1 31 32 package org.opencms.flex; 33 34 import org.opencms.file.CmsObject; 35 import org.opencms.file.CmsRequestContext; 36 import org.opencms.loader.I_CmsResourceLoader; 37 import org.opencms.main.CmsLog; 38 39 import java.util.Map ; 40 41 import javax.servlet.http.HttpServletRequest ; 42 import javax.servlet.http.HttpSession ; 43 44 import org.apache.commons.logging.Log; 45 46 55 public class CmsFlexRequestKey { 56 57 58 private static final Log LOG = CmsLog.getLog(CmsFlexRequestKey.class); 59 60 61 private CmsRequestContext m_context; 62 63 64 private HttpServletRequest m_request; 65 66 67 private String m_resource; 68 69 81 public CmsFlexRequestKey(HttpServletRequest req, String target, boolean online) { 82 83 m_request = req; 85 86 CmsObject cms = CmsFlexController.getCmsObject(req); 88 89 m_context = cms.getRequestContext(); 91 92 m_resource = CmsFlexCacheKey.getKeyName(m_context.addSiteRoot(target), online); 94 95 if (LOG.isDebugEnabled()) { 96 LOG.debug(Messages.get().getBundle().key(Messages.LOG_FLEXREQUESTKEY_CREATED_NEW_KEY_1, m_resource)); 97 } 98 } 99 100 105 public String getElement() { 106 107 return m_request.getParameter(I_CmsResourceLoader.PARAMETER_ELEMENT); 108 } 109 110 115 public String getEncoding() { 116 117 return m_context.getEncoding(); 118 } 119 120 125 public String getIp() { 126 127 return m_context.getRemoteAddress(); 128 } 129 130 135 public String getLocale() { 136 137 return m_context.getLocale().toString(); 138 } 139 140 145 public Map getParams() { 146 147 Map params = m_request.getParameterMap(); 149 if (params.size() == 0) { 150 return null; 151 } 152 return params; 153 } 154 155 160 public Integer getPort() { 161 162 return new Integer (m_request.getServerPort()); 163 } 164 165 170 public String getResource() { 171 172 return m_resource; 173 } 174 175 180 public String getScheme() { 181 182 return m_request.getScheme().toLowerCase(); 183 } 184 185 191 public HttpSession getSession() { 192 193 return m_request.getSession(false); 194 } 195 196 201 public String getSite() { 202 203 return m_context.getSiteRoot(); 204 } 205 206 211 public String getUri() { 212 213 return m_context.addSiteRoot(m_context.getUri()); 214 } 215 216 221 public String getUser() { 222 223 return m_context.currentUser().getName(); 224 } 225 } | Popular Tags |