From cc0e645ba59ed3377feed48b5afbdbc42e0f3065 Mon Sep 17 00:00:00 2001 From: "luca.frosini" Date: Thu, 21 Dec 2017 10:09:46 +0000 Subject: [PATCH] Merged from branch after release 4.9.0. refs #10253 git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry@160760 82a268e6-3cf1-43bd-a215-b396298e98cf --- distro/changelog.xml | 1 + .../dbinitialization/DatabaseEnvironment.java | 18 +++++------------- .../resourceregistry/rest/Access.java | 3 +-- .../resourceregistry/rest/SchemaManager.java | 9 +++------ 4 files changed, 10 insertions(+), 21 deletions(-) diff --git a/distro/changelog.xml b/distro/changelog.xml index 05dbb0c..8af9854 100644 --- a/distro/changelog.xml +++ b/distro/changelog.xml @@ -14,6 +14,7 @@ Added API to enumerate all Context in Access port type #10610 Exposed API to enumerate all Context in Context port-type #10217 Added support for hierarchical roles in Contexts to support child Context overview #10435 + Using new multiple inheritance support of ISModel to create types when creating new database #5706 Added an API to retrieve Resource instances filtering them #9772 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 ce192bb..5dec118 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/dbinitialization/DatabaseEnvironment.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/dbinitialization/DatabaseEnvironment.java @@ -6,11 +6,9 @@ import java.util.Map; import java.util.Properties; import java.util.UUID; -import org.gcube.informationsystem.impl.utils.ISMapper; -import org.gcube.informationsystem.impl.utils.discovery.ERDiscovery; +import org.gcube.informationsystem.impl.utils.discovery.ISMDiscovery; +import org.gcube.informationsystem.impl.utils.discovery.SchemaAction; import org.gcube.informationsystem.model.ISConstants; -import org.gcube.informationsystem.model.embedded.Embedded; -import org.gcube.informationsystem.model.embedded.ValueSchema; import org.gcube.informationsystem.resourceregistry.context.ContextUtility; import org.gcube.informationsystem.resourceregistry.context.security.AdminSecurityContext; import org.gcube.informationsystem.resourceregistry.context.security.ContextSecurityContext; @@ -199,7 +197,9 @@ public class DatabaseEnvironment { schemaSecurityContext.create(); - createEntitiesAndRelations(); + SchemaAction schemaAction = new SchemaActionImpl(); + ISMDiscovery.manageISM(schemaAction); + } } catch(Exception e) { @@ -286,12 +286,4 @@ public class DatabaseEnvironment { return false; } - private static void createEntitiesAndRelations() throws Exception { - ERDiscovery erDiscovery = ISMapper.getErdiscovery(); - SchemaActionImpl entityRegistrationAction = new SchemaActionImpl(); - entityRegistrationAction.manageEmbeddedClass(Embedded.class); - entityRegistrationAction.manageEmbeddedClass(ValueSchema.class); - erDiscovery.manageDiscoveredERTypes(entityRegistrationAction); - } - } 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 81b15d0..0f77a86 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/rest/Access.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/rest/Access.java @@ -29,7 +29,6 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.er.ERNotFound import org.gcube.informationsystem.resourceregistry.api.exceptions.query.InvalidQueryException; import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.SchemaNotFoundException; import org.gcube.informationsystem.resourceregistry.api.rest.AccessPath; -import org.gcube.informationsystem.resourceregistry.api.rest.ContextPath; import org.gcube.informationsystem.resourceregistry.api.rest.httputils.HTTPCall.HTTPMETHOD; import org.gcube.informationsystem.resourceregistry.context.ContextManagement; import org.gcube.informationsystem.resourceregistry.er.ERManagement; @@ -275,7 +274,7 @@ public class Access { public String getContext(@PathParam(ID_PATH_PARAM) String uuid) throws ContextNotFoundException, ResourceRegistryException { ContextManagement contextManagement = new ContextManagement(); - if(uuid.compareTo(ContextPath.ALL_PATH_PART)==0) { + if(uuid.compareTo(AccessPath.ALL_PATH_PART)==0) { logger.info("Requested to read all {}s", org.gcube.informationsystem.model.entity.Context.NAME); return contextManagement.all(false); }else { diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/rest/SchemaManager.java b/src/main/java/org/gcube/informationsystem/resourceregistry/rest/SchemaManager.java index ef8d811..838e29f 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/rest/SchemaManager.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/rest/SchemaManager.java @@ -1,6 +1,5 @@ package org.gcube.informationsystem.resourceregistry.rest; -import javax.ws.rs.ApplicationPath; import javax.ws.rs.Consumes; import javax.ws.rs.DefaultValue; import javax.ws.rs.GET; @@ -18,7 +17,6 @@ import org.gcube.informationsystem.resourceregistry.ResourceInitializer; import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException; import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.SchemaException; import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.SchemaNotFoundException; -import org.gcube.informationsystem.resourceregistry.api.rest.AccessPath; import org.gcube.informationsystem.resourceregistry.api.rest.SchemaPath; import org.gcube.informationsystem.resourceregistry.schema.SchemaManagement; import org.gcube.informationsystem.resourceregistry.schema.SchemaManagementImpl; @@ -28,7 +26,7 @@ import org.slf4j.LoggerFactory; /** * @author Luca Frosini (ISTI - CNR) */ -@ApplicationPath(SchemaPath.SCHEMA_PATH_PART) +@Path(SchemaPath.SCHEMA_PATH_PART) public class SchemaManager { private static Logger logger = LoggerFactory.getLogger(SchemaManager.class); @@ -54,7 +52,7 @@ public class SchemaManager { AccessType accessType = null; try { - accessType = AccessType.valueOf(type); + accessType = AccessType.valueOf(type.toUpperCase()); switch(accessType) { case EMBEDDED: break; @@ -91,10 +89,9 @@ public class SchemaManager { */ @GET @Path("{" + TYPE_PATH_PARAM + "}") - @Consumes({MediaType.TEXT_PLAIN, ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8}) @Produces(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8) public String read(@PathParam(TYPE_PATH_PARAM) String type, - @QueryParam(AccessPath.POLYMORPHIC_PARAM) @DefaultValue("false") Boolean polymorphic) + @QueryParam(SchemaPath.POLYMORPHIC_PARAM) @DefaultValue("false") Boolean polymorphic) throws SchemaNotFoundException, ResourceRegistryException { logger.info("Requested Schema for type {}", type); SchemaManagement schemaManagement = new SchemaManagementImpl();