Switched to use utility

This commit is contained in:
Luca Frosini 2023-04-21 17:04:14 +02:00
parent b1153f7283
commit 39556110c2
5 changed files with 10 additions and 7 deletions

View File

@ -7,7 +7,6 @@ import java.util.UUID;
import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
import org.gcube.common.scope.impl.ScopeBean;
import org.gcube.informationsystem.base.reference.IdentifiableElement;
import org.gcube.informationsystem.contexts.reference.entities.Context;
import org.gcube.informationsystem.contexts.reference.relations.IsParentOf;
import org.gcube.informationsystem.resourceregistry.api.contexts.ContextCache;
@ -124,7 +123,7 @@ public class ContextUtility {
OVertex contextVertex = getContextVertexByFullName(oDatabaseDocument, fullName);
uuid = UUID.fromString(contextVertex.getProperty(IdentifiableElement.UUID_PROPERTY));
uuid = UUIDUtility.getUUID(contextVertex);
securityContext = getSecurityContextByUUID(uuid, contextVertex);

View File

@ -363,8 +363,8 @@ public abstract class ElementManagement<El extends OElement, T extends Type> {
protected void checkUUIDMatch() throws ResourceRegistryException {
if(jsonNode.has(IdentifiableElement.UUID_PROPERTY)) {
UUID resourceUUID = UUIDUtility.getUUID(jsonNode);
UUID resourceUUID = UUIDUtility.getUUID(jsonNode);
if(resourceUUID!=null) {
if(resourceUUID.compareTo(uuid) != 0) {
String error = String.format(
"UUID provided in the instance (%s) differs from UUID (%s) used to identify the %s instance",

View File

@ -534,7 +534,9 @@ public class TypeManagement {
String propertyName = newPropertyDefinition.getName();
if(propertyName.compareTo(IdentifiableElement.UUID_PROPERTY)==0 || propertyName.compareTo(IdentifiableElement.METADATA_PROPERTY)==0 || propertyName.compareTo(Relation.PROPAGATION_CONSTRAINT_PROPERTY)==0) {
if(propertyName.compareTo(IdentifiableElement.UUID_PROPERTY)==0 ||
propertyName.compareTo(IdentifiableElement.METADATA_PROPERTY)==0 ||
propertyName.compareTo(Relation.PROPAGATION_CONSTRAINT_PROPERTY)==0) {
continue;
}

View File

@ -7,6 +7,9 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegis
import com.orientechnologies.orient.core.record.OElement;
/**
* @author Luca Frosini (ISTI - CNR)
*/
public class UUIDUtility extends org.gcube.informationsystem.utils.UUIDUtility {
public static UUID getUUID(OElement element) throws ResourceRegistryException {

View File

@ -96,8 +96,7 @@ public class Utility {
}
// TODO Rewrite using Gremlin
String select = "SELECT FROM " + elementType + " WHERE " + IdentifiableElement.UUID_PROPERTY
+ " = \"" + uuid.toString() + "\"";
String select = "SELECT FROM " + elementType + " WHERE " + IdentifiableElement.UUID_PROPERTY + " = \"" + uuid.toString() + "\"";
OResultSet resultSet = oDatabaseDocument.query(select, new HashMap<>());