/** * Creates a new instance with all context variables initialized from the given request context.<p> * * @param requestContext the request context to initialize this context info with */ public CmsContextInfo(CmsRequestContext requestContext) { setUserName(requestContext.getCurrentUser().getName()); setProjectName(requestContext.getCurrentProject().getName()); setRequestedUri(requestContext.getUri()); setSiteRoot(requestContext.getSiteRoot()); setRequestMatcher(requestContext.getRequestMatcher()); setLocale(requestContext.getLocale()); setEncoding(requestContext.getEncoding()); setRemoteAddr(requestContext.getRemoteAddress()); setRequestTime(requestContext.getRequestTime()); setIsSecureRequest(requestContext.isSecureRequest()); setOuFqn(requestContext.getOuFqn()); setDetailResource(requestContext.getDetailResource()); }
/** * Creates a copy of the admin cms object which is initialize with the data of the current cms object.<p> * * @param cms the current cms object * @return the new admin cms object * * @throws CmsException if something goes wrong */ private CmsObject getAdminCms(CmsObject cms) throws CmsException { CmsObject adminCms = OpenCms.initCmsObject(m_adminCms); adminCms.getRequestContext().setSiteRoot(cms.getRequestContext().getSiteRoot()); adminCms.getRequestContext().setRequestTime(cms.getRequestContext().getRequestTime()); adminCms.getRequestContext().setCurrentProject(cms.getRequestContext().getCurrentProject()); adminCms.getRequestContext().setEncoding(cms.getRequestContext().getEncoding()); adminCms.getRequestContext().setUri(cms.getRequestContext().getUri()); return adminCms; }
/** * @see org.opencms.repository.I_CmsRepositoryItem#getName() */ public String getName() { return m_cms.getRequestContext().removeSiteRoot(m_resource.getRootPath()); }
/** * Returns the uri.<p> * * @return the uri */ public String getUri() { String uri = m_context.addSiteRoot(m_context.getUri()); if (m_detailViewId != null) { uri += m_detailViewId.toString() + "/"; } return uri; }
/** * Updates the session info object with the information from * the given request context.<p> * * @param context the request context to update the session with */ protected void update(CmsRequestContext context) { m_timeUpdated = System.currentTimeMillis(); m_siteRoot = context.getSiteRoot(); setProject(context.getCurrentProject().getUuid()); m_ouFqn = context.getOuFqn(); } }
/** * Updates the session info object with the information from * the given request context.<p> * * @param context the request context to update the session with */ protected void update(CmsRequestContext context) { m_timeUpdated = System.currentTimeMillis(); m_siteRoot = context.getSiteRoot(); setProject(context.currentProject().getUuid()); m_ouFqn = context.getOuFqn(); } }
/** * Creates a new instance with all context variables initialized from the given request context.<p> * * @param requestContext the request context to initialize this context info with */ public CmsContextInfo(CmsRequestContext requestContext) { setUserName(requestContext.currentUser().getName()); setProjectName(requestContext.currentProject().getName()); setRequestedUri(requestContext.getUri()); setSiteRoot(requestContext.getSiteRoot()); setLocale(requestContext.getLocale()); setEncoding(requestContext.getEncoding()); setRemoteAddr(requestContext.getRemoteAddress()); setRequestTime(requestContext.getRequestTime()); setOuFqn(requestContext.getOuFqn()); }
/** * @see org.opencms.workplace.list.A_CmsListExplorerDialog#getListItems() */ @Override protected List<CmsListItem> getListItems() throws CmsException { String storedSiteRoot = getCms().getRequestContext().getSiteRoot(); try { getCms().getRequestContext().setSiteRoot(""); return super.getListItems(); } finally { getCms().getRequestContext().setSiteRoot(storedSiteRoot); } }
/** * Returns the locale.<p> * * @return the locale */ public String getLocale() { return m_context.getLocale().toString(); }
/** * 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(); }
/** * Returns the site root.<p> * * @return the site root */ public String getSite() { return m_context.getSiteRoot(); }
/** * Repairs broken categories.<p> * * @param dbc the database context * @param projectId the project id * @param resource the resource to repair the categories for * * @throws CmsException if something goes wrong */ public void repairCategories(CmsDbContext dbc, CmsUUID projectId, CmsResource resource) throws CmsException { CmsObject cms = OpenCms.initCmsObject(new CmsObject(getSecurityManager(), dbc.getRequestContext())); cms.getRequestContext().setSiteRoot(""); cms.getRequestContext().setCurrentProject(readProject(dbc, projectId)); CmsCategoryService.getInstance().repairRelations(cms, resource); }
/** * Sets the current project to the provided project name.<p> * * @param name the project name to set * @return the project set * @throws Exception if something goes wrong */ public CmsProject setCurrentProject(String name) throws Exception { return m_cms.getRequestContext().setCurrentProject(m_cms.readProject(name)); }
/** * Returns the encoding.<p> * * @return the encoding */ public String getEncoding() { return m_context.getEncoding(); }
/** * Sets the site root of the CMS context.<p> * * @param siteRoot the site root */ public void setSiteRoot(String siteRoot) { m_cms.getRequestContext().setSiteRoot(siteRoot); }
/** * 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 the currently logged in user.<p> * * @return the currently logged in user */ public CmsUser getUser() { return getRequestContext().getCurrentUser(); }
/** * 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); }
/** * 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()); }
/** * Returns the perma link for the current page based on the URI and detail content id stored in the CmsObject passed as a parameter.<p< * * @param cms the CMS context to use to generate the permalink * * @return the permalink */ public String getPermalinkForCurrentPage(CmsObject cms) { return getPermalink(cms, cms.getRequestContext().getUri(), cms.getRequestContext().getDetailContentId()); }