Fix get Folder

This commit is contained in:
Fabio Sinibaldi 2022-11-04 17:48:04 +01:00
parent 222b337308
commit 0ec65d1d30
2 changed files with 23 additions and 10 deletions

View File

@ -78,10 +78,23 @@ public class WorkspaceManager {
sgClient.open(id).asFolder().delete();
}
public FolderContainer getSubFolder(FolderContainer parentFolder,String path) throws StorageHubException {
public FolderContainer getSubFolder(FolderContainer parentFolder,String path) throws StorageHubException {
return getSubFolder(parentFolder,path,"");
}
/**
* Returns sub folder. Creates it if missing
*
* @param parentFolder
* @param path
* @return
* @throws StorageHubException
*/
public FolderContainer getSubFolder(FolderContainer parentFolder,String path, String description) throws StorageHubException {
try{
return parentFolder.openByRelativePath(path).asFolder();
}catch(StorageHubException e) {
}catch(StorageHubException e) {
log.debug("Missing subPath "+path);
FolderContainer targetParent=parentFolder;
String targetName=path;
@ -91,8 +104,9 @@ public class WorkspaceManager {
targetParent=getSubFolder(parentFolder,parent);
targetName=path.substring(path.lastIndexOf("/")+1);
}
log.debug("Creating "+targetName);
return createFolder(new FolderOptions(targetName,"",targetParent));
FolderOptions opts = new FolderOptions(targetName,description,targetParent);
log.debug("Creating FOLDER {}", opts);
return createFolder(opts);
}
}

View File

@ -624,8 +624,6 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI<
}
if(!policy.canWrite(doc,u)) throw new UnauthorizedAccess("No edit rights on project "+id);
doc.getLifecycleInformation().cleanState();
doc.getLifecycleInformation().setLastOperationStatus(LifecycleInformation.Status.OK);
@ -968,10 +966,11 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI<
log.trace("Folder ID is {} ",folderID);
FolderContainer sectionFolder=null;
if(folderID==null || folderID.isEmpty()) {
FolderContainer base = ws.createFolder(new WorkspaceManager.FolderOptions(
docID, "Base Folder for profiled document. UseCaseDescriptor " + profileID, null));
sectionFolder = ws.createFolder(new WorkspaceManager.FolderOptions(
docID + "_" + uuid, "Registered Fileset uuid " + uuid, base));
// Get BASE Folder for project
FolderContainer base = ws.getSubFolder(ws.getAppBase(),docID,"Base Folder for profiled document. UseCaseDescriptor " + profileID);
// Create Folder for FileSet
sectionFolder = ws.createFolder(new WorkspaceManager.FolderOptions(docID + "_" + uuid, "Registered Fileset uuid " + uuid, base));
toReturn.put(RegisteredFileSet.FOLDER_ID, sectionFolder.getId());
}else {
sectionFolder = ws.getFolderById(folderID);