Class CmsObject
It encapsulates user identification and permissions.
Think of it as an initialized "shell" to access the OpenCms VFS.
Every call to a method here will be checked for user permissions
according to the
this CmsObject instance was created with.CmsRequestContext
From a JSP page running in OpenCms, use
to gain
access to the current users CmsObject. Usually this is done with a CmsJspBean.getCmsObject()
.CmsJspActionElement
To generate a new instance of this class in your application, use
. The argument String should be
the name of the guest user, usually "Guest" and more formally obtained by OpenCms.initCmsObject(String)
.
This will give you an initialized context with guest user permissions.
Then use CmsDefaultUsers.getUserGuest()
to log in the user you want.
Obviously you need the password for the new user.
You should never try to create an instance of this class using the constructor,
this is reserved for internal operation only.loginUser(String, String)
- Since:
- 6.0.0
-
Field Summary
Modifier and TypeFieldDescriptionprotected CmsRequestContext
The request context.protected CmsSecurityManager
The security manager to access the cms. -
Constructor Summary
ConstructorDescriptionCmsObject
(CmsSecurityManager securityManager, CmsRequestContext context) Connects an OpenCms user context to a running database. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addRelationToResource
(String resourceName, String targetPath, String type) Adds a new relation to the given resource.void
addRelationToResource
(CmsResource resource, CmsResource target, String type) Adds a new relation to the given resource.addSiteRoot
(String resourcename) Convenience method to add the site root from the current user's request context to the given resource name.void
addUserToGroup
(String username, String groupname) Adds a user to a group.void
adjustLinks
(String sourceFolder, String targetFolder) Adjusts all links in the target folder that point to the source folder so that they are kept "relative" in the target folder where possible.void
adjustLinks
(List<String> sourceFiles, String targetParentFolder) This method works just likeadjustLinks(String, String)
, but you can specify multiple source files, and the target folder is interpreted as the folder into which the source files have been copied.void
adjustLinks
(Map<String, String> sourceTargetMap, String targetParentFolder) This method works just likeadjustLinks(String, String)
, but instead of specifying a single source and target folder, you can specify multiple sources and the corresponding targets in a map of strings.void
chacc
(String resourceName, String principalType, String principalName, int allowedPermissions, int deniedPermissions, int flags) Changes the access control for a given resource and a given principal(user/group).void
Changes the access control for a given resource and a given principal(user/group).void
changeLock
(String resourcename) Changes the lock of a resource to the current user, that is "steals" the lock from another user.void
changeLock
(CmsResource resource) Changes the lock of a resource to the current user, that is "steals" the lock from another user.changeResourcesInFolderWithProperty
(String resourcename, String property, String oldValue, String newValue, boolean recursive) Returns a list with all sub resources of a given folder that have set the given property, matching the current property's value with the given old value and replacing it by a given new value.void
checkLoginUser
(String userName, String password) Checks if a login for the given user name and password would work without taking two-factor authentication into account.void
Changes the resource flags of a resource.void
Deprecated.void
chtype
(String resourcename, I_CmsResourceType type) Changes the resource type of a resource.void
chtype
(CmsResource resource, I_CmsResourceType type) Changes the resource type of a resource.void
copyResource
(String source, String destination) Copies a resource.void
copyResource
(String source, String destination, CmsResource.CmsResourceCopyMode siblingMode) Copies a resource.void
copyResourceToProject
(String resourcename) Copies a resource to the current project of the user.void
copyResourceToProject
(CmsResource resource) Copies a resource to the current project of the user.int
Counts the locked resources in a project.void
Copies access control entries of a given resource to another resource.createGroup
(String groupFqn, String description, int flags, String parent) Creates a new user group.createProject
(String name, String description, String groupname, String managergroupname) Creates a new project.createProject
(String name, String description, String groupname, String managergroupname, CmsProject.CmsProjectType projecttype) Creates a new project.Creates a property definition.createResource
(String resourcename, int type) Deprecated.UsecreateResource(String, I_CmsResourceType)
instead.createResource
(String resourcename, int type, byte[] content, List<CmsProperty> properties) Deprecated.createResource
(String sitePath, CmsResource resource, byte[] content, List<CmsProperty> properties) Creates a resource with the given properties and content.createResource
(String resourcename, I_CmsResourceType type) Creates a new resource of the given resource type with empty content and no properties.createResource
(String resourcename, I_CmsResourceType type, byte[] content, List<CmsProperty> properties) Creates a new resource of the given resource type with the provided content and properties.createSibling
(String source, String destination, List<CmsProperty> properties) Creates a new sibling of the source resource.Creates the project for the temporary workplace files.Creates a new user.void
deleteAllStaticExportPublishedResources
(int linkType) Deletes all published resource entries.void
deleteGroup
(String group) Deletes a user group.void
deleteGroup
(CmsUUID groupId, CmsUUID replacementId) Deletes a group, where all permissions, users and children of the group are transfered to a replacement group.void
deleteHistoricalVersions
(int versionsToKeep, int versionsDeleted, long timeDeleted, I_CmsReport report) Deletes the versions from the history tables, keeping the given number of versions per resource.void
deleteLogEntries
(CmsLogFilter filter) Deletes the log entries matching the given filter.void
deleteProject
(CmsUUID id) Deletes a project.void
Deletes a property definition.void
deleteRelationsFromResource
(String resourceName, CmsRelationFilter filter) Deletes the relations to a given resource.void
deleteRelationsFromResource
(CmsResource resource, CmsRelationFilter filter) Deletes the relations to a given resource.void
deleteResource
(String resourcename, CmsResource.CmsResourceDeleteMode siblingMode) Deletes a resource given its name.void
deleteResource
(CmsResource res, CmsResource.CmsResourceDeleteMode deletePreserveSiblings) Deletes a resource.void
deleteStaticExportPublishedResource
(String resourceName, int linkType, String linkParameter) Deletes a published resource entry.void
deleteUser
(String username) Deletes a user.void
deleteUser
(CmsUUID userId) Deletes a user.void
deleteUser
(CmsUUID userId, CmsUUID replacementId) Deletes a user, where all permissions and resources attributes of the user were transfered to a replacement user.boolean
existsResource
(String resourcename) Checks the availability of a resource in the VFS, using the
filter.CmsResourceFilter.DEFAULT
boolean
existsResource
(String resourcename, CmsResourceFilter filter) Checks the availability of a resource in the VFS, using the provided filter.boolean
existsResource
(CmsUUID structureId) Checks the availability of a resource in the VFS, using the
filter.CmsResourceFilter.DEFAULT
boolean
existsResource
(CmsUUID structureId, CmsResourceFilter filter) Checks the availability of a resource in the VFS, using the
filter.CmsResourceFilter.DEFAULT
getAccessControlEntries
(String resourceName) Returns the list of access control entries of a resource given its name.getAccessControlEntries
(String resourceName, boolean getInherited) Returns the list of access control entries of a resource given its name.getAccessControlList
(String resourceName) Returns the access control list (summarized access control entries) of a given resource.getAccessControlList
(String resourceName, boolean inheritedOnly) Returns the access control list (summarized access control entries) of a given resource.Gets all access control entries for the current project.Returns a list with all projects from history.Gets all URL names for a given structure id.getBlockingLockedResources
(String resourceName) Returns a list of child resources to the given resource that can not be locked by the current user.getBlockingLockedResources
(CmsResource resource) Returns a list of child resources to the given resource that can not be locked by the current user.getChildren
(String groupname, boolean includeSubChildren) Returns all child groups of a group.getDetailName
(CmsResource res, Locale locale, List<Locale> defaultLocales) Returns the detail name of a resource.getFilesInFolder
(String resourcename) Returns all file resources contained in a folder.getFilesInFolder
(String resourcename, CmsResourceFilter filter) Returns all file resources contained in a folder.getGroupsOfUser
(String username, boolean directGroupsOnly) Returns all the groups the given user belongs to.getGroupsOfUser
(String username, boolean directGroupsOnly, boolean includeOtherOus) Returns all the groups the given user belongs to.getGroupsOfUser
(String username, boolean directGroupsOnly, boolean includeOtherOus, String remoteAddress) Returns the groups of a user filtered by the specified IP address.Creates a new locale group service.Returns the lock state for a specified resource name.getLock
(CmsResource resource) Returns the edition lock state for a specified resource.getLockedResources
(String resourceName, CmsLockFilter filter) Returns all locked resources within a folder or matches the lock of the given resource.getLockedResources
(CmsResource resource, CmsLockFilter filter) Returns all locked resources within a folder or matches the lock of the given resource.getLockedResourcesWithCache
(CmsResource resource, CmsLockFilter filter, Map<String, CmsResource> cache) Returns all locked resources within a folder or matches the lock of the given resource, but uses a cache for resource lookup.getLogEntries
(CmsLogFilter filter) Returns all log entries matching the given filter.getLostAndFoundName
(String resourcename) Returns the name a resource would have if it were moved to the "lost and found" folder.Returns the parent group of a group.getPermissions
(String resourceName) Returns the set of permissions of the current user for a given resource.getPermissions
(String resourceName, String userName) Returns the set of permissions of a given user for a given resource.getRelationsForResource
(String resourceName, CmsRelationFilter filter) Returns all relations for the given resource matching the given filter.getRelationsForResource
(CmsResource resource, CmsRelationFilter filter) Returns all relations for the given resource matching the given filter.Returns the current users request context.getResourcesForPrincipal
(CmsUUID principalId, CmsPermissionSet permissions, boolean includeAttr) Returns all resources associated to a given principal via an ACE with the given permissions.getResourcesInFolder
(String resourcename, CmsResourceFilter filter) Returns all child resources of a resource, that is the resources contained in a folder.getSitePath
(CmsResource resource) Adjusts the absolute resource root path for the current site.getSubFolders
(String resourcename) Returns all folder resources contained in a folder.getSubFolders
(String resourcename, CmsResourceFilter filter) Returns all folder resources contained in a folder.Returns the newest URL names for the given structure id for each locale.getUsersOfGroup
(String groupname) Returns all direct users of a given group.getUsersOfGroup
(String groupname, boolean includeOtherOus) Returns all direct users of a given group.boolean
hasPermissions
(CmsResource resource, CmsPermissionSet requiredPermissions) Checks if the current user has required permissions to access a given resource.boolean
hasPermissions
(CmsResource resource, CmsPermissionSet requiredPermissions, boolean checkLock, CmsResourceFilter filter) Checks if the current user has required permissions to access a given resource.void
importAccessControlEntries
(CmsResource resource, List<CmsAccessControlEntry> acEntries) Writes a list of access control entries as new access control entries of a given resource.void
importRelation
(String resourceName, String targetPath, String relationType) Imports a new relation to the given resource.importResource
(String resourcename, CmsResource resource, byte[] content, List<CmsProperty> properties) Imports a resource to the OpenCms VFS.importResource
(String resourcename, I_CmsReport report, CmsResource resource, byte[] content, List<CmsProperty> properties) Imports a resource to the OpenCms VFS.importUser
(String id, String name, String password, String firstname, String lastname, String email, int flags, long dateCreated, Map<String, Object> additionalInfos) Creates a new user by import.int
incrementCounter
(String name) Increments a counter and returns its old value.boolean
isInsideCurrentProject
(String resourcename) Checks if the specified resource is inside the current project.boolean
Checks if the current user has management access to the current project.void
lockResource
(String resourcename) Locks a resource.void
lockResource
(CmsResource resource) Locks a resource.void
lockResourceShallow
(CmsResource resource) Locks the given resource with a shallow lock that is not inherited on subresources.void
lockResourceTemporary
(String resourcename) Locks a resource temporary.void
lockResourceTemporary
(CmsResource resource) Locks a resource temporary.Logs a user into the Cms, if the password is correct.Logs a user with a given ip address into the Cms, if the password is correct.loginUser
(String username, String password, CmsSecondFactorInfo code) Logs in the user.loginUser
(String username, String password, CmsSecondFactorInfo code, String remoteAddress) Logs a user with a given ip address into the Cms, if the password is correct.lookupPrincipal
(String principalName) Lookups and reads the user or group with the given name.lookupPrincipal
(CmsUUID principalId) Lookups and reads the user or group with the given UUID.void
moveResource
(String source, String destination) Moves a resource to the given destination.moveToLostAndFound
(String resourcename) Moves a resource to the "lost and found" folder.readAllAvailableVersions
(String resourceName) Reads all historical versions of a resource.
The reading excludes the file content, if the resource is a file.readAllAvailableVersions
(CmsResource resource) Reads all available versions for a given resource.Reads all property definitions.readAncestor
(String resourcename, int type) Returns the first ancestor folder matching the resource type.readAncestor
(String resourcename, CmsResourceFilter filter) Returns the first ancestor folder matching the filter criteria.readBestUrlName
(CmsUUID id, Locale locale, List<Locale> defaultLocales) Reads the newest URL name which is mapped to the given structure id.readDefaultFile
(String resourceNameOrID) Returns the default resource for the given folder.readDefaultFile
(String resourceNameOrID, CmsResourceFilter filter) Returns the default resource for the given folder.readDefaultFile
(CmsResource folderResource, CmsResourceFilter resourceFilter) Returns the default resource for the given folder.readDeletedResources
(String resourcename, boolean readTree) Reads all deleted (historical) resources below the given path, including the full tree below the path, if required.Reads a file resource (including it's binary content) from the VFS, using the
filter.CmsResourceFilter.DEFAULT
readFile
(String resourcename, CmsResourceFilter filter) Reads a file resource (including it's binary content) from the VFS, using the specified resource filter.readFile
(CmsResource resource) Reads a file resource (including it's binary content) from the VFS, for the given resource (this may also be an historical version of the resource).readFolder
(String resourcename) Reads a folder resource from the VFS, using the
filter.CmsResourceFilter.DEFAULT
readFolder
(String resourcename, CmsResourceFilter filter) Reads a folder resource from the VFS, using the specified resource filter.Reads a group based on its name.readGroup
(CmsProject project) Reads the group of a project.Reads a group based on its id.readHistoryPrincipal
(CmsUUID principalId) Reads a principal (an user or group) from the historical archive based on its ID.readHistoryProject
(int publishTag) Returns a historical project entry.readHistoryProject
(CmsUUID projectId) Returns the latest historical project entry with the given id.Reads the list of all
objects that belong to the given historical resource version.CmsProperty
readIdForUrlName
(String name) This method retrieves the structure id which is mapped to a given URL name.readManagerGroup
(CmsProject project) Returns the project manager group of a project.readOwner
(CmsProject project) Reads the owner of a project.readParentFolder
(CmsUUID structureId) Returns the parent folder to the given structure id.readPath
(String path, CmsResourceFilter filter) Builds a list of resources for a given path.readPath
(CmsResource resource, CmsResourceFilter filter) Builds a list of resources for a given path.readProject
(String name) Reads the project with the given name.readProject
(CmsUUID id) Reads the project with the given id.readProjectResources
(CmsProject project) Returns the list of all resource names that define the "view" of the given project.readProjectView
(CmsUUID projectId, CmsResourceState state) Reads all resources of a project that match a given state from the VFS.readPropertyDefinition
(String name) Reads a property definition.readPropertyObject
(String resourcePath, String property, boolean search) Reads a property object from a resource specified by a property name.readPropertyObject
(String resourcePath, String property, boolean search, Locale locale) Reads the locale specific version of a property object from a resource specified by a property name.readPropertyObject
(CmsResource resource, String property, boolean search) Reads a property object from a resource specified by a property name.readPropertyObject
(CmsResource resource, String property, boolean search, Locale locale) Reads the locale specific version of a property object from a resource specified by a property name.readPropertyObjects
(String resourcePath, boolean search) Reads all property objects from a resource.readPropertyObjects
(CmsResource resource, boolean search) Reads all property objects from a resource.readPublishedResources
(CmsUUID publishHistoryId) Reads the resources that were published in a publish task for a given publish history ID.readRelations
(CmsRelationFilter filter) Returns all relations matching the given filter.readResource
(String resourcename) Reads a resource from the VFS, using the
filter.CmsResourceFilter.DEFAULT
readResource
(String resourcename, CmsResourceFilter filter) Reads a resource from the VFS, using the specified resource filter.readResource
(CmsUUID structureID) Reads a resource from the VFS, using the
filter.CmsResourceFilter.DEFAULT
readResource
(CmsUUID structureID, int version) Reads the historical resource with the given version for the resource given the given structure id.readResource
(CmsUUID structureID, CmsResourceFilter filter) Reads a resource from the VFS, using the specified resource filter.readResources
(String resourcename, CmsResourceFilter filter) Reads all resources below the given path matching the filter criteria, including the full tree below the path.readResources
(String resourcename, CmsResourceFilter filter, boolean readTree) Reads all resources below the given path matching the filter criteria, including the full tree below the path only in case thereadTree
parameter istrue
.readResources
(CmsResource resource, CmsResourceFilter filter, boolean readTree) Reads all resources below the given resource matching the filter criteria, including the full tree below the path only in case thereadTree
parameter istrue
.readResourcesWithProperty
(String propertyDefinition) Reads all resources that have a value set for the specified property.readResourcesWithProperty
(String path, String propertyDefinition) Reads all resources that have a value set for the specified property in the given path.readResourcesWithProperty
(String path, String propertyDefinition, String value) Reads all resources that have a value (containing the specified value) set for the specified property in the given path.readResourcesWithProperty
(String path, String propertyDefinition, String value, CmsResourceFilter filter) Reads all resources that have a value (containing the specified value) set for the specified property in the given path.readResponsiblePrincipals
(CmsResource resource) Returns a set of principals that are responsible for a specific resource.readResponsibleUsers
(CmsResource resource) Returns a set of users that are responsible for a specific resource.readSiblings
(String resourcename, CmsResourceFilter filter) Returns a list of all siblings of the specified resource, the specified resource being always part of the result set.readSiblings
(CmsResource resource, CmsResourceFilter filter) Returns a list of all siblings of the specified resource, the specified resource being always part of the result set.readSiblingsForResourceId
(CmsUUID resourceId, CmsResourceFilter filter) Reads all resources with the given resource id.Returns the parameters of a resource in the list of all published template resources.readStaticExportResources
(int parameterResources, long timestamp) Returns a list of all template resources which must be processed during a static export.Reads the URL name mappings matching a given filter.readUrlNamesForAllLocales
(CmsUUID structureId) Reads the URL names for all locales.Reads a user based on its name.Returns a user, if the password is correct.Reads a user based on its id.void
removeResourceFromProject
(String resourcename) Removes a resource from the current project of the user.void
removeUserFromGroup
(String username, String groupname) Removes a user from a group.void
renameResource
(String source, String destination) Renames a resource to the given destination name, this is identical to amove
operation.void
replaceResource
(String resourcename, int type, byte[] content, List<CmsProperty> properties) Deprecated.void
replaceResource
(String resourcename, I_CmsResourceType type, byte[] content, List<CmsProperty> properties) Replaces the content, type and properties of a resource.void
restoreDeletedResource
(CmsUUID structureId) Restores a deleted resource identified by its structure id from the historical archive.void
restoreResourceVersion
(CmsUUID structureId, int version) Restores a resource in the current project with a version from the historical archive.void
Removes an access control entry of a given principal from a given resource.void
setDateExpired
(String resourcename, long dateExpired, boolean recursive) Changes the "expire" date of a resource.void
setDateExpired
(CmsResource resource, long dateExpired, boolean recursive) Changes the "expire" date of a resource.void
setDateLastModified
(String resourcename, long dateLastModified, boolean recursive) Changes the "last modified" time stamp of a resource.void
setDateReleased
(String resourcename, long dateReleased, boolean recursive) Changes the "release" date of a resource.void
setDateReleased
(CmsResource resource, long dateReleased, boolean recursive) Changes the "release" date of a resource.void
setParentGroup
(String groupName, String parentGroupName) Sets a new parent-group for an already existing group.void
setPassword
(String username, String newPassword) Sets the password for a user.void
setPassword
(String username, String oldPassword, String newPassword) Sets the password for a specified user.void
setPassword
(String username, String oldPassword, CmsSecondFactorInfo secondFactor, String newPassword) Sets the password for a specified user.void
setRestricted
(CmsResource res, String groupName, boolean restricted) Sets/clears the 'restricted' status for the given resource and group.tempChangeSiteRoot
(String siteRoot) Helper method to temporarily change the site root in a try-with-resources statement.void
undeleteResource
(String resourcename, boolean recursive) Undeletes a resource.void
undoChanges
(String resourcename, CmsResource.CmsResourceUndoMode mode) Undoes all changes to a resource by restoring the version from the online project to the current offline project.void
unlockProject
(CmsUUID id) Unlocks all resources of a project.void
unlockResource
(String resourcename) Unlocks a resource.void
unlockResource
(CmsResource resource) Unlocks a resource.void
updateLastLoginDate
(CmsUser user) Updates the last login date on the given user to the current time.boolean
userInGroup
(String username, String groupname) Tests if a user is member of the given group.void
validatePassword
(String password) This method checks if a new password follows the rules for new passwords, which are defined by a Class implementing the
interface and configured in the opencms.properties file.I_CmsPasswordHandler
Writes a resource to the OpenCms VFS, including it's content.void
writeGroup
(CmsGroup group) Writes an already existing group.void
writeHistoryProject
(int publishTag, long publishDate) Creates a historical entry of the current project.void
writeProject
(CmsProject project) Writes an already existing project.void
writeProjectLastModified
(CmsResource resource, CmsProject project) Writes the 'projectlastmodified' field of a resource record.void
writePropertyObject
(String resourcename, CmsProperty property) Writes a property for a specified resource.void
writePropertyObjects
(String resourcename, List<CmsProperty> properties) Writes a list of properties for a specified resource.void
writePropertyObjects
(CmsResource res, List<CmsProperty> properties) Writes a list of properties for a specified resource.void
writeResource
(CmsResource resource) Writes a resource.void
writeStaticExportPublishedResource
(String resourceName, int linkType, String linkParameter, long timestamp) Writes a published resource entry.writeUrlNameMapping
(String name, CmsUUID structureId, String locale, boolean replaceOnPublish) Writes a new URL name mapping for a given resource.writeUrlNameMapping
(Iterator<String> nameSeq, CmsUUID structureId, String locale, boolean replaceOnPublish) Writes a new URL name mapping for a given resource.void
Updates the user information.
-
Field Details
-
m_context
The request context. -
m_securityManager
The security manager to access the cms.
-
-
Constructor Details
-
CmsObject
Connects an OpenCms user context to a running database.Please note: This constructor is internal to OpenCms and not for public use. If you want to create a new instance of a
in your application, useCmsObject
.OpenCms.initCmsObject(String)
- Parameters:
securityManager
- the security managercontext
- the request context that contains the user authentication
-
-
Method Details
-
addRelationToResource
public void addRelationToResource(CmsResource resource, CmsResource target, String type) throws CmsException Adds a new relation to the given resource.- Parameters:
resource
- the source resourcetarget
- the target resourcetype
- the type of the relation- Throws:
CmsException
- if something goes wrong
-
addRelationToResource
public void addRelationToResource(String resourceName, String targetPath, String type) throws CmsException Adds a new relation to the given resource.- Parameters:
resourceName
- the name of the source resourcetargetPath
- the path of the target resourcetype
- the type of the relation- Throws:
CmsException
- if something goes wrong
-
addSiteRoot
Convenience method to add the site root from the current user's request context to the given resource name.- Parameters:
resourcename
- the resource name- Returns:
- the resource name with the site root added
- See Also:
-
addUserToGroup
Adds a user to a group.- Parameters:
username
- the name of the user that is to be added to the groupgroupname
- the name of the group- Throws:
CmsException
- if something goes wrong
-
adjustLinks
This method works just likeadjustLinks(String, String)
, but you can specify multiple source files, and the target folder is interpreted as the folder into which the source files have been copied.- Parameters:
sourceFiles
- the list of source filestargetParentFolder
- the folder into which the source files have been copied- Throws:
CmsException
- if something goes wrong
-
adjustLinks
public void adjustLinks(Map<String, String> sourceTargetMap, String targetParentFolder) throws CmsExceptionThis method works just likeadjustLinks(String, String)
, but instead of specifying a single source and target folder, you can specify multiple sources and the corresponding targets in a map of strings.- Parameters:
sourceTargetMap
- a map with the source files as keys and the corresponding targets as valuestargetParentFolder
- the folder into which the source files have been copied- Throws:
CmsException
- if something goes wrong
-
adjustLinks
Adjusts all links in the target folder that point to the source folder so that they are kept "relative" in the target folder where possible. If a link is found from the target folder to the source folder, then the target folder is checked if a target of the same name is found also "relative" inside the target Folder, and if so, the link is changed to that "relative" target. This is mainly used to keep relative links inside a copied folder structure intact. Example: Image we have folder /folderA/ that contains files /folderA/x1 and /folderA/y1. x1 has a link to y1 and y1 to x1. Now someone copies /folderA/ to /folderB/. So we end up with /folderB/x2 and /folderB/y2. Because of the link mechanism in OpenCms, x2 will have a link to y1 and y2 to x1. By using this method, the links from x2 to y1 will be replaced by a link x2 to y2, and y2 to x1 with y2 to x2. Link replacement works for links in XML files as well as relation only type links.- Parameters:
sourceFolder
- the source foldertargetFolder
- the target folder- Throws:
CmsException
- if something goes wrong
-
chacc
public void chacc(String resourceName, String principalType, String principalName, int allowedPermissions, int deniedPermissions, int flags) throws CmsException Changes the access control for a given resource and a given principal(user/group).- Parameters:
resourceName
- name of the resourceprincipalType
- the type of the principal (currently group or user):principalName
- name of the principalallowedPermissions
- bit set of allowed permissionsdeniedPermissions
- bit set of denied permissionsflags
- additional flags of the access control entry- Throws:
CmsException
- if something goes wrong
-
chacc
public void chacc(String resourceName, String principalType, String principalName, String permissionString) throws CmsException Changes the access control for a given resource and a given principal(user/group).- Parameters:
resourceName
- name of the resourceprincipalType
- the type of the principal (group or user):principalName
- name of the principalpermissionString
- the permissions in the format ((+|-)(r|w|v|c|i|o))*- Throws:
CmsException
- if something goes wrong
-
changeLock
Changes the lock of a resource to the current user, that is "steals" the lock from another user.This is the "steal lock" operation.
- Parameters:
resource
- the resource to change the lock- Throws:
CmsException
- if something goes wrong
-
changeLock
Changes the lock of a resource to the current user, that is "steals" the lock from another user.This is the "steal lock" operation.
- Parameters:
resourcename
- the name of the resource to change the lock with complete path- Throws:
CmsException
- if something goes wrong
-
changeResourcesInFolderWithProperty
public List<CmsResource> changeResourcesInFolderWithProperty(String resourcename, String property, String oldValue, String newValue, boolean recursive) throws CmsException Returns a list with all sub resources of a given folder that have set the given property, matching the current property's value with the given old value and replacing it by a given new value.- Parameters:
resourcename
- the name of the resource to change the property valueproperty
- the name of the property to change the valueoldValue
- the old value of the property, can be a regular expressionnewValue
- the new value of the propertyrecursive
- if true, change recursively all property values on sub-resources (only for folders)- Returns:
- a list with the
's where the property value has been changedCmsResource
- Throws:
CmsException
- if operation was not successful
-
checkLoginUser
Checks if a login for the given user name and password would work without taking two-factor authentication into account. If this succeeds, it does not actually log the CmsObject in. But if it fails, it throws an exception and increments the failed login counter for the given user.- Parameters:
userName
- the user name to checkpassword
- the password to check- Throws:
CmsException
- if the login check fails
-
chflags
Changes the resource flags of a resource.The resource flags are used to indicate various "special" conditions for a resource. Most notably, the "internal only" setting which signals that a resource can not be directly requested with it's URL.
- Parameters:
resourcename
- the name of the resource to change the flags for (full current site relative path)flags
- the new flags for this resource- Throws:
CmsException
- if something goes wrong
-
chtype
Changes the resource type of a resource.OpenCms handles resources according to the resource type, not the file suffix. This is e.g. why a JSP in OpenCms can have the suffix ".html" instead of ".jsp" only. Changing the resource type makes sense e.g. if you want to make a plain text file a JSP resource, or a binary file an image, etc.
- Parameters:
resource
- the resource whose type should be changedtype
- the new resource type for this resource- Throws:
CmsException
- if something goes wrong
-
chtype
Changes the resource type of a resource.OpenCms handles resources according to the resource type, not the file suffix. This is e.g. why a JSP in OpenCms can have the suffix ".html" instead of ".jsp" only. Changing the resource type makes sense e.g. if you want to make a plain text file a JSP resource, or a binary file an image, etc.
- Parameters:
resourcename
- the name of the resource to change the type for (full current site relative path)type
- the new resource type for this resource- Throws:
CmsException
- if something goes wrong
-
chtype
Deprecated.Usechtype(String, I_CmsResourceType)
instead. Resource types should always be referenced either by its type class (preferred) or by type name. Use of int based resource type references will be discontinued in a future OpenCms release.Changes the resource type of a resource.OpenCms handles resources according to the resource type, not the file suffix. This is e.g. why a JSP in OpenCms can have the suffix ".html" instead of ".jsp" only. Changing the resource type makes sense e.g. if you want to make a plain text file a JSP resource, or a binary file an image, etc.
- Parameters:
resourcename
- the name of the resource to change the type for (full current site relative path)type
- the new resource type for this resource- Throws:
CmsException
- if something goes wrong
-
copyResource
public void copyResource(String source, String destination) throws CmsException, CmsIllegalArgumentException Copies a resource.The copied resource will always be locked to the current user after the copy operation.
Siblings will be treated according to the
mode.CmsResource.COPY_PRESERVE_SIBLING
- Parameters:
source
- the name of the resource to copy (full current site relative path)destination
- the name of the copy destination (full current site relative path)- Throws:
CmsException
- if something goes wrongCmsIllegalArgumentException
- if thedestination
argument is null or of length 0- See Also:
-
copyResource
public void copyResource(String source, String destination, CmsResource.CmsResourceCopyMode siblingMode) throws CmsException, CmsIllegalArgumentException Copies a resource.The copied resource will always be locked to the current user after the copy operation.
The
siblingMode
parameter controls how to handle siblings during the copy operation.
Possible values for this parameter are:
- Parameters:
source
- the name of the resource to copy (full current site relative path)destination
- the name of the copy destination (full current site relative path)siblingMode
- indicates how to handle siblings during copy- Throws:
CmsException
- if something goes wrongCmsIllegalArgumentException
- if thedestination
argument is null or of length 0
-
copyResourceToProject
Copies a resource to the current project of the user.This is used to extend the current users project with the specified resource, in case that the resource is not yet part of the project. The resource is not really copied like in a regular copy operation, it is in fact only "enabled" in the current users project.
- Parameters:
resource
- the resource to copy to the current project- Throws:
CmsException
- if something goes wrong
-
copyResourceToProject
Copies a resource to the current project of the user.This is used to extend the current users project with the specified resource, in case that the resource is not yet part of the project. The resource is not really copied like in a regular copy operation, it is in fact only "enabled" in the current users project.
- Parameters:
resourcename
- the name of the resource to copy to the current project (full current site relative path)- Throws:
CmsException
- if something goes wrong
-
countLockedResources
Counts the locked resources in a project.- Parameters:
id
- the id of the project- Returns:
- the number of locked resources in this project
- Throws:
CmsException
- if operation was not successful
-
cpacc
Copies access control entries of a given resource to another resource.Already existing access control entries of the destination resource are removed.
- Parameters:
sourceName
- the name of the resource of which the access control entries are copieddestName
- the name of the resource to which the access control entries are applied- Throws:
CmsException
- if something goes wrong
-
createGroup
public CmsGroup createGroup(String groupFqn, String description, int flags, String parent) throws CmsException Creates a new user group.- Parameters:
groupFqn
- the name of the new groupdescription
- the description of the new groupflags
- the flags for the new groupparent
- the parent group (ornull
)- Returns:
- a
object representing the newly created groupCmsGroup
- Throws:
CmsException
- if operation was not successful
-
createProject
public CmsProject createProject(String name, String description, String groupname, String managergroupname) throws CmsException Creates a new project.- Parameters:
name
- the name of the project to createdescription
- the description for the new projectgroupname
- the name of the project user groupmanagergroupname
- the name of the project manager group- Returns:
- the created project
- Throws:
CmsException
- if something goes wrong
-
createProject
public CmsProject createProject(String name, String description, String groupname, String managergroupname, CmsProject.CmsProjectType projecttype) throws CmsException Creates a new project.- Parameters:
name
- the name of the project to createdescription
- the description for the new projectgroupname
- the name of the project user groupmanagergroupname
- the name of the project manager groupprojecttype
- the type of the project (normal or temporary)- Returns:
- the created project
- Throws:
CmsException
- if operation was not successful
-
createPropertyDefinition
Creates a property definition.Property definitions are valid for all resource types.
- Parameters:
name
- the name of the property definition to create- Returns:
- the created property definition
- Throws:
CmsException
- if something goes wrong
-
createResource
public CmsResource createResource(String sitePath, CmsResource resource, byte[] content, List<CmsProperty> properties) throws CmsException Creates a resource with the given properties and content. Will throw an exception, if a resource with the given name already exists.- Parameters:
sitePath
- the site path for the resourceresource
- the resource object to be importedcontent
- the content of the resourceproperties
- the properties of the resource- Returns:
- the imported resource
- Throws:
CmsException
- if something goes wrong
-
createResource
public CmsResource createResource(String resourcename, I_CmsResourceType type) throws CmsException, CmsIllegalArgumentException Creates a new resource of the given resource type with empty content and no properties.- Parameters:
resourcename
- the name of the resource to create (full current site relative path)type
- the type of the resource to create- Returns:
- the created resource
- Throws:
CmsException
- if something goes wrongCmsIllegalArgumentException
- if the givenresourcename
is null or of length 0- See Also:
-
createResource
public CmsResource createResource(String resourcename, I_CmsResourceType type, byte[] content, List<CmsProperty> properties) throws CmsException, CmsIllegalArgumentException Creates a new resource of the given resource type with the provided content and properties.- Parameters:
resourcename
- the name of the resource to create (full current site relative path)type
- the type of the resource to createcontent
- the contents for the new resourceproperties
- the properties for the new resource- Returns:
- the created resource
- Throws:
CmsException
- if something goes wrongCmsIllegalArgumentException
- if theresourcename
argument is null or of length 0
-
createResource
@Deprecated public CmsResource createResource(String resourcename, int type) throws CmsException, CmsIllegalArgumentException Deprecated.UsecreateResource(String, I_CmsResourceType)
instead. Resource types should always be referenced either by its type class (preferred) or by type name. Use of int based resource type references will be discontinued in a future OpenCms release.Creates a new resource of the given resource type with empty content and no properties.- Parameters:
resourcename
- the name of the resource to create (full current site relative path)type
- the type of the resource to create- Returns:
- the created resource
- Throws:
CmsException
- if something goes wrongCmsIllegalArgumentException
- if the givenresourcename
is null or of length 0- See Also:
-
createResource
@Deprecated public CmsResource createResource(String resourcename, int type, byte[] content, List<CmsProperty> properties) throws CmsException, CmsIllegalArgumentException Deprecated.UsecreateResource(String, I_CmsResourceType, byte[], List)
instead. Resource types should always be referenced either by its type class (preferred) or by type name. Use of int based resource type references will be discontinued in a future OpenCms release.Creates a new resource of the given resource type with the provided content and properties.- Parameters:
resourcename
- the name of the resource to create (full current site relative path)type
- the type of the resource to createcontent
- the contents for the new resourceproperties
- the properties for the new resource- Returns:
- the created resource
- Throws:
CmsException
- if something goes wrongCmsIllegalArgumentException
- if theresourcename
argument is null or of length 0
-
createSibling
public CmsResource createSibling(String source, String destination, List<CmsProperty> properties) throws CmsException Creates a new sibling of the source resource.- Parameters:
source
- the name of the resource to create a sibling for with complete pathdestination
- the name of the sibling to create with complete pathproperties
- the individual properties for the new sibling- Returns:
- the new created sibling
- Throws:
CmsException
- if something goes wrong
-
createTempfileProject
Creates the project for the temporary workplace files.- Returns:
- the created project for the temporary workplace files
- Throws:
CmsException
- if something goes wrong
-
createUser
public CmsUser createUser(String userFqn, String password, String description, Map<String, Object> additionalInfos) throws CmsExceptionCreates a new user.- Parameters:
userFqn
- the name for the new userpassword
- the password for the new userdescription
- the description for the new useradditionalInfos
- the additional infos for the user- Returns:
- the created user
- Throws:
CmsException
- if something goes wrong
-
deleteAllStaticExportPublishedResources
Deletes all published resource entries.- Parameters:
linkType
- the type of resource deleted (0= non-parameter, 1=parameter)- Throws:
CmsException
- if something goes wrong
-
deleteGroup
Deletes a group, where all permissions, users and children of the group are transfered to a replacement group.- Parameters:
groupId
- the id of the group to be deletedreplacementId
- the id of the group to be transfered, can benull
- Throws:
CmsException
- if operation was not successful
-
deleteGroup
Deletes a user group.Only groups that contain no subgroups can be deleted.
- Parameters:
group
- the name of the group- Throws:
CmsException
- if operation was not successful
-
deleteHistoricalVersions
public void deleteHistoricalVersions(int versionsToKeep, int versionsDeleted, long timeDeleted, I_CmsReport report) throws CmsException Deletes the versions from the history tables, keeping the given number of versions per resource.- Parameters:
versionsToKeep
- number of versions to keep, is ignored if negativeversionsDeleted
- number of versions to keep for deleted resources, is ignored if negativetimeDeleted
- deleted resources older than this will also be deleted, is ignored if negativereport
- the report for output logging- Throws:
CmsException
- if operation was not successful
-
deleteLogEntries
Deletes the log entries matching the given filter.- Parameters:
filter
- the filter to use for deleting the log entries- Throws:
CmsException
- if something goes wrong- See Also:
-
deleteProject
Deletes a project.All resources inside the project have to be be reset to their online state.
- Parameters:
id
- the id of the project to delete- Throws:
CmsException
- if operation was not successful
-
deletePropertyDefinition
Deletes a property definition.- Parameters:
name
- the name of the property definition to delete- Throws:
CmsException
- if something goes wrong
-
deleteRelationsFromResource
public void deleteRelationsFromResource(CmsResource resource, CmsRelationFilter filter) throws CmsException Deletes the relations to a given resource.- Parameters:
resource
- the resource to delete the relations fromfilter
- the filter to use for deleting the relations- Throws:
CmsException
- if something goes wrong
-
deleteRelationsFromResource
public void deleteRelationsFromResource(String resourceName, CmsRelationFilter filter) throws CmsException Deletes the relations to a given resource.- Parameters:
resourceName
- the resource to delete the relations fromfilter
- the filter to use for deleting the relations- Throws:
CmsException
- if something goes wrong
-
deleteResource
public void deleteResource(CmsResource res, CmsResource.CmsResourceDeleteMode deletePreserveSiblings) throws CmsException Deletes a resource.The
siblingMode
parameter controls how to handle siblings during the delete operation.
Possible values for this parameter are:
- Parameters:
res
- the resource to deletedeletePreserveSiblings
- indicates how to handle siblings of the deleted resource- Throws:
CmsException
- if something goes wrong
-
deleteResource
public void deleteResource(String resourcename, CmsResource.CmsResourceDeleteMode siblingMode) throws CmsException Deletes a resource given its name.The
siblingMode
parameter controls how to handle siblings during the delete operation.
Possible values for this parameter are:
- Parameters:
resourcename
- the name of the resource to delete (full current site relative path)siblingMode
- indicates how to handle siblings of the deleted resource- Throws:
CmsException
- if something goes wrong
-
deleteStaticExportPublishedResource
public void deleteStaticExportPublishedResource(String resourceName, int linkType, String linkParameter) throws CmsException Deletes a published resource entry.- Parameters:
resourceName
- The name of the resource to be deleted in the static exportlinkType
- the type of resource deleted (0= non-parameter, 1=parameter)linkParameter
- the parameters of the resource- Throws:
CmsException
- if something goes wrong
-
deleteUser
Deletes a user.- Parameters:
userId
- the id of the user to be deleted- Throws:
CmsException
- if operation was not successful
-
deleteUser
Deletes a user, where all permissions and resources attributes of the user were transfered to a replacement user.- Parameters:
userId
- the id of the user to be deletedreplacementId
- the id of the user to be transfered, can benull
- Throws:
CmsException
- if operation was not successful
-
deleteUser
Deletes a user.- Parameters:
username
- the name of the user to be deleted- Throws:
CmsException
- if operation was not successful
-
existsResource
Checks the availability of a resource in the VFS, using the
filter.CmsResourceFilter.DEFAULT
A resource may be of type
orCmsFile
.CmsFolder
This method also takes into account the user permissions, so if the given resource exists, but the current user has not the required permissions, then this method will return
false
.- Parameters:
structureId
- the structure id of the resource to check- Returns:
true
if the resource is available- See Also:
-
existsResource
Checks the availability of a resource in the VFS, using the
filter.CmsResourceFilter.DEFAULT
A resource may be of type
orCmsFile
.CmsFolder
The specified filter controls what kind of resources should be "found" during the read operation. This will depend on the application. For example, using
will only return currently "valid" resources, while usingCmsResourceFilter.DEFAULT
will ignore the date release / date expired information of the resource.CmsResourceFilter.IGNORE_EXPIRATION
This method also takes into account the user permissions, so if the given resource exists, but the current user has not the required permissions, then this method will return
false
.- Parameters:
structureId
- the structure id of the resource to checkfilter
- the resource filter to use while checking- Returns:
true
if the resource is available- See Also:
-
existsResource
Checks the availability of a resource in the VFS, using the
filter.CmsResourceFilter.DEFAULT
A resource may be of type
orCmsFile
.CmsFolder
This method also takes into account the user permissions, so if the given resource exists, but the current user has not the required permissions, then this method will return
false
.- Parameters:
resourcename
- the name of the resource to check (full current site relative path)- Returns:
true
if the resource is available- See Also:
-
existsResource
Checks the availability of a resource in the VFS, using the provided filter.A resource may be of type
orCmsFile
.CmsFolder
The specified filter controls what kind of resources should be "found" during the read operation. This will depend on the application. For example, using
will only return currently "valid" resources, while usingCmsResourceFilter.DEFAULT
will ignore the date release / date expired information of the resource.CmsResourceFilter.IGNORE_EXPIRATION
This method also takes into account the user permissions, so if the given resource exists, but the current user has not the required permissions, then this method will return
false
.- Parameters:
resourcename
- the name of the resource to check (full current site relative path)filter
- the resource filter to use while checking- Returns:
true
if the resource is available- See Also:
-
getAccessControlEntries
Returns the list of access control entries of a resource given its name.- Parameters:
resourceName
- the name of the resource- Returns:
- a list of
objectsCmsAccessControlEntry
- Throws:
CmsException
- if something goes wrong
-
getAccessControlEntries
public List<CmsAccessControlEntry> getAccessControlEntries(String resourceName, boolean getInherited) throws CmsException Returns the list of access control entries of a resource given its name.- Parameters:
resourceName
- the name of the resourcegetInherited
-true
, if inherited access control entries should be returned, too- Returns:
- a list of
objects defining all permissions for the given resourceCmsAccessControlEntry
- Throws:
CmsException
- if something goes wrong
-
getAccessControlList
Returns the access control list (summarized access control entries) of a given resource.- Parameters:
resourceName
- the name of the resource- Returns:
- the access control list of the resource
- Throws:
CmsException
- if something goes wrong
-
getAccessControlList
public CmsAccessControlList getAccessControlList(String resourceName, boolean inheritedOnly) throws CmsException Returns the access control list (summarized access control entries) of a given resource.If
inheritedOnly
is set, only inherited access control entries are returned.- Parameters:
resourceName
- the name of the resourceinheritedOnly
- if set, the non-inherited entries are skipped- Returns:
- the access control list of the resource
- Throws:
CmsException
- if something goes wrong
-
getAllAccessControlEntries
Gets all access control entries for the current project.- Returns:
- the list of all access control entries
- Throws:
CmsException
- if something goes wrong
-
getAllHistoricalProjects
Returns a list with all projects from history.- Returns:
- list of
objects with all projects from historyCmsHistoryProject
- Throws:
CmsException
- if operation was not successful
-
getAllUrlNames
Gets all URL names for a given structure id.- Parameters:
id
- the structure id- Returns:
- the list of all URL names for that structure id
- Throws:
CmsException
- if something goes wrong
-
getBlockingLockedResources
Returns a list of child resources to the given resource that can not be locked by the current user.- Parameters:
resource
- the resource- Returns:
- a list of child resources to the given resource that can not be locked by the current user
- Throws:
CmsException
- if something goes wrong reading the resources
-
getBlockingLockedResources
Returns a list of child resources to the given resource that can not be locked by the current user.- Parameters:
resourceName
- the resource site path- Returns:
- a list of child resources to the given resource that can not be locked by the current user
- Throws:
CmsException
- if something goes wrong reading the resources
-
getChildren
Returns all child groups of a group.- Parameters:
groupname
- the name of the groupincludeSubChildren
- if set also returns all sub-child groups of the given group- Returns:
- a list of all child
objects orCmsGroup
null
- Throws:
CmsException
- if operation was not successful
-
getDetailName
public String getDetailName(CmsResource res, Locale locale, List<Locale> defaultLocales) throws CmsException Returns the detail name of a resource.The detail view URI of a content element consists of its detail page URI and the detail name returned by this method.
- Parameters:
res
- the resource for which the detail name should be retrievedlocale
- the locale for the detail namedefaultLocales
- the default locales for the detail name- Returns:
- the detail name
- Throws:
CmsException
- if something goes wrong
-
getFilesInFolder
Returns all file resources contained in a folder.The result is filtered according to the rules of the
filter.CmsResourceFilter.DEFAULT
- Parameters:
resourcename
- the full current site relative path of the resource to return the child resources for- Returns:
- a list of all child files as
objectsCmsResource
- Throws:
CmsException
- if something goes wrong- See Also:
-
getFilesInFolder
public List<CmsResource> getFilesInFolder(String resourcename, CmsResourceFilter filter) throws CmsException Returns all file resources contained in a folder.With the
provided as parameter you can control if you want to include deleted, invisible or time-invalid resources in the result.CmsResourceFilter
- Parameters:
resourcename
- the full path of the resource to return the child resources forfilter
- the resource filter to use- Returns:
- a list of all child file as
objectsCmsResource
- Throws:
CmsException
- if something goes wrong
-
getGroupsOfUser
public List<CmsGroup> getGroupsOfUser(String username, boolean directGroupsOnly) throws CmsException Returns all the groups the given user belongs to.- Parameters:
username
- the name of the userdirectGroupsOnly
- if set only the direct assigned groups will be returned, if not also indirect roles- Returns:
- a list of
objectsCmsGroup
- Throws:
CmsException
- if operation was not successful
-
getGroupsOfUser
public List<CmsGroup> getGroupsOfUser(String username, boolean directGroupsOnly, boolean includeOtherOus) throws CmsException Returns all the groups the given user belongs to.- Parameters:
username
- the name of the userdirectGroupsOnly
- if set only the direct assigned groups will be returned, if not also indirect rolesincludeOtherOus
- if to include groups of other organizational units- Returns:
- a list of
objectsCmsGroup
- Throws:
CmsException
- if operation was not successful
-
getGroupsOfUser
public List<CmsGroup> getGroupsOfUser(String username, boolean directGroupsOnly, boolean includeOtherOus, String remoteAddress) throws CmsException Returns the groups of a user filtered by the specified IP address.- Parameters:
username
- the name of the userdirectGroupsOnly
- if set only the direct assigned groups will be returned, if not also indirect rolesremoteAddress
- the IP address to filter the groups in the result listincludeOtherOus
- if to include groups of other organizational units- Returns:
- a list of
objects filtered by the specified IP addressCmsGroup
- Throws:
CmsException
- if operation was not successful
-
getLocaleGroupService
Creates a new locale group service.- Returns:
- a locale group service instance
-
getLock
Returns the edition lock state for a specified resource.If the resource is waiting to be publish you might get a lock of type
CmsLockType.PUBLISH
.- Parameters:
resource
- the resource to return the edition lock state for- Returns:
- the edition lock state for the specified resource
- Throws:
CmsException
- if something goes wrong
-
getLock
Returns the lock state for a specified resource name.If the resource is waiting to be publish you might get a lock of type
CmsLockType.PUBLISH
.- Parameters:
resourcename
- the name if the resource to get the lock state for (full current site relative path)- Returns:
- the lock state for the specified resource
- Throws:
CmsException
- if something goes wrong
-
getLockedResources
public List<CmsResource> getLockedResources(CmsResource resource, CmsLockFilter filter) throws CmsException Returns all locked resources within a folder or matches the lock of the given resource.- Parameters:
resource
- the resource to checkfilter
- the lock filter- Returns:
- a list of locked resources
- Throws:
CmsException
- if operation was not successful
-
getLockedResources
public List<String> getLockedResources(String resourceName, CmsLockFilter filter) throws CmsException Returns all locked resources within a folder or matches the lock of the given resource.- Parameters:
resourceName
- the name of the resource to checkfilter
- the lock filter- Returns:
- a list of locked resource paths (relative to current site)
- Throws:
CmsException
- if operation was not successful
-
getLockedResourcesWithCache
public List<CmsResource> getLockedResourcesWithCache(CmsResource resource, CmsLockFilter filter, Map<String, CmsResource> cache) throws CmsExceptionReturns all locked resources within a folder or matches the lock of the given resource, but uses a cache for resource lookup.- Parameters:
resource
- the resource to checkfilter
- the lock filtercache
- the cache to use for resource lookups- Returns:
- a list of locked resources
- Throws:
CmsException
- if operation was not successful
-
getLogEntries
Returns all log entries matching the given filter.- Parameters:
filter
- the filter to match the relation- Returns:
- a list containing all log entries matching the given filter
- Throws:
CmsException
- if something goes wrong- See Also:
-
getLostAndFoundName
Returns the name a resource would have if it were moved to the "lost and found" folder.In general, it is the same name as the given resource has, the only exception is if a resource in the "lost and found" folder with the same name already exists. In such case, a counter is added to the resource name.
- Parameters:
resourcename
- the name of the resource to get the "lost and found" name for (full current site relative path)- Returns:
- the tentative name of the resource inside the "lost and found" folder
- Throws:
CmsException
- if something goes wrong- See Also:
-
getParent
Returns the parent group of a group.- Parameters:
groupname
- the name of the group- Returns:
- group the parent group or
null
- Throws:
CmsException
- if operation was not successful
-
getPermissions
Returns the set of permissions of the current user for a given resource.- Parameters:
resourceName
- the name of the resource- Returns:
- the bit set of the permissions of the current user
- Throws:
CmsException
- if something goes wrong
-
getPermissions
Returns the set of permissions of a given user for a given resource.- Parameters:
resourceName
- the name of the resourceuserName
- the name of the user- Returns:
- the current permissions on this resource
- Throws:
CmsException
- if something goes wrong
-
getRelationsForResource
public List<CmsRelation> getRelationsForResource(CmsResource resource, CmsRelationFilter filter) throws CmsException Returns all relations for the given resource matching the given filter.You should have view/read permissions on the given resource.
You may become source and/or target paths to resource you do not have view/read permissions on.
- Parameters:
resource
- the resource to retrieve the relations forfilter
- the filter to match the relation- Returns:
- a List containing all
CmsRelation
objects for the given resource matching the given filter - Throws:
CmsException
- if something goes wrong- See Also:
-
getRelationsForResource
public List<CmsRelation> getRelationsForResource(String resourceName, CmsRelationFilter filter) throws CmsException Returns all relations for the given resource matching the given filter.You should have view/read permissions on the given resource.
You may become source and/or target paths to resource you do not have view/read permissions on.
- Parameters:
resourceName
- the name of the resource to retrieve the relations forfilter
- the filter to match the relation- Returns:
- a List containing all
CmsRelation
objects for the given resource matching the given filter - Throws:
CmsException
- if something goes wrong- See Also:
-
getRequestContext
Returns the current users request context.This request context is used to authenticate the user for all OpenCms operations. It also contains the request runtime settings, e.g. about the current site this request was made on.
- Returns:
- the current users request context
-
getResourcesForPrincipal
public Set<CmsResource> getResourcesForPrincipal(CmsUUID principalId, CmsPermissionSet permissions, boolean includeAttr) throws CmsException Returns all resources associated to a given principal via an ACE with the given permissions.If the
includeAttr
flag is set it returns also all resources associated to a given principal through some of following attributes.- User Created
- User Last Modified
- Parameters:
principalId
- the id of the principalpermissions
- a set of permissions to match, can benull
for all ACEsincludeAttr
- a flag to include resources associated by attributes- Returns:
- a set of
objectsCmsResource
- Throws:
CmsException
- if something goes wrong
-
getResourcesInFolder
public List<CmsResource> getResourcesInFolder(String resourcename, CmsResourceFilter filter) throws CmsException Returns all child resources of a resource, that is the resources contained in a folder.With the
provided as parameter you can control if you want to include deleted, invisible or time-invalid resources in the result.CmsResourceFilter
This method is mainly used by the workplace explorer.
- Parameters:
resourcename
- the full current site relative path of the resource to return the child resources forfilter
- the resource filter to use- Returns:
- a list of all child
sCmsResource
- Throws:
CmsException
- if something goes wrong
-
getSitePath
Adjusts the absolute resource root path for the current site.The full root path of a resource is always available using
. From this name this method cuts of the current site root usingCmsResource.getRootPath()
.CmsRequestContext.removeSiteRoot(String)
If the resource root path does not start with the current site root, it is left untouched.
- Parameters:
resource
- the resource to get the adjusted site root path for- Returns:
- the absolute resource path adjusted for the current site
- See Also:
-
getSubFolders
Returns all folder resources contained in a folder.The result is filtered according to the rules of the
filter.CmsResourceFilter.DEFAULT
- Parameters:
resourcename
- the full current site relative path of the resource to return the child resources for.- Returns:
- a list of all child file as
objectsCmsResource
- Throws:
CmsException
- if something goes wrong- See Also:
-
getSubFolders
public List<CmsResource> getSubFolders(String resourcename, CmsResourceFilter filter) throws CmsException Returns all folder resources contained in a folder.With the
provided as parameter you can control if you want to include deleted, invisible or time-invalid resources in the result.CmsResourceFilter
- Parameters:
resourcename
- the full current site relative path of the resource to return the child resources for.filter
- the resource filter to use- Returns:
- a list of all child folder
sCmsResource
- Throws:
CmsException
- if something goes wrong
-
getUrlNamesForAllLocales
Returns the newest URL names for the given structure id for each locale.- Parameters:
id
- the structure id- Returns:
- the list of URL names for each locale
- Throws:
CmsException
- if something goes wrong
-
getUsersOfGroup
Returns all direct users of a given group.Users that are "indirectly" in the group are not returned in the result.
- Parameters:
groupname
- the name of the group to get all users for- Returns:
- all
objects in the groupCmsUser
- Throws:
CmsException
- if operation was not successful
-
getUsersOfGroup
Returns all direct users of a given group.Users that are "indirectly" in the group are not returned in the result.
- Parameters:
groupname
- the name of the group to get all users forincludeOtherOus
- if the result should include users of other ous- Returns:
- all
objects in the groupCmsUser
- Throws:
CmsException
- if operation was not successful
-
hasPermissions
public boolean hasPermissions(CmsResource resource, CmsPermissionSet requiredPermissions) throws CmsException Checks if the current user has required permissions to access a given resource.- Parameters:
resource
- the resource to check the permissions forrequiredPermissions
- the set of permissions to check for- Returns:
true
if the required permissions are satisfied- Throws:
CmsException
- if something goes wrong
-
hasPermissions
public boolean hasPermissions(CmsResource resource, CmsPermissionSet requiredPermissions, boolean checkLock, CmsResourceFilter filter) throws CmsException Checks if the current user has required permissions to access a given resource.- Parameters:
resource
- the resource to check the permissions forrequiredPermissions
- the set of permissions to check forcheckLock
- iftrue
the lock status of the resource is checked for write operations and the resource needs be locked by the current user so that the test is passed, iffalse
the lock is not checked at allfilter
- the resource filter to use- Returns:
true
if the required permissions are satisfied- Throws:
CmsException
- if something goes wrong
-
importAccessControlEntries
public void importAccessControlEntries(CmsResource resource, List<CmsAccessControlEntry> acEntries) throws CmsException Writes a list of access control entries as new access control entries of a given resource.Already existing access control entries of this resource are removed before.
- Parameters:
resource
- the resource to attach the control entries toacEntries
- a list of
objectsCmsAccessControlEntry
- Throws:
CmsException
- if something goes wrong
-
importRelation
public void importRelation(String resourceName, String targetPath, String relationType) throws CmsException Imports a new relation to the given resource.- Parameters:
resourceName
- the name of the source resourcetargetPath
- the path of the target resourcerelationType
- the type of the relation- Throws:
CmsException
- if something goes wrong
-
importResource
public CmsResource importResource(String resourcename, CmsResource resource, byte[] content, List<CmsProperty> properties) throws CmsException Imports a resource to the OpenCms VFS.If a resource already exists in the VFS (i.e. has the same name and same id) it is replaced by the imported resource.
If a resource with the same name but a different id exists, the imported resource is (usually) moved to the "lost and found" folder.
- Parameters:
resourcename
- the name for the resource after import (full current site relative path)resource
- the resource object to be importedcontent
- the content of the resourceproperties
- the properties of the resource- Returns:
- the imported resource
- Throws:
CmsException
- if something goes wrong- See Also:
-
importResource
public CmsResource importResource(String resourcename, I_CmsReport report, CmsResource resource, byte[] content, List<CmsProperty> properties) throws CmsException Imports a resource to the OpenCms VFS.If a resource already exists in the VFS (i.e. has the same name and same id) it is replaced by the imported resource.
If a resource with the same name but a different id exists, the imported resource is (usually) moved to the "lost and found" folder.
- Parameters:
resourcename
- the name for the resource after import (full current site relative path)report
- optional report to write non-critical errors to (may be null)resource
- the resource object to be importedcontent
- the content of the resourceproperties
- the properties of the resource- Returns:
- the imported resource
- Throws:
CmsException
- if something goes wrong- See Also:
-
importUser
public CmsUser importUser(String id, String name, String password, String firstname, String lastname, String email, int flags, long dateCreated, Map<String, Object> additionalInfos) throws CmsExceptionCreates a new user by import.- Parameters:
id
- the id of the username
- the new name for the userpassword
- the new password for the userfirstname
- the first name of the userlastname
- the last name of the useremail
- the email of the userflags
- the flags for a user (for example
)I_CmsPrincipal.FLAG_ENABLED
dateCreated
- the creation dateadditionalInfos
- the additional user infos- Returns:
- the imported user
- Throws:
CmsException
- if something goes wrong
-
incrementCounter
Increments a counter and returns its old value.- Parameters:
name
- the name of the counter- Returns:
- the value of the counter before incrementing
- Throws:
CmsException
- if something goes wrong
-
isInsideCurrentProject
Checks if the specified resource is inside the current project.The project "view" is determined by a set of path prefixes. If the resource starts with any one of this prefixes, it is considered to be "inside" the project.
- Parameters:
resourcename
- the specified resource name (full current site relative path)- Returns:
true
, if the specified resource is inside the current project
-
isManagerOfProject
Checks if the current user has management access to the current project.- Returns:
true
, if the user has management access to the current project
-
lockResource
Locks a resource.This will be an exclusive, persistent lock that is removed only if the user unlocks it.
- Parameters:
resource
- the resource to lock- Throws:
CmsException
- if something goes wrong
-
lockResource
Locks a resource.This will be an exclusive, persistent lock that is removed only if the user unlocks it.
- Parameters:
resourcename
- the name of the resource to lock (full current site relative path)- Throws:
CmsException
- if something goes wrong
-
lockResourceShallow
Locks the given resource with a shallow lock that is not inherited on subresources.Shallow locks are non-persistent, like temporary locks.
- Parameters:
resource
- the resource to lock- Throws:
CmsException
- if something goes wrong
-
lockResourceTemporary
Locks a resource temporary.This will be an exclusive, temporary lock valid only for the current users session. Usually this should not be used directly, this method is intended for the OpenCms workplace only.
- Parameters:
resource
- the resource to lock- Throws:
CmsException
- if something goes wrong- See Also:
-
lockResourceTemporary
Locks a resource temporary.This will be an exclusive, temporary lock valid only for the current users session. Usually this should not be used directly, this method is intended for the OpenCms workplace only.
- Parameters:
resourcename
- the name of the resource to lock (full current site relative path)- Throws:
CmsException
- if something goes wrong- See Also:
-
loginUser
Logs a user into the Cms, if the password is correct.- Parameters:
username
- the name of the userpassword
- the password of the user- Returns:
- the name of the logged in user
- Throws:
CmsException
- if the login was not successful
-
loginUser
public String loginUser(String username, String password, CmsSecondFactorInfo code) throws CmsException Logs in the user.- Parameters:
username
- the user namepassword
- the passwordcode
- the second factor information for 2FA- Returns:
- the logged in user
- Throws:
CmsException
- if something goes wrong
-
loginUser
public String loginUser(String username, String password, CmsSecondFactorInfo code, String remoteAddress) throws CmsException Logs a user with a given ip address into the Cms, if the password is correct.- Parameters:
username
- the name of the userpassword
- the password of the usercode
- the second factor information for 2FAremoteAddress
- the ip address- Returns:
- the name of the logged in user
- Throws:
CmsException
- if the login was not successful
-
loginUser
Logs a user with a given ip address into the Cms, if the password is correct.- Parameters:
username
- the name of the userpassword
- the password of the userremoteAddress
- the ip address- Returns:
- the name of the logged in user
- Throws:
CmsException
- if the login was not successful
-
lookupPrincipal
Lookups and reads the user or group with the given UUID.- Parameters:
principalId
- the uuid of a user or group- Returns:
- the user or group with the given UUID
-
lookupPrincipal
Lookups and reads the user or group with the given name.- Parameters:
principalName
- the name of the user or group- Returns:
- the user or group with the given name
-
moveResource
Moves a resource to the given destination.A move operation in OpenCms is always a copy (as sibling) followed by a delete, this is a result of the online/offline structure of the OpenCms VFS. This way you can see the deleted files/folders in the offline project, and you will be unable to undelete them.
- Parameters:
source
- the name of the resource to move (full current site relative path)destination
- the destination resource name (full current site relative path)- Throws:
CmsException
- if something goes wrong- See Also:
-
moveToLostAndFound
Moves a resource to the "lost and found" folder.The "lost and found" folder is a special system folder. This operation is used e.g. during import of resources when a resource with the same name but a different resource ID already exists in the VFS. In this case, the imported resource is moved to the "lost and found" folder.
- Parameters:
resourcename
- the name of the resource to move to "lost and found" (full current site relative path)- Returns:
- the name of the resource inside the "lost and found" folder
- Throws:
CmsException
- if something goes wrong- See Also:
-
readAllAvailableVersions
public List<I_CmsHistoryResource> readAllAvailableVersions(CmsResource resource) throws CmsException Reads all available versions for a given resource.- Parameters:
resource
- the resource for which to read the versions- Returns:
- the list of historical versions of the resource
- Throws:
CmsException
- if something goes wrong
-
readAllAvailableVersions
Reads all historical versions of a resource.
The reading excludes the file content, if the resource is a file.- Parameters:
resourceName
- the name of the resource to be read- Returns:
- a list of historical resources, as
objectsI_CmsHistoryResource
- Throws:
CmsException
- if operation was not successful
-
readAllPropertyDefinitions
Reads all property definitions.- Returns:
- a list with the
objects (may be empty)CmsPropertyDefinition
- Throws:
CmsException
- if something goes wrong
-
readAncestor
Returns the first ancestor folder matching the filter criteria.If no folder matching the filter criteria is found, null is returned.
- Parameters:
resourcename
- the name of the resource to start (full current site relative path)filter
- the resource filter to match while reading the ancestors- Returns:
- the first ancestor folder matching the filter criteria or null if no folder was found
- Throws:
CmsException
- if something goes wrong
-
readAncestor
Returns the first ancestor folder matching the resource type.If no folder with the requested resource type is found, null is returned.
- Parameters:
resourcename
- the name of the resource to start (full current site relative path)type
- the resource type of the folder to match- Returns:
- the first ancestor folder matching the filter criteria or null if no folder was found
- Throws:
CmsException
- if something goes wrong
-
readBestUrlName
public String readBestUrlName(CmsUUID id, Locale locale, List<Locale> defaultLocales) throws CmsException Reads the newest URL name which is mapped to the given structure id.If the structure id is not mapped to any name, null will be returned.
- Parameters:
id
- the structure id for which the newest mapped name should be returnedlocale
- the locale for which the URL name should be selected if possibledefaultLocales
- the default locales which should be used if the locale is not available- Returns:
- an URL name or null
- Throws:
CmsException
- if something goes wrong
-
readDefaultFile
public CmsResource readDefaultFile(CmsResource folderResource, CmsResourceFilter resourceFilter) throws CmsSecurityException Returns the default resource for the given folder.- the
CmsPropertyDefinition.PROPERTY_DEFAULT_FILE
is checked, and - if still no file could be found, the configured default files in the
opencms-vfs.xml
configuration are iterated until a match is found, and - if still no file could be found,
null
is returned
- Parameters:
folderResource
- the folderresourceFilter
- the resource filter- Returns:
- the default file for the given folder
- Throws:
CmsSecurityException
- if the user has no permissions to read the resulting file
- the
-
readDefaultFile
public CmsResource readDefaultFile(String resourceNameOrID) throws CmsException, CmsSecurityException Returns the default resource for the given folder.If the given resource name or id identifies a file, then this file is returned.
Otherwise, in case of a folder:
- the
CmsPropertyDefinition.PROPERTY_DEFAULT_FILE
is checked, and - if still no file could be found, the configured default files in the
opencms-vfs.xml
configuration are iterated until a match is found, and - if still no file could be found,
null
is returned
- Parameters:
resourceNameOrID
- the name or id of the folder to read the default file for- Returns:
- the default file for the given folder
- Throws:
CmsException
- if something goes wrongCmsSecurityException
- if the user has no permissions to read the resulting file
- the
-
readDefaultFile
public CmsResource readDefaultFile(String resourceNameOrID, CmsResourceFilter filter) throws CmsException, CmsSecurityException Returns the default resource for the given folder.If the given resource name or id identifies a file, then this file is returned.
Otherwise, in case of a folder:
- the
CmsPropertyDefinition.PROPERTY_DEFAULT_FILE
is checked, and - if still no file could be found, the configured default files in the
opencms-vfs.xml
configuration are iterated until a match is found, and - if still no file could be found,
null
is returned
- Parameters:
resourceNameOrID
- the name or id of the folder to read the default file for#filter
- the resource filter to use for reading the resources- Returns:
- the default file for the given folder
- Throws:
CmsException
- if something goes wrongCmsSecurityException
- if the user has no permissions to read the resulting file
- the
-
readDeletedResources
public List<I_CmsHistoryResource> readDeletedResources(String resourcename, boolean readTree) throws CmsException Reads all deleted (historical) resources below the given path, including the full tree below the path, if required.The result list may include resources with the same name of resources (with different id's).
Use in conjunction with the
restoreDeletedResource(CmsUUID)
method.- Parameters:
resourcename
- the parent path to read the resources fromreadTree
-true
to read all sub resources- Returns:
- a list of
objectsI_CmsHistoryResource
- Throws:
CmsException
- if something goes wrong- See Also:
-
readFile
Reads a file resource (including it's binary content) from the VFS, for the given resource (this may also be an historical version of the resource).In case the input
CmsResource
object already is aCmsFile
with contents available, it is casted to a file and returned unchanged. Otherwise the file is read from the VFS.In case you do not need the file content, use
orreadResource(String)
instead.readResource(String, CmsResourceFilter)
No resource filter is applied when reading the resource, since we already have a full resource instance and assume we just want the content for that instance. In case you need to apply a filter, use
readFile(String, CmsResourceFilter)
instead.- Parameters:
resource
- the resource to read- Returns:
- the file resource that was read
- Throws:
CmsException
- if the file resource could not be read for any reason- See Also:
-
readFile
Reads a file resource (including it's binary content) from the VFS, using the
filter.CmsResourceFilter.DEFAULT
In case you do not need the file content, use
instead.readResource(String)
- Parameters:
resourcename
- the name of the resource to read (full current site relative path)- Returns:
- the file resource that was read
- Throws:
CmsException
- if the file resource could not be read for any reason- See Also:
-
readFile
Reads a file resource (including it's binary content) from the VFS, using the specified resource filter.In case you do not need the file content, use
instead.readResource(String, CmsResourceFilter)
The specified filter controls what kind of resources should be "found" during the read operation. This will depend on the application. For example, using
will only return currently "valid" resources, while usingCmsResourceFilter.DEFAULT
will ignore the date release / date expired information of the resource.CmsResourceFilter.IGNORE_EXPIRATION
- Parameters:
resourcename
- the name of the resource to read (full current site relative path)filter
- the resource filter to use while reading- Returns:
- the file resource that was read
- Throws:
CmsException
- if the file resource could not be read for any reason- See Also:
-
readFolder
Reads a folder resource from the VFS, using the
filter.CmsResourceFilter.DEFAULT
- Parameters:
resourcename
- the name of the folder resource to read (full current site relative path)- Returns:
- the folder resource that was read
- Throws:
CmsException
- if the resource could not be read for any reason- See Also:
-
readFolder
Reads a folder resource from the VFS, using the specified resource filter.The specified filter controls what kind of resources should be "found" during the read operation. This will depend on the application. For example, using
will only return currently "valid" resources, while usingCmsResourceFilter.DEFAULT
will ignore the date release / date expired information of the resource.CmsResourceFilter.IGNORE_EXPIRATION
- Parameters:
resourcename
- the name of the folder resource to read (full current site relative path)filter
- the resource filter to use while reading- Returns:
- the folder resource that was read
- Throws:
CmsException
- if the resource could not be read for any reason- See Also:
-
readGroup
Reads the group of a project.- Parameters:
project
- the project to read the group from- Returns:
- the group of the given project
-
readGroup
Reads a group based on its id.- Parameters:
groupId
- the id of the group to be read- Returns:
- the group that has the provided id
- Throws:
CmsException
- if something goes wrong- See Also:
-
readGroup
Reads a group based on its name.- Parameters:
groupName
- the name of the group to be read- Returns:
- the group that has the provided name
- Throws:
CmsException
- if something goes wrong
-
readHistoryPrincipal
Reads a principal (an user or group) from the historical archive based on its ID.- Parameters:
principalId
- the id of the principal to read- Returns:
- the historical principal entry with the given id
- Throws:
CmsException
- if something goes wrong, ie.CmsDbEntryNotFoundException
- See Also:
-
readHistoryProject
Returns the latest historical project entry with the given id.- Parameters:
projectId
- the project id- Returns:
- the requested historical project entry
- Throws:
CmsException
- if operation was not successful
-
readHistoryProject
Returns a historical project entry.- Parameters:
publishTag
- publish tag of the project- Returns:
- the requested historical project entry
- Throws:
CmsException
- if operation was not successful
-
readHistoryPropertyObjects
public List<CmsProperty> readHistoryPropertyObjects(I_CmsHistoryResource resource) throws CmsException Reads the list of all
objects that belong to the given historical resource version.CmsProperty
- Parameters:
resource
- the historical resource version to read the properties for- Returns:
- the list of
objectsCmsProperty
- Throws:
CmsException
- if something goes wrong
-
readIdForUrlName
This method retrieves the structure id which is mapped to a given URL name.If there is no structure id mapped to the given name, null will be returned.
However if the parameter is a string which represents a valid uuid, it will be directly returned as a
CmsUUID
instance.- Parameters:
name
- the url name- Returns:
- the id which is mapped to the URL name
- Throws:
CmsException
- if something goes wrong
-
readManagerGroup
Returns the project manager group of a project.- Parameters:
project
- the project- Returns:
- the manager group of the project
-
readOwner
Reads the owner of a project.- Parameters:
project
- the project to read the owner from- Returns:
- the owner of the project
- Throws:
CmsException
- if something goes wrong
-
readParentFolder
Returns the parent folder to the given structure id.- Parameters:
structureId
- the child structure id- Returns:
- the parent folder
CmsResource
- Throws:
CmsException
- if something goes wrong
-
readPath
public List<CmsResource> readPath(CmsResource resource, CmsResourceFilter filter) throws CmsException Builds a list of resources for a given path.- Parameters:
resource
- the resource to read the path forfilter
- a filter object (only "includeDeleted" information is used!)- Returns:
- list of
sCmsResource
- Throws:
CmsException
- if something goes wrong
-
readPath
Builds a list of resources for a given path.- Parameters:
path
- the requested pathfilter
- a filter object (only "includeDeleted" information is used!)- Returns:
- list of
sCmsResource
- Throws:
CmsException
- if something goes wrong
-
readProject
Reads the project with the given id.- Parameters:
id
- the id of the project- Returns:
- the project with the given id
- Throws:
CmsException
- if operation was not successful
-
readProject
Reads the project with the given name.- Parameters:
name
- the name of the project- Returns:
- the project with the given name
- Throws:
CmsException
- if operation was not successful
-
readProjectResources
Returns the list of all resource names that define the "view" of the given project.- Parameters:
project
- the project to get the project resources for- Returns:
- the list of all resource names (root paths), as
objects that define the "view" of the given projectString
- Throws:
CmsException
- if something goes wrong
-
readProjectView
public List<CmsResource> readProjectView(CmsUUID projectId, CmsResourceState state) throws CmsException Reads all resources of a project that match a given state from the VFS.Possible values for the
state
parameter are:
: Read all "changed" resources in the projectCmsResource.STATE_CHANGED
: Read all "new" resources in the projectCmsResource.STATE_NEW
: Read all "deleted" resources in the projectCmsResource.STATE_DELETED
: Read all resources either "changed", "new" or "deleted" in the projectCmsResource.STATE_KEEP
- Parameters:
projectId
- the id of the project to read the file resources forstate
- the resource state to match- Returns:
- all
s of a project that match a given criteria from the VFSCmsResource
- Throws:
CmsException
- if something goes wrong
-
readPropertyDefinition
Reads a property definition.If no property definition with the given name is found,
null
is returned.- Parameters:
name
- the name of the property definition to read- Returns:
- the property definition that was read
- Throws:
CmsException
- a CmsDbEntryNotFoundException is thrown if the property definition does not exist
-
readPropertyObject
public CmsProperty readPropertyObject(CmsResource resource, String property, boolean search) throws CmsException Reads a property object from a resource specified by a property name.Returns
if the property is not found.CmsProperty.getNullProperty()
This method is more efficient then using
if you already have an instance of the resource to look up the property from.readPropertyObject(String, String, boolean)
- Parameters:
resource
- the resource where the property is attached toproperty
- the property namesearch
- if true, the property is searched on all parent folders of the resource, if it's not found attached directly to the resource- Returns:
- the required property, or
if the property was not foundCmsProperty.getNullProperty()
- Throws:
CmsException
- if something goes wrong
-
readPropertyObject
public CmsProperty readPropertyObject(CmsResource resource, String property, boolean search, Locale locale) throws CmsException Reads the locale specific version of a property object from a resource specified by a property name.Returns
if the property is not found.CmsProperty.getNullProperty()
This method is more efficient then using
if you already have an instance of the resource to look up the property from.readPropertyObject(String, String, boolean)
- Parameters:
resource
- the resource where the property is attached toproperty
- the property namesearch
- if true, the property is searched on all parent folders of the resource, if it's not found attached directly to the resourcelocale
- the locale for which the property should be read.- Returns:
- the required property, or
if the property was not foundCmsProperty.getNullProperty()
- Throws:
CmsException
- if something goes wrong
-
readPropertyObject
public CmsProperty readPropertyObject(String resourcePath, String property, boolean search) throws CmsException Reads a property object from a resource specified by a property name.Returns
if the property is not found.CmsProperty.getNullProperty()
- Parameters:
resourcePath
- the name of resource where the property is attached toproperty
- the property namesearch
- if true, the property is searched on all parent folders of the resource, if it's not found attached directly to the resource- Returns:
- the required property, or
if the property was not foundCmsProperty.getNullProperty()
- Throws:
CmsException
- if something goes wrong
-
readPropertyObject
public CmsProperty readPropertyObject(String resourcePath, String property, boolean search, Locale locale) throws CmsException Reads the locale specific version of a property object from a resource specified by a property name.Returns
if the property is not found.CmsProperty.getNullProperty()
- Parameters:
resourcePath
- the name of resource where the property is attached toproperty
- the property namesearch
- if true, the property is searched on all parent folders of the resource, if it's not found attached directly to the resourcelocale
- the locale for which the property should be read.- Returns:
- the required property, or
if the property was not foundCmsProperty.getNullProperty()
- Throws:
CmsException
- if something goes wrong
-
readPropertyObjects
public List<CmsProperty> readPropertyObjects(CmsResource resource, boolean search) throws CmsException Reads all property objects from a resource.Returns an empty list if no properties are found.
This method is more efficient then using
if you already have an instance of the resource to look up the property from.readPropertyObjects(String, boolean)
If the
search
parameter istrue
, the properties of all parent folders of the resource are also read. The results are merged with the properties directly attached to the resource. While merging, a property on a parent folder that has already been found will be ignored. So e.g. if a resource has a property "Title" attached, and it's parent folder has the same property attached but with a different value, the result list will contain only the property with the value from the resource, not form the parent folder(s).- Parameters:
resource
- the resource where the property is mapped tosearch
- iftrue
, the properties of all parent folders of the resource are merged with the resource properties.- Returns:
- a list of
objectsCmsProperty
- Throws:
CmsException
- if something goes wrong
-
readPropertyObjects
public List<CmsProperty> readPropertyObjects(String resourcePath, boolean search) throws CmsException Reads all property objects from a resource.Returns an empty list if no properties are found.
All properties in the result List will be in frozen (read only) state, so you can't change the values.
If the
search
parameter istrue
, the properties of all parent folders of the resource are also read. The results are merged with the properties directly attached to the resource. While merging, a property on a parent folder that has already been found will be ignored. So e.g. if a resource has a property "Title" attached, and it's parent folder has the same property attached but with a different value, the result list will contain only the property with the value from the resource, not form the parent folder(s).- Parameters:
resourcePath
- the name of resource where the property is mapped tosearch
- iftrue
, the properties of all parent folders of the resource are merged with the resource properties.- Returns:
- a list of
objectsCmsProperty
- Throws:
CmsException
- if something goes wrong
-
readPublishedResources
public List<CmsPublishedResource> readPublishedResources(CmsUUID publishHistoryId) throws CmsException Reads the resources that were published in a publish task for a given publish history ID.- Parameters:
publishHistoryId
- unique ID to identify each publish task in the publish history- Returns:
- a list of
objectsCmsPublishedResource
- Throws:
CmsException
- if something goes wrong
-
readRelations
Returns all relations matching the given filter.- Parameters:
filter
- the filter to match the relation- Returns:
- all relations matching the given filter
- Throws:
CmsException
- if something goes wrong- See Also:
-
readResource
Reads a resource from the VFS, using the
filter.CmsResourceFilter.DEFAULT
A resource may be of type
orCmsFile
. In case of a file, the resource will not contain the binary file content. Since reading the binary content is a cost-expensive database operation, it's recommended to work with resources if possible, and only read the file content when absolutely required. To "upgrade" a resource to a file, useCmsFolder
.readFile(CmsResource)
- Parameters:
structureID
- the structure ID of the resource to read- Returns:
- the resource that was read
- Throws:
CmsException
- if the resource could not be read for any reason- See Also:
-
readResource
Reads a resource from the VFS, using the specified resource filter.A resource may be of type
orCmsFile
. In case of a file, the resource will not contain the binary file content. Since reading the binary content is a cost-expensive database operation, it's recommended to work with resources if possible, and only read the file content when absolutely required. To "upgrade" a resource to a file, useCmsFolder
.readFile(CmsResource)
The specified filter controls what kind of resources should be "found" during the read operation. This will depend on the application. For example, using
will only return currently "valid" resources, while usingCmsResourceFilter.DEFAULT
will ignore the date release / date expired information of the resource.CmsResourceFilter.IGNORE_EXPIRATION
- Parameters:
structureID
- the structure ID of the resource to readfilter
- the resource filter to use while reading- Returns:
- the resource that was read
- Throws:
CmsException
- if the resource could not be read for any reason- See Also:
-
readResource
public I_CmsHistoryResource readResource(CmsUUID structureID, int version) throws CmsException, CmsVfsResourceNotFoundException Reads the historical resource with the given version for the resource given the given structure id.A resource may be of type
orCmsFile
. In case of a file, the resource will not contain the binary file content. Since reading the binary content is a cost-expensive database operation, it's recommended to work with resources if possible, and only read the file content when absolutely required. To "upgrade" a resource to a file, useCmsFolder
.readFile(CmsResource)
Please note that historical versions are just generated during publishing, so the first version with version number 1 is generated during publishing of a new resource (exception is a new sibling, that may also contain some relevant versions of already published siblings) and the last version available is the version of the current online resource.
- Parameters:
structureID
- the structure ID of the resource to readversion
- the version number you want to retrieve- Returns:
- the resource that was read
- Throws:
CmsException
- if the resource could not be read for any reasonCmsVfsResourceNotFoundException
- if the version does not exists- See Also:
-
readResource
Reads a resource from the VFS, using the
filter.CmsResourceFilter.DEFAULT
A resource may be of type
orCmsFile
. In case of a file, the resource will not contain the binary file content. Since reading the binary content is a cost-expensive database operation, it's recommended to work with resources if possible, and only read the file content when absolutely required. To "upgrade" a resource to a file, useCmsFolder
.readFile(CmsResource)
- Parameters:
resourcename
- the name of the resource to read (full current site relative path)- Returns:
- the resource that was read
- Throws:
CmsException
- if the resource could not be read for any reason- See Also:
-
readResource
Reads a resource from the VFS, using the specified resource filter.A resource may be of type
orCmsFile
. In case of a file, the resource will not contain the binary file content. Since reading the binary content is a cost-expensive database operation, it's recommended to work with resources if possible, and only read the file content when absolutely required. To "upgrade" a resource to a file, useCmsFolder
.readFile(CmsResource)
The specified filter controls what kind of resources should be "found" during the read operation. This will depend on the application. For example, using
will only return currently "valid" resources, while usingCmsResourceFilter.DEFAULT
will ignore the date release / date expired information of the resource.CmsResourceFilter.IGNORE_EXPIRATION
- Parameters:
resourcename
- the name of the resource to read (full current site relative path)filter
- the resource filter to use while reading- Returns:
- the resource that was read
- Throws:
CmsException
- if the resource could not be read for any reason- See Also:
-
readResources
public List<CmsResource> readResources(CmsResource resource, CmsResourceFilter filter, boolean readTree) throws CmsException Reads all resources below the given resource matching the filter criteria, including the full tree below the path only in case thereadTree
parameter istrue
.- Parameters:
resource
- the parent resourcefilter
- the filterreadTree
-true
to read all sub resources- Returns:
- a list of
objects matching the filter criteriaCmsResource
- Throws:
CmsException
- if something goes wrong
-
readResources
public List<CmsResource> readResources(String resourcename, CmsResourceFilter filter) throws CmsException Reads all resources below the given path matching the filter criteria, including the full tree below the path.- Parameters:
resourcename
- the parent path to read the resources fromfilter
- the filter- Returns:
- a list of
objects matching the filter criteriaCmsResource
- Throws:
CmsException
- if something goes wrong- See Also:
-
readResources
public List<CmsResource> readResources(String resourcename, CmsResourceFilter filter, boolean readTree) throws CmsException Reads all resources below the given path matching the filter criteria, including the full tree below the path only in case thereadTree
parameter istrue
.- Parameters:
resourcename
- the parent path to read the resources fromfilter
- the filterreadTree
-true
to read all sub resources- Returns:
- a list of
objects matching the filter criteriaCmsResource
- Throws:
CmsException
- if something goes wrong
-
readResourcesWithProperty
Reads all resources that have a value set for the specified property.Both individual and shared properties of a resource are checked.
Will use the
CmsResourceFilter.ALL
resource filter.- Parameters:
propertyDefinition
- the name of the property to check for- Returns:
- a list of all
objects that have a value set for the specified property.CmsResource
- Throws:
CmsException
- if something goes wrong
-
readResourcesWithProperty
public List<CmsResource> readResourcesWithProperty(String path, String propertyDefinition) throws CmsException Reads all resources that have a value set for the specified property in the given path.Both individual and shared properties of a resource are checked.
Will use the
CmsResourceFilter.ALL
resource filter.- Parameters:
path
- the folder to get the resources with the property frompropertyDefinition
- the name of the property to check for- Returns:
- all
objects that have a value set for the specified property in the given path.CmsResource
- Throws:
CmsException
- if something goes wrong
-
readResourcesWithProperty
public List<CmsResource> readResourcesWithProperty(String path, String propertyDefinition, String value) throws CmsException Reads all resources that have a value (containing the specified value) set for the specified property in the given path.Both individual and shared properties of a resource are checked.
If the
value
parameter isnull
, all resources having the given property set are returned.Will use the
CmsResourceFilter.ALL
resource filter.- Parameters:
path
- the folder to get the resources with the property frompropertyDefinition
- the name of the property to check forvalue
- the string to search in the value of the property- Returns:
- all
objects that have a value set for the specified property in the given path.CmsResource
- Throws:
CmsException
- if something goes wrong
-
readResourcesWithProperty
public List<CmsResource> readResourcesWithProperty(String path, String propertyDefinition, String value, CmsResourceFilter filter) throws CmsException Reads all resources that have a value (containing the specified value) set for the specified property in the given path.Both individual and shared properties of a resource are checked.
If the
value
parameter isnull
, all resources having the given property set are returned.Will use the given resource filter.
- Parameters:
path
- the folder to get the resources with the property frompropertyDefinition
- the name of the property to check forvalue
- the string to search in the value of the propertyfilter
- the resource filter to apply to the result set- Returns:
- all
objects that have a value set for the specified property in the given path.CmsResource
- Throws:
CmsException
- if something goes wrong
-
readResponsiblePrincipals
Returns a set of principals that are responsible for a specific resource.- Parameters:
resource
- the resource to get the responsible principals from- Returns:
- the set of principals that are responsible for a specific resource
- Throws:
CmsException
- if something goes wrong
-
readResponsibleUsers
Returns a set of users that are responsible for a specific resource.- Parameters:
resource
- the resource to get the responsible users from- Returns:
- the set of users that are responsible for a specific resource
- Throws:
CmsException
- if something goes wrong
-
readSiblings
public List<CmsResource> readSiblings(CmsResource resource, CmsResourceFilter filter) throws CmsException Returns a list of all siblings of the specified resource, the specified resource being always part of the result set.- Parameters:
resource
- the resourcefilter
- a resource filter- Returns:
- a list of
s that are siblings to the specified resource, including the specified resource itself.CmsResource
- Throws:
CmsException
- if something goes wrong
-
readSiblings
public List<CmsResource> readSiblings(String resourcename, CmsResourceFilter filter) throws CmsException Returns a list of all siblings of the specified resource, the specified resource being always part of the result set.- Parameters:
resourcename
- the name of the specified resourcefilter
- a resource filter- Returns:
- a list of
s that are siblings to the specified resource, including the specified resource itself.CmsResource
- Throws:
CmsException
- if something goes wrong
-
readSiblingsForResourceId
public List<CmsResource> readSiblingsForResourceId(CmsUUID resourceId, CmsResourceFilter filter) throws CmsException Reads all resources with the given resource id.- Parameters:
resourceId
- the resource id for which we want the siblingsfilter
- the resource filter used to read the resources- Returns:
- the siblings which share the given resource id
- Throws:
CmsException
- if something goes wrong
-
readStaticExportPublishedResourceParameters
Returns the parameters of a resource in the list of all published template resources.- Parameters:
rfsName
- the rfs name of the resource- Returns:
- the parameter string of the requested resource
- Throws:
CmsException
- if something goes wrong
-
readStaticExportResources
public List<String> readStaticExportResources(int parameterResources, long timestamp) throws CmsException Returns a list of all template resources which must be processed during a static export.- Parameters:
parameterResources
- flag for reading resources with parameters (1) or without (0)timestamp
- a time stamp for reading the data from the db- Returns:
- a list of template resources as
objectsString
- Throws:
CmsException
- if something goes wrong
-
readUrlNameMappings
public List<CmsUrlNameMappingEntry> readUrlNameMappings(CmsUrlNameMappingFilter filter) throws CmsException Reads the URL name mappings matching a given filter.- Parameters:
filter
- the filter to match- Returns:
- the URL name mappings matching the filter
- Throws:
CmsException
- if something goes wrong
-
readUrlNamesForAllLocales
Reads the URL names for all locales.- Parameters:
structureId
- the id of resource for which the URL names should be read- Returns:
- returns the URL names for the resource
- Throws:
CmsException
- if something goes wrong
-
readUser
Reads a user based on its id.- Parameters:
userId
- the id of the user to be read- Returns:
- the user with the given id
- Throws:
CmsException
- if something goes wrong- See Also:
-
readUser
Reads a user based on its name.- Parameters:
username
- the name of the user to be read- Returns:
- the user with the given name
- Throws:
CmsException
- if something goes wrong
-
readUser
Returns a user, if the password is correct.If the user/pwd pair is not valid a
is thrown.CmsException
- Parameters:
username
- the name of the user to be returnedpassword
- the password of the user to be returned- Returns:
- the validated user
- Throws:
CmsException
- if operation was not successful
-
removeResourceFromProject
Removes a resource from the current project of the user.This is used to reduce the current users project with the specified resource, in case that the resource is already part of the project. The resource is not really removed like in a regular copy operation, it is in fact only "disabled" in the current users project.
- Parameters:
resourcename
- the name of the resource to remove to the current project (full current site relative path)- Throws:
CmsException
- if something goes wrong
-
removeUserFromGroup
Removes a user from a group.- Parameters:
username
- the name of the user that is to be removed from the groupgroupname
- the name of the group- Throws:
CmsException
- if operation was not successful
-
renameResource
Renames a resource to the given destination name, this is identical to amove
operation.- Parameters:
source
- the name of the resource to rename (full current site relative path)destination
- the new resource name (full path)- Throws:
CmsException
- if something goes wrong- See Also:
-
replaceResource
public void replaceResource(String resourcename, I_CmsResourceType type, byte[] content, List<CmsProperty> properties) throws CmsException Replaces the content, type and properties of a resource.- Parameters:
resourcename
- the name of the resource to replace (full current site relative path)type
- the new type of the resourcecontent
- the new content of the resourceproperties
- the new properties of the resource- Throws:
CmsException
- if something goes wrong
-
replaceResource
@Deprecated public void replaceResource(String resourcename, int type, byte[] content, List<CmsProperty> properties) throws CmsException Deprecated.UsereplaceResource(String, I_CmsResourceType, byte[], List)
instead. Resource types should always be referenced either by its type class (preferred) or by type name. Use of int based resource type references will be discontinued in a future OpenCms release.Replaces the content, type and properties of a resource.- Parameters:
resourcename
- the name of the resource to replace (full current site relative path)type
- the new type of the resourcecontent
- the new content of the resourceproperties
- the new properties of the resource- Throws:
CmsException
- if something goes wrong
-
restoreDeletedResource
Restores a deleted resource identified by its structure id from the historical archive.These ids can be obtained from the
readDeletedResources(String, boolean)
method.- Parameters:
structureId
- the structure id of the resource to restore- Throws:
CmsException
- if something goes wrong
-
restoreResourceVersion
Restores a resource in the current project with a version from the historical archive.- Parameters:
structureId
- the structure id of the resource to restore from the archiveversion
- the desired version of the resource to be restored- Throws:
CmsException
- if something goes wrong- See Also:
-
rmacc
public void rmacc(String resourceName, String principalType, String principalName) throws CmsException Removes an access control entry of a given principal from a given resource.- Parameters:
resourceName
- name of the resourceprincipalType
- the type of the principal (currently group or user)principalName
- the name of the principal- Throws:
CmsException
- if something goes wrong
-
setDateExpired
public void setDateExpired(CmsResource resource, long dateExpired, boolean recursive) throws CmsException Changes the "expire" date of a resource.- Parameters:
resource
- the resource to changedateExpired
- the new expire date of the changed resourcerecursive
- if this operation is to be applied recursively to all resources in a folder- Throws:
CmsException
- if something goes wrong
-
setDateExpired
public void setDateExpired(String resourcename, long dateExpired, boolean recursive) throws CmsException Changes the "expire" date of a resource.- Parameters:
resourcename
- the name of the resource to change (full current site relative path)dateExpired
- the new expire date of the changed resourcerecursive
- if this operation is to be applied recursively to all resources in a folder- Throws:
CmsException
- if something goes wrong
-
setDateLastModified
public void setDateLastModified(String resourcename, long dateLastModified, boolean recursive) throws CmsException Changes the "last modified" time stamp of a resource.- Parameters:
resourcename
- the name of the resource to change (full current site relative path)dateLastModified
- time stamp the new time stamp of the changed resourcerecursive
- if this operation is to be applied recursively to all resources in a folder- Throws:
CmsException
- if something goes wrong
-
setDateReleased
public void setDateReleased(CmsResource resource, long dateReleased, boolean recursive) throws CmsException Changes the "release" date of a resource.- Parameters:
resource
- the resource to changedateReleased
- the new release date of the changed resourcerecursive
- if this operation is to be applied recursively to all resources in a folder- Throws:
CmsException
- if something goes wrong
-
setDateReleased
public void setDateReleased(String resourcename, long dateReleased, boolean recursive) throws CmsException Changes the "release" date of a resource.- Parameters:
resourcename
- the name of the resource to change (full current site relative path)dateReleased
- the new release date of the changed resourcerecursive
- if this operation is to be applied recursively to all resources in a folder- Throws:
CmsException
- if something goes wrong
-
setParentGroup
Sets a new parent-group for an already existing group.- Parameters:
groupName
- the name of the group that should be updatedparentGroupName
- the name of the parent group to set, ornull
if the parent group should be deleted.- Throws:
CmsException
- if operation was not successful
-
setPassword
Sets the password for a user.- Parameters:
username
- the name of the usernewPassword
- the new password- Throws:
CmsException
- if operation was not successful
-
setPassword
public void setPassword(String username, String oldPassword, CmsSecondFactorInfo secondFactor, String newPassword) throws CmsException Sets the password for a specified user.- Parameters:
username
- the name of the useroldPassword
- the old passwordsecondFactor
- the second factor information for 2FAnewPassword
- the new password- Throws:
CmsException
- if the user data could not be read from the database
-
setPassword
public void setPassword(String username, String oldPassword, String newPassword) throws CmsException Sets the password for a specified user.- Parameters:
username
- the name of the useroldPassword
- the old passwordnewPassword
- the new password- Throws:
CmsException
- if the user data could not be read from the database
-
setRestricted
public void setRestricted(CmsResource res, String groupName, boolean restricted) throws CmsException Sets/clears the 'restricted' status for the given resource and group.The 'restricted' status causes files to be inaccessible to users not in the group if the file is expired or unreleased.
It is implemented as an access control entry with the 'responsible' flag, but the permission check for this method is different from the chacc() methods: It doesn't require control permissions on the target resource, but the user has to be a member of the given group and have write access to the resource.
- Parameters:
res
- the target resourcegroup
- a group (current user must be a member)restricted
- true if the restriction status should be set- Throws:
CmsException
- if something goes wrong
-
tempChangeSiteRoot
Helper method to temporarily change the site root in a try-with-resources statement.- Parameters:
siteRoot
- the site root to switch to- Returns:
- an AutoCloseable that restores the original site root when closed
-
undeleteResource
Undeletes a resource.Only resources that have already been published once can be undeleted, if a "new" resource is deleted it can not be undeleted.
- Parameters:
resourcename
- the name of the resource to undeleterecursive
- if this operation is to be applied recursively to all resources in a folder- Throws:
CmsException
- if something goes wrong- See Also:
-
undoChanges
public void undoChanges(String resourcename, CmsResource.CmsResourceUndoMode mode) throws CmsException Undoes all changes to a resource by restoring the version from the online project to the current offline project.- Parameters:
resourcename
- the name of the resource to undo the changes formode
- the undo mode, one of the
constantsCmsResource.CmsResourceUndoMode
#UNDO_XXX- Throws:
CmsException
- if something goes wrong- See Also:
-
unlockProject
Unlocks all resources of a project.- Parameters:
id
- the id of the project to be unlocked- Throws:
CmsException
- if operation was not successful
-
unlockResource
Unlocks a resource.- Parameters:
resource
- the resource to unlock- Throws:
CmsException
- if something goes wrong
-
unlockResource
Unlocks a resource.- Parameters:
resourcename
- the name of the resource to unlock (full current site relative path)- Throws:
CmsException
- if something goes wrong
-
updateLastLoginDate
Updates the last login date on the given user to the current time.- Parameters:
user
- the user to be updated- Throws:
CmsRoleViolationException
- if the current user does not own the ruleCmsRole.ACCOUNT_MANAGER
for the current projectCmsException
- if operation was not successful
-
userInGroup
Tests if a user is member of the given group.- Parameters:
username
- the name of the user to testgroupname
- the name of the group to test- Returns:
true
, if the user is in the group; orfalse
otherwise- Throws:
CmsException
- if operation was not successful
-
validatePassword
This method checks if a new password follows the rules for new passwords, which are defined by a Class implementing the
interface and configured in the opencms.properties file.I_CmsPasswordHandler
If this method throws no exception the password is valid.
- Parameters:
password
- the new password that has to be checked- Throws:
CmsSecurityException
- if the password is not valid
-
writeFile
Writes a resource to the OpenCms VFS, including it's content.Applies only to resources of type
i.e. resources that have a binary content attached.CmsFile
Certain resource types might apply content validation or transformation rules before the resource is actually written to the VFS. The returned result might therefore be a modified version from the provided original.
- Parameters:
resource
- the resource to write- Returns:
- the written resource (may have been modified)
- Throws:
CmsException
- if something goes wrong
-
writeGroup
Writes an already existing group.The group has to be a valid OpenCms group.
The group will be completely overridden by the given data.- Parameters:
group
- the group that should be written- Throws:
CmsException
- if operation was not successful
-
writeHistoryProject
Creates a historical entry of the current project.- Parameters:
publishTag
- the correlative publish tagpublishDate
- the date of publishing- Throws:
CmsException
- if operation was not successful
-
writeProject
Writes an already existing project.The project id has to be a valid OpenCms project id.
The project with the given id will be completely overridden by the given data.- Parameters:
project
- the project that should be written- Throws:
CmsException
- if operation was not successful
-
writeProjectLastModified
Writes the 'projectlastmodified' field of a resource record.- Parameters:
resource
- the resource which should be modifiedproject
- the project whose id should be written into the resource record- Throws:
CmsException
- if something goes wrong
-
writePropertyObject
Writes a property for a specified resource.- Parameters:
resourcename
- the name of resource with complete pathproperty
- the property to write- Throws:
CmsException
- if something goes wrong
-
writePropertyObjects
Writes a list of properties for a specified resource.Code calling this method has to ensure that the no properties
a, b
are contained in the specified list so thata.equals(b)
, otherwise an exception is thrown.- Parameters:
res
- the resourceproperties
- the list of properties to write- Throws:
CmsException
- if something goes wrong
-
writePropertyObjects
public void writePropertyObjects(String resourcename, List<CmsProperty> properties) throws CmsException Writes a list of properties for a specified resource.Code calling this method has to ensure that the no properties
a, b
are contained in the specified list so thata.equals(b)
, otherwise an exception is thrown.- Parameters:
resourcename
- the name of resource with complete pathproperties
- the list of properties to write- Throws:
CmsException
- if something goes wrong
-
writeResource
Writes a resource.- Parameters:
resource
- the file to write- Throws:
CmsException
- if resource type is set to folder, or if the user has not the rights to write the file header.
-
writeStaticExportPublishedResource
public void writeStaticExportPublishedResource(String resourceName, int linkType, String linkParameter, long timestamp) throws CmsException Writes a published resource entry.This is done during static export.
- Parameters:
resourceName
- The name of the resource to be added to the static exportlinkType
- the type of resource exported (0= non-parameter, 1=parameter)linkParameter
- the parameters added to the resourcetimestamp
- a time stamp for writing the data into the db- Throws:
CmsException
- if something goes wrong
-
writeUrlNameMapping
public String writeUrlNameMapping(Iterator<String> nameSeq, CmsUUID structureId, String locale, boolean replaceOnPublish) throws CmsException Writes a new URL name mapping for a given resource.The first name from the given name sequence which is not already mapped to another resource will be used for the URL name mapping.
- Parameters:
nameSeq
- an iterator for generating names for the mappingstructureId
- the structure id to which the name should be mappedlocale
- the locale of the mappingreplaceOnPublish
- if the mapping should replace previous mappings when published- Returns:
- the name which was actually mapped to the structure id
- Throws:
CmsException
- if something goes wrong
-
writeUrlNameMapping
public String writeUrlNameMapping(String name, CmsUUID structureId, String locale, boolean replaceOnPublish) throws CmsException Writes a new URL name mapping for a given resource.This method uses
CmsNumberSuffixNameSequence
to generate a sequence of name candidates from the given base name.- Parameters:
name
- the base name for the mappingstructureId
- the structure id to which the name should be mappedlocale
- the locale of the mappingreplaceOnPublish
- mappings for which this is set will replace older mappings on publish- Returns:
- the URL name that was actually used for the mapping
- Throws:
CmsException
- if something goes wrong
-
writeUser
Updates the user information.The user id has to be a valid OpenCms user id.
The user with the given id will be completely overriden by the given data.- Parameters:
user
- the user to be written- Throws:
CmsException
- if operation was not successful
-
chtype(String, I_CmsResourceType)
instead.