Search in sources :

Example 1 with HttpGraniteContext

use of org.granite.messaging.webapp.HttpGraniteContext in project collect by openforis.

the class SaikuService method getSaikuUrl.

public String getSaikuUrl() {
    HttpGraniteContext graniteContext = (HttpGraniteContext) GraniteContext.getCurrentInstance();
    HttpServletRequest request = graniteContext.getRequest();
    String protocol = request.isSecure() ? "https" : "http";
    String localAddr = request.getLocalAddr();
    if (DEV_REQUEST_LOCAL_ADDRESS.equals(localAddr)) {
        localAddr = DEV_LOCAL_ADDRESS;
    }
    String url = String.format(SAIKU_URL_FORMAT, protocol, localAddr, request.getLocalPort(), saikuConfiguration.getContextPath());
    return url;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) HttpGraniteContext(org.granite.messaging.webapp.HttpGraniteContext)

Example 2 with HttpGraniteContext

use of org.granite.messaging.webapp.HttpGraniteContext in project collect by openforis.

the class SessionManager method invalidateSession.

public void invalidateSession() {
    try {
        releaseRecord();
    } catch (RecordUnlockedException e) {
    // do nothing
    }
    GraniteContext graniteContext = GraniteContext.getCurrentInstance();
    if (graniteContext != null && graniteContext instanceof HttpGraniteContext) {
        HttpGraniteContext httpGraniteContext = (HttpGraniteContext) graniteContext;
        HttpServletRequest request = httpGraniteContext.getRequest();
        HttpSession session = request.getSession();
        session.invalidate();
    }
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) GraniteContext(org.granite.context.GraniteContext) HttpGraniteContext(org.granite.messaging.webapp.HttpGraniteContext) HttpSession(javax.servlet.http.HttpSession) RecordUnlockedException(org.openforis.collect.persistence.RecordUnlockedException) HttpGraniteContext(org.granite.messaging.webapp.HttpGraniteContext)

Example 3 with HttpGraniteContext

use of org.granite.messaging.webapp.HttpGraniteContext in project collect by openforis.

the class AttributeChangeProxy method getContextBean.

protected <T extends Object> T getContextBean(Class<T> type) {
    HttpGraniteContext graniteContext = (HttpGraniteContext) GraniteContext.getCurrentInstance();
    ServletContext servletContext = graniteContext.getServletContext();
    WebApplicationContext applicationContext = WebApplicationContextUtils.getWebApplicationContext(servletContext);
    T bean = applicationContext.getBean(type);
    return bean;
}
Also used : ServletContext(javax.servlet.ServletContext) HttpGraniteContext(org.granite.messaging.webapp.HttpGraniteContext) WebApplicationContext(org.springframework.web.context.WebApplicationContext)

Aggregations

HttpGraniteContext (org.granite.messaging.webapp.HttpGraniteContext)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 ServletContext (javax.servlet.ServletContext)1 HttpSession (javax.servlet.http.HttpSession)1 GraniteContext (org.granite.context.GraniteContext)1 RecordUnlockedException (org.openforis.collect.persistence.RecordUnlockedException)1 WebApplicationContext (org.springframework.web.context.WebApplicationContext)1