/** * Updates the context info of the request context.<p> */ private void updateRequestContextInfo() { if ((m_flexContextInfoList != null) && !m_flexContextInfoList.isEmpty()) { m_cmsObject.getRequestContext().setAttribute( CmsRequestUtil.HEADER_LAST_MODIFIED, m_flexContextInfoList.get(m_flexContextInfoList.size() - 1)); } } }
/** * Updates the context info of the request context.<p> */ private void updateRequestContextInfo() { if ((m_flexContextInfoList != null) && !m_flexContextInfoList.isEmpty()) { m_cmsObject.getRequestContext().setAttribute( CmsRequestUtil.HEADER_LAST_MODIFIED, m_flexContextInfoList.get(m_flexContextInfoList.size() - 1)); } } }
/** * Sets the edit context URI.<p> * * @param editContext the edit context URI. */ public void setParamEditContext(String editContext) { m_paramEditContext = editContext; CmsObject cms = getCms(); if ((cms != null) && (editContext != null)) { cms.getRequestContext().setAttribute(ATTRIBUTE_EDITCONTEXT, editContext); } }
/** * @see org.alfresco.jlan.server.filesys.DiskInterface#fileExists(org.alfresco.jlan.server.SrvSession, org.alfresco.jlan.server.filesys.TreeConnection, java.lang.String) */ public int fileExists(SrvSession session, TreeConnection connection, String path) { try { CmsObjectWrapper cms = getCms(session, connection); cms.getRequestContext().setAttribute(NO_FILESIZE_REQUIRED, Boolean.TRUE); CmsJlanNetworkFile file = getFileForPath(cms, session, connection, path); if (file == null) { return FileStatus.NotExist; } else { return file.isDirectory() ? FileStatus.DirectoryExists : FileStatus.FileExists; } } catch (Exception e) { System.out.println(e); return FileStatus.NotExist; } }
/** * Stores this dependency object for a published resource in the OpenCms runtime context.<p> * * This done to optimize indexing speed. When the index update information is calculated, * all dependencies for a resource must be calculated also. The same information is later needed when * the Lucene document is created, for example in order to store the list of other available languages.<p> * * @param cms the current OpenCms user context */ public void storeInContext(CmsObject cms) { cms.getRequestContext().setAttribute(getAttributeKey(getResource().getRootPath()), this); }
/** * Generates the HTML form for the XML content editor.<p> * * @return the HTML that generates the form for the XML editor */ public String getXmlEditorForm() { // set "editor mode" attribute (required for link replacement in the root site) getCms().getRequestContext().setAttribute(CmsRequestContext.ATTRIBUTE_EDITOR, Boolean.TRUE); // add customized message bundle eventually specified in XSD of XML content addMessages(m_content.getContentDefinition().getContentHandler().getMessages(getLocale())); // initialize tab lists for error handling before generating the editor form m_errorTabs = new ArrayList(); m_warningTabs = new ArrayList(); return getXmlEditorForm(m_content.getContentDefinition(), "", true, false).toString(); }
/** * Creates a new instance of the JSP VFS access utility bean.<p> * * To prevent multiple creations of the bean during a request, the OpenCms request context * attributes are used to cache the created VFS access utility bean.<p> * * @param cms the current OpenCms user context * * @return a new instance of the JSP VFS access utility bean */ public static CmsJspVfsAccessBean create(CmsObject cms) { CmsJspVfsAccessBean result; Object attribute = cms.getRequestContext().getAttribute(ATTRIBUTE_VFS_ACCESS_BEAN); if (attribute != null) { result = (CmsJspVfsAccessBean)attribute; } else { result = new CmsJspVfsAccessBean(cms); cms.getRequestContext().setAttribute(ATTRIBUTE_VFS_ACCESS_BEAN, result); } return result; }
/** * Creates a new instance of the JSP VFS access utility bean.<p> * * To prevent multiple creations of the bean during a request, the OpenCms request context * attributes are used to cache the created VFS access utility bean.<p> * * @param cms the current OpenCms user context * * @return a new instance of the JSP VFS access utility bean */ public static CmsJspVfsAccessBean create(CmsObject cms) { CmsJspVfsAccessBean result; Object attribute = cms.getRequestContext().getAttribute(ATTRIBUTE_VFS_ACCESS_BEAN); if (attribute != null) { result = (CmsJspVfsAccessBean)attribute; } else { result = new CmsJspVfsAccessBean(cms); cms.getRequestContext().setAttribute(ATTRIBUTE_VFS_ACCESS_BEAN, result); } return result; }
jsp.getRequestContext().setAttribute("EDITORHANDLER_RESOURCE", res); resTypeId = res.getTypeId();
/** * Creates a new thumbnail link for the given resource and options.<p> * * @param cms the current CMS context * @param pdfResource the PDF resource for which to create a thumbnail link * @param width thumbnail width * @param height thumbnail height * @param format the thumbnail image format (png, gif..,) */ public CmsPdfThumbnailLink(CmsObject cms, CmsResource pdfResource, int width, int height, String format) { m_pdfResource = pdfResource; m_width = width; m_height = height; m_format = format.toLowerCase(); m_options = "w:" + m_width + ",h:" + m_height; cms.getRequestContext().setAttribute(CmsDefaultLinkSubstitutionHandler.ATTR_IS_IMAGE_LINK, "true"); try { m_link = OpenCms.getLinkManager().substituteLink( cms, "/" + MARKER + "/" + pdfResource.getStructureId() + "." + format); } finally { cms.getRequestContext().removeAttribute(CmsDefaultLinkSubstitutionHandler.ATTR_IS_IMAGE_LINK); } }
/** * Generates the HTML form for the XML content editor.<p> * * @return the HTML that generates the form for the XML editor */ public String getXmlEditorForm() { // set "editor mode" attribute (required for link replacement in the root site) getCms().getRequestContext().setAttribute(CmsRequestContext.ATTRIBUTE_EDITOR, Boolean.TRUE); // add customized message bundle eventually specified in XSD of XML content addMessages(m_content.getHandler().getMessages(getLocale())); ((CmsMultiMessages)getMessages()).setFallbackHandler(m_content.getHandler().getMessageKeyHandler()); // initialize tab lists for error handling before generating the editor form m_errorTabs = new ArrayList<CmsXmlContentTab>(); m_warningTabs = new ArrayList<CmsXmlContentTab>(); return getXmlEditorForm(m_content.getContentDefinition(), "", true, false).toString(); }
/** * Rewrites the content of the given file.<p> * * @param cms the CmsObject * @param resource the resource to rewrite the content for * * @throws CmsException if something goes wrong */ private void hardTouch(CmsObject cms, CmsResource resource) throws CmsException { CmsFile file = cms.readFile(resource); cms = OpenCms.initCmsObject(cms); cms.getRequestContext().setAttribute(CmsXmlContent.AUTO_CORRECTION_ATTRIBUTE, Boolean.TRUE); file.setContents(file.getContents()); cms.writeFile(file); }
/** * Copies a given CMS context and set the copy's site root to '/'.<p> * * @param cms the CMS context to copy * @return the copy * * @throws CmsException if something goes wrong */ public CmsObject createRootCms(CmsObject cms) throws CmsException { CmsObject rootCms = OpenCms.initCmsObject(cms); Object logEntry = cms.getRequestContext().getAttribute(CmsLogEntry.ATTR_LOG_ENTRY); if (logEntry != null) { rootCms.getRequestContext().setAttribute(CmsLogEntry.ATTR_LOG_ENTRY, logEntry); } rootCms.getRequestContext().setSiteRoot("/"); return rootCms; }
/** * Rewrites all parseable files, to assure link check.<p> * * This is a global process, that is executed only once at the * end of the import to be sure that all link targets are * available.<p> * * @see #addXmlDigesterRules(Digester) */ public void rewriteParseables() { if (m_parseables.isEmpty()) { return; } I_CmsReport report = getReport(); CmsObject cms = getCms(); cms.getRequestContext().setAttribute(CmsLogEntry.ATTR_LOG_ENTRY, Boolean.FALSE); report.println(Messages.get().container(Messages.RPT_START_PARSE_LINKS_0), I_CmsReport.FORMAT_HEADLINE); parseLinks(cms, report); report.println(Messages.get().container(Messages.RPT_END_PARSE_LINKS_0), I_CmsReport.FORMAT_HEADLINE); m_parseables = null; }
/** * Rewrites the content of the given file.<p> * * @param resource the resource to rewrite the content for * * @throws CmsException if something goes wrong */ private void hardTouch(CmsResource resource) throws CmsException { CmsFile file = m_context.getCms().readFile(resource); CmsObject cms = OpenCms.initCmsObject(m_context.getCms()); cms.getRequestContext().setAttribute(CmsXmlContent.AUTO_CORRECTION_ATTRIBUTE, Boolean.TRUE); file.setContents(file.getContents()); cms.writeFile(file); }
/** * Returns the list of organizational units the given resource belongs to.<p> * * @param dbc the current database context * @param resource the resource * * @return list of {@link CmsOrganizationalUnit} objects * * @throws CmsException if something goes wrong */ public List getResourceOrgUnits(CmsDbContext dbc, CmsResource resource) throws CmsException { try { dbc.getRequestContext().setAttribute(I_CmsVfsDriver.REQ_ATTR_RESOURCE_OUS, Boolean.TRUE); return m_vfsDriver.readRelations( dbc, dbc.currentProject().getUuid(), resource, CmsRelationFilter.TARGETS.filterIncludeChildren()); } finally { dbc.getRequestContext().removeAttribute(I_CmsVfsDriver.REQ_ATTR_RESOURCE_OUS); } }
/** * Rewrites all parseable files, to assure link check.<p> * * This is a global process, that is executed only once at the * end of the import to be sure that all link targets are * available.<p> * * @see #addXmlDigesterRules(Digester) */ public void rewriteParseables() { if (m_parseables.isEmpty()) { return; } I_CmsReport report = getReport(); CmsObject cms = getCms(); cms.getRequestContext().setAttribute(CmsLogEntry.ATTR_LOG_ENTRY, Boolean.FALSE); report.println(Messages.get().container(Messages.RPT_START_PARSE_LINKS_0), I_CmsReport.FORMAT_HEADLINE); parseLinks(cms, report); report.println(Messages.get().container(Messages.RPT_END_PARSE_LINKS_0), I_CmsReport.FORMAT_HEADLINE); m_parseables = null; }
/** * @see org.opencms.repository.I_CmsRepository#login(java.lang.String, java.lang.String) */ public I_CmsRepositorySession login(String userName, String password) throws CmsException { CmsObject cms; cms = OpenCms.initCmsObject(OpenCms.getDefaultUsers().getUserGuest()); cms.loginUser(userName, password); CmsUserSettings settings = new CmsUserSettings(cms); cms.getRequestContext().setSiteRoot(settings.getStartSite()); cms.getRequestContext().setCurrentProject(cms.readProject(settings.getStartProject())); // set the object wrapper as an attribute in the request context, so that it can be // used everywhere a CmsObject is accessible. CmsObjectWrapper objWrapper = new CmsObjectWrapper(cms, m_wrappers); cms.getRequestContext().setAttribute(CmsObjectWrapper.ATTRIBUTE_NAME, objWrapper); return new CmsRepositorySession(objWrapper, getFilter()); }
/** * @see org.opencms.repository.A_CmsRepository#login(java.lang.String, java.lang.String) */ @Override public I_CmsRepositorySession login(String userName, String password) throws CmsException { CmsObject cms; cms = OpenCms.initCmsObject(OpenCms.getDefaultUsers().getUserGuest()); cms.loginUser(userName, password); CmsUserSettings settings = new CmsUserSettings(cms); cms.getRequestContext().setSiteRoot(settings.getStartSite()); cms.getRequestContext().setCurrentProject(cms.readProject(settings.getStartProject())); // set the object wrapper as an attribute in the request context, so that it can be // used everywhere a CmsObject is accessible. CmsObjectWrapper objWrapper = new CmsObjectWrapper(cms, m_wrappers); cms.getRequestContext().setAttribute(CmsObjectWrapper.ATTRIBUTE_NAME, objWrapper); return new CmsRepositorySession(objWrapper, getFilter()); }
/** * Creates a CmsObjectWrapper for the current session.<p> * * @param session the current session * @param connection the tree connection * * @return the correctly configured CmsObjectWrapper for this session * * @throws CmsException if something goes wrong */ public CmsObjectWrapper getCms(SrvSession session, TreeConnection connection) throws CmsException { String userName = session.getClientInformation().getUserName(); userName = CmsJlanUsers.translateUser(userName); CmsContextInfo contextInfo = new CmsContextInfo(m_cms.getRequestContext()); contextInfo.setUserName(userName); CmsObject newCms = OpenCms.initCmsObject(m_cms, contextInfo); newCms.getRequestContext().setSiteRoot(getRoot()); newCms.getRequestContext().setCurrentProject(getProject()); CmsObjectWrapper result = new CmsObjectWrapper(newCms, getWrappers()); result.setAddByteOrderMark(m_addByteOrderMark); result.getRequestContext().setAttribute(CmsXmlContent.AUTO_CORRECTION_ATTRIBUTE, Boolean.TRUE); return result; }