From cf29667f190e428706540c493684a7c3ec5d814e Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Fri, 26 Feb 2021 12:17:32 +0100 Subject: [PATCH 01/10] Enhanced and tested OrientDB version to 3.0.37 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 99c2b8a..b7eae4f 100644 --- a/pom.xml +++ b/pom.xml @@ -53,7 +53,7 @@ com.orientechnologies orientdb-graphdb - 3.0.35 + 3.0.37 org.gcube.common From 129c4b5b54db0cd014bd27e72dc4f2b30e478ce7 Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Fri, 26 Feb 2021 18:08:13 +0100 Subject: [PATCH 02/10] Getting constant from ORientDB class in place of redefining it --- .../dbinitialization/DatabaseEnvironment.java | 4 +--- .../informationsystem/resourceregistry/types/CachedType.java | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/dbinitialization/DatabaseEnvironment.java b/src/main/java/org/gcube/informationsystem/resourceregistry/dbinitialization/DatabaseEnvironment.java index 7a7d02a..3bc2a78 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/dbinitialization/DatabaseEnvironment.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/dbinitialization/DatabaseEnvironment.java @@ -114,8 +114,6 @@ public class DatabaseEnvironment { private static final String SERVER_URI; public static final String DB_URI; - public static final String O_RESTRICTED_CLASS = "ORestricted"; - public static final CONNECTION_STRATEGY CONNECTION_STRATEGY_PARAMETER = CONNECTION_STRATEGY.ROUND_ROBIN_CONNECT; // Used to indicate virtual admin security context @@ -381,7 +379,7 @@ public class DatabaseEnvironment { logger.trace( "Setting Record-level Security (see https://orientdb.com/docs/last/Database-Security.html)"); OSchema oSchema = oMetadata.getSchema(); - OClass oRestricted = oSchema.getClass(O_RESTRICTED_CLASS); + OClass oRestricted = oSchema.getClass(OSecurity.RESTRICTED_CLASSNAME); OClass v = oSchema.getClass("V"); v.addSuperClass(oRestricted); diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/types/CachedType.java b/src/main/java/org/gcube/informationsystem/resourceregistry/types/CachedType.java index a3d6aeb..a064ccb 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/types/CachedType.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/types/CachedType.java @@ -13,7 +13,6 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.Schema import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility; import org.gcube.informationsystem.resourceregistry.contexts.security.AdminSecurityContext; import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext.PermissionMode; -import org.gcube.informationsystem.resourceregistry.dbinitialization.DatabaseEnvironment; import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagement; import org.gcube.informationsystem.types.TypeMapper; import org.gcube.informationsystem.types.reference.Type; @@ -25,6 +24,7 @@ import com.orientechnologies.orient.core.db.document.ODatabaseDocument; import com.orientechnologies.orient.core.metadata.OMetadata; import com.orientechnologies.orient.core.metadata.schema.OClass; import com.orientechnologies.orient.core.metadata.schema.OSchema; +import com.orientechnologies.orient.core.metadata.security.OSecurity; import com.tinkerpop.blueprints.util.StringFactory; /** @@ -132,7 +132,7 @@ public class CachedType { CachedType cachedType = typesCache.getCachedType(name); cachedType.setOClass(oSuperClass); if(name.compareTo(StringFactory.V.toUpperCase()) == 0 || name.compareTo(StringFactory.E.toUpperCase()) == 0 - || name.compareTo(DatabaseEnvironment.O_RESTRICTED_CLASS) == 0) { + || name.compareTo(OSecurity.RESTRICTED_CLASSNAME) == 0) { continue; } From 9deed7214b30e76da50f5a0490814edaec6450d6 Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Fri, 26 Feb 2021 18:11:35 +0100 Subject: [PATCH 03/10] fixed log --- .../resourceregistry/dbinitialization/DatabaseEnvironment.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/dbinitialization/DatabaseEnvironment.java b/src/main/java/org/gcube/informationsystem/resourceregistry/dbinitialization/DatabaseEnvironment.java index 3bc2a78..3b330f3 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/dbinitialization/DatabaseEnvironment.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/dbinitialization/DatabaseEnvironment.java @@ -377,7 +377,7 @@ public class DatabaseEnvironment { } logger.trace( - "Setting Record-level Security (see https://orientdb.com/docs/last/Database-Security.html)"); + "Setting Record-level Security (see http://orientdb.com/docs/3.0.x/security/Database-Security.html#record-level-security)"); OSchema oSchema = oMetadata.getSchema(); OClass oRestricted = oSchema.getClass(OSecurity.RESTRICTED_CLASSNAME); From cc908bf1b0ecaaa72b4d8f886807ea0d60070956 Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Fri, 26 Feb 2021 18:37:57 +0100 Subject: [PATCH 04/10] Cleaning code --- .../dbinitialization/DatabaseEnvironment.java | 7 +++++-- .../resourceregistry/utils/HeaderUtility.java | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/dbinitialization/DatabaseEnvironment.java b/src/main/java/org/gcube/informationsystem/resourceregistry/dbinitialization/DatabaseEnvironment.java index 3b330f3..7c5558c 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/dbinitialization/DatabaseEnvironment.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/dbinitialization/DatabaseEnvironment.java @@ -136,6 +136,9 @@ public class DatabaseEnvironment { private static final Key KEY; + public static final String V = "V"; + public static final String E = "E"; + static { Properties properties = new Properties(); InputStream input = null; @@ -381,10 +384,10 @@ public class DatabaseEnvironment { OSchema oSchema = oMetadata.getSchema(); OClass oRestricted = oSchema.getClass(OSecurity.RESTRICTED_CLASSNAME); - OClass v = oSchema.getClass("V"); + OClass v = oSchema.getClass(V); v.addSuperClass(oRestricted); - OClass e = oSchema.getClass("E"); + OClass e = oSchema.getClass(E); e.addSuperClass(oRestricted); oDatabaseSession.commit(); diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/utils/HeaderUtility.java b/src/main/java/org/gcube/informationsystem/resourceregistry/utils/HeaderUtility.java index dac4ae7..d907fe9 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/utils/HeaderUtility.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/utils/HeaderUtility.java @@ -21,7 +21,6 @@ import org.slf4j.LoggerFactory; import com.orientechnologies.orient.core.record.OElement; import com.orientechnologies.orient.core.record.impl.ODocument; -import com.tinkerpop.blueprints.Edge; /** * @author Luca Frosini (ISTI - CNR) @@ -121,11 +120,13 @@ public class HeaderUtility { return header; } + /* public static Header addHeader(Edge edge, UUID uuid) { Header header = createHeader(uuid); edge.setProperty(IdentifiableElement.HEADER_PROPERTY, header); return header; } + */ public static Header getHeader(OElement element) throws ResourceRegistryException { return Utility.getPropertyDocument(Header.class, element, IdentifiableElement.HEADER_PROPERTY); From 5f8850611de60c94c773576e8244c440b91db48b Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Fri, 26 Feb 2021 18:39:53 +0100 Subject: [PATCH 05/10] Cleaning code --- .../informationsystem/resourceregistry/types/CachedType.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/types/CachedType.java b/src/main/java/org/gcube/informationsystem/resourceregistry/types/CachedType.java index a064ccb..8f03252 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/types/CachedType.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/types/CachedType.java @@ -13,6 +13,7 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.Schema import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility; import org.gcube.informationsystem.resourceregistry.contexts.security.AdminSecurityContext; import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext.PermissionMode; +import org.gcube.informationsystem.resourceregistry.dbinitialization.DatabaseEnvironment; import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagement; import org.gcube.informationsystem.types.TypeMapper; import org.gcube.informationsystem.types.reference.Type; @@ -25,7 +26,6 @@ import com.orientechnologies.orient.core.metadata.OMetadata; import com.orientechnologies.orient.core.metadata.schema.OClass; import com.orientechnologies.orient.core.metadata.schema.OSchema; import com.orientechnologies.orient.core.metadata.security.OSecurity; -import com.tinkerpop.blueprints.util.StringFactory; /** * @author Luca Frosini (ISTI - CNR) @@ -131,7 +131,7 @@ public class CachedType { String name = oSuperClass.getName(); CachedType cachedType = typesCache.getCachedType(name); cachedType.setOClass(oSuperClass); - if(name.compareTo(StringFactory.V.toUpperCase()) == 0 || name.compareTo(StringFactory.E.toUpperCase()) == 0 + if(name.compareTo(DatabaseEnvironment.V) == 0 || name.compareTo(DatabaseEnvironment.E) == 0 || name.compareTo(OSecurity.RESTRICTED_CLASSNAME) == 0) { continue; } From 6d3d9b8e374220c1d07a7897e2f0cfac63058503 Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Fri, 26 Feb 2021 18:41:14 +0100 Subject: [PATCH 06/10] Cleaning code --- .../gcube/informationsystem/resourceregistry/rest/Access.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/rest/Access.java b/src/main/java/org/gcube/informationsystem/resourceregistry/rest/Access.java index 2c3fe65..90c0ccd 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/rest/Access.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/rest/Access.java @@ -40,7 +40,6 @@ import org.gcube.informationsystem.types.TypeMapper; import org.gcube.informationsystem.types.reference.Type; import com.orientechnologies.orient.core.record.ODirection; -import com.tinkerpop.blueprints.Direction; /** * @author Luca Frosini (ISTI - CNR) @@ -421,7 +420,7 @@ public class Access extends BaseRest { try { directionEnum = ODirection.valueOf(direction.toUpperCase()); } catch(Exception e) { - String error = String.format("%s is not a valid. Allowed values are %s", direction, Direction.values()); + String error = String.format("%s is not a valid. Allowed values are %s", direction, ODirection.values()); throw new InvalidQueryException(error); } From b3433d2d234ad417df6e6d31db87d588b492f36a Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Fri, 26 Feb 2021 18:41:55 +0100 Subject: [PATCH 07/10] Cleaning code --- .../instances/base/ElementManagement.java | 4 ++++ .../instances/base/entities/EntityElementManagement.java | 8 ++++---- .../instances/model/entities/EntityManagement.java | 8 ++++---- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/ElementManagement.java b/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/ElementManagement.java index e3410d1..a3551f5 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/ElementManagement.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/ElementManagement.java @@ -73,6 +73,10 @@ public abstract class ElementManagement { public final static String AT = "@"; public final static String UNDERSCORE = "_"; + public final static String IN_PREFIX = "in_"; + public final static String OUT_PREFIX = "out_"; + + /* * * The classes which has not to be included in the superClasses property when serialize and instance * e.g. for any Resource instance when mast not include Entity and any Entity super class diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/entities/EntityElementManagement.java b/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/entities/EntityElementManagement.java index 2c51c6d..3cd095b 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/entities/EntityElementManagement.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/entities/EntityElementManagement.java @@ -43,10 +43,10 @@ public abstract class EntityElementManagement(); diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/instances/model/entities/EntityManagement.java b/src/main/java/org/gcube/informationsystem/resourceregistry/instances/model/entities/EntityManagement.java index cff239c..8a9b0a6 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/instances/model/entities/EntityManagement.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/instances/model/entities/EntityManagement.java @@ -133,10 +133,10 @@ public abstract class EntityManagement this.ignoreKeys.add(Entity.HEADER_PROPERTY); - this.ignoreStartWithKeys.add(com.tinkerpop.blueprints.impls.orient.OrientVertex.CONNECTION_IN_PREFIX.toLowerCase()); - this.ignoreStartWithKeys.add(com.tinkerpop.blueprints.impls.orient.OrientVertex.CONNECTION_OUT_PREFIX.toLowerCase()); - this.ignoreStartWithKeys.add(com.tinkerpop.blueprints.impls.orient.OrientVertex.CONNECTION_IN_PREFIX.toUpperCase()); - this.ignoreStartWithKeys.add(com.tinkerpop.blueprints.impls.orient.OrientVertex.CONNECTION_OUT_PREFIX.toUpperCase()); + this.ignoreStartWithKeys.add(IN_PREFIX.toLowerCase()); + this.ignoreStartWithKeys.add(OUT_PREFIX.toLowerCase()); + this.ignoreStartWithKeys.add(IN_PREFIX.toUpperCase()); + this.ignoreStartWithKeys.add(OUT_PREFIX.toUpperCase()); this.relationManagements = new HashMap<>(); From 99e88fc1e3771b5e360febe97fb690ccce87b76e Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Fri, 26 Feb 2021 18:46:00 +0100 Subject: [PATCH 08/10] Cleaning code --- .../instances/base/ElementManagement.java | 11 ----------- .../base/entities/EntityElementManagement.java | 3 +++ .../base/relations/RelationElementManagement.java | 12 ++++++++---- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/ElementManagement.java b/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/ElementManagement.java index a3551f5..2c6bae5 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/ElementManagement.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/ElementManagement.java @@ -73,17 +73,6 @@ public abstract class ElementManagement { public final static String AT = "@"; public final static String UNDERSCORE = "_"; - public final static String IN_PREFIX = "in_"; - public final static String OUT_PREFIX = "out_"; - - - /* * - * The classes which has not to be included in the superClasses property when serialize and instance - * e.g. for any Resource instance when mast not include Entity and any Entity super class - * / - public final Set superClassesToBeExcluded; - */ - protected final Set ignoreKeys; protected final Set ignoreStartWithKeys; diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/entities/EntityElementManagement.java b/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/entities/EntityElementManagement.java index 3cd095b..c898dad 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/entities/EntityElementManagement.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/entities/EntityElementManagement.java @@ -31,6 +31,9 @@ import com.orientechnologies.orient.core.record.OVertex; */ public abstract class EntityElementManagement extends ElementManagement { + public final static String IN_PREFIX = "in_"; + public final static String OUT_PREFIX = "out_"; + /** * Provide a cache edge-internal-id -> RelationManagement * this avoid to recreate the relationManagement of already visited edges diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/relations/RelationElementManagement.java b/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/relations/RelationElementManagement.java index 66ef2f8..08ed3ea 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/relations/RelationElementManagement.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/relations/RelationElementManagement.java @@ -32,6 +32,9 @@ import com.orientechnologies.orient.core.record.OVertex; public abstract class RelationElementManagement, TEM extends EntityElementManagement, SET extends EntityType, TET extends EntityType> extends ElementManagement> { + public final static String IN = "in"; + public final static String OUT = "out"; + protected final Class sourceEntityClass; protected final Class targetEntityClass; @@ -44,10 +47,11 @@ public abstract class RelationElementManagement Date: Fri, 26 Feb 2021 18:51:06 +0100 Subject: [PATCH 09/10] Using orientdb-client in place of orientdb-graphdb --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b7eae4f..25e6a86 100644 --- a/pom.xml +++ b/pom.xml @@ -52,7 +52,7 @@ com.orientechnologies - orientdb-graphdb + orientdb-client 3.0.37 From 933c5dd469eb61a588645b67a7c8738db0b65c1f Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Fri, 26 Feb 2021 18:54:05 +0100 Subject: [PATCH 10/10] Added old dependency as comment for future reference --- pom.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pom.xml b/pom.xml index 25e6a86..e3ebce6 100644 --- a/pom.xml +++ b/pom.xml @@ -52,6 +52,12 @@ com.orientechnologies + orientdb-client 3.0.37