/** * @see org.opencms.db.I_CmsDbContextFactory#getDbContext(org.opencms.file.CmsRequestContext) */ public CmsDbContext getDbContext(CmsRequestContext context) { return new CmsDbContext(context); }
/** * Reads the locks that were saved to the database in the previous run of OpenCms.<p> * * @throws CmsException if something goes wrong */ public void readLocks() throws CmsException { CmsDbContext dbc = m_dbContextFactory.getDbContext(); try { m_driverManager.readLocks(dbc); } finally { dbc.clear(); } }
/** * @see org.opencms.db.I_CmsCacheKey#getCacheKeyForUserPermissions(java.lang.String, org.opencms.db.CmsDbContext, org.opencms.file.CmsResource, org.opencms.security.CmsPermissionSet) */ public String getCacheKeyForUserPermissions( String prefix, CmsDbContext context, CmsResource resource, CmsPermissionSet requiredPermissions) { if (!context.getProjectId().isNullUUID()) { return ""; } StringBuffer cacheBuffer = new StringBuffer(64); cacheBuffer.append(prefix); cacheBuffer.append('_'); cacheBuffer.append(context.currentUser().getName()); cacheBuffer.append(context.currentProject().isOnlineProject() ? "_0_" : "_1_"); cacheBuffer.append(requiredPermissions.getPermissionString()); cacheBuffer.append('_'); cacheBuffer.append(resource.getStructureId().toString()); return cacheBuffer.toString(); } }
/** * Returns the history driver for a given database context.<p> * * @param dbc the database context * @return the history driver for the database context */ public I_CmsHistoryDriver getHistoryDriver(CmsDbContext dbc) { if ((dbc == null) || (dbc.getProjectId() == null) || dbc.getProjectId().isNullUUID()) { return m_historyDriver; } I_CmsHistoryDriver driver = dbc.getHistoryDriver(dbc.getProjectId()); return driver != null ? driver : m_historyDriver; }
/** * Returns the user driver for a given database context.<p> * * @param dbc the database context * * @return the user driver for the database context */ public I_CmsUserDriver getUserDriver(CmsDbContext dbc) { if ((dbc == null) || (dbc.getProjectId() == null) || dbc.getProjectId().isNullUUID()) { return m_userDriver; } I_CmsUserDriver driver = dbc.getUserDriver(dbc.getProjectId()); return driver != null ? driver : m_userDriver; }
/** * Returns the VFS driver for the given database context.<p> * * @param dbc the database context * * @return a VFS driver */ public I_CmsVfsDriver getVfsDriver(CmsDbContext dbc) { if ((dbc == null) || (dbc.getProjectId() == null) || dbc.getProjectId().isNullUUID()) { return m_vfsDriver; } I_CmsVfsDriver driver = dbc.getVfsDriver(dbc.getProjectId()); return driver != null ? driver : m_vfsDriver; }
dbc.pop(); } catch (Throwable t) { dbc.report(report, Messages.get().container( Messages.ERR_WRITING_HISTORY_OF_PROJECT_1, dbc.currentProject().getName()), t); LOG.debug(Messages.get().getBundle().key( Messages.LOG_START_PUBLISHING_PROJECT_2, dbc.currentProject().getName(), dbc.currentUser().getName())); dbc.pop(); report.print(org.opencms.report.Messages.get().container( org.opencms.report.Messages.RPT_ARGUMENT_1, dbc.removeSiteRoot(currentFolder.getRootPath()))); report.print(org.opencms.report.Messages.get().container(org.opencms.report.Messages.RPT_DOTS_0)); report.println(org.opencms.report.Messages.get().container( dbc.pop(); } catch (Throwable t) { dbc.report(report, Messages.get().container( Messages.ERR_ERROR_PUBLISHING_FOLDER_1, currentFolder.getRootPath()), t); dbc.pop(); } catch (Throwable t) { dbc.report(report, Messages.get().container( Messages.ERR_ERROR_PUBLISHING_FILE_1,
/** * Updates/Creates the relations for the given resource.<p> * * @param context the current user context * @param resource the resource to update the relations for * @param relations the relations to update * * @throws CmsException if something goes wrong * * @see CmsDriverManager#updateRelationsForResource(CmsDbContext, CmsResource, List) */ public void updateRelationsForResource(CmsRequestContext context, CmsResource resource, List relations) throws CmsException { CmsDbContext dbc = m_dbContextFactory.getDbContext(context); try { m_driverManager.updateRelationsForResource(dbc, resource, relations); } catch (Exception e) { dbc.report(null, Messages.get().container( Messages.ERR_UPDATE_RELATIONS_1, dbc.removeSiteRoot(resource.getRootPath())), e); } finally { dbc.clear(); } }
/** * Returns a list with all projects from history.<p> * * @param context the current request context * * @return list of <code>{@link CmsHistoryProject}</code> objects * with all projects from history. * * @throws CmsException if operation was not successful */ public List getAllHistoricalProjects(CmsRequestContext context) throws CmsException { CmsDbContext dbc = m_dbContextFactory.getDbContext(context); List result = null; try { result = m_driverManager.getAllHistoricalProjects(dbc); } catch (Exception e) { dbc.report(null, Messages.get().container( Messages.ERR_GET_ALL_ACCESSIBLE_PROJECTS_1, dbc.currentUser().getName()), e); } finally { dbc.clear(); } return result; }
/** * Enumeration class for the mode parameter in the * {@link CmsDriverManager#readChangedResourcesInsideProject(CmsDbContext, CmsUUID, CmsReadChangedProjectResourceMode)} * method.<p> */ private static class CmsReadChangedProjectResourceMode { /** * Default constructor.<p> */ protected CmsReadChangedProjectResourceMode() { // noop } }
CmsProject currentProject = dbc.currentProject(); dbc.getRequestContext().setCurrentProject(project); try { relations = m_driverManager.getRelationsForResource(dbc, resource, CmsRelationFilter.SOURCES); } finally { dbc.getRequestContext().setCurrentProject(currentProject); report.println(Messages.get().container( Messages.LOG_LINK_SEARCH_1, dbc.removeSiteRoot(resource.getRootPath())), I_CmsReport.FORMAT_ERROR); new CmsDbContext(), project.getUuid(), relation.getTargetId(), new CmsDbContext(), project.getUuid(), relation.getTargetPath(), Messages.RPT_HTMLLINK_BROKEN_TARGET_2, relation.getSourcePath(), dbc.removeSiteRoot(link)), I_CmsReport.FORMAT_WARNING); } else { report.println(Messages.get().container( Messages.RPT_HTMLLINK_BROKEN_SOURCE_2, dbc.removeSiteRoot(link), relation.getTargetPath()), I_CmsReport.FORMAT_WARNING);
/** * Deletes all entries in the published resource table.<p> * * @param context the current request context * @param linkType the type of resource deleted (0= non-parameter, 1=parameter) * * @throws CmsException if something goes wrong */ public void deleteAllStaticExportPublishedResources(CmsRequestContext context, int linkType) throws CmsException { CmsDbContext dbc = m_dbContextFactory.getDbContext(context); try { m_driverManager.deleteAllStaticExportPublishedResources(dbc, linkType); } catch (Exception e) { dbc.report(null, Messages.get().container(Messages.ERR_DELETE_STATEXP_PUBLISHED_RESOURCES_0), e); } finally { dbc.clear(); } }
/** * Checks if the user of the current database context has permissions to impersonate the given role * for the given resource.<p> * * @param dbc the current OpenCms users database context * @param role the role to check * @param resource the resource to check the role for * * @throws CmsRoleViolationException if the user does not have the required role permissions * * @see org.opencms.security.CmsRoleManager#checkRole(CmsObject, CmsRole) */ public void checkRoleForResource(CmsDbContext dbc, CmsRole role, CmsResource resource) throws CmsRoleViolationException { if (!hasRoleForResource(dbc, dbc.currentUser(), role, resource)) { throw role.createRoleViolationExceptionForResource(dbc.getRequestContext(), resource); } }
/** * Reads all property definitions for the given mapping type.<p> * * @param dbc the current database context * * @return a list with the <code>{@link CmsPropertyDefinition}</code> objects (may be empty) * * @throws CmsException if something goes wrong */ public List readAllPropertyDefinitions(CmsDbContext dbc) throws CmsException { List returnValue = m_vfsDriver.readPropertyDefinitions(dbc, dbc.currentProject().getUuid()); Collections.sort(returnValue); return returnValue; }
/** * Returns the list of organizational units the given resource belongs to.<p> * * @param dbc the current database context * @param resource the resource * * @return list of {@link CmsOrganizationalUnit} objects * * @throws CmsException if something goes wrong */ public List getResourceOrgUnits(CmsDbContext dbc, CmsResource resource) throws CmsException { try { dbc.getRequestContext().setAttribute(I_CmsVfsDriver.REQ_ATTR_RESOURCE_OUS, Boolean.TRUE); return m_vfsDriver.readRelations( dbc, dbc.currentProject().getUuid(), resource, CmsRelationFilter.TARGETS.filterIncludeChildren()); } finally { dbc.getRequestContext().removeAttribute(I_CmsVfsDriver.REQ_ATTR_RESOURCE_OUS); } }
report.print(org.opencms.report.Messages.get().container( org.opencms.report.Messages.RPT_ARGUMENT_1, dbc.removeSiteRoot(offlineResource.getRootPath()))); report.print(org.opencms.report.Messages.get().container(org.opencms.report.Messages.RPT_DOTS_0)); dbc.pop(); report.print(org.opencms.report.Messages.get().container( org.opencms.report.Messages.RPT_ARGUMENT_1, dbc.removeSiteRoot(offlineResource.getRootPath()))); report.print(org.opencms.report.Messages.get().container(org.opencms.report.Messages.RPT_DOTS_0)); publishTag); dbc.pop(); report.print(org.opencms.report.Messages.get().container( org.opencms.report.Messages.RPT_ARGUMENT_1, dbc.removeSiteRoot(offlineResource.getRootPath()))); report.print(org.opencms.report.Messages.get().container(org.opencms.report.Messages.RPT_DOTS_0)); dbc.pop(); report.print(org.opencms.report.Messages.get().container( org.opencms.report.Messages.RPT_ARGUMENT_1, dbc.removeSiteRoot(offlineResource.getRootPath()))); report.print(org.opencms.report.Messages.get().container(org.opencms.report.Messages.RPT_DOTS_0)); report.println(
throws CmsException { CmsUUID projectId = ((dbc.getProjectId() == null) || dbc.getProjectId().isNullUUID()) ? dbc.currentProject().getUuid() : dbc.getProjectId(); CmsProject project = dbc.currentProject(); dbc.getRequestContext().setCurrentProject(m_driverManager.readProject(dbc, CmsProject.ONLINE_PROJECT_ID)); try { m_driverManager.getVfsDriver(dbc).writeResource( dbc, dbc.currentProject().getUuid(), resource, CmsDriverManager.NOTHING_CHANGED); } finally { dbc.getRequestContext().setCurrentProject(project);
} catch (CmsException e) { try { CmsProject onlineProject = dbc.currentProject(); CmsProject setupProject = onlineProject; new CmsDbContext(), I_CmsProjectDriver.SETUP_PROJECT_NAME); } catch (CmsException exc) { setupProject = m_driverManager.readProject(new CmsDbContext(), "Offline"); } catch (CmsException exc2) { dbc.getRequestContext().setCurrentProject(setupProject); try { createOrganizationalUnit(dbc, "", CmsMacroResolver.localizedKeyMacro( null), 0, null, "/"); } finally { dbc.getRequestContext().setCurrentProject(onlineProject);
/** * Returns the correct project id.<p> * * @param dbc the database context * * @return the correct project id */ private CmsUUID getProjectIdForContext(CmsDbContext dbc) { CmsUUID projectId = dbc.getProjectId(); if (projectId.isNullUUID()) { projectId = dbc.currentProject().getUuid(); } return projectId; }
CmsFlexRequestContextInfo info = dbc.getFlexRequestContextInfo(); List<CmsResource> result = new ArrayList<CmsResource>(resourceList.size()); for (int i = 0; i < resourceList.size(); i++) { CmsResource resource = resourceList.get(i); if (filter.isValid(dbc.getRequestContext(), resource)) { result.add(resource);