Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //FolderController
- public FolderMetadata handleCreateNewFolder(Request request, Response response){
- try{
- PathManager pathManager = new PathManager(request.params(":path"));
- if(folderMetadataRepostiory.fetchByPathDisplay(pathManager.getPath()).isEmpty()){
- Integer parentID = folderMetadataRepostiory.fetchByPathDisplay(pathManager.getParentPath()).get(0).getFolderId();
- System.out.println(parentID);
- FolderMetadata folderMetadata = new FolderMetadata(null,
- pathManager.getFileName(),
- pathManager.pathToLowerCase(),
- pathManager.getPath(),
- parentID,
- new Date().toString(),
- 10); // TO DO
- FolderMetadata inserted = folderMetadataRepostiory.insertFolder(folderMetadata);
- folderFolderContentsRepository.insertFolder(new FolderFolderContents(parentID, folderMetadata.getFolderId()));
- response.status(CREATED);
- return inserted;
- }
- else{
- response.status(FOLDEREXISTS);
- throw new FolderAlreadyExists("Folder with path: " + pathManager.getPath() + " already exists");
- }
- }
- catch(WrongPathFormat ex){
- response.status(INVALIDPATHPARAMETER);
- throw ex;
- }
- }
- //FolderMetadataDAO
- public pl.edu.agh.kis.florist.db.tables.pojos.FolderMetadata insertFolder(pl.edu.agh.kis.florist.db.tables.pojos.FolderMetadata folderMetadata){
- try (DSLContext create = DSL.using(DB_URL)){
- FolderMetadataRecord record=create.newRecord(FOLDER_METADATA, folderMetadata);
- record.store();
- pl.edu.agh.kis.florist.db.tables.pojos.FolderMetadata retrieved=record.into(pl.edu.agh.kis.florist.db.tables.pojos.FolderMetadata.class);
- return retrieved;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement