Improving code

This commit is contained in:
Luca Frosini 2021-03-02 09:35:02 +01:00
parent c65e84a0bb
commit 0a807d74a2
5 changed files with 13 additions and 18 deletions

View File

@ -128,14 +128,6 @@ public abstract class ElementManagement<El extends OElement, T extends Type> {
public UUID getUUID() {
return uuid;
}
public boolean isEntryPoint() {
return entryPoint;
}
public void setEntryPoint(boolean entryPoint) {
this.entryPoint = entryPoint;
}
public boolean isReload() {
return reload;
@ -496,6 +488,7 @@ public abstract class ElementManagement<El extends OElement, T extends Type> {
public abstract String reallyGetAll(boolean polymorphic) throws ResourceRegistryException;
public String all(boolean polymorphic) throws ResourceRegistryException {
entryPoint = true;
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
try {
oDatabaseDocument = getWorkingContext().getDatabaseDocument(PermissionMode.READER);
@ -516,6 +509,7 @@ public abstract class ElementManagement<El extends OElement, T extends Type> {
}
public boolean exists() throws NotFoundException, AvailableInAnotherContextException, ResourceRegistryException {
entryPoint = true;
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
try {
oDatabaseDocument = getWorkingContext().getDatabaseDocument(PermissionMode.READER);
@ -542,6 +536,7 @@ public abstract class ElementManagement<El extends OElement, T extends Type> {
public String createOrUpdate()
throws NotFoundException, AvailableInAnotherContextException, ResourceRegistryException {
entryPoint = true;
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
try {
oDatabaseDocument = getWorkingContext().getDatabaseDocument(PermissionMode.WRITER);
@ -592,6 +587,7 @@ public abstract class ElementManagement<El extends OElement, T extends Type> {
}
public String create() throws AlreadyPresentException, ResourceRegistryException {
entryPoint = true;
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
try {
oDatabaseDocument = getWorkingContext().getDatabaseDocument(PermissionMode.WRITER);
@ -629,9 +625,9 @@ public abstract class ElementManagement<El extends OElement, T extends Type> {
}
public String read() throws NotFoundException, AvailableInAnotherContextException, ResourceRegistryException {
entryPoint = true;
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
try {
oDatabaseDocument = getWorkingContext().getDatabaseDocument(PermissionMode.READER);
getElement();
@ -655,6 +651,7 @@ public abstract class ElementManagement<El extends OElement, T extends Type> {
}
public String update() throws NotFoundException, AvailableInAnotherContextException, ResourceRegistryException {
entryPoint = true;
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
try {
oDatabaseDocument = getWorkingContext().getDatabaseDocument(PermissionMode.WRITER);
@ -694,6 +691,7 @@ public abstract class ElementManagement<El extends OElement, T extends Type> {
}
public boolean delete() throws NotFoundException, AvailableInAnotherContextException, ResourceRegistryException {
entryPoint = true;
logger.debug("Going to delete {} with UUID {}", accessType.getName(), uuid);
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
try {
@ -737,6 +735,7 @@ public abstract class ElementManagement<El extends OElement, T extends Type> {
public Set<String> getContextsSet() throws NotFoundException, ContextException, ResourceRegistryException {
entryPoint = true;
logger.debug("Going to get contexts for {} with UUID", typeName, uuid);
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
try {

View File

@ -347,6 +347,7 @@ public abstract class EntityManagement<E extends Entity, ET extends EntityType>
}
public Map<UUID,JsonNode> addToContext(UUID contextUUID) throws SchemaViolationException, NotFoundException, ContextException, ResourceRegistryException {
entryPoint = true;
logger.info("Going to add {} with UUID {} to Context with UUID {}", accessType.getName(), uuid, contextUUID);
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
try {
@ -438,6 +439,7 @@ public abstract class EntityManagement<E extends Entity, ET extends EntityType>
public Map<UUID,JsonNode> removeFromContext(UUID contextUUID)
throws SchemaViolationException, NotFoundException, ContextException, ResourceRegistryException {
entryPoint = true;
logger.debug("Going to remove {} with UUID {} from Context with UUID {}", typeName, uuid, contextUUID);
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
try {
@ -794,6 +796,7 @@ public abstract class EntityManagement<E extends Entity, ET extends EntityType>
public String query(String relationType, String referenceType, UUID referenceUUID, ODirection direction,
boolean polymorphic, Map<String,String> constraint, boolean includeRelationInResult) throws ResourceRegistryException {
try {
entryPoint = true;
oDatabaseDocument = getWorkingContext().getDatabaseDocument(PermissionMode.READER);
TypesCache typesCache = TypesCache.getInstance();

View File

@ -536,6 +536,7 @@ public abstract class RelationManagement<T extends EntityManagement<? extends En
}
public Map<UUID,JsonNode> addToContext(UUID contextUUID) throws NotFoundException, ContextException {
entryPoint = true;
logger.debug("Going to add {} with UUID {} to Context with UUID {}", accessType.getName(), uuid, contextUUID);
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
try {
@ -678,6 +679,7 @@ public abstract class RelationManagement<T extends EntityManagement<? extends En
public Map<UUID,JsonNode> removeFromContext(UUID contextUUID)
throws NotFoundException, ContextException, ResourceRegistryException {
entryPoint = true;
logger.debug("Going to remove {} with UUID {} from Context with UUID {}", typeName, uuid, contextUUID);
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
try {

View File

@ -55,7 +55,6 @@ public class InstancesManager extends BaseRest {
@SuppressWarnings("rawtypes")
ElementManagement erManagement = ElementManagementUtility.getERManagement(type);
erManagement.setEntryPoint(true);
return erManagement.all(polymorphic);
}
@ -78,8 +77,6 @@ public class InstancesManager extends BaseRest {
@SuppressWarnings("rawtypes")
ElementManagement erManagement = ElementManagementUtility.getERManagement(type);
erManagement.setEntryPoint(true);
try {
erManagement.setUUID(UUID.fromString(uuid));
boolean found = erManagement.exists();
@ -118,7 +115,6 @@ public class InstancesManager extends BaseRest {
@SuppressWarnings("rawtypes")
ElementManagement erManagement = ElementManagementUtility.getERManagement(type);
erManagement.setEntryPoint(true);
erManagement.setElementType(type);
erManagement.setUUID(UUID.fromString(uuid));
return erManagement.read().toString();
@ -143,11 +139,9 @@ public class InstancesManager extends BaseRest {
@SuppressWarnings("rawtypes")
ElementManagement erManagement = ElementManagementUtility.getERManagement(type);
erManagement.setEntryPoint(true);
erManagement.setUUID(UUID.fromString(uuid));
erManagement.setElementType(type);
erManagement.setJson(json);
return erManagement.createOrUpdate();
}
@ -165,7 +159,6 @@ public class InstancesManager extends BaseRest {
@SuppressWarnings("rawtypes")
ElementManagement erManagement = ElementManagementUtility.getERManagement(type);
erManagement.setEntryPoint(true);
erManagement.setUUID(UUID.fromString(uuid));
erManagement.delete();
@ -194,7 +187,6 @@ public class InstancesManager extends BaseRest {
@SuppressWarnings("rawtypes")
ElementManagement erManagement = ElementManagementUtility.getERManagement(type);
erManagement.setEntryPoint(true);
erManagement.setUUID(UUID.fromString(instanceId));
return erManagement.getContexts();
}

View File

@ -185,7 +185,6 @@ public class SharingManager {
ElementManagement<?,?> elementManagement = ElementManagementUtility.getERManagement(type);
elementManagement.setEntryPoint(true);
elementManagement.setUUID(UUID.fromString(instanceId));
((ERManagement) elementManagement).setDryRunContextSharing(dryRun);