/** * Returns the request context.<p> * * @return the request context */ public CmsRequestContext getRequestContext() { return m_cms.getRequestContext(); }
/** * Returns the current project from the context.<p> * * Usage example on a JSP with the EL:<pre> * The current project name is: ${cms:vfs(pageContext).currentProject.name} * </pre> * * @return the current project */ public CmsProject getCurrentProject() { return m_cms.getRequestContext().getCurrentProject(); }
/** * Constructor, setting the user to the current user from the context.<p> * * @param cms the current users context */ public CmsVisitedByFilter(CmsObject cms) { this(); m_user = cms.getRequestContext().getCurrentUser(); }
/** * @see org.opencms.file.types.I_CmsResourceType#changeLock(org.opencms.file.CmsObject, CmsSecurityManager, CmsResource) */ public void changeLock(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource) throws CmsException { securityManager.changeLock(cms.getRequestContext(), resource); }
/** * @see org.opencms.file.types.I_CmsResourceType#setDateReleased(org.opencms.file.CmsObject, CmsSecurityManager, CmsResource, long, boolean) */ public void setDateReleased( CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, long dateReleased, boolean recursive) throws CmsException { securityManager.setDateReleased(cms.getRequestContext(), resource, dateReleased); }
/** * @see org.opencms.file.types.I_CmsResourceType#writePropertyObjects(org.opencms.file.CmsObject, org.opencms.db.CmsSecurityManager, CmsResource, java.util.List) */ public void writePropertyObjects( CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, List<CmsProperty> properties) throws CmsException { securityManager.writePropertyObjects(cms.getRequestContext(), resource, properties); }
/** * Creates a content access bean based on a Resource, using the current request context locale.<p> * * @param cms the OpenCms context of the current user * @param resource the resource to create the content from */ public CmsJspContentAccessBean(CmsObject cms, CmsResource resource) { this(cms, cms.getRequestContext().getLocale(), resource); }
/** * Creates a new CMS object based on existing one and changes its site root to the site root.<p> * * @param cms the CMS context * @return the root site CMS context * @throws CmsException if something goes wrong */ protected CmsObject rootCms(CmsObject cms) throws CmsException { CmsObject result = OpenCms.initCmsObject(cms); result.getRequestContext().setSiteRoot(""); return result; }
/** * Initializes this bean.<p> * * @param cms the current cms context * @param locale the locale for which properties should be read */ public void init(CmsObject cms, Locale locale) { m_cms = cms; m_locale = locale; m_requestUri = m_cms.getRequestContext().getUri(); m_requestUriFolder = CmsResource.getFolderPath(m_requestUri); }
/** * Returns a list of all sites available (visible) for the current user.<p> * * @param cms the current OpenCms user context * @param workplaceMode if true, the root and current site is included for the admin user * and the view permission is required to see the site root * * @return a list of all sites available for the current user */ public List<CmsSite> getAvailableSites(CmsObject cms, boolean workplaceMode) { return getAvailableSites(cms, workplaceMode, cms.getRequestContext().getOuFqn()); }
/** * 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)); }
/** * Converts a list of {@link CmsResource} objects to a list of {@link CmsJspContentAccessBean} objects, * using the current request context locale.<p> * * @param cms the current OpenCms user context * @param resources a list of of {@link CmsResource} objects that should be converted * * @return a list of {@link CmsJspContentAccessBean} objects created from the given {@link CmsResource} objects */ public static List<CmsJspContentAccessBean> convertResourceList(CmsObject cms, List<CmsResource> resources) { return convertResourceList(cms, cms.getRequestContext().getLocale(), resources); }
/** * Returns the show editor help flag.<p> * * @param cms the cms context * * @return the show editor help flag */ public boolean isShowEditorHelp(CmsObject cms) { CmsUser user = cms.getRequestContext().getCurrentUser(); String showHelp = (String)user.getAdditionalInfo(ADDINFO_ADE_SHOW_EDITOR_HELP); return CmsStringUtil.isEmptyOrWhitespaceOnly(showHelp) || Boolean.parseBoolean(showHelp); }
/** * Returns true if the current user is not the guest user, * i.e. if he already has logged in with some other user account.<p> * * @return true if the current user is already logged in */ public boolean isLoggedIn() { return !getCmsObject().getRequestContext().getCurrentUser().isGuestUser(); }
/** * Reads the result view type from the current user.<p> * * @return the result view type */ private String readResultViewType() { return (String)getCmsObject().getRequestContext().getCurrentUser().getAdditionalInfo( RESULT_VIEW_TYPE_ADD_INFO_KEY); }
/** * @see org.opencms.file.wrapper.A_CmsResourceWrapper#unlockResource(org.opencms.file.CmsObject, java.lang.String) */ @Override public boolean unlockResource(CmsObject cms, String resourcename) throws CmsException { CmsResource res = getResource(cms, resourcename, CmsResourceFilter.DEFAULT); if (res != null) { cms.unlockResource(cms.getRequestContext().removeSiteRoot(res.getRootPath())); return true; } return false; }
/** * Rebuilds (if required creates) the given search index.<p> * * @param index name of the index to update * @throws Exception if something goes wrong * @see org.opencms.search.CmsSearchManager#rebuildIndex(String, org.opencms.report.I_CmsReport) */ public void rebuildIndex(String index) throws Exception { OpenCms.getSearchManager().rebuildIndex(index, new CmsShellReport(m_cms.getRequestContext().getLocale())); }
/** * 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); }
/** * Gets the cached formatters.<p> * * @return the cached formatters */ public CmsFormatterConfigurationCacheState getCachedFormatters() { return OpenCms.getADEManager().getCachedFormatters( getCms().getRequestContext().getCurrentProject().isOnlineProject()); }
/** * Ensures that the user session is still valid.<p> * * @throws CmsException if the current user is the guest user */ protected void ensureSession() throws CmsException { CmsUser user = getCmsObject().getRequestContext().getCurrentUser(); if (user.isGuestUser()) { throw new CmsException(Messages.get().container(Messages.ERR_SESSION_EXPIRED_0)); } }