/** * Executes this action with the given HTTP request and returns the result. * * @param req the http request with which to execute this action * @return a promise to the action's result */ public CompletionStage<Result> call(Request req) { // TODO: Make this method abstract after removing call(Context) return Context.safeCurrent().map(threadLocalCtx -> { // A previous action did explicitly set a context onto the thread local (via Http.Context.current.set(...)) // Let's use that context so the user doesn't loose data he/she set onto that ctx (args,...) Context newCtx = threadLocalCtx.withRequest(req.removeAttr(CTX_ARGS)); Context.setCurrent(newCtx); return call(newCtx); }).orElseGet(() -> { // A previous action did not set a context explicitly, we simply create a new one to pass on the request Context ctx = new Context(req.removeAttr(CTX_ARGS), contextComponents); ctx.args = req.attrs().getOptional(CTX_ARGS).orElse(new HashMap<>()); return call(ctx); }); }
/** * Executes this action with the given HTTP request and returns the result. * * @param req the http request with which to execute this action * @return a promise to the action's result */ public CompletionStage<Result> call(Request req) { // TODO: Make this method abstract after removing call(Context) return Context.safeCurrent().map(threadLocalCtx -> { // A previous action did explicitly set a context onto the thread local (via Http.Context.current.set(...)) // Let's use that context so the user doesn't loose data he/she set onto that ctx (args,...) Context newCtx = threadLocalCtx.withRequest(req.removeAttr(CTX_ARGS)); Context.setCurrent(newCtx); return call(newCtx); }).orElseGet(() -> { // A previous action did not set a context explicitly, we simply create a new one to pass on the request Context ctx = new Context(req.removeAttr(CTX_ARGS), contextComponents); ctx.args = req.attrs().getOptional(CTX_ARGS).orElse(new HashMap<>()); return call(ctx); }); }
/** * Executes this action with the given HTTP request and returns the result. * * @param req the http request with which to execute this action * @return a promise to the action's result */ public CompletionStage<Result> call(Request req) { // TODO: Make this method abstract after removing call(Context) return Context.safeCurrent().map(threadLocalCtx -> { // A previous action did explicitly set a context onto the thread local (via Http.Context.current.set(...)) // Let's use that context so the user doesn't loose data he/she set onto that ctx (args,...) Context newCtx = threadLocalCtx.withRequest(req.removeAttr(CTX_ARGS)); Context.setCurrent(newCtx); return call(newCtx); }).orElseGet(() -> { // A previous action did not set a context explicitly, we simply create a new one to pass on the request Context ctx = new Context(req.removeAttr(CTX_ARGS), contextComponents); ctx.args = req.attrs().getOptional(CTX_ARGS).orElse(new HashMap<>()); return call(ctx); }); }
@Override public DynamicForm bindFromRequest(Http.Request request, String... allowedFields) { return bind(this.messagesApi.preferred(request).lang(), request.attrs(), requestData(request), requestFileData(request), allowedFields); }
@Override public DynamicForm bindFromRequest(Http.Request request, String... allowedFields) { return bind(this.messagesApi.preferred(request).lang(), request.attrs(), requestData(request), requestFileData(request), allowedFields); }
@Override public DynamicForm bindFromRequest(Http.Request request, String... allowedFields) { return bind(this.messagesApi.preferred(request).lang(), request.attrs(), requestData(request), requestFileData(request), allowedFields); }
/** * Binds request data to this form - that is, handles form submission. * * @param request the request to bind data from. * @param allowedFields the fields that should be bound to the form, all fields if not specified. * @return a copy of this form filled with the new data */ public Form<T> bindFromRequest(Http.Request request, String... allowedFields) { return bind(this.messagesApi.preferred(request).lang(), request.attrs(), requestData(request), requestFileData(request), allowedFields); }
@Override @Deprecated public DynamicForm bindFromRequest(String... allowedFields) { return bind(play.mvc.Controller.ctx().messages().lang(), play.mvc.Controller.request().attrs(), requestData(play.mvc.Controller.request()), requestFileData(play.mvc.Controller.request()), allowedFields); }
/** * @deprecated Deprecated as of 2.7.0. */ @Deprecated protected TypedMap ctxRequestAttrs() { return Http.Context.safeCurrent().map(ctx -> ctx.request().attrs()).orElseGet(() -> TypedMap.empty()); }
@Override @Deprecated public DynamicForm bindFromRequest(String... allowedFields) { return bind(play.mvc.Controller.ctx().messages().lang(), play.mvc.Controller.request().attrs(), requestData(play.mvc.Controller.request()), requestFileData(play.mvc.Controller.request()), allowedFields); }
@Override @Deprecated public DynamicForm bindFromRequest(String... allowedFields) { return bind(play.mvc.Controller.ctx().messages().lang(), play.mvc.Controller.request().attrs(), requestData(play.mvc.Controller.request()), requestFileData(play.mvc.Controller.request()), allowedFields); }
/** * Binds request data to this form - that is, handles form submission. * * @param allowedFields the fields that should be bound to the form, all fields if not specified. * @return a copy of this form filled with the new data * * @deprecated Deprecated as of 2.7.0. Use {@link #bindFromRequest(Http.Request, String...)} instead. */ @Deprecated public Form<T> bindFromRequest(String... allowedFields) { return bind(play.mvc.Controller.ctx().messages().lang(), play.mvc.Controller.request().attrs(), requestData(play.mvc.Controller.request()), requestFileData(play.mvc.Controller.request()), allowedFields); }
/** * Binds request data to this form - that is, handles form submission. * * @param request the request to bind data from. * @param allowedFields the fields that should be bound to the form, all fields if not specified. * @return a copy of this form filled with the new data */ public Form<T> bindFromRequest(Http.Request request, String... allowedFields) { return bind(this.messagesApi.preferred(request).lang(), request.attrs(), requestData(request), requestFileData(request), allowedFields); }
/** * Binds request data to this form - that is, handles form submission. * * @param allowedFields the fields that should be bound to the form, all fields if not specified. * @return a copy of this form filled with the new data * * @deprecated Deprecated as of 2.7.0. Use {@link #bindFromRequest(Http.Request, String...)} instead. */ @Deprecated public Form<T> bindFromRequest(String... allowedFields) { return bind(play.mvc.Controller.ctx().messages().lang(), play.mvc.Controller.request().attrs(), requestData(play.mvc.Controller.request()), requestFileData(play.mvc.Controller.request()), allowedFields); }
/** * @deprecated Deprecated as of 2.7.0. */ @Deprecated protected TypedMap ctxRequestAttrs() { return Http.Context.safeCurrent().map(ctx -> ctx.request().attrs()).orElseGet(() -> TypedMap.empty()); }
/** * @deprecated Deprecated as of 2.7.0. */ @Deprecated protected TypedMap ctxRequestAttrs() { return Http.Context.safeCurrent().map(ctx -> ctx.request().attrs()).orElseGet(() -> TypedMap.empty()); }
@Override public Object getRequestAttribute(final String name) { Object value = context.args.get(name); // for the user profiles, if we don't get a value from the context.args, we try from the attributes (call after the SecurityFilter) if (Pac4jConstants.USER_PROFILES.equals(name) && value == null) { final Optional<Object> optionalValue = request.attrs().getOptional(PAC4J_USER_PROFILES); if (optionalValue.isPresent()) { value = optionalValue.get(); } } return value; }
@Override public Object getRequestAttribute(final String name) { Object value = context.args.get(name); // for the user profiles, if we don't get a value from the context.args, we try from the attributes (call after the SecurityFilter) if (Pac4jConstants.USER_PROFILES.equals(name) && value == null) { final Optional<Object> optionalValue = request.attrs().getOptional(PAC4J_USER_PROFILES); if (optionalValue.isPresent()) { value = optionalValue.get(); } } return value; }
/** * Binds request data to this form - that is, handles form submission. * * @param allowedFields the fields that should be bound to the form, all fields if not specified. * @return a copy of this form filled with the new data * * @deprecated Deprecated as of 2.7.0. Use {@link #bindFromRequest(Http.Request, String...)} instead. */ @Deprecated public Form<T> bindFromRequest(String... allowedFields) { return bind(play.mvc.Controller.ctx().messages().lang(), play.mvc.Controller.request().attrs(), requestData(play.mvc.Controller.request()), requestFileData(play.mvc.Controller.request()), allowedFields); }
/** * Binds request data to this form - that is, handles form submission. * * @param request the request to bind data from. * @param allowedFields the fields that should be bound to the form, all fields if not specified. * @return a copy of this form filled with the new data */ public Form<T> bindFromRequest(Http.Request request, String... allowedFields) { return bind(this.messagesApi.preferred(request).lang(), request.attrs(), requestData(request), requestFileData(request), allowedFields); }