Fixing deleteFileSetRoutine

This commit is contained in:
Francesco Mangiacrapa 2023-04-28 16:05:58 +02:00
parent f0488d5c73
commit a8b14a911b
1 changed files with 18 additions and 4 deletions

View File

@ -1243,8 +1243,8 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI<
JSONPathWrapper wrapper = new JSONPathWrapper(doc.getTheDocument().toJson());
List<String> matchingPaths = wrapper.getMatchingPaths(path);
log.info("matchingPaths is: "+matchingPaths);
log.info("matchingPaths is: " + matchingPaths);
String error = null;
if (matchingPaths.isEmpty()) {
error = "No Registered FileSet found at " + path;
@ -1263,8 +1263,22 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI<
return doc;
}
RegisteredFileSet fs = Serialization.convert(wrapper.getByPath(path).get(0), RegisteredFileSet.class);
log.debug("Going to delete {}", fs);
// Updated by Francesco
RegisteredFileSet fs = 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;
}
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 {}", path);
log.debug("Error is: ", e);
}
// Updated by Francesco. See #24902
doc = triggerEvent(doc, EventExecutionRequest.Events.ON_DELETE_FILESET,