Class DocumentService
java.lang.Object
com.eurodyn.qlack.fuse.cm.service.DocumentService
- Author:
- European Dynamics
-
Constructor Summary
ConstructorsConstructorDescriptionDocumentService
(ConcurrencyControlService concurrencyControlService, VersionService versionService, NodeRepository nodeRepository, NodeMapper mapper) -
Method Summary
Modifier and TypeMethodDescriptionCopy.createAttribute
(String nodeId, String attributeName, String attributeValue, String userId, String lockToken) Creates the attribute.createFile
(FileDTO file, String userID, String lockToken) Creates the file.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.createFolder
(FolderDTO folder, String userID, String lockToken) Creates a new folder under a specific parent folder.void
deleteAttribute
(String nodeID, String attributeName, String userID, String lockToken) Delete attribute.void
deleteFile
(String fileID, String lockToken) Deletes a file .void
deleteFolder
(String folderID, String lockToken) Deletes a folder .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.getAncestors
(String nodeID) Gets the ancestors.getFileByID
(String fileID, boolean includeVersions, boolean findPath) Finds an return a file with the specific ID along with its versions (optionally).byte[]
getFolderAsZip
(String folderID, boolean includeProperties, boolean isDeep) Gets the content of a folder node in a zip file.getFolderByID
(String folderID, boolean lazyRelatives, boolean findPath) Finds ands returns a folder with the specific ID along with is children (optionally).getNodeByAttributes
(String parentId, Map<String, String> attributes) Retrieves a list of nodes of a specified parent.getNodeByID
(String nodeID) Gets the node by ID.Gets the parent.boolean
isFileNameUnique
(String name, String parentNodeID) Checks whether a file or folder with the same name, already exists in a specified directory.void
Move.void
renameFile
(String fileID, String newName, String userID, String lockToken) Rename file.void
renameFolder
(String folderID, String newName, String userID, String lockToken) Rename folder.void
updateAttribute
(String nodeID, String attributeName, String attributeValue, String userID, String lockToken) Update attribute.
-
Constructor Details
-
DocumentService
@Autowired public DocumentService(ConcurrencyControlService concurrencyControlService, VersionService versionService, NodeRepository nodeRepository, NodeMapper mapper)
-
-
Method Details
-
createFolder
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
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
Rename folder.- Parameters:
folderID
- the folder IDnewName
- the new nameuserID
- the user idlockToken
- the lock token- Throws:
QNodeLockException
- the q node lock exception
-
getFolderByID
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
Gets the parent.- Parameters:
nodeID
- the node IDlazyRelatives
- the lazy relatives- Returns:
- the parent
-
getFolderAsZip
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 retrievedincludeProperties
- 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 = propertyValueisDeep
- 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
Creates the file.- Parameters:
file
- the fileuserID
- the user IDlockToken
- the lock token- Returns:
- the string
- Throws:
QNodeLockException
- the q node lock exception
-
deleteFile
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
Rename file.- Parameters:
fileID
- the file IDnewName
- the new nameuserID
- the user IDlockToken
- the lock token- Throws:
QNodeLockException
- the q node lock exception
-
getFileByID
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
Gets the node by ID.- Parameters:
nodeID
- the node ID- Returns:
- the node by ID
-
getNodeByAttributes
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 idattributes
- the attributes- Returns:
- the node by attributes
-
getAncestors
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 idattributeName
- the attribute nameattributeValue
- the attribute valueuserId
- the user idlockToken
- 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 IDattributeName
- the attribute nameattributeValue
- the attribute valueuserID
- the user IDlockToken
- the lock token- Throws:
QNodeLockException
- the q node lock exception
-
deleteAttribute
Delete attribute.- Parameters:
nodeID
- the node IDattributeName
- the attribute nameuserID
- the user IDlockToken
- the lock token- Throws:
QNodeLockException
- the q node lock exception
-
copy
Copy.- Parameters:
nodeID
- the node IDnewParentID
- the new parent IDuserID
- the user IDlockToken
- the lock token- Returns:
- the string
-
move
Move.- Parameters:
nodeID
- the node IDnewParentID
- the new parent IDuserID
- the user IDlockToken
- the lock token
-
isFileNameUnique
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 existsparentNodeID
- 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
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 informationcmVersion
- 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.
-