improved deleteFileSetRoutine

This commit is contained in:
Francesco Mangiacrapa 2023-04-28 16:39:51 +02:00
parent 2593fbf195
commit 8b92ee395b
1 changed files with 24 additions and 9 deletions

View File

@ -1122,7 +1122,7 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI<
throws ConfigurationException, StorageHubException, JsonProcessingException, DeletionException,
EventException, ProjectLockedException, ProjectNotFoundException, InvalidLockException,
InvalidUserRoleException, UnauthorizedAccess {
log.info("Deleting Fileset for {} [useCaseDescriptor ID {}], at {} [force {} and ignore_errors {}]", id,
log.info("Deleting Fileset for P_ID {} [UCD_ID {}], at {} [force {} and ignore_errors {}]", id,
useCaseDescriptor.getId(), path, force, ignore_errors);
Project doc = lock(id, "Fileset Deletion");
try {
@ -1263,22 +1263,37 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI<
return doc;
}
// Updated by Francesco
// Changed by Francesco
RegisteredFileSet fs = null;
error = null;
Exception theExc = null;
try {
List<Object> deleteList = wrapper.getByPath(path);
if (deleteList == null || deleteList.isEmpty()) {
log.info("List of object going to delete is null or empty, retuning input doc");
return doc;
error = "List of object going to delete is null or empty";
log.info(error);
}
Object toFileSet = deleteList.get(0); // expected one
fs = Serialization.convert(toFileSet, RegisteredFileSet.class);
log.info("Going to delete {}", fs);
if (error == null) {
Object toFileSet = deleteList.get(0); // expected one
fs = Serialization.convert(toFileSet, RegisteredFileSet.class);
log.info("Going to delete {}", fs);
}
} catch (Exception e) {
log.warn("Error on getting the RegisteredFileSet for path {}. Returning the input doc {}", path, doc.getId());
error = "Error on getting the RegisteredFileSet for path: " + path;
log.warn(error);
log.debug("Error is: ", e);
return doc;
theExc = e;
}
if (error != null) {
if (ignore_errors) {
log.info("ignore_errors is {}, returning input doc {}", ignore_errors, doc.getId());
return doc;
}
log.info("Thrown "+ConfigurationException.class.getSimpleName()+" with message {}", theExc.getMessage());
throw new ConfigurationException(theExc.getMessage());
}
// Updated by Francesco. See #24902