org.opencms.file
Class CmsObject

java.lang.Object
  extended byorg.opencms.file.CmsObject

public final class CmsObject
extends java.lang.Object

This pivotal class provides all authorized access to the OpenCms VFS resources.

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 CmsRequestContext this CmsObject instance was created with.

From a JSP page running in OpenCms, use CmsJspBean.getCmsObject() to gain access to the current users CmsObject. Usually this is done with a CmsJspActionElement.

To generate a new instance of this class in your application, use OpenCms.initCmsObject(String). The argument String should be the name of the guest user, usually "Guest" and more formally obtained by CmsDefaultUsers.getUserGuest(). This will give you an initialized context with guest user permissions. Then use loginUser(String, String) 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.

Since:
6.0.0
Version:
$Revision: 1.146 $
Author:
Alexander Kandzior, Thomas Weckert, Carsten Weinholz, Andreas Zahner, Michael Moossen

Field Summary
protected  CmsRequestContext m_context
          The request context.
protected  CmsSecurityManager m_securityManager
          The security manager to access the cms.
 
Constructor Summary
CmsObject(CmsSecurityManager securityManager, CmsRequestContext context)
          Connects an OpenCms user context to a running database.
 
Method Summary
 void addUserToGroup(java.lang.String username, java.lang.String groupname)
          Adds a user to a group.
 CmsUser addWebUser(java.lang.String name, java.lang.String password, java.lang.String group, java.lang.String description, java.util.Map additionalInfos)
          Creates a new web user.
 void backupProject(int versionId, long publishDate)
          Creates a backup of the current project.
 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 changeLastModifiedProjectId(java.lang.String resourcename)
          Changes the project id of the resource to the current project, indicating that the resource was last modified in this project.
 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 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 changeUserType(CmsUUID userId, int userType)
          Changes the type of a user given its id.
 void changeUserType(java.lang.String username, int userType)
          Changes the type of a user given its name.
 void checkPublishPermissions(CmsPublishList publishList)
          Checks if the given base publish list can be published by the current user.
 void checkRole(CmsRole roles)
          Checks if the user of this OpenCms context is a member of at last one of the roles in the given role set.
 void chflags(java.lang.String resourcename, int flags)
          Changes the resource flags of a resource.
 void chtype(java.lang.String resourcename, int type)
          Changes the resource type of a resource.
 void copyResource(java.lang.String source, java.lang.String destination)
          Copies a resource.
 void copyResource(java.lang.String source, java.lang.String destination, int siblingMode)
          Copies a resource.
 void copyResourceToProject(java.lang.String resourcename)
          Copies a resource to the current project of the user.
 int countLockedResources(int id)
          Counts the locked resources in a project.
 int countLockedResources(java.lang.String foldername)
          Counts the locked resources within a folder.
 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 name, 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, int projecttype)
          Creates a new project.
 CmsPropertyDefinition createPropertyDefinition(java.lang.String name)
          Creates a property definition.
 CmsResource createResource(java.lang.String resourcename, int type)
          Creates a new resource of the given resource type with empty content and no properties.
 CmsResource createResource(java.lang.String resourcename, int type, byte[] content, java.util.List properties)
          Creates a new resource of the given resource type with the provided content and properties.
 void createSibling(java.lang.String source, java.lang.String destination, java.util.List properties)
          Creates a new sibling of the source resource.
 CmsProject createTempfileProject()
          Creates the project for the temporary workplace files.
 CmsUser createUser(java.lang.String name, java.lang.String password, java.lang.String description, java.util.Map additionalInfos)
          Creates a new user.
 void deleteAllStaticExportPublishedResources(int linkType)
          Deletes all published resource entries.
 void deleteBackups(long timestamp, int versions, I_CmsReport report)
          Deletes the versions from the backup tables that are older then the given timestamp and/or number of remaining versions.
 void deleteGroup(CmsUUID groupId, CmsUUID replacementId)
          Deletes a group, where all permissions, users and childs of the group are transfered to a replacement group.
 void deleteGroup(java.lang.String delgroup)
          Deletes a user group.
 void deleteProject(int id)
          Deletes a project.
 void deleteProperty(java.lang.String resourcename, java.lang.String key)
          Deprecated. use writePropertyObject(String, CmsProperty) instead.
 void deletePropertyDefinition(java.lang.String name)
          Deletes a property definition.
 void deleteResource(java.lang.String resourcename, int 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.
 void deleteWebUser(CmsUUID userId)
          Deletes a web user.
 boolean existsResource(java.lang.String resourcename)
          Checks the availability of a resource in the VFS, using the CmsResourceFilter.DEFAULT filter.
 boolean existsResource(java.lang.String resourcename, CmsResourceFilter filter)
          Checks the availability of a resource in the VFS, using the CmsResourceFilter.DEFAULT filter.
 java.util.List getAccessControlEntries(java.lang.String resourceName)
          Returns the list of access control entries of a resource given its name.
 java.util.List 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 getAllAccessibleProjects()
          Returns all projects which are owned by the current user or which are accessible for the group of the user.
 java.util.List getAllBackupProjects()
          Returns a list with all projects from history.
 java.util.List getAllManageableProjects()
          Returns all projects which are owned by the current user or which are manageable for the group of the user.
 int getBackupTagId()
          Returns the next version id for the published backup resources.
 java.util.List getChild(java.lang.String groupname)
          Returns all child groups of a group.
 java.util.List getChilds(java.lang.String groupname)
          Returns all child groups of a group.
 java.util.Map getConfigurations()
          Returns the configuration read fromr the opencms.properties file.
 java.util.List getDirectGroupsOfUser(java.lang.String username)
          Returns all groups to which a given user directly belongs.
 java.util.List getFilesInFolder(java.lang.String resourcename)
          Returns all file resources contained in a folder.
 java.util.List getFilesInFolder(java.lang.String resourcename, CmsResourceFilter filter)
          Returns all file resources contained in a folder.
 java.util.List getGroups()
          Returns all groups.
 java.util.List getGroupsOfUser(java.lang.String username)
          Returns all the groups the given user, directly or indirectly, belongs to.
 java.util.List getGroupsOfUser(java.lang.String username, java.lang.String remoteAddress)
          Returns the groups of a user filtered by the specified IP address.
 CmsLock getLock(CmsResource resource)
          Returns the lock state for a specified resource.
 CmsLock getLock(java.lang.String resourcename)
          Returns the lock state for a specified resource name.
 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.
 CmsPublishList getPublishList()
          Returns a publish list with all new/changed/deleted resources of the current (offline) project that actually get published.
 CmsPublishList getPublishList(CmsResource directPublishResource, boolean directPublishSiblings)
          Returns a publish list with all new/changed/deleted resources of the current (offline) project that actually get published for a direct publish of a single resource.
 CmsPublishList getPublishList(java.util.List directPublishResources, boolean directPublishSiblings)
          Returns a publish list with all new/changed/deleted resources of the current (offline) project that actually get published for a direct publish of a List of resources.
 CmsPublishList getPublishList(java.util.List directPublishResources, boolean directPublishSiblings, boolean publishSubResources)
          Returns a publish list with all new/changed/deleted resources of the current (offline) project that actually get published for a direct publish of a List of resources.
 CmsRequestContext getRequestContext()
          Returns the current users request context.
 java.util.List 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 getResourcesInFolder(java.lang.String resourcename, CmsResourceFilter filter)
          Returns all child resources of a resource, that is the resources contained in a folder.
 java.util.List getResourcesInTimeRange(java.lang.String folder, long starttime, long endtime)
          Returns a list with all sub resources of the given parent folder (and all of it's subfolders) that have been modified in the given time range.
 java.lang.String getSitePath(CmsResource resource)
          Adjusts the absolute resource root path for the current site.
 java.util.List getSubFolders(java.lang.String resourcename)
          Returns all folder resources contained in a folder.
 java.util.List getSubFolders(java.lang.String resourcename, CmsResourceFilter filter)
          Returns all folder resources contained in a folder.
 CmsTaskService getTaskService()
          Returns the current session info manager object.
 java.util.List getUsers()
          Returns all users.
 java.util.List getUsers(int type)
          Returns all users of the given type.
 java.util.List getUsersOfGroup(java.lang.String groupname)
          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.
 boolean hasPublishPermissions(java.lang.String resourcename)
          Checks if the given resource or the current project can be published by the current user using his current OpenCms context.
 boolean hasRole(CmsRole roles)
          Checks if the user of the current OpenCms context is a member of at last one of the roles in the given role set.
 void importAccessControlEntries(CmsResource resource, java.util.List acEntries)
          Writes a list of access control entries as new access control entries of a given resource.
 CmsResource importResource(java.lang.String resourcename, CmsResource resource, byte[] content, java.util.List 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 description, java.lang.String firstname, java.lang.String lastname, java.lang.String email, java.lang.String address, int flags, int type, java.util.Map additionalInfos)
          Creates a new user by import.
 boolean isAdmin()
          Deprecated. use hasRole(CmsRole) or checkRole(CmsRole) instead
 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(java.lang.String resourcename)
          Locks a resource.
 void lockResource(java.lang.String resourcename, int mode)
          Locks a resource.
 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.
 java.lang.String loginUser(java.lang.String username, java.lang.String password, java.lang.String remoteAddress, int type)
          Logs a user with a given type and a given ip address into the Cms, if the password is correct.
 java.lang.String loginWebUser(java.lang.String username, java.lang.String password)
          Logs a web user 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.
 CmsUUID publishProject()
          Publishes the current project, printing messages to a shell report.
 CmsUUID publishProject(I_CmsReport report)
          Publishes the current project.
 CmsUUID publishProject(I_CmsReport report, CmsPublishList publishList)
          Publishes the resources of a specified publish list.
 CmsUUID publishProject(I_CmsReport report, CmsResource directPublishResource, boolean directPublishSiblings)
          Direct publishes a specified resource.
 CmsUUID publishResource(java.lang.String resourcename)
          Publishes a single resource, printing messages to a shell report.
 CmsUUID publishResource(java.lang.String resourcename, boolean publishSiblings, I_CmsReport report)
          Publishes a single resource.
 java.util.List readAllBackupFileHeaders(java.lang.String filename)
          Reads all file headers of a file.
 java.util.List 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.
 CmsBackupResource readBackupFile(java.lang.String filename, int tagId)
          Returns a file from the history.
 CmsBackupProject readBackupProject(int tagId)
          Returns a backup project.
 java.util.List readBackupPropertyObjects(CmsBackupResource resource)
          Reads the list of CmsProperty objects that belong the the given backup resource.
 CmsFile readFile(java.lang.String resourcename)
          Reads a file resource (including it's binary content) from the VFS, using the CmsResourceFilter.DEFAULT 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.
 CmsResource readFileHeader(java.lang.String resourcename)
          Deprecated. use readResource(String, CmsResourceFilter) instead.
 CmsFolder readFolder(java.lang.String resourcename)
          Reads a folder resource from the VFS, using the CmsResourceFilter.DEFAULT 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.
 CmsGroup readManagerGroup(CmsProject project)
          Returns the project manager group of a project.
 CmsUser readOwner(CmsProject project)
          Reads the owner of a project.
 java.util.List readPath(java.lang.String path, CmsResourceFilter filter)
          Builds a list of resources for a given path.
 CmsProject readProject(int id)
          Reads the project with the given id.
 CmsProject readProject(java.lang.String name)
          Reads the project with the given name.
 java.util.List readProjectResources(CmsProject project)
          Returns the list of all resource names that define the "view" of the given project.
 java.util.List readProjectView(int projectId, int state)
          Reads all resources of a project that match a given state from the VFS.
 java.util.Map readProperties(java.lang.String resourcePath)
          Deprecated. use readPropertyObjects(String, boolean) instead.
 java.util.Map readProperties(java.lang.String resourcePath, boolean search)
          Deprecated. use readPropertyObjects(String, boolean) instead.
 java.lang.String readProperty(java.lang.String resourcePath, java.lang.String property)
          Deprecated. use readPropertyObject(String, String, boolean) instead.
 java.lang.String readProperty(java.lang.String resourcePath, java.lang.String property, boolean search)
          Deprecated. use readPropertyObject(String, String, boolean) instead.
 java.lang.String readProperty(java.lang.String resourcePath, java.lang.String property, boolean search, java.lang.String propertyDefault)
          Deprecated. use readPropertyObject(String, String, boolean) instead.
 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(java.lang.String resourcePath, java.lang.String property, boolean search)
          Reads a property object from a resource specified by a property name.
 java.util.List readPropertyObjects(CmsResource resource, boolean search)
          Reads all property objects from a resource.
 java.util.List readPropertyObjects(java.lang.String resourcePath, boolean search)
          Reads all property objects from a resource.
 java.util.List readPublishedResources(CmsUUID publishHistoryId)
          Reads the resources that were published in a publish task for a given publish history ID.
 CmsResource readResource(java.lang.String resourcename)
          Reads a resource from the VFS, using the CmsResourceFilter.DEFAULT filter.
 CmsResource readResource(java.lang.String resourcename, CmsResourceFilter filter)
          Reads a resource from the VFS, using the specified resource filter.
 java.util.List 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 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 readResourcesWithProperty(java.lang.String propertyDefinition)
          Reads all resources that have a value set for the specified property.
 java.util.List 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 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.Set readResponsiblePrincipals(CmsResource resource)
          Returns a set of principals that are responsible for a specific resource.
 java.util.Set readResponsibleUsers(CmsResource resource)
          Returns a set of users that are responsible for a specific resource.
 java.util.List 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.lang.String readStaticExportPublishedResourceParameters(java.lang.String rfsName)
          Returns the parameters of a resource in the list of all published template resources.
 java.util.List readStaticExportResources(int parameterResources, long timestamp)
          Returns a list of all template resources which must be processed during a static export.
 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, int type)
          Returns a user given its name and type.
 CmsUser readUser(java.lang.String username, java.lang.String password)
          Returns a user, if the password is correct.
 CmsUser readWebUser(java.lang.String username)
          Returns a webuser.
 CmsUser readWebUser(java.lang.String username, java.lang.String password)
          Returns a web user if the password for the user 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, int type, byte[] content, java.util.List properties)
          Replaces the content, type and properties of a resource.
 void restoreResourceBackup(java.lang.String resourcename, int tagId)
          Restores a file in the current project with a version from the backup archive.
 void rmacc(java.lang.String resourceName, java.lang.String principalType, java.lang.String principalName)
          Removes an access control entry of a griven principal from a given 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" timestamp 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 touch(java.lang.String resourcename, long dateLastModified, long dateReleased, long dateExpired, boolean recursive)
          Deprecated. use setDateLastModified(String, long, boolean), setDateReleased(String, long, boolean) or setDateExpired(String, long, boolean) instead
 void undeleteResource(java.lang.String resourcename)
          Undeletes a resource (this is the same operation as "undo changes").
 void undoChanges(java.lang.String resourcename, boolean recursive)
          Undos all changes to a resource by restoring the version from the online project to the current offline project.
 void unlockProject(int id)
          Unlocks all resources of a project.
 void unlockResource(java.lang.String resourcename)
          Unlocks a resource.
 boolean userInGroup(java.lang.String username, java.lang.String groupname)
          Tests if a user is member of the given group.
 java.util.Map validateHtmlLinks(CmsPublishList publishList, I_CmsReport report)
          Validates the HTML links in the unpublished files of the specified publish list, if a file resource type implements the interface I_CmsXmlDocumentLinkValidatable.
 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 I_CmsPasswordHandler interface and configured in the opencms.properties file.
 CmsFile writeFile(CmsFile resource)
          Writes a resource to the OpenCms VFS, including it's content.
 void writeFileHeader(CmsFile file)
          Writes a file-header.
 void writeGroup(CmsGroup group)
          Writes an already existing group.
 void writeProject(CmsProject project)
          Writes an already existing project.
 void writeProperties(java.lang.String resourceName, java.util.Map properties)
          Deprecated. use writePropertyObjects(String, List) instead.
 void writeProperties(java.lang.String name, java.util.Map properties, boolean addDefinition)
          Deprecated. use writePropertyObjects(String, List) instead.
 void writeProperty(java.lang.String resourceName, java.lang.String key, java.lang.String value)
          Deprecated. use writePropertyObject(String, CmsProperty) instead.
 void writeProperty(java.lang.String resourcename, java.lang.String key, java.lang.String value, boolean addDefinition)
          Deprecated. use writePropertyObject(String, CmsProperty) instead.
 void writePropertyObject(java.lang.String resourcename, CmsProperty property)
          Writes a property for a specified resource.
 void writePropertyObjects(java.lang.String resourcename, java.util.List properties)
          Writes a list of properties for a specified resource.
 void writeStaticExportPublishedResource(java.lang.String resourceName, int linkType, java.lang.String linkParameter, long timestamp)
          Writes a published resource entry.
 void writeUser(CmsUser user)
          Updates the user information.
 void writeWebUser(CmsUser user)
          Updates the user information of a web user.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_context

protected CmsRequestContext m_context
The request context.


m_securityManager

protected CmsSecurityManager m_securityManager
The security manager to access the cms.

Constructor Detail

CmsObject

public CmsObject(CmsSecurityManager securityManager,
                 CmsRequestContext context)
Connects an OpenCms user context to a running database.

Please note: This constructor is internal to OpenCms and not for public use. If you want to create a new instance of a CmsObject in your application, use OpenCms.initCmsObject(String).

Parameters:
securityManager - the security manager
context - the request context that contains the user authentification
Method Detail

addUserToGroup

public void addUserToGroup(java.lang.String username,
                           java.lang.String groupname)
                    throws CmsException
Adds a user to a group.

Parameters:
username - the name of the user that is to be added to the group
groupname - the name of the group
Throws:
CmsException - if something goes wrong

addWebUser

public CmsUser addWebUser(java.lang.String name,
                          java.lang.String password,
                          java.lang.String group,
                          java.lang.String description,
                          java.util.Map additionalInfos)
                   throws CmsException
Creates a new web user.

A web user has no access to the workplace but is able to access personalized functions controlled by the OpenCms.
Moreover, a web user can be created by any user, the intention being that a "Guest" user can create a personalized account for himself.

Parameters:
name - the name for the new web user
password - the password for the user
group - the default groupname for the user
description - the description for the user
additionalInfos - a Map with additional infos for the user
Returns:
the newly created user
Throws:
CmsException - if something goes wrong

backupProject

public void backupProject(int versionId,
                          long publishDate)
                   throws CmsException
Creates a backup of the current project.

Parameters:
versionId - the version of the backup
publishDate - the date of publishing
Throws:
CmsException - if operation was not succesful

chacc

public void chacc(java.lang.String resourceName,
                  java.lang.String principalType,
                  java.lang.String principalName,
                  int allowedPermissions,
                  int deniedPermissions,
                  int flags)
           throws CmsException
Changes the access control for a given resource and a given principal(user/group).

Parameters:
resourceName - name of the resource
principalType - the type of the principal (currently group or user):
principalName - name of the principal
allowedPermissions - bitset of allowed permissions
deniedPermissions - bitset of denied permissions
flags - additional flags of the access control entry
Throws:
CmsException - if something goes wrong

chacc

public void chacc(java.lang.String resourceName,
                  java.lang.String principalType,
                  java.lang.String principalName,
                  java.lang.String permissionString)
           throws CmsException
Changes the access control for a given resource and a given principal(user/group).

Parameters:
resourceName - name of the resource
principalType - the type of the principal (group or user):
principalName - name of the principal
permissionString - the permissions in the format ((+|-)(r|w|v|c|i|o))*
Throws:
CmsException - if something goes wrong

changeLastModifiedProjectId

public void changeLastModifiedProjectId(java.lang.String resourcename)
                                 throws CmsException
Changes the project id of the resource to the current project, indicating that the resource was last modified in this project.

This information is used while publishing. Only resources inside the project folders that are new/modified/changed and that "belong" to the project (i.e. have the id of the project set) are published with the project.

Parameters:
resourcename - the name of the resource to change the project id for (full path)
Throws:
CmsException - if something goes wrong

changeLock

public void changeLock(java.lang.String resourcename)
                throws CmsException
Changes the lock of a resource to the current user, that is "steals" the lock from another user.

This is the "steal lock" operation.

Parameters:
resourcename - the name of the resource to change the lock with complete path
Throws:
CmsException - if something goes wrong

changeResourcesInFolderWithProperty

public java.util.List changeResourcesInFolderWithProperty(java.lang.String resourcename,
                                                          java.lang.String property,
                                                          java.lang.String oldValue,
                                                          java.lang.String newValue,
                                                          boolean recursive)
                                                   throws CmsException
Returns a list with all sub resources of a given folder that have set the given property, matching the current property's value with the given old value and replacing it by a given new value.

Parameters:
resourcename - the name of the resource to change the property value
property - the name of the property to change the value
oldValue - the old value of the property, can be a regular expression
newValue - the new value of the property
recursive - if true, change recursively all property values on sub-resources (only for folders)
Returns:
a list with the CmsResource's where the property value has been changed
Throws:
CmsException - if operation was not successful

changeUserType

public void changeUserType(CmsUUID userId,
                           int userType)
                    throws CmsException
Changes the type of a user given its id.

Parameters:
userId - The id of the user to change
userType - The new type of the user
Throws:
CmsException - if something goes wrong

changeUserType

public void changeUserType(java.lang.String username,
                           int userType)
                    throws CmsException
Changes the type of a user given its name.

Parameters:
username - The name of the user to change
userType - The new type of the user
Throws:
CmsException - if something goes wrong

checkPublishPermissions

public void checkPublishPermissions(CmsPublishList publishList)
                             throws CmsException
Checks if the given base publish list can be published by the current user.

Parameters:
publishList - the base publish list to check
Throws:
CmsException - in case the publish permissions are not granted

checkRole

public void checkRole(CmsRole roles)
               throws CmsRoleViolationException
Checks if the user of this OpenCms context is a member of at last one of the roles in the given role set.

Parameters:
roles - the roles to check
Throws:
CmsRoleViolationException - if the user does not have the required role permissions

chflags

public void chflags(java.lang.String resourcename,
                    int flags)
             throws CmsException
Changes the resource flags of a resource.

The resource flags are used to indicate various "special" conditions for a resource. Most notably, the "internal only" setting which signals that a resource can not be directly requested with it's URL.

Parameters:
resourcename - the name of the resource to change the flags for (full path)
flags - the new flags for this resource
Throws:
CmsException - if something goes wrong

chtype

public void chtype(java.lang.String resourcename,
                   int type)
            throws CmsException
Changes the resource type of a resource.

OpenCms handles resources according to the resource type, not the file suffix. This is e.g. why a JSP in OpenCms can have the suffix ".html" instead of ".jsp" only. Changing the resource type makes sense e.g. if you want to make a plain text file a JSP resource, or a binary file an image, etc.

Parameters:
resourcename - the name of the resource to change the type for (full path)
type - the new resource type for this resource
Throws:
CmsException - if something goes wrong

copyResource

public void copyResource(java.lang.String source,
                         java.lang.String destination)
                  throws CmsException,
                         CmsIllegalArgumentException
Copies a resource.

The copied resource will always be locked to the current user after the copy operation.

Siblings will be treated according to the CmsResource.COPY_PRESERVE_SIBLING mode.

Parameters:
source - the name of the resource to copy (full path)
destination - the name of the copy destination (full path)
Throws:
CmsException - if something goes wrong
CmsIllegalArgumentException - if the destination argument is null or of length 0
See Also:
copyResource(String, String, int)

copyResource

public void copyResource(java.lang.String source,
                         java.lang.String destination,
                         int siblingMode)
                  throws CmsException,
                         CmsIllegalArgumentException
Copies a resource.

The copied resource will always be locked to the current user after the copy operation.

The siblingMode parameter controls how to handle siblings during the copy operation.
Possible values for this parameter are:

Parameters:
source - the name of the resource to copy (full path)
destination - the name of the copy destination (full path)
siblingMode - indicates how to handle siblings during copy
Throws:
CmsException - if something goes wrong
CmsIllegalArgumentException - if the destination argument is null or of length 0

copyResourceToProject

public void copyResourceToProject(java.lang.String resourcename)
                           throws CmsException
Copies a resource to the current project of the user.

This is used to extend the current users project with the specified resource, in case that the resource is not yet part of the project. The resource is not really copied like in a regular copy operation, it is in fact only "enabled" in the current users project.

Parameters:
resourcename - the name of the resource to copy to the current project (full path)
Throws:
CmsException - if something goes wrong

countLockedResources

public int countLockedResources(int id)
                         throws CmsException
Counts the locked resources in a project.

Parameters:
id - the id of the project
Returns:
the number of locked resources in this project
Throws:
CmsException - if operation was not successful

countLockedResources

public int countLockedResources(java.lang.String foldername)
                         throws CmsException
Counts the locked resources within a folder.

Parameters:
foldername - the name of the folder
Returns:
the number of locked resources in this folder
Throws:
CmsException - if operation was not successful

cpacc

public void cpacc(java.lang.String sourceName,
                  java.lang.String destName)
           throws CmsException
Copies access control entries of a given resource to another resource.

Already existing access control entries of the destination resource are removed.

Parameters:
sourceName - the name of the resource of which the access control entries are copied
destName - the name of the resource to which the access control entries are applied
Throws:
CmsException - if something goes wrong

createGroup

public CmsGroup createGroup(java.lang.String name,
                            java.lang.String description,
                            int flags,
                            java.lang.String parent)
                     throws CmsException
Creates a new user group.

Parameters:
name - the name of the new group
description - the description of the new group
flags - the flags for the new group
parent - the parent group (or null)
Returns:
a CmsGroup object representing the newly created group
Throws:
CmsException - if operation was not successful

createProject

public CmsProject createProject(java.lang.String name,
                                java.lang.String description,
                                java.lang.String groupname,
                                java.lang.String managergroupname)
                         throws CmsException
Creates a new project.

Parameters:
name - the name of the project to create
description - the description for the new project
groupname - the name of the project user group
managergroupname - the name of the project manager group
Returns:
the created project
Throws:
CmsException - if something goes wrong

createProject

public CmsProject createProject(java.lang.String name,
                                java.lang.String description,
                                java.lang.String groupname,
                                java.lang.String managergroupname,
                                int projecttype)
                         throws CmsException
Creates a new project.

Parameters:
name - the name of the project to create
description - the description for the new project
groupname - the name of the project user group
managergroupname - the name of the project manager group
projecttype - the type of the project (normal or temporary)
Returns:
the created project
Throws:
CmsException - if operation was not successful

createPropertyDefinition

public CmsPropertyDefinition createPropertyDefinition(java.lang.String name)
                                               throws CmsException
Creates a property definition.

Property definitions are valid for all resource types.

Parameters:
name - the name of the property definition to create
Returns:
the created property definition
Throws:
CmsException - if something goes wrong

createResource

public CmsResource createResource(java.lang.String resourcename,
                                  int type)
                           throws CmsException,
                                  CmsIllegalArgumentException
Creates a new resource of the given resource type with empty content and no properties.

Parameters:
resourcename - the name of the resource to create (full path)
type - the type of the resource to create
Returns:
the created resource
Throws:
CmsException - if something goes wrong
CmsIllegalArgumentException - if the given resourcename is null or of length 0
See Also:
createResource(String, int, byte[], List)

createResource

public CmsResource createResource(java.lang.String resourcename,
                                  int type,
                                  byte[] content,
                                  java.util.List properties)
                           throws CmsException,
                                  CmsIllegalArgumentException
Creates a new resource of the given resource type with the provided content and properties.

Parameters:
resourcename - the name of the resource to create (full path)
type - the type of the resource to create
content - the contents for the new resource
properties - the properties for the new resource
Returns:
the created resource
Throws:
CmsException - if something goes wrong
CmsIllegalArgumentException - if the resourcename argument is null or of length 0

createSibling

public void createSibling(java.lang.String source,
                          java.lang.String destination,
                          java.util.List properties)
                   throws CmsException
Creates a new sibling of the source resource.

Parameters:
source - the name of the resource to create a sibling for with complete path
destination - the name of the sibling to create with complete path
properties - the individual properties for the new sibling
Throws:
CmsException - if something goes wrong

createTempfileProject

public CmsProject createTempfileProject()
                                 throws CmsException
Creates the project for the temporary workplace files.

Returns:
the created project for the temporary workplace files
Throws:
CmsException - if something goes wrong

createUser

public CmsUser createUser(java.lang.String name,
                          java.lang.String password,
                          java.lang.String description,
                          java.util.Map additionalInfos)
                   throws CmsException
Creates a new user.

Parameters:
name - the name for the new user
password - the password for the new user
description - the description for the new user
additionalInfos - the additional infos for the user
Returns:
the created user
Throws:
CmsException - if something goes wrong

deleteAllStaticExportPublishedResources

public void deleteAllStaticExportPublishedResources(int linkType)
                                             throws CmsException
Deletes all published resource entries.

Parameters:
linkType - the type of resource deleted (0= non-paramter, 1=parameter)
Throws:
CmsException - if something goes wrong

deleteBackups

public void deleteBackups(long timestamp,
                          int versions,
                          I_CmsReport report)
                   throws CmsException
Deletes the versions from the backup tables that are older then the given timestamp and/or number of remaining versions.

The number of verions always wins, i.e. if the given timestamp would delete more versions than given in the versions parameter, the timestamp will be ignored.

Deletion will delete file header, content and properties.

Parameters:
timestamp - timestamp which defines the date after which backup resources must be deleted
versions - the number of versions per file which should kept in the system
report - the report for output logging
Throws:
CmsException - if something goes wrong

deleteGroup

public void deleteGroup(CmsUUID groupId,
                        CmsUUID replacementId)
                 throws CmsException
Deletes a group, where all permissions, users and childs of the group are transfered to a replacement group.

Parameters:
groupId - the id of the group to be deleted
replacementId - the id of the group to be transfered, can be null
Throws:
CmsException - if operation was not successful

deleteGroup

public void deleteGroup(java.lang.String delgroup)
                 throws CmsException
Deletes a user group.

Only groups that contain no subgroups can be deleted.

Parameters:
delgroup - the name of the group
Throws:
CmsException - if operation was not successful

deleteProject

public void deleteProject(int id)
                   throws CmsException
Deletes a project.

All resources inside the project have to be be reset to their online state.

Parameters:
id - the id of the project to delete
Throws:
CmsException - if operation was not successful

deleteProperty

public void deleteProperty(java.lang.String resourcename,
                           java.lang.String key)
                    throws CmsException
Deprecated. use writePropertyObject(String, CmsProperty) instead.

Deletes a property for a file or folder.

Parameters:
resourcename - the name of a resource for which the property should be deleted
key - the name of the property
Throws:
CmsException - if something goes wrong

deletePropertyDefinition

public void deletePropertyDefinition(java.lang.String name)
                              throws CmsException
Deletes a property definition.

Parameters:
name - the name of the property definition to delete
Throws:
CmsException - if something goes wrong

deleteResource

public void deleteResource(java.lang.String resourcename,
                           int siblingMode)
                    throws CmsException
Deletes a resource given its name.

The siblingMode parameter controls how to handle siblings during the delete operation.
Possible values for this parameter are:

Parameters:
resourcename - the name of the resource to delete (full path)
siblingMode - indicates how to handle siblings of the deleted resource
Throws:
CmsException - if something goes wrong

deleteStaticExportPublishedResource

public void deleteStaticExportPublishedResource(java.lang.String resourceName,
                                                int linkType,
                                                java.lang.String linkParameter)
                                         throws CmsException
Deletes a published resource entry.

Parameters:
resourceName - The name of the resource to be deleted in the static export
linkType - the type of resource deleted (0= non-paramter, 1=parameter)
linkParameter - the parameters of the resource
Throws:
CmsException - if something goes wrong

deleteUser

public void deleteUser(CmsUUID userId)
                throws CmsException
Deletes a user.

Parameters:
userId - the id of the user to be deleted
Throws:
CmsException - if operation was not successful

deleteUser

public void deleteUser(CmsUUID userId,
                       CmsUUID replacementId)
                throws CmsException
Deletes a user, where all permissions and resources attributes of the user were transfered to a replacement user.

Parameters:
userId - the id of the user to be deleted
replacementId - the id of the user to be transfered, can be null
Throws:
CmsException - if operation was not successful

deleteUser

public void deleteUser(java.lang.String username)
                throws CmsException
Deletes a user.

Parameters:
username - the name of the user to be deleted
Throws:
CmsException - if operation was not successful

deleteWebUser

public void deleteWebUser(CmsUUID userId)
                   throws CmsException
Deletes a web user.

Parameters:
userId - the id of the user to be deleted
Throws:
CmsException - if operation was not successful

existsResource

public boolean existsResource(java.lang.String resourcename)
Checks the availability of a resource in the VFS, using the CmsResourceFilter.DEFAULT filter.

A resource may be of type CmsFile or CmsFolder.

This method also takes into account the user permissions, so if the given resource exists, but the current user has not the required permissions, then this method will return false.

Parameters:
resourcename - the name of the resource to check (full path)
Returns:
true if the resource is available
See Also:
readResource(String), existsResource(String, CmsResourceFilter)

existsResource

public boolean existsResource(java.lang.String resourcename,
                              CmsResourceFilter filter)
Checks the availability of a resource in the VFS, using the CmsResourceFilter.DEFAULT filter.

A resource may be of type CmsFile or 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 CmsResourceFilter.DEFAULT will only return currently "valid" resources, while using CmsResourceFilter.IGNORE_EXPIRATION will ignore the date release / date expired information of the resource.

This method also takes into account the user permissions, so if the given resource exists, but the current user has not the required permissions, then this method will return false.

Parameters:
resourcename - the name of the resource to check (full path)
filter - the resource filter to use while checking
Returns:
true if the resource is available
See Also:
readResource(String), readResource(String, CmsResourceFilter)

getAccessControlEntries

public java.util.List getAccessControlEntries(java.lang.String resourceName)
                                       throws CmsException
Returns the list of access control entries of a resource given its name.

Parameters:
resourceName - the name of the resource
Returns:
a list of CmsAccessControlEntry objects
Throws:
CmsException - if something goes wrong

getAccessControlEntries

public java.util.List getAccessControlEntries(java.lang.String resourceName,
                                              boolean getInherited)
                                       throws CmsException
Returns the list of access control entries of a resource given its name.

Parameters:
resourceName - the name of the resource
getInherited - true, if inherited access control entries should be returned, too
Returns:
a list of CmsAccessControlEntry objects defining all permissions for the given resource
Throws:
CmsException - if something goes wrong

getAccessControlList

public CmsAccessControlList getAccessControlList(java.lang.String resourceName)
                                          throws CmsException
Returns the access control list (summarized access control entries) of a given resource.

Parameters:
resourceName - the name of the resource
Returns:
the access control list of the resource
Throws:
CmsException - if something goes wrong

getAccessControlList

public CmsAccessControlList getAccessControlList(java.lang.String resourceName,
                                                 boolean inheritedOnly)
                                          throws CmsException
Returns the access control list (summarized access control entries) of a given resource.

If inheritedOnly is set, only inherited access control entries are returned.

Parameters:
resourceName - the name of the resource
inheritedOnly - if set, the non-inherited entries are skipped
Returns:
the access control list of the resource
Throws:
CmsException - if something goes wrong

getAllAccessibleProjects

public java.util.List getAllAccessibleProjects()
                                        throws CmsException
Returns all projects which are owned by the current user or which are accessible for the group of the user.

Returns:
a list of objects of type CmsProject
Throws:
CmsException - if operation was not successful

getAllBackupProjects

public java.util.List getAllBackupProjects()
                                    throws CmsException
Returns a list with all projects from history.

Returns:
list of CmsBackupProject objects with all projects from history.
Throws:
CmsException - if operation was not succesful

getAllManageableProjects

public java.util.List getAllManageableProjects()
                                        throws CmsException
Returns all projects which are owned by the current user or which are manageable for the group of the user.

Returns:
a list of objects of type CmsProject
Throws:
CmsException - if operation was not successful

getBackupTagId

public int getBackupTagId()
Returns the next version id for the published backup resources.

Returns:
int the new version id

getChild

public java.util.List getChild(java.lang.String groupname)
                        throws CmsException
Returns all child groups of a group.

Parameters:
groupname - the name of the group
Returns:
a list of all child CmsGroup objects or null
Throws:
CmsException - if operation was not successful

getChilds

public java.util.List getChilds(java.lang.String groupname)
                         throws CmsException
Returns all child groups of a group.

This method also returns all sub-child groups of the current group.

Parameters:
groupname - the name of the group
Returns:
a list of all child CmsGroup objects or null
Throws:
CmsException - if operation was not successful

getConfigurations

public java.util.Map getConfigurations()
Returns the configuration read fromr the opencms.properties file.

Returns:
the configuration read fromr the opencms.properties file

getDirectGroupsOfUser

public java.util.List getDirectGroupsOfUser(java.lang.String username)
                                     throws CmsException
Returns all groups to which a given user directly belongs.

Parameters:
username - the name of the user to get all groups for
Returns:
a list of CmsGroup objects
Throws:
CmsException - if operation was not successful

getFilesInFolder

public java.util.List getFilesInFolder(java.lang.String resourcename)
                                throws CmsException
Returns all file resources contained in a folder.

The result is filtered according to the rules of the CmsResourceFilter.DEFAULT filter.

Parameters:
resourcename - the full path of the resource to return the child resources for.
Returns:
a list of all child file CmsResources
Throws:
CmsException - if something goes wrong
See Also:
getFilesInFolder(String, CmsResourceFilter)

getFilesInFolder

public java.util.List getFilesInFolder(java.lang.String resourcename,
                                       CmsResourceFilter filter)
                                throws CmsException
Returns all file resources contained in a folder.

With the CmsResourceFilter provided as parameter you can control if you want to include deleted, invisible or time-invalid resources in the result.

Parameters:
resourcename - the full path of the resource to return the child resources for.
filter - the resource filter to use
Returns:
a list of all child file CmsResources
Throws:
CmsException - if something goes wrong

getGroups

public java.util.List getGroups()
                         throws CmsException
Returns all groups.

Returns:
a list of all CmsGroup objects
Throws:
CmsException - if operation was not successful

getGroupsOfUser

public java.util.List getGroupsOfUser(java.lang.String username)
                               throws CmsException
Returns all the groups the given user, directly or indirectly, belongs to.

Parameters:
username - the name of the user
Returns:
a list of CmsGroup objects
Throws:
CmsException - if operation was not succesful

getGroupsOfUser

public java.util.List getGroupsOfUser(java.lang.String username,
                                      java.lang.String remoteAddress)
                               throws CmsException
Returns the groups of a user filtered by the specified IP address.

Parameters:
username - the name of the user
remoteAddress - the IP address to filter the groups in the result list
Returns:
a list of CmsGroup objects filtered by the specified IP address
Throws:
CmsException - if operation was not succesful

getLock

public CmsLock getLock(CmsResource resource)
                throws CmsException
Returns the lock state for a specified resource.

Parameters:
resource - the resource to return the lock state for
Returns:
the lock state for the specified resource
Throws:
CmsException - if something goes wrong

getLock

public CmsLock getLock(java.lang.String resourcename)
                throws CmsException
Returns the lock state for a specified resource name.

Parameters:
resourcename - the name if the resource to get the lock state for (full path)
Returns:
the lock state for the specified resource
Throws:
CmsException - if something goes wrong

getLostAndFoundName

public java.lang.String getLostAndFoundName(java.lang.String resourcename)
                                     throws CmsException
Returns the name a resource would have if it were moved to the "lost and found" folder.

In general, it is the same name as the given resource has, the only exception is if a resource in the "lost and found" folder with the same name already exists. In such case, a counter is added to the resource name.

Parameters:
resourcename - the name of the resource to get the "lost and found" name for (full path)
Returns:
the tentative name of the resource inside the "lost and found" folder
Throws:
CmsException - if something goes wrong
See Also:
moveToLostAndFound(String)

getParent

public CmsGroup getParent(java.lang.String groupname)
                   throws CmsException
Returns the parent group of a group.

Parameters:
groupname - the name of the group
Returns:
group the parent group or null
Throws:
CmsException - if operation was not successful

getPermissions

public CmsPermissionSet getPermissions(java.lang.String resourceName)
                                throws CmsException
Returns the set of permissions of the current user for a given resource.

Parameters:
resourceName - the name of the resource
Returns:
the bitset of the permissions of the current user
Throws:
CmsException - if something goes wrong

getPermissions

public CmsPermissionSet getPermissions(java.lang.String resourceName,
                                       java.lang.String userName)
                                throws CmsException
Returns the set of permissions of a given user for a given resource.

Parameters:
resourceName - the name of the resource
userName - the name of the user
Returns:
the current permissions on this resource
Throws:
CmsException - if something goes wrong

getPublishList

public CmsPublishList getPublishList()
                              throws CmsException
Returns a publish list with all new/changed/deleted resources of the current (offline) project that actually get published.

Returns:
a publish list
Throws:
CmsException - if something goes wrong

getPublishList

public CmsPublishList getPublishList(CmsResource directPublishResource,
                                     boolean directPublishSiblings)
                              throws CmsException
Returns a publish list with all new/changed/deleted resources of the current (offline) project that actually get published for a direct publish of a single resource.

Parameters:
directPublishResource - the resource which will be directly published
directPublishSiblings - true, if all eventual siblings of the direct published resource should also get published.
Returns:
a publish list
Throws:
CmsException - if something goes wrong

getPublishList

public CmsPublishList getPublishList(java.util.List directPublishResources,
                                     boolean directPublishSiblings)
                              throws CmsException
Returns a publish list with all new/changed/deleted resources of the current (offline) project that actually get published for a direct publish of a List of resources.

Parameters:
directPublishResources - the resources which will be directly published
directPublishSiblings - true, if all eventual siblings of the direct published resources should also get published.
Returns:
a publish list
Throws:
CmsException - if something goes wrong

getPublishList

public CmsPublishList getPublishList(java.util.List directPublishResources,
                                     boolean directPublishSiblings,
                                     boolean publishSubResources)
                              throws CmsException
Returns a publish list with all new/changed/deleted resources of the current (offline) project that actually get published for a direct publish of a List of resources.

Parameters:
directPublishResources - the resources which will be directly published
directPublishSiblings - true, if all eventual siblings of the direct published resources should also get published.
publishSubResources - indicates if sub-resources in folders should be published (for direct publish only)
Returns:
a publish list
Throws:
CmsException - if something goes wrong

getRequestContext

public CmsRequestContext getRequestContext()
Returns the current users request context.

This request context is used to authenticate the user for all OpenCms operations. It also contains the request runtime settings, e.g. about the current site this request was made on.

Returns:
the current users request context

getResourcesForPrincipal

public java.util.List getResourcesForPrincipal(CmsUUID principalId,
                                               CmsPermissionSet permissions,
                                               boolean includeAttr)
                                        throws CmsException
Returns all resources associated to a given principal via an ACE with the given permissions.

If the includeAttr flag is set it returns also all resources associated to a given principal through some of following attributes.

Parameters:
principalId - the id of the principal
permissions - a set of permissions to match, can be null for all ACEs
includeAttr - a flag to include resources associated by attributes
Returns:
a list of CmsResource objects
Throws:
CmsException - if something goes wrong

getResourcesInFolder

public java.util.List getResourcesInFolder(java.lang.String resourcename,
                                           CmsResourceFilter filter)
                                    throws CmsException
Returns all child resources of a resource, that is the resources contained in a folder.

With the CmsResourceFilter provided as parameter you can control if you want to include deleted, invisible or time-invalid resources in the result.

This method is mainly used by the workplace explorer.

Parameters:
resourcename - the full path of the resource to return the child resources for
filter - the resource filter to use
Returns:
a list of all child CmsResources
Throws:
CmsException - if something goes wrong

getResourcesInTimeRange

public java.util.List getResourcesInTimeRange(java.lang.String folder,
                                              long starttime,
                                              long endtime)
                                       throws CmsException
Returns a list with all sub resources of the given parent folder (and all of it's subfolders) that have been modified in the given time range.

The result list is descending sorted (newest resource first).

Parameters:
folder - the folder to get the subresources from
starttime - the begin of the time range
endtime - the end of the time range
Returns:
a list with all CmsResource objects that have been modified in the given time range.
Throws:
CmsException - if operation was not succesful

getSitePath

public java.lang.String getSitePath(CmsResource resource)
Adjusts the absolute resource root path for the current site.

The full root path of a resource is always available using CmsResource.getRootPath(). From this name this method cuts of the current site root using CmsRequestContext.removeSiteRoot(String).

If the resource root path does not start with the current site root, it is left untouched.

Parameters:
resource - the resource to get the adjusted site root path for
Returns:
the absolute resource path adjusted for the current site
See Also:
CmsRequestContext.removeSiteRoot(String), CmsRequestContext.getSitePath(CmsResource), CmsResource.getRootPath()

getSubFolders

public java.util.List getSubFolders(java.lang.String resourcename)
                             throws CmsException
Returns all folder resources contained in a folder.

The result is filtered according to the rules of the CmsResourceFilter.DEFAULT filter.

Parameters:
resourcename - the full path of the resource to return the child resources for.
Returns:
a list of all child file CmsResources
Throws:
CmsException - if something goes wrong
See Also:
getSubFolders(String, CmsResourceFilter)

getSubFolders

public java.util.List getSubFolders(java.lang.String resourcename,
                                    CmsResourceFilter filter)
                             throws CmsException
Returns all folder resources contained in a folder.

With the CmsResourceFilter provided as parameter you can control if you want to include deleted, invisible or time-invalid resources in the result.

Parameters:
resourcename - the full path of the resource to return the child resources for.
filter - the resource filter to use
Returns:
a list of all child folder CmsResources
Throws:
CmsException - if something goes wrong

getTaskService

public CmsTaskService getTaskService()
Returns the current session info manager object.

Returns:
the current session info manager object

getUsers

public java.util.List getUsers()
                        throws CmsException
Returns all users.

Returns:
a list of all CmsUser objects
Throws:
CmsException - if operation was not successful

getUsers

public java.util.List getUsers(int type)
                        throws CmsException
Returns all users of the given type.

Parameters:
type - the type of the users
Returns:
a list of all CmsUser objects of the given type
Throws:
CmsException - if operation was not successful

getUsersOfGroup

public java.util.List getUsersOfGroup(java.lang.String groupname)
                               throws CmsException
Returns all direct users of a given group.

Users that are "indirectly" in the group are not returned in the result.

Parameters:
groupname - the name of the group to get all users for
Returns:
all CmsUser objects in the group
Throws:
CmsException - if operation was not successful

hasPermissions

public boolean hasPermissions(CmsResource resource,
                              CmsPermissionSet requiredPermissions)
                       throws CmsException
Checks if the current user has required permissions to access a given resource.

Parameters:
resource - the resource to check the permissions for
requiredPermissions - the set of permissions to check for
Returns:
true if the required permissions are satisfied
Throws:
CmsException - if something goes wrong

hasPermissions

public boolean hasPermissions(CmsResource resource,
                              CmsPermissionSet requiredPermissions,
                              boolean checkLock,
                              CmsResourceFilter filter)
                       throws CmsException
Checks if the current user has required permissions to access a given resource.

Parameters:
resource - the resource to check the permissions for
requiredPermissions - the set of permissions to check for
checkLock - if true, a lock for the current user is required for all write operations, if false it's ok to write as long as the resource is not locked by another user.
filter - the resource filter to use
Returns:
true if the required permissions are satisfied
Throws:
CmsException - if something goes wrong

hasPublishPermissions

public boolean hasPublishPermissions(java.lang.String resourcename)
Checks if the given resource or the current project can be published by the current user using his current OpenCms context.

If the resource parameter is null, then the current project is checked, otherwise the resource is checked for direct publish permissions.

Parameters:
resourcename - the direct publish resource name (optional, if null only the current project is checked)
Returns:
true, if the current user can direct publish the given resource in his current context

hasRole

public boolean hasRole(CmsRole roles)
Checks if the user of the current OpenCms context is a member of at last one of the roles in the given role set.

Parameters:
roles - the role to check
Returns:
true if the user of the current OpenCms context is at a member of at last one of the roles in the given role set

importAccessControlEntries

public void importAccessControlEntries(CmsResource resource,
                                       java.util.List acEntries)
                                throws CmsException
Writes a list of access control entries as new access control entries of a given resource.

Already existing access control entries of this resource are removed before.

Parameters:
resource - the resource to attach the control entries to
acEntries - a list of CmsAccessControlEntry objects
Throws:
CmsException - if something goes wrong

importResource

public CmsResource importResource(java.lang.String resourcename,
                                  CmsResource resource,
                                  byte[] content,
                                  java.util.List properties)
                           throws CmsException
Imports a resource to the OpenCms VFS.

If a resource already exists in the VFS (i.e. has the same name and same id) it is replaced by the imported resource.

If a resource with the same name but a different id exists, the imported resource is (usually) moved to the "lost and found" folder.

Parameters:
resourcename - the name for the resource after import (full path)
resource - the resource object to be imported
content - the content of the resource
properties - the properties of the resource
Returns:
the imported resource
Throws:
CmsException - if something goes wrong
See Also:
moveToLostAndFound(String)

importUser

public CmsUser importUser(java.lang.String id,
                          java.lang.String name,
                          java.lang.String password,
                          java.lang.String description,
                          java.lang.String firstname,
                          java.lang.String lastname,
                          java.lang.String email,
                          java.lang.String address,
                          int flags,
                          int type,
                          java.util.Map additionalInfos)
                   throws CmsException
Creates a new user by import.

Parameters:
id - the id of the user
name - the new name for the user
password - the new password for the user
description - the description for the user
firstname - the firstname of the user
lastname - the lastname of the user
email - the email of the user
address - the address of the user
flags - the flags for a user (for example I_CmsPrincipal.FLAG_ENABLED)
type - the type of the user
additionalInfos - the additional user infos
Returns:
the imported user
Throws:
CmsException - if something goes wrong

isAdmin

public boolean isAdmin()
Deprecated. use hasRole(CmsRole) or checkRole(CmsRole) instead

Checks if the current user has role access to CmsRole.ADMINISTRATOR.

Returns:
true, if the current user has role access to CmsRole.ADMINISTRATOR

isInsideCurrentProject

public boolean isInsideCurrentProject(java.lang.String resourcename)
Checks if the specified resource is inside the current project.

The project "view" is determined by a set of path prefixes. If the resource starts with any one of this prefixes, it is considered to be "inside" the project.

Parameters:
resourcename - the specified resource name (full path)
Returns:
true, if the specified resource is inside the current project

isManagerOfProject

public boolean isManagerOfProject()
Checks if the current user has management access to the current project.

Returns:
true, if the user has management access to the current project

lockResource

public void lockResource(java.lang.String resourcename)
                  throws CmsException
Locks a resource.

The mode for the lock is CmsLock.COMMON.

Parameters:
resourcename - the name of the resource to lock (full path)
Throws:
CmsException - if something goes wrong
See Also:
lockResource(String, int)

lockResource

public void lockResource(java.lang.String resourcename,
                         int mode)
                  throws CmsException
Locks a resource.

The mode parameter controls what kind of lock is used.
Possible values for this parameter are:

Parameters:
resourcename - the name of the resource to lock (full path)
mode - flag indicating the mode for the lock
Throws:
CmsException - if something goes wrong

loginUser

public java.lang.String loginUser(java.lang.String username,
                                  java.lang.String password)
                           throws CmsException
Logs a user into the Cms, if the password is correct.

Parameters:
username - the name of the user
password - the password of the user
Returns:
the name of the logged in user
Throws:
CmsException - if the login was not successful

loginUser

public java.lang.String loginUser(java.lang.String username,
                                  java.lang.String password,
                                  java.lang.String remoteAddress)
                           throws CmsException
Logs a user with a given ip address into the Cms, if the password is correct.

Parameters:
username - the name of the user
password - the password of the user
remoteAddress - the ip address
Returns:
the name of the logged in user
Throws:
CmsException - if the login was not successful

loginUser

public java.lang.String loginUser(java.lang.String username,
                                  java.lang.String password,
                                  java.lang.String remoteAddress,
                                  int type)
                           throws CmsException
Logs a user with a given type and a given ip address into the Cms, if the password is correct.

Parameters:
username - the name of the user
password - the password of the user
remoteAddress - the ip address
type - the user type (System or Web user)
Returns:
the name of the logged in user
Throws:
CmsException - if the login was not successful

loginWebUser

public java.lang.String loginWebUser(java.lang.String username,
                                     java.lang.String password)
                              throws CmsException
Logs a web user into the Cms, if the password is correct.

Parameters:
username - the name of the user
password - the password of the user
Returns:
the name of the logged in user
Throws:
CmsException - if the login was not successful

lookupPrincipal

public I_CmsPrincipal lookupPrincipal(CmsUUID principalId)
Lookups and reads the user or group with the given UUID.

Parameters:
principalId - the uuid of a user or group
Returns:
the user or group with the given UUID

lookupPrincipal

public I_CmsPrincipal lookupPrincipal(java.lang.String principalName)
Lookups and reads the user or group with the given name.

Parameters:
principalName - the name of the user or group
Returns:
the user or group with the given name

moveResource

public void moveResource(java.lang.String source,
                         java.lang.String destination)
                  throws CmsException
Moves a resource to the given destination.

A move operation in OpenCms is always a copy (as sibling) followed by a delete, this is a result of the online/offline structure of the OpenCms VFS. This way you can see the deleted files/folders in the offline project, and you will be unable to undelete them.

Parameters:
source - the name of the resource to move (full path)
destination - the destination resource name (full path)
Throws:
CmsException - if something goes wrong
See Also:
renameResource(String, String)

moveToLostAndFound

public java.lang.String moveToLostAndFound(java.lang.String resourcename)
                                    throws CmsException
Moves a resource to the "lost and found" folder.

The "lost and found" folder is a special system folder. This operation is used e.g. during import of resources when a resource with the same name but a different resource ID already exists in the VFS. In this case, the imported resource is moved to the "lost and found" folder.

Parameters:
resourcename - the name of the resource to move to "lost and found" (full path)
Returns:
the name of the resource inside the "lost and found" folder
Throws:
CmsException - if something goes wrong
See Also:
getLostAndFoundName(String)

publishProject

public CmsUUID publishProject()
                       throws java.lang.Exception
Publishes the current project, printing messages to a shell report.

Returns:
the publish history id of the published project
Throws:
java.lang.Exception - if something goes wrong
See Also:
CmsShellReport

publishProject

public CmsUUID publishProject(I_CmsReport report)
                       throws CmsException
Publishes the current project.

Parameters:
report - an instance of I_CmsReport to print messages
Returns:
the publish history id of the published project
Throws:
CmsException - if something goes wrong

publishProject

public CmsUUID publishProject(I_CmsReport report,
                              CmsPublishList publishList)
                       throws CmsException
Publishes the resources of a specified publish list.

Parameters:
report - an instance of I_CmsReport to print messages
publishList - a publish list
Returns:
the publish history id of the published project
Throws:
CmsException - if something goes wrong
See Also:
getPublishList(), getPublishList(CmsResource, boolean), getPublishList(List, boolean)

publishProject

public CmsUUID publishProject(I_CmsReport report,
                              CmsResource directPublishResource,
                              boolean directPublishSiblings)
                       throws CmsException
Direct publishes a specified resource.

Parameters:
report - an instance of I_CmsReport to print messages
directPublishResource - a CmsResource that gets directly published; or null if an entire project gets published.
directPublishSiblings - if a CmsResource that should get published directly is provided as an argument, all eventual siblings of this resource get publish too, if this flag is true.
Returns:
the publish history id of the published project
Throws:
CmsException - if something goes wrong
See Also:
publishResource(String), publishResource(String, boolean, I_CmsReport)

publishResource

public CmsUUID publishResource(java.lang.String resourcename)
                        throws java.lang.Exception
Publishes a single resource, printing messages to a shell report.

The siblings of the resource will not be published.

Parameters:
resourcename - the name of the resource to be published
Returns:
the publish history id of the published project
Throws:
java.lang.Exception - if something goes wrong
See Also:
CmsShellReport

publishResource

public CmsUUID publishResource(java.lang.String resourcename,
                               boolean publishSiblings,
                               I_CmsReport report)
                        throws java.lang.Exception
Publishes a single resource.

Parameters:
resourcename - the name of the resource to be published
publishSiblings - if true, all siblings of the resource are also published
report - the report to write the progress information to
Returns:
the publish history id of the published project
Throws:
java.lang.Exception - if something goes wrong

readAllBackupFileHeaders

public java.util.List readAllBackupFileHeaders(java.lang.String filename)
                                        throws CmsException
Reads all file headers of a file.
This method returns a list with the history of all file headers, i.e. the file headers of a file, independent of the project they were attached to.
The reading excludes the file content.

Parameters:
filename - the name of the file to be read
Returns:
a list of file headers, as CmsBackupResource objects, read from the Cms
Throws:
CmsException - if operation was not successful

readAllPropertyDefinitions

public java.util.List readAllPropertyDefinitions()
                                          throws CmsException
Reads all property definitions.

Returns:
a list with the CmsPropertyDefinition objects (may be empty)
Throws:
CmsException - if something goes wrong

readAncestor

public CmsFolder readAncestor(java.lang.String resourcename,
                              CmsResourceFilter filter)
                       throws CmsException
Returns the first ancestor folder matching the filter criteria.

If no folder matching the filter criteria is found, null is returned.

Parameters:
resourcename - the name of the resource to start (full path)
filter - the resource filter to match while reading the ancestors
Returns:
the first ancestor folder matching the filter criteria or null if no folder was found
Throws:
CmsException - if something goes wrong

readAncestor

public CmsFolder readAncestor(java.lang.String resourcename,
                              int type)
                       throws CmsException
Returns the first ancestor folder matching the resource type.

If no folder with the requested resource type is found, null is returned.

Parameters:
resourcename - the name of the resource to start (full path)
type - the resource type of the folder to match
Returns:
the first ancestor folder matching the filter criteria or null if no folder was found
Throws:
CmsException - if something goes wrong

readBackupFile

public CmsBackupResource readBackupFile(java.lang.String filename,
                                        int tagId)
                                 throws CmsException
Returns a file from the history.
The reading includes the file content.

Parameters:
filename - the complete path of the file to be read
tagId - the tag id of the resource
Returns:
the file read
Throws:
CmsException - if the user has not the rights to read the file, or if the file couldn't be read.

readBackupProject

public CmsBackupProject readBackupProject(int tagId)
                                   throws CmsException
Returns a backup project.

Parameters:
tagId - the tag of the backup project to be read
Returns:
the requested backup project
Throws:
CmsException - if operation was not successful

readBackupPropertyObjects

public java.util.List readBackupPropertyObjects(CmsBackupResource resource)
                                         throws CmsException
Reads the list of CmsProperty objects that belong the the given backup resource.

Parameters:
resource - the backup resource to read the properties from
Returns:
the list of CmsProperty objects that belong the the given backup resource
Throws:
CmsException - if something goes wrong

readFile

public CmsFile readFile(java.lang.String resourcename)
                 throws CmsException
Reads a file resource (including it's binary content) from the VFS, using the CmsResourceFilter.DEFAULT filter.

In case you do not need the file content, use readResource(String) instead.

Parameters:
resourcename - the name of the resource to read (full path)
Returns:
the file resource that was read
Throws:
CmsException - if the file resource could not be read for any reason
See Also:
readFile(String, CmsResourceFilter), readResource(String)

readFile

public CmsFile readFile(java.lang.String resourcename,
                        CmsResourceFilter filter)
                 throws CmsException
Reads a file resource (including it's binary content) from the VFS, using the specified resource filter.

In case you do not need the file content, use readResource(String, CmsResourceFilter) instead.

The specified filter controls what kind of resources should be "found" during the read operation. This will depend on the application. For example, using CmsResourceFilter.DEFAULT will only return currently "valid" resources, while using CmsResourceFilter.IGNORE_EXPIRATION will ignore the date release / date expired information of the resource.

Parameters:
resourcename - the name of the resource to read (full path)
filter - the resource filter to use while reading
Returns:
the file resource that was read
Throws:
CmsException - if the file resource could not be read for any reason
See Also:
readResource(String, CmsResourceFilter)

readFileHeader

public CmsResource readFileHeader(java.lang.String resourcename)
                           throws CmsException
Deprecated. use readResource(String, CmsResourceFilter) instead.

Reads a resource from the VFS, using the CmsResourceFilter.DEFAULT filter.

Parameters:
resourcename - the name of the resource to read (full path)
Returns:
the file resource that was read
Throws:
CmsException - if something goes wrong

readFolder

public CmsFolder readFolder(java.lang.String resourcename)
                     throws CmsException
Reads a folder resource from the VFS, using the CmsResourceFilter.DEFAULT filter.

Parameters:
resourcename - the name of the folder resource to read (full path)
Returns:
the folder resource that was read
Throws:
CmsException - if the resource could not be read for any reason
See Also:
readResource(String, CmsResourceFilter), readFolder(String, CmsResourceFilter)

readFolder

public CmsFolder readFolder(java.lang.String resourcename,
                            CmsResourceFilter filter)
                     throws CmsException
Reads a folder resource from the VFS, using the specified resource filter.

The specified filter controls what kind of resources should be "found" during the read operation. This will depend on the application. For example, using CmsResourceFilter.DEFAULT will only return currently "valid" resources, while using CmsResourceFilter.IGNORE_EXPIRATION will ignore the date release / date expired information of the resource.

Parameters:
resourcename - the name of the folder resource to read (full path)
filter - the resource filter to use while reading
Returns:
the folder resource that was read
Throws:
CmsException - if the resource could not be read for any reason
See Also:
readResource(String, CmsResourceFilter)

readGroup

public CmsGroup readGroup(CmsProject project)
Reads the group of a project.

Parameters:
project - the project to read the group from
Returns:
the group of the given project

readGroup

public CmsGroup readGroup(CmsUUID groupId)
                   throws CmsException
Reads a group based on its id.

Parameters:
groupId - the id of the group to be read
Returns:
the group that has the provided id
Throws:
CmsException - if something goes wrong

readGroup

public CmsGroup readGroup(java.lang.String groupName)
                   throws CmsException
Reads a group based on its name.

Parameters:
groupName - the name of the group to be read
Returns:
the group that has the provided name
Throws:
CmsException - if something goes wrong

readManagerGroup

public CmsGroup readManagerGroup(CmsProject project)
Returns the project manager group of a project.

Parameters:
project - the project
Returns:
the manager group of the project

readOwner

public CmsUser readOwner(CmsProject project)
                  throws CmsException
Reads the owner of a project.

Parameters:
project - the project to read the owner from
Returns:
the owner of the project
Throws:
CmsException - if something goes wrong

readPath

public java.util.List readPath(java.lang.String path,
                               CmsResourceFilter filter)
                        throws CmsException
Builds a list of resources for a given path.

Parameters:
path - the requested path
filter - a filter object (only "includeDeleted" information is used!)
Returns:
list of CmsResources
Throws:
CmsException - if something goes wrong

readProject

public CmsProject readProject(int id)
                       throws CmsException
Reads the project with the given id.

Parameters:
id - the id of the project
Returns:
the project with the given id
Throws:
CmsException - if operation was not successful

readProject

public CmsProject readProject(java.lang.String name)
                       throws CmsException
Reads the project with the given name.

Parameters:
name - the name of the project
Returns:
the project with the given name
Throws:
CmsException - if operation was not successful

readProjectResources

public java.util.List readProjectResources(CmsProject project)
                                    throws CmsException
Returns the list of all resource names that define the "view" of the given project.

Parameters:
project - the project to get the project resources for
Returns:
the list of all resource names, as String objects that define the "view" of the given project.
Throws:
CmsException - if something goes wrong

readProjectView

public java.util.List readProjectView(int projectId,
                                      int state)
                               throws CmsException
Reads all resources of a project that match a given state from the VFS.

Possible values for the state parameter are:

Parameters:
projectId - the id of the project to read the file resources for
state - the resource state to match
Returns:
all CmsResources of a project that match a given criteria from the VFS
Throws:
CmsException - if something goes wrong

readProperties

public java.util.Map readProperties(java.lang.String resourcePath)
                             throws CmsException
Deprecated. use readPropertyObjects(String, boolean) instead.

Reads the (compound) values of all properties mapped to a specified resource.

Parameters:
resourcePath - the resource to look up the property for
Returns:
a map of String objects representing all properties of the resource
Throws:
CmsException - in case there where problems reading the properties

readProperties

public java.util.Map readProperties(java.lang.String resourcePath,
                                    boolean search)
                             throws CmsException
Deprecated. use readPropertyObjects(String, boolean) instead.

Reads the (compound) values of all properties mapped to a specified resource with optional direcory upward cascading.

Parameters:
resourcePath - the resource to look up the property for
search - if true, the properties will also be looked up on all parent folders and the results will be merged, if false not (ie. normal property lookup)
Returns:
Map of String objects representing all properties of the resource
Throws:
CmsException - in case there where problems reading the properties

readProperty

public java.lang.String readProperty(java.lang.String resourcePath,
                                     java.lang.String property)
                              throws CmsException
Deprecated. use readPropertyObject(String, String, boolean) instead.

Reads the (compound) value of a property mapped to a specified resource.

Parameters:
resourcePath - the resource to look up the property for
property - the name of the property to look up
Returns:
the value of the property found, null if nothing was found
Throws:
CmsException - in case there where problems reading the property
See Also:
CmsProperty.getValue()

readProperty

public java.lang.String readProperty(java.lang.String resourcePath,
                                     java.lang.String property,
                                     boolean search)
                              throws CmsException
Deprecated. use readPropertyObject(String, String, boolean) instead.

Reads the (compound) value of a property mapped to a specified resource with optional direcory upward cascading.

Parameters:
resourcePath - the resource to look up the property for
property - the name of the property to look up
search - if true, the property will be looked up on all parent folders if it is not attached to the the resource, if false not (ie. normal property lookup)
Returns:
the value of the property found, null if nothing was found
Throws:
CmsException - in case there where problems reading the property
See Also:
CmsProperty.getValue()

readProperty

public java.lang.String readProperty(java.lang.String resourcePath,
                                     java.lang.String property,
                                     boolean search,
                                     java.lang.String propertyDefault)
                              throws CmsException
Deprecated. use readPropertyObject(String, String, boolean) instead.

Reads the (compound) value of a property mapped to a specified resource with optional direcory upward cascading, a default value will be returned if the property is not found on the resource (or it's parent folders in case search is set to true).

Parameters:
resourcePath - the resource to look up the property for
property - the name of the property to look up
search - if true, the property will be looked up on all parent folders if it is not attached to the the resource, if false not (ie. normal property lookup)
propertyDefault - a default value that will be returned if the property was not found on the selected resource
Returns:
the value of the property found, if nothing was found the value of the propertyDefault parameter is returned
Throws:
CmsException - in case there where problems reading the property
See Also:
CmsProperty.getValue()

readPropertyDefinition

public CmsPropertyDefinition readPropertyDefinition(java.lang.String name)
                                             throws CmsException
Reads a property definition.

If no property definition with the given name is found, null is returned.

Parameters:
name - the name of the property definition to read
Returns:
the property definition that was read, or null if there is no property definition with the given name.
Throws:
CmsException - if something goes wrong

readPropertyObject

public CmsProperty readPropertyObject(CmsResource resource,
                                      java.lang.String property,
                                      boolean search)
                               throws CmsException
Reads a property object from a resource specified by a property name.

Returns CmsProperty.getNullProperty() if the property is not found.

This method is more efficient then using readPropertyObject(String, String, boolean) if you already have an instance of the resource to look up the property from.

Parameters:
resource - the resource where the property is attached to
property - the property name
search - if true, the property is searched on all parent folders of the resource, if it's not found attached directly to the resource
Returns:
the required property, or CmsProperty.getNullProperty() if the property was not found
Throws:
CmsException - if something goes wrong

readPropertyObject

public CmsProperty readPropertyObject(java.lang.String resourcePath,
                                      java.lang.String property,
                                      boolean search)
                               throws CmsException
Reads a property object from a resource specified by a property name.

Returns CmsProperty.getNullProperty() if the property is not found.

Parameters:
resourcePath - the name of resource where the property is attached to
property - the property name
search - if true, the property is searched on all parent folders of the resource, if it's not found attached directly to the resource
Returns:
the required property, or CmsProperty.getNullProperty() if the property was not found
Throws:
CmsException - if something goes wrong

readPropertyObjects

public java.util.List readPropertyObjects(CmsResource resource,
                                          boolean search)
                                   throws CmsException
Reads all property objects from a resource.

Returns an empty list if no properties are found.

This method is more efficient then using readPropertyObjects(String, boolean) if you already have an instance of the resource to look up the property from.

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 differrent value, the result list will contain only the property with the value from the resource, not form the parent folder(s).

Parameters:
resource - the resource where the property is mapped to
search - if true, the properties of all parent folders of the resource are merged with the resource properties.
Returns:
a list of CmsProperty objects
Throws:
CmsException - if something goes wrong

readPropertyObjects

public java.util.List readPropertyObjects(java.lang.String resourcePath,
                                          boolean search)
                                   throws CmsException
Reads all property objects from a resource.

Returns an empty list if no properties are found.

All properties in the result List will be in frozen (read only) state, so you can't change the values.

If the search parameter 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 differrent value, the result list will contain only the property with the value from the resource, not form the parent folder(s).

Parameters:
resourcePath - the name of resource where the property is mapped to
search - if true, the properties of all parent folders of the resource are merged with the resource properties.
Returns:
a list of CmsProperty objects
Throws:
CmsException - if something goes wrong

readPublishedResources

public java.util.List readPublishedResources(CmsUUID publishHistoryId)
                                      throws CmsException
Reads the resources that were published in a publish task for a given publish history ID.

Parameters:
publishHistoryId - unique int ID to identify each publish task in the publish history
Returns:
a list of CmsPublishedResource objects
Throws:
CmsException - if something goes wrong

readResource

public CmsResource readResource(java.lang.String resourcename)
                         throws CmsException
Reads a resource from the VFS, using the CmsResourceFilter.DEFAULT filter.

A resource may be of type CmsFile or CmsFolder. 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 CmsFile.upgrade(CmsResource, CmsObject).

Parameters:
resourcename - the name of the resource to read (full path)
Returns:
the resource that was read
Throws:
CmsException - if the resource could not be read for any reason
See Also:
readFile(String), readResource(String, CmsResourceFilter), CmsFile.upgrade(CmsResource, CmsObject)

readResource

public CmsResource readResource(java.lang.String resourcename,
                                CmsResourceFilter filter)
                         throws CmsException
Reads a resource from the VFS, using the specified resource filter.

A resource may be of type CmsFile or CmsFolder. 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 absolutly required. To "upgrade" a resource to a file, use CmsFile.upgrade(CmsResource, CmsObject).

The specified filter controls what kind of resources should be "found" during the read operation. This will depend on the application. For example, using CmsResourceFilter.DEFAULT will only return currently "valid" resources, while using CmsResourceFilter.IGNORE_EXPIRATION will ignore the date release / date expired information of the resource.

Parameters:
resourcename - the name of the resource to read (full path)
filter - the resource filter to use while reading
Returns:
the resource that was read
Throws:
CmsException - if the resource could not be read for any reason
See Also:
readFile(String, CmsResourceFilter), readFolder(String, CmsResourceFilter), CmsFile.upgrade(CmsResource, CmsObject)

readResources

public java.util.List readResources(java.lang.String resourcename,
                                    CmsResourceFilter filter)
                             throws CmsException
Reads all resources below the given path matching the filter criteria, including the full tree below the path.

Parameters:
resourcename - the parent path to read the resources from
filter - the filter
Returns:
a list of CmsResource objects matching the filter criteria
Throws:
CmsException - if something goes wrong
See Also:
readResources(String, CmsResourceFilter, boolean)

readResources

public java.util.List readResources(java.lang.String resourcename,
                                    CmsResourceFilter filter,
                                    boolean readTree)
                             throws CmsException
Reads all resources below the given path matching the filter criteria, including the full tree below the path only in case the readTree parameter is true.

Parameters:
resourcename - the parent path to read the resources from
filter - the filter
readTree - true to read all subresources
Returns:
a list of CmsResource objects matching the filter criteria
Throws:
CmsException - if something goes wrong

readResourcesWithProperty

public java.util.List readResourcesWithProperty(java.lang.String propertyDefinition)
                                         throws CmsException
Reads all resources that have a value set for the specified property.

Both individual and shared properties of a resource are checked.

Parameters:
propertyDefinition - the name of the property to check for
Returns:
a list of all CmsResource objects that have a value set for the specified property.
Throws:
CmsException - if something goes wrong

readResourcesWithProperty

public java.util.List readResourcesWithProperty(java.lang.String path,
                                                java.lang.String propertyDefinition)
                                         throws CmsException
Reads all resources that have a value set for the specified property in the given path.

Both individual and shared properties of a resource are checked.

Parameters:
path - the folder to get the resources with the property from
propertyDefinition - the name of the property to check for
Returns:
all CmsResource objects that have a value set for the specified property in the given path.
Throws:
CmsException - if something goes wrong

readResourcesWithProperty

public java.util.List readResourcesWithProperty(java.lang.String path,
                                                java.lang.String propertyDefinition,
                                                java.lang.String value)
                                         throws CmsException
Reads all resources that have a value (containing the specified value) set for the specified property in the given path.

Both individual and shared properties of a resource are checked.

Parameters:
path - the folder to get the resources with the property from
propertyDefinition - the name of the property to check for
value - the string to search in the value of the property
Returns:
all CmsResource objects that have a value set for the specified property in the given path.
Throws:
CmsException - if something goes wrong

readResponsiblePrincipals

public java.util.Set readResponsiblePrincipals(CmsResource resource)
                                        throws CmsException
Returns a set of principals that are responsible for a specific resource.

Parameters:
resource - the resource to get the responsible principals from
Returns:
the set of principals that are responsible for a specific resource
Throws:
CmsException - if something goes wrong

readResponsibleUsers

public java.util.Set readResponsibleUsers(CmsResource resource)
                                   throws CmsException
Returns a set of users that are responsible for a specific resource.

Parameters:
resource - the resource to get the responsible users from
Returns:
the set of users that are responsible for a specific resource
Throws:
CmsException - if something goes wrong

readSiblings

public java.util.List readSiblings(java.lang.String resourcename,
                                   CmsResourceFilter filter)
                            throws CmsException
Returns a list of all siblings of the specified resource, the specified resource being always part of the result set.

Parameters:
resourcename - the name of the specified resource
filter - a resource filter
Returns:
a list of CmsResources that are siblings to the specified resource, including the specified resource itself.
Throws:
CmsException - if something goes wrong

readStaticExportPublishedResourceParameters

public java.lang.String readStaticExportPublishedResourceParameters(java.lang.String rfsName)
                                                             throws CmsException
Returns the parameters of a resource in the list of all published template resources.

Parameters:
rfsName - the rfs name of the resource
Returns:
the parameter string of the requested resource
Throws:
CmsException - if something goes wrong

readStaticExportResources

public java.util.List readStaticExportResources(int parameterResources,
                                                long timestamp)
                                         throws CmsException
Returns a list of all template resources which must be processed during a static export.

Parameters:
parameterResources - flag for reading resources with parameters (1) or without (0)
timestamp - a timestamp for reading the data from the db
Returns:
a list of template resources as String objects
Throws:
CmsException - if something goes wrong

readUser

public CmsUser readUser(CmsUUID userId)
                 throws CmsException
Reads a user based on its id.

Parameters:
userId - the id of the user to be read
Returns:
the user with the given id
Throws:
CmsException - if something goes wrong

readUser

public CmsUser readUser(java.lang.String username)
                 throws CmsException
Reads a user based on its name.

Parameters:
username - the name of the user to be read
Returns:
the user with the given name
Throws:
CmsException - if somthing goes wrong

readUser

public CmsUser readUser(java.lang.String username,
                        int type)
                 throws CmsException
Returns a user given its name and type.

Parameters:
username - the name of the user to be returned
type - the type of the user
Returns:
the user with the given name and type
Throws:
CmsException - if operation was not successful

readUser

public CmsUser readUser(java.lang.String username,
                        java.lang.String password)
                 throws CmsException
Returns a user, if the password is correct.

If the user/pwd pair is not valid a CmsException is thrown.

Parameters:
username - the name of the user to be returned
password - the password of the user to be returned
Returns:
the validated user
Throws:
CmsException - if operation was not successful

readWebUser

public CmsUser readWebUser(java.lang.String username)
                    throws CmsException
Returns a webuser.

Parameters:
username - the username of the webuser that is to be read
Returns:
the webuser
Throws:
CmsException - if operation was not succesful

readWebUser

public CmsUser readWebUser(java.lang.String username,
                           java.lang.String password)
                    throws CmsException
Returns a web user if the password for the user is correct.

If the user/pwd pair is not valid a CmsException is thrown.

Parameters:
username - the username of the user that is to be read
password - the password of the user that is to be read
Returns:
a web user
Throws:
CmsException - if something goes wrong

removeResourceFromProject

public void removeResourceFromProject(java.lang.String resourcename)
                               throws CmsException
Removes a resource from the current project of the user.

This is used to reduce the current users project with the specified resource, in case that the resource is already part of the project. The resource is not really removed like in a regular copy operation, it is in fact only "disabled" in the current users project.

Parameters:
resourcename - the name of the resource to remove to the current project (full path)
Throws:
CmsException - if something goes wrong

removeUserFromGroup

public void removeUserFromGroup(java.lang.String username,
                                java.lang.String groupname)
                         throws CmsException
Removes a user from a group.

Parameters:
username - the name of the user that is to be removed from the group
groupname - the name of the group
Throws:
CmsException - if operation was not successful

renameResource

public void renameResource(java.lang.String source,
                           java.lang.String destination)
                    throws CmsException
Renames a resource to the given destination name, this is identical to a move operation.

Parameters:
source - the name of the resource to rename (full path)
destination - the new resource name (full path)
Throws:
CmsException - if something goes wrong
See Also:
moveResource(String, String)

replaceResource

public void replaceResource(java.lang.String resourcename,
                            int type,
                            byte[] content,
                            java.util.List properties)
                     throws CmsException
Replaces the content, type and properties of a resource.

Parameters:
resourcename - the name of the resource to replace (full path)
type - the new type of the resource
content - the new content of the resource
properties - the new properties of the resource
Throws:
CmsException - if something goes wrong

restoreResourceBackup

public void restoreResourceBackup(java.lang.String resourcename,
                                  int tagId)
                           throws CmsException
Restores a file in the current project with a version from the backup archive.

Parameters:
resourcename - the name of the resource to restore from the archive (full path)
tagId - the desired tag ID of the resource
Throws:
CmsException - if something goes wrong

rmacc

public void rmacc(java.lang.String resourceName,
                  java.lang.String principalType,
                  java.lang.String principalName)
           throws CmsException
Removes an access control entry of a griven principal from a given resource.

Parameters:
resourceName - name of the resource
principalType - the type of the principal (currently group or user)
principalName - the name of the principal
Throws:
CmsException - if something goes wrong

setDateExpired

public void setDateExpired(java.lang.String resourcename,
                           long dateExpired,
                           boolean recursive)
                    throws CmsException
Changes the "expire" date of a resource.

Parameters:
resourcename - the name of the resource to change (full path)
dateExpired - the new expire date of the changed resource
recursive - if this operation is to be applied recursivly to all resources in a folder
Throws:
CmsException - if something goes wrong

setDateLastModified

public void setDateLastModified(java.lang.String resourcename,
                                long dateLastModified,
                                boolean recursive)
                         throws CmsException
Changes the "last modified" timestamp of a resource.

Parameters:
resourcename - the name of the resource to change (full path)
dateLastModified - timestamp the new timestamp of the changed resource
recursive - if this operation is to be applied recursivly to all resources in a folder
Throws:
CmsException - if something goes wrong

setDateReleased

public void setDateReleased(java.lang.String resourcename,
                            long dateReleased,
                            boolean recursive)
                     throws CmsException
Changes the "release" date of a resource.

Parameters:
resourcename - the name of the resource to change (full path)
dateReleased - the new release date of the changed resource
recursive - if this operation is to be applied recursivly to all resources in a folder
Throws:
CmsException - if something goes wrong

setParentGroup

public void setParentGroup(java.lang.String groupName,
                           java.lang.String parentGroupName)
                    throws CmsException
Sets a new parent-group for an already existing group.

Parameters:
groupName - the name of the group that should be updated
parentGroupName - the name of the parent group to set, or null if the parent group should be deleted.
Throws:
CmsException - if operation was not successfull

setPassword

public void setPassword(java.lang.String username,
                        java.lang.String newPassword)
                 throws CmsException
Sets the password for a user.

Parameters:
username - the name of the user
newPassword - the new password
Throws:
CmsException - if operation was not successful

setPassword

public void setPassword(java.lang.String username,
                        java.lang.String oldPassword,
                        java.lang.String newPassword)
                 throws CmsException
Sets the password for a specified user.

Parameters:
username - the name of the user
oldPassword - the old password
newPassword - the new password
Throws:
CmsException - if the user data could not be read from the database

touch

public void touch(java.lang.String resourcename,
                  long dateLastModified,
                  long dateReleased,
                  long dateExpired,
                  boolean recursive)
           throws CmsException
Deprecated. use setDateLastModified(String, long, boolean), setDateReleased(String, long, boolean) or setDateExpired(String, long, boolean) instead

Changes the timestamp information of a resource.

This method is used to set the "last modified" date of a resource, the "release" date of a resource, and also the "expire" date of a resource.

Parameters:
resourcename - the name of the resource to change (full path)
dateLastModified - timestamp the new timestamp of the changed resource
dateReleased - the new release date of the changed resource, set it to CmsResource.TOUCH_DATE_UNCHANGED to keep it unchanged.
dateExpired - the new expire date of the changed resource. set it to CmsResource.TOUCH_DATE_UNCHANGED to keep it unchanged.
recursive - if this operation is to be applied recursivly to all resources in a folder
Throws:
CmsException - if something goes wrong

undeleteResource

public void undeleteResource(java.lang.String resourcename)
                      throws CmsException
Undeletes a resource (this is the same operation as "undo changes").

Only resources that have already been published once can be undeleted, if a "new" resource is deleted it can not be undeleted.

Internally, this method undos all changes to a resource by restoring the version from the online project, that is to the state of last publishing.

Parameters:
resourcename - the name of the resource to undelete (full path)
Throws:
CmsException - if something goes wrong
See Also:
undoChanges(String, boolean)

undoChanges

public void undoChanges(java.lang.String resourcename,
                        boolean recursive)
                 throws CmsException
Undos all changes to a resource by restoring the version from the online project to the current offline project.

Parameters:
resourcename - the name of the resource to undo the changes for (full path)
recursive - if this operation is to be applied recursivly to all resources in a folder
Throws:
CmsException - if something goes wrong

unlockProject

public void unlockProject(int id)
                   throws CmsException
Unlocks all resources of a project.

Parameters:
id - the id of the project to be unlocked
Throws:
CmsException - if operation was not successful

unlockResource

public void unlockResource(java.lang.String resourcename)
                    throws CmsException
Unlocks a resource.

Parameters:
resourcename - the name of the resource to unlock (full path)
Throws:
CmsException - if something goes wrong

userInGroup

public boolean userInGroup(java.lang.String username,
                           java.lang.String groupname)
                    throws CmsException
Tests if a user is member of the given group.

Parameters:
username - the name of the user to test
groupname - the name of the group to test
Returns:
true, if the user is in the group; or false otherwise
Throws:
CmsException - if operation was not successful

validateHtmlLinks

public java.util.Map validateHtmlLinks(CmsPublishList publishList,
                                       I_CmsReport report)
                                throws java.lang.Exception
Validates the HTML links in the unpublished files of the specified publish list, if a file resource type implements the interface I_CmsXmlDocumentLinkValidatable.

Parameters:
publishList - an OpenCms publish list
report - a report to write the messages to
Returns:
a map with lists of invalid links (String objects) keyed by resource names
Throws:
java.lang.Exception - if something goes wrong
See Also:
I_CmsXmlDocumentLinkValidatable

validatePassword

public void validatePassword(java.lang.String password)
                      throws CmsSecurityException
This method checks if a new password follows the rules for new passwords, which are defined by a Class implementing the I_CmsPasswordHandler interface and configured in the opencms.properties file.

If this method throws no exception the password is valid.

Parameters:
password - the new password that has to be checked
Throws:
CmsSecurityException - if the password is not valid

writeFile

public CmsFile writeFile(CmsFile resource)
                  throws CmsException
Writes a resource to the OpenCms VFS, including it's content.

Applies only to resources of type CmsFile i.e. resources that have a binary content attached.

Certain resource types might apply content validation or transformation rules before the resource is actually written to the VFS. The returned result might therefore be a modified version from the provided original.

Parameters:
resource - the resource to write
Returns:
the written resource (may have been modified)
Throws:
CmsException - if something goes wrong

writeFileHeader

public void writeFileHeader(CmsFile file)
                     throws CmsException
Writes a file-header.

Parameters:
file - the file to write
Throws:
CmsException - if resourcetype is set to folder, or if the user has not the rights to write the file header.

writeGroup

public void writeGroup(CmsGroup group)
                throws CmsException
Writes an already existing group.

The group id has to be a valid OpenCms group id.
The group with the given id will be completely overriden by the given data.

Parameters:
group - the group that should be written
Throws:
CmsException - if operation was not successful

writeProject

public void writeProject(CmsProject project)
                  throws CmsException
Writes an already existing project.

The project id has to be a valid OpenCms project id.
The project with the given id will be completely overriden by the given data.

Parameters:
project - the project that should be written
Throws:
CmsException - if operation was not successful

writeProperties

public void writeProperties(java.lang.String resourceName,
                            java.util.Map properties)
                     throws CmsException
Deprecated. use writePropertyObjects(String, List) instead.

Writes a couple of properties as structure values for a file or folder.

Parameters:
resourceName - the resource-name of which the Property has to be set
properties - a Hashtable with property-definitions and property values as Strings
Throws:
CmsException - if operation was not successful

writeProperties

public void writeProperties(java.lang.String name,
                            java.util.Map properties,
                            boolean addDefinition)
                     throws CmsException
Deprecated. use writePropertyObjects(String, List) instead.

Writes a couple of Properties for a file or folder.

Parameters:
name - the resource-name of which the Property has to be set
properties - a Hashtable with property-definitions and property values as Strings
addDefinition - flag to indicate if unknown definitions should be added
Throws:
CmsException - if operation was not successful

writeProperty

public void writeProperty(java.lang.String resourceName,
                          java.lang.String key,
                          java.lang.String value)
                   throws CmsException
Deprecated. use writePropertyObject(String, CmsProperty) instead.

Writes a property as a structure value for a file or folder.

Parameters:
resourceName - the resource-name for which the property will be set
key - the property definition name
value - the value for the property to be set
Throws:
CmsException - if operation was not successful

writeProperty

public void writeProperty(java.lang.String resourcename,
                          java.lang.String key,
                          java.lang.String value,
                          boolean addDefinition)
                   throws CmsException
Deprecated. use writePropertyObject(String, CmsProperty) instead.

Writes a property for a file or folder.

Parameters:
resourcename - the resource-name for which the property will be set
key - the property-definition name
value - the value for the property to be set
addDefinition - flag to indicate if unknown definitions should be added
Throws:
CmsException - if operation was not successful

writePropertyObject

public void writePropertyObject(java.lang.String resourcename,
                                CmsProperty property)
                         throws CmsException
Writes a property for a specified resource.

Parameters:
resourcename - the name of resource with complete path
property - the property to write
Throws:
CmsException - if something goes wrong

writePropertyObjects

public void writePropertyObjects(java.lang.String resourcename,
                                 java.util.List properties)
                          throws CmsException
Writes a list of properties for a specified resource.

Code calling this method has to ensure that the no properties a, b are contained in the specified list so that a.equals(b), otherwise an exception is thrown.

Parameters:
resourcename - the name of resource with complete path
properties - the list of properties to write
Throws:
CmsException - if something goes wrong

writeStaticExportPublishedResource

public void writeStaticExportPublishedResource(java.lang.String resourceName,
                                               int linkType,
                                               java.lang.String linkParameter,
                                               long timestamp)
                                        throws CmsException
Writes a published resource entry.

This is done during static export.

Parameters:
resourceName - The name of the resource to be added to the static export
linkType - the type of resource exported (0= non-paramter, 1=parameter)
linkParameter - the parameters added to the resource
timestamp - a timestamp for writing the data into the db
Throws:
CmsException - if something goes wrong

writeUser

public void writeUser(CmsUser user)
               throws CmsException
Updates the user information.

The user id has to be a valid OpenCms user id.
The user with the given id will be completely overriden by the given data.

Parameters:
user - the user to be written
Throws:
CmsException - if operation was not successful

writeWebUser

public void writeWebUser(CmsUser user)
                  throws CmsException
Updates the user information of a web user.
Only a web user can be updated this way.

The user id has to be a valid OpenCms user id.
The user with the given id will be completely overriden by the given data.

Parameters:
user - the user to be written
Throws:
CmsException - if operation was not successful