Advertisement
Coriic

Untitled

Jan 11th, 2017
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. public Object hangleCreateNewFolder(Request request, Response response){
  2. String path = request.params(":path");
  3. String[] pathSplitted = path.split("/");
  4. Random rand = new Random();
  5. int folderID;
  6. for(;;){
  7. folderID = rand.nextInt(10000) + 1;
  8. if(folderMetadataRepostiory.loadFolderOfID(folderID) == null){
  9. break;
  10. }
  11. }
  12. FolderMetadata folderMetadata = new FolderMetadata(folderID,
  13. pathSplitted[pathSplitted.length-2],
  14. path.toLowerCase(),
  15. path,
  16. folderMetadataRepostiory.loadFolderOfPath(path.replace(pathSplitted[pathSplitted.length-2]+"/","")).getFolderId(),
  17. new Date().toString(),
  18. 10);
  19. folderMetadataRepostiory.storeFolderMetadata(folderMetadata);
  20. folderFolderContentsRepository.storeFolderFolderContens(new FolderFolderContents(
  21. folderMetadataRepostiory.loadFolderOfPath(path.replace(pathSplitted[pathSplitted.length-2]+"/","")).getFolderId(),
  22. folderID
  23. ));
  24. response.status(CREATED);
  25. return folderMetadata;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement