/** * 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)); }
/** * 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)); }
/** * Sets the current project to the provided project id.<p> * * @param id the project id to set * @return the project set * @throws Exception if something goes wrong */ public CmsProject setCurrentProject(CmsUUID id) throws Exception { return m_cms.getRequestContext().setCurrentProject(m_cms.readProject(id)); }
/** * Sets the current project to the provided project id.<p> * * @param id the project id to set * @return the project set * @throws Exception if something goes wrong */ public CmsProject setCurrentProject(CmsUUID id) throws Exception { return m_cms.getRequestContext().setCurrentProject(m_cms.readProject(id)); }
/** * Helper method to change back from the temporary project to the current project.<p> * * @throws CmsException if switching back fails */ protected void switchToCurrentProject() throws CmsException { if (m_currentProjectId != null) { // switch back to the current users project getCms().getRequestContext().setCurrentProject(getCms().readProject(m_currentProjectId)); } }
/** * Helper method to change back from the temporary project to the current project.<p> * * @throws CmsException if switching back fails */ protected void switchToCurrentProject() throws CmsException { if (m_currentProjectId != null) { // switch back to the current users project getCms().getRequestContext().setCurrentProject(getCms().readProject(m_currentProjectId)); } }
/** * Initializes a CmsObject based on the given one, but with adjusted project information and configured, such that release and expiration date are ignored.<p> * @param cms the original CmsObject. * * @param online true if a CmsObject for the Online project should be returned * @return the initialized CmsObject * * @throws CmsException if something goes wrong */ public static CmsObject adjustCmsObject(CmsObject cms, boolean online) throws CmsException { CmsObject result = OpenCms.initCmsObject(cms); if (online) { CmsProject onlineProject = cms.readProject(CmsProject.ONLINE_PROJECT_ID); result.getRequestContext().setCurrentProject(onlineProject); } result.getRequestContext().setRequestTime(CmsResource.DATE_RELEASED_EXPIRED_IGNORE); return result; } }
/** * @see org.opencms.cmis.I_CmsCmisRepository#initializeCms(org.opencms.file.CmsObject) */ public void initializeCms(CmsObject cms) throws CmsException { m_adminCms = cms; m_typeManager = new CmsCmisTypeManager(cms, m_propertyProviders); String projectName = m_parameterConfiguration.getString(PARAM_PROJECT, CmsProject.ONLINE_PROJECT_NAME); CmsResource root = m_adminCms.readResource("/"); CmsObject offlineCms = OpenCms.initCmsObject(m_adminCms); CmsProject project = m_adminCms.readProject(projectName); m_project = project; offlineCms.getRequestContext().setCurrentProject(project); m_adminCms = offlineCms; m_root = root; m_isReadOnly = project.isOnlineProject(); }
/** * Helper method to change the current project to the temporary file project.<p> * * The id of the old project is stored in a member variable to switch back.<p> * * @return the id of the tempfileproject * @throws CmsException if getting the tempfileproject id fails */ protected CmsUUID switchToTempProject() throws CmsException { // store the current project id in member variable m_currentProjectId = getSettings().getProject(); CmsUUID tempProjectId = OpenCms.getWorkplaceManager().getTempFileProjectId(); getCms().getRequestContext().setCurrentProject(getCms().readProject(tempProjectId)); return tempProjectId; }
/** * Helper method to change the current project to the temporary file project.<p> * * The id of the old project is stored in a member variable to switch back.<p> * * @return the id of the tempfileproject * @throws CmsException if getting the tempfileproject id fails */ protected CmsUUID switchToTempProject() throws CmsException { // store the current project id in member variable m_currentProjectId = getSettings().getProject(); CmsUUID tempProjectId = OpenCms.getWorkplaceManager().getTempFileProjectId(); getCms().getRequestContext().setCurrentProject(getCms().readProject(tempProjectId)); return tempProjectId; }
/** * Revives this publish job.<p> * * @param adminCms an admin cms object * @param publishList a publish list * * @throws CmsException if something goes wrong */ public void revive(CmsObject adminCms, CmsPublishList publishList) throws CmsException { CmsContextInfo context = new CmsContextInfo(adminCms.readUser(m_userId).getName()); CmsProject project = adminCms.readProject(m_projectId); context.setLocale(m_locale); m_cms = OpenCms.initCmsObject(adminCms, context); m_cms.getRequestContext().setCurrentProject(project); m_publishList = publishList; m_publishList.revive(m_cms); }
/** * Revives this publish job.<p> * * @param adminCms an admin cms object * @param publishList a publish list * * @throws CmsException if something goes wrong */ public void revive(CmsObject adminCms, CmsPublishList publishList) throws CmsException { CmsContextInfo context = new CmsContextInfo(adminCms.readUser(m_userId).getName()); CmsProject project = adminCms.readProject(m_projectId); context.setLocale(m_locale); m_cms = OpenCms.initCmsObject(adminCms, context); m_cms.getRequestContext().setCurrentProject(project); m_publishList = publishList; m_publishList.revive(m_cms); }
/** * 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); }
/** * Changes to the given project. Will update session and workplace settings.<p> * * @param project the project to change to */ public void changeProject(CmsProject project) { CmsObject cms = getCmsObject(); if (!cms.getRequestContext().getCurrentProject().equals(project)) { cms.getRequestContext().setCurrentProject(project); getWorkplaceSettings().setProject(project.getUuid()); OpenCms.getSessionManager().updateSessionInfo(cms, getHttpSession()); if (!project.isOnlineProject()) { setAttribute(LAST_OFFLINE_PROJECT, project); } } }
/** * @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; }
/** * 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; }
/** * 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().currentProject()); adminCms.getRequestContext().setEncoding(cms.getRequestContext().getEncoding()); adminCms.getRequestContext().setUri(cms.getRequestContext().getUri()); return adminCms; }