/** * Sets the site root of the CMS context.<p> * * @param siteRoot the site root */ public void setSiteRoot(String siteRoot) { m_cms.getRequestContext().setSiteRoot(siteRoot); }
/** * 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; }
/** * Creates a new instance.<p> * * @param cms the CMS context to use for file operations * * @throws CmsException if something goes wrong */ public ElementGenerator(CmsObject cms) throws CmsException { m_cms = OpenCms.initCmsObject(cms); m_cms.getRequestContext().setSiteRoot(""); }
/** * Creates a new instance.<p> * * @param cms the CMS context * * @throws CmsException if something goes wrong */ public CmsPdfUserAgent(CmsObject cms) throws CmsException { super(IMAGE_CACHE_CAPACITY); m_cms = cms; m_rootCms = OpenCms.initCmsObject(cms); m_rootCms.getRequestContext().setSiteRoot(""); }
/** * Returns the root cms context.<p> * * @return the root cms context * * @throws CmsException in case initializing the context fails */ private CmsObject getRootCms() throws CmsException { if (m_rootCms == null) { m_rootCms = OpenCms.initCmsObject(getCms()); m_rootCms.getRequestContext().setSiteRoot("/"); } return m_rootCms; }
/** * Checks whether the current user has permissions for mass editing the alias table.<p> * * @param cms the current CMS context * @param siteRoot the site root to check * @return true if the user from the CMS context is allowed to mass edit the alias table */ public boolean hasPermissionsForMassEdit(CmsObject cms, String siteRoot) { String originalSiteRoot = cms.getRequestContext().getSiteRoot(); try { cms.getRequestContext().setSiteRoot(siteRoot); return OpenCms.getRoleManager().hasRoleForResource(cms, CmsRole.ADMINISTRATOR, "/"); } finally { cms.getRequestContext().setSiteRoot(originalSiteRoot); } }
/** * @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); } }
/** * @see org.opencms.workplace.list.A_CmsListExplorerDialog#getListItems() */ @Override protected List getListItems() throws CmsException { String storedSiteRoot = getCms().getRequestContext().getSiteRoot(); try { getCms().getRequestContext().setSiteRoot(""); return super.getListItems(); } finally { getCms().getRequestContext().setSiteRoot(storedSiteRoot); } }
/** * @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); } }
/** * @see org.opencms.workplace.list.A_CmsListExplorerDialog#getListItems() */ @Override protected List<CmsListItem> getListItems() throws CmsException { String oldSite = getCms().getRequestContext().getSiteRoot(); try { getCms().getRequestContext().setSiteRoot(""); return super.getListItems(); } finally { getCms().getRequestContext().setSiteRoot(oldSite); } }
/** * @see org.opencms.workplace.list.A_CmsListExplorerDialog#getListItems() */ @Override protected List getListItems() throws CmsException { String oldSite = getCms().getRequestContext().getSiteRoot(); try { getCms().getRequestContext().setSiteRoot(""); return super.getListItems(); } finally { getCms().getRequestContext().setSiteRoot(oldSite); } }
/** * Gets the sitemap service.<p> * * @return the sitemap service * * @throws CmsException if something goes wrong */ public CmsVfsSitemapService getSitemapService() throws CmsException { CmsVfsSitemapService svc = new CmsVfsSitemapService(); CmsObject cms = OpenCms.initCmsObject(m_cms); cms.getRequestContext().setSiteRoot(""); svc.setCms(cms); return svc; }
/** * Constructor, with parameters.<p> * * @param context the JSP page context object * @param req the JSP request * @param res the JSP response * * @throws CmsException if something goes wrong */ public CmsUploadBean(PageContext context, HttpServletRequest req, HttpServletResponse res) throws CmsException { super(); init(context, req, res); m_rootCms = OpenCms.initCmsObject(getCmsObject()); m_rootCms.getRequestContext().setSiteRoot(""); }
/** * @see org.opencms.gwt.shared.rpc.I_CmsVfsService#saveProperties(org.opencms.gwt.shared.property.CmsPropertyChangeSet) */ public void saveProperties(CmsPropertyChangeSet changes) throws CmsRpcException { String origSiteRoot = getCmsObject().getRequestContext().getSiteRoot(); try { getCmsObject().getRequestContext().setSiteRoot(""); CmsPropertyEditorHelper helper = new CmsPropertyEditorHelper(getCmsObject()); helper.saveProperties(changes); } catch (Throwable t) { error(t); } finally { getCmsObject().getRequestContext().setSiteRoot(origSiteRoot); } }
/** * @see org.opencms.gwt.shared.rpc.I_CmsVfsService#substituteLinkForRootPath(java.lang.String, java.lang.String) */ public String substituteLinkForRootPath(String currentSiteRoot, String rootPath) throws CmsRpcException { String result = null; try { CmsObject cms = OpenCms.initCmsObject(getCmsObject()); cms.getRequestContext().setSiteRoot(currentSiteRoot); result = OpenCms.getLinkManager().substituteLinkForRootPath(cms, rootPath); } catch (CmsException e) { error(e); } return result; }
/** * Changes to the given site. Will update session and workplace settings.<p> * * @param siteRoot the site to change to */ public void changeSite(String siteRoot) { if (!getCmsObject().getRequestContext().getSiteRoot().equals(siteRoot)) { getCmsObject().getRequestContext().setSiteRoot(siteRoot); getWorkplaceSettings().setSite(siteRoot); OpenCms.getSessionManager().updateSessionInfo(getCmsObject(), getHttpSession()); } }
/** * @see org.opencms.gwt.shared.rpc.I_CmsVfsService#undelete(org.opencms.util.CmsUUID) */ public void undelete(CmsUUID structureId) throws CmsRpcException { try { CmsObject cms = OpenCms.initCmsObject(getCmsObject()); cms.getRequestContext().setSiteRoot(""); CmsResource resource = cms.readResource(structureId, CmsResourceFilter.ALL); ensureLock(resource); cms.undeleteResource(resource.getRootPath(), true); } catch (Exception e) { error(e); } }
/** * 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); }
/** * 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); }
/** * @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()); }