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 DirectorycreateFolder(Account account, long parentDirId, java.lang.String dirName)Creates a new folder inside a folder.voiddeleteDirectory(Directory directory)Internal use only: possible security flaw!.java.util.List<Directory>getAllRootDirectories()Fetches list of all root directories.longgetDirCountInGroup(long groupId)Get the total number of directories in a group.DirectorygetDirectory(long dirId)Internal use only: possible security flaw!.java.util.List<Directory>getDirectoryPath(long dirId)Builds directory path as list.GroupRootDirWrappergetOrCreateRootFolder(long groupId)Creates the group root directory.java.util.List<Directory>getSubFolders(Account account, long parentDirID)Returns all folders of the parent folder.longgetTotalDirCount()Get the total number of directories in all groups.DirectoryrenameDirectory(Account account, long dirId, java.lang.String newName)renames a directory.DirectorysaveDirectory(Directory directory)Internal use only: possible security flaw!.DirectoryPermissionsupdatePermission(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:
getSubFoldersin 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:
getDirectoryPathin 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:
getOrCreateRootFolderin 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:
createFolderin 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:
updatePermissionin 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:
getDirectoryin 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:
saveDirectoryin 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:
deleteDirectoryin interfaceDirectoryService- Parameters:
directory- directory to be deleted- Throws:
MopsException- on error
-
getDirCountInGroup
public long getDirCountInGroup(long groupId) throws MopsExceptionGet the total number of directories in a group.- Specified by:
getDirCountInGroupin interfaceDirectoryService- Parameters:
groupId- group- Returns:
- directory count
- Throws:
MopsException
-
getTotalDirCount
public long getTotalDirCount() throws MopsExceptionGet the total number of directories in all groups.- Specified by:
getTotalDirCountin 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:
renameDirectoryin 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:
getAllRootDirectoriesin interfaceDirectoryService- Returns:
- all root directories.
- Throws:
MopsException- on error.
-
-