/** * 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; }
/** * Returns the project driver for a given DB context.<p> * * @param dbc the database context * * @return the project driver for the database context */ public I_CmsProjectDriver getProjectDriver(CmsDbContext dbc) { if ((dbc == null) || (dbc.getProjectId() == null) || dbc.getProjectId().isNullUUID()) { return m_projectDriver; } I_CmsProjectDriver driver = dbc.getProjectDriver(dbc.getProjectId()); return driver != null ? driver : m_projectDriver; }
/** * Returns either the user driver for the given DB context (if it has one) or a default value instead.<p> * * @param dbc the DB context * @param defaultDriver the driver that should be returned if no driver for the DB context was found * * @return either the user driver for the DB context, or <code>defaultDriver</code> if none were found */ public I_CmsUserDriver getUserDriver(CmsDbContext dbc, I_CmsUserDriver defaultDriver) { if ((dbc == null) || (dbc.getProjectId() == null) || dbc.getProjectId().isNullUUID()) { return defaultDriver; } I_CmsUserDriver driver = dbc.getUserDriver(dbc.getProjectId()); return driver != null ? driver : defaultDriver; }
/** * Returns either the project driver for the DB context (if it has one) or a default project driver.<p> * * @param dbc the DB context * @param defaultDriver the driver which should be returned if there is no project driver for the DB context * * @return either the project driver for the DB context, or the default driver */ public I_CmsProjectDriver getProjectDriver(CmsDbContext dbc, I_CmsProjectDriver defaultDriver) { if ((dbc == null) || (dbc.getProjectId() == null) || dbc.getProjectId().isNullUUID()) { return defaultDriver; } I_CmsProjectDriver driver = dbc.getProjectDriver(dbc.getProjectId()); return driver != null ? driver : defaultDriver; }
/** * @see org.opencms.db.I_CmsCacheKey#getCacheKeyForUserGroups(java.lang.String, org.opencms.db.CmsDbContext, org.opencms.file.CmsUser) */ public String getCacheKeyForUserGroups(String prefix, CmsDbContext context, CmsUser user) { if (!context.getProjectId().isNullUUID()) { return ""; } StringBuffer cacheBuffer = new StringBuffer(64); cacheBuffer.append(prefix); cacheBuffer.append('_'); cacheBuffer.append(user.getName()); return cacheBuffer.toString(); }
/** * @see org.opencms.db.I_CmsCacheKey#getCacheKeyForGroupUsers(java.lang.String, org.opencms.db.CmsDbContext, org.opencms.file.CmsGroup) */ public String getCacheKeyForGroupUsers(String prefix, CmsDbContext context, CmsGroup group) { if (!context.getProjectId().isNullUUID()) { return ""; } StringBuffer cacheBuffer = new StringBuffer(64); cacheBuffer.append(prefix); cacheBuffer.append('_'); cacheBuffer.append(group.getName()); return cacheBuffer.toString(); }
/** * @see org.opencms.db.I_CmsCacheKey#getCacheKeyForGroupUsers(java.lang.String, org.opencms.db.CmsDbContext, org.opencms.file.CmsGroup) */ public String getCacheKeyForGroupUsers(String prefix, CmsDbContext context, CmsGroup group) { if (!context.getProjectId().isNullUUID()) { return ""; } StringBuffer cacheBuffer = new StringBuffer(64); cacheBuffer.append(prefix); cacheBuffer.append('_'); cacheBuffer.append(group.getName()); return cacheBuffer.toString(); }
/** * @see org.opencms.db.I_CmsCacheKey#getCacheKeyForUserGroups(java.lang.String, org.opencms.db.CmsDbContext, org.opencms.file.CmsUser) */ public String getCacheKeyForUserGroups(String prefix, CmsDbContext context, CmsUser user) { if (!context.getProjectId().isNullUUID()) { return ""; } StringBuffer cacheBuffer = new StringBuffer(64); cacheBuffer.append(prefix); cacheBuffer.append('_'); cacheBuffer.append(user.getName()); return cacheBuffer.toString(); }
/** * @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(); } }
/** * @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 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; }
/** * 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; }
/** * 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 } }
/** * Reads the resources that were published in a publish task for a given publish history ID.<p> * * @param dbc the current database context * @param publishHistoryId unique int ID to identify each publish task in the publish history * * @return a list of <code>{@link org.opencms.db.CmsPublishedResource}</code> objects * * @throws CmsException if something goes wrong */ public List readPublishedResources(CmsDbContext dbc, CmsUUID publishHistoryId) throws CmsException { String cacheKey = publishHistoryId.toString(); List resourceList = m_monitor.getCachedPublishedResources(cacheKey); if ((resourceList == null) || !dbc.getProjectId().isNullUUID()) { resourceList = m_projectDriver.readPublishedResources(dbc, publishHistoryId); // store the result in the cache if (dbc.getProjectId().isNullUUID()) { m_monitor.cachePublishedResources(cacheKey, resourceList); } } return resourceList; }
/** * Updates the state of a resource, depending on the <code>resourceState</code> parameter.<p> * * @param dbc the db context * @param resource the resource * @param resourceState if <code>true</code> the resource state will be updated, if not just the structure state. * * @throws CmsDataAccessException if something goes wrong */ private void updateState(CmsDbContext dbc, CmsResource resource, boolean resourceState) throws CmsDataAccessException { CmsUUID projectId = ((dbc.getProjectId() == null) || dbc.getProjectId().isNullUUID()) ? dbc.currentProject().getUuid() : dbc.getProjectId(); resource.setUserLastModified(dbc.currentUser().getId()); if (resourceState) { // update the whole resource state getVfsDriver(dbc).writeResource(dbc, projectId, resource, UPDATE_RESOURCE_STATE); } else { // update the structure state getVfsDriver(dbc).writeResource(dbc, projectId, resource, UPDATE_STRUCTURE_STATE); } }
/** * Reads the resources that were published in a publish task for a given publish history ID.<p> * * @param dbc the current database context * @param publishHistoryId unique int ID to identify each publish task in the publish history * * @return a list of <code>{@link org.opencms.db.CmsPublishedResource}</code> objects * * @throws CmsException if something goes wrong */ public List<CmsPublishedResource> readPublishedResources(CmsDbContext dbc, CmsUUID publishHistoryId) throws CmsException { String cacheKey = publishHistoryId.toString(); List<CmsPublishedResource> resourceList = m_monitor.getCachedPublishedResources(cacheKey); if ((resourceList == null) || !dbc.getProjectId().isNullUUID()) { resourceList = getProjectDriver(dbc).readPublishedResources(dbc, publishHistoryId); // store the result in the cache if (dbc.getProjectId().isNullUUID()) { m_monitor.cachePublishedResources(cacheKey, resourceList); } } return resourceList; }
/** * Writes an already existing group.<p> * * The group id has to be a valid OpenCms group id.<br> * * The group with the given id will be completely overridden * by the given data.<p> * * @param dbc the current database context * @param group the group that should be written * * @throws CmsException if operation was not successful */ public void writeGroup(CmsDbContext dbc, CmsGroup group) throws CmsException { CmsGroup oldGroup = readGroup(dbc, group.getName()); m_monitor.uncacheGroup(oldGroup); getUserDriver(dbc).writeGroup(dbc, group); m_monitor.cacheGroup(group); if (!dbc.getProjectId().isNullUUID()) { // group modified event is not needed return; } // fire group modified event Map<String, Object> eventData = new HashMap<String, Object>(); eventData.put(I_CmsEventListener.KEY_GROUP_ID, group.getId().toString()); eventData.put(I_CmsEventListener.KEY_GROUP_NAME, oldGroup.getName()); eventData.put(I_CmsEventListener.KEY_USER_ACTION, I_CmsEventListener.VALUE_GROUP_MODIFIED_ACTION_WRITE); OpenCms.fireCmsEvent(new CmsEvent(I_CmsEventListener.EVENT_GROUP_MODIFIED, eventData)); }
/** * 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 } }