/** * The transient language will be taken into account when using {@link MessagesApi#preferred(RequestHeader)}} (It will take precedence over any other language). * * @return The current transient language of this request. */ default Optional<Lang> transientLang() { return attrs().getOptional(Messages.Attrs.CurrentLang).map(play.api.i18n.Lang::asJava); }
/** * The transient language will be taken into account when using {@link MessagesApi#preferred(RequestHeader)}} (It will take precedence over any other language). * * @return The current transient language of this request. */ default Optional<Lang> transientLang() { return attrs().getOptional(Messages.Attrs.CurrentLang).map(play.api.i18n.Lang::asJava); }
/** * The transient language will be taken into account when using {@link MessagesApi#preferred(RequestHeader)}} (It will take precedence over any other language). * * @return The current transient language of this request. */ default Optional<Lang> transientLang() { return attrs().getOptional(Messages.Attrs.CurrentLang).map(play.api.i18n.Lang::asJava); }
/** * If a constraint is defined for a given route, test that constraint before allowing the request to proceed. * * @param next the next step in the filter chain * @param requestHeader the request header * @return a future for the result */ @Override public CompletionStage<Result> apply(final Function<Http.RequestHeader, CompletionStage<Result>> next, final Http.RequestHeader requestHeader) { final HandlerDef handlerDef = requestHeader.attrs().get(Router.Attrs.HANDLER_DEF); final List<String> deadboltModifierTags = handlerDef.getModifiers().stream().filter(mt -> mt != null && mt.startsWith("deadbolt:")).collect(Collectors.toList()); return processModifierTags(deadboltModifierTags, 0, requestHeader, next); }
/** * If a constraint is defined for a given route, test that constraint before allowing the request to proceed. * * @param next the next step in the filter chain * @param requestHeader the request header * @return a future for the result */ @Override public CompletionStage<Result> apply(final Function<Http.RequestHeader, CompletionStage<Result>> next, final Http.RequestHeader requestHeader) { final HandlerDef handlerDef = requestHeader.attrs().get(Router.Attrs.HANDLER_DEF); final List<String> deadboltModifierTags = handlerDef.getModifiers().stream().filter(mt -> mt != null && mt.startsWith("deadbolt:")).collect(Collectors.toList()); return processModifierTags(deadboltModifierTags, 0, requestHeader, next); }
/** * Get the deferred action from the request. * * @param request the request * @return a tuple containing the deferred action (or null if it doesn't exist) and the cleaned up request you should pass on */ @SuppressWarnings("unchecked") public F.Tuple<AbstractDeadboltAction<?>, Http.RequestHeader> getDeferredAction(final Http.RequestHeader request) { return request.attrs().getOptional(ACTION_DEFERRED).map(action -> { action.delegate = this; return F.<AbstractDeadboltAction<?>, Http.RequestHeader>Tuple(action, request.removeAttr(ACTION_DEFERRED).addAttr(IGNORE_DEFERRED_FLAG, true)); }).orElseGet(() -> F.Tuple(null, request)); }
/** * Checks if an action is authorised. This allows controller-level annotations to cede control to method-level annotations. * * @param request the request * @return true if a more-specific annotation has authorised access, otherwise false */ protected static boolean isAuthorised(final Http.RequestHeader request) { return request.attrs().getOptional(ACTION_AUTHORISED).orElse(false); }
@Override public Object getAttribute(final String name) { return ofNullable(attributes.get(name)) .orElseGet(() -> playDelegate.attrs().getOptional(TypedKey.create(name)).orElse(null)); }
/** * Check if there is a deferred action in the request. * * @param request the request * @return true if there is a deferred action in the request */ public boolean isDeferred(final Http.RequestHeader request) { return request.attrs().containsKey(ACTION_DEFERRED); }
/** * Checks if an action is authorised. This allows controller-level annotations to cede control to method-level annotations. * * @param request the request * @return true if a more-specific annotation has authorised access, otherwise false */ protected static boolean isAuthorised(final Http.RequestHeader request) { return request.attrs().getOptional(ACTION_AUTHORISED).orElse(false); }
/** * Check if there is a deferred action in the request. * * @param request the request * @return true if there is a deferred action in the request */ public boolean isDeferred(final Http.RequestHeader request) { return request.attrs().containsKey(ACTION_DEFERRED); }
/** * Parses the Session cookie and returns the Session data. The request's session cookie is stored in an attribute indexed by * {@link RequestAttrKey#Session()}. The attribute uses a {@link Cell} to store the session cookie, to allow it to be evaluated on-demand. */ default Session session() { return attrs().get(RequestAttrKey.Session().asJava()).value().asJava(); }
/** * The request id. The request id is stored as an attribute indexed by {@link RequestAttrKey#Id()}. */ default Long id() { return (Long) attrs().get(RequestAttrKey.Id().asJava()); }
/** * The request id. The request id is stored as an attribute indexed by {@link RequestAttrKey#Id()}. */ default Long id() { return (Long) attrs().get(RequestAttrKey.Id().asJava()); }
/** * Parses the Flash cookie and returns the Flash data. The request's flash cookie is stored in an attribute indexed by * {@link RequestAttrKey#Flash()}}. The attribute uses a {@link Cell} to store the flash, to allow it to be evaluated on-demand. */ default Flash flash() { return attrs().get(RequestAttrKey.Flash().asJava()).value().asJava(); }
/** * Parses the Flash cookie and returns the Flash data. The request's flash cookie is stored in an attribute indexed by * {@link RequestAttrKey#Flash()}}. The attribute uses a {@link Cell} to store the flash, to allow it to be evaluated on-demand. */ default Flash flash() { return attrs().get(RequestAttrKey.Flash().asJava()).value().asJava(); }
/** * Parses the Session cookie and returns the Session data. The request's session cookie is stored in an attribute indexed by * {@link RequestAttrKey#Session()}. The attribute uses a {@link Cell} to store the session cookie, to allow it to be evaluated on-demand. */ default Session session() { return attrs().get(RequestAttrKey.Session().asJava()).value().asJava(); }
/** * The request id. The request id is stored as an attribute indexed by {@link RequestAttrKey#Id()}. */ default Long id() { return (Long) attrs().get(RequestAttrKey.Id().asJava()); }
/** * Parses the Flash cookie and returns the Flash data. The request's flash cookie is stored in an attribute indexed by * {@link RequestAttrKey#Flash()}}. The attribute uses a {@link Cell} to store the flash, to allow it to be evaluated on-demand. */ default Flash flash() { return attrs().get(RequestAttrKey.Flash().asJava()).value().asJava(); }
/** * Parses the Session cookie and returns the Session data. The request's session cookie is stored in an attribute indexed by * {@link RequestAttrKey#Session()}. The attribute uses a {@link Cell} to store the session cookie, to allow it to be evaluated on-demand. */ default Session session() { return attrs().get(RequestAttrKey.Session().asJava()).value().asJava(); }