Interface RepositoryService


  • public interface RepositoryService
    A service to manage resources in the repository.

    A repository file is typically modified by checking it out into a user's workspace, modifying the file in the workspace, and then checking the modified files into the repository.

    The repository file can be versioned or unversioned.

    When an unversioned file is updated, its content is replaced by the new content. When a versioned file is updated, a new version of the file is created with the new version number that is specified by RepositoryCheckinSpecification. RepositoryCheckinSpecification specifies that the major or minor number field is incremented or specifies the exact version label to use for the update. New version number must always be an increase of the previous number.

    Since:
    1.1
    • Method Detail

      • createFolder

        RepositoryFolder createFolder​(java.lang.String path,
                                      boolean createParentFolders)
                               throws RepositoryItemNotFoundException,
                                      RepositoryItemExistsException
        Creates a folder in the repository.
        Parameters:
        path - The path to the folder to create.
        createParentFolders - Indicates whether the parent folders are automatically created during the operation. This does NOT include creating contexts, only folders.
        Returns:
        The created folder.
        Throws:
        RepositoryItemNotFoundException - Thrown when createParentContainers is set to false and a parent container does NOT exist.
        RepositoryItemExistsException - Thrown when an object exists in the repository at the specified path.
      • createFile

        RepositoryFile createFile​(java.lang.String path,
                                  java.lang.String localFilePath,
                                  java.lang.String comment,
                                  boolean createParentFolders)
                           throws RepositoryItemNotFoundException,
                                  RepositoryItemExistsException,
                                  java.io.IOException
        Creates an unversioned file in the repository.
        Parameters:
        path - The path to the unversioned file.
        localFilePath - The local file path with the contents for the new repository file.
        comment - The comment about the unversioned file.
        createParentFolders - Indicates whether the missing parent containers are automatically created during the operation. This does NOT include creating contexts, only folders.
        Returns:
        The created unversioned repository file.
        Throws:
        RepositoryItemNotFoundException - Thrown when createParentContainers is set to false and a parent container does NOT exist.
        RepositoryItemExistsException - Thrown when an object exists at the specified path.
        java.io.IOException - Thrown when there is a problem streaming the file contents.
      • createVersionedFile

        RepositoryFile createVersionedFile​(java.lang.String path,
                                           java.lang.String localFilePath,
                                           java.lang.String comment,
                                           java.lang.String startingVersion,
                                           boolean createParentFolders)
                                    throws RepositoryItemNotFoundException,
                                           RepositoryItemExistsException,
                                           java.io.IOException
        Creates a versioned file in the repository.
        Parameters:
        path - The path to the versioned file.
        localFilePath - The local file path with the contents for the new repository file.
        comment - The comment about the versioned file.
        startingVersion - The version to use for the initial version of the repository file. The default version of 1.0 is used if not provided.
        createParentFolders - Indicates whether missing parent containers are automatically created during the operation. This does NOT include creating contexts, only folders.
        Returns:
        The created versioned repository file.
        Throws:
        RepositoryItemNotFoundException - Thrown when createParentFolders is false and a parent container does NOT exist.
        RepositoryItemExistsException - Thrown when an object exists at the specified path.
        java.io.IOException - Thrown when there is a problem streaming the file contents.
      • updateItem

        RepositoryItem updateItem​(RepositoryItem item)
                           throws RepositoryItemNotFoundException,
                                  RepositoryItemUpdateException
        Updates the editable attributes of a repository object. These include description, the syncable flag, the run-as-owner flag (if the object is a job file), and extended attributes, if they exist. All other attribute changes are ignored. If any extended attributes are deleted, or new attributes added that are not defined for the object type, those changes are ignored.

        The expected flow for the call is to first retrieve the object by calling getItem(String) or getChildren(String), making required updates to the editable attributes, and then calling this method to persist the changes.

        Parameters:
        item - The repository object.
        Returns:
        The updated repository object.
        Throws:
        RepositoryItemNotFoundException - Thrown when repository object is not found at the given path.
        RepositoryItemUpdateException - Thrown when the repository object is not updated.
        Since:
        1.7
      • move

        RepositoryItem move​(java.lang.String sourcePath,
                            java.lang.String destinationPath)
                     throws RepositoryItemNotFoundException,
                            RepositoryItemExistsException,
                            RepositoryItemMoveException
        Moves the repository object from the source path to the destination path. The destination path is the full path to the moved item, which includes the name of the moved object.

        Only folders and files can be moved. Objects that are moved maintain their identifiers and their audit trail.

        Parameters:
        sourcePath - The path to the file or folder.
        destinationPath - The path to the destination file or folder, which includes the name of the item.
        Returns:
        The moved repository object.
        Throws:
        RepositoryItemNotFoundException - Thrown when the specified source path or destination location is not found.
        RepositoryItemExistsException - Thrown when an object exists at the destination path.
        RepositoryItemMoveException - Thrown when the move request is not possible.
      • copy

        RepositoryItem copy​(java.lang.String sourcePath,
                            java.lang.String destinationPath)
                     throws RepositoryItemNotFoundException,
                            RepositoryItemExistsException,
                            RepositoryItemCopyException
        Copies the repository object from the source path to the destination path. The destination path is the full path to the created copy, which includes the name of the new object.

        Only folders and files can be copied. Items that are copied create new items, with new identifiers. If a folder is copied, the folder and all readable contents within it are copied. If a versioned file is copied, only the latest version of the file is copied.

        Parameters:
        sourcePath - The path to the file or folder to copy.
        destinationPath - The path to the destination file or folder to create, which includes the name of the created copy.
        Returns:
        The created repository file or folder.
        Throws:
        RepositoryItemNotFoundException - Thrown when the specified source path or destination location is not found.
        RepositoryItemExistsException - Whrown when an object exists at the destination path.
        RepositoryItemCopyException - Thrown when the copy request is not possible. For example, the destination path is a child of the source path.
      • delete

        java.util.List<java.lang.String> delete​(java.lang.String path)
                                         throws RepositoryItemNotFoundException,
                                                RepositoryItemDeleteException
        Logically deletes the object (moves it to the recycle bin). Only files and folders can be logically deleted. Note that contexts cannot be logically or permanently deleted via the API.
        Parameters:
        path - The object to logically delete.
        Returns:
        The list of the paths that were logically deleted with the action.
        Throws:
        RepositoryItemNotFoundException - Thrown when repository object is not found at the given path.
        RepositoryItemDeleteException - Thrown when there is an issue logically deleting the object.
      • permanentlyDelete

        java.util.List<java.lang.String> permanentlyDelete​(java.lang.String path)
                                                    throws RepositoryItemNotFoundException,
                                                           RepositoryItemDeleteException
        Permanently deletes the specified object. This action cannot be undone. If the object is a file, all versions (if the file is versioned) are deleted. Contexts cannot be permanently deleted. If the object is a container, all children are deleted.
        Parameters:
        path - The object to permanently delete.
        Returns:
        The list of the paths that were permanently deleted with the action.
        Throws:
        RepositoryItemNotFoundException - Thrown when repository object is not found at the given path.
        RepositoryItemDeleteException - Thrown when there is an issue permanently deleting the item.
      • enableVersioning

        RepositoryFile enableVersioning​(java.lang.String path,
                                        java.lang.String startingVersion,
                                        java.lang.String comment)
                                 throws RepositoryItemNotFoundException,
                                        RepositoryItemVersioningException
        Enables versioning for the repository file. The current contents of the file are the starting version of the versioned file.
        Parameters:
        path - The repository file to version.
        startingVersion - (optional) the version to use for the initial version of the repository file. The default version of 1.0 is used if not provided.
        comment - (optional) a comment that describes the version.
        Returns:
        The updated versioned file.
        Throws:
        RepositoryItemNotFoundException - Thrown when repository object is not found at the specified path.
        RepositoryItemVersioningException - Thrown when the file versioning is not enabled, such as when the file currently versioned.
      • disableVersioning

        RepositoryFile disableVersioning​(java.lang.String path,
                                         java.lang.String comment)
                                  throws RepositoryItemNotFoundException,
                                         RepositoryItemVersioningException
        Disables versioning support for the repository file. The latest version contents remain as the only contents available for the file. All previous versions of the file and their contents are removed. This action cannot be undone.
        Parameters:
        path - The repository file to unversion.
        comment - Thecomment that describes the file's contents.
        Returns:
        The updated unversioned file.
        Throws:
        RepositoryItemNotFoundException - Thrown when the specified path is not found.
        RepositoryItemVersioningException - Thrown when versioning is not disabled for the file, such as when the file is currently unversioned.
      • exists

        boolean exists​(java.lang.String path)
        Indicates whether the path exists in the repository.
        Parameters:
        path - The path to the repository item.
        Returns:
        True, if the path exists, false otherwise.
      • getTopLevelContexts

        java.util.List<RepositoryContext> getTopLevelContexts()
        Gets the list of all of the accessible top-level contexts.
        Returns:
        The list of all of the accessible top-level contexts.
      • getSynchronizationInfo

        SynchronizationInfo getSynchronizationInfo​(java.lang.String path)
        Gets the synchronization information for the specified file path.

        The synchronization information is information about the state between the file that that is located in the workspace and a file that is located in the repository. A file that is in the workspace can be independent of a file that is in the repository. This method retrieves information which that indicates the state of the file. Does it exist only in the workspace or the repository? Does it exist in both places? Was the workspace file synchronized with the repository file? If so, which version of the repository file was synchronized? Is the workspace file still in sync with the repository file or has the repository file changed? Has the workspace file changed?

        The information contained in the SynchronizationInfo object enables you to determine whether the workspace file is out-of-sync with the repository file.

        If the path specified does not exist a SynchronizationInfo is returned, SynchronizationInfo.FileStatus.NON_EXISTENT is set, and all other file information attributes are null. If the path is to a folder, an IllegalArgumentException is thrown.

        Parameters:
        path - The file path to retrieve synchronization information for.
        Returns:
        The synchronization information for the file.
      • getSynchronizationInfos

        java.util.List<SynchronizationInfo> getSynchronizationInfos​(java.util.Set<java.lang.String> paths,
                                                                    boolean recurse)
        Gets the synchronization information for the paths specified. The paths can be to files or folders. For a folder path, if recurse is false, synchronization information for the files immediately within the folder are returned. If recurse is true, it returns synchronization information for all of the files that are within the entire subtree.

        If there are no child files, then an empty List is be returned. Note: Root and top context level paths are not allowed.

        Parameters:
        paths - That path to the files or folders.
        recurse - Indicates whether to retrieve recursive synchronization. If false, it retrieves the synchronization information for the files that are within the folder specified (the folder's immediate children). If true, it retrieves the synchronization information for the files that are within the entire subtree (recurses into all subfolders, if they exist).
        Returns:
        The synchronization information for files at the specified paths.
      • getParentMembershipContext

        RepositoryContext getParentMembershipContext​(java.lang.String path)
                                              throws RepositoryItemNotFoundException,
                                                     MembershipContextNotFoundException
        Gets the nearest parent context with the membership capability for the repository path. Read access is required to the context that is returned.
        Parameters:
        path - The repository path for which the nearest membership context is found. This can be a folder path, file path, context path, or other repository type.
        Returns:
        The nearest repository context with the membership capability.
        Throws:
        RepositoryItemNotFoundException - Thrown when the repository item is not found at the specified path.
        MembershipContextNotFoundException - Thrown when the repository item has no parent context with the membership capability. This is thrown when a top repository context path is specified.
      • getChildrenByType

        java.util.List<RepositoryItem> getChildrenByType​(java.lang.String path,
                                                         java.lang.String typeId)
                                                  throws RepositoryItemNotFoundException
        Gets the children of the container path.
        Parameters:
        path - The path to the parent container.
        typeId - The type of children to return.
        Returns:
        The children of the parent container.
        Throws:
        RepositoryItemNotFoundException - Thrown when the repository item is not found at the specified path.
      • getFileVersion

        RepositoryFile getFileVersion​(java.lang.String path,
                                      java.lang.String version)
                               throws RepositoryItemNotFoundException
        Gets the specific version of a versioned file.
        Parameters:
        path - The path to the versioned file.
        version - The version.
        Returns:
        The specified version of the versioned file at the specified path.
        Throws:
        RepositoryItemNotFoundException - Thrown when the repository item is not found at the specified path, if it is not a versioned file, or if the specified version does not exist for the versioned file.
      • downloadFile

        void downloadFile​(java.lang.String path,
                          java.lang.String version,
                          java.lang.String outputFilePath)
                   throws RepositoryItemNotFoundException,
                          java.io.IOException
        Downloads the file to a local file.

        Note: This action has no effect upon the workspace. The file is downloaded to the client computer.

        Parameters:
        path - The path to the repository file to download.
        version - The version of the file to download. Specify null if you want the latest version.
        outputFilePath - The location on the client computer in which to store the file.
        Throws:
        RepositoryItemNotFoundException - Thrown when the repository item is not found at the specified path.
        java.io.IOException - Thrown when there is a problem streaming the file.
      • updateFileContents

        RepositoryFile updateFileContents​(java.lang.String path,
                                          RepositoryCheckinSpecification checkinSpecification,
                                          java.lang.String localFileLocation)
                                   throws RepositoryItemNotFoundException,
                                          RepositoryItemVersioningException,
                                          RepositoryItemCheckoutException,
                                          java.io.IOException
        Updates the repository file with the specified file or creates a new version of the file, if the file is versioned.

        Note: This method enables you to update a repository file without going through the typical checkout/checkin process. Therefore, this action has no effect on your workspace contents.

        If null is specified for the checkin specification, that is interpreted as a blank comment and MAJOR version update value, if the file is versioned.

        Parameters:
        path - The path to the repository file to update.
        checkinSpecification - The method to generate the file version number, if the file is versioned.
        localFileLocation - The local file path with the new version of the file.
        Returns:
        The modified repository file.
        Throws:
        RepositoryItemNotFoundException - Thrown when the repository item is not found at the specified path.
        RepositoryItemVersioningException - Thrown when the version specification is not valid or inappropriate for the specified file.
        RepositoryItemCheckoutException - Thrown when the specified file specified is currently checked out.
        java.io.IOException - Thrown when there is a problem streaming the file.
      • setState

        java.util.List<RepositoryStateChangeResult> setState​(java.lang.String path,
                                                             RepositoryItem.State state,
                                                             java.lang.String comment,
                                                             boolean recurse)
                                                      throws RepositoryItemNotFoundException
        Sets the state of a repository context. These are the two RepositoryItem.States:
      • ACTIVE - Allows all repository activities that authorizations allow.
      • CLOSED - Prevents all actions that could change the content or metadata. CLOSED is intended to be an archival state that prevents all changes to the current structure and data.
      • Setting the state requires the privilege PRIVILEGE_MANAGE_STATE. In addition, READ METADATA and WRITE METADATA permissions are required on the context. If the user setting the state has these authorizations, then they are allowed to set the state on all descendents implicitly. Even if they lack one or both of the permissions required on the context to set, the state IS set implicitly, if the state is cascading.

        As described above, an ACTIVE context within a CLOSED context is an invalid state. Therefore, when setting a context from CLOSED to ACTIVE and the parent context is CLOSED, this action automatically changes the state of all immediate ancestors that are CLOSED to ACTIVE.

Parameters:
path - The path to the context.
state - The state.
comment - The comment that is used in the audit record. If no comment is specified then that value is not audited. The comment is not persisted in any other place except the audit trail.
recurse - The state to set is cascaded to all of the descendent contexts. All non-context descendents (which includes non-stateable) contexts are always set regardless of whether this flag is set. If a context is set to ACTIVE, all folders, files, and non-stateable context descendents are set to the context state automatically by default. The flag indicates whether stateable context descendents should have their state changed. The flag is used only when setting the state to ACTIVE. When setting a context state to CLOSED, then ALL descendents are automatically set to CLOSED because ACTIVE content within a CLOSED context is an invalid state. Therefore, when closing a context, the flag is ignored because recursion is a requirement.
Returns:
The results of what changed based on the action.
Throws:
RepositoryItemNotFoundException - Thrown when the item no longer exists.
IllegalTypeException - Thrown if the path specified is for a type that is not Stateable. This includes non-stateable context types, folders, and files.
PrivilegeRequiredAccessDeniedException - Thrown when the current user does not have the scoped privilege PRIVILEGE_MANAGE_STATE granted at the context to be set or higher. This can also be thrown when the user is propagating the state change upwards and they do NOT have the privilege on a parent.
PermissionRequiredAccessDeniedException - Thrown when the current user does not have READ and WRITE METADATA permissions on the context to set. This can also be thrown when the user is propagating the state change upwards and they do NOT have the permissions on a parent.