/** * 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; }
/** * 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 m_vfsDriver.validateResourceIdExists(dbc, dbc.currentProject().getUuid(), resourceId); }
/** * @see org.opencms.db.I_CmsVfsDriver#writeContent(CmsDbContext, CmsUUID, byte[]) */ @Override public void writeContent(CmsDbContext dbc, CmsUUID resourceId, byte[] content) throws CmsDataAccessException { internalWriteContent(dbc, dbc.currentProject().getUuid(), resourceId, content, -1); }
/** * @see org.opencms.db.I_CmsVfsDriver#writeContent(CmsDbContext, CmsUUID, byte[]) */ @Override public void writeContent(CmsDbContext dbc, CmsUUID resourceId, byte[] content) throws CmsDataAccessException { internalWriteContent(dbc, dbc.currentProject().getUuid(), resourceId, content, -1); }
/** * 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 an access control entry from the cms.<p> * * The access control entries of a resource are readable by everyone. * * @param dbc the current database context * @param resource the resource * @param principal the id of a group or a user any other entity * @return an access control entry that defines the permissions of the entity for the given resource * @throws CmsException if something goes wrong */ public CmsAccessControlEntry readAccessControlEntry(CmsDbContext dbc, CmsResource resource, CmsUUID principal) throws CmsException { return m_userDriver.readAccessControlEntry(dbc, dbc.currentProject(), resource.getResourceId(), principal); }
/** * Reads all access control entries.<p> * * @param dbc the current database context * @return all access control entries for the current project (offline/online) * * @throws CmsException if something goes wrong */ public List<CmsAccessControlEntry> getAllAccessControlEntries(CmsDbContext dbc) throws CmsException { I_CmsUserDriver userDriver = getUserDriver(dbc); List<CmsAccessControlEntry> ace = userDriver.readAccessControlEntries( dbc, dbc.currentProject(), CmsAccessControlEntry.PRINCIPAL_READALL_ID, false); return ace; }
/** * 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, * or <code>null</code> if there is no property definition with the given name. * * @throws CmsException if something goes wrong */ public CmsPropertyDefinition readPropertyDefinition(CmsDbContext dbc, String name) throws CmsException { return m_vfsDriver.readPropertyDefinition(dbc, name, dbc.currentProject().getUuid()); }
/** * 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 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; }
/** * 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()); }
/** * 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; }
/** * @see org.opencms.db.I_CmsVfsDriver#writeContent(org.opencms.db.CmsDbContext, org.opencms.util.CmsUUID, byte[]) */ public void writeContent(CmsDbContext dbc, CmsUUID resourceId, byte[] content) throws CmsDataAccessException { try { Query q = m_sqlManager.createQuery(dbc, dbc.currentProject(), C_OFFLINE_CONTENTS_UPDATE); // update the file content in the database. q.setParameter(1, resourceId.toString()); @SuppressWarnings("unchecked") List<CmsDAOOfflineContents> res = q.getResultList(); for (CmsDAOOfflineContents oc : res) { oc.setFileContent(content); } } catch (PersistenceException e) { throw new CmsDataAccessException(Messages.get().container(Messages.ERR_JPA_PERSITENCE_1, e), e); } }
/** * Checks if the project in the given database context is not the "Online" project, * and throws an Exception if this is the case.<p> * * This is used to ensure a user is in an "Offline" project * before write access to VFS resources is granted.<p> * * @param dbc the current OpenCms users database context * * @throws CmsVfsException if the project in the given database context is the "Online" project */ public void checkOfflineProject(CmsDbContext dbc) throws CmsVfsException { if (dbc.currentProject().isOnlineProject()) { throw new CmsVfsException(org.opencms.file.Messages.get().container( org.opencms.file.Messages.ERR_NOT_ALLOWED_IN_ONLINE_PROJECT_0)); } }
/** * Checks if the project in the given database context is not the "Online" project, * and throws an Exception if this is the case.<p> * * This is used to ensure a user is in an "Offline" project * before write access to VFS resources is granted.<p> * * @param dbc the current OpenCms users database context * * @throws CmsVfsException if the project in the given database context is the "Online" project */ public void checkOfflineProject(CmsDbContext dbc) throws CmsVfsException { if (dbc.currentProject().isOnlineProject()) { throw new CmsVfsException( org.opencms.file.Messages.get().container( org.opencms.file.Messages.ERR_NOT_ALLOWED_IN_ONLINE_PROJECT_0)); } }
/** * 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 } }