/** * @see org.opencms.workplace.explorer.menu.I_CmsMenuItemRule#matches(org.opencms.file.CmsObject, org.opencms.workplace.explorer.CmsResourceUtil[]) */ public boolean matches(CmsObject cms, CmsResourceUtil[] resourceUtil) { String subcontext = (String)cms.getRequestContext().getAttribute(I_CmsMenuItemRule.ATTR_SUB_CONTEXT); return CmsGwtConstants.SUBCONTEXT_PUBLISH.equals(subcontext); } }
/** * Creates a new database context initialized with the given user request context.<p> * * @param context the current users request context */ public CmsDbContext(CmsRequestContext context) { m_requestContext = context; m_projectId = CmsUUID.getNullUUID(); if (m_requestContext != null) { m_flexRequestContextInfo = (CmsFlexRequestContextInfo)m_requestContext.getAttribute(CmsRequestUtil.HEADER_LAST_MODIFIED); } }
/** * Creates a new database context initialized with the given user request context.<p> * * @param context the current users request context */ public CmsDbContext(CmsRequestContext context) { m_requestContext = context; m_projectId = CmsUUID.getNullUUID(); if (m_requestContext != null) { m_flexRequestContextInfo = (CmsFlexRequestContextInfo)m_requestContext.getAttribute( CmsRequestUtil.HEADER_LAST_MODIFIED); } }
/** * @see org.opencms.workplace.explorer.menu.I_CmsMenuItemRule#matches(org.opencms.file.CmsObject, org.opencms.workplace.explorer.CmsResourceUtil[]) */ public boolean matches(CmsObject cms, CmsResourceUtil[] resourceUtil) { String context = (String)cms.getRequestContext().getAttribute(I_CmsMenuItemRule.ATTR_CONTEXT_INFO); if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(context)) { if (contexts.contains(context.toLowerCase())) { return true; } } return false; } }
/** * @see org.opencms.workplace.explorer.menu.I_CmsMenuItemRule#matches(org.opencms.file.CmsObject, org.opencms.workplace.explorer.CmsResourceUtil[]) */ public boolean matches(CmsObject cms, CmsResourceUtil[] resourceUtil) { String context = (String)cms.getRequestContext().getAttribute(I_CmsMenuItemRule.ATTR_CONTEXT_INFO); if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(context)) { return context.toLowerCase().equals(I_CmsMenuItemRule.CONTEXT_SITEMAP); } return false; } }
/** * @see org.opencms.workplace.explorer.menu.I_CmsMenuItemRule#matches(org.opencms.file.CmsObject, org.opencms.workplace.explorer.CmsResourceUtil[]) */ public boolean matches(CmsObject cms, CmsResourceUtil[] resourceUtil) { String context = (String)cms.getRequestContext().getAttribute(I_CmsMenuItemRule.ATTR_CONTEXT_INFO); if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(context)) { if (contexts.contains(context.toLowerCase())) { return true; } } return false; } }
/** * @see org.opencms.workplace.explorer.menu.I_CmsMenuItemRule#matches(org.opencms.file.CmsObject, org.opencms.workplace.explorer.CmsResourceUtil[]) */ public boolean matches(CmsObject cms, CmsResourceUtil[] resourceUtil) { String context = (String)cms.getRequestContext().getAttribute(I_CmsMenuItemRule.ATTR_CONTEXT_INFO); if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(context)) { return contexts.contains(context); } return false; } }
/** * @see org.opencms.workplace.explorer.menu.I_CmsMenuItemRule#matches(org.opencms.file.CmsObject, org.opencms.workplace.explorer.CmsResourceUtil[]) */ public boolean matches(CmsObject cms, CmsResourceUtil[] resourceUtil) { String context = (String)cms.getRequestContext().getAttribute(I_CmsMenuItemRule.ATTR_CONTEXT_INFO); if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(context)) { if (context.toLowerCase().equals(I_CmsMenuItemRule.CONTEXT_SITEMAP)) { return true; } } return false; } }
/** * Reads the dependency object for the given root path in the OpenCms runtime context.<p> * * @param cms the current OpenCms user context * @param rootPath the root path to look up the dependency object for * * @return the deps */ private static CmsDocumentDependency readFromContext(CmsObject cms, String rootPath) { return (CmsDocumentDependency)cms.getRequestContext().getAttribute(getAttributeKey(rootPath)); }
/** * @see org.opencms.workplace.explorer.menu.I_CmsMenuItemRule#matches(org.opencms.file.CmsObject, org.opencms.workplace.explorer.CmsResourceUtil[]) */ public boolean matches(CmsObject cms, CmsResourceUtil[] resourceUtil) { String context = (String)cms.getRequestContext().getAttribute(I_CmsMenuItemRule.ATTR_CONTEXT_INFO); if (CmsStringUtil.isEmptyOrWhitespaceOnly(context)) { return true; } return false; } }
/** * Use the {@link org.opencms.file.wrapper.CmsObjectWrapper} to restore the link in the VFS.<p> * * @param internalUri the internal URI to restore * * @return the restored URI */ private String rewriteUri(String internalUri) { // if an object wrapper is used, rewrite the uri if (m_cms != null) { Object obj = m_cms.getRequestContext().getAttribute(CmsObjectWrapper.ATTRIBUTE_NAME); if (obj != null) { CmsObjectWrapper wrapper = (CmsObjectWrapper)obj; return wrapper.restoreLink(internalUri); } } return internalUri; } }
/** * Use the {@link org.opencms.file.wrapper.CmsObjectWrapper} to restore the link in the VFS.<p> * * @param internalUri the internal URI to restore * * @return the restored URI */ private String rewriteUri(String internalUri) { // if an object wrapper is used, rewrite the uri if (m_cms != null) { Object obj = m_cms.getRequestContext().getAttribute(CmsObjectWrapper.ATTRIBUTE_NAME); if (obj != null) { CmsObjectWrapper wrapper = (CmsObjectWrapper)obj; return wrapper.restoreLink(internalUri); } } return internalUri; } }
/** * Returns if direct edit is enabled.<p> * * @param cms the current cms context * * @return <code>true</code> if direct edit is enabled */ static boolean isDirectEditEnabled(CmsObject cms) { return !cms.getRequestContext().getCurrentProject().isOnlineProject() && (cms.getRequestContext().getAttribute(CmsGwtConstants.PARAM_DISABLE_DIRECT_EDIT) == null); }
/** * Gets the locale which should be used for creating an empty content.<p> * * @param cms the current CMS context * @param securityManager the security manager * @param resourcename the name of the resource to create * @param properties the properties for the resource to create * * @return the locale to use */ protected Locale getLocaleForNewContent( CmsObject cms, CmsSecurityManager securityManager, String resourcename, List<CmsProperty> properties) { Locale locale = (Locale)(cms.getRequestContext().getAttribute(CmsRequestContext.ATTRIBUTE_NEW_RESOURCE_LOCALE)); if (locale != null) { return locale; } List<Locale> locales = OpenCms.getLocaleManager().getDefaultLocales( cms, CmsResource.getParentFolder(resourcename)); return locales.get(0); }
/** * 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; }
/** * @see org.opencms.workplace.editors.I_CmsEditorCssHandler#getUriStyleSheet(org.opencms.file.CmsObject, java.lang.String) */ public String getUriStyleSheet(CmsObject cms, String editedResourcePath) { String editContext = (String)(cms.getRequestContext().getAttribute(CmsXmlContentEditor.ATTRIBUTE_EDITCONTEXT)); String result = ""; if (!CmsStringUtil.isEmptyOrWhitespaceOnly(editContext)) { // prefer the style sheet of the edit context (usually this will be a container page) result = internalGetUriStyleSheet(cms, editContext); } if (CmsStringUtil.isEmptyOrWhitespaceOnly(result)) { result = internalGetUriStyleSheet(cms, editedResourcePath); } return result; }
/** * @see org.opencms.db.I_CmsProjectDriver#readProjects(org.opencms.db.CmsDbContext, String) */ public List<CmsProject> readProjects(CmsDbContext dbc, String ouFqn) throws CmsDataAccessException { if ((dbc.getRequestContext() != null) && (dbc.getRequestContext().getAttribute(DBC_ATTR_READ_PROJECT_FOR_RESOURCE) != null)) { dbc.getRequestContext().removeAttribute(DBC_ATTR_READ_PROJECT_FOR_RESOURCE); // TODO: this should get its own method in the interface return readProjectsForResource(dbc, ouFqn); } List<CmsProject> projects = new ArrayList<CmsProject>(); try { // create the statement Query q = m_sqlManager.createQuery(dbc, C_PROJECTS_READ_BYOU_1); q.setParameter(1, CmsOrganizationalUnit.SEPARATOR + ouFqn + "%"); List<CmsDAOProjects> res = q.getResultList(); for (CmsDAOProjects p : res) { projects.add(internalCreateProject(p)); } } catch (PersistenceException e) { throw new CmsDataAccessException(Messages.get().container(Messages.ERR_JPA_PERSITENCE_1, e), e); } return (projects); }
/** * @see org.opencms.db.I_CmsUserDriver#writePassword(org.opencms.db.CmsDbContext, java.lang.String, java.lang.String, java.lang.String) */ public void writePassword(CmsDbContext dbc, String userFqn, String oldPassword, String newPassword) throws CmsDataAccessException, CmsPasswordEncryptionException { // check if the old password is valid if (oldPassword != null) { readUser(dbc, userFqn, oldPassword, ""); } String pwd = newPassword; if (dbc.getRequestContext().getAttribute(REQ_ATTR_DONT_DIGEST_PASSWORD) == null) { pwd = OpenCms.getPasswordHandler().digest(newPassword); } try { Query q = m_sqlManager.createQuery(dbc, C_USERS_SET_PWD_3); q.setParameter(1, CmsOrganizationalUnit.getSimpleName(userFqn)); q.setParameter(2, CmsOrganizationalUnit.SEPARATOR + CmsOrganizationalUnit.getParentFqn(userFqn)); List<CmsDAOUsers> res = q.getResultList(); for (CmsDAOUsers u : res) { u.setUserPassword(pwd); } } catch (PersistenceException e) { throw new CmsDataAccessException(Messages.get().container(Messages.ERR_JPA_PERSITENCE_1, e), e); } }
/** * 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; }