/** * Reads a project given the projects id.<p> * * @param id the id of the project * * @return the project read * * @throws CmsException if something goes wrong */ public CmsProject readProject(CmsUUID id) throws CmsException { CmsDbContext dbc = m_dbContextFactory.getDbContext(); CmsProject result = null; try { result = m_driverManager.readProject(dbc, id); } catch (Exception e) { dbc.report(null, Messages.get().container(Messages.ERR_READ_PROJECT_FOR_ID_1, id), e); } finally { dbc.clear(); } return result; }
/** * Reads a project given the projects id.<p> * * @param id the id of the project * * @return the project read * * @throws CmsException if something goes wrong */ public CmsProject readProject(CmsUUID id) throws CmsException { CmsDbContext dbc = m_dbContextFactory.getDbContext(); CmsProject result = null; try { result = m_driverManager.readProject(dbc, id); } catch (Exception e) { dbc.report(null, Messages.get().container(Messages.ERR_READ_PROJECT_FOR_ID_1, id), e); } finally { dbc.clear(); } return result; }
/** * Reads a project.<p> * * Important: Since a project name can be used multiple times, this is NOT the most efficient * way to read the project. This is only a convenience for front end developing. * Reading a project by name will return the first project with that name. * All core classes must use the id version {@link #readProject(CmsUUID)} to ensure the right project is read.<p> * * @param name the name of the project * * @return the project read * * @throws CmsException if something goes wrong */ public CmsProject readProject(String name) throws CmsException { CmsDbContext dbc = m_dbContextFactory.getDbContext(); CmsProject result = null; try { result = m_driverManager.readProject(dbc, CmsOrganizationalUnit.removeLeadingSeparator(name)); } catch (Exception e) { dbc.report(null, Messages.get().container(Messages.ERR_READ_PROJECT_FOR_NAME_1, name), e); } finally { dbc.clear(); } return result; }
/** * Reads a project.<p> * * Important: Since a project name can be used multiple times, this is NOT the most efficient * way to read the project. This is only a convenience for front end developing. * Reading a project by name will return the first project with that name. * All core classes must use the id version {@link #readProject(CmsUUID)} to ensure the right project is read.<p> * * @param name the name of the project * * @return the project read * * @throws CmsException if something goes wrong */ public CmsProject readProject(String name) throws CmsException { CmsDbContext dbc = m_dbContextFactory.getDbContext(); CmsProject result = null; try { result = m_driverManager.readProject(dbc, CmsOrganizationalUnit.removeLeadingSeparator(name)); } catch (Exception e) { dbc.report(null, Messages.get().container(Messages.ERR_READ_PROJECT_FOR_NAME_1, name), e); } finally { dbc.clear(); } return result; }
/** * 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.db.I_CmsUserDriver#deleteOrganizationalUnit(org.opencms.db.CmsDbContext, org.opencms.security.CmsOrganizationalUnit) */ public void deleteOrganizationalUnit(CmsDbContext dbc, CmsOrganizationalUnit organizationalUnit) throws CmsDataAccessException { try { CmsResource resource = m_driverManager.readResource( dbc, ORGUNIT_BASE_FOLDER + organizationalUnit.getName(), CmsResourceFilter.DEFAULT); internalDeleteOrgUnitResource(dbc, resource); if (organizationalUnit.getProjectId() != null) { try { // maintain the default project synchronized m_driverManager.deleteProject( dbc, m_driverManager.readProject(dbc, organizationalUnit.getProjectId())); } catch (CmsDbEntryNotFoundException e) { // ignore } } } catch (CmsException e) { throw new CmsDataAccessException(e.getMessageContainer(), 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); }
/** * @see org.opencms.db.I_CmsUserDriver#deleteOrganizationalUnit(org.opencms.db.CmsDbContext, org.opencms.security.CmsOrganizationalUnit) */ public void deleteOrganizationalUnit(CmsDbContext dbc, CmsOrganizationalUnit organizationalUnit) throws CmsDataAccessException { try { CmsResource resource = m_driverManager.readResource( dbc, organizationalUnit.getId(), CmsResourceFilter.DEFAULT); internalDeleteOrgUnitResource(dbc, resource); if (organizationalUnit.getProjectId() != null) { try { // maintain the default project synchronized m_driverManager.deleteProject(dbc, m_driverManager.readProject( dbc, organizationalUnit.getProjectId())); } catch (CmsDbEntryNotFoundException e) { // ignore } } } catch (CmsException e) { throw new CmsDataAccessException(e.getMessageContainer(), e); } }
/** * @see org.opencms.db.I_CmsUserDriver#deleteOrganizationalUnit(org.opencms.db.CmsDbContext, org.opencms.security.CmsOrganizationalUnit) */ public void deleteOrganizationalUnit(CmsDbContext dbc, CmsOrganizationalUnit organizationalUnit) throws CmsDataAccessException { try { CmsResource resource = m_driverManager.readResource( dbc, ORGUNIT_BASE_FOLDER + organizationalUnit.getName(), CmsResourceFilter.DEFAULT); internalDeleteOrgUnitResource(dbc, resource); if (organizationalUnit.getProjectId() != null) { try { // maintain the default project synchronized m_driverManager.deleteProject( dbc, m_driverManager.readProject(dbc, organizationalUnit.getProjectId()), false); } catch (CmsDbEntryNotFoundException e) { // ignore } } } catch (CmsException e) { throw new CmsDataAccessException(e.getMessageContainer(), e); } }
/** * Unlocks all resources in this project.<p> * * @param context the current request context * @param projectId the id of the project to be published * * @throws CmsException if something goes wrong * @throws CmsRoleViolationException if the current user does not own the required permissions */ public void unlockProject(CmsRequestContext context, CmsUUID projectId) throws CmsException, CmsRoleViolationException { CmsDbContext dbc = m_dbContextFactory.getDbContext(context); CmsProject project = m_driverManager.readProject(dbc, projectId); try { checkManagerOfProjectRole(dbc, project); m_driverManager.unlockProject(project); } catch (Exception e) { dbc.report(null, Messages.get().container( Messages.ERR_UNLOCK_PROJECT_2, projectId, dbc.currentUser().getName()), e); } finally { dbc.clear(); } }
/** * Counts the locked resources in this project.<p> * * @param context the current request context * @param id the id of the project * * @return the amount of locked resources in this project * * @throws CmsException if something goes wrong * @throws CmsRoleViolationException if the current user does not have management access to the project */ public int countLockedResources(CmsRequestContext context, CmsUUID id) throws CmsException, CmsRoleViolationException { CmsDbContext dbc = m_dbContextFactory.getDbContext(context); CmsProject project = null; int result = 0; try { project = m_driverManager.readProject(dbc, id); checkManagerOfProjectRole(dbc, project); result = m_driverManager.countLockedResources(project); } catch (Exception e) { dbc.report(null, Messages.get().container( Messages.ERR_COUNT_LOCKED_RESOURCES_PROJECT_2, (project == null) ? "<failed to read>" : project.getName(), id), e); } finally { dbc.clear(); } return result; }
try { deleteProject = m_driverManager.readProject(dbc, projectId); checkManagerOfProjectRole(dbc, deleteProject); m_driverManager.deleteProject(dbc, deleteProject);
int result = 0; try { project = m_driverManager.readProject(dbc, id); checkManagerOfProjectRole(dbc, project); result = m_driverManager.countLockedResources(project);
/** * Unlocks all resources in this project.<p> * * @param context the current request context * @param projectId the id of the project to be published * * @throws CmsException if something goes wrong * @throws CmsRoleViolationException if the current user does not own the required permissions */ public void unlockProject(CmsRequestContext context, CmsUUID projectId) throws CmsException, CmsRoleViolationException { CmsDbContext dbc = m_dbContextFactory.getDbContext(context); CmsProject project = m_driverManager.readProject(dbc, projectId); try { checkManagerOfProjectRole(dbc, project); m_driverManager.unlockProject(project); } catch (Exception e) { dbc.report( null, Messages.get().container(Messages.ERR_UNLOCK_PROJECT_2, projectId, dbc.currentUser().getName()), e); } finally { dbc.clear(); } }
try { deleteProject = m_driverManager.readProject(dbc, projectId); checkManagerOfProjectRole(dbc, deleteProject); m_driverManager.deleteProject(dbc, deleteProject);
dbc.getRequestContext().setCurrentProject(m_driverManager.readProject(dbc, CmsProject.ONLINE_PROJECT_ID)); try {
dbc.getRequestContext().setCurrentProject(m_driverManager.readProject(dbc, CmsProject.ONLINE_PROJECT_ID)); try {
dbc.getRequestContext().setCurrentProject(m_driverManager.readProject(dbc, CmsProject.ONLINE_PROJECT_ID)); try {
CmsProject onlineProject = m_driverManager.readProject(dbc, CmsProject.ONLINE_PROJECT_ID); resource.setState(CmsResource.STATE_UNCHANGED); m_driverManager.getVfsDriver(dbc).writeResource(
CmsProject onlineProject = m_driverManager.readProject(dbc, CmsProject.ONLINE_PROJECT_ID); resource.setState(CmsResource.STATE_UNCHANGED); m_driverManager.getVfsDriver(dbc).writeResource(