Class 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
    • 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 authentication
    • Method Detail

      • addRelationToResource

        public void addRelationToResource​(CmsResource resource,
                                          CmsResource target,
                                          java.lang.String type)
                                   throws CmsException
        Adds a new relation to the given resource.

        Parameters:
        resource - the source resource
        target - the target resource
        type - the type of the relation
        Throws:
        CmsException - if something goes wrong
      • addRelationToResource

        public void addRelationToResource​(java.lang.String resourceName,
                                          java.lang.String targetPath,
                                          java.lang.String type)
                                   throws CmsException
        Adds a new relation to the given resource.

        Parameters:
        resourceName - the name of the source resource
        targetPath - the path of the target resource
        type - the type of the relation
        Throws:
        CmsException - if something goes wrong
      • addSiteRoot

        public java.lang.String addSiteRoot​(java.lang.String resourcename)
        Convenience method to add the site root from the current user's request context to the given resource name.

        Parameters:
        resourcename - the resource name
        Returns:
        the resource name with the site root added
        See Also:
        CmsRequestContext.addSiteRoot(String)
      • 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
      • adjustLinks

        public void adjustLinks​(java.util.List<java.lang.String> sourceFiles,
                                java.lang.String targetParentFolder)
                         throws CmsException
        This method works just like adjustLinks(String, String), but you can specify multiple source files, and the target folder is interpreted as the folder into which the source files have been copied.

        Parameters:
        sourceFiles - the list of source files
        targetParentFolder - the folder into which the source files have been copied
        Throws:
        CmsException - if something goes wrong
      • adjustLinks

        public void adjustLinks​(java.util.Map<java.lang.String,​java.lang.String> sourceTargetMap,
                                java.lang.String targetParentFolder)
                         throws CmsException
        This method works just like adjustLinks(String, String), but instead of specifying a single source and target folder, you can specify multiple sources and the corresponding targets in a map of strings.
        Parameters:
        sourceTargetMap - a map with the source files as keys and the corresponding targets as values
        targetParentFolder - the folder into which the source files have been copied
        Throws:
        CmsException - if something goes wrong
      • adjustLinks

        public void adjustLinks​(java.lang.String sourceFolder,
                                java.lang.String targetFolder)
                         throws CmsException
        Adjusts all links in the target folder that point to the source folder so that they are kept "relative" in the target folder where possible. If a link is found from the target folder to the source folder, then the target folder is checked if a target of the same name is found also "relative" inside the target Folder, and if so, the link is changed to that "relative" target. This is mainly used to keep relative links inside a copied folder structure intact. Example: Image we have folder /folderA/ that contains files /folderA/x1 and /folderA/y1. x1 has a link to y1 and y1 to x1. Now someone copies /folderA/ to /folderB/. So we end up with /folderB/x2 and /folderB/y2. Because of the link mechanism in OpenCms, x2 will have a link to y1 and y2 to x1. By using this method, the links from x2 to y1 will be replaced by a link x2 to y2, and y2 to x1 with y2 to x2. Link replacement works for links in XML files as well as relation only type links.
        Parameters:
        sourceFolder - the source folder
        targetFolder - the target folder
        Throws:
        CmsException - if something goes wrong
      • 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 - bit set of allowed permissions
        deniedPermissions - bit set 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
      • changeLock

        public void changeLock​(CmsResource resource)
                        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:
        resource - the resource to change the lock
        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<CmsResourcechangeResourcesInFolderWithProperty​(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
      • checkLoginUser

        public void checkLoginUser​(java.lang.String userName,
                                   java.lang.String password)
                            throws CmsException
        Checks if a login for the given user name and password would work without taking two-factor authentication into account. If this succeeds, it does not actually log the CmsObject in. But if it fails, it throws an exception and increments the failed login counter for the given user.
        Parameters:
        userName - the user name to check
        password - the password to check
        Throws:
        CmsException - if the login check fails
      • 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 current site relative path)
        flags - the new flags for this resource
        Throws:
        CmsException - if something goes wrong
      • chtype

        public void chtype​(CmsResource resource,
                           I_CmsResourceType 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:
        resource - the resource whose type should be changed
        type - the new resource type for this resource
        Throws:
        CmsException - if something goes wrong
      • chtype

        public void chtype​(java.lang.String resourcename,
                           I_CmsResourceType 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 current site relative path)
        type - the new resource type for this resource
        Throws:
        CmsException - if something goes wrong
      • chtype

        @Deprecated
        public void chtype​(java.lang.String resourcename,
                           int type)
                    throws CmsException
        Deprecated.
        Use chtype(String, I_CmsResourceType) instead. Resource types should always be referenced either by its type class (preferred) or by type name. Use of int based resource type references will be discontinued in a future OpenCms release.
        Changes the resource type of a resource.

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

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

        public void copyResourceToProject​(CmsResource resource)
                                   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:
        resource - the resource to copy to the current project
        Throws:
        CmsException - if something goes wrong
      • 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 current site relative path)
        Throws:
        CmsException - if something goes wrong
      • countLockedResources

        public int countLockedResources​(CmsUUID 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
      • 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 groupFqn,
                                    java.lang.String description,
                                    int flags,
                                    java.lang.String parent)
                             throws CmsException
        Creates a new user group.

        Parameters:
        groupFqn - 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,
                                        CmsProject.CmsProjectType 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 sitePath,
                                          CmsResource resource,
                                          byte[] content,
                                          java.util.List<CmsProperty> properties)
                                   throws CmsException
        Creates a resource with the given properties and content. Will throw an exception, if a resource with the given name already exists.

        Parameters:
        sitePath - the site path for the resource
        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
      • createResource

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

        Parameters:
        resourcename - the name of the resource to create (full current site relative path)
        type - the type of the resource to 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
      • createResource

        @Deprecated
        public CmsResource createResource​(java.lang.String resourcename,
                                          int type,
                                          byte[] content,
                                          java.util.List<CmsProperty> properties)
                                   throws CmsException,
                                          CmsIllegalArgumentException
        Deprecated.
        Use createResource(String, I_CmsResourceType, byte[], List) instead. Resource types should always be referenced either by its type class (preferred) or by type name. Use of int based resource type references will be discontinued in a future OpenCms release.
        Creates a new resource of the given resource type with the provided content and properties.

        Parameters:
        resourcename - the name of the resource to create (full current site relative path)
        type - the type of the resource to 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 CmsResource createSibling​(java.lang.String source,
                                         java.lang.String destination,
                                         java.util.List<CmsProperty> properties)
                                  throws CmsException
        Creates a new sibling of the source resource.

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

        public CmsUser createUser​(java.lang.String userFqn,
                                  java.lang.String password,
                                  java.lang.String description,
                                  java.util.Map<java.lang.String,​java.lang.Object> additionalInfos)
                           throws CmsException
        Creates a new user.

        Parameters:
        userFqn - 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
      • deleteGroup

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

        Parameters:
        groupId - the id of the group to be 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 group)
                         throws CmsException
        Deletes a user group.

        Only groups that contain no subgroups can be deleted.

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

        public void deleteHistoricalVersions​(int versionsToKeep,
                                             int versionsDeleted,
                                             long timeDeleted,
                                             I_CmsReport report)
                                      throws CmsException
        Deletes the versions from the history tables, keeping the given number of versions per resource.

        Parameters:
        versionsToKeep - number of versions to keep, is ignored if negative
        versionsDeleted - number of versions to keep for deleted resources, is ignored if negative
        timeDeleted - deleted resources older than this will also be deleted, is ignored if negative
        report - the report for output logging
        Throws:
        CmsException - if operation was not successful
      • deleteProject

        public void deleteProject​(CmsUUID 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
      • 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
      • deleteRelationsFromResource

        public void deleteRelationsFromResource​(java.lang.String resourceName,
                                                CmsRelationFilter filter)
                                         throws CmsException
        Deletes the relations to a given resource.

        Parameters:
        resourceName - the resource to delete the relations from
        filter - the filter to use for deleting the relations
        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-parameter, 1=parameter)
        linkParameter - the parameters of the resource
        Throws:
        CmsException - if something goes wrong
      • 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
      • existsResource

        public boolean existsResource​(CmsUUID structureId,
                                      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:
        structureId - the structure id of the resource to check
        filter - the resource filter to use while checking
        Returns:
        true if the resource is available
        See Also:
        readResource(CmsUUID), readResource(CmsUUID, CmsResourceFilter)
      • 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 current site relative 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 provided 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 current site relative 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<CmsAccessControlEntrygetAccessControlEntries​(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
      • getAllUrlNames

        public java.util.List<java.lang.String> getAllUrlNames​(CmsUUID id)
                                                        throws CmsException
        Gets all URL names for a given structure id.

        Parameters:
        id - the structure id
        Returns:
        the list of all URL names for that structure id
        Throws:
        CmsException - if something goes wrong
      • getBlockingLockedResources

        public java.util.List<CmsResourcegetBlockingLockedResources​(CmsResource resource)
                                                               throws CmsException
        Returns a list of child resources to the given resource that can not be locked by the current user.

        Parameters:
        resource - the resource
        Returns:
        a list of child resources to the given resource that can not be locked by the current user
        Throws:
        CmsException - if something goes wrong reading the resources
      • getBlockingLockedResources

        public java.util.List<CmsResourcegetBlockingLockedResources​(java.lang.String resourceName)
                                                               throws CmsException
        Returns a list of child resources to the given resource that can not be locked by the current user.

        Parameters:
        resourceName - the resource site path
        Returns:
        a list of child resources to the given resource that can not be locked by the current user
        Throws:
        CmsException - if something goes wrong reading the resources
      • getChildren

        public java.util.List<CmsGroupgetChildren​(java.lang.String groupname,
                                                    boolean includeSubChildren)
                                             throws CmsException
        Returns all child groups of a group.

        Parameters:
        groupname - the name of the group
        includeSubChildren - if set also returns all sub-child groups of the given group
        Returns:
        a list of all child CmsGroup objects or null
        Throws:
        CmsException - if operation was not successful
      • getDetailName

        public java.lang.String getDetailName​(CmsResource res,
                                              java.util.Locale locale,
                                              java.util.List<java.util.Locale> defaultLocales)
                                       throws CmsException
        Returns the detail name of a resource.

        The detail view URI of a content element consists of its detail page URI and the detail name returned by this method.

        Parameters:
        res - the resource for which the detail name should be retrieved
        locale - the locale for the detail name
        defaultLocales - the default locales for the detail name
        Returns:
        the detail name
        Throws:
        CmsException - if something goes wrong
      • getFilesInFolder

        public java.util.List<CmsResourcegetFilesInFolder​(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 as CmsResource objects
        Throws:
        CmsException - if something goes wrong
      • getGroupsOfUser

        public java.util.List<CmsGroupgetGroupsOfUser​(java.lang.String username,
                                                        boolean directGroupsOnly)
                                                 throws CmsException
        Returns all the groups the given user belongs to.

        Parameters:
        username - the name of the user
        directGroupsOnly - if set only the direct assigned groups will be returned, if not also indirect roles
        Returns:
        a list of CmsGroup objects
        Throws:
        CmsException - if operation was not successful
      • getGroupsOfUser

        public java.util.List<CmsGroupgetGroupsOfUser​(java.lang.String username,
                                                        boolean directGroupsOnly,
                                                        boolean includeOtherOus)
                                                 throws CmsException
        Returns all the groups the given user belongs to.

        Parameters:
        username - the name of the user
        directGroupsOnly - if set only the direct assigned groups will be returned, if not also indirect roles
        includeOtherOus - if to include groups of other organizational units
        Returns:
        a list of CmsGroup objects
        Throws:
        CmsException - if operation was not successful
      • getGroupsOfUser

        public java.util.List<CmsGroupgetGroupsOfUser​(java.lang.String username,
                                                        boolean directGroupsOnly,
                                                        boolean includeOtherOus,
                                                        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
        directGroupsOnly - if set only the direct assigned groups will be returned, if not also indirect roles
        remoteAddress - the IP address to filter the groups in the result list
        includeOtherOus - if to include groups of other organizational units
        Returns:
        a list of CmsGroup objects filtered by the specified IP address
        Throws:
        CmsException - if operation was not successful
      • getLock

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

        If the resource is waiting to be publish you might get a lock of type CmsLockType.PUBLISH.

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

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

        If the resource is waiting to be publish you might get a lock of type CmsLockType.PUBLISH.

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

        public java.util.List<CmsResourcegetLockedResources​(CmsResource resource,
                                                              CmsLockFilter filter)
                                                       throws CmsException
        Returns all locked resources within a folder or matches the lock of the given resource.

        Parameters:
        resource - the resource to check
        filter - the lock filter
        Returns:
        a list of locked resources
        Throws:
        CmsException - if operation was not successful
      • getLockedResources

        public java.util.List<java.lang.String> getLockedResources​(java.lang.String resourceName,
                                                                   CmsLockFilter filter)
                                                            throws CmsException
        Returns all locked resources within a folder or matches the lock of the given resource.

        Parameters:
        resourceName - the name of the resource to check
        filter - the lock filter
        Returns:
        a list of locked resource paths (relative to current site)
        Throws:
        CmsException - if operation was not successful
      • getLockedResourcesWithCache

        public java.util.List<CmsResourcegetLockedResourcesWithCache​(CmsResource resource,
                                                                       CmsLockFilter filter,
                                                                       java.util.Map<java.lang.String,​CmsResource> cache)
                                                                throws CmsException
        Returns all locked resources within a folder or matches the lock of the given resource, but uses a cache for resource lookup.

        Parameters:
        resource - the resource to check
        filter - the lock filter
        cache - the cache to use for resource lookups
        Returns:
        a list of locked resources
        Throws:
        CmsException - if operation was not successful
      • 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 current site relative path)
        Returns:
        the tentative name of the resource inside the "lost and found" folder
        Throws:
        CmsException - if something goes wrong
        See Also:
        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 bit set 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
      • 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.Set<CmsResourcegetResourcesForPrincipal​(CmsUUID principalId,
                                                                   CmsPermissionSet permissions,
                                                                   boolean includeAttr)
                                                            throws CmsException
        Returns all resources associated to a given principal via an ACE with the given permissions.

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

        • User Created
        • User Last Modified

        Parameters:
        principalId - the id of the 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 set of CmsResource objects
        Throws:
        CmsException - if something goes wrong
      • getResourcesInFolder

        public java.util.List<CmsResourcegetResourcesInFolder​(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 current site relative path of the resource to return the child resources for
        filter - the resource filter to use
        Returns:
        a list of all child CmsResources
        Throws:
        CmsException - if something goes wrong
      • getSubFolders

        public java.util.List<CmsResourcegetSubFolders​(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 current site relative path of the resource to return the child resources for.
        filter - the resource filter to use
        Returns:
        a list of all child folder CmsResources
        Throws:
        CmsException - if something goes wrong
      • getUrlNamesForAllLocales

        public java.util.List<java.lang.String> getUrlNamesForAllLocales​(CmsUUID id)
                                                                  throws CmsException
        Returns the newest URL names for the given structure id for each locale.

        Parameters:
        id - the structure id
        Returns:
        the list of URL names for each locale
        Throws:
        CmsException - if something goes wrong
      • getUsersOfGroup

        public java.util.List<CmsUsergetUsersOfGroup​(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
      • getUsersOfGroup

        public java.util.List<CmsUsergetUsersOfGroup​(java.lang.String groupname,
                                                       boolean includeOtherOus)
                                                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
        includeOtherOus - if the result should include users of other ous
        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 the lock status of the resource is checked for write operations and the resource needs be locked by the current user so that the test is passed, if false the lock is not checked at all
        filter - the resource filter to use
        Returns:
        true if the required permissions are satisfied
        Throws:
        CmsException - if something goes wrong
      • importRelation

        public void importRelation​(java.lang.String resourceName,
                                   java.lang.String targetPath,
                                   java.lang.String relationType)
                            throws CmsException
        Imports a new relation to the given resource.

        Parameters:
        resourceName - the name of the source resource
        targetPath - the path of the target resource
        relationType - the type of the relation
        Throws:
        CmsException - if something goes wrong
      • importResource

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

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

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

        Parameters:
        resourcename - the name for the resource after import (full current site relative path)
        resource - the resource object to be 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)
      • importResource

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

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

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

        Parameters:
        resourcename - the name for the resource after import (full current site relative path)
        report - optional report to write non-critical errors to (may be null)
        resource - the resource object to be 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 firstname,
                                  java.lang.String lastname,
                                  java.lang.String email,
                                  int flags,
                                  long dateCreated,
                                  java.util.Map<java.lang.String,​java.lang.Object> additionalInfos)
                           throws CmsException
        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
        firstname - the first name of the user
        lastname - the last name of the user
        email - the email of the user
        flags - the flags for a user (for example I_CmsPrincipal.FLAG_ENABLED)
        dateCreated - the creation date
        additionalInfos - the additional user infos
        Returns:
        the imported user
        Throws:
        CmsException - if something goes wrong
      • incrementCounter

        public int incrementCounter​(java.lang.String name)
                             throws CmsException
        Increments a counter and returns its old value.

        Parameters:
        name - the name of the counter
        Returns:
        the value of the counter before incrementing
        Throws:
        CmsException - if something goes wrong
      • isInsideCurrentProject

        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 current site relative 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​(CmsResource resource)
                          throws CmsException
        Locks a resource.

        This will be an exclusive, persistent lock that is removed only if the user unlocks it.

        Parameters:
        resource - the resource to lock
        Throws:
        CmsException - if something goes wrong
      • lockResource

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

        This will be an exclusive, persistent lock that is removed only if the user unlocks it.

        Parameters:
        resourcename - the name of the resource to lock (full current site relative path)
        Throws:
        CmsException - if something goes wrong
      • lockResourceShallow

        public void lockResourceShallow​(CmsResource resource)
                                 throws CmsException
        Locks the given resource with a shallow lock that is not inherited on subresources.

        Shallow locks are non-persistent, like temporary locks.

        Parameters:
        resource - the resource to lock
        Throws:
        CmsException - if something goes wrong
      • lockResourceTemporary

        public void lockResourceTemporary​(CmsResource resource)
                                   throws CmsException
        Locks a resource temporary.

        This will be an exclusive, temporary lock valid only for the current users session. Usually this should not be used directly, this method is intended for the OpenCms workplace only.

        Parameters:
        resource - the resource to lock
        Throws:
        CmsException - if something goes wrong
        See Also:
        lockResource(String)
      • lockResourceTemporary

        public void lockResourceTemporary​(java.lang.String resourcename)
                                   throws CmsException
        Locks a resource temporary.

        This will be an exclusive, temporary lock valid only for the current users session. Usually this should not be used directly, this method is intended for the OpenCms workplace only.

        Parameters:
        resourcename - the name of the resource to lock (full current site relative path)
        Throws:
        CmsException - if something goes wrong
        See Also:
        lockResource(String)
      • 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,
                                          CmsSecondFactorInfo code)
                                   throws CmsException
        Logs in the user.
        Parameters:
        username - the user name
        password - the password
        code - the second factor information for 2FA
        Returns:
        the logged in user
        Throws:
        CmsException - if something goes wrong
      • loginUser

        public java.lang.String loginUser​(java.lang.String username,
                                          java.lang.String password,
                                          CmsSecondFactorInfo code,
                                          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
        code - the second factor information for 2FA
        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)
                                   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
      • 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 current site relative path)
        destination - the destination resource name (full current site relative 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 current site relative path)
        Returns:
        the name of the resource inside the "lost and found" folder
        Throws:
        CmsException - if something goes wrong
        See Also:
        getLostAndFoundName(String)
      • readAllAvailableVersions

        public java.util.List<I_CmsHistoryResourcereadAllAvailableVersions​(java.lang.String resourceName)
                                                                      throws CmsException
        Reads all historical versions of a resource.
        The reading excludes the file content, if the resource is a file.

        Parameters:
        resourceName - the name of the resource to be read
        Returns:
        a list of historical resources, as I_CmsHistoryResource objects
        Throws:
        CmsException - if operation was not successful
      • 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 current site relative path)
        filter - the resource filter to match while reading the ancestors
        Returns:
        the first ancestor folder matching the filter criteria or null if no folder was found
        Throws:
        CmsException - if something goes wrong
      • readAncestor

        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 current site relative path)
        type - the resource type of the folder to match
        Returns:
        the first ancestor folder matching the filter criteria or null if no folder was found
        Throws:
        CmsException - if something goes wrong
      • readBestUrlName

        public java.lang.String readBestUrlName​(CmsUUID id,
                                                java.util.Locale locale,
                                                java.util.List<java.util.Locale> defaultLocales)
                                         throws CmsException
        Reads the newest URL name which is mapped to the given structure id.

        If the structure id is not mapped to any name, null will be returned.

        Parameters:
        id - the structure id for which the newest mapped name should be returned
        locale - the locale for which the URL name should be selected if possible
        defaultLocales - the default locales which should be used if the locale is not available
        Returns:
        an URL name or null
        Throws:
        CmsException - if something goes wrong
      • readDefaultFile

        public CmsResource readDefaultFile​(java.lang.String resourceNameOrID)
                                    throws CmsException,
                                           CmsSecurityException
        Returns the default resource for the given folder.

        If the given resource name or id identifies a file, then this file is returned.

        Otherwise, in case of a folder:

        1. the CmsPropertyDefinition.PROPERTY_DEFAULT_FILE is checked, and
        2. if still no file could be found, the configured default files in the opencms-vfs.xml configuration are iterated until a match is found, and
        3. if still no file could be found, null is returned
        Parameters:
        resourceNameOrID - the name or id of the folder to read the default file for
        Returns:
        the default file for the given folder
        Throws:
        CmsException - if something goes wrong
        CmsSecurityException - if the user has no permissions to read the resulting file
      • readDefaultFile

        public CmsResource readDefaultFile​(java.lang.String resourceNameOrID,
                                           CmsResourceFilter filter)
                                    throws CmsException,
                                           CmsSecurityException
        Returns the default resource for the given folder.

        If the given resource name or id identifies a file, then this file is returned.

        Otherwise, in case of a folder:

        1. the CmsPropertyDefinition.PROPERTY_DEFAULT_FILE is checked, and
        2. if still no file could be found, the configured default files in the opencms-vfs.xml configuration are iterated until a match is found, and
        3. if still no file could be found, null is returned
        Parameters:
        resourceNameOrID - the name or id of the folder to read the default file for#
        filter - the resource filter to use for reading the resources
        Returns:
        the default file for the given folder
        Throws:
        CmsException - if something goes wrong
        CmsSecurityException - if the user has no permissions to read the resulting file
      • 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 current site relative path)
        filter - the resource filter to use while reading
        Returns:
        the folder resource that was read
        Throws:
        CmsException - if the resource could not be read for any reason
        See Also:
        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​(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
      • readHistoryProject

        public CmsHistoryProject readHistoryProject​(int publishTag)
                                             throws CmsException
        Returns a historical project entry.

        Parameters:
        publishTag - publish tag of the project
        Returns:
        the requested historical project entry
        Throws:
        CmsException - if operation was not successful
      • readIdForUrlName

        public CmsUUID readIdForUrlName​(java.lang.String name)
                                 throws CmsException
        This method retrieves the structure id which is mapped to a given URL name.

        If there is no structure id mapped to the given name, null will be returned.

        However if the parameter is a string which represents a valid uuid, it will be directly returned as a CmsUUID instance.

        Parameters:
        name - the url name
        Returns:
        the id which is mapped to the URL name
        Throws:
        CmsException - if something goes wrong
      • readManagerGroup

        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<CmsResourcereadPath​(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​(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<java.lang.String> 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 (root paths), as String objects that define the "view" of the given project
        Throws:
        CmsException - if something goes wrong
      • 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
        Throws:
        CmsException - a CmsDbEntryNotFoundException is thrown if the property definition does not exist
      • 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​(CmsResource resource,
                                              java.lang.String property,
                                              boolean search,
                                              java.util.Locale locale)
                                       throws CmsException
        Reads the locale specific version of 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
        locale - the locale for which the property should be read.
        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
      • readPropertyObject

        public CmsProperty readPropertyObject​(java.lang.String resourcePath,
                                              java.lang.String property,
                                              boolean search,
                                              java.util.Locale locale)
                                       throws CmsException
        Reads the locale specific version of 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
        locale - the locale for which the property should be read.
        Returns:
        the required property, or CmsProperty.getNullProperty() if the property was not found
        Throws:
        CmsException - if something goes wrong
      • readPropertyObjects

        public java.util.List<CmsPropertyreadPropertyObjects​(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 different value, the result list will contain only the property with the value from the resource, not form the parent folder(s).

        Parameters:
        resource - the resource where the property is mapped 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<CmsPropertyreadPropertyObjects​(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 different value, the result list will contain only the property with the value from the resource, not form the parent folder(s).

        Parameters:
        resourcePath - the name of resource where the property is mapped 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
      • readResource

        public CmsResource readResource​(CmsUUID structureID,
                                        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 absolutely required. To "upgrade" a resource to a file, use readFile(CmsResource).

        The specified filter controls what kind of resources should be "found" during the read operation. This will depend on the application. For example, using 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:
        structureID - the structure ID of the resource to read
        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)
      • readResource

        public I_CmsHistoryResource readResource​(CmsUUID structureID,
                                                 int version)
                                          throws CmsException,
                                                 CmsVfsResourceNotFoundException
        Reads the historical resource with the given version for the resource given the given structure id.

        A resource may be of type 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 readFile(CmsResource).

        Please note that historical versions are just generated during publishing, so the first version with version number 1 is generated during publishing of a new resource (exception is a new sibling, that may also contain some relevant versions of already published siblings) and the last version available is the version of the current online resource.

        Parameters:
        structureID - the structure ID of the resource to read
        version - the version number you want to retrieve
        Returns:
        the resource that was read
        Throws:
        CmsException - if the resource could not be read for any reason
        CmsVfsResourceNotFoundException - if the version does not exists
        See Also:
        restoreResourceVersion(CmsUUID, int)
      • 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 absolutely required. To "upgrade" a resource to a file, use readFile(CmsResource).

        The specified filter controls what kind of resources should be "found" during the read operation. This will depend on the application. For example, using 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 current site relative path)
        filter - the resource filter to use while reading
        Returns:
        the resource that was read
        Throws:
        CmsException - if the resource could not be read for any reason
        See Also:
        readFile(String, CmsResourceFilter), readFolder(String, CmsResourceFilter)
      • readResources

        public java.util.List<CmsResourcereadResources​(CmsResource resource,
                                                         CmsResourceFilter filter,
                                                         boolean readTree)
                                                  throws CmsException
        Reads all resources below the given resource matching the filter criteria, including the full tree below the path only in case the readTree parameter is true.

        Parameters:
        resource - the parent resource
        filter - the filter
        readTree - true to read all sub resources
        Returns:
        a list of CmsResource objects matching the filter criteria
        Throws:
        CmsException - if something goes wrong
      • readResources

        public java.util.List<CmsResourcereadResources​(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 sub resources
        Returns:
        a list of CmsResource objects matching the filter criteria
        Throws:
        CmsException - if something goes wrong
      • readResourcesWithProperty

        public java.util.List<CmsResourcereadResourcesWithProperty​(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.

        Will use the CmsResourceFilter.ALL resource filter.

        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<CmsResourcereadResourcesWithProperty​(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.

        Will use the CmsResourceFilter.ALL resource filter.

        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<CmsResourcereadResourcesWithProperty​(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.

        If the value parameter is null, all resources having the given property set are returned.

        Will use the CmsResourceFilter.ALL resource filter.

        Parameters:
        path - the folder to get the resources with the property 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
      • readResourcesWithProperty

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

        Both individual and shared properties of a resource are checked.

        If the value parameter is null, all resources having the given property set are returned.

        Will use the given resource filter.

        Parameters:
        path - the folder to get the resources with the property from
        propertyDefinition - the name of the property to check for
        value - the string to search in the value of the property
        filter - the resource filter to apply to the result set
        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<I_CmsPrincipalreadResponsiblePrincipals​(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<CmsUserreadResponsibleUsers​(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<CmsResourcereadSiblings​(CmsResource resource,
                                                        CmsResourceFilter filter)
                                                 throws CmsException
        Returns a list of all siblings of the specified resource, the specified resource being always part of the result set.

        Parameters:
        resource - the 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
      • readSiblings

        public java.util.List<CmsResourcereadSiblings​(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
      • readSiblingsForResourceId

        public java.util.List<CmsResourcereadSiblingsForResourceId​(CmsUUID resourceId,
                                                                     CmsResourceFilter filter)
                                                              throws CmsException
        Reads all resources with the given resource id.

        Parameters:
        resourceId - the resource id for which we want the siblings
        filter - the resource filter used to read the resources
        Returns:
        the siblings which share the given resource id
        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<java.lang.String> readStaticExportResources​(int parameterResources,
                                                                          long timestamp)
                                                                   throws CmsException
        Returns a list of all template resources which must be processed during a static export.

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

        public java.util.List<java.lang.String> readUrlNamesForAllLocales​(CmsUUID structureId)
                                                                   throws CmsException
        Reads the URL names for all locales.

        Parameters:
        structureId - the id of resource for which the URL names should be read
        Returns:
        returns the URL names for the resource
        Throws:
        CmsException - if something goes wrong
      • readUser

        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 something goes wrong
      • 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
      • 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 current site relative 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 current site relative 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,
                                    I_CmsResourceType type,
                                    byte[] content,
                                    java.util.List<CmsProperty> properties)
                             throws CmsException
        Replaces the content, type and properties of a resource.

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

        @Deprecated
        public void replaceResource​(java.lang.String resourcename,
                                    int type,
                                    byte[] content,
                                    java.util.List<CmsProperty> properties)
                             throws CmsException
        Deprecated.
        Use replaceResource(String, I_CmsResourceType, byte[], List) instead. Resource types should always be referenced either by its type class (preferred) or by type name. Use of int based resource type references will be discontinued in a future OpenCms release.
        Replaces the content, type and properties of a resource.

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

        public void restoreResourceVersion​(CmsUUID structureId,
                                           int version)
                                    throws CmsException
        Restores a resource in the current project with a version from the historical archive.

        Parameters:
        structureId - the structure id of the resource to restore from the archive
        version - the desired version of the resource to be restored
        Throws:
        CmsException - if something goes wrong
        See Also:
        readResource(CmsUUID, int)
      • 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 given 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​(CmsResource resource,
                                   long dateExpired,
                                   boolean recursive)
                            throws CmsException
        Changes the "expire" date of a resource.

        Parameters:
        resource - the resource to change
        dateExpired - the new expire date of the changed resource
        recursive - if this operation is to be applied recursively to all resources in a folder
        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 current site relative path)
        dateExpired - the new expire date of the changed resource
        recursive - if this operation is to be applied recursively 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" time stamp of a resource.

        Parameters:
        resourcename - the name of the resource to change (full current site relative path)
        dateLastModified - time stamp the new time stamp of the changed resource
        recursive - if this operation is to be applied recursively to all resources in a folder
        Throws:
        CmsException - if something goes wrong
      • setDateReleased

        public void setDateReleased​(CmsResource resource,
                                    long dateReleased,
                                    boolean recursive)
                             throws CmsException
        Changes the "release" date of a resource.

        Parameters:
        resource - the resource to change
        dateReleased - the new release date of the changed resource
        recursive - if this operation is to be applied recursively 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 current site relative path)
        dateReleased - the new release date of the changed resource
        recursive - if this operation is to be applied recursively 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 successful
      • 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,
                                CmsSecondFactorInfo secondFactor,
                                java.lang.String newPassword)
                         throws CmsException
        Sets the password for a specified user.

        Parameters:
        username - the name of the user
        oldPassword - the old password
        secondFactor - the second factor information for 2FA
        newPassword - the new password
        Throws:
        CmsException - if the user data could not be read from the database
      • 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
      • tempChangeSiteRoot

        public java.lang.AutoCloseable tempChangeSiteRoot​(java.lang.String siteRoot)
        Helper method to temporarily change the site root in a try-with-resources statement.
        Parameters:
        siteRoot - the site root to switch to
        Returns:
        an AutoCloseable that restores the original site root when closed
      • undeleteResource

        public void undeleteResource​(java.lang.String resourcename,
                                     boolean recursive)
                              throws CmsException
        Undeletes a resource.

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

        Parameters:
        resourcename - the name of the resource to undelete
        recursive - if this operation is to be applied recursively to all resources in a folder
        Throws:
        CmsException - if something goes wrong
        See Also:
        undoChanges(String, CmsResource.CmsResourceUndoMode)
      • unlockProject

        public void unlockProject​(CmsUUID 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 current site relative 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
      • 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
      • writeGroup

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

        The group has to be a valid OpenCms group.
        The group will be completely overridden by the given data.

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

        public void writeHistoryProject​(int publishTag,
                                        long publishDate)
                                 throws CmsException
        Creates a historical entry of the current project.

        Parameters:
        publishTag - the correlative publish tag
        publishDate - the date of publishing
        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 overridden by the given data.

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

        public void writeProjectLastModified​(CmsResource resource,
                                             CmsProject project)
                                      throws CmsException
        Writes the 'projectlastmodified' field of a resource record.

        Parameters:
        resource - the resource which should be modified
        project - the project whose id should be written into the resource record
        Throws:
        CmsException - if something goes wrong
      • 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​(CmsResource res,
                                         java.util.List<CmsProperty> properties)
                                  throws CmsException
        Writes a list of properties for a specified resource.

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

        Parameters:
        res - the resource
        properties - the list of properties to write
        Throws:
        CmsException - if something goes wrong
      • writePropertyObjects

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

        Code calling this method has to ensure that the no properties a, b are contained in the specified list so 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
      • writeResource

        public void writeResource​(CmsResource resource)
                           throws CmsException
        Writes a resource.

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

        public void writeStaticExportPublishedResource​(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-parameter, 1=parameter)
        linkParameter - the parameters added to the resource
        timestamp - a time stamp for writing the data into the db
        Throws:
        CmsException - if something goes wrong
      • writeUrlNameMapping

        public java.lang.String writeUrlNameMapping​(java.util.Iterator<java.lang.String> nameSeq,
                                                    CmsUUID structureId,
                                                    java.lang.String locale,
                                                    boolean replaceOnPublish)
                                             throws CmsException
        Writes a new URL name mapping for a given resource.

        The first name from the given name sequence which is not already mapped to another resource will be used for the URL name mapping.

        Parameters:
        nameSeq - an iterator for generating names for the mapping
        structureId - the structure id to which the name should be mapped
        locale - the locale of the mapping
        replaceOnPublish - if the mapping should replace previous mappings when published
        Returns:
        the name which was actually mapped to the structure id
        Throws:
        CmsException - if something goes wrong
      • writeUrlNameMapping

        public java.lang.String writeUrlNameMapping​(java.lang.String name,
                                                    CmsUUID structureId,
                                                    java.lang.String locale,
                                                    boolean replaceOnPublish)
                                             throws CmsException
        Writes a new URL name mapping for a given resource.

        This method uses CmsNumberSuffixNameSequence to generate a sequence of name candidates from the given base name.

        Parameters:
        name - the base name for the mapping
        structureId - the structure id to which the name should be mapped
        locale - the locale of the mapping
        replaceOnPublish - mappings for which this is set will replace older mappings on publish
        Returns:
        the URL name that was actually used for the mapping
        Throws:
        CmsException - if something goes wrong
      • writeUser

        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