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 DirectorydeleteFile(Account account, long fileId)Deletes a file.voiddeleteFileWithoutMeta(long fileId)INTERNAL USE ONLY.java.util.Set<java.lang.Long>getAllFileIds()Fetches all IDs.FileContainergetFile(Account account, long fileId)Gets a file.FileInfogetFileInfo(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.DirectoryrenameFile(Account account, long fileId, java.lang.String newName)Renames a file.voidsaveFile(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:
saveFilein 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:
getFilein 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:
deleteFilein 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:
getFileInfoin 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:
getFilesOfDirectoryin 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 MopsExceptionFetches all IDs.- Specified by:
getAllFileIdsin interfaceFileService- Returns:
- all File IDs
- Throws:
MopsException
-
deleteFileWithoutMeta
public void deleteFileWithoutMeta(long fileId) throws MopsExceptionINTERNAL USE ONLY. Deletes a file without checking permission. And without removing the corresponding FileInfo.- Specified by:
deleteFileWithoutMetain 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:
renameFilein interfaceFileService- Parameters:
account- user credentialsfileId- the file IDnewName- the new filename- Returns:
- the directory of the dir
- Throws:
MopsException- on error
-
-