String gateInPortalKey = Environment.class.getName() + ".isGateInPortal.gateInPortal";
Boolean gateInPortal = (Boolean) applicationMap.get(gateInPortalKey);
if (gateInPortal == null)
try {
Object request = externalContext.getRequest();
PortalContext portalContext;
if (request instanceof RenderRequest)
portalContext = ((RenderRequest) request).getPortalContext();
else if (request instanceof ActionRequest)
portalContext = ((ActionRequest) request).getPortalContext();
else
portalContext = null;
gateInPortal = portalContext != null && portalContext.getPortalInfo().contains("GateIn");
} catch (NoClassDefFoundError e) {
gateInPortal = false;
}
applicationMap.put(gateInPortalKey, gateInPortal);
return gateInPortal;