Class DocumentService

java.lang.Object
com.eurodyn.qlack.fuse.cm.service.DocumentService

@Service public class DocumentService extends Object
Author:
European Dynamics
  • Constructor Details

  • Method Details

    • createFolder

      public String createFolder(FolderDTO folder, String userID, String lockToken)
      Creates a new folder under a specific parent folder.
      Parameters:
      folder - The FolderDTO of the folder to be created.
      userID - The ID of the logged in user who is creating the folder.
      lockToken - A lock token id, which will used to examine whether the user is allowed to create a folder under the specific hierarchy (check for locked ascendant).
      Returns:
      The id of the newly created folder conflict
      Throws:
      QNodeLockException - If the folder/node cannot be created under the specific hierarchy since an ascendant is already locked
    • deleteFolder

      public void deleteFolder(String folderID, String lockToken)
      Deletes a folder .
      Parameters:
      folderID - The ID of the folder to be deleted.
      lockToken - A lock token id, which will used to examine whether the user is allowed to delete the folder under the specific hierarchy. It checks for locked ascendant or if the folder has been locked by other user.
      Throws:
      QNodeLockException - If the folder/node cannot be deleted under the specific hierarchy since an ascendant or the folder itself is already locked
    • renameFolder

      public void renameFolder(String folderID, String newName, String userID, String lockToken)
      Rename folder.
      Parameters:
      folderID - the folder ID
      newName - the new name
      userID - the user id
      lockToken - the lock token
      Throws:
      QNodeLockException - the q node lock exception
    • getFolderByID

      public FolderDTO getFolderByID(String folderID, boolean lazyRelatives, boolean findPath)
      Finds ands returns a folder with the specific ID along with is children (optionally).
      Parameters:
      folderID - The ID of the folder to be retrieved.
      lazyRelatives - When true it will not compute the relatives (ancestors/descendats) of the required folder.
      findPath - When true the directory path until the required folder will be computed.
      Returns:
      The FolderDTO which contains all the information about the folder.
    • getParent

      public FolderDTO getParent(String nodeID, boolean lazyRelatives)
      Gets the parent.
      Parameters:
      nodeID - the node ID
      lazyRelatives - the lazy relatives
      Returns:
      the parent
    • getFolderAsZip

      public byte[] getFolderAsZip(String folderID, boolean includeProperties, boolean isDeep)
      Gets the content of a folder node in a zip file. This method retrieves the binary contents of all files included in the folder node specified as well as their attributes if the includeAttributes argument is true. The contents of files included in other folders contained by the folder specified are also retrieved in case the isDeep argument is true.
      Parameters:
      folderID - The ID of the folder the content of which is to be retrieved
      includeProperties - If true then a separate properties file will be created inside the final zip file for each node included in the result, containing the nodes' properties in the form: propertyName = propertyValue
      isDeep - If true then the whole tree commencing by the specified folder will be traversed in order to be included in the final result. Otherwise only the file nodes which are direct children of the specified folder will be included in the result.
      Returns:
      The binary content (and properties if applicable) of the specified folder as a byte array representing a zip file.
    • createFile

      public String createFile(FileDTO file, String userID, String lockToken)
      Creates the file.
      Parameters:
      file - the file
      userID - the user ID
      lockToken - the lock token
      Returns:
      the string
      Throws:
      QNodeLockException - the q node lock exception
    • deleteFile

      public void deleteFile(String fileID, String lockToken)
      Deletes a file .
      Parameters:
      fileID - The ID of the file to be deleted.
      lockToken - A lock token id, which will used to examine whether the user is allowed to delete the file, under the specific hierarchy. It checks for locked ascendant or if the file itself has been locked by other user.
      Throws:
      QNodeLockException - If the node cannot be deleted under the specific hierarchy since an ascendant or the folder itself is already locked
    • renameFile

      public void renameFile(String fileID, String newName, String userID, String lockToken)
      Rename file.
      Parameters:
      fileID - the file ID
      newName - the new name
      userID - the user ID
      lockToken - the lock token
      Throws:
      QNodeLockException - the q node lock exception
    • getFileByID

      public FileDTO getFileByID(String fileID, boolean includeVersions, boolean findPath)
      Finds an return a file with the specific ID along with its versions (optionally).
      Parameters:
      fileID - The ID of the folder to be retrieved.
      includeVersions - When true all versions of the file are included.
      findPath - When true the directory path until the required folder will be computed.
      Returns:
      The FileDTO which contains all the information about the required file
    • getNodeByID

      public NodeDTO getNodeByID(String nodeID)
      Gets the node by ID.
      Parameters:
      nodeID - the node ID
      Returns:
      the node by ID
    • getNodeByAttributes

      public List<NodeDTO> getNodeByAttributes(String parentId, Map<String,String> attributes)
      Retrieves a list of nodes of a specified parent. In addition the method can return a list of nodes of the given parent having the attributes passed as a parameter
      Parameters:
      parentId - the parent id
      attributes - the attributes
      Returns:
      the node by attributes
    • getAncestors

      public List<FolderDTO> getAncestors(String nodeID)
      Gets the ancestors.
      Parameters:
      nodeID - the node ID
      Returns:
      the ancestors
    • createAttribute

      public String createAttribute(String nodeId, String attributeName, String attributeValue, String userId, String lockToken)
      Creates the attribute.
      Parameters:
      nodeId - the node id
      attributeName - the attribute name
      attributeValue - the attribute value
      userId - the user id
      lockToken - the lock token
      Returns:
      the string
      Throws:
      QNodeLockException - the q node lock exception
    • updateAttribute

      public void updateAttribute(String nodeID, String attributeName, String attributeValue, String userID, String lockToken)
      Update attribute.
      Parameters:
      nodeID - the node ID
      attributeName - the attribute name
      attributeValue - the attribute value
      userID - the user ID
      lockToken - the lock token
      Throws:
      QNodeLockException - the q node lock exception
    • deleteAttribute

      public void deleteAttribute(String nodeID, String attributeName, String userID, String lockToken)
      Delete attribute.
      Parameters:
      nodeID - the node ID
      attributeName - the attribute name
      userID - the user ID
      lockToken - the lock token
      Throws:
      QNodeLockException - the q node lock exception
    • copy

      public String copy(String nodeID, String newParentID, String userID, String lockToken)
      Copy.
      Parameters:
      nodeID - the node ID
      newParentID - the new parent ID
      userID - the user ID
      lockToken - the lock token
      Returns:
      the string
    • move

      public void move(String nodeID, String newParentID, String userID, String lockToken)
      Move.
      Parameters:
      nodeID - the node ID
      newParentID - the new parent ID
      userID - the user ID
      lockToken - the lock token
    • isFileNameUnique

      public boolean isFileNameUnique(String name, String parentNodeID)
      Checks whether a file or folder with the same name, already exists in a specified directory.
      Parameters:
      name - The name of the new file which should be checked to find out if a duplicate name exists
      parentNodeID - The ID of the folder within which a file is a specified name is searched
      Returns:
      true if the specified file name is unique in the folder.
    • duplicateFileNamesInDirectory

      public List<String> duplicateFileNamesInDirectory(List<String> fileNames, String parentId)
      Checks whether the folder or file names are unique in the specified directory and returns a lists on the duplicate.
      Parameters:
      fileNames - The file names which will be checked id it is unique in a provided directory.
      parentId - The id of the parent folder within which duplicate file and folder names are searched.
      Returns:
      a lists on the duplicates.
    • createFileAndVersion

      public CreateFileAndVersionStatusDTO createFileAndVersion(FileDTO file, VersionDTO cmVersion, byte[] content, String userID, String lockToken)
      Creates a new file as well as a new version for the specific file.
      Parameters:
      file - The FileDTO which contain all the new file information
      cmVersion - The new version.
      content - The binary content of the new version. It is optional, so null can be used instead.
      userID - The user ID of the creator.
      lockToken - The lock token to be used so as to avoid lock conflicts.
      Returns:
      CreateFileAndVersionStatusDTO which contains the ids of the newly created file and version.