Moved sanityCheck in internalCreate() and internalUpdate() functions

This commit is contained in:
Luca Frosini 2021-02-22 11:15:15 +01:00
parent 8822d1a40b
commit f767fc021a
1 changed files with 9 additions and 12 deletions

View File

@ -340,6 +340,8 @@ public abstract class ElementManagement<El extends OElement> {
getWorkingContext().addElement(element, oDatabaseDocument);
sanityCheck();
element.save();
return element;
@ -358,6 +360,9 @@ public abstract class ElementManagement<El extends OElement> {
reallyUpdate();
HeaderUtility.updateModifiedByAndLastUpdate(element);
sanityCheck();
element.save();
return element;
@ -450,8 +455,6 @@ public abstract class ElementManagement<El extends OElement> {
public abstract void sanityCheck() throws SchemaViolationException, ResourceRegistryException;
//public abstract void sanityCheck(Map<UUID, JsonNode> expectedInstances) throws SchemaViolationException, ResourceRegistryException;
public String all(boolean polymorphic) throws ResourceRegistryException {
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
try {
@ -507,16 +510,14 @@ public abstract class ElementManagement<El extends OElement> {
try {
getElement();
update = true;
element = internalUpdate();
internalUpdate();
} catch(NotFoundException e) {
String calledMethod = CalledMethodProvider.instance.get();
calledMethod = calledMethod.replace("update", "create");
CalledMethodProvider.instance.set(calledMethod);
element = internalCreate();
internalCreate();
}
sanityCheck();
oDatabaseDocument.commit();
if(update) {
@ -556,9 +557,7 @@ public abstract class ElementManagement<El extends OElement> {
oDatabaseDocument = getWorkingContext().getDatabaseDocument(PermissionMode.WRITER);
oDatabaseDocument.begin();
element = internalCreate();
sanityCheck();
internalCreate();
oDatabaseDocument.commit();
@ -621,9 +620,7 @@ public abstract class ElementManagement<El extends OElement> {
oDatabaseDocument = getWorkingContext().getDatabaseDocument(PermissionMode.WRITER);
oDatabaseDocument.begin();
element = internalUpdate();
sanityCheck();
internalUpdate();
oDatabaseDocument.commit();