Example usage for org.springframework.web.context.request WebRequest getAttribute

List of usage examples for org.springframework.web.context.request WebRequest getAttribute

Introduction

In this page you can find the example usage for org.springframework.web.context.request WebRequest getAttribute.

Prototype

@Nullable
Object getAttribute(String name, int scope);

Source Link

Document

Return the value for the scoped attribute of the given name, if any.

Usage

From source file:org.sarons.spring4me.web.page.utils.PageConfigUtils.java

public static PageConfig getPageConfig(WebRequest webRequest) {
    return (PageConfig) webRequest.getAttribute(PageConfig.KEY, WebRequest.SCOPE_SESSION);
}

From source file:org.focusns.web.helper.WebRequestHelper.java

public static Project getProject(WebRequest webRequest) {
    return (Project) webRequest.getAttribute("project", WebRequest.SCOPE_SESSION);
}

From source file:org.focusns.web.helper.WebRequestHelper.java

public static ProjectFeature getProjectFeature(WebRequest webRequest) {
    return (ProjectFeature) webRequest.getAttribute("feature", WebRequest.SCOPE_SESSION);
}

From source file:org.mytms.common.web.util.RequestUtil.java

/**
 * Broadleaf "Resolver" and "Filter" classes may need to know if they are allowed to utilize the session.
 * BLC uses a pattern where we will store an attribute in the request indicating whether or not the
 * session can be used.   For example, when using the REST APIs, we typically do not want to utilize the
 * session.//from   ww w .  j a  va  2 s . co  m
 */
public static boolean isOKtoUseSession(WebRequest request) {
    Boolean useSessionForRequestProcessing = (Boolean) request.getAttribute(OK_TO_USE_SESSION,
            WebRequest.SCOPE_REQUEST);
    if (useSessionForRequestProcessing == null) {
        // by default we will use the session
        return true;
    } else {
        return useSessionForRequestProcessing.booleanValue();
    }
}

From source file:org.mytms.common.web.util.RequestUtil.java

/**
 * Takes {@link #isOKtoUseSession(WebRequest)} into account when retrieving session attributes. If it's not ok, this
 * will return null//from  w  ww  .  j  a va 2  s.c o m
 */
public static Object getSessionAttributeIfOk(WebRequest request, String attribute) {
    if (isOKtoUseSession(request)) {
        return request.getAttribute(attribute, WebRequest.SCOPE_GLOBAL_SESSION);
    }
    return null;
}

From source file:com.kdubb.socialshowcaseboot.twitter.TweetAfterConnectInterceptor.java

public void postConnect(Connection<Twitter> connection, WebRequest request) {
    if (request.getAttribute(POST_TWEET_ATTRIBUTE, WebRequest.SCOPE_SESSION) != null) {
        try {/*from   ww w.  java  2 s . c  o  m*/
            connection.updateStatus("I've connected with the Spring Social Showcase!");
        } catch (DuplicateStatusException e) {
        }
        request.removeAttribute(POST_TWEET_ATTRIBUTE, WebRequest.SCOPE_SESSION);
    }
}

From source file:eu.gyza.eap.eapsocialontology.twitter.TweetAfterConnectInterceptor.java

public void postConnect(Connection<Twitter> connection, WebRequest request) {
    if (request.getAttribute(POST_TWEET_ATTRIBUTE, WebRequest.SCOPE_SESSION) != null) {
        try {//from w ww.  j av a  2s  .  com
            connection.updateStatus("I've connected with the EAP Social Ontology!");
        } catch (DuplicateStatusException e) {
        }
        request.removeAttribute(POST_TWEET_ATTRIBUTE, WebRequest.SCOPE_SESSION);
    }
}

From source file:org.fuzzydb.samples.social.TweetAfterConnectInterceptor.java

public void postConnect(Connection<Twitter> connection, WebRequest request) {
    if (request.getAttribute(POST_TWEET_ATTRIBUTE, WebRequest.SCOPE_SESSION) != null) {
        try {/*from w  ww .j  a  va 2 s  .co m*/
            connection.updateStatus("I've connected with the @fuzzydb sample webapp");
        } catch (DuplicateStatusException e) {
        }
        request.removeAttribute(POST_TWEET_ATTRIBUTE, WebRequest.SCOPE_SESSION);
    }
}

From source file:rd.kpath.twitter.TweetAfterConnectInterceptor.java

public void postConnect(Connection<Twitter> connection, WebRequest request) {
    if (request.getAttribute(POST_TWEET_ATTRIBUTE, WebRequest.SCOPE_SESSION) != null) {
        try {/*from   w w  w .jav  a 2  s  .co m*/
            connection.updateStatus("I've connected with the K-Path!");
        } catch (DuplicateStatusException e) {
        }
        request.removeAttribute(POST_TWEET_ATTRIBUTE, WebRequest.SCOPE_SESSION);
    }
}

From source file:com.kdubb.socialshowcaseboot.facebook.PostToWallAfterConnectInterceptor.java

public void postConnect(Connection<Facebook> connection, WebRequest request) {
    if (request.getAttribute(POST_TO_WALL_ATTRIBUTE, WebRequest.SCOPE_SESSION) != null) {
        try {//from www .java  2 s . c o  m
            connection.updateStatus("I've connected with the Spring Social Showcase!");
        } catch (ApiException e) {
            // Do nothing: No need to break down if the post-connect post can't be made.
        }
        request.removeAttribute(POST_TO_WALL_ATTRIBUTE, WebRequest.SCOPE_SESSION);
    }
}