Package com.logicaldoc.core.folder
Class HibernateFolderDAO
- java.lang.Object
-
- com.logicaldoc.core.HibernatePersistentObjectDAO<Folder>
-
- com.logicaldoc.core.folder.HibernateFolderDAO
-
- All Implemented Interfaces:
FolderDAO
,PersistentObjectDAO<Folder>
public class HibernateFolderDAO extends HibernatePersistentObjectDAO<Folder> implements FolderDAO
Hibernate implementation ofFolderDAO
- Since:
- 6.0
- Author:
- Marco Meschieri - LogicalDOC
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
applyGridToTree(long id, FolderHistory transaction)
Propagates the grid layout of a node to the whole subtreeboolean
applyMetadataToTree(long id, FolderHistory transaction)
Propagates the template metadata to the whole subreeboolean
applyOCRToTree(long id, FolderHistory transaction)
Propagates the OCR settings to the whole subreeboolean
applyRightToTree(long rootId, FolderHistory transaction)
Propagates the security policies of a node to the whole subtreeboolean
applyStorageToTree(long id, FolderHistory transaction)
Propagates the storage setting to the whole subreeboolean
applyTagsToTree(long id, FolderHistory transaction)
Propagates the tags to the whole subreeString
computePath(long folderId)
Dynamically computes the path for the specified folder.String
computePathExtended(long folderId)
Dynamically computes the path extended for the specified folder.long
computeTreeSize(long rootId)
Counts the number of documents inside a given folder's tree (direct and indirect children)Folder
copy(Folder source, Folder target, String newName, boolean foldersOnly, String securityOption, FolderHistory transaction)
Copies a folder into another folderint
count(boolean computeDeleted)
Counts the number of folderslong
countDocsInTree(long rootId)
Counts the number of documents inside a given folder's tree (direct and indirect children)Folder
create(Folder parent, Folder folderVO, boolean inheritSecurity, FolderHistory transaction)
Creates a new folder in the parent FolderFolder
createAlias(long parentId, long foldRef, FolderHistory transaction)
Creates a new folder folder aliasFolder
createPath(Folder parent, String path, boolean inheritSecurity, FolderHistory transaction)
Creates the folder for the specified path.boolean
delete(long folderId, int code)
This method deletes an entity and you can give a deletion codeboolean
delete(long folderId, int delCode, FolderHistory transaction)
This method deletes the folder object and insert a new folder history entryboolean
delete(long folderId, FolderHistory transaction)
Shortcut for delete(id, 1, transaction)void
deleteAll(Collection<Folder> folders, int code, FolderHistory transaction)
For each folder, save the folder delete history entry for each folder and delete the foldervoid
deleteAll(Collection<Folder> folders, FolderHistory transaction)
Shortcut for deleteAll(folders, 1, transaction)List<Folder>
deleteTree(long folderId, int delCode, FolderHistory transaction)
Delete a folder and all its sub-folders that a user can delete.List<Folder>
deleteTree(long folderId, FolderHistory transaction)
Shortcut for deleteTree(folderId, 1, transaction)List<Folder>
deleteTree(Folder folder, int delCode, FolderHistory transaction)
Deletes a folder and all its sub-folders that a user can delete.List<Folder>
find(String name, Long tenantId)
Useful method that allows to find all folders that contains the given name into their text.List<Folder>
findAliases(Long foldRef, long tenantId)
Finds all the aliasesList<Folder>
findByGroupId(long groupId)
Finds all folders accessible by the passed groupList<Folder>
findByName(Folder parent, String name, Long tenantId, boolean caseSensitive)
Finds all folders by folder text, contained in the parent folder.List<Folder>
findByName(String name, Long tenantId)
Finds all folders by folder nameList<Folder>
findByNameAndParentId(String name, long parentId)
Finds that folder that lies under a specific parent (given by the id) an with a given name(like operator is used)List<Folder>
findByParentId(long parentId)
Finds all children(direct and indirect) by parentIdFolder
findByPathExtended(String pathExtended, long tenantId)
Retrieval of a folder by the extended pathList<Folder>
findByUserId(long userId)
Finds authorized folders for a userList<Folder>
findByUserId(long userId, long parentId)
Finds direct children of a folder.List<Folder>
findByUserIdAndTag(long userId, String tag, Integer max)
Finds authorized folders for a user having a specified tag.List<Folder>
findChildren(long parentId, long userId)
Finds direct children of a folder accessible by the given userList<Folder>
findChildren(long parentId, Integer max)
Finds direct children of a folderFolder
findDefaultWorkspace(long tenantId)
Retrieves the Default workspace of the given tenantList<Folder>
findDeleted(long userId, Integer maxHits)
Finds all deleted folders of a specific user.Folder
findFolder(long folderId)
Gets a folder by a given ID if it is an alias, the referenced folder is returned.List<Long>
findFolderIdByTag(String tag)
Collection<Long>
findFolderIdByUserId(long userId, Long parentId, boolean tree)
This method selects only the folder ID from the folders for which a user is authorized.Collection<Long>
findFolderIdByUserIdAndPermission(long userId, Permission permission, Long parentId, boolean tree)
Finds all folders ids with a specific permission enabled on the specifies userList<Long>
findFolderIdByUserIdAndTag(long userId, String tag)
Collection<Long>
findFolderIdByUserIdInPath(long userId, Long parentId)
This method selects only the folder ID from the folders for which a user is authorized.Set<Long>
findFolderIdInPath(long rootId, boolean includeDeleted)
Retrieve all the ids of the folders in a given tree using the path attributeSet<Long>
findFolderIdInTree(long rootId, boolean includeDeleted)
Retrieve all the ids of the folders in a given treeList<Long>
findIdByUserId(long userId, long parentId)
This method selects only the folder ID from the folders for which a user is authorized.List<Long>
findIdsByParentId(long parentId)
Finds all children(direct and indirect) by parentIdList<Folder>
findParents(long folderId)
Returns a List of folders being a parent of the given folder.Folder
findRoot(long tenantId)
Retrieves the root folder of the given tenantList<String>
findTags(long folderId)
Retrieves the alphabetically ordered list of all the folder's tagsFolder
findWorkspace(long folderId)
Returns the workspace that contains the given folderList<Folder>
findWorkspaces(long tenantId)
Retrieves all the workspaces in the system, that are the first-level folders of typeFolder.TYPE_WORKSPACE
Set<Permission>
getEnabledPermissions(long folderId, long userId)
Finds all permissions of a user enabled on the specified folderFolderHistoryDAO
getHistoryDAO()
UserDAO
getUserDAO()
boolean
hasWriteAccess(Folder folder, long userId)
Checks that the user has access to the folder and all its sub-itemsvoid
initialize(Folder folder)
Doesn't do anything by defaultboolean
isDownloadEnabled(long id, long userId)
boolean
isInPath(long folderId, long targetId)
Checks if a folder with the given folderId is parent of the folder with the given targetIdboolean
isMoveEnabled(long id, long userId)
boolean
isPermissionEnabled(Permission permission, long folderId, long userId)
This method checks if the given permission is enabled for a folder and an user.boolean
isPrintEnabled(long folderId, long userId)
boolean
isReadEnabled(long folderId, long userId)
boolean
isWriteEnabled(long folderId, long userId)
This method is looking up for writing rights for a folder and an user.void
merge(Folder source, Folder target, FolderHistory transaction)
Merges the contents of two foldersvoid
move(Folder source, Folder target, FolderHistory transaction)
Moves a folder into another foldervoid
restore(long folderId, long parentId, FolderHistory transaction)
Restores a previously deleted foldervoid
saveFolderHistory(Folder folder, FolderHistory transaction)
Utility method that logs into the DB the transaction that involved the passed folder.void
setHistoryDAO(FolderHistoryDAO historyDAO)
void
setStorer(Storer storer)
void
setUserDAO(UserDAO userDAO)
boolean
store(Folder folder)
This method persists the entity objectboolean
store(Folder folder, FolderHistory transaction)
Same as store(Folder, boolean, FolderHistory)boolean
updateSecurityRef(long folderId, long rightsFolderId, FolderHistory transaction)
Changes the securityRef of the given folder, all the other folders that inherits from this one will be changed accordingly.-
Methods inherited from class com.logicaldoc.core.HibernatePersistentObjectDAO
bulkUpdate, delete, deleteAll, deleteAll, findAll, findAll, findAllIds, findAllIds, findById, findById, findByObjectQuery, findByQuery, findByWhere, findByWhere, findIdsByWhere, findIdsByWhere, getDbms, getSessionFactory, isOracle, jdbcUpdate, jdbcUpdate, query, queryForInt, queryForList, queryForList, queryForLong, queryForObject, queryForRowSet, queryForString, setSessionFactory
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.logicaldoc.core.PersistentObjectDAO
bulkUpdate, delete, deleteAll, deleteAll, findAll, findAll, findAllIds, findAllIds, findById, findById, findByObjectQuery, findByQuery, findByWhere, findByWhere, findIdsByWhere, findIdsByWhere, getDbms, isOracle, jdbcUpdate, jdbcUpdate, query, queryForInt, queryForList, queryForList, queryForLong, queryForObject, queryForRowSet, queryForString
-
-
-
-
Method Detail
-
getUserDAO
public UserDAO getUserDAO()
-
setUserDAO
public void setUserDAO(UserDAO userDAO)
-
store
public boolean store(Folder folder) throws PersistenceException
Description copied from interface:PersistentObjectDAO
This method persists the entity object- Specified by:
store
in interfacePersistentObjectDAO<Folder>
- Overrides:
store
in classHibernatePersistentObjectDAO<Folder>
- Parameters:
folder
- entity to be stored- Returns:
- True if successfully stored in a database
- Throws:
PersistenceException
- raised in case of errors in the database
-
store
public boolean store(Folder folder, FolderHistory transaction) throws PersistenceException
Description copied from interface:FolderDAO
Same as store(Folder, boolean, FolderHistory)- Specified by:
store
in interfaceFolderDAO
- Parameters:
folder
- the folder to storetransaction
- current session informations- Returns:
- true if the folder has been correctly stored
- Throws:
PersistenceException
- in case of database error
-
findByUserId
public List<Folder> findByUserId(long userId)
Description copied from interface:FolderDAO
Finds authorized folders for a user- Specified by:
findByUserId
in interfaceFolderDAO
- Parameters:
userId
- ID of the user- Returns:
- List of found folders
-
findByUserId
public List<Folder> findByUserId(long userId, long parentId)
Description copied from interface:FolderDAO
Finds direct children of a folder.- Specified by:
findByUserId
in interfaceFolderDAO
- Parameters:
userId
- identifier of the userparentId
- ID of the folder which children are wanted- Returns:
- List of found folders sorted by text
-
findChildren
public List<Folder> findChildren(long parentId, Integer max)
Description copied from interface:FolderDAO
Finds direct children of a folder- Specified by:
findChildren
in interfaceFolderDAO
- Parameters:
parentId
- Folder ID of the folder which children are wantedmax
- Optional, maximum number of children- Returns:
- List of found folders
-
findChildren
public List<Folder> findChildren(long parentId, long userId)
Description copied from interface:FolderDAO
Finds direct children of a folder accessible by the given user- Specified by:
findChildren
in interfaceFolderDAO
- Parameters:
parentId
- Folder ID of the folder which children are wanteduserId
- Identifier of the user that must have read access- Returns:
- List of found folders
-
findByParentId
public List<Folder> findByParentId(long parentId)
Description copied from interface:FolderDAO
Finds all children(direct and indirect) by parentId- Specified by:
findByParentId
in interfaceFolderDAO
- Parameters:
parentId
- identifier of the parent folder- Returns:
- List of found folders
-
findIdsByParentId
public List<Long> findIdsByParentId(long parentId)
Description copied from interface:FolderDAO
Finds all children(direct and indirect) by parentId- Specified by:
findIdsByParentId
in interfaceFolderDAO
- Parameters:
parentId
- identifier of the parent folder- Returns:
- list of folder IDs
-
isPrintEnabled
public boolean isPrintEnabled(long folderId, long userId)
- Specified by:
isPrintEnabled
in interfaceFolderDAO
-
isWriteEnabled
public boolean isWriteEnabled(long folderId, long userId)
Description copied from interface:FolderDAO
This method is looking up for writing rights for a folder and an user.- Specified by:
isWriteEnabled
in interfaceFolderDAO
- Parameters:
folderId
- ID of the folderuserId
- ID of the user- Returns:
- if the write permission is granted
-
isDownloadEnabled
public boolean isDownloadEnabled(long id, long userId)
- Specified by:
isDownloadEnabled
in interfaceFolderDAO
-
isMoveEnabled
public boolean isMoveEnabled(long id, long userId)
- Specified by:
isMoveEnabled
in interfaceFolderDAO
-
isReadEnabled
public boolean isReadEnabled(long folderId, long userId)
- Specified by:
isReadEnabled
in interfaceFolderDAO
-
findFolderIdByUserId
public Collection<Long> findFolderIdByUserId(long userId, Long parentId, boolean tree)
Description copied from interface:FolderDAO
This method selects only the folder ID from the folders for which a user is authorized.- Specified by:
findFolderIdByUserId
in interfaceFolderDAO
- Parameters:
userId
- ID of the user.parentId
- The id of the parent folder to inspect (optional)tree
- If true, the parentId will be interpreted as the root of a tree- Returns:
- List of selected folder IDs.
-
hasWriteAccess
public boolean hasWriteAccess(Folder folder, long userId)
Description copied from interface:FolderDAO
Checks that the user has access to the folder and all its sub-items- Specified by:
hasWriteAccess
in interfaceFolderDAO
- Parameters:
folder
- the folderuserId
- identifier of the document- Returns:
- if the user has write permission
-
findByGroupId
public List<Folder> findByGroupId(long groupId)
Description copied from interface:FolderDAO
Finds all folders accessible by the passed group- Specified by:
findByGroupId
in interfaceFolderDAO
- Parameters:
groupId
- The group id- Returns:
- The List of folders
-
findIdByUserId
public List<Long> findIdByUserId(long userId, long parentId)
Description copied from interface:FolderDAO
This method selects only the folder ID from the folders for which a user is authorized. Only folders direct child of the specified parent are returned.- Specified by:
findIdByUserId
in interfaceFolderDAO
- Parameters:
userId
- ID of the userparentId
- Parent folder- Returns:
- List of selected folder ID's.
-
findByName
public List<Folder> findByName(String name, Long tenantId)
Description copied from interface:FolderDAO
Finds all folders by folder name- Specified by:
findByName
in interfaceFolderDAO
- Parameters:
name
- name of the foldertenantId
- Specification of the owning tenant (optional).- Returns:
- List of folders with given folder name.
-
findByName
public List<Folder> findByName(Folder parent, String name, Long tenantId, boolean caseSensitive)
Description copied from interface:FolderDAO
Finds all folders by folder text, contained in the parent folder.- Specified by:
findByName
in interfaceFolderDAO
- Parameters:
parent
- The parent folder(optional)name
- The folder name to search fortenantId
- Specification of the owning tenant (optional). If not specified the tenant of parent is used insteadcaseSensitive
- true if the search must be case sensitive- Returns:
- List of folders with given name
-
computePath
public String computePath(long folderId)
Description copied from interface:FolderDAO
Dynamically computes the path for the specified folder. The path is a sequence of IDS in the form: /4/55897/99870- Specified by:
computePath
in interfaceFolderDAO
- Parameters:
folderId
- identifier of the folder- Returns:
- the folder's path
-
computePathExtended
public String computePathExtended(long folderId)
Description copied from interface:FolderDAO
Dynamically computes the path extended for the specified folder. The path extended is a human readable path in the form: /folder1/folder2/folder3- Specified by:
computePathExtended
in interfaceFolderDAO
- Parameters:
folderId
- the folder's identifier- Returns:
- The path extended
-
saveFolderHistory
public void saveFolderHistory(Folder folder, FolderHistory transaction)
Utility method that logs into the DB the transaction that involved the passed folder. The transaction must be provided with userId and userName- Specified by:
saveFolderHistory
in interfaceFolderDAO
- Parameters:
folder
- the folder to persisttransaction
- informations about the session
-
findByNameAndParentId
public List<Folder> findByNameAndParentId(String name, long parentId)
Description copied from interface:FolderDAO
Finds that folder that lies under a specific parent (given by the id) an with a given name(like operator is used)- Specified by:
findByNameAndParentId
in interfaceFolderDAO
- Parameters:
name
- name of the dolderparentId
- identifier of the parent folder- Returns:
- list of folders
-
findParents
public List<Folder> findParents(long folderId)
Description copied from interface:FolderDAO
Returns a List of folders being a parent of the given folder. The list is ordered starting from the root of folders. The list doesn't include the given folder.- Specified by:
findParents
in interfaceFolderDAO
- Parameters:
folderId
- ID of the folder- Returns:
- the hierarchy of parent folders
-
findWorkspace
public Folder findWorkspace(long folderId)
Description copied from interface:FolderDAO
Returns the workspace that contains the given folder- Specified by:
findWorkspace
in interfaceFolderDAO
- Parameters:
folderId
- ID of the folder- Returns:
- the workspace containing the fiven folder
-
isPermissionEnabled
public boolean isPermissionEnabled(Permission permission, long folderId, long userId)
Description copied from interface:FolderDAO
This method checks if the given permission is enabled for a folder and an user.- Specified by:
isPermissionEnabled
in interfaceFolderDAO
- Parameters:
permission
- the permission to checkfolderId
- ID of the folderuserId
- ID of the user- Returns:
- if the permission is granted to the user
-
restore
public void restore(long folderId, long parentId, FolderHistory transaction) throws PersistenceException
Description copied from interface:FolderDAO
Restores a previously deleted folder- Specified by:
restore
in interfaceFolderDAO
- Parameters:
folderId
- The folder identifierparentId
- The parent folder to restore intransaction
- Current session informations- Throws:
PersistenceException
- in case of database error
-
getEnabledPermissions
public Set<Permission> getEnabledPermissions(long folderId, long userId)
Description copied from interface:FolderDAO
Finds all permissions of a user enabled on the specified folder- Specified by:
getEnabledPermissions
in interfaceFolderDAO
- Parameters:
folderId
- ID of the folderuserId
- ID of the user- Returns:
- Collection of enabled permissions
-
findFolderIdByUserIdInPath
public Collection<Long> findFolderIdByUserIdInPath(long userId, Long parentId)
Description copied from interface:FolderDAO
This method selects only the folder ID from the folders for which a user is authorized.- Specified by:
findFolderIdByUserIdInPath
in interfaceFolderDAO
- Parameters:
userId
- ID of the user.parentId
- The id of the parent folder to inspect (optional)- Returns:
- List of selected folder IDs.
-
findFolderIdByUserIdAndPermission
public Collection<Long> findFolderIdByUserIdAndPermission(long userId, Permission permission, Long parentId, boolean tree)
Description copied from interface:FolderDAO
Finds all folders ids with a specific permission enabled on the specifies user- Specified by:
findFolderIdByUserIdAndPermission
in interfaceFolderDAO
- Parameters:
userId
- The user identifierpermission
- The permission to checkparentId
- The id of the parent folder to inspect (optional)tree
- If true, the parentId will be interpreted as the root of a tree- Returns:
- List of selected folder IDs.
-
getHistoryDAO
public FolderHistoryDAO getHistoryDAO()
-
setHistoryDAO
public void setHistoryDAO(FolderHistoryDAO historyDAO)
-
deleteAll
public void deleteAll(Collection<Folder> folders, FolderHistory transaction) throws PersistenceException
Description copied from interface:FolderDAO
Shortcut for deleteAll(folders, 1, transaction)- Specified by:
deleteAll
in interfaceFolderDAO
- Parameters:
folders
- the folderstransaction
- current session informations- Throws:
PersistenceException
- in case of database error
-
deleteAll
public void deleteAll(Collection<Folder> folders, int code, FolderHistory transaction) throws PersistenceException
Description copied from interface:FolderDAO
For each folder, save the folder delete history entry for each folder and delete the folder- Specified by:
deleteAll
in interfaceFolderDAO
- Parameters:
folders
- List of folder to be deletecode
- The deletion codetransaction
- entry to log the event on each folder- Throws:
PersistenceException
- in case of database error
-
delete
public boolean delete(long folderId, int code) throws PersistenceException
Description copied from interface:PersistentObjectDAO
This method deletes an entity and you can give a deletion code- Specified by:
delete
in interfacePersistentObjectDAO<Folder>
- Overrides:
delete
in classHibernatePersistentObjectDAO<Folder>
- Parameters:
folderId
- ID of the entity which should be deletedcode
- Deletion code- Returns:
- if the record has been successfully deleted
- Throws:
PersistenceException
- raised in case of errors in the database
-
delete
public boolean delete(long folderId, FolderHistory transaction) throws PersistenceException
Description copied from interface:FolderDAO
Shortcut for delete(id, 1, transaction)- Specified by:
delete
in interfaceFolderDAO
- Parameters:
folderId
- the folder identifiertransaction
- the session informations- Returns:
- if the folde has been succesfully deleted
- Throws:
PersistenceException
- in case of database error
-
delete
public boolean delete(long folderId, int delCode, FolderHistory transaction) throws PersistenceException
Description copied from interface:FolderDAO
This method deletes the folder object and insert a new folder history entry- Specified by:
delete
in interfaceFolderDAO
- Parameters:
folderId
- The id of the folder to deletedelCode
- The deletion codetransaction
- entry to log the event- Returns:
- True if successfully deleted from the database
- Throws:
PersistenceException
- in case of database error
-
applyRightToTree
public boolean applyRightToTree(long rootId, FolderHistory transaction)
Description copied from interface:FolderDAO
Propagates the security policies of a node to the whole subtree- Specified by:
applyRightToTree
in interfaceFolderDAO
- Parameters:
rootId
- identifier of the root foldertransaction
- session informations- Returns:
- if the rights have been correctly applied
-
createAlias
public Folder createAlias(long parentId, long foldRef, FolderHistory transaction) throws PersistenceException
Description copied from interface:FolderDAO
Creates a new folder folder alias- Specified by:
createAlias
in interfaceFolderDAO
- Parameters:
parentId
- The parent folderfoldRef
- The referenced foldertransaction
- optional transaction entry to log the event- Returns:
- The newly created alias
- Throws:
PersistenceException
- in case of database error
-
create
public Folder create(Folder parent, Folder folderVO, boolean inheritSecurity, FolderHistory transaction) throws PersistenceException
Description copied from interface:FolderDAO
Creates a new folder in the parent Folder- Specified by:
create
in interfaceFolderDAO
- Parameters:
parent
- The parent folderfolderVO
- The folder's metadatainheritSecurity
- If true the new folder will 'point' to the parent for the security policies.transaction
- optional transaction entry to log the event- Returns:
- The newly created folder
- Throws:
PersistenceException
- in case of database error
-
createPath
public Folder createPath(Folder parent, String path, boolean inheritSecurity, FolderHistory transaction) throws PersistenceException
Description copied from interface:FolderDAO
Creates the folder for the specified path. All unexisting nodes specified in the path will be created. The path must be in any case inside a workspace, if not, the Default one will be used.- Specified by:
createPath
in interfaceFolderDAO
- Parameters:
parent
- The parent folderpath
- The folder path(for example /dog/cat/mouse)inheritSecurity
- If true the new folders will 'point' to the parent for the security policies.transaction
- optional transaction entry to log the event- Returns:
- The created folder
- Throws:
PersistenceException
- in case of database error
-
findByPathExtended
public Folder findByPathExtended(String pathExtended, long tenantId)
Description copied from interface:FolderDAO
Retrieval of a folder by the extended path- Specified by:
findByPathExtended
in interfaceFolderDAO
- Parameters:
pathExtended
- the path extendedtenantId
- identifier of the tenant- Returns:
- The folder that matched the given path
-
copy
public Folder copy(Folder source, Folder target, String newName, boolean foldersOnly, String securityOption, FolderHistory transaction) throws PersistenceException
Description copied from interface:FolderDAO
Copies a folder into another folder- Specified by:
copy
in interfaceFolderDAO
- Parameters:
source
- The folder to copytarget
- The target foldernewName
- optional new name of the copied folderfoldersOnly
- True if only the folders tree has to be copied; if false, the documents will also be copiedsecurityOption
- How to assign the security policies to the newly created folders:- null or none: empty security policies
- inherit: the new folder will point to the parent for the security policies
- replicate: the new folder will have a copy of the security policies of the source folder
transaction
- entry to log the event (set the user)- Returns:
- The new folder created
- Throws:
PersistenceException
- in case of database error
-
move
public void move(Folder source, Folder target, FolderHistory transaction) throws PersistenceException
Description copied from interface:FolderDAO
Moves a folder into another folder- Specified by:
move
in interfaceFolderDAO
- Parameters:
source
- The folder to movetarget
- The target foldertransaction
- entry to log the event (set the user)- Throws:
PersistenceException
- in case of database error
-
deleteTree
public List<Folder> deleteTree(long folderId, FolderHistory transaction) throws Exception
Description copied from interface:FolderDAO
Shortcut for deleteTree(folderId, 1, transaction)- Specified by:
deleteTree
in interfaceFolderDAO
- Parameters:
folderId
- Folder to deletetransaction
- entry to log the event (set the user)- Returns:
- List of folders that the user cannot delete(permissions, o immutable documents presents)
- Throws:
Exception
- in case of any error
-
deleteTree
public List<Folder> deleteTree(long folderId, int delCode, FolderHistory transaction) throws Exception
Description copied from interface:FolderDAO
Delete a folder and all its sub-folders that a user can delete. After recovering of all sub-folders inside the folder, will be canceled all folders for which the user has the delete permission or there isn't an immutable document inside it.
Important: All the contained documents will be deleted- Specified by:
deleteTree
in interfaceFolderDAO
- Parameters:
folderId
- Folder to deletedelCode
- The deletion codetransaction
- entry to log the event (set the user)- Returns:
- List of folders that the user cannot delete(permissions, o immutable documents presents)
- Throws:
Exception
- in case of any error
-
deleteTree
public List<Folder> deleteTree(Folder folder, int delCode, FolderHistory transaction) throws PersistenceException
Description copied from interface:FolderDAO
Deletes a folder and all its sub-folders that a user can delete. After recovering of all sub-folders inside the folder, will be canceled all folders for which the user has the delete permission or there isn't an immutable document inside it.
Important: Remember to delete orphaned documents.- Specified by:
deleteTree
in interfaceFolderDAO
- Parameters:
folder
- Folder to deletedelCode
- The deletion codetransaction
- entry to log the event (set the user)- Returns:
- List of folders that the user cannot delete(permissions, o immutable documents presents)
- Throws:
PersistenceException
- in case of database error
-
findFolderIdInTree
public Set<Long> findFolderIdInTree(long rootId, boolean includeDeleted)
Description copied from interface:FolderDAO
Retrieve all the ids of the folders in a given tree- Specified by:
findFolderIdInTree
in interfaceFolderDAO
- Parameters:
rootId
- Root of the treeincludeDeleted
- True if the deleted records need to be loaded- Returns:
- List of selected folder IDs, rootId is included as well
-
findFolderIdInPath
public Set<Long> findFolderIdInPath(long rootId, boolean includeDeleted)
Description copied from interface:FolderDAO
Retrieve all the ids of the folders in a given tree using the path attribute- Specified by:
findFolderIdInPath
in interfaceFolderDAO
- Parameters:
rootId
- Root of the folderincludeDeleted
- True if the deleted records need to be loaded- Returns:
- List of selected folder IDs, rootId is included as well
-
find
public List<Folder> find(String name, Long tenantId)
Description copied from interface:FolderDAO
Useful method that allows to find all folders that contains the given name into their text.
-
isInPath
public boolean isInPath(long folderId, long targetId)
Description copied from interface:FolderDAO
Checks if a folder with the given folderId is parent of the folder with the given targetId
-
count
public int count(boolean computeDeleted)
Description copied from interface:FolderDAO
Counts the number of folders
-
findWorkspaces
public List<Folder> findWorkspaces(long tenantId)
Description copied from interface:FolderDAO
Retrieves all the workspaces in the system, that are the first-level folders of typeFolder.TYPE_WORKSPACE
- Specified by:
findWorkspaces
in interfaceFolderDAO
- Parameters:
tenantId
- identifier of the tenant- Returns:
- list of folders
-
initialize
public void initialize(Folder folder)
Description copied from class:HibernatePersistentObjectDAO
Doesn't do anything by default- Specified by:
initialize
in interfaceFolderDAO
- Specified by:
initialize
in interfacePersistentObjectDAO<Folder>
- Overrides:
initialize
in classHibernatePersistentObjectDAO<Folder>
- Parameters:
folder
- The entity to be initialised
-
findDeleted
public List<Folder> findDeleted(long userId, Integer maxHits)
Description copied from interface:FolderDAO
Finds all deleted folders of a specific user.- Specified by:
findDeleted
in interfaceFolderDAO
- Parameters:
userId
- The user that performed the deletionmaxHits
- Optional defines the max number of returned hits- Returns:
- The folders list
-
findRoot
public Folder findRoot(long tenantId)
Description copied from interface:FolderDAO
Retrieves the root folder of the given tenant
-
findDefaultWorkspace
public Folder findDefaultWorkspace(long tenantId)
Description copied from interface:FolderDAO
Retrieves the Default workspace of the given tenant- Specified by:
findDefaultWorkspace
in interfaceFolderDAO
- Parameters:
tenantId
- identifier of the tenant- Returns:
- The default workspace
-
setStorer
public void setStorer(Storer storer)
-
updateSecurityRef
public boolean updateSecurityRef(long folderId, long rightsFolderId, FolderHistory transaction)
Description copied from interface:FolderDAO
Changes the securityRef of the given folder, all the other folders that inherits from this one will be changed accordingly.- Specified by:
updateSecurityRef
in interfaceFolderDAO
- Parameters:
folderId
- identifier of the folderrightsFolderId
- id of the folder to inherit fromtransaction
- session informations- Returns:
- is the update has been successful
-
countDocsInTree
public long countDocsInTree(long rootId)
Description copied from interface:FolderDAO
Counts the number of documents inside a given folder's tree (direct and indirect children)- Specified by:
countDocsInTree
in interfaceFolderDAO
- Parameters:
rootId
- identifier of the root folder- Returns:
- the number of documents contained in the tree
-
computeTreeSize
public long computeTreeSize(long rootId)
Description copied from interface:FolderDAO
Counts the number of documents inside a given folder's tree (direct and indirect children)- Specified by:
computeTreeSize
in interfaceFolderDAO
- Parameters:
rootId
- identifier of the root folder- Returns:
- sum of the sizes of the documents contained in the tree expressed in bytes
-
findAliases
public List<Folder> findAliases(Long foldRef, long tenantId)
Description copied from interface:FolderDAO
Finds all the aliases- Specified by:
findAliases
in interfaceFolderDAO
- Parameters:
foldRef
- The referenced foldertenantId
- The tenant- Returns:
- Collection of aliases
-
findFolder
public Folder findFolder(long folderId)
Description copied from interface:FolderDAO
Gets a folder by a given ID if it is an alias, the referenced folder is returned.- Specified by:
findFolder
in interfaceFolderDAO
- Parameters:
folderId
- The ID- Returns:
- A real folder that is referenced by the given ID
-
applyMetadataToTree
public boolean applyMetadataToTree(long id, FolderHistory transaction)
Description copied from interface:FolderDAO
Propagates the template metadata to the whole subree- Specified by:
applyMetadataToTree
in interfaceFolderDAO
- Parameters:
id
- identifier of the foldertransaction
- session informations- Returns:
- is the update has been successful
-
applyTagsToTree
public boolean applyTagsToTree(long id, FolderHistory transaction)
Description copied from interface:FolderDAO
Propagates the tags to the whole subree- Specified by:
applyTagsToTree
in interfaceFolderDAO
- Parameters:
id
- identifier of the foldertransaction
- session informations- Returns:
- is the update has been successful
-
applyGridToTree
public boolean applyGridToTree(long id, FolderHistory transaction)
Description copied from interface:FolderDAO
Propagates the grid layout of a node to the whole subtree- Specified by:
applyGridToTree
in interfaceFolderDAO
- Parameters:
id
- identifier of the root foldertransaction
- session informations- Returns:
- if the grid layout has been correctly replicated
-
applyStorageToTree
public boolean applyStorageToTree(long id, FolderHistory transaction) throws PersistenceException
Description copied from interface:FolderDAO
Propagates the storage setting to the whole subree- Specified by:
applyStorageToTree
in interfaceFolderDAO
- Parameters:
id
- identifier of the foldertransaction
- session informations- Returns:
- is the update has been successful
- Throws:
PersistenceException
- in case of database error
-
applyOCRToTree
public boolean applyOCRToTree(long id, FolderHistory transaction) throws PersistenceException
Description copied from interface:FolderDAO
Propagates the OCR settings to the whole subree- Specified by:
applyOCRToTree
in interfaceFolderDAO
- Parameters:
id
- identifier of the foldertransaction
- session informations- Returns:
- is the update has been successful
- Throws:
PersistenceException
- in case of database error
-
findByUserIdAndTag
public List<Folder> findByUserIdAndTag(long userId, String tag, Integer max)
Description copied from interface:FolderDAO
Finds authorized folders for a user having a specified tag.- Specified by:
findByUserIdAndTag
in interfaceFolderDAO
- Parameters:
userId
- ID of the usertag
- Tag of the foldermax
- Optional, defines the maximum records number- Returns:
- Collection of found folders
-
findTags
public List<String> findTags(long folderId)
Description copied from interface:FolderDAO
Retrieves the alphabetically ordered list of all the folder's tags
-
merge
public void merge(Folder source, Folder target, FolderHistory transaction) throws PersistenceException
Description copied from interface:FolderDAO
Merges the contents of two folders- Specified by:
merge
in interfaceFolderDAO
- Parameters:
source
- The folder whose contents must be merged inside folderAtarget
- The main folder to use as containertransaction
- the session informations- Throws:
PersistenceException
- in case of database or logical error
-
-