Package mops.businesslogic.directory
Class DirectoryServiceImpl
- java.lang.Object
-
- mops.businesslogic.directory.DirectoryServiceImpl
-
- All Implemented Interfaces:
DirectoryService
@Service public class DirectoryServiceImpl extends java.lang.Object implements DirectoryService
Handles meta data for directories.
-
-
Constructor Summary
Constructors Constructor Description DirectoryServiceImpl(DirectoryRepository directoryRepository, SecurityService securityService, PermissionService permissionService, GroupService groupService)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Directory
createFolder(Account account, long parentDirId, java.lang.String dirName)
Creates a new folder inside a folder.void
deleteDirectory(Directory directory)
Internal use only: possible security flaw!.java.util.List<Directory>
getAllRootDirectories()
Fetches list of all root directories.long
getDirCountInGroup(long groupId)
Get the total number of directories in a group.Directory
getDirectory(long dirId)
Internal use only: possible security flaw!.java.util.List<Directory>
getDirectoryPath(long dirId)
Builds directory path as list.GroupRootDirWrapper
getOrCreateRootFolder(long groupId)
Creates the group root directory.java.util.List<Directory>
getSubFolders(Account account, long parentDirID)
Returns all folders of the parent folder.long
getTotalDirCount()
Get the total number of directories in all groups.Directory
renameDirectory(Account account, long dirId, java.lang.String newName)
renames a directory.Directory
saveDirectory(Directory directory)
Internal use only: possible security flaw!.DirectoryPermissions
updatePermission(Account account, long dirId, DirectoryPermissions permissions)
Replaces the permissions for a directory and all its parents and children (which use the same permissions object) with the given ones.
-
-
-
Constructor Detail
-
DirectoryServiceImpl
public DirectoryServiceImpl(DirectoryRepository directoryRepository, SecurityService securityService, PermissionService permissionService, GroupService groupService)
-
-
Method Detail
-
getSubFolders
public java.util.List<Directory> getSubFolders(Account account, long parentDirID) throws MopsException
Returns all folders of the parent folder.- Specified by:
getSubFolders
in interfaceDirectoryService
- Parameters:
account
- user credentialsparentDirID
- id of the parent folder- Returns:
- list of folders
- Throws:
MopsException
-
getDirectoryPath
public java.util.List<Directory> getDirectoryPath(long dirId) throws MopsException
Builds directory path as list.- Specified by:
getDirectoryPath
in interfaceDirectoryService
- Parameters:
dirId
- highest dir of path- Returns:
- directory path ordered list
- Throws:
MopsException
-
getOrCreateRootFolder
public GroupRootDirWrapper getOrCreateRootFolder(long groupId) throws MopsException
Creates the group root directory.- Specified by:
getOrCreateRootFolder
in interfaceDirectoryService
- Parameters:
groupId
- the group id- Returns:
- the directory created
- Throws:
MopsException
-
createFolder
public Directory createFolder(Account account, long parentDirId, java.lang.String dirName) throws MopsException
Creates a new folder inside a folder.- Specified by:
createFolder
in interfaceDirectoryService
- Parameters:
account
- user credentialsparentDirId
- id of the parent folderdirName
- name of the new folder- Returns:
- id of the new folder
- Throws:
MopsException
-
updatePermission
public DirectoryPermissions updatePermission(Account account, long dirId, DirectoryPermissions permissions) throws MopsException
Replaces the permissions for a directory and all its parents and children (which use the same permissions object) with the given ones.- Specified by:
updatePermission
in interfaceDirectoryService
- Parameters:
account
- user credentialsdirId
- directory id for which the permission should be changedpermissions
- new permissions- Returns:
- the updated directory permissions
- Throws:
MopsException
-
getDirectory
public Directory getDirectory(long dirId) throws MopsException
Internal use only: possible security flaw!. Check permission before fetching!- Specified by:
getDirectory
in interfaceDirectoryService
- Parameters:
dirId
- the id of the parent folder- Returns:
- directory object of the requested folder
- Throws:
MopsException
- on error
-
saveDirectory
public Directory saveDirectory(Directory directory) throws MopsException
Internal use only: possible security flaw!. Check permission before saving!- Specified by:
saveDirectory
in interfaceDirectoryService
- Parameters:
directory
- directory to be saved- Returns:
- directory object of the requested folder
- Throws:
MopsException
- on error
-
deleteDirectory
public void deleteDirectory(Directory directory) throws MopsException
Internal use only: possible security flaw!. Check permission before deleting!- Specified by:
deleteDirectory
in interfaceDirectoryService
- Parameters:
directory
- directory to be deleted- Throws:
MopsException
- on error
-
getDirCountInGroup
public long getDirCountInGroup(long groupId) throws MopsException
Get the total number of directories in a group.- Specified by:
getDirCountInGroup
in interfaceDirectoryService
- Parameters:
groupId
- group- Returns:
- directory count
- Throws:
MopsException
-
getTotalDirCount
public long getTotalDirCount() throws MopsException
Get the total number of directories in all groups.- Specified by:
getTotalDirCount
in interfaceDirectoryService
- Returns:
- directory count
- Throws:
MopsException
-
renameDirectory
public Directory renameDirectory(Account account, long dirId, java.lang.String newName) throws MopsException
renames a directory.- Specified by:
renameDirectory
in interfaceDirectoryService
- Parameters:
account
- user credentialsdirId
- directory IDnewName
- new name- Returns:
- the directory
- Throws:
MopsException
- on error
-
getAllRootDirectories
public java.util.List<Directory> getAllRootDirectories() throws MopsException
Fetches list of all root directories.- Specified by:
getAllRootDirectories
in interfaceDirectoryService
- Returns:
- all root directories.
- Throws:
MopsException
- on error.
-
-