📄 cmsflexrequest.java
字号:
* If there is more than one value defined,
* return only the first one.<p>
*
* @param name the name of the desired request parameter
* @return the value of the specified request parameter
* @see javax.servlet.ServletRequest#getParameter(java.lang.String)
*/
public String getParameter(String name) {
String[] values = (String[])m_parameters.get(name);
if (values != null) {
return (values[0]);
} else {
return (null);
}
}
/**
* Returns a <code>Map</code> of the parameters of this request.<p>
*
* Request parameters are extra information sent with the request.
* For HTTP servlets, parameters are contained in the query string
* or posted form data.<p>
*
* @return a <code>Map</code> containing parameter names as keys
* and parameter values as map values
* @see javax.servlet.ServletRequest#getParameterMap()
*/
public Map getParameterMap() {
return m_parameters;
}
/**
* Return the names of all defined request parameters for this request.<p>
*
* @return the names of all defined request parameters for this request
* @see javax.servlet.ServletRequest#getParameterNames()
*/
public Enumeration getParameterNames() {
Vector v = new Vector();
v.addAll(m_parameters.keySet());
return (v.elements());
}
/**
* Returns the defined values for the specified request parameter, if any;
* otherwise, return <code>null</code>.
*
* @param name Name of the desired request parameter
* @return the defined values for the specified request parameter, if any;
* <code>null</code> otherwise
* @see javax.servlet.ServletRequest#getParameterValues(java.lang.String)
*/
public String[] getParameterValues(String name) {
return (String[])m_parameters.get(name);
}
/**
* Allows requests to be dispatched to internal VFS resources or
* external JSP pages, overloads the standard servlet API <code>getRequestDispatcher()</code> method.<p>
*
* @param target the target for the request dispatcher
* @return a special RequestDispatcher that allows access to VFS resources
*/
public javax.servlet.RequestDispatcher getRequestDispatcher(String target) {
String absolutUri = CmsLinkManager.getAbsoluteUri(target, m_controller.getCurrentRequest().getElementUri());
return new CmsFlexRequestDispatcher(
m_controller.getTopRequest().getRequestDispatcher(absolutUri),
absolutUri,
null);
}
/**
* Replacement for the standard servlet API getRequestDispatcher() method.<p>
*
* This variation is used if an external file (probably JSP) is dispached to.
* This external file must have a "mirror" version, i.e. a file in the OpenCms VFS
* that represents the external file.<p>
*
* @param vfs_target the OpenCms file that is a "mirror" version of the external file
* @param ext_target the external file (outside the OpenCms VFS)
* @return the constructed CmsFlexRequestDispatcher
*/
public CmsFlexRequestDispatcher getRequestDispatcherToExternal(String vfs_target, String ext_target) {
return new CmsFlexRequestDispatcher(
m_controller.getTopRequest().getRequestDispatcher(ext_target),
CmsLinkManager.getAbsoluteUri(vfs_target, m_controller.getCmsObject().getRequestContext().getUri()),
ext_target);
}
/**
* Wraps the request URI, overloading the standard API.<p>
*
* This ensures that any wrapped request will use the "faked"
* target parameters. Remember that for the real request,
* a mixture of PathInfo and other request information is used to
* idenify the target.<p>
*
* @return a faked URI that will point to the wrapped target in the VFS
* @see javax.servlet.http.HttpServletRequest#getRequestURI()
*/
public String getRequestURI() {
if (m_requestUri != null) {
return m_requestUri;
}
StringBuffer buf = new StringBuffer(128);
buf.append(OpenCms.getSystemInfo().getOpenCmsContext());
buf.append(getElementUri());
m_requestUri = buf.toString();
return m_requestUri;
}
/**
* Wraps the request URL, overloading the standard API,
* the wrapped URL will always point to the currently included VFS resource.<p>
*
* @return a faked URL that will point to the included target in the VFS
* @see javax.servlet.http.HttpServletRequest#getRequestURL()
*/
public StringBuffer getRequestURL() {
if (m_requestUrl != null) {
return m_requestUrl;
}
StringBuffer buf = new StringBuffer(128);
buf.append(getScheme());
buf.append("://");
buf.append(getServerName());
buf.append(":");
buf.append(getServerPort());
buf.append(getRequestURI());
m_requestUrl = buf;
return m_requestUrl;
}
/**
* Checks if JSPs should always be recompiled.<p>
*
* This is useful in case directive based includes are used
* with <%@ include file="..." %> on a JSP.
* Note that this also forces the request not to be cached.<p>
*
* @return true if JSPs should be recompiled, false otherwise
*/
public boolean isDoRecompile() {
return m_doRecompile;
}
/**
* Indicates that this request belongs to an online project.<p>
*
* This is required to distinguish between online and offline
* resources in the cache. Since the resources have the same name,
* a suffix [online] or [offline] is added to distinguish the strings
* when building cache keys.
* Any resource from a request that isOnline() will be saved with
* the [online] suffix and vice versa.<p>
*
* Resources in the OpenCms workplace are not distinguised between
* online and offline but have their own suffix [workplace].
* The assumption is that if you do change the workplace, this is
* only on true development macines so you can do the cache clearing
* manually if required.<p>
*
* The suffixes are used so that we have a simple String name
* for the resources in the cache. This makes it easy to
* use a standard HashMap for storage of the resources.<p>
*
* @return true if an online resource was requested, false otherwise
*/
public boolean isOnline() {
return m_isOnline;
}
/**
* Sets the specified Map as paramter map of the request.<p>
*
* The map set should be immutable.
* This will completly replace the parameter map.
* Use this in combination with getParameterMap() and
* addParameterMap() in case you want to set the old status
* of the parameter map after you have modified it for
* a specific operation.<p>
*
* @param map the map to set
*/
public void setParameterMap(Map map) {
m_parameters = map;
}
/**
* @see java.lang.Object#toString()
*/
public String toString() {
// return the uri of the element requested for this request, useful in debugging
return m_elementUri;
}
/**
* Returns the List of include calls which will be passed to the next wrapping layer.<p>
*
* The set of include calls is maintained to dectect
* an endless inclusion loop.<p>
*
* @return the List of include calls
*/
protected List getCmsIncludeCalls() {
return m_includeCalls;
}
/**
* Adds another include call to this wrapper.<p>
*
* The set of include calls is maintained to dectect
* an endless inclusion loop.<p>
*
* @param target the target name (absolute OpenCms URI) to add
*/
void addInlucdeCall(String target) {
m_includeCalls.add(target);
}
/**
* Checks if a given target is already included in a top-layer of this
* wrapped request.<p>
*
* The set of include calls is maintained to dectect
* an endless inclusion loop.<p>
*
* @param target the target name (absolute OpenCms URI) to check for
* @return true if the target is already included, false otherwise
*/
boolean containsIncludeCall(String target) {
return m_includeCalls.contains(target);
}
/**
* Returns the CmsFlexCacheKey for this request,
* the key will be calculated if neccessary.<p>
*
* @return the CmsFlexCacheKey for this request
*/
CmsFlexRequestKey getCmsCacheKey() {
// The key for this request is only calculated if actually requested
if (m_key == null) {
m_key = new CmsFlexRequestKey(this, m_elementUri, m_isOnline);
}
return m_key;
}
/**
* This is needed to decide if this request can be cached or not.<p>
*
* Using the request to decide if caching is used or not
* makes it possible to set caching to false e.g. on a per-user
* or per-project basis.<p>
*
* @return true if the request is cacheable, false otherwise
*/
boolean isCacheable() {
return m_canCache;
}
/**
* Removes an include call from this wrapper.<p>
*
* The set of include calls is maintained to dectect
* an endless inclusion loop.<p>
*
* @param target the target name (absolute OpenCms URI) to remove
*/
void removeIncludeCall(String target) {
m_includeCalls.remove(target);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -