From ee43e4ed1f18a5f72c4cb2acccff634fc30b69c6 Mon Sep 17 00:00:00 2001 From: Fabio Sinibaldi Date: Wed, 20 Nov 2019 17:00:05 +0000 Subject: [PATCH] Merged release gcube 4.15.0 git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/spatial-data/sdi-service@182281 82a268e6-3cf1-43bd-a215-b396298e98cf --- pom.xml | 89 +++++-- .../spatial/data/sdi/LocalConfiguration.java | 2 +- .../gcube/spatial/data/sdi/ScopeUtils.java | 70 ----- .../data/sdi/engine/impl/SDIManagerImpl.java | 2 +- .../sdi/engine/impl/ThreddsManagerImpl.java | 10 +- .../engine/impl/cluster/AbstractCluster.java | 2 +- .../impl/cluster/GeoNetworkCluster.java | 21 +- .../impl/cluster/GeoNetworkController.java | 252 +++++++++++------- .../impl/cluster/GeoServerController.java | 2 +- .../impl/cluster/GeoServiceController.java | 5 +- .../impl/gn/extension/GNClientExtension.java | 10 +- .../extension/GNMetadataAdminExtension.java | 4 +- .../impl/gn/extension/GeoNetworkClient.java | 14 +- .../impl/gn/extension/GeoNetworkUtils.java | 16 +- .../sdi/engine/impl/gn/utils/GroupUtils.java | 88 ++++++ .../sdi/engine/impl/gn/utils/UserUtils.java | 88 ++++++ .../sdi/engine/impl/is/AbstractISModule.java | 5 +- .../engine/impl/is/GeoNetworkRetriever.java | 18 +- .../impl/is/GeoServerClusterRetriever.java | 25 +- .../data/sdi/engine/impl/is/ISUtils.java | 32 ++- .../engine/impl/metadata/MetadataUtils.java | 4 +- .../sdi/model/credentials/AccessType.java | 10 - .../sdi/model/credentials/Credentials.java | 35 --- .../spatial/data/sdi/rest/GeoNetwork.java | 8 + .../spatial/data/sdi/rest/GeoServer.java | 8 + .../gcube/spatial/data/sdi/rest/Metadata.java | 4 +- .../gcube/spatial/data/sdi/rest/Thredds.java | 4 +- src/main/webapp/WEB-INF/config.properties | 2 + .../data/sdi/test/ConfigurationTest.java | 15 +- .../sdi/test/MetadataApplicationTest.java | 7 +- .../data/sdi/test/RegisterServiceTest.java | 80 ++++++ .../data/sdi/test/TestCreateCatalog.java | 85 ++++++ .../gcube/spatial/data/sdi/test/TestIS.java | 12 +- .../test/factories/ThreddsManagerFactory.java | 2 +- 34 files changed, 705 insertions(+), 326 deletions(-) delete mode 100644 src/main/java/org/gcube/spatial/data/sdi/ScopeUtils.java create mode 100644 src/main/java/org/gcube/spatial/data/sdi/engine/impl/gn/utils/GroupUtils.java create mode 100644 src/main/java/org/gcube/spatial/data/sdi/engine/impl/gn/utils/UserUtils.java delete mode 100644 src/main/java/org/gcube/spatial/data/sdi/model/credentials/AccessType.java delete mode 100644 src/main/java/org/gcube/spatial/data/sdi/model/credentials/Credentials.java create mode 100644 src/test/java/org/gcube/spatial/data/sdi/test/RegisterServiceTest.java create mode 100644 src/test/java/org/gcube/spatial/data/sdi/test/TestCreateCatalog.java diff --git a/pom.xml b/pom.xml index 6b1e5ae..6308c51 100644 --- a/pom.xml +++ b/pom.xml @@ -4,11 +4,11 @@ org.gcube.tools maven-parent - LATEST + 1.1.0 org.gcube.spatial.data sdi-service - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT SDI Service REST Interface towards SDI facilities war @@ -35,29 +35,33 @@ - - org.gcube.spatial.data - gis-interface - [2.4.0-SNAPSHOT,3.0.0-SNAPSHOT) - - - slf4j-log4j12 - org.slf4j - - - + + + + + + + + + + + org.gcube.spatial.data sdi-interface [1.0.0-SNAPSHOT,2.0.0-SNAPSHOT) - + + org.gcube.portlets.user + uri-resolver-manager + [1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT) + org.gcube.data.transfer data-transfer-library - [1.2.0-SNAPSHOT,2.0.0-SNAPSHOT) + [1.2.0-SNAPSHOT,2.0.0-SNAPSHOT) @@ -222,6 +226,61 @@ + + + + + it.geosolutions + geonetwork-manager + 1.4-SNAPSHOT + + + + org.geotoolkit + geotk-metadata + 3.20 + + + org.w3c + dom + 2.3.0-jaxb-1.0.6 + + + org.geotoolkit + geotk-referencing + 3.20 + + + + com.thoughtworks.xstream + xstream + 1.4.9 + + + + + + org.freemarker + freemarker + 2.3.25-incubating + + + + + + + it.geosolutions + geoserver-manager + 1.5.2 + + + org.slf4j + jcl-over-slf4j + + + + + diff --git a/src/main/java/org/gcube/spatial/data/sdi/LocalConfiguration.java b/src/main/java/org/gcube/spatial/data/sdi/LocalConfiguration.java index 4fbd52a..07f3dad 100644 --- a/src/main/java/org/gcube/spatial/data/sdi/LocalConfiguration.java +++ b/src/main/java/org/gcube/spatial/data/sdi/LocalConfiguration.java @@ -36,7 +36,7 @@ public class LocalConfiguration { final static public String GEONETWORK_SE_CONFIDENTIAL_GROUP_PREFIX="gn.se.confidential.group.prefix"; final static public String GEONETWORK_SE_CONTEXT_GROUP_PREFIX="gn.se.context.group.prefix"; final static public String GEONETWORK_GROUP_ALL="gn.groups.all"; - + final static public String GEONETWORK_GROUP_MAX_LENGTH="gn.groups.max_length"; final static public String GEONETWORK_MANDATORY_SG="gn.mandatorySG"; diff --git a/src/main/java/org/gcube/spatial/data/sdi/ScopeUtils.java b/src/main/java/org/gcube/spatial/data/sdi/ScopeUtils.java deleted file mode 100644 index 4edce5a..0000000 --- a/src/main/java/org/gcube/spatial/data/sdi/ScopeUtils.java +++ /dev/null @@ -1,70 +0,0 @@ -package org.gcube.spatial.data.sdi; - -import static org.gcube.common.authorization.client.Constants.authorizationService; - -import java.util.ArrayList; - -import org.gcube.common.authorization.library.AuthorizationEntry; -import org.gcube.common.authorization.library.provider.SecurityTokenProvider; -import org.gcube.common.scope.api.ScopeProvider; - -import lombok.extern.slf4j.Slf4j; - -@Slf4j -public class ScopeUtils { - - public static String getCurrentScope(){ - // try{ - // String token=SecurityTokenProvider.instance.get(); - // log.debug("Token is : "+token); - // if(token==null) throw new Exception("Security Token is null"); - // AuthorizationEntry entry = authorizationService().get(token); - // return entry.getContext(); - // }catch(Exception e ){ - // log.debug("Unable to resolve token, checking scope provider..",e); - // return ScopeProvider.instance.get(); - // } - - String scope=ScopeProvider.instance.get(); - if(scope!=null) { - log.debug("Found scope provider {}, skipping token",scope); - return scope; - }else{ - try{ - log.debug("Scope provider not set, reverting to token"); - String token=SecurityTokenProvider.instance.get(); - log.debug("Token is : "+token); - if(token==null) throw new Exception("Security Token is null"); - AuthorizationEntry entry = authorizationService().get(token); - return entry.getContext(); - }catch(Exception e){ - throw new RuntimeException("Unable to evaluate scope ",e); - } - } - - - } - - public static String getCurrentScopeName(){ - return getScopeName(getCurrentScope()); - } - - public static String getScopeName(String scope) { - return scope.substring(scope.lastIndexOf('/')+1); - } - - - public static ArrayList getParentScopes(String scope){ - String[] splitted=scope.substring(1).split("/"); - ArrayList toReturn=new ArrayList(); - for(int i=0;i comparator=new Comparator() { @Override public int compare(GeoNetworkController o1, GeoNetworkController o2) { - return o1.getDescriptor().getPriority().compareTo(o2.getDescriptor().getPriority()); + return o1.getPriority().compareTo(o2.getPriority()); } }; - - + + public GeoNetworkCluster(long objectsTTL, ISModule retriever, String cacheName) { super(objectsTTL, retriever, cacheName); // TODO Auto-generated constructor stub @@ -32,20 +32,21 @@ public class GeoNetworkCluster extends AbstractCluster getComparator() { return comparator; } - + @Override protected GeoNetworkController translate(ServiceEndpoint e) throws InvalidServiceEndpointException { return new GeoNetworkController(e); } - + @Override protected ArrayList getLiveControllerCollection() throws ConfigurationNotFoundException { ArrayList toReturn= super.getLiveControllerCollection(); - try{ - toReturn.get(0).configure(); - }catch(ServiceInteractionException e) { - log.warn("Unexpected exception while configuring GeoNetwork SE [ID : "+toReturn.get(0).getServiceEndpoint().id()+"]",e); - } + for(GeoNetworkController controller:toReturn) + try{ + controller.configure(); + }catch(ServiceInteractionException e) { + log.warn("Unexpected exception while configuring GeoNetwork SE [ID : "+controller.getServiceEndpoint().id()+"]",e); + } return toReturn; } } diff --git a/src/main/java/org/gcube/spatial/data/sdi/engine/impl/cluster/GeoNetworkController.java b/src/main/java/org/gcube/spatial/data/sdi/engine/impl/cluster/GeoNetworkController.java index 537f332..8d11ed5 100644 --- a/src/main/java/org/gcube/spatial/data/sdi/engine/impl/cluster/GeoNetworkController.java +++ b/src/main/java/org/gcube/spatial/data/sdi/engine/impl/cluster/GeoNetworkController.java @@ -9,49 +9,76 @@ import java.util.Set; import org.gcube.common.resources.gcore.ServiceEndpoint; import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint; import org.gcube.common.resources.gcore.ServiceEndpoint.Property; -import org.gcube.spatial.data.geonetwork.model.Group; -import org.gcube.spatial.data.geonetwork.model.User; -import org.gcube.spatial.data.geonetwork.utils.UserUtils; import org.gcube.spatial.data.sdi.LocalConfiguration; -import org.gcube.spatial.data.sdi.ScopeUtils; import org.gcube.spatial.data.sdi.engine.impl.faults.InvalidServiceEndpointException; import org.gcube.spatial.data.sdi.engine.impl.faults.OutdatedServiceEndpointException; import org.gcube.spatial.data.sdi.engine.impl.faults.ServiceInteractionException; import org.gcube.spatial.data.sdi.engine.impl.gn.extension.GeoNetworkClient; import org.gcube.spatial.data.sdi.engine.impl.gn.extension.GeoNetworkUtils; +import org.gcube.spatial.data.sdi.engine.impl.gn.utils.UserUtils; import org.gcube.spatial.data.sdi.engine.impl.is.ISUtils; import org.gcube.spatial.data.sdi.model.credentials.AccessType; import org.gcube.spatial.data.sdi.model.credentials.Credentials; +import org.gcube.spatial.data.sdi.model.gn.Group; +import org.gcube.spatial.data.sdi.model.gn.User; import org.gcube.spatial.data.sdi.model.service.GeoNetworkDescriptor; +import org.gcube.spatial.data.sdi.utils.ScopeUtils; import lombok.extern.slf4j.Slf4j; @Slf4j public class GeoNetworkController extends GeoServiceController{ - String scopeUserPrefix=LocalConfiguration.getProperty(LocalConfiguration.GEONETWORK_SE_SCOPE_USER_PREFIX); - String scopePasswordPrefix=LocalConfiguration.getProperty(LocalConfiguration.GEONETWORK_SE_SCOPE_PASSWORD_PREFIX); - String ckanUserPrefix=LocalConfiguration.getProperty(LocalConfiguration.GEONETWORK_SE_CKAN_USER_PREFIX); - String ckanPasswordPrefix=LocalConfiguration.getProperty(LocalConfiguration.GEONETWORK_SE_CKAN_PASSWORD_PREFIX); - String managerUserPrefix=LocalConfiguration.getProperty(LocalConfiguration.GEONETWORK_SE_MANAGER_USER_PREFIX); - String managerPasswordPrefix=LocalConfiguration.getProperty(LocalConfiguration.GEONETWORK_SE_MANAGER_PASSWORD_PREFIX); - String assignedScopePrefix=LocalConfiguration.getProperty(LocalConfiguration.GEONETWORK_SE_ASSIGNED_SCOPE_PREFIX); - String defaultGroupPrefix=LocalConfiguration.getProperty(LocalConfiguration.GEONETWORK_SE_DEFAULT_GROUP_PREFIX); - String sharedGroupPrefix=LocalConfiguration.getProperty(LocalConfiguration.GEONETWORK_SE_SHARED_GROUP_PREFIX); - String confidentialGroupPrefix=LocalConfiguration.getProperty(LocalConfiguration.GEONETWORK_SE_CONFIDENTIAL_GROUP_PREFIX); - String contextGroupPrefix=LocalConfiguration.getProperty(LocalConfiguration.GEONETWORK_SE_CONTEXT_GROUP_PREFIX); - String suffixesProperty=LocalConfiguration.getProperty(LocalConfiguration.GEONETWORK_SE_SUFFIXES); - String priorityProperty=LocalConfiguration.getProperty(LocalConfiguration.GEONETWORK_SE_PRIORITY); - - private String suffixes=null; + + private static String scopeUserPrefix=null; + private static String scopePasswordPrefix=null; + private static String ckanUserPrefix=null; + private static String ckanPasswordPrefix=null; + private static String managerUserPrefix=null; + private static String managerPasswordPrefix=null; + private static String assignedScopePrefix=null; + private static String defaultGroupPrefix=null; + private static String sharedGroupPrefix=null; + private static String confidentialGroupPrefix=null; + private static String contextGroupPrefix=null; + private static String suffixesProperty=null; + private static String priorityProperty=null; + + static{ + + scopeUserPrefix=LocalConfiguration.getProperty(LocalConfiguration.GEONETWORK_SE_SCOPE_USER_PREFIX); + scopePasswordPrefix=LocalConfiguration.getProperty(LocalConfiguration.GEONETWORK_SE_SCOPE_PASSWORD_PREFIX); + ckanUserPrefix=LocalConfiguration.getProperty(LocalConfiguration.GEONETWORK_SE_CKAN_USER_PREFIX); + ckanPasswordPrefix=LocalConfiguration.getProperty(LocalConfiguration.GEONETWORK_SE_CKAN_PASSWORD_PREFIX); + managerUserPrefix=LocalConfiguration.getProperty(LocalConfiguration.GEONETWORK_SE_MANAGER_USER_PREFIX); + managerPasswordPrefix=LocalConfiguration.getProperty(LocalConfiguration.GEONETWORK_SE_MANAGER_PASSWORD_PREFIX); + assignedScopePrefix=LocalConfiguration.getProperty(LocalConfiguration.GEONETWORK_SE_ASSIGNED_SCOPE_PREFIX); + defaultGroupPrefix=LocalConfiguration.getProperty(LocalConfiguration.GEONETWORK_SE_DEFAULT_GROUP_PREFIX); + sharedGroupPrefix=LocalConfiguration.getProperty(LocalConfiguration.GEONETWORK_SE_SHARED_GROUP_PREFIX); + confidentialGroupPrefix=LocalConfiguration.getProperty(LocalConfiguration.GEONETWORK_SE_CONFIDENTIAL_GROUP_PREFIX); + contextGroupPrefix=LocalConfiguration.getProperty(LocalConfiguration.GEONETWORK_SE_CONTEXT_GROUP_PREFIX); + suffixesProperty=LocalConfiguration.getProperty(LocalConfiguration.GEONETWORK_SE_SUFFIXES); + priorityProperty=LocalConfiguration.getProperty(LocalConfiguration.GEONETWORK_SE_PRIORITY); + + } + + private String suffixes; private Integer priority; - - - - - + + + public Integer getPriority() { + return priority; + } + + public GeoNetworkController(ServiceEndpoint serviceEndpoint) throws InvalidServiceEndpointException { - super(serviceEndpoint); + super(serviceEndpoint); + } + + + @Override + protected void setServiceEndpoint(ServiceEndpoint toSet) { + super.setServiceEndpoint(toSet); suffixes=getSEProperty(suffixesProperty, true); priority=Integer.parseInt(getSEProperty(priorityProperty, true)); } @@ -63,44 +90,45 @@ public class GeoNetworkController extends GeoServiceController availableCredentials=new ArrayList(); availableCredentials.add(adminAccount); - + Credentials context=new Credentials(getSEProperty(scopeUserPrefix+suffix, true), getSEProperty(scopePasswordPrefix+suffix, true), AccessType.CONTEXT_USER); availableCredentials.add(context); - + Credentials ckan=new Credentials(getSEProperty(ckanUserPrefix+suffix, true), getSEProperty(ckanPasswordPrefix+suffix, true), AccessType.CKAN); availableCredentials.add(ckan); - + String managerUser=getSEProperty(managerUserPrefix+suffix, false); if(managerUser!=null) { Credentials manager=new Credentials(managerUser,getSEProperty(managerPasswordPrefix+suffix, true),AccessType.CONTEXT_MANAGER); availableCredentials.add(manager); } - + descriptor.setAccessibleCredentials(availableCredentials); - + descriptor.setPriority(priority); - - + + descriptor.setContextGroup(getSEProperty(contextGroupPrefix+suffix, true)); descriptor.setSharedGroup(getSEProperty(sharedGroupPrefix+suffix, true)); String confidentialGroup=getSEProperty(confidentialGroupPrefix+suffix, false); if(confidentialGroup!=null) descriptor.setConfidentialGroup(confidentialGroup); - - + + descriptor.setDefaultGroup(getSEProperty(defaultGroupPrefix+suffix, true)); descriptor.setPublicGroup(LocalConfiguration.getProperty(LocalConfiguration.GEONETWORK_GROUP_ALL)); - + return descriptor; } - + @Override protected AccessPoint getTheRightAccessPoint(ServiceEndpoint endpoint) { for(AccessPoint declaredPoint:endpoint.profile().accessPoints().asCollection()) { @@ -110,22 +138,25 @@ public class GeoNetworkController extends GeoServiceController existingGroups=gnClient.getGroups(); Set existingUsers=gnClient.getUsers(); - + // Get parent scopes users and groups // configure parent [mng,ctx] to access [sh] // configure siblings [mng,ctx] to access [sh] // configure users [mng,ctx] to access siblings [sh] and parent [ctx,sh] - + ArrayList sharedGroupExternalUsers=new ArrayList(); ArrayList externalGroupsToAccess=new ArrayList(); - + // gathering users and groups from siblings log.debug("Getting Siblings information from SE.."); - for(String siblingScope:ISUtils.getSiblingsScopesInResource(serviceEndpoint, scope)) { - for(String username:getUserNamesByScope(siblingScope, true, true, false)) - sharedGroupExternalUsers.add(UserUtils.getByName(existingUsers, username)); - - externalGroupsToAccess.addAll(getGroupIDSByScope(siblingScope, true, false, false)); - } + for(String siblingScope:ISUtils.getSiblingsScopesInResource(serviceEndpoint, scope)) + try { + getSuffixByScope(ScopeUtils.getScopeName(siblingScope)); + for(String username:getUserNamesByScope(siblingScope, true, true, false)) + sharedGroupExternalUsers.add(UserUtils.getByName(existingUsers, username)); + + externalGroupsToAccess.addAll(getGroupIDSByScope(siblingScope, true, false, false)); + }catch(InvalidServiceEndpointException e) { + log.debug("Sibling scope {} not found in resource. Skipping.",siblingScope); + } + log.debug("Getting Parents information from SE.."); // gathering users and groups from parents - for(String parentScope:ScopeUtils.getParentScopes(scope)) { - for(String username:getUserNamesByScope(parentScope, true, true, false)) - sharedGroupExternalUsers.add(UserUtils.getByName(existingUsers, username)); - - externalGroupsToAccess.addAll(getGroupIDSByScope(parentScope, true, true, false)); - } - - - + for(String parentScope:ScopeUtils.getParentScopes(scope)) + try { + getSuffixByScope(ScopeUtils.getScopeName(parentScope)); + for(String username:getUserNamesByScope(parentScope, true, true, false)) + sharedGroupExternalUsers.add(UserUtils.getByName(existingUsers, username)); + + externalGroupsToAccess.addAll(getGroupIDSByScope(parentScope, true, true, false)); + }catch(InvalidServiceEndpointException e) { + log.debug("Parent scope {} not found in resource. Skipping it. ",parentScope); + } + + + // Creating groups - + log.debug("Creating groups.."); String contactMail=LocalConfiguration.getProperty(LocalConfiguration.GEONETWORK_MAIL); int passwordLength=Integer.parseInt(LocalConfiguration.getProperty(LocalConfiguration.GEONETWORK_PASSWORD_LENGTH, "10")); - + // create user & groups [sh,conf,ctx] Group shared=GeoNetworkUtils.generateGroup(existingGroups, "Shared_"+scopeName, "Shared metadata group for "+scopeName, contactMail); shared=gnClient.createGroup(shared); - + existingGroups.add(shared); + Group context=GeoNetworkUtils.generateGroup(existingGroups, "Context_"+scopeName, "Context metadata group for "+scopeName, contactMail); context=gnClient.createGroup(context); - + existingGroups.add(context); + Group confidential=GeoNetworkUtils.generateGroup(existingGroups, "Confidential_"+scopeName, "Confidential metadata group for "+scopeName, contactMail); - confidential=gnClient.createGroup(context); - - + confidential=gnClient.createGroup(confidential); + existingGroups.add(confidential); + // Giving access to shared group log.debug("Giving access to shared group from external scopes.."); for(User toUpdate:sharedGroupExternalUsers) gnClient.editUser(toUpdate, Collections.singleton(shared.getId())); - - + + log.debug("Creating users.."); // CKAN -> sh,ctx - User ckan=GeoNetworkUtils.generateUser(existingUsers, passwordLength, "CKAN_"+scopeName); - ckan=gnClient.createUsers(ckan, Arrays.asList(shared.getId(),context.getId())); - + User ckan=GeoNetworkUtils.generateUser(existingUsers, passwordLength, "CKAN_"+scopeName); + ckan.setId(gnClient.createUsers(ckan, Arrays.asList(shared.getId(),context.getId())).getId()); + existingUsers.add(ckan); + + // CTX-USR -> sh,ctx,siblings [sh], parents [sh,ctx] User ctx=GeoNetworkUtils.generateUser(existingUsers, passwordLength, "Ctx_"+scopeName); ArrayList ctxUserAccessibleGroups=new ArrayList<>(); ctxUserAccessibleGroups.addAll(externalGroupsToAccess); ctxUserAccessibleGroups.add(shared.getId()); ctxUserAccessibleGroups.add(context.getId()); - ctx=gnClient.createUsers(ctx, ctxUserAccessibleGroups); - + ctx.setId(gnClient.createUsers(ctx, ctxUserAccessibleGroups).getId()); + existingUsers.add(ctx); + // CTX-MANAGER -> sh,ctx,conf siblings [sh], parents [sh,ctx] User manager=GeoNetworkUtils.generateUser(existingUsers, passwordLength, "Mng_"+scopeName); ctxUserAccessibleGroups.add(confidential.getId()); - - + manager.setId(gnClient.createUsers(manager, ctxUserAccessibleGroups).getId()); + existingUsers.add(manager); + // Setting information in Service Endpoint log.debug("Inserting configuration in Service Endpoint"); - + String generatedSuffix=generateSuffix(suffixes); - + ArrayList toUpdateProperties=new ArrayList<>(); toUpdateProperties.add( new Property().nameAndValue(assignedScopePrefix+generatedSuffix, scopeName)); toUpdateProperties.add( new Property().nameAndValue(scopeUserPrefix+generatedSuffix, ctx.getUsername())); - toUpdateProperties.add( new Property().nameAndValue(scopePasswordPrefix+generatedSuffix, ctx.getPassword()).encrypted(true)); + toUpdateProperties.add( new Property().nameAndValue(scopePasswordPrefix+generatedSuffix, ISUtils.encryptString(ctx.getPassword())).encrypted(true)); toUpdateProperties.add( new Property().nameAndValue(ckanUserPrefix+generatedSuffix, ckan.getUsername())); - toUpdateProperties.add( new Property().nameAndValue(ckanPasswordPrefix+generatedSuffix, ckan.getPassword()).encrypted(true)); + toUpdateProperties.add( new Property().nameAndValue(ckanPasswordPrefix+generatedSuffix, ISUtils.encryptString(ckan.getPassword())).encrypted(true)); toUpdateProperties.add( new Property().nameAndValue(managerUserPrefix+generatedSuffix, manager.getUsername())); - toUpdateProperties.add( new Property().nameAndValue(managerPasswordPrefix+generatedSuffix, manager.getPassword()).encrypted(true)); + toUpdateProperties.add( new Property().nameAndValue(managerPasswordPrefix+generatedSuffix, ISUtils.encryptString(manager.getPassword())).encrypted(true)); toUpdateProperties.add( new Property().nameAndValue(sharedGroupPrefix+generatedSuffix, shared.getId()+"")); toUpdateProperties.add( new Property().nameAndValue(defaultGroupPrefix+generatedSuffix, shared.getId()+"")); toUpdateProperties.add( new Property().nameAndValue(confidentialGroupPrefix+generatedSuffix, confidential.getId()+"")); toUpdateProperties.add( new Property().nameAndValue(contextGroupPrefix+generatedSuffix, context.getId()+"")); - toUpdateProperties.add(new Property().nameAndValue(suffixesProperty, suffixes+","+generatedSuffix)); + + + + String suffixesList=(suffixes!=null&&!suffixes.trim().isEmpty()&&suffixes!=",")?suffixes+","+generatedSuffix:generatedSuffix; + toUpdateProperties.add(new Property().nameAndValue(suffixesProperty, suffixesList)); accessPoint.properties().addAll(toUpdateProperties); throw new OutdatedServiceEndpointException("Created scope configuration for "+scopeName); } - - + + private String getSuffixByScope(String scopeName) { log.debug("looking for scope {} suffix. Available suffixes are : {} ",scopeName,suffixes); - for(String suff:suffixes.split(",")) - if(getSEProperty(assignedScopePrefix+suff, true).equals(scopeName)) return suff; + if(suffixes!=null) + for(String suff:suffixes.split(",")) + if(suff!=null&&!suff.isEmpty()) { + String propertyValue=getSEProperty(assignedScopePrefix+suff, false); + if(propertyValue!=null&&propertyValue.equals(scopeName)) return suff; + } return null; } - - + + private static String generateSuffix(String existingSuffixes){ log.debug("Generating suffix, existing are : "+existingSuffixes); - String[] suffixArray=existingSuffixes.split(","); + String[] suffixArray=existingSuffixes==null?new String[0]:existingSuffixes.split(","); int maxIndex=0; for(String suff:suffixArray){ try{ @@ -249,8 +303,8 @@ public class GeoNetworkController extends GeoServiceController getUserNamesByScope(String scope, boolean getContext, boolean getManager, boolean getCKAN){ HashSet toReturn=new HashSet(); String scopeName=ScopeUtils.getScopeName(scope); @@ -265,7 +319,7 @@ public class GeoNetworkController extends GeoServiceController getGroupIDSByScope(String scope, boolean getShared,boolean getContext,boolean getConfidential){ HashSet toReturn=new HashSet(); String scopeName=ScopeUtils.getScopeName(scope); @@ -280,6 +334,6 @@ public class GeoNetworkController extends GeoServiceController { public void onUpdateServiceEndpoint() { setServiceEndpoint(ISUtils.updateAndWait(serviceEndpoint)); - cachedDescriptor.invalidate(); + if(cachedDescriptor!=null)cachedDescriptor.invalidate(); } protected void setServiceEndpoint(ServiceEndpoint toSet) { @@ -84,7 +84,8 @@ public abstract class GeoServiceController { protected String getSEProperty(String property, boolean mandatory) throws InvalidServiceEndpointException{ if(!propertyMap.containsKey(property)) - if(mandatory)throw new InvalidServiceEndpointException("Expected property "+property+" was not found."); + if(mandatory) + throw new InvalidServiceEndpointException("Expected property "+property+" was not found. in Resource ID "+getServiceEndpoint().id()); else return null; else { Property prop=propertyMap.get(property); diff --git a/src/main/java/org/gcube/spatial/data/sdi/engine/impl/gn/extension/GNClientExtension.java b/src/main/java/org/gcube/spatial/data/sdi/engine/impl/gn/extension/GNClientExtension.java index ea2a999..f4859cc 100644 --- a/src/main/java/org/gcube/spatial/data/sdi/engine/impl/gn/extension/GNClientExtension.java +++ b/src/main/java/org/gcube/spatial/data/sdi/engine/impl/gn/extension/GNClientExtension.java @@ -5,11 +5,11 @@ import java.util.Collection; import java.util.List; import java.util.Set; -import org.gcube.spatial.data.geonetwork.model.Group; -import org.gcube.spatial.data.geonetwork.model.User; -import org.gcube.spatial.data.geonetwork.model.User.Profile; -import org.gcube.spatial.data.geonetwork.utils.GroupUtils; -import org.gcube.spatial.data.geonetwork.utils.UserUtils; +import org.gcube.spatial.data.sdi.engine.impl.gn.utils.GroupUtils; +import org.gcube.spatial.data.sdi.engine.impl.gn.utils.UserUtils; +import org.gcube.spatial.data.sdi.model.gn.Group; +import org.gcube.spatial.data.sdi.model.gn.User; +import org.gcube.spatial.data.sdi.model.gn.User.Profile; import org.jdom.Element; import it.geosolutions.geonetwork.GNClient; diff --git a/src/main/java/org/gcube/spatial/data/sdi/engine/impl/gn/extension/GNMetadataAdminExtension.java b/src/main/java/org/gcube/spatial/data/sdi/engine/impl/gn/extension/GNMetadataAdminExtension.java index 86a6b42..4e41fde 100644 --- a/src/main/java/org/gcube/spatial/data/sdi/engine/impl/gn/extension/GNMetadataAdminExtension.java +++ b/src/main/java/org/gcube/spatial/data/sdi/engine/impl/gn/extension/GNMetadataAdminExtension.java @@ -5,8 +5,8 @@ import java.net.MalformedURLException; import java.util.Collection; import java.util.List; -import org.gcube.spatial.data.geonetwork.model.User; -import org.gcube.spatial.data.geonetwork.model.User.Profile; +import org.gcube.spatial.data.sdi.model.gn.User; +import org.gcube.spatial.data.sdi.model.gn.User.Profile; import org.jdom.Element; import org.jdom.output.Format; import org.jdom.output.XMLOutputter; diff --git a/src/main/java/org/gcube/spatial/data/sdi/engine/impl/gn/extension/GeoNetworkClient.java b/src/main/java/org/gcube/spatial/data/sdi/engine/impl/gn/extension/GeoNetworkClient.java index ba52765..8a4d4c1 100644 --- a/src/main/java/org/gcube/spatial/data/sdi/engine/impl/gn/extension/GeoNetworkClient.java +++ b/src/main/java/org/gcube/spatial/data/sdi/engine/impl/gn/extension/GeoNetworkClient.java @@ -5,13 +5,12 @@ import java.util.Collection; import java.util.EnumSet; import java.util.Set; -import org.gcube.spatial.data.geonetwork.model.Group; -import org.gcube.spatial.data.geonetwork.model.User; -import org.gcube.spatial.data.geonetwork.model.faults.MissingServiceEndpointException; -import org.gcube.spatial.data.geonetwork.utils.GroupUtils; -import org.gcube.spatial.data.geonetwork.utils.UserUtils; import org.gcube.spatial.data.sdi.LocalConfiguration; import org.gcube.spatial.data.sdi.engine.impl.faults.ServiceInteractionException; +import org.gcube.spatial.data.sdi.engine.impl.gn.utils.GroupUtils; +import org.gcube.spatial.data.sdi.engine.impl.gn.utils.UserUtils; +import org.gcube.spatial.data.sdi.model.gn.Group; +import org.gcube.spatial.data.sdi.model.gn.User; import org.gcube.spatial.data.sdi.model.service.GeoNetworkDescriptor; import org.gcube.spatial.data.sdi.model.service.Version; @@ -30,16 +29,17 @@ public class GeoNetworkClient { private ServerAccess access; private GNClientExtension theClient=null; - private GeoNetworkDescriptor descriptor; + private GeoNetworkDescriptor descriptor=null; public GeoNetworkClient(String baseURL, Version version, String password, String user, GeoNetworkDescriptor descriptor) { this(baseURL,version,password,user); - theClient=new GNClientExtension(access); + this.descriptor=descriptor; } public GeoNetworkClient(String baseURL, Version version, String password, String user) { super(); this.access=new ServerAccess(baseURL,version,password,user); + theClient=new GNClientExtension(access); } //************************************** GROUPS AND USERS diff --git a/src/main/java/org/gcube/spatial/data/sdi/engine/impl/gn/extension/GeoNetworkUtils.java b/src/main/java/org/gcube/spatial/data/sdi/engine/impl/gn/extension/GeoNetworkUtils.java index c1152fb..fd0570f 100644 --- a/src/main/java/org/gcube/spatial/data/sdi/engine/impl/gn/extension/GeoNetworkUtils.java +++ b/src/main/java/org/gcube/spatial/data/sdi/engine/impl/gn/extension/GeoNetworkUtils.java @@ -4,11 +4,12 @@ import java.util.HashSet; import java.util.Iterator; import java.util.Set; -import org.gcube.spatial.data.geonetwork.model.Group; -import org.gcube.spatial.data.geonetwork.model.User; -import org.gcube.spatial.data.geonetwork.model.User.Profile; -import org.gcube.spatial.data.geonetwork.utils.StringUtils; +import org.gcube.spatial.data.sdi.LocalConfiguration; import org.gcube.spatial.data.sdi.engine.impl.faults.gn.MetadataNotFoundException; +import org.gcube.spatial.data.sdi.model.gn.Group; +import org.gcube.spatial.data.sdi.model.gn.User; +import org.gcube.spatial.data.sdi.model.gn.User.Profile; +import org.gcube.spatial.data.sdi.utils.StringUtils; import it.geosolutions.geonetwork.exception.GNLibException; import it.geosolutions.geonetwork.exception.GNServerException; @@ -21,7 +22,6 @@ import lombok.extern.slf4j.Slf4j; @Slf4j public class GeoNetworkUtils { - /** * Adds a suffix to groupName if needed * @@ -38,7 +38,9 @@ public class GeoNetworkUtils { } String toUseName=clashSafeString(groupName,existingNames); - + Integer maxLength=Integer.parseInt(LocalConfiguration.getProperty(LocalConfiguration.GEONETWORK_GROUP_MAX_LENGTH, "30")); + if(toUseName.length()>maxLength) + return generateGroup(existing, toUseName.substring(0, maxLength-2), description, contactMail); return new Group(toUseName, description, contactMail, maxId+1); } @@ -51,7 +53,7 @@ public class GeoNetworkUtils { return new User(0, // NB will be updated when creating it.. toUseUserName, - StringUtils.generateRandomString(passwordLength),Profile.RegisteredUser); + StringUtils.generateRandomString(passwordLength),Profile.Reviewer); } diff --git a/src/main/java/org/gcube/spatial/data/sdi/engine/impl/gn/utils/GroupUtils.java b/src/main/java/org/gcube/spatial/data/sdi/engine/impl/gn/utils/GroupUtils.java new file mode 100644 index 0000000..29ab3a7 --- /dev/null +++ b/src/main/java/org/gcube/spatial/data/sdi/engine/impl/gn/utils/GroupUtils.java @@ -0,0 +1,88 @@ +package org.gcube.spatial.data.sdi.engine.impl.gn.utils; + +import java.io.StringReader; +import java.util.HashSet; +import java.util.Set; + +import javax.xml.xpath.XPath; +import javax.xml.xpath.XPathFactory; + +import org.gcube.spatial.data.sdi.model.gn.Group; +import org.gcube.spatial.data.sdi.utils.StringUtils; +import org.jdom.Element; +import org.jdom.input.SAXBuilder; +import org.json.JSONArray; +import org.json.JSONObject; + +import it.geosolutions.geonetwork.exception.GNLibException; + +public class GroupUtils { + + private static XPath xpath = XPathFactory.newInstance().newXPath(); + + + public static Set parseGroupXMLResponse(String xml) throws GNLibException { + try{ + HashSet toReturn=new HashSet<>(); + SAXBuilder builder = new SAXBuilder(); + org.jdom.Element responseEl= builder.build(new StringReader(xml)).detachRootElement(); + for(Object recordObj:responseEl.getChildren("record")){ + org.jdom.Element record=(org.jdom.Element) recordObj; + Integer id=Integer.parseInt(record.getChild("id").getText()); + String name=record.getChild("name").getText(); + Element descElement=record.getChild("description"); + String description=descElement!=null?descElement.getText():""; + Element mailElement=record.getChild("email"); + String email=mailElement!=null?mailElement.getText():""; + toReturn.add(new Group(name,description,email,id)); + } + return toReturn; + }catch(Exception e){ + throw new GNLibException("Unable to parse response", e); + } + + } + + public static Set parseUserJSONResponse(String groupResponse) throws GNLibException { + try{ + HashSet toReturn=new HashSet<>(); + JSONArray array=new JSONArray(groupResponse); + for(int i=0;i existing, Integer nameLenght){ + Set existingNames=new HashSet<>(); + int maxId=0; + for(Group g:existing){ + existingNames.add(g.getName()); + if(maxId toLookInto,String toLookFor){ + for(Group g:toLookInto) + if(g.getName().equals(toLookFor)) return g; + return null; + } + + +} diff --git a/src/main/java/org/gcube/spatial/data/sdi/engine/impl/gn/utils/UserUtils.java b/src/main/java/org/gcube/spatial/data/sdi/engine/impl/gn/utils/UserUtils.java new file mode 100644 index 0000000..c15ba68 --- /dev/null +++ b/src/main/java/org/gcube/spatial/data/sdi/engine/impl/gn/utils/UserUtils.java @@ -0,0 +1,88 @@ +package org.gcube.spatial.data.sdi.engine.impl.gn.utils; + +import java.io.StringReader; +import java.util.HashSet; +import java.util.Set; + +import org.gcube.spatial.data.sdi.model.gn.User; +import org.gcube.spatial.data.sdi.model.gn.User.Profile; +import org.gcube.spatial.data.sdi.utils.StringUtils; +import org.jdom.input.SAXBuilder; +import org.json.JSONArray; +import org.json.JSONObject; + +import it.geosolutions.geonetwork.exception.GNLibException; + +public class UserUtils { + + + public static Set parseUserXMLResponse(String toParse) throws GNLibException{ + try{ + HashSet toReturn=new HashSet<>(); + SAXBuilder builder = new SAXBuilder(); + org.jdom.Element responseEl= builder.build(new StringReader(toParse)).detachRootElement(); + for(Object recordObj:responseEl.getChildren("record")){ + org.jdom.Element record=(org.jdom.Element) recordObj; + Integer id=Integer.parseInt(record.getChildText("id")); + String username=record.getChildText("username"); + String password=record.getChildText("password"); + Profile profile=Profile.valueOf(record.getChildText("profile")); + toReturn.add(new User(id,username, password, profile)); + } + return toReturn; + }catch(Exception e){ + throw new GNLibException("Unable to parse users XML response", e); + } + + } + + + public static Set parseUserJSONResponse(String toParse)throws GNLibException{ + try{ + HashSet toReturn=new HashSet<>(); + JSONArray array=new JSONArray(toParse); + for(int i=0;i existing, Integer nameLenght, Integer passwordLength){ + Set existingNames=new HashSet<>(); + for(User g:existing)existingNames.add(g.getUsername()); + return new User(0,StringUtils.generateNewRandom(existingNames, nameLenght),StringUtils.generateRandomString(passwordLength),Profile.RegisteredUser); + } + + + public static Set parseGroupsByUserResponse(String toParse) throws GNLibException{ + try{ + HashSet toReturn=new HashSet<>(); + SAXBuilder builder = new SAXBuilder(); + org.jdom.Element responseEl= builder.build(new StringReader(toParse)).detachRootElement(); + for(Object recordObj:responseEl.getChildren("group")){ + org.jdom.Element record=(org.jdom.Element) recordObj; + Integer id=Integer.parseInt(record.getChildText("id")); + toReturn.add(id); + } + return toReturn; + }catch(Exception e){ + throw new GNLibException("Unable to Groups By User XML response", e); + } + } + + + public static User getByName(Set toLookInto,String toLookFor){ + for(User g:toLookInto) + if(g.getUsername().equals(toLookFor)) return g; + return null; + } + +} diff --git a/src/main/java/org/gcube/spatial/data/sdi/engine/impl/is/AbstractISModule.java b/src/main/java/org/gcube/spatial/data/sdi/engine/impl/is/AbstractISModule.java index b8c9cdd..c639174 100644 --- a/src/main/java/org/gcube/spatial/data/sdi/engine/impl/is/AbstractISModule.java +++ b/src/main/java/org/gcube/spatial/data/sdi/engine/impl/is/AbstractISModule.java @@ -9,7 +9,7 @@ import org.gcube.common.resources.gcore.GCoreEndpoint; import org.gcube.common.resources.gcore.ServiceEndpoint; import org.gcube.common.resources.gcore.ServiceEndpoint.Profile; import org.gcube.common.resources.gcore.common.Platform; -import org.gcube.spatial.data.geonetwork.utils.ScopeUtils; +import org.gcube.spatial.data.sdi.utils.ScopeUtils; import org.gcube.spatial.data.sdi.LocalConfiguration; import org.gcube.spatial.data.sdi.engine.impl.faults.ConfigurationNotFoundException; import org.gcube.spatial.data.sdi.engine.impl.faults.InvalidServiceDefinitionException; @@ -232,10 +232,11 @@ public abstract class AbstractISModule implements ISModule { protected ServiceEndpoint prepareEndpoint(ServiceDefinition definition) throws ServiceRegistrationException { try{ - ServiceEndpoint toCreate=new ServiceEndpoint(); + ServiceEndpoint toCreate=new ServiceEndpoint(); Profile profile=toCreate.newProfile(); profile.category(getServiceEndpointCategory()); profile.description(definition.getDescription()); + profile.name(definition.getName()); Platform platform=profile.newPlatform(); platform.name(getServiceEndpointPlatformName()). version(definition.getMajorVersion()). diff --git a/src/main/java/org/gcube/spatial/data/sdi/engine/impl/is/GeoNetworkRetriever.java b/src/main/java/org/gcube/spatial/data/sdi/engine/impl/is/GeoNetworkRetriever.java index 2841034..ac83acc 100644 --- a/src/main/java/org/gcube/spatial/data/sdi/engine/impl/is/GeoNetworkRetriever.java +++ b/src/main/java/org/gcube/spatial/data/sdi/engine/impl/is/GeoNetworkRetriever.java @@ -1,32 +1,20 @@ package org.gcube.spatial.data.sdi.engine.impl.is; -import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Map; -import org.gcube.common.resources.gcore.GCoreEndpoint; import org.gcube.common.resources.gcore.ServiceEndpoint; import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint; -import org.gcube.common.resources.gcore.ServiceEndpoint.Profile; import org.gcube.common.resources.gcore.ServiceEndpoint.Property; -import org.gcube.common.resources.gcore.common.Platform; -import org.gcube.spatial.data.geonetwork.GeoNetworkAdministration; -import org.gcube.spatial.data.geonetwork.configuration.Configuration; -import org.gcube.spatial.data.geonetwork.extension.ServerAccess; -import org.gcube.spatial.data.geonetwork.model.Account; -import org.gcube.spatial.data.geonetwork.model.ScopeConfiguration; -import org.gcube.spatial.data.gis.GISInterface; import org.gcube.spatial.data.sdi.LocalConfiguration; -import org.gcube.spatial.data.sdi.engine.impl.faults.ConfigurationNotFoundException; import org.gcube.spatial.data.sdi.engine.impl.faults.InvalidServiceDefinitionException; import org.gcube.spatial.data.sdi.engine.impl.faults.ServiceRegistrationException; import org.gcube.spatial.data.sdi.model.credentials.AccessType; import org.gcube.spatial.data.sdi.model.credentials.Credentials; +import org.gcube.spatial.data.sdi.model.gn.Account; import org.gcube.spatial.data.sdi.model.health.Status; -import org.gcube.spatial.data.sdi.model.service.GeoNetworkDescriptor; -import org.gcube.spatial.data.sdi.model.service.Version; import org.gcube.spatial.data.sdi.model.services.GeoNetworkServiceDefinition; import org.gcube.spatial.data.sdi.model.services.ServiceDefinition; import org.gcube.spatial.data.sdi.model.services.ServiceDefinition.Type; @@ -202,7 +190,7 @@ public class GeoNetworkRetriever extends AbstractISModule{ AccessPoint point=new AccessPoint(); point.address("http://"+definition.getHostname()+"/geonetwork"); - point.credentials(definition.getAdminPassword(), "admin"); + point.credentials(ISUtils.encryptString(definition.getAdminPassword()), "admin"); point.description("Main Access point"); point.name(getServiceEndpointAccessPointName()); @@ -212,7 +200,7 @@ public class GeoNetworkRetriever extends AbstractISModule{ point.properties().add(priorityProperty); // Suffixes property Property suffixesProperty=new Property(); - suffixesProperty.nameAndValue("suffixes", " "); + suffixesProperty.nameAndValue("suffixes", ""); point.properties().add(suffixesProperty); toReturn.profile().accessPoints().add(point); diff --git a/src/main/java/org/gcube/spatial/data/sdi/engine/impl/is/GeoServerClusterRetriever.java b/src/main/java/org/gcube/spatial/data/sdi/engine/impl/is/GeoServerClusterRetriever.java index 09b2447..b3be755 100644 --- a/src/main/java/org/gcube/spatial/data/sdi/engine/impl/is/GeoServerClusterRetriever.java +++ b/src/main/java/org/gcube/spatial/data/sdi/engine/impl/is/GeoServerClusterRetriever.java @@ -4,14 +4,9 @@ import java.util.Collections; import java.util.List; import org.gcube.common.resources.gcore.ServiceEndpoint; -import org.gcube.spatial.data.gis.is.AbstractGeoServerDescriptor; import org.gcube.spatial.data.sdi.LocalConfiguration; import org.gcube.spatial.data.sdi.engine.impl.faults.InvalidServiceDefinitionException; -import org.gcube.spatial.data.sdi.model.credentials.AccessType; -import org.gcube.spatial.data.sdi.model.credentials.Credentials; import org.gcube.spatial.data.sdi.model.health.Status; -import org.gcube.spatial.data.sdi.model.service.GeoServerDescriptor; -import org.gcube.spatial.data.sdi.model.service.Version; import org.gcube.spatial.data.sdi.model.services.GeoServerDefinition; import org.gcube.spatial.data.sdi.model.services.ServiceDefinition; import org.gcube.spatial.data.sdi.model.services.ServiceDefinition.Type; @@ -67,16 +62,16 @@ public class GeoServerClusterRetriever extends AbstractISModule{ - private static final GeoServerDescriptor translate(AbstractGeoServerDescriptor desc){ - Version version=new Version(2,1,2); - String baseEndpoint=desc.getUrl(); - List accessibleCredentials=Collections.singletonList(new Credentials(desc.getUser(), desc.getPassword(), AccessType.ADMIN)); - String confidentialWorkspace=null; - String contextVisibilityWorkspace=null; - String sharedWorkspace=null; - String publicWorkspace=null; - return new GeoServerDescriptor(version, baseEndpoint, accessibleCredentials, confidentialWorkspace, contextVisibilityWorkspace, sharedWorkspace, publicWorkspace); - } +// private static final GeoServerDescriptor translate(AbstractGeoServerDescriptor desc){ +// Version version=new Version(2,1,2); +// String baseEndpoint=desc.getUrl(); +// List accessibleCredentials=Collections.singletonList(new Credentials(desc.getUser(), desc.getPassword(), AccessType.ADMIN)); +// String confidentialWorkspace=null; +// String contextVisibilityWorkspace=null; +// String sharedWorkspace=null; +// String publicWorkspace=null; +// return new GeoServerDescriptor(version, baseEndpoint, accessibleCredentials, confidentialWorkspace, contextVisibilityWorkspace, sharedWorkspace, publicWorkspace); +// } @Override protected String getGCoreEndpointServiceClass() { diff --git a/src/main/java/org/gcube/spatial/data/sdi/engine/impl/is/ISUtils.java b/src/main/java/org/gcube/spatial/data/sdi/engine/impl/is/ISUtils.java index 146d84a..6434e29 100644 --- a/src/main/java/org/gcube/spatial/data/sdi/engine/impl/is/ISUtils.java +++ b/src/main/java/org/gcube/spatial/data/sdi/engine/impl/is/ISUtils.java @@ -5,6 +5,7 @@ import static org.gcube.resources.discovery.icclient.ICFactory.clientFor; import static org.gcube.resources.discovery.icclient.ICFactory.queryFor; import java.io.ByteArrayOutputStream; +import java.lang.reflect.InvocationTargetException; import java.net.UnknownHostException; import java.util.ArrayList; import java.util.Collection; @@ -23,7 +24,7 @@ import org.gcube.resources.discovery.client.queries.api.SimpleQuery; import org.gcube.resources.discovery.client.queries.impl.QueryBox; import org.gcube.spatial.data.sdi.LocalConfiguration; import org.gcube.spatial.data.sdi.NetUtils; -import org.gcube.spatial.data.sdi.ScopeUtils; +import org.gcube.spatial.data.sdi.utils.ScopeUtils; import org.gcube.vremanagement.resourcemanager.client.RMBinderLibrary; import org.gcube.vremanagement.resourcemanager.client.exceptions.InvalidScopeException; import org.gcube.vremanagement.resourcemanager.client.exceptions.ResourcesCreationException; @@ -118,7 +119,9 @@ public class ISUtils { } public static String registerService(ServiceEndpoint toRegister) { - RegistryPublisher rp=RegistryPublisherFactory.create(); + RegistryPublisher rp=RegistryPublisherFactory.create(); + if(log.isDebugEnabled()) + Resources.print(toRegister); Resource r=rp.create(toRegister); return r.id(); } @@ -166,10 +169,24 @@ public class ISUtils { } } + public static String encryptString(String toEncrypt){ + try{ + return StringEncrypter.getEncrypter().encrypt(toEncrypt); + }catch(Exception e) { + throw new RuntimeException("Unable to encrypt : "+toEncrypt,e); + } + } + public static ServiceEndpoint update(ServiceEndpoint toUpdate) { RegistryPublisher rp=RegistryPublisherFactory.create(); - return rp.update(toUpdate); + try{ + return rp.update(toUpdate); + }catch(RuntimeException t) { + log.warn("Unable to update resource {} ",toUpdate.id()); + log.debug("Updated resource is {} ",marshal(toUpdate)); + throw t; + } } public static ServiceEndpoint updateAndWait(ServiceEndpoint toUpdate) { @@ -185,10 +202,10 @@ public class ISUtils { try { Thread.sleep(500); } catch (InterruptedException e) {} - updatedString=queryById(toUpdate.id()).get(0); + updatedString=marshal(querySEById(toUpdate.id())); equals=toUpdateString.equals(updatedString); timeoutReached=(System.currentTimeMillis()-updateTime)>timeout; - }while(equals&&(!timeoutReached)); + }while(!equals&&(!timeoutReached)); if(timeoutReached) log.warn("Timeout reached. Check if {} is updated ",toUpdate.id()); return querySEById(toUpdate.id()); } @@ -206,7 +223,10 @@ public class ISUtils { String parent=ScopeUtils.getParentScope(scope); if (parent!=null) for(String resourceScope:res.scopes().asCollection()) - if(ScopeUtils.getParentScope(resourceScope).equals(parent)) toReturn.add(resourceScope); + if(!resourceScope.equals(scope)) { + String resourceScopeParent=ScopeUtils.getParentScope(resourceScope); + if((resourceScopeParent!=null)&&(resourceScopeParent.equals(parent))) toReturn.add(resourceScope); + } return toReturn; } diff --git a/src/main/java/org/gcube/spatial/data/sdi/engine/impl/metadata/MetadataUtils.java b/src/main/java/org/gcube/spatial/data/sdi/engine/impl/metadata/MetadataUtils.java index 5ce7271..c37474f 100644 --- a/src/main/java/org/gcube/spatial/data/sdi/engine/impl/metadata/MetadataUtils.java +++ b/src/main/java/org/gcube/spatial/data/sdi/engine/impl/metadata/MetadataUtils.java @@ -17,7 +17,7 @@ import org.gcube.common.resources.gcore.utils.XPathHelper; import org.gcube.portlets.user.uriresolvermanager.UriResolverManager; import org.gcube.portlets.user.uriresolvermanager.exception.IllegalArgumentException; import org.gcube.portlets.user.uriresolvermanager.exception.UriResolverMapException; -import org.gcube.spatial.data.geonetwork.utils.ScopeUtils; +import org.gcube.spatial.data.sdi.utils.ScopeUtils; import org.w3c.dom.Document; import org.w3c.dom.Node; import org.w3c.dom.NodeList; @@ -78,7 +78,7 @@ public class MetadataUtils { return new String(encoded); } - public static String getGisLinkByUUID(String uuid) throws UriResolverMapException, IllegalArgumentException{ + public static String getGisLinkByUUID(String uuid) throws UriResolverMapException, IllegalArgumentException { Map params=new HashMap(); params.put("scope", ScopeUtils.getCurrentScope()); params.put("gis-UUID", uuid); diff --git a/src/main/java/org/gcube/spatial/data/sdi/model/credentials/AccessType.java b/src/main/java/org/gcube/spatial/data/sdi/model/credentials/AccessType.java deleted file mode 100644 index 68a8088..0000000 --- a/src/main/java/org/gcube/spatial/data/sdi/model/credentials/AccessType.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.gcube.spatial.data.sdi.model.credentials; - -public enum AccessType { - - ADMIN, - CONTEXT_MANAGER, - CONTEXT_USER, - CKAN; - -} diff --git a/src/main/java/org/gcube/spatial/data/sdi/model/credentials/Credentials.java b/src/main/java/org/gcube/spatial/data/sdi/model/credentials/Credentials.java deleted file mode 100644 index ac533ec..0000000 --- a/src/main/java/org/gcube/spatial/data/sdi/model/credentials/Credentials.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.gcube.spatial.data.sdi.model.credentials; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlRootElement; - -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; -import lombok.Setter; - - -@Getter -@Setter -@NoArgsConstructor -@RequiredArgsConstructor -@XmlRootElement -@XmlAccessorType(XmlAccessType.FIELD) -public class Credentials { - - @NonNull - private String username; - @NonNull - private String password; - @NonNull - private AccessType accessType; - @Override - public String toString() { - return "Credentials [username=" + username + ", password=****, accessType=" + accessType + "]"; - } - - - -} diff --git a/src/main/java/org/gcube/spatial/data/sdi/rest/GeoNetwork.java b/src/main/java/org/gcube/spatial/data/sdi/rest/GeoNetwork.java index 34c89fd..ae8dd0f 100644 --- a/src/main/java/org/gcube/spatial/data/sdi/rest/GeoNetwork.java +++ b/src/main/java/org/gcube/spatial/data/sdi/rest/GeoNetwork.java @@ -58,8 +58,10 @@ public class GeoNetwork { return sdi.getGeoNetworkManager().getDescriptorByHostname(host); }catch(WebApplicationException e){ + log.warn("Unable to serve request",e); throw e; }catch(Exception e){ + log.warn("Unable to serve request",e); throw new WebApplicationException("Unable to serve request", e); } } @@ -76,8 +78,10 @@ public class GeoNetwork { return roleManager.getMostAccessible(sdi.getGeoNetworkManager().getDescriptorByHostname(host).getAccessibleCredentials(), false); // return .get(0); }catch(WebApplicationException e){ + log.warn("Unable to serve request",e); throw e; }catch(Exception e){ + log.warn("Unable to serve request",e); throw new WebApplicationException("Unable to serve request", e); } } @@ -89,8 +93,10 @@ public class GeoNetwork { try { return sdi.registerService(toRegister); }catch(WebApplicationException e) { + log.warn("Unable to serve request",e); throw e; }catch(Exception e) { + log.warn("Unable to serve request",e); throw new WebApplicationException("Unable to serve request",e); } } @@ -103,8 +109,10 @@ public class GeoNetwork { try { return sdi.importService(sourceToken, host, Type.GEONETWORK); }catch(WebApplicationException e) { + log.warn("Unable to serve request",e); throw e; }catch(Exception e) { + log.warn("Unable to serve request",e); throw new WebApplicationException("Unable to serve request",e); } } diff --git a/src/main/java/org/gcube/spatial/data/sdi/rest/GeoServer.java b/src/main/java/org/gcube/spatial/data/sdi/rest/GeoServer.java index 5d98823..48eedba 100644 --- a/src/main/java/org/gcube/spatial/data/sdi/rest/GeoServer.java +++ b/src/main/java/org/gcube/spatial/data/sdi/rest/GeoServer.java @@ -51,8 +51,10 @@ public class GeoServer { return sdi.getGeoServerManager().getDescriptorByHostname(host); }catch(WebApplicationException e){ + log.warn("Unable to serve request",e); throw e; }catch(Exception e){ + log.warn("Unable to serve request",e); throw new WebApplicationException("Unable to serve request", e); } } @@ -68,8 +70,10 @@ public class GeoServer { host=NetUtils.getHost(host); return sdi.getGeoServerManager().getDescriptorByHostname(host).getAccessibleCredentials().get(0); }catch(WebApplicationException e){ + log.warn("Unable to serve request",e); throw e; }catch(Exception e){ + log.warn("Unable to serve request",e); throw new WebApplicationException("Unable to serve request", e); } } @@ -81,8 +85,10 @@ public class GeoServer { try { return sdi.registerService(toRegister); }catch(WebApplicationException e) { + log.warn("Unable to serve request",e); throw e; }catch(Exception e) { + log.warn("Unable to serve request",e); throw new WebApplicationException("Unable to serve request",e); } } @@ -95,8 +101,10 @@ public class GeoServer { try { return sdi.importService(sourceToken, host, Type.GEOSERVER); }catch(WebApplicationException e) { + log.warn("Unable to serve request",e); throw e; }catch(Exception e) { + log.warn("Unable to serve request",e); throw new WebApplicationException("Unable to serve request",e); } } diff --git a/src/main/java/org/gcube/spatial/data/sdi/rest/Metadata.java b/src/main/java/org/gcube/spatial/data/sdi/rest/Metadata.java index 8996c7f..5f19380 100644 --- a/src/main/java/org/gcube/spatial/data/sdi/rest/Metadata.java +++ b/src/main/java/org/gcube/spatial/data/sdi/rest/Metadata.java @@ -137,10 +137,10 @@ public class Metadata { toReturn.setPublishedUUID(uuid); return toReturn; } catch (FileNotFoundException e) { - log.debug("Unable to get uploaded with ID {}. Cause : ",uploadedId,e); + log.warn("Unable to get uploaded with ID {}. Cause : ",uploadedId,e); throw new WebApplicationException("Invalid upload id "+uploadedId); }catch(Throwable e ){ - log.debug("Unexpected error while publishing {} . Cause : ",uploadedId,e); + log.warn("Unexpected error while publishing {} . Cause : ",uploadedId,e); throw new WebApplicationException("Unabel to publish metadata. Cause "+e.getMessage(),Status.INTERNAL_SERVER_ERROR); } } diff --git a/src/main/java/org/gcube/spatial/data/sdi/rest/Thredds.java b/src/main/java/org/gcube/spatial/data/sdi/rest/Thredds.java index 4589b92..977c928 100644 --- a/src/main/java/org/gcube/spatial/data/sdi/rest/Thredds.java +++ b/src/main/java/org/gcube/spatial/data/sdi/rest/Thredds.java @@ -12,8 +12,8 @@ import javax.ws.rs.core.MediaType; import org.gcube.data.transfer.model.plugins.thredds.ThreddsCatalog; import org.gcube.smartgears.annotations.ManagedBy; import org.gcube.spatial.data.sdi.SDIServiceManager; -import org.gcube.spatial.data.sdi.ScopeUtils; import org.gcube.spatial.data.sdi.engine.ThreddsManager; +import org.gcube.spatial.data.sdi.utils.ScopeUtils; import io.swagger.annotations.Api; import lombok.extern.slf4j.Slf4j; @@ -70,7 +70,7 @@ public class Thredds { return threddsManager.createCatalogFromTemplate(authority,path,datasetScanId,datasetScanName,folder,catalogReference); }catch(Throwable t) { - log.debug("Unable to create catalog",t); + log.warn("Unable to create catalog",t); throw new WebApplicationException("Unable to serve request", t); } } diff --git a/src/main/webapp/WEB-INF/config.properties b/src/main/webapp/WEB-INF/config.properties index 40e58fc..587fc0b 100644 --- a/src/main/webapp/WEB-INF/config.properties +++ b/src/main/webapp/WEB-INF/config.properties @@ -18,6 +18,8 @@ gn.se.confidential.group.prefix=confidential gn.se.context.group.prefix=private gn.groups.all=1 +gn.groups.max_length=32 + gn.ge.serviceClass=SDI gn.ge.serviceName=GeoNetwork diff --git a/src/test/java/org/gcube/spatial/data/sdi/test/ConfigurationTest.java b/src/test/java/org/gcube/spatial/data/sdi/test/ConfigurationTest.java index 683a144..39bf51f 100644 --- a/src/test/java/org/gcube/spatial/data/sdi/test/ConfigurationTest.java +++ b/src/test/java/org/gcube/spatial/data/sdi/test/ConfigurationTest.java @@ -1,6 +1,8 @@ package org.gcube.spatial.data.sdi.test; +import java.net.MalformedURLException; import java.net.URL; +import java.nio.file.Paths; import org.gcube.spatial.data.sdi.LocalConfiguration; import org.gcube.spatial.data.sdi.engine.impl.GISManagerImpl; @@ -8,19 +10,20 @@ import org.gcube.spatial.data.sdi.engine.impl.GeoNetworkManagerImpl; import org.gcube.spatial.data.sdi.engine.impl.RoleManagerImpl; import org.gcube.spatial.data.sdi.engine.impl.SDIManagerImpl; import org.gcube.spatial.data.sdi.engine.impl.ThreddsManagerImpl; +import org.gcube.spatial.data.sdi.test.factories.ThreddsManagerFactory; public class ConfigurationTest { - public static void main(String[] args) { - TokenSetter.set("/gcube/devNext"); + public static void main(String[] args) throws MalformedURLException { + TokenSetter.set("/d4science.research-infrastructures.eu/gCubeApps/BiodiversityLab"); - URL propertiesURL=ConfigurationTest.class.getResource("/WEB-INF/config.properties"); +// TokenSetter.set("/gcube/devNext/NextNext"); + LocalConfiguration.init(Paths.get("src/main/webapp/WEB-INF/config.properties").toUri().toURL()); - LocalConfiguration.init(propertiesURL); - - SDIManagerImpl sdi=new SDIManagerImpl(new GeoNetworkManagerImpl(new RoleManagerImpl()), new ThreddsManagerImpl(), new GISManagerImpl()); + SDIManagerImpl sdi=new SDIManagerImpl(new GeoNetworkManagerImpl(new RoleManagerImpl()), new ThreddsManagerFactory().provide(), new GISManagerImpl()); System.out.println(sdi.getContextConfiguration()); + System.out.println(sdi.getContextConfiguration().getGeonetworkConfiguration().get(0).getAccessibleCredentials()); } } diff --git a/src/test/java/org/gcube/spatial/data/sdi/test/MetadataApplicationTest.java b/src/test/java/org/gcube/spatial/data/sdi/test/MetadataApplicationTest.java index 63b5e4b..70537f1 100644 --- a/src/test/java/org/gcube/spatial/data/sdi/test/MetadataApplicationTest.java +++ b/src/test/java/org/gcube/spatial/data/sdi/test/MetadataApplicationTest.java @@ -16,12 +16,12 @@ public class MetadataApplicationTest { @Test public void apply() throws IOException, TransformerException{ - TokenSetter.set("/gcube/devsec/devVRE"); + TokenSetter.set("/gcube/devNext/NextNext"); MetadataTemplateManagerImpl manager=new MetadataTemplateManagerImpl(); // LocalConfiguration.init(Paths.get("src/main/webapp/WEB-INF/config.properties").toUri().toURL()) // .setTemplateConfigurationObject(Paths.get("src/main/webapp/WEB-INF/metadataTemplates").toFile()); - manager.init(Paths.get("src/main/webapp/WEB-INF/metadataTemplates").toFile()); + manager.init(Paths.get("src/main/webapp/WEB-INF/xmlTemplates").toFile()); System.out.println(manager.getAvailableMetadataTemplates()); @@ -31,6 +31,9 @@ public class MetadataApplicationTest { builder.threddsOnlineResources("localhost", "someFileName.sc", "newCatalog"); TemplateApplicationReport report=manager.applyMetadataTemplates(Paths.get("src/test/resources/xml/toEnrichMetadata.xml").toFile(), builder.get()); System.out.println(report); + + + } diff --git a/src/test/java/org/gcube/spatial/data/sdi/test/RegisterServiceTest.java b/src/test/java/org/gcube/spatial/data/sdi/test/RegisterServiceTest.java new file mode 100644 index 0000000..7a275ec --- /dev/null +++ b/src/test/java/org/gcube/spatial/data/sdi/test/RegisterServiceTest.java @@ -0,0 +1,80 @@ +package org.gcube.spatial.data.sdi.test; + +import java.net.MalformedURLException; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Arrays; + +import org.gcube.spatial.data.sdi.LocalConfiguration; +import org.gcube.spatial.data.sdi.engine.impl.GISManagerImpl; +import org.gcube.spatial.data.sdi.engine.impl.GeoNetworkManagerImpl; +import org.gcube.spatial.data.sdi.engine.impl.RoleManagerImpl; +import org.gcube.spatial.data.sdi.engine.impl.SDIManagerImpl; +import org.gcube.spatial.data.sdi.engine.impl.ThreddsManagerImpl; +import org.gcube.spatial.data.sdi.engine.impl.faults.ServiceRegistrationException; +import org.gcube.spatial.data.sdi.model.ParameterType; +import org.gcube.spatial.data.sdi.model.services.GeoNetworkServiceDefinition; +import org.gcube.spatial.data.sdi.test.factories.ThreddsManagerFactory; + +import ch.qos.logback.core.util.SystemInfo; + +public class RegisterServiceTest { + + + public static void main(String[] args) throws MalformedURLException, ServiceRegistrationException { + TokenSetter.set("/d4science.research-infrastructures.eu/gCubeApps/AlienAndInvasiveSpecies"); + + LocalConfiguration.init(Paths.get("src/main/webapp/WEB-INF/config.properties").toUri().toURL()); + + SDIManagerImpl sdi=new SDIManagerImpl(new GeoNetworkManagerImpl(new RoleManagerImpl()), new ThreddsManagerFactory().provide(), new GISManagerImpl()); + + + System.out.println(sdi.registerService(getGNDefinition())); + + + + + } + + + private static GeoNetworkServiceDefinition getGNDefinition() { + GeoNetworkServiceDefinition def=new GeoNetworkServiceDefinition(); + def.setAdminPassword("gCube@Gn321_sdi"); + def.setDescription("GeoNetwork v3 Serving Demo VREs"); + def.setHostname("geonetwork-spatialdata.d4science.org"); + def.setMajorVersion((short)3); + def.setMinorVersion((short)2); + def.setReleaseVersion((short)1); + def.setName("GeoNetwork 3 Alien"); + def.setPriority(10); + ParameterType[] params=new ParameterType[] { + new ParameterType("suffixes",""), + //devNext Manually configured +// new ParameterType("scope1","devNext"), +// new ParameterType("scopeUser1","devNext_context"), +// new ParameterType("scopePwd1","123456"), +// new ParameterType("ckanUser1","devNext_ckan"), +// new ParameterType("scopePwd1","987456"), +// new ParameterType("mngUser1","devNext_manager"), +// new ParameterType("mngPwd1","741852"), +// new ParameterType("default1","1"), +// new ParameterType("public1","1"), +// new ParameterType("confidential1","1"), +// new ParameterType("private1","1"), + //NextNext +// new ParameterType("scope2","NextNext"), +// new ParameterType("scopeUser2","nextNext_context"), +// new ParameterType("scopePwd2","456789"), +// new ParameterType("ckanUser2","nextNext_ckan"), +// new ParameterType("scopePwd2","123789"), +// new ParameterType("mngUser2","nextNext_manager"), +// new ParameterType("mngPwd2","963852"), +// new ParameterType("default2","1"), +// new ParameterType("public2","1"), +// new ParameterType("confidential2","1"), +// new ParameterType("private2","1"), + }; + def.setProperties(new ArrayList(Arrays.asList(params))); + return def; + } +} diff --git a/src/test/java/org/gcube/spatial/data/sdi/test/TestCreateCatalog.java b/src/test/java/org/gcube/spatial/data/sdi/test/TestCreateCatalog.java new file mode 100644 index 0000000..66ddef2 --- /dev/null +++ b/src/test/java/org/gcube/spatial/data/sdi/test/TestCreateCatalog.java @@ -0,0 +1,85 @@ +package org.gcube.spatial.data.sdi.test; + +import java.net.MalformedURLException; +import java.nio.file.Paths; + +import org.gcube.spatial.data.sdi.LocalConfiguration; +import org.gcube.spatial.data.sdi.engine.ThreddsManager; +import org.gcube.spatial.data.sdi.engine.impl.ThreddsManagerImpl; +import org.gcube.spatial.data.sdi.test.factories.ThreddsManagerFactory; + +public class TestCreateCatalog { + + public static void main(String[] args) throws MalformedURLException { +// TokenSetter.set("/d4science.research-infrastructures.eu/gCubeApps/BiodiversityLab"); + + + TokenSetter.set("/gcube/devNext"); + + + LocalConfiguration.init(Paths.get("src/main/webapp/WEB-INF/config.properties").toUri().toURL()); + + ThreddsManager mng=new ThreddsManagerFactory().provide(); + + /* + * "PUT /sdi-service/gcube/service/Thredds? + * name=Thredds+Root+Catalog& + * path=public/netcdf/syncfolderfrancesco& + * folder=public/netcdf/syncfolderfrancesco HTTP/1.1" 1057 Jersey/2.13 (HttpUrlConnection 1.8.0_131) + */ + + + String baseName="ThreddsRootCatalog"; + String authority="www.d4science.org"; + String path="public/netcdf/syncfolderfrancesco"; + String folder="public/netcdf/Anothersyncfolderfrancesco"; + + + /* + * + @QueryParam(Constants.AUTHORITY_PARAMETER) @DefaultValue("www.d4science.org") String authority, + @QueryParam(Constants.BASE_NAME_PARAMETER) String baseName, + @QueryParam(Constants.PATH_PARAMETER) String path, + @QueryParam(Constants.FOLDER_PARAMETER) String folder) + + + + try { + String scopeName=ScopeUtils.getCurrentScopeName(); + + log.info("Received register catalog request under scope {} ",scopeName); + + if(baseName==null) { + log.debug("Base name not provided, using VRE {} ",scopeName); + baseName=scopeName+"_VRE"; + } + + if(folder==null) { + log.debug("Folder not provided, using base name {} ",baseName); + folder=baseName+"_folder"; + } + + if(path==null) { + log.debug("Path not provided, using baseName {} ",baseName); + path=baseName; + } + + */ + String datasetScanName=(baseName+" Catalog").replace("_", " "); + String datasetScanId=baseName+"_in_"+folder; + String catalogReference=(baseName).replaceAll("_", " "); + + + + + + try { + + mng.createCatalogFromTemplate(authority,path,datasetScanId,datasetScanName,folder,catalogReference); + }catch(Exception e) { + e.printStackTrace(); + } + + } + +} diff --git a/src/test/java/org/gcube/spatial/data/sdi/test/TestIS.java b/src/test/java/org/gcube/spatial/data/sdi/test/TestIS.java index 4692e76..8af76cd 100644 --- a/src/test/java/org/gcube/spatial/data/sdi/test/TestIS.java +++ b/src/test/java/org/gcube/spatial/data/sdi/test/TestIS.java @@ -5,15 +5,21 @@ import java.nio.file.Paths; import org.gcube.common.resources.gcore.ServiceEndpoint; import org.gcube.spatial.data.sdi.LocalConfiguration; -import org.gcube.spatial.data.sdi.ScopeUtils; import org.gcube.spatial.data.sdi.engine.impl.is.ISUtils; +import org.gcube.spatial.data.sdi.utils.ScopeUtils; public class TestIS { public static void main(String[] args) throws MalformedURLException { - TokenSetter.set("/gcube/devNext"); + TokenSetter.set("/gcube/devNext/NextNext"); LocalConfiguration.init(Paths.get("src/main/webapp/WEB-INF/config.properties").toUri().toURL()); - ServiceEndpoint e=ISUtils.querySEById("c8afa8c0-c781-11e2-8f67-be3b57c971ee"); + ServiceEndpoint e=ISUtils.querySEById("8e1962e9-05a7-40d4-a56f-574431f4c907"); + + e.profile().description(e.profile().description()+"_modified"); + + System.out.println("Identity : "+ISUtils.marshal(e).equals(ISUtils.marshal(e))); + + System.out.println(ISUtils.updateAndWait(e)); System.out.println("PARENTS"); diff --git a/src/test/java/org/gcube/spatial/data/sdi/test/factories/ThreddsManagerFactory.java b/src/test/java/org/gcube/spatial/data/sdi/test/factories/ThreddsManagerFactory.java index aed6a0b..417ba6b 100644 --- a/src/test/java/org/gcube/spatial/data/sdi/test/factories/ThreddsManagerFactory.java +++ b/src/test/java/org/gcube/spatial/data/sdi/test/factories/ThreddsManagerFactory.java @@ -18,7 +18,7 @@ public class ThreddsManagerFactory implements Factory{ public ThreddsManagerFactory() { - manager=new ThreddsManagerImpl(){ + manager=new ThreddsManagerImpl(new MetadataTemplateManagerFactory().provide()){ @Override protected AbstractCluster getCluster() { TokenSetter.set(TestCommon.TEST_SCOPE);