Package mops.businesslogic.file
Class FileServiceImpl
- java.lang.Object
-
- mops.businesslogic.file.FileServiceImpl
-
- All Implemented Interfaces:
FileService
@Service public class FileServiceImpl extends java.lang.Object implements FileService
Handles requests to MinIO.
-
-
Constructor Summary
Constructors Constructor Description FileServiceImpl(DirectoryService directoryService, FileInfoService fileInfoService, SecurityService securityService, TimeService timeService, FileRepository fileRepository)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Directory
deleteFile(Account account, long fileId)
Deletes a file.void
deleteFileWithoutMeta(long fileId)
INTERNAL USE ONLY.java.util.Set<java.lang.Long>
getAllFileIds()
Fetches all IDs.FileContainer
getFile(Account account, long fileId)
Gets a file.FileInfo
getFileInfo(Account account, long fileId)
Retrieves file meta data.java.util.List<FileListEntry>
getFilesOfDirectory(Account account, long dirId)
Retrieves file meta data of all files in a directory.Directory
renameFile(Account account, long fileId, java.lang.String newName)
Renames a file.void
saveFile(Account account, long dirId, org.springframework.web.multipart.MultipartFile multipartFile, java.util.Set<java.lang.String> tags)
Saves a file.
-
-
-
Constructor Detail
-
FileServiceImpl
public FileServiceImpl(DirectoryService directoryService, FileInfoService fileInfoService, SecurityService securityService, TimeService timeService, FileRepository fileRepository)
-
-
Method Detail
-
saveFile
@Transactional public void saveFile(Account account, long dirId, org.springframework.web.multipart.MultipartFile multipartFile, java.util.Set<java.lang.String> tags) throws MopsException
Saves a file.- Specified by:
saveFile
in interfaceFileService
- Parameters:
account
- user credentialsdirId
- directory id of the future parent foldermultipartFile
- the binary code of the filetags
- the file tag- Throws:
MopsException
-
getFile
public FileContainer getFile(Account account, long fileId) throws MopsException
Gets a file.- Specified by:
getFile
in interfaceFileService
- Parameters:
account
- user credentialsfileId
- file id of needed file- Returns:
- file
- Throws:
MopsException
-
deleteFile
@Transactional public Directory deleteFile(Account account, long fileId) throws MopsException
Deletes a file.- Specified by:
deleteFile
in interfaceFileService
- Parameters:
account
- user credentialsfileId
- file id of file to be deleted- Returns:
- parent directory Id
- Throws:
MopsException
-
getFileInfo
public FileInfo getFileInfo(Account account, long fileId) throws MopsException
Retrieves file meta data.- Specified by:
getFileInfo
in interfaceFileService
- Parameters:
account
- the account object.fileId
- the file ID- Returns:
- the meta info.
- Throws:
MopsException
- on error.
-
getFilesOfDirectory
public java.util.List<FileListEntry> getFilesOfDirectory(Account account, long dirId) throws MopsException
Retrieves file meta data of all files in a directory.- Specified by:
getFilesOfDirectory
in interfaceFileService
- Parameters:
account
- the account object.dirId
- the file ID- Returns:
- the meta info.
- Throws:
MopsException
- on error.
-
getAllFileIds
public java.util.Set<java.lang.Long> getAllFileIds() throws MopsException
Fetches all IDs.- Specified by:
getAllFileIds
in interfaceFileService
- Returns:
- all File IDs
- Throws:
MopsException
-
deleteFileWithoutMeta
public void deleteFileWithoutMeta(long fileId) throws MopsException
INTERNAL USE ONLY. Deletes a file without checking permission. And without removing the corresponding FileInfo.- Specified by:
deleteFileWithoutMeta
in interfaceFileService
- Parameters:
fileId
- the id of the file- Throws:
MopsException
- on error
-
renameFile
public Directory renameFile(Account account, long fileId, java.lang.String newName) throws MopsException
Renames a file.- Specified by:
renameFile
in interfaceFileService
- Parameters:
account
- user credentialsfileId
- the file IDnewName
- the new filename- Returns:
- the directory of the dir
- Throws:
MopsException
- on error
-
-