public final class CmsObject extends java.lang.Object
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)
Modifier and Type | Field and Description |
---|---|
protected CmsRequestContext |
m_context
The request context.
|
protected CmsSecurityManager |
m_securityManager
The security manager to access the cms.
|
Constructor and Description |
---|
CmsObject(CmsSecurityManager securityManager,
CmsRequestContext context)
Connects an OpenCms user context to a running database.
|
Modifier and Type | Method and Description |
---|---|
void |
addRelationToResource(CmsResource resource,
CmsResource target,
java.lang.String type)
Adds a new relation to the given resource.
|
void |
addRelationToResource(java.lang.String resourceName,
java.lang.String targetPath,
java.lang.String type)
Adds a new relation to the given resource.
|
java.lang.String |
addSiteRoot(java.lang.String resourcename)
Convenience method to add the site root from the current user's
request context to the given resource name.
|
void |
addUserToGroup(java.lang.String username,
java.lang.String groupname)
Adds a user to a group.
|
void |
adjustLinks(java.util.List<java.lang.String> sourceFiles,
java.lang.String targetParentFolder)
This method works just like
adjustLinks(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(java.util.Map<java.lang.String,java.lang.String> sourceTargetMap,
java.lang.String targetParentFolder)
This method works just like
adjustLinks(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 |
adjustLinks(java.lang.String sourceFolder,
java.lang.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 |
chacc(java.lang.String resourceName,
java.lang.String principalType,
java.lang.String principalName,
int allowedPermissions,
int deniedPermissions,
int flags)
Changes the access control for a given resource and a given principal(user/group).
|
void |
chacc(java.lang.String resourceName,
java.lang.String principalType,
java.lang.String principalName,
java.lang.String permissionString)
Changes the access control for a given resource and a given principal(user/group).
|
void |
changeLock(CmsResource resource)
Changes the lock of a resource to the current user,
that is "steals" the lock from another user.
|
void |
changeLock(java.lang.String resourcename)
Changes the lock of a resource to the current user,
that is "steals" the lock from another user.
|
java.util.List<CmsResource> |
changeResourcesInFolderWithProperty(java.lang.String resourcename,
java.lang.String property,
java.lang.String oldValue,
java.lang.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 |
chflags(java.lang.String resourcename,
int flags)
Changes the resource flags of a resource.
|
void |
chtype(java.lang.String resourcename,
I_CmsResourceType type)
Changes the resource type of a resource.
|
void |
chtype(java.lang.String resourcename,
int type)
Deprecated.
Use
chtype(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. |
void |
copyResource(java.lang.String source,
java.lang.String destination)
Copies a resource.
|
void |
copyResource(java.lang.String source,
java.lang.String destination,
CmsResource.CmsResourceCopyMode siblingMode)
Copies a resource.
|
void |
copyResourceToProject(CmsResource resource)
Copies a resource to the current project of the user.
|
void |
copyResourceToProject(java.lang.String resourcename)
Copies a resource to the current project of the user.
|
int |
countLockedResources(CmsUUID id)
Counts the locked resources in a project.
|
void |
cpacc(java.lang.String sourceName,
java.lang.String destName)
Copies access control entries of a given resource to another resource.
|
CmsGroup |
createGroup(java.lang.String groupFqn,
java.lang.String description,
int flags,
java.lang.String parent)
Creates a new user group.
|
CmsProject |
createProject(java.lang.String name,
java.lang.String description,
java.lang.String groupname,
java.lang.String managergroupname)
Creates a new project.
|
CmsProject |
createProject(java.lang.String name,
java.lang.String description,
java.lang.String groupname,
java.lang.String managergroupname,
CmsProject.CmsProjectType projecttype)
Creates a new project.
|
CmsPropertyDefinition |
createPropertyDefinition(java.lang.String name)
Creates a property definition.
|
CmsResource |
createResource(java.lang.String sitePath,
CmsResource resource,
byte[] content,
java.util.List<CmsProperty> properties)
Creates a resource with the given properties and content.
|
CmsResource |
createResource(java.lang.String resourcename,
I_CmsResourceType type)
Creates a new resource of the given resource type with
empty content and no properties.
|
CmsResource |
createResource(java.lang.String resourcename,
I_CmsResourceType type,
byte[] content,
java.util.List<CmsProperty> properties)
Creates a new resource of the given resource type
with the provided content and properties.
|
CmsResource |
createResource(java.lang.String resourcename,
int type)
Deprecated.
Use
createResource(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. |
CmsResource |
createResource(java.lang.String resourcename,
int type,
byte[] content,
java.util.List<CmsProperty> properties)
Deprecated.
Use
createResource(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. |
CmsResource |
createSibling(java.lang.String source,
java.lang.String destination,
java.util.List<CmsProperty> properties)
Creates a new sibling of the source resource.
|
CmsProject |
createTempfileProject()
Creates the project for the temporary workplace files.
|
CmsUser |
createUser(java.lang.String userFqn,
java.lang.String password,
java.lang.String description,
java.util.Map<java.lang.String,java.lang.Object> additionalInfos)
Creates a new user.
|
void |
deleteAllStaticExportPublishedResources(int linkType)
Deletes all published resource entries.
|
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 |
deleteGroup(java.lang.String group)
Deletes a user 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 |
deletePropertyDefinition(java.lang.String name)
Deletes a property definition.
|
void |
deleteRelationsFromResource(CmsResource resource,
CmsRelationFilter filter)
Deletes the relations to a given resource.
|
void |
deleteRelationsFromResource(java.lang.String resourceName,
CmsRelationFilter filter)
Deletes the relations to a given resource.
|
void |
deleteResource(CmsResource res,
CmsResource.CmsResourceDeleteMode deletePreserveSiblings)
Deletes a resource.
|
void |
deleteResource(java.lang.String resourcename,
CmsResource.CmsResourceDeleteMode siblingMode)
Deletes a resource given its name.
|
void |
deleteStaticExportPublishedResource(java.lang.String resourceName,
int linkType,
java.lang.String linkParameter)
Deletes a published resource entry.
|
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.
|
void |
deleteUser(java.lang.String username)
Deletes a user.
|
boolean |
existsResource(CmsUUID structureId)
Checks the availability of a resource in the VFS,
using the
filter. |
boolean |
existsResource(CmsUUID structureId,
CmsResourceFilter filter)
Checks the availability of a resource in the VFS,
using the
filter. |
boolean |
existsResource(java.lang.String resourcename)
Checks the availability of a resource in the VFS,
using the
filter. |
boolean |
existsResource(java.lang.String resourcename,
CmsResourceFilter filter)
Checks the availability of a resource in the VFS,
using the provided filter.
|
java.util.List<CmsAccessControlEntry> |
getAccessControlEntries(java.lang.String resourceName)
Returns the list of access control entries of a resource given its name.
|
java.util.List<CmsAccessControlEntry> |
getAccessControlEntries(java.lang.String resourceName,
boolean getInherited)
Returns the list of access control entries of a resource given its name.
|
CmsAccessControlList |
getAccessControlList(java.lang.String resourceName)
Returns the access control list (summarized access control entries) of a given resource.
|
CmsAccessControlList |
getAccessControlList(java.lang.String resourceName,
boolean inheritedOnly)
Returns the access control list (summarized access control entries) of a given resource.
|
java.util.List<CmsAccessControlEntry> |
getAllAccessControlEntries()
Gets all access control entries for the current project.
|
java.util.List<CmsHistoryProject> |
getAllHistoricalProjects()
Returns a list with all projects from history.
|
java.util.List<java.lang.String> |
getAllUrlNames(CmsUUID id)
Gets all URL names for a given structure id.
|
java.util.List<CmsResource> |
getBlockingLockedResources(CmsResource resource)
Returns a list of child resources to the given resource that can not be locked by the current user.
|
java.util.List<CmsResource> |
getBlockingLockedResources(java.lang.String resourceName)
Returns a list of child resources to the given resource that can not be locked by the current user.
|
java.util.List<CmsGroup> |
getChildren(java.lang.String groupname,
boolean includeSubChildren)
Returns all child groups of a group.
|
java.lang.String |
getDetailName(CmsResource res,
java.util.Locale locale,
java.util.List<java.util.Locale> defaultLocales)
Returns the detail name of a resource.
|
java.util.List<CmsResource> |
getFilesInFolder(java.lang.String resourcename)
Returns all file resources contained in a folder.
|
java.util.List<CmsResource> |
getFilesInFolder(java.lang.String resourcename,
CmsResourceFilter filter)
Returns all file resources contained in a folder.
|
java.util.List<CmsGroup> |
getGroupsOfUser(java.lang.String username,
boolean directGroupsOnly)
Returns all the groups the given user belongs to.
|
java.util.List<CmsGroup> |
getGroupsOfUser(java.lang.String username,
boolean directGroupsOnly,
boolean includeOtherOus)
Returns all the groups the given user belongs to.
|
java.util.List<CmsGroup> |
getGroupsOfUser(java.lang.String username,
boolean directGroupsOnly,
boolean includeOtherOus,
java.lang.String remoteAddress)
Returns the groups of a user filtered by the specified IP address.
|
CmsLocaleGroupService |
getLocaleGroupService()
Creates a new locale group service.
|
CmsLock |
getLock(CmsResource resource)
Returns the edition lock state for a specified resource.
|
CmsLock |
getLock(java.lang.String resourcename)
Returns the lock state for a specified resource name.
|
java.util.List<CmsResource> |
getLockedResources(CmsResource resource,
CmsLockFilter filter)
Returns all locked resources within a folder or matches the lock of the given resource.
|
java.util.List<java.lang.String> |
getLockedResources(java.lang.String resourceName,
CmsLockFilter filter)
Returns all locked resources within a folder or matches the lock of the given resource.
|
java.util.List<CmsResource> |
getLockedResourcesWithCache(CmsResource resource,
CmsLockFilter filter,
java.util.Map<java.lang.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.
|
java.util.List<CmsLogEntry> |
getLogEntries(CmsLogFilter filter)
Returns all log entries matching the given filter.
|
java.lang.String |
getLostAndFoundName(java.lang.String resourcename)
Returns the name a resource would have if it were moved to the
"lost and found" folder.
|
CmsGroup |
getParent(java.lang.String groupname)
Returns the parent group of a group.
|
CmsPermissionSet |
getPermissions(java.lang.String resourceName)
Returns the set of permissions of the current user for a given resource.
|
CmsPermissionSet |
getPermissions(java.lang.String resourceName,
java.lang.String userName)
Returns the set of permissions of a given user for a given resource.
|
java.util.List<CmsRelation> |
getRelationsForResource(CmsResource resource,
CmsRelationFilter filter)
Returns all relations for the given resource matching the given filter.
|
java.util.List<CmsRelation> |
getRelationsForResource(java.lang.String resourceName,
CmsRelationFilter filter)
Returns all relations for the given resource matching the given filter.
|
CmsRequestContext |
getRequestContext()
Returns the current users request context.
|
java.util.Set<CmsResource> |
getResourcesForPrincipal(CmsUUID principalId,
CmsPermissionSet permissions,
boolean includeAttr)
Returns all resources associated to a given principal via an ACE with the given permissions.
|
java.util.List<CmsResource> |
getResourcesInFolder(java.lang.String resourcename,
CmsResourceFilter filter)
Returns all child resources of a resource, that is the resources
contained in a folder.
|
java.lang.String |
getSitePath(CmsResource resource)
Adjusts the absolute resource root path for the current site.
|
java.util.List<CmsResource> |
getSubFolders(java.lang.String resourcename)
Returns all folder resources contained in a folder.
|
java.util.List<CmsResource> |
getSubFolders(java.lang.String resourcename,
CmsResourceFilter filter)
Returns all folder resources contained in a folder.
|
java.util.List<java.lang.String> |
getUrlNamesForAllLocales(CmsUUID id)
Returns the newest URL names for the given structure id for each locale.
|
java.util.List<CmsUser> |
getUsersOfGroup(java.lang.String groupname)
Returns all direct users of a given group.
|
java.util.List<CmsUser> |
getUsersOfGroup(java.lang.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,
java.util.List<CmsAccessControlEntry> acEntries)
Writes a list of access control entries as new access control entries of a given resource.
|
void |
importRelation(java.lang.String resourceName,
java.lang.String targetPath,
java.lang.String relationType)
Imports a new relation to the given resource.
|
CmsResource |
importResource(java.lang.String resourcename,
CmsResource resource,
byte[] content,
java.util.List<CmsProperty> properties)
Imports a resource to the OpenCms VFS.
|
CmsUser |
importUser(java.lang.String id,
java.lang.String name,
java.lang.String password,
java.lang.String firstname,
java.lang.String lastname,
java.lang.String email,
int flags,
long dateCreated,
java.util.Map<java.lang.String,java.lang.Object> additionalInfos)
Creates a new user by import.
|
int |
incrementCounter(java.lang.String name)
Increments a counter and returns its old value.
|
boolean |
isInsideCurrentProject(java.lang.String resourcename)
Checks if the specified resource is inside the current project.
|
boolean |
isManagerOfProject()
Checks if the current user has management access to the current project.
|
void |
lockResource(CmsResource resource)
Locks a resource.
|
void |
lockResource(java.lang.String resourcename)
Locks a resource.
|
void |
lockResourceTemporary(CmsResource resource)
Locks a resource temporary.
|
void |
lockResourceTemporary(java.lang.String resourcename)
Locks a resource temporary.
|
java.lang.String |
loginUser(java.lang.String username,
java.lang.String password)
Logs a user into the Cms, if the password is correct.
|
java.lang.String |
loginUser(java.lang.String username,
java.lang.String password,
java.lang.String remoteAddress)
Logs a user with a given ip address into the Cms, if the password is correct.
|
I_CmsPrincipal |
lookupPrincipal(CmsUUID principalId)
Lookups and reads the user or group with the given UUID.
|
I_CmsPrincipal |
lookupPrincipal(java.lang.String principalName)
Lookups and reads the user or group with the given name.
|
void |
moveResource(java.lang.String source,
java.lang.String destination)
Moves a resource to the given destination.
|
java.lang.String |
moveToLostAndFound(java.lang.String resourcename)
Moves a resource to the "lost and found" folder.
|
java.util.List<I_CmsHistoryResource> |
readAllAvailableVersions(CmsResource resource)
Reads all available versions for a given resource.
|
java.util.List<I_CmsHistoryResource> |
readAllAvailableVersions(java.lang.String resourceName)
Reads all historical versions of a resource.
|
java.util.List<CmsPropertyDefinition> |
readAllPropertyDefinitions()
Reads all property definitions.
|
CmsFolder |
readAncestor(java.lang.String resourcename,
CmsResourceFilter filter)
Returns the first ancestor folder matching the filter criteria.
|
CmsFolder |
readAncestor(java.lang.String resourcename,
int type)
Returns the first ancestor folder matching the resource type.
|
java.lang.String |
readBestUrlName(CmsUUID id,
java.util.Locale locale,
java.util.List<java.util.Locale> defaultLocales)
Reads the newest URL name which is mapped to the given structure id.
|
CmsResource |
readDefaultFile(CmsResource folderResource,
CmsResourceFilter resourceFilter)
Returns the default resource for the given folder.
|
CmsResource |
readDefaultFile(java.lang.String resourceNameOrID)
Returns the default resource for the given folder.
|
CmsResource |
readDefaultFile(java.lang.String resourceNameOrID,
CmsResourceFilter filter)
Returns the default resource for the given folder.
|
java.util.List<I_CmsHistoryResource> |
readDeletedResources(java.lang.String resourcename,
boolean readTree)
Reads all deleted (historical) resources below the given path,
including the full tree below the path, if required.
|
CmsFile |
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).
|
CmsFile |
readFile(java.lang.String resourcename)
Reads a file resource (including it's binary content) from the VFS,
using the
filter. |
CmsFile |
readFile(java.lang.String resourcename,
CmsResourceFilter filter)
Reads a file resource (including it's binary content) from the VFS,
using the specified resource filter.
|
CmsFolder |
readFolder(java.lang.String resourcename)
Reads a folder resource from the VFS,
using the
filter. |
CmsFolder |
readFolder(java.lang.String resourcename,
CmsResourceFilter filter)
Reads a folder resource from the VFS,
using the specified resource filter.
|
CmsGroup |
readGroup(CmsProject project)
Reads the group of a project.
|
CmsGroup |
readGroup(CmsUUID groupId)
Reads a group based on its id.
|
CmsGroup |
readGroup(java.lang.String groupName)
Reads a group based on its name.
|
CmsHistoryPrincipal |
readHistoryPrincipal(CmsUUID principalId)
Reads a principal (an user or group) from the historical archive based on its ID.
|
CmsHistoryProject |
readHistoryProject(CmsUUID projectId)
Returns the latest historical project entry with the given id.
|
CmsHistoryProject |
readHistoryProject(int publishTag)
Returns a historical project entry.
|
java.util.List<CmsProperty> |
readHistoryPropertyObjects(I_CmsHistoryResource resource)
Reads the list of all
objects that belong to the given historical resource version. |
CmsUUID |
readIdForUrlName(java.lang.String name)
This method retrieves the structure id which is mapped to a given URL name.
|
CmsGroup |
readManagerGroup(CmsProject project)
Returns the project manager group of a project.
|
CmsUser |
readOwner(CmsProject project)
Reads the owner of a project.
|
CmsResource |
readParentFolder(CmsUUID structureId)
Returns the parent folder to the given structure id.
|
java.util.List<CmsResource> |
readPath(CmsResource resource,
CmsResourceFilter filter)
Builds a list of resources for a given path.
|
java.util.List<CmsResource> |
readPath(java.lang.String path,
CmsResourceFilter filter)
Builds a list of resources for a given path.
|
CmsProject |
readProject(CmsUUID id)
Reads the project with the given id.
|
CmsProject |
readProject(java.lang.String name)
Reads the project with the given name.
|
java.util.List<java.lang.String> |
readProjectResources(CmsProject project)
Returns the list of all resource names that define the "view" of the given project.
|
java.util.List<CmsResource> |
readProjectView(CmsUUID projectId,
CmsResourceState state)
Reads all resources of a project that match a given state from the VFS.
|
CmsPropertyDefinition |
readPropertyDefinition(java.lang.String name)
Reads a property definition.
|
CmsProperty |
readPropertyObject(CmsResource resource,
java.lang.String property,
boolean search)
Reads a property object from a resource specified by a property name.
|
CmsProperty |
readPropertyObject(CmsResource resource,
java.lang.String property,
boolean search,
java.util.Locale locale)
Reads the locale specific version of a property object from a resource specified by a property name.
|
CmsProperty |
readPropertyObject(java.lang.String resourcePath,
java.lang.String property,
boolean search)
Reads a property object from a resource specified by a property name.
|
CmsProperty |
readPropertyObject(java.lang.String resourcePath,
java.lang.String property,
boolean search,
java.util.Locale locale)
Reads the locale specific version of a property object from a resource specified by a property name.
|
java.util.List<CmsProperty> |
readPropertyObjects(CmsResource resource,
boolean search)
Reads all property objects from a resource.
|
java.util.List<CmsProperty> |
readPropertyObjects(java.lang.String resourcePath,
boolean search)
Reads all property objects from a resource.
|
java.util.List<CmsPublishedResource> |
readPublishedResources(CmsUUID publishHistoryId)
Reads the resources that were published in a publish task for a given publish history ID.
|
java.util.List<CmsRelation> |
readRelations(CmsRelationFilter filter)
Returns all relations matching the given filter.
|
CmsResource |
readResource(CmsUUID structureID)
Reads a resource from the VFS,
using the
filter. |
CmsResource |
readResource(CmsUUID structureID,
CmsResourceFilter filter)
Reads a resource from the VFS,
using the specified resource filter.
|
I_CmsHistoryResource |
readResource(CmsUUID structureID,
int version)
Reads the historical resource with the given version for the resource given
the given structure id.
|
CmsResource |
readResource(java.lang.String resourcename)
Reads a resource from the VFS,
using the
filter. |
CmsResource |
readResource(java.lang.String resourcename,
CmsResourceFilter filter)
Reads a resource from the VFS,
using the specified resource filter.
|
java.util.List<CmsResource> |
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 the
readTree
parameter is true . |
java.util.List<CmsResource> |
readResources(java.lang.String resourcename,
CmsResourceFilter filter)
Reads all resources below the given path matching the filter criteria,
including the full tree below the path.
|
java.util.List<CmsResource> |
readResources(java.lang.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 the
readTree
parameter is true . |
java.util.List<CmsResource> |
readResourcesWithProperty(java.lang.String propertyDefinition)
Reads all resources that have a value set for the specified property.
|
java.util.List<CmsResource> |
readResourcesWithProperty(java.lang.String path,
java.lang.String propertyDefinition)
Reads all resources that have a value set for the specified property in the given path.
|
java.util.List<CmsResource> |
readResourcesWithProperty(java.lang.String path,
java.lang.String propertyDefinition,
java.lang.String value)
Reads all resources that have a value (containing the specified value) set
for the specified property in the given path.
|
java.util.List<CmsResource> |
readResourcesWithProperty(java.lang.String path,
java.lang.String propertyDefinition,
java.lang.String value,
CmsResourceFilter filter)
Reads all resources that have a value (containing the specified value) set
for the specified property in the given path.
|
java.util.Set<I_CmsPrincipal> |
readResponsiblePrincipals(CmsResource resource)
Returns a set of principals that are responsible for a specific resource.
|
java.util.Set<CmsUser> |
readResponsibleUsers(CmsResource resource)
Returns a set of users that are responsible for a specific resource.
|
java.util.List<CmsResource> |
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.
|
java.util.List<CmsResource> |
readSiblings(java.lang.String resourcename,
CmsResourceFilter filter)
Returns a list of all siblings of the specified resource,
the specified resource being always part of the result set.
|
java.util.List<CmsResource> |
readSiblingsForResourceId(CmsUUID resourceId,
CmsResourceFilter filter)
Reads all resources with the given resource id.
|
java.lang.String |
readStaticExportPublishedResourceParameters(java.lang.String rfsName)
Returns the parameters of a resource in the list of all published template resources.
|
java.util.List<java.lang.String> |
readStaticExportResources(int parameterResources,
long timestamp)
Returns a list of all template resources which must be processed during a static export.
|
java.util.List<CmsUrlNameMappingEntry> |
readUrlNameMappings(CmsUrlNameMappingFilter filter)
Reads the URL name mappings matching a given filter.
|
java.util.List<java.lang.String> |
readUrlNamesForAllLocales(CmsUUID structureId)
Reads the URL names for all locales.
|
CmsUser |
readUser(CmsUUID userId)
Reads a user based on its id.
|
CmsUser |
readUser(java.lang.String username)
Reads a user based on its name.
|
CmsUser |
readUser(java.lang.String username,
java.lang.String password)
Returns a user, if the password is correct.
|
void |
removeResourceFromProject(java.lang.String resourcename)
Removes a resource from the current project of the user.
|
void |
removeUserFromGroup(java.lang.String username,
java.lang.String groupname)
Removes a user from a group.
|
void |
renameResource(java.lang.String source,
java.lang.String destination)
Renames a resource to the given destination name,
this is identical to a
move operation. |
void |
replaceResource(java.lang.String resourcename,
I_CmsResourceType type,
byte[] content,
java.util.List<CmsProperty> properties)
Replaces the content, type and properties of a resource.
|
void |
replaceResource(java.lang.String resourcename,
int type,
byte[] content,
java.util.List<CmsProperty> properties)
Deprecated.
Use
replaceResource(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. |
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 |
rmacc(java.lang.String resourceName,
java.lang.String principalType,
java.lang.String principalName)
Removes an access control entry of a given principal from a given resource.
|
void |
setDateExpired(CmsResource resource,
long dateExpired,
boolean recursive)
Changes the "expire" date of a resource.
|
void |
setDateExpired(java.lang.String resourcename,
long dateExpired,
boolean recursive)
Changes the "expire" date of a resource.
|
void |
setDateLastModified(java.lang.String resourcename,
long dateLastModified,
boolean recursive)
Changes the "last modified" time stamp of a resource.
|
void |
setDateReleased(CmsResource resource,
long dateReleased,
boolean recursive)
Changes the "release" date of a resource.
|
void |
setDateReleased(java.lang.String resourcename,
long dateReleased,
boolean recursive)
Changes the "release" date of a resource.
|
void |
setParentGroup(java.lang.String groupName,
java.lang.String parentGroupName)
Sets a new parent-group for an already existing group.
|
void |
setPassword(java.lang.String username,
java.lang.String newPassword)
Sets the password for a user.
|
void |
setPassword(java.lang.String username,
java.lang.String oldPassword,
java.lang.String newPassword)
Sets the password for a specified user.
|
void |
undeleteResource(java.lang.String resourcename,
boolean recursive)
Undeletes a resource.
|
void |
undoChanges(java.lang.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(CmsResource resource)
Unlocks a resource.
|
void |
unlockResource(java.lang.String resourcename)
Unlocks a resource.
|
void |
updateLastLoginDate(CmsUser user)
Updates the last login date on the given user to the current time.
|
boolean |
userInGroup(java.lang.String username,
java.lang.String groupname)
Tests if a user is member of the given group.
|
void |
validatePassword(java.lang.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. |
CmsFile |
writeFile(CmsFile resource)
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(java.lang.String resourcename,
CmsProperty property)
Writes a property for a specified resource.
|
void |
writePropertyObjects(CmsResource res,
java.util.List<CmsProperty> properties)
Writes a list of properties for a specified resource.
|
void |
writePropertyObjects(java.lang.String resourcename,
java.util.List<CmsProperty> properties)
Writes a list of properties for a specified resource.
|
void |
writeResource(CmsResource resource)
Writes a resource.
|
void |
writeStaticExportPublishedResource(java.lang.String resourceName,
int linkType,
java.lang.String linkParameter,
long timestamp)
Writes a published resource entry.
|
java.lang.String |
writeUrlNameMapping(java.util.Iterator<java.lang.String> nameSeq,
CmsUUID structureId,
java.lang.String locale,
boolean replaceOnPublish)
Writes a new URL name mapping for a given resource.
|
java.lang.String |
writeUrlNameMapping(java.lang.String name,
CmsUUID structureId,
java.lang.String locale,
boolean replaceOnPublish)
Writes a new URL name mapping for a given resource.
|
void |
writeUser(CmsUser user)
Updates the user information.
|
protected CmsRequestContext m_context
protected CmsSecurityManager m_securityManager
public CmsObject(CmsSecurityManager securityManager, CmsRequestContext context)
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,
use CmsObject
.OpenCms.initCmsObject(String)
securityManager
- the security managercontext
- the request context that contains the user authenticationpublic void addRelationToResource(CmsResource resource, CmsResource target, java.lang.String type) throws CmsException
resource
- the source resourcetarget
- the target resourcetype
- the type of the relationCmsException
- if something goes wrongpublic void addRelationToResource(java.lang.String resourceName, java.lang.String targetPath, java.lang.String type) throws CmsException
resourceName
- the name of the source resourcetargetPath
- the path of the target resourcetype
- the type of the relationCmsException
- if something goes wrongpublic java.lang.String addSiteRoot(java.lang.String resourcename)
resourcename
- the resource nameCmsRequestContext.addSiteRoot(String)
public void addUserToGroup(java.lang.String username, java.lang.String groupname) throws CmsException
username
- the name of the user that is to be added to the groupgroupname
- the name of the groupCmsException
- if something goes wrongpublic void adjustLinks(java.util.List<java.lang.String> sourceFiles, java.lang.String targetParentFolder) throws CmsException
adjustLinks(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.sourceFiles
- the list of source filestargetParentFolder
- the folder into which the source files have been copiedCmsException
- if something goes wrongpublic void adjustLinks(java.util.Map<java.lang.String,java.lang.String> sourceTargetMap, java.lang.String targetParentFolder) throws CmsException
adjustLinks(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.sourceTargetMap
- a map with the source files as keys and the corresponding targets as valuestargetParentFolder
- the folder into which the source files have been copiedCmsException
- if something goes wrongpublic void adjustLinks(java.lang.String sourceFolder, java.lang.String targetFolder) throws CmsException
sourceFolder
- the source foldertargetFolder
- the target folderCmsException
- if something goes wrongpublic void chacc(java.lang.String resourceName, java.lang.String principalType, java.lang.String principalName, int allowedPermissions, int deniedPermissions, int flags) throws CmsException
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 entryCmsException
- if something goes wrongpublic void chacc(java.lang.String resourceName, java.lang.String principalType, java.lang.String principalName, java.lang.String permissionString) throws CmsException
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))*CmsException
- if something goes wrongpublic void changeLock(CmsResource resource) throws CmsException
This is the "steal lock" operation.
resource
- the resource to change the lockCmsException
- if something goes wrongpublic void changeLock(java.lang.String resourcename) throws CmsException
This is the "steal lock" operation.
resourcename
- the name of the resource to change the lock with complete pathCmsException
- if something goes wrongpublic java.util.List<CmsResource> changeResourcesInFolderWithProperty(java.lang.String resourcename, java.lang.String property, java.lang.String oldValue, java.lang.String newValue, boolean recursive) throws CmsException
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)CmsResource
's where the property value has been changedCmsException
- if operation was not successfulpublic void chflags(java.lang.String resourcename, int flags) throws CmsException
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.
resourcename
- the name of the resource to change the flags for (full current site relative path)flags
- the new flags for this resourceCmsException
- if something goes wrongpublic void chtype(java.lang.String resourcename, I_CmsResourceType type) throws CmsException
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.
resourcename
- the name of the resource to change the type for (full current site relative path)type
- the new resource type for this resourceCmsException
- if something goes wrong@Deprecated public void chtype(java.lang.String resourcename, int type) throws CmsException
chtype(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.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.
resourcename
- the name of the resource to change the type for (full current site relative path)type
- the new resource type for this resourceCmsException
- if something goes wrongpublic void copyResource(java.lang.String source, java.lang.String destination) throws CmsException, CmsIllegalArgumentException
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
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)CmsException
- if something goes wrongCmsIllegalArgumentException
- if the destination
argument is null or of length 0copyResource(String, String, CmsResource.CmsResourceCopyMode)
public void copyResource(java.lang.String source, java.lang.String destination, CmsResource.CmsResourceCopyMode siblingMode) throws CmsException, CmsIllegalArgumentException
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:
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 copyCmsException
- if something goes wrongCmsIllegalArgumentException
- if the destination
argument is null or of length 0public void copyResourceToProject(CmsResource resource) throws CmsException
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.
resource
- the resource to copy to the current projectCmsException
- if something goes wrongpublic void copyResourceToProject(java.lang.String resourcename) throws CmsException
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.
resourcename
- the name of the resource to copy to the current project (full current site relative path)CmsException
- if something goes wrongpublic int countLockedResources(CmsUUID id) throws CmsException
id
- the id of the projectCmsException
- if operation was not successfulpublic void cpacc(java.lang.String sourceName, java.lang.String destName) throws CmsException
Already existing access control entries of the destination resource are removed.
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 appliedCmsException
- if something goes wrongpublic CmsGroup createGroup(java.lang.String groupFqn, java.lang.String description, int flags, java.lang.String parent) throws CmsException
groupFqn
- the name of the new groupdescription
- the description of the new groupflags
- the flags for the new groupparent
- the parent group (or null
)CmsGroup
object representing the newly created groupCmsException
- if operation was not successfulpublic CmsProject createProject(java.lang.String name, java.lang.String description, java.lang.String groupname, java.lang.String managergroupname) throws CmsException
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 groupCmsException
- if something goes wrongpublic CmsProject createProject(java.lang.String name, java.lang.String description, java.lang.String groupname, java.lang.String managergroupname, CmsProject.CmsProjectType projecttype) throws CmsException
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)CmsException
- if operation was not successfulpublic CmsPropertyDefinition createPropertyDefinition(java.lang.String name) throws CmsException
Property definitions are valid for all resource types.
name
- the name of the property definition to createCmsException
- if something goes wrongpublic CmsResource createResource(java.lang.String sitePath, CmsResource resource, byte[] content, java.util.List<CmsProperty> properties) throws CmsException
sitePath
- the site path for the resourceresource
- the resource object to be importedcontent
- the content of the resourceproperties
- the properties of the resourceCmsException
- if something goes wrongpublic CmsResource createResource(java.lang.String resourcename, I_CmsResourceType type) throws CmsException, CmsIllegalArgumentException
resourcename
- the name of the resource to create (full current site relative path)type
- the type of the resource to createCmsException
- if something goes wrongCmsIllegalArgumentException
- if the given resourcename
is null or of length 0createResource(String, int, byte[], List)
public CmsResource createResource(java.lang.String resourcename, I_CmsResourceType type, byte[] content, java.util.List<CmsProperty> properties) throws CmsException, CmsIllegalArgumentException
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 resourceCmsException
- if something goes wrongCmsIllegalArgumentException
- if the resourcename
argument is null or of length 0@Deprecated public CmsResource createResource(java.lang.String resourcename, int type) throws CmsException, CmsIllegalArgumentException
createResource(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.resourcename
- the name of the resource to create (full current site relative path)type
- the type of the resource to createCmsException
- if something goes wrongCmsIllegalArgumentException
- if the given resourcename
is null or of length 0createResource(String, int, byte[], List)
@Deprecated public CmsResource createResource(java.lang.String resourcename, int type, byte[] content, java.util.List<CmsProperty> properties) throws CmsException, CmsIllegalArgumentException
createResource(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.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 resourceCmsException
- if something goes wrongCmsIllegalArgumentException
- if the resourcename
argument is null or of length 0public CmsResource createSibling(java.lang.String source, java.lang.String destination, java.util.List<CmsProperty> properties) throws CmsException
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 siblingCmsException
- if something goes wrongpublic CmsProject createTempfileProject() throws CmsException
CmsException
- if something goes wrongpublic CmsUser createUser(java.lang.String userFqn, java.lang.String password, java.lang.String description, java.util.Map<java.lang.String,java.lang.Object> additionalInfos) throws CmsException
userFqn
- the name for the new userpassword
- the password for the new userdescription
- the description for the new useradditionalInfos
- the additional infos for the userCmsException
- if something goes wrongpublic void deleteAllStaticExportPublishedResources(int linkType) throws CmsException
linkType
- the type of resource deleted (0= non-parameter, 1=parameter)CmsException
- if something goes wrongpublic void deleteGroup(CmsUUID groupId, CmsUUID replacementId) throws CmsException
groupId
- the id of the group to be deletedreplacementId
- the id of the group to be transfered, can be null
CmsException
- if operation was not successfulpublic void deleteGroup(java.lang.String group) throws CmsException
Only groups that contain no subgroups can be deleted.
group
- the name of the groupCmsException
- if operation was not successfulpublic void deleteHistoricalVersions(int versionsToKeep, int versionsDeleted, long timeDeleted, I_CmsReport report) throws CmsException
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 loggingCmsException
- if operation was not successfulpublic void deleteLogEntries(CmsLogFilter filter) throws CmsException
filter
- the filter to use for deleting the log entriesCmsException
- if something goes wrongCmsSecurityManager.deleteLogEntries(CmsRequestContext, CmsLogFilter)
,
getLogEntries(CmsLogFilter)
public void deleteProject(CmsUUID id) throws CmsException
All resources inside the project have to be be reset to their online state.
id
- the id of the project to deleteCmsException
- if operation was not successfulpublic void deletePropertyDefinition(java.lang.String name) throws CmsException
name
- the name of the property definition to deleteCmsException
- if something goes wrongpublic void deleteRelationsFromResource(CmsResource resource, CmsRelationFilter filter) throws CmsException
resource
- the resource to delete the relations fromfilter
- the filter to use for deleting the relationsCmsException
- if something goes wrongpublic void deleteRelationsFromResource(java.lang.String resourceName, CmsRelationFilter filter) throws CmsException
resourceName
- the resource to delete the relations fromfilter
- the filter to use for deleting the relationsCmsException
- if something goes wrongpublic void deleteResource(CmsResource res, CmsResource.CmsResourceDeleteMode deletePreserveSiblings) throws CmsException
The siblingMode
parameter controls how to handle siblings
during the delete operation.
Possible values for this parameter are:
res
- the resource to deletedeletePreserveSiblings
- indicates how to handle siblings of the deleted resourceCmsException
- if something goes wrongpublic void deleteResource(java.lang.String resourcename, CmsResource.CmsResourceDeleteMode siblingMode) throws CmsException
The siblingMode
parameter controls how to handle siblings
during the delete operation.
Possible values for this parameter are:
resourcename
- the name of the resource to delete (full current site relative path)siblingMode
- indicates how to handle siblings of the deleted resourceCmsException
- if something goes wrongpublic void deleteStaticExportPublishedResource(java.lang.String resourceName, int linkType, java.lang.String linkParameter) throws CmsException
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 resourceCmsException
- if something goes wrongpublic void deleteUser(CmsUUID userId) throws CmsException
userId
- the id of the user to be deletedCmsException
- if operation was not successfulpublic void deleteUser(CmsUUID userId, CmsUUID replacementId) throws CmsException
userId
- the id of the user to be deletedreplacementId
- the id of the user to be transfered, can be null
CmsException
- if operation was not successfulpublic void deleteUser(java.lang.String username) throws CmsException
username
- the name of the user to be deletedCmsException
- if operation was not successfulpublic boolean existsResource(CmsUUID structureId)
CmsResourceFilter.DEFAULT
filter.
A resource may be of type
or
CmsFile
.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
.
structureId
- the structure id of the resource to checktrue
if the resource is availablereadResource(CmsUUID)
,
existsResource(CmsUUID, CmsResourceFilter)
public boolean existsResource(CmsUUID structureId, CmsResourceFilter filter)
CmsResourceFilter.DEFAULT
filter.
A resource may be of type
or
CmsFile
.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 using CmsResourceFilter.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
.
structureId
- the structure id of the resource to checkfilter
- the resource filter to use while checkingtrue
if the resource is availablereadResource(CmsUUID)
,
readResource(CmsUUID, CmsResourceFilter)
public boolean existsResource(java.lang.String resourcename)
CmsResourceFilter.DEFAULT
filter.
A resource may be of type
or
CmsFile
.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
.
resourcename
- the name of the resource to check (full current site relative path)true
if the resource is availablereadResource(String)
,
existsResource(String, CmsResourceFilter)
public boolean existsResource(java.lang.String resourcename, CmsResourceFilter filter)
A resource may be of type
or
CmsFile
.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 using CmsResourceFilter.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
.
resourcename
- the name of the resource to check (full current site relative path)filter
- the resource filter to use while checkingtrue
if the resource is availablereadResource(String)
,
readResource(String, CmsResourceFilter)
public java.util.List<CmsAccessControlEntry> getAccessControlEntries(java.lang.String resourceName) throws CmsException
resourceName
- the name of the resourceCmsAccessControlEntry
objectsCmsException
- if something goes wrongpublic java.util.List<CmsAccessControlEntry> getAccessControlEntries(java.lang.String resourceName, boolean getInherited) throws CmsException
resourceName
- the name of the resourcegetInherited
- true
, if inherited access control entries should be returned, tooCmsAccessControlEntry
objects defining all permissions for the given resourceCmsException
- if something goes wrongpublic CmsAccessControlList getAccessControlList(java.lang.String resourceName) throws CmsException
resourceName
- the name of the resourceCmsException
- if something goes wrongpublic CmsAccessControlList getAccessControlList(java.lang.String resourceName, boolean inheritedOnly) throws CmsException
If inheritedOnly
is set, only inherited access control entries are returned.
resourceName
- the name of the resourceinheritedOnly
- if set, the non-inherited entries are skippedCmsException
- if something goes wrongpublic java.util.List<CmsAccessControlEntry> getAllAccessControlEntries() throws CmsException
CmsException
- if something goes wrongpublic java.util.List<CmsHistoryProject> getAllHistoricalProjects() throws CmsException
CmsHistoryProject
objects
with all projects from historyCmsException
- if operation was not successfulpublic java.util.List<java.lang.String> getAllUrlNames(CmsUUID id) throws CmsException
id
- the structure idCmsException
- if something goes wrongpublic java.util.List<CmsResource> getBlockingLockedResources(CmsResource resource) throws CmsException
resource
- the resourceCmsException
- if something goes wrong reading the resourcespublic java.util.List<CmsResource> getBlockingLockedResources(java.lang.String resourceName) throws CmsException
resourceName
- the resource site pathCmsException
- if something goes wrong reading the resourcespublic java.util.List<CmsGroup> getChildren(java.lang.String groupname, boolean includeSubChildren) throws CmsException
groupname
- the name of the groupincludeSubChildren
- if set also returns all sub-child groups of the given groupCmsGroup
objects or null
CmsException
- if operation was not successfulpublic java.lang.String getDetailName(CmsResource res, java.util.Locale locale, java.util.List<java.util.Locale> defaultLocales) throws CmsException
The detail view URI of a content element consists of its detail page URI and the detail name returned by this method.
res
- the resource for which the detail name should be retrievedlocale
- the locale for the detail namedefaultLocales
- the default locales for the detail nameCmsException
- if something goes wrongpublic java.util.List<CmsResource> getFilesInFolder(java.lang.String resourcename) throws CmsException
The result is filtered according to the rules of
the
filter.CmsResourceFilter.DEFAULT
resourcename
- the full current site relative path of the resource to return the child resources forCmsResource
objectsCmsException
- if something goes wronggetFilesInFolder(String, CmsResourceFilter)
public java.util.List<CmsResource> getFilesInFolder(java.lang.String resourcename, CmsResourceFilter filter) throws CmsException
With the
provided as parameter
you can control if you want to include deleted, invisible or
time-invalid resources in the result.CmsResourceFilter
resourcename
- the full path of the resource to return the child resources forfilter
- the resource filter to useCmsResource
objectsCmsException
- if something goes wrongpublic java.util.List<CmsGroup> getGroupsOfUser(java.lang.String username, boolean directGroupsOnly) throws CmsException
username
- the name of the userdirectGroupsOnly
- if set only the direct assigned groups will be returned, if not also indirect rolesCmsGroup
objectsCmsException
- if operation was not successfulpublic java.util.List<CmsGroup> getGroupsOfUser(java.lang.String username, boolean directGroupsOnly, boolean includeOtherOus) throws CmsException
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 unitsCmsGroup
objectsCmsException
- if operation was not successfulpublic java.util.List<CmsGroup> getGroupsOfUser(java.lang.String username, boolean directGroupsOnly, boolean includeOtherOus, java.lang.String remoteAddress) throws CmsException
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 unitsCmsGroup
objects filtered by the specified IP addressCmsException
- if operation was not successfulpublic CmsLocaleGroupService getLocaleGroupService()
public CmsLock getLock(CmsResource resource) throws CmsException
If the resource is waiting to be publish you might get a lock of type CmsLockType.PUBLISH
.
resource
- the resource to return the edition lock state forCmsException
- if something goes wrongpublic CmsLock getLock(java.lang.String resourcename) throws CmsException
If the resource is waiting to be publish you might get a lock of type CmsLockType.PUBLISH
.
resourcename
- the name if the resource to get the lock state for (full current site relative path)CmsException
- if something goes wrongpublic java.util.List<CmsResource> getLockedResources(CmsResource resource, CmsLockFilter filter) throws CmsException
resource
- the resource to checkfilter
- the lock filterCmsException
- if operation was not successfulpublic java.util.List<java.lang.String> getLockedResources(java.lang.String resourceName, CmsLockFilter filter) throws CmsException
resourceName
- the name of the resource to checkfilter
- the lock filterCmsException
- if operation was not successfulpublic java.util.List<CmsResource> getLockedResourcesWithCache(CmsResource resource, CmsLockFilter filter, java.util.Map<java.lang.String,CmsResource> cache) throws CmsException
resource
- the resource to checkfilter
- the lock filtercache
- the cache to use for resource lookupsCmsException
- if operation was not successfulpublic java.util.List<CmsLogEntry> getLogEntries(CmsLogFilter filter) throws CmsException
filter
- the filter to match the relationCmsException
- if something goes wrongCmsSecurityManager.getLogEntries(CmsRequestContext, CmsLogFilter)
,
deleteLogEntries(CmsLogFilter)
public java.lang.String getLostAndFoundName(java.lang.String resourcename) throws CmsException
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.
resourcename
- the name of the resource to get the "lost and found" name for (full current site relative path)CmsException
- if something goes wrongmoveToLostAndFound(String)
public CmsGroup getParent(java.lang.String groupname) throws CmsException
groupname
- the name of the groupnull
CmsException
- if operation was not successfulpublic CmsPermissionSet getPermissions(java.lang.String resourceName) throws CmsException
resourceName
- the name of the resourceCmsException
- if something goes wrongpublic CmsPermissionSet getPermissions(java.lang.String resourceName, java.lang.String userName) throws CmsException
resourceName
- the name of the resourceuserName
- the name of the userCmsException
- if something goes wrongpublic java.util.List<CmsRelation> getRelationsForResource(CmsResource resource, CmsRelationFilter filter) throws CmsException
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.
resource
- the resource to retrieve the relations forfilter
- the filter to match the relationCmsRelation
objects for the given resource matching the given filterCmsException
- if something goes wrongCmsSecurityManager.getRelationsForResource(CmsRequestContext, CmsResource, CmsRelationFilter)
public java.util.List<CmsRelation> getRelationsForResource(java.lang.String resourceName, CmsRelationFilter filter) throws CmsException
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.
resourceName
- the name of the resource to retrieve the relations forfilter
- the filter to match the relationCmsRelation
objects for the given resource matching the given filterCmsException
- if something goes wrongCmsSecurityManager.getRelationsForResource(CmsRequestContext, CmsResource, CmsRelationFilter)
public CmsRequestContext getRequestContext()
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.
public java.util.Set<CmsResource> getResourcesForPrincipal(CmsUUID principalId, CmsPermissionSet permissions, boolean includeAttr) throws CmsException
If the includeAttr
flag is set it returns also all resources associated to
a given principal through some of following attributes.
principalId
- the id of the principalpermissions
- a set of permissions to match, can be null
for all ACEsincludeAttr
- a flag to include resources associated by attributesCmsResource
objectsCmsException
- if something goes wrongpublic java.util.List<CmsResource> getResourcesInFolder(java.lang.String resourcename, CmsResourceFilter filter) throws CmsException
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.
resourcename
- the full current site relative path of the resource to return the child resources forfilter
- the resource filter to useCmsResource
sCmsException
- if something goes wrongpublic java.lang.String getSitePath(CmsResource resource)
The full root path of a resource is always available using
. From this name this method cuts
of the current site root using
CmsResource.getRootPath()
.CmsRequestContext.removeSiteRoot(String)
If the resource root path does not start with the current site root, it is left untouched.
resource
- the resource to get the adjusted site root path forCmsRequestContext.removeSiteRoot(String)
,
CmsRequestContext.getSitePath(CmsResource)
,
CmsResource.getRootPath()
public java.util.List<CmsResource> getSubFolders(java.lang.String resourcename) throws CmsException
The result is filtered according to the rules of
the
filter.CmsResourceFilter.DEFAULT
resourcename
- the full current site relative path of the resource to return the child resources for.CmsResource
objectsCmsException
- if something goes wronggetSubFolders(String, CmsResourceFilter)
public java.util.List<CmsResource> getSubFolders(java.lang.String resourcename, CmsResourceFilter filter) throws CmsException
With the
provided as parameter
you can control if you want to include deleted, invisible or
time-invalid resources in the result.CmsResourceFilter
resourcename
- the full current site relative path of the resource to return the child resources for.filter
- the resource filter to useCmsResource
sCmsException
- if something goes wrongpublic java.util.List<java.lang.String> getUrlNamesForAllLocales(CmsUUID id) throws CmsException
id
- the structure idCmsException
- if something goes wrongpublic java.util.List<CmsUser> getUsersOfGroup(java.lang.String groupname) throws CmsException
Users that are "indirectly" in the group are not returned in the result.
groupname
- the name of the group to get all users forCmsUser
objects in the groupCmsException
- if operation was not successfulpublic java.util.List<CmsUser> getUsersOfGroup(java.lang.String groupname, boolean includeOtherOus) throws CmsException
Users that are "indirectly" in the group are not returned in the result.
groupname
- the name of the group to get all users forincludeOtherOus
- if the result should include users of other ousCmsUser
objects in the groupCmsException
- if operation was not successfulpublic boolean hasPermissions(CmsResource resource, CmsPermissionSet requiredPermissions) throws CmsException
resource
- the resource to check the permissions forrequiredPermissions
- the set of permissions to check fortrue
if the required permissions are satisfiedCmsException
- if something goes wrongpublic boolean hasPermissions(CmsResource resource, CmsPermissionSet requiredPermissions, boolean checkLock, CmsResourceFilter filter) throws CmsException
resource
- the resource to check the permissions forrequiredPermissions
- the set of permissions to check forcheckLock
- if true
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,
if false
the lock is not checked at allfilter
- the resource filter to usetrue
if the required permissions are satisfiedCmsException
- if something goes wrongpublic void importAccessControlEntries(CmsResource resource, java.util.List<CmsAccessControlEntry> acEntries) throws CmsException
Already existing access control entries of this resource are removed before.
resource
- the resource to attach the control entries toacEntries
- a list of CmsAccessControlEntry
objectsCmsException
- if something goes wrongpublic void importRelation(java.lang.String resourceName, java.lang.String targetPath, java.lang.String relationType) throws CmsException
resourceName
- the name of the source resourcetargetPath
- the path of the target resourcerelationType
- the type of the relationCmsException
- if something goes wrongpublic CmsResource importResource(java.lang.String resourcename, CmsResource resource, byte[] content, java.util.List<CmsProperty> properties) throws CmsException
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.
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 resourceCmsException
- if something goes wrongmoveToLostAndFound(String)
public CmsUser importUser(java.lang.String id, java.lang.String name, java.lang.String password, java.lang.String firstname, java.lang.String lastname, java.lang.String email, int flags, long dateCreated, java.util.Map<java.lang.String,java.lang.Object> additionalInfos) throws CmsException
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 infosCmsException
- if something goes wrongpublic int incrementCounter(java.lang.String name) throws CmsException
name
- the name of the counterCmsException
- if something goes wrongpublic boolean isInsideCurrentProject(java.lang.String resourcename)
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.
resourcename
- the specified resource name (full current site relative path)true
, if the specified resource is inside the current projectpublic boolean isManagerOfProject()
true
, if the user has management access to the current projectpublic void lockResource(CmsResource resource) throws CmsException
This will be an exclusive, persistent lock that is removed only if the user unlocks it.
resource
- the resource to lockCmsException
- if something goes wrongpublic void lockResource(java.lang.String resourcename) throws CmsException
This will be an exclusive, persistent lock that is removed only if the user unlocks it.
resourcename
- the name of the resource to lock (full current site relative path)CmsException
- if something goes wrongpublic void lockResourceTemporary(CmsResource resource) throws CmsException
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.
resource
- the resource to lockCmsException
- if something goes wronglockResource(String)
public void lockResourceTemporary(java.lang.String resourcename) throws CmsException
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.
resourcename
- the name of the resource to lock (full current site relative path)CmsException
- if something goes wronglockResource(String)
public java.lang.String loginUser(java.lang.String username, java.lang.String password) throws CmsException
username
- the name of the userpassword
- the password of the userCmsException
- if the login was not successfulpublic java.lang.String loginUser(java.lang.String username, java.lang.String password, java.lang.String remoteAddress) throws CmsException
username
- the name of the userpassword
- the password of the userremoteAddress
- the ip addressCmsException
- if the login was not successfulpublic I_CmsPrincipal lookupPrincipal(CmsUUID principalId)
principalId
- the uuid of a user or grouppublic I_CmsPrincipal lookupPrincipal(java.lang.String principalName)
principalName
- the name of the user or grouppublic void moveResource(java.lang.String source, java.lang.String destination) throws CmsException
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.
source
- the name of the resource to move (full current site relative path)destination
- the destination resource name (full current site relative path)CmsException
- if something goes wrongrenameResource(String, String)
public java.lang.String moveToLostAndFound(java.lang.String resourcename) throws CmsException
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.
resourcename
- the name of the resource to move to "lost and found" (full current site relative path)CmsException
- if something goes wronggetLostAndFoundName(String)
public java.util.List<I_CmsHistoryResource> readAllAvailableVersions(CmsResource resource) throws CmsException
resource
- the resource for which to read the versionsCmsException
- if something goes wrongpublic java.util.List<I_CmsHistoryResource> readAllAvailableVersions(java.lang.String resourceName) throws CmsException
resourceName
- the name of the resource to be readI_CmsHistoryResource
objectsCmsException
- if operation was not successfulpublic java.util.List<CmsPropertyDefinition> readAllPropertyDefinitions() throws CmsException
CmsPropertyDefinition
objects (may be empty)CmsException
- if something goes wrongpublic CmsFolder readAncestor(java.lang.String resourcename, CmsResourceFilter filter) throws CmsException
If no folder matching the filter criteria is found, null is returned.
resourcename
- the name of the resource to start (full current site relative path)filter
- the resource filter to match while reading the ancestorsCmsException
- if something goes wrongpublic CmsFolder readAncestor(java.lang.String resourcename, int type) throws CmsException
If no folder with the requested resource type is found, null is returned.
resourcename
- the name of the resource to start (full current site relative path)type
- the resource type of the folder to matchCmsException
- if something goes wrongpublic java.lang.String readBestUrlName(CmsUUID id, java.util.Locale locale, java.util.List<java.util.Locale> defaultLocales) throws CmsException
If the structure id is not mapped to any name, null will be returned.
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 availableCmsException
- if something goes wrongpublic CmsResource readDefaultFile(CmsResource folderResource, CmsResourceFilter resourceFilter) throws CmsSecurityException
CmsPropertyDefinition.PROPERTY_DEFAULT_FILE
is checked, and
opencms-vfs.xml
configuration are iterated until a match is
found, and
null
is returned
folderResource
- the folderresourceFilter
- the resource filterCmsSecurityException
- if the user has no permissions to read the resulting filepublic CmsResource readDefaultFile(java.lang.String resourceNameOrID) throws CmsException, CmsSecurityException
If the given resource name or id identifies a file, then this file is returned.
Otherwise, in case of a folder:
CmsPropertyDefinition.PROPERTY_DEFAULT_FILE
is checked, and
opencms-vfs.xml
configuration are iterated until a match is
found, and
null
is returned
resourceNameOrID
- the name or id of the folder to read the default file forCmsException
- if something goes wrongCmsSecurityException
- if the user has no permissions to read the resulting filepublic CmsResource readDefaultFile(java.lang.String resourceNameOrID, CmsResourceFilter filter) throws CmsException, CmsSecurityException
If the given resource name or id identifies a file, then this file is returned.
Otherwise, in case of a folder:
CmsPropertyDefinition.PROPERTY_DEFAULT_FILE
is checked, and
opencms-vfs.xml
configuration are iterated until a match is
found, and
null
is returned
resourceNameOrID
- the name or id of the folder to read the default file for#filter
- the resource filter to use for reading the resourcesCmsException
- if something goes wrongCmsSecurityException
- if the user has no permissions to read the resulting filepublic java.util.List<I_CmsHistoryResource> readDeletedResources(java.lang.String resourcename, boolean readTree) throws CmsException
The result list may include resources with the same name of resources (with different id's).
Use in conjunction with the restoreDeletedResource(CmsUUID)
method.
resourcename
- the parent path to read the resources fromreadTree
- true
to read all sub resourcesI_CmsHistoryResource
objectsCmsException
- if something goes wrongreadResource(CmsUUID, int)
,
readResources(String, CmsResourceFilter, boolean)
public CmsFile readFile(CmsResource resource) throws CmsException
In case the input CmsResource
object already is a CmsFile
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
or
readResource(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.
resource
- the resource to readCmsException
- if the file resource could not be read for any reasonreadFile(String)
,
readFile(String, CmsResourceFilter)
public CmsFile readFile(java.lang.String resourcename) throws CmsException
CmsResourceFilter.DEFAULT
filter.
In case you do not need the file content,
use
instead.readResource(String)
resourcename
- the name of the resource to read (full current site relative path)CmsException
- if the file resource could not be read for any reasonreadFile(String, CmsResourceFilter)
,
readFile(CmsResource)
,
readResource(String)
public CmsFile readFile(java.lang.String resourcename, CmsResourceFilter filter) throws CmsException
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 using CmsResourceFilter.DEFAULT
will ignore the date release / date expired information of the resource.CmsResourceFilter.IGNORE_EXPIRATION
resourcename
- the name of the resource to read (full current site relative path)filter
- the resource filter to use while readingCmsException
- if the file resource could not be read for any reasonreadFile(String)
,
readFile(CmsResource)
,
readResource(String, CmsResourceFilter)
public CmsFolder readFolder(java.lang.String resourcename) throws CmsException
CmsResourceFilter.DEFAULT
filter.resourcename
- the name of the folder resource to read (full current site relative path)CmsException
- if the resource could not be read for any reasonreadResource(String, CmsResourceFilter)
,
readFolder(String, CmsResourceFilter)
public CmsFolder readFolder(java.lang.String resourcename, CmsResourceFilter filter) throws CmsException
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 using CmsResourceFilter.DEFAULT
will ignore the date release / date expired information of the resource.CmsResourceFilter.IGNORE_EXPIRATION
resourcename
- the name of the folder resource to read (full current site relative path)filter
- the resource filter to use while readingCmsException
- if the resource could not be read for any reasonreadResource(String, CmsResourceFilter)
public CmsGroup readGroup(CmsProject project)
project
- the project to read the group frompublic CmsGroup readGroup(CmsUUID groupId) throws CmsException
groupId
- the id of the group to be readCmsException
- if something goes wrongfor retrieving deleted groups
public CmsGroup readGroup(java.lang.String groupName) throws CmsException
groupName
- the name of the group to be readCmsException
- if something goes wrongpublic CmsHistoryPrincipal readHistoryPrincipal(CmsUUID principalId) throws CmsException
principalId
- the id of the principal to readCmsException
- if something goes wrong, ie. CmsDbEntryNotFoundException
readUser(CmsUUID)
,
readGroup(CmsUUID)
public CmsHistoryProject readHistoryProject(CmsUUID projectId) throws CmsException
projectId
- the project idCmsException
- if operation was not successfulpublic CmsHistoryProject readHistoryProject(int publishTag) throws CmsException
publishTag
- publish tag of the projectCmsException
- if operation was not successfulpublic java.util.List<CmsProperty> readHistoryPropertyObjects(I_CmsHistoryResource resource) throws CmsException
CmsProperty
objects that belong to the given historical resource version.resource
- the historical resource version to read the properties forCmsProperty
objectsCmsException
- if something goes wrongpublic CmsUUID readIdForUrlName(java.lang.String name) throws CmsException
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.
name
- the url nameCmsException
- if something goes wrongpublic CmsGroup readManagerGroup(CmsProject project)
project
- the projectpublic CmsUser readOwner(CmsProject project) throws CmsException
project
- the project to read the owner fromCmsException
- if something goes wrongpublic CmsResource readParentFolder(CmsUUID structureId) throws CmsException
structureId
- the child structure idCmsResource
CmsException
- if something goes wrongpublic java.util.List<CmsResource> readPath(CmsResource resource, CmsResourceFilter filter) throws CmsException
resource
- the resource to read the path forfilter
- a filter object (only "includeDeleted" information is used!)CmsResource
sCmsException
- if something goes wrongpublic java.util.List<CmsResource> readPath(java.lang.String path, CmsResourceFilter filter) throws CmsException
path
- the requested pathfilter
- a filter object (only "includeDeleted" information is used!)CmsResource
sCmsException
- if something goes wrongpublic CmsProject readProject(CmsUUID id) throws CmsException
id
- the id of the projectCmsException
- if operation was not successfulpublic CmsProject readProject(java.lang.String name) throws CmsException
name
- the name of the projectCmsException
- if operation was not successfulpublic java.util.List<java.lang.String> readProjectResources(CmsProject project) throws CmsException
project
- the project to get the project resources forString
objects that define the "view" of the given projectCmsException
- if something goes wrongpublic java.util.List<CmsResource> readProjectView(CmsUUID projectId, CmsResourceState state) throws CmsException
Possible values for the state
parameter are:
CmsResource.STATE_CHANGED
: Read all "changed" resources in the projectCmsResource.STATE_NEW
: Read all "new" resources in the projectCmsResource.STATE_DELETED
: Read all "deleted" resources in the projectCmsResource.STATE_KEEP
: Read all resources either "changed", "new" or "deleted" in the projectprojectId
- the id of the project to read the file resources forstate
- the resource state to matchCmsResource
s of a project that match a given criteria from the VFSCmsException
- if something goes wrongpublic CmsPropertyDefinition readPropertyDefinition(java.lang.String name) throws CmsException
If no property definition with the given name is found,
null
is returned.
name
- the name of the property definition to readCmsException
- a CmsDbEntryNotFoundException is thrown if the property definition does not existpublic CmsProperty readPropertyObject(CmsResource resource, java.lang.String property, boolean search) throws CmsException
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)
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 resourceCmsProperty.getNullProperty()
if the property was not foundCmsException
- if something goes wrongpublic CmsProperty readPropertyObject(CmsResource resource, java.lang.String property, boolean search, java.util.Locale locale) throws CmsException
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)
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.CmsProperty.getNullProperty()
if the property was not foundCmsException
- if something goes wrongpublic CmsProperty readPropertyObject(java.lang.String resourcePath, java.lang.String property, boolean search) throws CmsException
Returns
if the property is not found.CmsProperty.getNullProperty()
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 resourceCmsProperty.getNullProperty()
if the property was not foundCmsException
- if something goes wrongpublic CmsProperty readPropertyObject(java.lang.String resourcePath, java.lang.String property, boolean search, java.util.Locale locale) throws CmsException
Returns
if the property is not found.CmsProperty.getNullProperty()
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.CmsProperty.getNullProperty()
if the property was not foundCmsException
- if something goes wrongpublic java.util.List<CmsProperty> readPropertyObjects(CmsResource resource, boolean search) throws CmsException
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 is true
, 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).
resource
- the resource where the property is mapped tosearch
- if true
, the properties of all parent folders of the resource
are merged with the resource properties.CmsProperty
objectsCmsException
- if something goes wrongpublic java.util.List<CmsProperty> readPropertyObjects(java.lang.String resourcePath, boolean search) throws CmsException
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 is true
, 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).
resourcePath
- the name of resource where the property is mapped tosearch
- if true
, the properties of all parent folders of the resource
are merged with the resource properties.CmsProperty
objectsCmsException
- if something goes wrongpublic java.util.List<CmsPublishedResource> readPublishedResources(CmsUUID publishHistoryId) throws CmsException
publishHistoryId
- unique ID to identify each publish task in the publish historyCmsPublishedResource
objectsCmsException
- if something goes wrongpublic java.util.List<CmsRelation> readRelations(CmsRelationFilter filter) throws CmsException
filter
- the filter to match the relationCmsException
- if something goes wrongCmsSecurityManager.getRelationsForResource(CmsRequestContext, CmsResource, CmsRelationFilter)
,
getRelationsForResource(CmsResource, CmsRelationFilter)
public CmsResource readResource(CmsUUID structureID) throws CmsException
CmsResourceFilter.DEFAULT
filter.
A resource may be of type
or
CmsFile
. 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,
use CmsFolder
.readFile(CmsResource)
structureID
- the structure ID of the resource to readCmsException
- if the resource could not be read for any reasonreadFile(String)
,
readResource(CmsUUID, CmsResourceFilter)
public CmsResource readResource(CmsUUID structureID, CmsResourceFilter filter) throws CmsException
A resource may be of type
or
CmsFile
. 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,
use CmsFolder
.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 using CmsResourceFilter.DEFAULT
will ignore the date release / date expired information of the resource.CmsResourceFilter.IGNORE_EXPIRATION
structureID
- the structure ID of the resource to readfilter
- the resource filter to use while readingCmsException
- if the resource could not be read for any reasonreadFile(String, CmsResourceFilter)
,
readFolder(String, CmsResourceFilter)
public I_CmsHistoryResource readResource(CmsUUID structureID, int version) throws CmsException, CmsVfsResourceNotFoundException
A resource may be of type
or
CmsFile
. 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, use
CmsFolder
.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.
structureID
- the structure ID of the resource to readversion
- the version number you want to retrieveCmsException
- if the resource could not be read for any reasonCmsVfsResourceNotFoundException
- if the version does not existsrestoreResourceVersion(CmsUUID, int)
public CmsResource readResource(java.lang.String resourcename) throws CmsException
CmsResourceFilter.DEFAULT
filter.
A resource may be of type
or
CmsFile
. 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,
use CmsFolder
.readFile(CmsResource)
resourcename
- the name of the resource to read (full current site relative path)CmsException
- if the resource could not be read for any reasonreadFile(String)
,
readResource(String, CmsResourceFilter)
public CmsResource readResource(java.lang.String resourcename, CmsResourceFilter filter) throws CmsException
A resource may be of type
or
CmsFile
. 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,
use CmsFolder
.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 using CmsResourceFilter.DEFAULT
will ignore the date release / date expired information of the resource.CmsResourceFilter.IGNORE_EXPIRATION
resourcename
- the name of the resource to read (full current site relative path)filter
- the resource filter to use while readingCmsException
- if the resource could not be read for any reasonreadFile(String, CmsResourceFilter)
,
readFolder(String, CmsResourceFilter)
public java.util.List<CmsResource> readResources(CmsResource resource, CmsResourceFilter filter, boolean readTree) throws CmsException
readTree
parameter is true
.resource
- the parent resourcefilter
- the filterreadTree
- true
to read all sub resourcesCmsResource
objects matching the filter criteriaCmsException
- if something goes wrongpublic java.util.List<CmsResource> readResources(java.lang.String resourcename, CmsResourceFilter filter) throws CmsException
resourcename
- the parent path to read the resources fromfilter
- the filterCmsResource
objects matching the filter criteriaCmsException
- if something goes wrongreadResources(String, CmsResourceFilter, boolean)
public java.util.List<CmsResource> readResources(java.lang.String resourcename, CmsResourceFilter filter, boolean readTree) throws CmsException
readTree
parameter is true
.resourcename
- the parent path to read the resources fromfilter
- the filterreadTree
- true
to read all sub resourcesCmsResource
objects matching the filter criteriaCmsException
- if something goes wrongpublic java.util.List<CmsResource> readResourcesWithProperty(java.lang.String propertyDefinition) throws CmsException
Both individual and shared properties of a resource are checked.
Will use the CmsResourceFilter.ALL
resource filter.
propertyDefinition
- the name of the property to check forCmsResource
objects
that have a value set for the specified property.CmsException
- if something goes wrongpublic java.util.List<CmsResource> readResourcesWithProperty(java.lang.String path, java.lang.String propertyDefinition) throws CmsException
Both individual and shared properties of a resource are checked.
Will use the CmsResourceFilter.ALL
resource filter.
path
- the folder to get the resources with the property frompropertyDefinition
- the name of the property to check forCmsResource
objects
that have a value set for the specified property in the given path.CmsException
- if something goes wrongpublic java.util.List<CmsResource> readResourcesWithProperty(java.lang.String path, java.lang.String propertyDefinition, java.lang.String value) throws CmsException
Both individual and shared properties of a resource are checked.
If the value
parameter is null
, all resources having the
given property set are returned.
Will use the CmsResourceFilter.ALL
resource filter.
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 propertyCmsResource
objects
that have a value set for the specified property in the given path.CmsException
- if something goes wrongpublic java.util.List<CmsResource> readResourcesWithProperty(java.lang.String path, java.lang.String propertyDefinition, java.lang.String value, CmsResourceFilter filter) throws CmsException
Both individual and shared properties of a resource are checked.
If the value
parameter is null
, all resources having the
given property set are returned.
Will use the given resource filter.
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 setCmsResource
objects
that have a value set for the specified property in the given path.CmsException
- if something goes wrongpublic java.util.Set<I_CmsPrincipal> readResponsiblePrincipals(CmsResource resource) throws CmsException
resource
- the resource to get the responsible principals fromCmsException
- if something goes wrongpublic java.util.Set<CmsUser> readResponsibleUsers(CmsResource resource) throws CmsException
resource
- the resource to get the responsible users fromCmsException
- if something goes wrongpublic java.util.List<CmsResource> readSiblings(CmsResource resource, CmsResourceFilter filter) throws CmsException
resource
- the resourcefilter
- a resource filterCmsResource
s that
are siblings to the specified resource,
including the specified resource itself.CmsException
- if something goes wrongpublic java.util.List<CmsResource> readSiblings(java.lang.String resourcename, CmsResourceFilter filter) throws CmsException
resourcename
- the name of the specified resourcefilter
- a resource filterCmsResource
s that
are siblings to the specified resource,
including the specified resource itself.CmsException
- if something goes wrongpublic java.util.List<CmsResource> readSiblingsForResourceId(CmsUUID resourceId, CmsResourceFilter filter) throws CmsException
resourceId
- the resource id for which we want the siblingsfilter
- the resource filter used to read the resourcesCmsException
- if something goes wrongpublic java.lang.String readStaticExportPublishedResourceParameters(java.lang.String rfsName) throws CmsException
rfsName
- the rfs name of the resourceCmsException
- if something goes wrongpublic java.util.List<java.lang.String> readStaticExportResources(int parameterResources, long timestamp) throws CmsException
parameterResources
- flag for reading resources with parameters (1) or without (0)timestamp
- a time stamp for reading the data from the dbString
objectsCmsException
- if something goes wrongpublic java.util.List<CmsUrlNameMappingEntry> readUrlNameMappings(CmsUrlNameMappingFilter filter) throws CmsException
filter
- the filter to matchCmsException
- if something goes wrongpublic java.util.List<java.lang.String> readUrlNamesForAllLocales(CmsUUID structureId) throws CmsException
structureId
- the id of resource for which the URL names should be readCmsException
- if something goes wrongpublic CmsUser readUser(CmsUUID userId) throws CmsException
userId
- the id of the user to be readCmsException
- if something goes wrongfor retrieving data of deleted users
public CmsUser readUser(java.lang.String username) throws CmsException
username
- the name of the user to be readCmsException
- if something goes wrongpublic CmsUser readUser(java.lang.String username, java.lang.String password) throws CmsException
If the user/pwd pair is not valid a
is thrown.CmsException
username
- the name of the user to be returnedpassword
- the password of the user to be returnedCmsException
- if operation was not successfulpublic void removeResourceFromProject(java.lang.String resourcename) throws CmsException
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.
resourcename
- the name of the resource to remove to the current project (full current site relative path)CmsException
- if something goes wrongpublic void removeUserFromGroup(java.lang.String username, java.lang.String groupname) throws CmsException
username
- the name of the user that is to be removed from the groupgroupname
- the name of the groupCmsException
- if operation was not successfulpublic void renameResource(java.lang.String source, java.lang.String destination) throws CmsException
move
operation.source
- the name of the resource to rename (full current site relative path)destination
- the new resource name (full path)CmsException
- if something goes wrongmoveResource(String, String)
public void replaceResource(java.lang.String resourcename, I_CmsResourceType type, byte[] content, java.util.List<CmsProperty> properties) throws CmsException
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 resourceCmsException
- if something goes wrong@Deprecated public void replaceResource(java.lang.String resourcename, int type, byte[] content, java.util.List<CmsProperty> properties) throws CmsException
replaceResource(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.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 resourceCmsException
- if something goes wrongpublic void restoreDeletedResource(CmsUUID structureId) throws CmsException
These ids can be obtained from the readDeletedResources(String, boolean)
method.
structureId
- the structure id of the resource to restoreCmsException
- if something goes wrongpublic void restoreResourceVersion(CmsUUID structureId, int version) throws CmsException
structureId
- the structure id of the resource to restore from the archiveversion
- the desired version of the resource to be restoredCmsException
- if something goes wrongreadResource(CmsUUID, int)
public void rmacc(java.lang.String resourceName, java.lang.String principalType, java.lang.String principalName) throws CmsException
resourceName
- name of the resourceprincipalType
- the type of the principal (currently group or user)principalName
- the name of the principalCmsException
- if something goes wrongpublic void setDateExpired(CmsResource resource, long dateExpired, boolean recursive) throws CmsException
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 folderCmsException
- if something goes wrongpublic void setDateExpired(java.lang.String resourcename, long dateExpired, boolean recursive) throws CmsException
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 folderCmsException
- if something goes wrongpublic void setDateLastModified(java.lang.String resourcename, long dateLastModified, boolean recursive) throws CmsException
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 folderCmsException
- if something goes wrongpublic void setDateReleased(CmsResource resource, long dateReleased, boolean recursive) throws CmsException
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 folderCmsException
- if something goes wrongpublic void setDateReleased(java.lang.String resourcename, long dateReleased, boolean recursive) throws CmsException
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 folderCmsException
- if something goes wrongpublic void setParentGroup(java.lang.String groupName, java.lang.String parentGroupName) throws CmsException
groupName
- the name of the group that should be updatedparentGroupName
- the name of the parent group to set,
or null
if the parent
group should be deleted.CmsException
- if operation was not successfulpublic void setPassword(java.lang.String username, java.lang.String newPassword) throws CmsException
username
- the name of the usernewPassword
- the new passwordCmsException
- if operation was not successfulpublic void setPassword(java.lang.String username, java.lang.String oldPassword, java.lang.String newPassword) throws CmsException
username
- the name of the useroldPassword
- the old passwordnewPassword
- the new passwordCmsException
- if the user data could not be read from the databasepublic void undeleteResource(java.lang.String resourcename, boolean recursive) throws CmsException
Only resources that have already been published once can be undeleted, if a "new" resource is deleted it can not be undeleted.
resourcename
- the name of the resource to undeleterecursive
- if this operation is to be applied recursively to all resources in a folderCmsException
- if something goes wrongundoChanges(String, CmsResource.CmsResourceUndoMode)
public void undoChanges(java.lang.String resourcename, CmsResource.CmsResourceUndoMode mode) throws CmsException
resourcename
- the name of the resource to undo the changes formode
- the undo mode, one of the CmsResource.CmsResourceUndoMode
#UNDO_XXX
constantsCmsException
- if something goes wrongCmsResource.UNDO_CONTENT
,
CmsResource.UNDO_CONTENT_RECURSIVE
,
CmsResource.UNDO_MOVE_CONTENT
,
CmsResource.UNDO_MOVE_CONTENT_RECURSIVE
public void unlockProject(CmsUUID id) throws CmsException
id
- the id of the project to be unlockedCmsException
- if operation was not successfulpublic void unlockResource(CmsResource resource) throws CmsException
resource
- the resource to unlockCmsException
- if something goes wrongpublic void unlockResource(java.lang.String resourcename) throws CmsException
resourcename
- the name of the resource to unlock (full current site relative path)CmsException
- if something goes wrongpublic void updateLastLoginDate(CmsUser user) throws CmsRoleViolationException, CmsException
user
- the user to be updatedCmsRoleViolationException
- if the current user does not own the rule CmsRole.ACCOUNT_MANAGER
for the current projectCmsException
- if operation was not successfulpublic boolean userInGroup(java.lang.String username, java.lang.String groupname) throws CmsException
username
- the name of the user to testgroupname
- the name of the group to testtrue
, if the user is in the group; or false
otherwiseCmsException
- if operation was not successfulpublic void validatePassword(java.lang.String password) throws CmsSecurityException
I_CmsPasswordHandler
interface and configured in the opencms.properties file.If this method throws no exception the password is valid.
password
- the new password that has to be checkedCmsSecurityException
- if the password is not validpublic CmsFile writeFile(CmsFile resource) throws CmsException
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.
resource
- the resource to writeCmsException
- if something goes wrongpublic void writeGroup(CmsGroup group) throws CmsException
The group has to be a valid OpenCms group.
The group will be completely overridden by the given data.
group
- the group that should be writtenCmsException
- if operation was not successfulpublic void writeHistoryProject(int publishTag, long publishDate) throws CmsException
publishTag
- the correlative publish tagpublishDate
- the date of publishingCmsException
- if operation was not successfulpublic void writeProject(CmsProject project) throws CmsException
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.
project
- the project that should be writtenCmsException
- if operation was not successfulpublic void writeProjectLastModified(CmsResource resource, CmsProject project) throws CmsException
resource
- the resource which should be modifiedproject
- the project whose id should be written into the resource recordCmsException
- if something goes wrongpublic void writePropertyObject(java.lang.String resourcename, CmsProperty property) throws CmsException
resourcename
- the name of resource with complete pathproperty
- the property to writeCmsException
- if something goes wrongpublic void writePropertyObjects(CmsResource res, java.util.List<CmsProperty> properties) throws CmsException
Code calling this method has to ensure that the no properties
a, b
are contained in the specified list so that a.equals(b)
,
otherwise an exception is thrown.
res
- the resourceproperties
- the list of properties to writeCmsException
- if something goes wrongpublic void writePropertyObjects(java.lang.String resourcename, java.util.List<CmsProperty> properties) throws CmsException
Code calling this method has to ensure that the no properties
a, b
are contained in the specified list so that a.equals(b)
,
otherwise an exception is thrown.
resourcename
- the name of resource with complete pathproperties
- the list of properties to writeCmsException
- if something goes wrongpublic void writeResource(CmsResource resource) throws CmsException
resource
- the file to writeCmsException
- if resource type is set to folder, or
if the user has not the rights to write the file header.public void writeStaticExportPublishedResource(java.lang.String resourceName, int linkType, java.lang.String linkParameter, long timestamp) throws CmsException
This is done during static export.
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 dbCmsException
- if something goes wrongpublic java.lang.String writeUrlNameMapping(java.util.Iterator<java.lang.String> nameSeq, CmsUUID structureId, java.lang.String locale, boolean replaceOnPublish) throws CmsException
The first name from the given name sequence which is not already mapped to another resource will be used for the URL name mapping.
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 publishedCmsException
- if something goes wrongpublic java.lang.String writeUrlNameMapping(java.lang.String name, CmsUUID structureId, java.lang.String locale, boolean replaceOnPublish) throws CmsException
This method uses CmsNumberSuffixNameSequence
to generate a sequence of name candidates
from the given base name.
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 publishCmsException
- if something goes wrongpublic void writeUser(CmsUser user) throws CmsException
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.
user
- the user to be writtenCmsException
- if operation was not successful