📄 cmsworkplace.java
字号:
m_parameterMap = CmsRequestUtil.readParameterMapFromMultiPart(
getCms().getRequestContext().getEncoding(),
m_multiPartFileItems);
request.setAttribute(REQUEST_ATTRIBUTE_MULTIPART, Boolean.TRUE);
}
}
if (m_parameterMap == null) {
// the request was a "normal" request
m_parameterMap = request.getParameterMap();
}
List methods = paramSetMethods();
Iterator i = methods.iterator();
while (i.hasNext()) {
Method m = (Method)i.next();
String name = m.getName().substring(8).toLowerCase();
String[] values = (String[])m_parameterMap.get(name);
String value = null;
if (values != null) {
// get the parameter value from the map
value = values[0];
}
if (CmsStringUtil.isEmpty(value)) {
value = null;
}
value = decodeParamValue(name, value);
try {
if (LOG.isDebugEnabled() && (value != null)) {
LOG.debug(Messages.get().getBundle().key(Messages.LOG_SET_PARAM_2, m.getName(), value));
}
m.invoke(this, new Object[] {value});
} catch (InvocationTargetException ite) {
// can usually be ignored
if (LOG.isInfoEnabled()) {
LOG.info(ite.getLocalizedMessage());
}
} catch (IllegalAccessException eae) {
// can usually be ignored
if (LOG.isInfoEnabled()) {
LOG.info(eae.getLocalizedMessage());
}
}
}
}
/**
* Returns the message String for the broadcast message alert of the workplace.<p>
*
* Caution: returns the pure message String (not escaped) or null, if no message is pending.<p>
*
* @return the message String for the broadcast message alert of the workplace
*/
public String getBroadcastMessageString() {
String sessionId = getSession().getId();
Buffer messageQueue = OpenCms.getSessionManager().getBroadcastQueue(sessionId);
if (!messageQueue.isEmpty()) {
// create message String
StringBuffer result = new StringBuffer(512);
// the user has pending messages, display them all
while (!messageQueue.isEmpty()) {
CmsBroadcast message = (CmsBroadcast)messageQueue.remove();
result.append('[');
result.append(getMessages().getDateTime(message.getSendTime()));
result.append("] ");
result.append(key(Messages.GUI_LABEL_BROADCASTMESSAGEFROM_0));
result.append(' ');
result.append(message.getUser().getName());
result.append(":\n");
result.append(message.getMessage());
result.append("\n\n");
}
return result.toString();
}
// no message pending, return null
return null;
}
/**
* Returns the initialized cms object for the current user.<p>
*
* @return the initialized cms object for the current user
*/
public CmsObject getCms() {
return m_cms;
}
/**
* Returns the current workplace encoding.<p>
*
* @return the current workplace encoding
*/
public String getEncoding() {
return OpenCms.getWorkplaceManager().getEncoding();
}
/**
* Returns the uri (including context path) to the explorer file list.<p>
*
* @return the uri (including context path) to the explorer file list
*/
public String getExplorerFileListFullUri() {
if (m_file_explorer_filelist != null) {
return m_file_explorer_filelist;
}
synchronized (this) {
m_file_explorer_filelist = OpenCms.getLinkManager().substituteLink(getCms(), FILE_EXPLORER_FILELIST);
}
return m_file_explorer_filelist;
}
/**
* Returns the html for the frame name and source and stores this information in the workplace settings.<p>
*
* @param frameName the name of the frame
* @param uri the absolute path of the frame
* @return the html for the frame name and source
*/
public String getFrameSource(String frameName, String uri) {
String frameString = "name=\"" + frameName + "\" src=\"" + uri + "\"";
int paramIndex = uri.indexOf("?");
if (paramIndex != -1) {
// remove request parameters from URI before putting it to Map
uri = uri.substring(0, uri.indexOf("?"));
}
getSettings().getFrameUris().put(frameName, uri);
return frameString;
}
/**
* Returns the JSP action element.<p>
*
* @return the JSP action element
*/
public CmsJspActionElement getJsp() {
return m_jsp;
}
/**
* Returns the current users workplace locale settings.<p>
*
* @return the current users workplace locale setting
*/
public Locale getLocale() {
return m_settings.getUserSettings().getLocale();
}
/**
* Returns the current used macro resolver instance.<p>
*
* @return the macro resolver
*/
public CmsMacroResolver getMacroResolver() {
if (m_macroResolver == null) {
// create a new macro resolver "with everything we got"
m_macroResolver = CmsMacroResolver.newInstance()
// initialize resolver with the objects available
.setCmsObject(m_cms).setMessages(getMessages()).setJspPageContext(
(m_jsp == null) ? null : m_jsp.getJspContext());
}
return m_macroResolver;
}
/**
* Returns the current used message object.<p>
*
* @return the current used message object
*/
public CmsMessages getMessages() {
return m_messages;
}
/**
* Returns a list of FileItem instances parsed from the request, in the order that they were transmitted.<p>
*
* This list is automatically initialized from the createParameterMapFromMultiPart(HttpServletRequest) method.<p>
*
* @return list of FileItem instances parsed from the request, in the order that they were transmitted
*/
public List getMultiPartFileItems() {
return m_multiPartFileItems;
}
/**
* Returns the path to the workplace static resources.<p>
*
* Workplaces static resources are images, css files etc.
* These are exported during the installation of OpenCms,
* and are usually only read from this exported location to
* avoid the overhaead of accessing the database later.<p>
*
* @return the path to the workplace static resources
*/
public String getResourceUri() {
if (m_resourceUri == null) {
m_resourceUri = OpenCms.getSystemInfo().getContextPath() + CmsWorkplace.RFS_PATH_RESOURCES;
}
return m_resourceUri;
}
/**
* Returns the current user http session.<p>
*
* @return the current user http session
*/
public HttpSession getSession() {
return m_session;
}
/**
* Returns the current users workplace settings.<p>
*
* @return the current users workplace settings
*/
public CmsWorkplaceSettings getSettings() {
return m_settings;
}
/**
* Returns the path to the cascading stylesheets.<p>
*
* @param filename the name of the stylesheet
* @return the path to the cascading stylesheets
*/
public String getStyleUri(String filename) {
return getStyleUri(getJsp(), filename);
}
/**
* Builds the end html of the page.<p>
*
* @return the end html of the page
*/
public String htmlEnd() {
return pageHtml(HTML_END, null);
}
/**
* Builds the start html of the page, including setting of DOCTYPE and
* inserting a header with the content-type.<p>
*
* @param title the content for the title tag
* @return the start html of the page
*/
public String htmlStart(String title) {
return pageHtml(HTML_START, title);
}
/**
* Sets site and project in the workplace settings with the request values of parameters
* <code>{@link CmsWorkplace#PARAM_WP_SITE}</code> and <code>{@link CmsWorkplace#PARAM_WP_PROJECT}</code>.<p>
*
* @param settings the workplace settings
* @param request the current request
*
* @return true, if a reload of the main body frame is required
*/
public boolean initSettings(CmsWorkplaceSettings settings, HttpServletRequest request) {
// check if the user requested a project change
String project = request.getParameter(PARAM_WP_PROJECT);
boolean reloadRequired = false;
if (project != null) {
reloadRequired = true;
try {
getCms().readProject(Integer.parseInt(project));
} catch (Exception e) {
// project not found, set online project
project = String.valueOf(CmsProject.ONLINE_PROJECT_ID);
}
try {
m_cms.getRequestContext().setCurrentProject(getCms().readProject(Integer.parseInt(project)));
} catch (Exception e) {
if (LOG.isInfoEnabled()) {
LOG.info(e);
}
}
settings.setProject(Integer.parseInt(project));
}
// check if the user requested a site change
String site = request.getParameter(PARAM_WP_SITE);
if (site != null) {
reloadRequired = true;
m_cms.getRequestContext().setSiteRoot(site);
settings.setSite(site);
}
// check which resource was requested
String explorerResource = request.getParameter(PARAM_WP_EXPLORER_RESOURCE);
if (explorerResource != null) {
reloadRequired = true;
settings.setExplorerResource(explorerResource);
}
return reloadRequired;
}
/**
* Returns the forwarded flag.<p>
*
* @return the forwarded flag
*/
public boolean isForwarded() {
return m_forwarded;
}
/**
* Returns true if the online help for the users current workplace language is installed.<p>
*
* @return true if the online help for the users current workplace language is installed
*/
public boolean isHelpEnabled() {
return getCms().existsResource(
resolveMacros(CmsHelpTemplateBean.PATH_HELP),
CmsResourceFilter.IGNORE_EXPIRATION);
}
/**
* Returns true if the currently processed element is an included sub element.<p>
*
* @return true if the currently processed element is an included sub element
*/
public boolean isSubElement() {
return !getJsp().getRequestContext().getUri().equals(getJsp().info("opencms.request.element.uri"));
}
/**
* Returns the localized resource string for a given message key,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -