Advertisement
Coriic

Untitled

Jan 12th, 2017
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. public FolderMetadata handleCreateNewFolder(Request request, Response response){
  2. try{
  3. PathManager pathManager = new PathManager(request.params(":path"));
  4. if(folderMetadataRepostiory.fetchByPathDisplay(pathManager.getPath()) != null){
  5. int parentID = folderMetadataRepostiory.fetchByPathDisplay(pathManager.getParentPath()).get(0).getParentFolderId();
  6. FolderMetadata folderMetadata = new FolderMetadata(null,
  7. pathManager.getFileName(),
  8. pathManager.pathToLowerCase(),
  9. pathManager.getPath(),
  10. parentID,
  11. new Date().toString(),
  12. null); // TO DO
  13. FolderMetadata inserted = folderMetadataRepostiory.insertFolder(folderMetadata);
  14. folderFolderContentsRepository.insertFolder(new FolderFolderContents(parentID, folderMetadata.getFolderId()));
  15. response.status(CREATED);
  16. return inserted;
  17. }
  18. else{
  19. response.status(FOLDEREXISTS);
  20. return null;
  21. }
  22. }
  23. catch(WrongPathFormat ex){
  24. response.status(INVALIDPATHPARAMETER);
  25. return null;
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement