Package mops.businesslogic.file
Class FileInfoServiceImpl
- java.lang.Object
-
- mops.businesslogic.file.FileInfoServiceImpl
-
- All Implemented Interfaces:
FileInfoService
@Service public class FileInfoServiceImpl extends java.lang.Object implements FileInfoService
Handles meta data for files.
-
-
Constructor Summary
Constructors Constructor Description FileInfoServiceImpl(FileInfoRepository fileInfoRepo)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
deleteFileInfo(long fileId)
Delete file from database by id.java.util.Set<java.lang.Long>
fetchAllFileInfoIds()
Fetches all available FileInfo ids.java.util.List<FileInfo>
fetchAllFilesInDirectory(long dirId)
Lists all files in a specific directory.java.util.Set<java.lang.Long>
fetchAllOrphanedFileInfos()
Fetches all FileInfos which are in non existing directories.FileInfo
fetchFileInfo(long fileId)
Get a file by id.long
getFileCountInGroup(long groupId)
Get the total number of files in a group.long
getStorageUsageInGroup(long groupId)
Get the total number of bytes used by that group.long
getTotalFileCount()
Get the total number of files in all groups.long
getTotalStorageUsage()
Get the total number of bytes used by all groups.FileInfo
saveFileInfo(FileInfo fileInfo)
Save file to database.
-
-
-
Constructor Detail
-
FileInfoServiceImpl
public FileInfoServiceImpl(FileInfoRepository fileInfoRepo)
-
-
Method Detail
-
fetchAllFilesInDirectory
public java.util.List<FileInfo> fetchAllFilesInDirectory(long dirId) throws MopsException
Lists all files in a specific directory.- Specified by:
fetchAllFilesInDirectory
in interfaceFileInfoService
- Parameters:
dirId
- directory id- Returns:
- a list of files in that directory
- Throws:
MopsException
-
fetchFileInfo
public FileInfo fetchFileInfo(long fileId) throws MopsException
Get a file by id.- Specified by:
fetchFileInfo
in interfaceFileInfoService
- Parameters:
fileId
- file id- Returns:
- a FileInfo object
- Throws:
MopsException
-
saveFileInfo
public FileInfo saveFileInfo(FileInfo fileInfo) throws MopsException
Save file to database.- Specified by:
saveFileInfo
in interfaceFileInfoService
- Parameters:
fileInfo
- Metadata of a file- Returns:
- the freshly saved FileInfo
- Throws:
MopsException
-
deleteFileInfo
public void deleteFileInfo(long fileId) throws MopsException
Delete file from database by id.- Specified by:
deleteFileInfo
in interfaceFileInfoService
- Parameters:
fileId
- file id- Throws:
MopsException
-
getStorageUsageInGroup
public long getStorageUsageInGroup(long groupId) throws MopsException
Get the total number of bytes used by that group.- Specified by:
getStorageUsageInGroup
in interfaceFileInfoService
- Parameters:
groupId
- group- Returns:
- bytes used
- Throws:
MopsException
-
getTotalStorageUsage
public long getTotalStorageUsage() throws MopsException
Get the total number of bytes used by all groups.- Specified by:
getTotalStorageUsage
in interfaceFileInfoService
- Returns:
- bytes used
- Throws:
MopsException
-
getFileCountInGroup
public long getFileCountInGroup(long groupId) throws MopsException
Get the total number of files in a group.- Specified by:
getFileCountInGroup
in interfaceFileInfoService
- Parameters:
groupId
- group- Returns:
- file count
- Throws:
MopsException
-
getTotalFileCount
public long getTotalFileCount() throws MopsException
Get the total number of files in all groups.- Specified by:
getTotalFileCount
in interfaceFileInfoService
- Returns:
- file count
- Throws:
MopsException
-
fetchAllFileInfoIds
public java.util.Set<java.lang.Long> fetchAllFileInfoIds() throws MopsException
Fetches all available FileInfo ids.- Specified by:
fetchAllFileInfoIds
in interfaceFileInfoService
- Returns:
- all ids
- Throws:
MopsException
- on error
-
fetchAllOrphanedFileInfos
public java.util.Set<java.lang.Long> fetchAllOrphanedFileInfos() throws MopsException
Fetches all FileInfos which are in non existing directories.- Specified by:
fetchAllOrphanedFileInfos
in interfaceFileInfoService
- Returns:
- all ids
- Throws:
MopsException
- on error
-
-