Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void handleDeleteFolder(Request request, Response response){
- try{
- PathManager path = new PathManager(request.params(":path"));
- if(!(sessionDataRepository.fetchBySessionId(request.params(":session")).get(0).getUserId()
- .equals(fileMetadataRepository.fetchByFolderPath(path.getPath()).get(0).getOwnerId()))) {
- response.status(UNSUCCESSFULAUTHORIZATION);
- throw new UnsuccessfulAuthorization("Unsuccessful authorization");
- }
- if(folderMetadataRepostiory.fetchByPathDisplay(path.getPath()).isEmpty()) {
- response.status(FOLDERDOESNOTEXIST);
- throw new FileDoesNotExist("Folder with path: " + path.getPath() + " already exists");
- }
- folderMetadataRepostiory.deleteFoldersByPath(path.getPath());
- fileContentsRepository.deleteById(fileMetadataRepository.getFileIdFromPath(path.getPath()));
- fileMetadataRepository.deleteFromSpecifiedPath(path.getPath());
- response.status(DELETED);
- }
- catch(WrongPathFormat ex){
- response.status(INVALIDPATHPARAMETER);
- throw ex;
- }
- catch(RuntimeException ex){
- throw ex;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement