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 Details

    • createContext

      Creates a context in the repository.
      Parameters:
      path - The path to the context to create.
      typeId - The type of context to create.
      Returns:
      The created context.
      Throws:
      RepositoryItemNotFoundException - Thrown when a parent context does NOT exist.
      RepositoryItemExistsException - Thrown when an object exists in the repository at the specified path.
    • createFolder

      RepositoryFolder createFolder(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.
    • createSharedFolder

      Creates a shared folder in the repository. The folder must be directly under a context that has the capability to have files and folders. There cannot already be a shared folder under the same context because only one shared folder can exist in a context.

      Creating a shared folder requires the privilege ScopedPrivileges.PRIVILEGE_MANAGE_SHARED_FOLDERS.

      Parameters:
      path - The path to the shared folder to create.
      Returns:
      The created shared folder.
      Throws:
      RepositoryItemNotFoundException - Thrown when the parent container does not exist.
      RepositoryItemExistsException - Thrown when a shared folder already exists under the context.
    • createFile

      RepositoryFile createFile(String path, String localFilePath, String comment, boolean createParentFolders) throws RepositoryItemNotFoundException, RepositoryItemExistsException, 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.
      IOException - Thrown when there is a problem streaming the file contents.
    • createVersionedFile

      RepositoryFile createVersionedFile(String path, String localFilePath, String comment, String startingVersion, boolean createParentFolders) throws RepositoryItemNotFoundException, RepositoryItemExistsException, 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.
      IOException - Thrown when there is a problem streaming the file contents.
    • updateItem

      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
    • rename

      Renames the repository object.
      Parameters:
      path - The path to the repository object to rename.
      name - the new name
      Returns:
      The updated repository object with the new name.
      Throws:
      RepositoryItemNotFoundException - Thrown when repository object was not found at the specified path.
      RepositoryItemExistsException - Thrown when a repository object exists in the same location with the new. name.
    • move

      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

      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

      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.
    • deleteVersions

      Permanently deletes the versions of the file at the specified path.
      Parameters:
      path - The path to the file with versions.
      versions - The versions of the path to delete.
      Returns:
      The list of deletion status information for each version that is specified for deletion.
      Throws:
      RepositoryItemNotFoundException - Thrown when repository object is not found at the specified path.
      RepositoryItemDeleteException - Thrown when there is an issue permanently deleting the version.
    • permanentlyDelete

      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(String path, String startingVersion, 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

      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.
    • lockFile

      Locks the specified repository file, prevents users from modifying the file in any way.
      Parameters:
      path - The path to the repository file to lock.
      Returns:
      The locked repository file.
      Throws:
      RepositoryItemNotFoundException - Thrown when the specified path is not found.
      RepositoryItemLockException - Thrown when the specified file is not locked, such as when the file is currently locked.
    • unlockFile

      Unlocks the repository file.
      Parameters:
      path - The path to the repository file to unlock.
      Returns:
      The unlocked repository file.
      Throws:
      RepositoryItemNotFoundException - Thrown when the specified path is not found.
      RepositoryItemUnlockException - Thrown when the specified file cannot be unlocked, such as when the file is currently unlocked.
    • exists

      boolean exists(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.
    • getItem

      Gets the repository object at the path.
      Parameters:
      path - The path to the repository item.
      Returns:
      The repository object located at the specified path.
      Throws:
      RepositoryItemNotFoundException - Thrown when repository object is not found at the specified path.
    • getTopLevelContextByName

      RepositoryContext getTopLevelContextByName(String name) throws RepositoryItemNotFoundException
      Gets a top-level context by name.
      Parameters:
      name - The name of the top-level context.
      Returns:
      The top-level context with the specified name.
      Throws:
      RepositoryItemNotFoundException - Thrown when the top-level context is not found.
    • getTopLevelContexts

      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(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

      List<SynchronizationInfo> getSynchronizationInfos(Set<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.
    • getContext

      Gets the repository context at the path.
      Parameters:
      path - The path to the repository context.
      Returns:
      The repository context located at the specified path.
      Throws:
      RepositoryItemNotFoundException - Thrown when a repository context is not found at the specified path.
    • getContextById

      Gets the repository context by its unique identifier.
      Parameters:
      id - The identifier of the repository context.
      Returns:
      The repository context that is located at the specified path.
      Throws:
      RepositoryItemNotFoundException - Thrown when a repository context is not found.
    • getParentMembershipContext

      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.
    • getFolder

      Gets the repository folder at the path.
      Parameters:
      path - The path to the repository folder.
      Returns:
      The repository folder located at the specified path.
      Throws:
      RepositoryItemNotFoundException - Thrown when the repository folder is not found at the specified path.
    • getFile

      Gets the repository file at the path.
      Parameters:
      path - the path of the repository file.
      Returns:
      The repository file that is located at the specified path.
      Throws:
      RepositoryItemNotFoundException - Thrown when the repository file is not found at the specified path.
    • getChildren

      Gets the children of the container path.
      Parameters:
      path - The path to the parent container.
      Returns:
      The children of the parent container.
      Throws:
      RepositoryItemNotFoundException - Thrown when the repository item is not found at the specified path.
    • getChildrenByType

      List<RepositoryItem> getChildrenByType(String path, 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(String path, 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.
    • getFileVersions

      Gets the list of versions of the repository file.
      Parameters:
      path - The path to the file.
      Returns:
      The list of the repository files, one for each version of the specified file that is in the repository.
      Throws:
      RepositoryItemNotFoundException - Thrown when the repository item is not found at the specified path.
      RepositoryItemVersioningException - Thrown when the file at the specified path is not versioned.
    • getFileVersionInfos

      Gets the list of the version information that represents each version of the repository file.
      Parameters:
      path - The path to the repository file.
      Returns:
      A list of the version information that describes each version of the specified file.
      Throws:
      RepositoryItemNotFoundException - Thrown when the repository item is not found at the specified path.
      RepositoryItemVersioningException - Thrown when the file at the specified path is not versioned.
    • downloadFile

      void downloadFile(String path, String version, String outputFilePath) throws RepositoryItemNotFoundException, 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.
      IOException - Thrown when there is a problem streaming the file.
    • updateFileContents

      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.
      IOException - Thrown when there is a problem streaming the file.
    • setState

      List<RepositoryStateChangeResult> setState(String path, RepositoryItem.State state, 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.
    • checkout

      Checks out the file from the repository.
      Parameters:
      path - The repository file.
      Returns:
      The repository file in a checked out state.
      Throws:
      RepositoryItemNotFoundException - Thrown when the specified path is not found.
      RepositoryItemCheckoutException - Thrown when the file is currently checked out or locked.
    • undoCheckout

      Undoes the checkout of the file.
      Parameters:
      path - The repository file.
      Returns:
      The repository file in an unchecked out state.
      Throws:
      RepositoryItemNotFoundException - Thrown when the specified path cannot not found.
      RepositoryItemUndoCheckoutException - Thrown when the repository file is not checked out.
    • checkin

      Checks in the file from the current user's workspace to the repository.
      Parameters:
      path - The file.
      checkinSpecification - The method for how to label the new version. If null is specified for checkinSpecification, that is interpreted as a blank comment (and MINOR version update value if the file is versioned).
      Returns:
      The latest version of the repository file.
      Throws:
      RepositoryItemNotFoundException - Thrown when the specified path is not found.
      RepositoryItemCheckinException - Thrown when the specified file is not checked in.
    • copyLatestFileVersionToWorkspace

      void copyLatestFileVersionToWorkspace(String path) throws RepositoryItemNotFoundException
      Copies the latest version of the repository file to your workspace.
      Parameters:
      path - The path to the repository file.
      Throws:
      RepositoryItemNotFoundException - Thrown when repository file is not found at the specified path.
    • copySpecificFileVersionToWorkspace

      void copySpecificFileVersionToWorkspace(String path, String version) throws RepositoryItemNotFoundException
      Copies the version of the repository file to your workspace.
      Parameters:
      path - The path to the repository file.
      version - The specific version to copy into your workspace.
      Throws:
      RepositoryItemNotFoundException - Thrown when the repository file is not found at the specified path.
    • searchCheckedOutFiles

      SearchResultsInfo searchCheckedOutFiles(CheckedOutFilesQuery query)
      Searches the checked out files information and returns the information that describes the results, not the results themselves. The search results information contains the row count in which to request pageable checked-out file entries by calling getCheckedOutFilesSearchResults(int, int). When the results are no longer required, call clearCheckedOutFilesSearchResults() to release server-side resources that are related to the query.

      Note: Only one query can be active at a time for each client. The results generated for the query can be used to iterate through the results by calling getCheckedOutFilesSearchResults(int, int), but if the same client calls this method again, a new set of results is generated. The previous results are no longer valid.

      Parameters:
      query - The search criteria with which to query the checked out files. Specifying null returns the current user's checked out files.
      Returns:
      The metadata that describes the search results that contains the row count to indicate the number of records that were returned by the query.
    • search

      Searches the repository based on the specified query. The server will return a list of RepositoryItems that satisfy the query. However, items in the recycle bin and any items that the current user does not have read access to will not be returned. If the server cannot process all of the items due to server limitations, RepositorySearchResults.isLimitReached() is set to true. If true, more items might exist that satisfy the query but they cannot be returned.

      Search rules:

      • Search is not case-sensitive. AAA finds file with aaa.
      • Without quotes surrounding multiple-word search item, the search find each individual word, not the whole word phrase. For example, APPLE TARTE returns files with apple or tarte or both, whereas "APPLE TARTE" only returns files that contain the exact search item.
      • Without * or ? wildcard characters, the search tooling will not find search terms contained inside other text. By default, it searches for complete words.

      To search file content, setTypeId must be called with one of the following types. Note: Because job files contain XML content, search will only find what is in attribute values.

      Parameters:
      query - The search criteria with which to query the repository. Must specify a value for at least one query field.
      Returns:
      The metadata that describes the search results that contains RepositoryItems that satisfy the query and whether the limit is reached on the server.
      Throws:
      RepositorySearchException - Thrown if there is an issue processing the repository search.
    • getCheckedOutFilesSearchResults

      List<SynchronizationInfo> getCheckedOutFilesSearchResults(int fromRow, int toRow) throws CheckedOutFilesSearchException
      Gets a range of results after calling searchCheckedOutFiles(CheckedOutFilesQuery). The from row and to row values must be between 1 and the total number of rows retrieved by the query. This is considered a page of results, and therefore, a pageable results model.

      Note: The maximum number of records that can be returned for a single page is determined by getPageSizeLimit(). The default maximum is 5000.

      Parameters:
      fromRow - The starting row number to include in the results. Must be greater than 0.
      toRow - The ending row number to include in the results. Must be less than or equal to the total row count. The total number retrieved must be less than or equal to the page size limit.
      Returns:
      The list of SynchronizationInfo objects that are based on token and rows specified.
      Throws:
      CheckedOutFilesSearchException - Thrown when the total row number requested exceeds the page size limit.
    • clearCheckedOutFilesSearchResults

      void clearCheckedOutFilesSearchResults()
      Releases any cached information about the query that is associated with the current search. This should be called once in a finally block for each call to searchCheckedOutFiles(CheckedOutFilesQuery). If the results no longer exist when this method is called, then this method returns without any further action.
    • getPageSizeLimit

      int getPageSizeLimit()
      Gets the maximum number of checked out files that can be returned in a single request. The default is 5000.
      Returns:
      The page size limit.