/** * Adds an alias entry.<p> * * @param dbc the database context * @param project the current project * @param alias the alias to add * * @throws CmsException if something goes wrong */ public void addAlias(CmsDbContext dbc, CmsProject project, CmsAlias alias) throws CmsException { I_CmsVfsDriver vfsDriver = getVfsDriver(dbc); vfsDriver.insertAlias(dbc, project, alias); }
/** * Gets the rewrite aliases matching a given filter.<p> * * @param dbc the current database context * @param filter the filter used for filtering rewrite aliases * * @return the rewrite aliases matching the given filter * * @throws CmsException if something goes wrong */ public List<CmsRewriteAlias> getRewriteAliases(CmsDbContext dbc, CmsRewriteAliasFilter filter) throws CmsException { return getVfsDriver(dbc).readRewriteAliases(dbc, filter); }
/** * Deletes aliases indicated by a filter.<p> * * @param dbc the current database context * @param project the current project * @param filter the filter which describes which aliases to delete * * @throws CmsException if something goes wrong */ public void deleteAliases(CmsDbContext dbc, CmsProject project, CmsAliasFilter filter) throws CmsException { I_CmsVfsDriver vfsDriver = getVfsDriver(dbc); vfsDriver.deleteAliases(dbc, project, filter); }
/** * Increments a counter and returns its value before incrementing.<p> * * @param dbc the current database context * @param name the name of the counter which should be incremented * * @return the value of the counter * * @throws CmsException if something goes wrong */ public int incrementCounter(CmsDbContext dbc, String name) throws CmsException { return getVfsDriver(dbc).incrementCounter(dbc, name); }
/** * Reads URL name mapping entries which match the given filter.<p> * * @param dbc the database context * @param online if true, read online URL name mappings, else offline ones * @param filter the filter for matching the URL name entries * * @return the list of URL name mapping entries which match the given filter * * @throws CmsDataAccessException if something goes wrong */ public List<CmsUrlNameMappingEntry> readUrlNameMappingEntries( CmsDbContext dbc, boolean online, CmsUrlNameMappingFilter filter) throws CmsDataAccessException { I_CmsVfsDriver vfsDriver = getVfsDriver(dbc); return vfsDriver.readUrlNameMappingEntries(dbc, online, filter); }
/** * Reads the aliases which point to a given structure id.<p> * * @param dbc the current database context * @param project the current project * @param structureId the structure id for which we want to read the aliases * * @return the list of aliases pointing to the structure id * @throws CmsException if something goes wrong */ public List<CmsAlias> readAliasesByStructureId(CmsDbContext dbc, CmsProject project, CmsUUID structureId) throws CmsException { return getVfsDriver(dbc).readAliases(dbc, project, new CmsAliasFilter(null, null, structureId)); }
/** * Writes a new project into the PROJECT_LASTMODIFIED field of a resource record.<p> * * @param dbc the current database context * @param resource the resource which should be modified * @param projectId the project id to write * * @throws CmsDataAccessException if the database access fails */ public void writeProjectLastModified(CmsDbContext dbc, CmsResource resource, CmsUUID projectId) throws CmsDataAccessException { I_CmsVfsDriver vfsDriver = getVfsDriver(dbc); vfsDriver.writeLastModifiedProjectId(dbc, dbc.currentProject(), projectId, resource); }
/** * Reads the aliases for a given site root.<p> * * @param dbc the current database context * @param currentProject the current project * @param siteRoot the site root * * @return the list of aliases for the given site root * * @throws CmsException if something goes wrong */ public List<CmsAlias> readAliasesBySite(CmsDbContext dbc, CmsProject currentProject, String siteRoot) throws CmsException { return getVfsDriver(dbc).readAliases(dbc, currentProject, new CmsAliasFilter(siteRoot, null, null)); }
/** * Replaces the complete list of rewrite aliases for a given site root.<p> * * @param dbc the current database context * @param siteRoot the site root for which the rewrite aliases should be replaced * @param newAliases the new aliases for the given site root * @throws CmsException if something goes wrong */ public void saveRewriteAliases(CmsDbContext dbc, String siteRoot, List<CmsRewriteAlias> newAliases) throws CmsException { CmsRewriteAliasFilter filter = new CmsRewriteAliasFilter().setSiteRoot(siteRoot); getVfsDriver(dbc).deleteRewriteAliases(dbc, filter); getVfsDriver(dbc).insertRewriteAliases(dbc, newAliases); }
/** * Returns all relations for the given resource matching the given filter.<p> * * @param dbc the current db context * @param resource the resource to retrieve the relations for * @param filter the filter to match the relation * * @return all relations for the given resource matching the given filter * * @throws CmsException if something goes wrong * * @see CmsSecurityManager#getRelationsForResource(CmsRequestContext, CmsResource, CmsRelationFilter) */ public List<CmsRelation> getRelationsForResource(CmsDbContext dbc, CmsResource resource, CmsRelationFilter filter) throws CmsException { CmsUUID projectId = getProjectIdForContext(dbc); return getVfsDriver(dbc).readRelations(dbc, projectId, resource, filter); }
/** * 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<CmsPropertyDefinition> readAllPropertyDefinitions(CmsDbContext dbc) throws CmsException { List<CmsPropertyDefinition> result = getVfsDriver(dbc).readPropertyDefinitions( dbc, dbc.currentProject().getUuid()); Collections.sort(result); return result; }
/** * Tests if a resource with the given resourceId does already exist in the Database.<p> * * @param dbc the current database context * @param resourceId the resource id to test for * @return true if a resource with the given id was found, false otherweise * @throws CmsException if something goes wrong */ public boolean existsResourceId(CmsDbContext dbc, CmsUUID resourceId) throws CmsException { return getVfsDriver(dbc).validateResourceIdExists(dbc, dbc.currentProject().getUuid(), resourceId); }
/** * Reads the parent folder to a given structure id.<p> * * @param dbc the current database context * @param structureId the structure id of the child * * @return the parent folder resource * * @throws CmsDataAccessException if something goes wrong */ public CmsResource readParentFolder(CmsDbContext dbc, CmsUUID structureId) throws CmsDataAccessException { return getVfsDriver(dbc).readParentFolder(dbc, dbc.currentProject().getUuid(), structureId); }
/** * 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<CmsOrganizationalUnit> getResourceOrgUnits(CmsDbContext dbc, CmsResource resource) throws CmsException { List<CmsOrganizationalUnit> result = getVfsDriver(dbc).getResourceOus( dbc, dbc.currentProject().getUuid(), resource); return result; }
/** * Reads the URL name mappings matching the given filter.<p> * * @param dbc the DB context to use * @param filter the filter used to select the mapping entries * @return the entries matching the given filter * * @throws CmsDataAccessException if something goes wrong */ public List<CmsUrlNameMappingEntry> readUrlNameMappings(CmsDbContext dbc, CmsUrlNameMappingFilter filter) throws CmsDataAccessException { List<CmsUrlNameMappingEntry> entries = getVfsDriver(dbc).readUrlNameMappingEntries( dbc, dbc.currentProject().isOnlineProject(), filter); return entries; }
/** * Reads a property definition.<p> * * If no property definition with the given name is found, * <code>null</code> is returned.<p> * * @param dbc the current database context * @param name the name of the property definition to read * * @return the property definition that was read * * @throws CmsException a CmsDbEntryNotFoundException is thrown if the property definition does not exist */ public CmsPropertyDefinition readPropertyDefinition(CmsDbContext dbc, String name) throws CmsException { return getVfsDriver(dbc).readPropertyDefinition(dbc, name, dbc.currentProject().getUuid()); }
/** * 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); } }
/** * 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 } }
/** * Removes a resource after it has been deleted by the driver manager.<p> * * @param dbc the current database context * @param resourceName the root path of the deleted resource * @throws CmsException if something goes wrong */ public void removeDeletedResource(CmsDbContext dbc, String resourceName) throws CmsException { try { m_driverManager.getVfsDriver(dbc).readResource(dbc, dbc.currentProject().getUuid(), resourceName, false); throw new CmsLockException( Messages.get().container( Messages.ERR_REMOVING_UNDELETED_RESOURCE_1, dbc.getRequestContext().removeSiteRoot(resourceName))); } catch (CmsVfsResourceNotFoundException e) { // ok, ignore } unlockResource(resourceName, true); unlockResource(resourceName, false); }
/** * Removes a resource after it has been deleted by the driver manager.<p> * * @param dbc the current database context * @param resourceName the root path of the deleted resource * @throws CmsException if something goes wrong */ public void removeDeletedResource(CmsDbContext dbc, String resourceName) throws CmsException { try { m_driverManager.getVfsDriver().readResource(dbc, dbc.currentProject().getUuid(), resourceName, false); throw new CmsLockException(Messages.get().container( Messages.ERR_REMOVING_UNDELETED_RESOURCE_1, dbc.getRequestContext().removeSiteRoot(resourceName))); } catch (CmsVfsResourceNotFoundException e) { // ok, ignore } unlockResource(resourceName, true); unlockResource(resourceName, false); }