it.eng.spago.base.PortletAccess Maven / Gradle / Ivy
/**
Copyright 2004, 2007 Engineering Ingegneria Informatica S.p.A.
This file is part of Spago.
Spago is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
any later version.
Spago is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with Spago; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
**/
package it.eng.spago.base;
import java.util.Locale;
import javax.portlet.PortletConfig;
import javax.portlet.PortletRequest;
import javax.portlet.PortletResponse;
import javax.portlet.PortletSession;
public class PortletAccess {
static ThreadLocal portletRequest = new ThreadLocal();
static ThreadLocal portletResponse = new ThreadLocal();
static PortletConfig portletConfig = null;
//static ThreadLocal browserLocale = new ThreadLocal();
//static Locale portalLocale = null;
static public void setPortletRequest(PortletRequest req) {
portletRequest.set(req);
}
static public void setPortletResponse(PortletResponse resp) {
portletResponse.set(resp);
}
// static public void setBrowserLocale(Locale local) {
// browserLocale.set(local);
// }
// static public void setPortalLocale(Locale local) {
// portalLocale = local;
// }
static public void setPortletConfig(PortletConfig conf) {
portletConfig = conf;
}
static public PortletRequest getPortletRequest() {
PortletRequest request = null;
try{
request = (PortletRequest)portletRequest.get();
} catch(Exception e) {
// ignore
}
return request;
}
static public PortletResponse getPortletResponse() {
PortletResponse response = null;
try {
response = (PortletResponse)portletResponse.get();
} catch (Exception e) {
// ignore
}
return response;
}
static public PortletConfig getPortletConfig() {
return portletConfig;
}
static public Locale getBrowserLocale() {
PortletRequest request = null;
try{
request = (PortletRequest) portletRequest.get();
} catch(Exception e) {
// ignore
}
PortletSession portletSession = request.getPortletSession();
Locale browserLocale = (Locale) portletSession.getAttribute("BrowserLocale");
return browserLocale;
// Locale locale = null;
// try {
// locale = (Locale)browserLocale.get();
// } catch (Exception e) {
// // ignore
// }
// return locale;
}
static public Locale getPortalLocale() {
PortletRequest request = null;
try{
request = (PortletRequest) portletRequest.get();
} catch(Exception e) {
// ignore
}
PortletSession portletSession = request.getPortletSession();
Locale portalLocale = (Locale) portletSession.getAttribute("PortalLocale");
return portalLocale;
// return portalLocale;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy