UserUtils integration

This commit is contained in:
Fabio Sinibaldi 2023-01-10 15:57:40 +01:00
parent 5055c548d1
commit 5ea3d278ad
45 changed files with 199 additions and 218 deletions

View File

@ -2,6 +2,9 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
# Changelog for org.gcube.spatial.data.gcube-sdi-suite
## [v1.0.4-SNAPSHOT] - 2023-01-10
- Updated plugin framework
## [v1.0.3] - 2022-12-07
- Updated plugin framework
- Introduced module default-lc-managers

View File

@ -4,6 +4,9 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
This library contains gcube-cms plugins for ckan materializations
## [v1.0.2-SNAPSHOT] - 2023-01-10
- Pom updates
## [v1.0.1] - 2022-12-07
- Pom updates

View File

@ -5,14 +5,14 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>ckan-plugins</artifactId>
<version>1.0.1</version>
<version>1.0.2-SNAPSHOT</version>
<name>gCube CMS - CKAN Plugins</name>
<parent>
<groupId>org.gcube.application.cms</groupId>
<artifactId>gcube-cms-suite</artifactId>
<version>1.0.3</version>
<version>1.0.4-SNAPSHOT</version>
</parent>
<properties>

View File

@ -2,6 +2,9 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
# Changelog for org.gcube.application.cms-plugin-framework
## [v1.0.3-SNAPSHOT] - 2023-01-10
- UserUtils in framework
## [v1.0.2] 2022-01-17
- Fixes #2435
- Introduced module default-lc-managers

View File

@ -4,12 +4,12 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>cms-plugin-framework</artifactId>
<version>1.0.2</version>
<version>1.0.3-SNAPSHOT</version>
<parent>
<groupId>org.gcube.application.cms</groupId>
<artifactId>gcube-cms-suite</artifactId>
<version>1.0.3</version>
<version>1.0.4-SNAPSHOT</version>
</parent>
@ -67,6 +67,12 @@
<dependencies>
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>authorization-utils</artifactId>
<version>[2.0.0, 3.0.0-SNAPSHOT)</version>
</dependency>
<dependency>
<groupId>org.gcube.application.cms</groupId>
<artifactId>geoportal-common</artifactId>

View File

@ -2,6 +2,7 @@ package org.gcube.application.cms.caches;
import lombok.NonNull;
import lombok.extern.slf4j.Slf4j;
import org.gcube.application.cms.implementations.utils.UserUtils;
import org.gcube.application.geoportal.common.model.rest.ConfigurationException;
import org.gcube.application.geoportal.common.utils.ContextUtils;
@ -18,7 +19,10 @@ public abstract class AbstractScopedMap<T> extends TimedMap<String,T> implements
@Override
public T getObject() throws ConfigurationException {
return get(ContextUtils.getCurrentScope());
UserUtils.AuthenticatedUser user = UserUtils.getCurrent();
String context = user.getContext();
log.debug(" {} : Accessing object under context {} ",name,context);
return get(context);
}

View File

@ -1,4 +1,4 @@
package org.gcube.application.geoportal.service.utils;
package org.gcube.application.cms.implementations.utils;
import lombok.AllArgsConstructor;
import lombok.Getter;

View File

@ -2,6 +2,9 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
# Changelog for org.gcube.application.cms.cms-test-commons
## [v1.0.4-SNAPSHOT] - 2023-01-10
- Pom updates
## [v1.0.3] - 2022-12-07
- Pom updates

View File

@ -5,14 +5,14 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>cms-test-commons</artifactId>
<version>1.0.3</version>
<version>1.0.4-SNAPSHOT</version>
<name>CMS Test Commons</name>
<parent>
<groupId>org.gcube.application.cms</groupId>
<artifactId>gcube-cms-suite</artifactId>
<version>1.0.3</version>
<version>1.0.4-SNAPSHOT</version>
</parent>

View File

@ -4,6 +4,9 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
This library contains custom extensions for the support of GNA "concessioni" use case
## [v1.0.3-SNAPSHOT] - 2023-01-10
- Pom updates
## [v1.0.2] - 2022-12-07
- Pom updates
- Introduced module default-lc-managers

View File

@ -4,14 +4,14 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>concessioni-lifecycle</artifactId>
<version>1.0.2</version>
<version>1.0.3-SNAPSHOT</version>
<name>GNA Concessioni Lifecycle</name>
<parent>
<groupId>org.gcube.application.cms</groupId>
<artifactId>gcube-cms-suite</artifactId>
<version>1.0.3</version>
<version>1.0.4-SNAPSHOT</version>
</parent>
<properties>

View File

@ -4,6 +4,9 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
This library contains custom BEANS for the support of GNA "concessioni" use case
## [v1.0.3-SNAPSHOT] - 2023-01-10
- Pom updates
## [v1.0.2] - 2022-12-07
- Pom updates

View File

@ -6,14 +6,14 @@
<groupId>org.gcube.application.cms</groupId>
<artifactId>concessioni-model</artifactId>
<version>1.0.2</version>
<version>1.0.3-SNAPSHOT</version>
<name>GNA Concessioni Model</name>
<parent>
<groupId>org.gcube.application.cms</groupId>
<artifactId>gcube-cms-suite</artifactId>
<version>1.0.3</version>
<version>1.0.4-SNAPSHOT</version>
</parent>
<properties>

View File

@ -4,6 +4,9 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
This library contains gcube-cms plugins for processing via gCube Dataminer
## [v1.0.2-SNAPSHOT] - 2023-01-10
- Pom updates
## [v1.0.1] - 2022-12-07
- Pom updates

View File

@ -5,14 +5,14 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>dataminer-plugins</artifactId>
<version>1.0.1</version>
<version>1.0.3-SNAPSHOT</version>
<name>gCube CMS - Dataminer Plugins</name>
<parent>
<groupId>org.gcube.application.cms</groupId>
<artifactId>gcube-cms-suite</artifactId>
<version>1.0.3</version>
<version>1.0.4-SNAPSHOT</version>
</parent>
<dependencyManagement>

View File

@ -4,5 +4,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
This library contains default Lifecycle Managers handlers
## [v1.0.0] - 2022-02-24
## [v1.0.1-SNAPSHOT] - 2023-01-10
- Pom updates
- ## [v1.0.0] - 2022-02-24
- First release

View File

@ -5,14 +5,14 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>default-lc-managers</artifactId>
<version>1.0.0</version>
<version>1.0.1-SNAPSHOT</version>
<name>gCube CMS - Default LC Managers</name>
<parent>
<groupId>org.gcube.application.cms</groupId>
<artifactId>gcube-cms-suite</artifactId>
<version>1.0.3</version>
<version>1.0.4-SNAPSHOT</version>
</parent>
<properties>

View File

@ -3,6 +3,7 @@ package org.gcube.application.cms.plugins.implementations;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.gcube.application.cms.implementations.ProjectAccess;
import org.gcube.application.cms.implementations.utils.UserUtils;
import org.gcube.application.cms.plugins.LifecycleManager;
import org.gcube.application.cms.plugins.PluginManagerInterface;
import org.gcube.application.cms.plugins.faults.*;
@ -164,9 +165,10 @@ public abstract class AbstractLifeCycleManager extends AbstractPlugin implements
try{
report.setStatus(Report.Status.OK);
} catch (Throwable e) {
log.error("Unable to initialize plugins in {} ", ContextUtils.getCurrentScope(),e);
String context = UserUtils.getCurrent().getContext();
log.error("Unable to initialize plugins in {} ", context,e);
report.setStatus(Report.Status.WARNING);
report.putMessage("Unable to initialize plugins in "+ ContextUtils.getCurrentScope()+" : "+e.getMessage());
report.putMessage("Unable to initialize plugins in "+ context +" : "+e.getMessage());
}
return report;
}

View File

@ -2,6 +2,9 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
# Changelog for org.gcube.application.geoportal-client
## [v1.1.2-SNAPSHOT] - 2023-01-10
- Pom updates
## [v1.1.1] - 2022-12-07
- Pom updates

View File

@ -4,14 +4,14 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.gcube.application</groupId>
<artifactId>geoportal-client</artifactId>
<version>1.1.1</version>
<version>1.1.2-SNAPSHOT</version>
<name>Geoportal Client</name>
<parent>
<groupId>org.gcube.application.cms</groupId>
<artifactId>gcube-cms-suite</artifactId>
<version>1.0.3</version>
<version>1.0.4-SNAPSHOT</version>
</parent>

View File

@ -2,6 +2,9 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
# Changelog for org.gcube.application.geoportal-common
## [v1.0.11-SNAPSHOT] - 2023-01-10
- Pom updates
## [v1.0.10] - 2022-12-07
- Pom updates

View File

@ -3,14 +3,14 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>geoportal-common</artifactId>
<version>1.0.10</version>
<version>1.0.11-SNAPSHOT</version>
<name>Geoportal Common</name>
<parent>
<groupId>org.gcube.application.cms</groupId>
<artifactId>gcube-cms-suite</artifactId>
<version>1.0.3</version>
<version>1.0.4-SNAPSHOT</version>
</parent>
<properties>

View File

@ -8,33 +8,20 @@ import org.gcube.common.scope.api.ScopeProvider;
import static org.gcube.common.authorization.client.Constants.authorizationService;
@Slf4j
@Deprecated
public class ContextUtils {
public static String getCurrentScope(){
try{
String token=SecurityTokenProvider.instance.get();
log.trace("Token is : "+token.substring(0,2)+"..."+token.substring(token.length()-3));
if(token==null) throw new Exception("Security Token is null");
AuthorizationEntry entry = authorizationService().get(token);
return entry.getContext();
}catch(Exception e ){
log.trace("Unable to resolve token, checking scope provider..",e);
return ScopeProvider.instance.get();
}
}
public static String getCurrentCaller(){
try{
String token=SecurityTokenProvider.instance.get();
log.trace("Token is : "+token.substring(0,2)+"..."+token.substring(token.length()-3));
if(token==null) throw new Exception("Security Token is null");
log.trace("Token is : "+token.substring(0,2)+"..."+token.substring(token.length()-3));
AuthorizationEntry entry = authorizationService().get(token);
return entry.getClientInfo().getId();
}catch(Exception e ){
log.trace("Unable to resolve token, checking scope provider..",e);
return "Unidentified data-transfer user";
log.warn("Unable to resolve token using legacy utils, using default ..",e);
return "CMS_default_user";
}
}
}

View File

@ -17,7 +17,7 @@ public class GCubeTest {
testContext = "/pred4s/preprod/preVRE";
// testContext = "/d4science.research-infrastructures.eu/D4OS/GNA";
testContext= "/gcube/devsec/devVRE";
// testContext= "/gcube/devsec/devVRE";
System.out.println("TEST CONTEXT = "+testContext);
return testContext;

View File

@ -2,6 +2,9 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
# Changelog for org.gcube.application.geoportal-service
## [v1.0.12-SNAPSHOT] - 2023-01-10
- Refactored UserUtils into framework plugin
## [v1.0.11] - 2022-12-07
- Pom updates
- Introduced module default-lc-managers

View File

@ -4,14 +4,14 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.gcube.application</groupId>
<artifactId>geoportal-service</artifactId>
<version>1.0.11</version>
<version>1.0.13-SNAPSHOT</version>
<name>Geoportal Service</name>
<packaging>war</packaging>
<parent>
<groupId>org.gcube.application.cms</groupId>
<artifactId>gcube-cms-suite</artifactId>
<version>1.0.3</version>
<version>1.0.4-SNAPSHOT</version>
</parent>
<properties>
@ -68,11 +68,6 @@
<artifactId>default-lc-managers</artifactId>
</dependency>
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>authorization-utils</artifactId>
<version>[2.0.0, 3.0.0-SNAPSHOT)</version>
</dependency>
<!-- MONGO -->
<!-- https://mvnrepository.com/artifact/org.mongodb/mongo-java-driver -->

View File

@ -14,6 +14,7 @@ import org.bson.types.ObjectId;
import org.gcube.application.cms.implementations.ImplementationProvider;
import org.gcube.application.cms.implementations.WorkspaceManager;
import org.gcube.application.cms.implementations.faults.*;
import org.gcube.application.cms.implementations.utils.UserUtils;
import org.gcube.application.cms.plugins.LifecycleManager;
import org.gcube.application.cms.plugins.faults.EventException;
import org.gcube.application.cms.plugins.faults.InsufficientPrivileges;
@ -50,7 +51,7 @@ import org.gcube.application.geoportal.common.model.useCaseDescriptor.*;
import org.gcube.application.geoportal.common.utils.ContextUtils;
import org.gcube.application.geoportal.common.utils.StorageUtils;
import org.gcube.application.geoportal.service.engine.providers.PluginManager;
import org.gcube.application.geoportal.service.utils.UserUtils;
import org.gcube.common.storagehub.client.dsl.FolderContainer;
import org.gcube.common.storagehub.model.exceptions.StorageHubException;
@ -821,7 +822,8 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI<
@Override
public Configuration getConfiguration() throws ConfigurationException{
log.debug("Asking configuration for {} in {} ", useCaseDescriptor.getId(), UserUtils.getCurrent().getContext());
String context = UserUtils.getCurrent().getContext();
log.debug("Asking configuration for {} in {} ", useCaseDescriptor.getId(), context);
Configuration toReturn= new Configuration();
List<Archive> archives = new ArrayList<>();
toReturn.setArchives(archives);
@ -829,7 +831,7 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI<
toReturn.setIndexes(indexes);
// Set Basic Info
toReturn.setProfileId(this.getUseCaseDescriptor().getId());
toReturn.setContext(ContextUtils.getCurrentScope());
toReturn.setContext(context);
toReturn.setLastUpdatedTime(LocalDateTime.now());
// Add Mongo Info

View File

@ -7,6 +7,7 @@ import com.mongodb.client.model.ReturnDocument;
import lombok.extern.slf4j.Slf4j;
import org.bson.Document;
import org.bson.types.ObjectId;
import org.gcube.application.cms.implementations.utils.UserUtils;
import org.gcube.application.cms.serialization.Serialization;
import org.gcube.application.geoportal.common.model.rest.ConfigurationException;
import org.gcube.application.geoportal.common.model.rest.QueryRequest;
@ -24,7 +25,10 @@ public class UCDMongoManager extends MongoManager implements UCDManagerI{
public UCDMongoManager() throws ConfigurationException {
init("UCD_"+ContextUtils.getCurrentScope().replaceAll("/","_"));
String context = UserUtils.getCurrent().getContext();
String collectionName ="UCD_"+context.replaceAll("/","_");
log.debug("Starting UCD mongo manager under {} with collection name {} ",context, collectionName);
init(collectionName);
}
public long deleteAll(){

View File

@ -4,10 +4,12 @@ import lombok.NonNull;
import lombok.extern.slf4j.Slf4j;
import org.gcube.application.cms.caches.AbstractScopedMap;
import org.gcube.application.cms.caches.TimedMap;
import org.gcube.application.cms.implementations.utils.UserUtils;
import org.gcube.application.geoportal.common.model.configuration.Configuration;
import org.gcube.application.geoportal.common.model.rest.ConfigurationException;
import org.gcube.application.geoportal.service.engine.mongo.ProfiledMongoManager;
import java.time.Duration;
import java.time.temporal.ChronoUnit;
import java.time.temporal.TemporalAmount;
@ -45,6 +47,7 @@ public class ConfigurationCache extends AbstractScopedMap<ConfigurationCache.Con
private static Configuration getForProfile(String profileID) throws ConfigurationException{
log.info("Evaluating Configuration for profile {} ",profileID);
log.debug("Caller is {} ", UserUtils.getCurrent());
try{
return new ProfiledMongoManager(profileID).getConfiguration();
} catch (ConfigurationException e) {

View File

@ -6,6 +6,7 @@ import org.gcube.application.cms.caches.AbstractScopedMap;
import org.gcube.application.cms.caches.Engine;
import org.gcube.application.cms.caches.ObjectManager;
import org.gcube.application.cms.implementations.ImplementationProvider;
import org.gcube.application.cms.implementations.utils.UserUtils;
import org.gcube.application.cms.serialization.Serialization;
import org.gcube.application.geoportal.common.model.rest.ConfigurationException;
import org.gcube.application.geoportal.common.model.rest.QueryRequest;
@ -204,7 +205,8 @@ public class UCDManager extends AbstractScopedMap<UCDManagerI> implements UCDMan
log.warn("Unable to cache UCD {}",entry.getKey(),e);
}
}
log.info("Cached {} UCDs in {} ",memCache.size(),ContextUtils.getCurrentScope());
String context = UserUtils.getCurrent().getContext();
log.info("Cached {} UCDs in {} ",memCache.size(),context);
cacheLock.writeLock().unlock();
}

View File

@ -2,6 +2,7 @@ package org.gcube.application.geoportal.service.engine.mongo;
import org.bson.Document;
import org.gcube.application.cms.implementations.faults.*;
import org.gcube.application.cms.implementations.utils.UserUtils;
import org.gcube.application.cms.plugins.faults.EventException;
import org.gcube.application.cms.plugins.faults.InsufficientPrivileges;
import org.gcube.application.cms.plugins.faults.StepException;
@ -16,7 +17,6 @@ import org.gcube.application.geoportal.common.utils.FileSets;
import org.gcube.application.geoportal.common.utils.StorageUtils;
import org.gcube.application.geoportal.common.utils.tests.GCubeTest;
import org.gcube.application.geoportal.service.BasicServiceTestUnit;
import org.gcube.application.geoportal.service.utils.UserUtils;
import org.gcube.common.storagehub.model.exceptions.StorageHubException;
import org.junit.Before;
import org.junit.BeforeClass;
@ -30,7 +30,7 @@ import static org.junit.Assume.assumeTrue;
public class LockTests extends BasicServiceTestUnit {
String profileID = "rolesTesting";
String profileID = "basic";
ProfiledMongoManager manager= null;
@BeforeClass
@ -100,7 +100,7 @@ public class LockTests extends BasicServiceTestUnit {
// register fileset
FileSets.RequestBuilder builder = FileSets.build(
"$.relazioneScavo","fileset","relazioneScavo."+ Field.CHILDREN+"[?(@.fileset)]");
"$.section","fileset","section."+ Field.CHILDREN+"[?(@.fileset)]");
StorageUtils s= new StorageUtils();
builder.add(
s.putOntoStorage(new File(Tests.FOLDER_CONCESSIONI,"pos.shp"),"pos.shp"));
@ -109,7 +109,7 @@ public class LockTests extends BasicServiceTestUnit {
checkIsLockCleaned(p.getId());
// delete fileset
p=managerInterface.deleteFileSet(p.getId(),"$.relazioneScavo.fileset",false);
p=managerInterface.deleteFileSet(p.getId(),"$.section.fileset",false);
checkIsLockCleaned(p.getId());
// perform step

View File

@ -24,6 +24,7 @@ import org.junit.Before;
import org.junit.Test;
import org.opengis.service.Interface;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.client.Entity;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;

View File

@ -33,7 +33,7 @@ public class DummyProjectTest extends AbstractProfiledDocumentsTests{
String fieldName="fileset";
String fieldDefinition="section."+Field.CHILDREN+"[?(@.fileset)]";
String filename = "sample.tif";
String filename = "concessioni/sample.tif";
@Override
@ -146,137 +146,16 @@ public class DummyProjectTest extends AbstractProfiledDocumentsTests{
return doc;
}
@Test
public void testUnlock() throws Exception {
assumeTrue(GCubeTest.isTestInfrastructureEnabled());
// Not automatic, needs generation of locked project
assumeTrue(false);
String id = "627e87bb02ad3d1a2e0e9e18";
String ucd = "profiledConcessioni";
Project p =check(target(InterfaceConstants.Methods.PROJECTS).path(ucd).path(InterfaceConstants.Methods.FORCE_UNLOCK).path(id).request(MediaType.APPLICATION_JSON).
put(Entity.entity("", MediaType.APPLICATION_JSON)), Project.class);
assertNull(p.getLock());
}
@Test
public void testRelationships() throws Exception {
assumeTrue(GCubeTest.isTestInfrastructureEnabled());
Project a = createNew(new Document("key","value"));
Project b = createNew(new Document("key","value"));
// set relation a -- precedes --> b
System.out.println("Setting relation..");
String relId="precedes";
a = check(baseTarget().
path(InterfaceConstants.Methods.RELATIONSHIP).
path(a.getId()).
path(relId).
queryParam(InterfaceConstants.Parameters.TARGET_UCD,b.getProfileID()).
queryParam(InterfaceConstants.Parameters.TARGET_ID,b.getId()).
request(MediaType.APPLICATION_JSON).
put(Entity.json("")), Project.class);
// check set relation in a
System.out.println("Checking relation a->b");
assertTrue(a.getRelationships()!=null && a.getRelationships().size()==1);
Relationship rel = a.getRelationships().get(0);
assertEquals(rel.getRelationshipName(),relId);
assertEquals(rel.getTargetUCD(),b.getProfileID());
assertEquals(rel.getTargetID(),b.getId());
// TODO TBD check reciprocity : expected relation b -- follows -> a
// delete relation
System.out.println("Deleting relation a->b");
a = check(baseTarget().
path(InterfaceConstants.Methods.RELATIONSHIP).
path(a.getId()).
path(relId).
queryParam(InterfaceConstants.Parameters.TARGET_UCD,b.getProfileID()).
queryParam(InterfaceConstants.Parameters.TARGET_ID,b.getId()).
request(MediaType.APPLICATION_JSON).
delete(), Project.class);
// check deleted
System.out.println("Checking deleted relation");
assertTrue(a.getRelationships()==null || a.getRelationships().isEmpty());
}
// @Test
// public void testSDI() throws Exception {
// // Create new
// Project doc = createNew(new Document("posizionamentoScavo",new Document("title","Mio pos")));
//
// // register filesets
// doc = upload(
// new StorageUtils(),
// doc.getId(),
// "posizionamentoScavo","fileset",
// "posizionamentoScavo."+Field.CHILDREN+"[?(@.fileset)]",
// null,
// RegisterFileSetRequest.ClashOptions.REPLACE_EXISTING,
// "pos.shp","pos.shx");
//
// System.out.println("Registered posizionamento, result is "+ Serialization.write(doc));
//
// // invoke step SUBMIT-FOR-REVIEW
// StepExecutionRequest req=new StepExecutionRequest();
// req.setStepID("SUBMIT-FOR-REVIEW");
// doc=step(doc.getId(),req);
// System.out.println(doc);
// if(doc.getLifecycleInformation().getErrorMessages()!=null) {
// System.out.println("ERROR MESSAGES");
// doc.getLifecycleInformation().getErrorMessages().forEach(s -> System.out.println(s));
// }
// if(doc.getLifecycleInformation().getWarningMessages()!=null) {
// System.out.println("WARNING MESSAGES");
// doc.getLifecycleInformation().getWarningMessages().forEach(s -> System.out.println(s));
// }
//
// assertTrue(doc.getLifecycleInformation().getLastOperationStatus().equals(LifecycleInformation.Status.OK));
//
// JSONPathWrapper wrapper = new JSONPathWrapper(doc.getTheDocument().toJson());
// RegisteredFileSet fs = Serialization.convert(wrapper.getByPath("$..fileset").get(0),RegisteredFileSet.class);
// assertTrue(fs!=null);
// assertTrue(fs.getPayloads().size()==2);
// assertTrue(fs.getMaterializations().size()>0);
//
//
// for(Object matObj : wrapper.getByPath("$..[?(@."+ Materialization.TYPE +" == '"+GCubeSDILayer.GCUBE_SDY_LAYER_TYPE+"' )]")){
// GCubeSDILayer layer = Serialization.convert(matObj, GCubeSDILayer.class);
// System.out.println("Checking Layer : "+layer);
// assertTrue(layer.getType().equals(GCubeSDILayer.GCUBE_SDY_LAYER_TYPE));
// assertTrue(layer.getOGCLinks().size()>0);
// assertTrue(layer.getPlatformInfo().size()>0);
// assertTrue(layer.getBBox()!=null);
// }
//
// // Checking platform info GeoServer
// for(Object platformObj : wrapper.getByPath("$..[?(@."+ Materialization.TYPE +" == 'GeoServer' )]")){
// Document platform=Serialization.asDocument(platformObj);
// assertTrue(platform.containsKey("layerName"));
// assertTrue(platform.containsKey("workspace"));
// assertTrue(platform.containsKey("storeName"));
// assertTrue(platform.containsKey("persistencePath"));
// assertTrue(platform.get("files",List.class).size()==2);
// }
//
//
// req.setStepID("APPROVE DRAFT");
// doc=step(doc.getId(),req);
// if(doc.getLifecycleInformation().getErrorMessages()!=null) {
// System.out.println("ERROR MESSAGES");
// doc.getLifecycleInformation().getErrorMessages().forEach(s -> System.out.println(s));
// }
// if(doc.getLifecycleInformation().getWarningMessages()!=null) {
// System.out.println("WARNING MESSAGES");
// doc.getLifecycleInformation().getWarningMessages().forEach(s -> System.out.println(s));
// }
//
// assertTrue(doc.getLifecycleInformation().getLastOperationStatus().equals(LifecycleInformation.Status.OK));
//
// public void testUnlock() throws Exception {
// assumeTrue(GCubeTest.isTestInfrastructureEnabled());
// assumeTrue(false);
// String id = "627e87bb02ad3d1a2e0e9e18";
// String ucd = "profiledConcessioni";
// Project p =check(target(InterfaceConstants.Methods.PROJECTS).path(ucd).path(InterfaceConstants.Methods.FORCE_UNLOCK).path(id).request(MediaType.APPLICATION_JSON).
// put(Entity.entity("", MediaType.APPLICATION_JSON)), Project.class);
// assertNull(p.getLock());
// }
}

View File

@ -2,11 +2,8 @@ package org.gcube.application.geoportal.service.profiledDocuments;
import lombok.extern.slf4j.Slf4j;
import org.bson.Document;
import org.gcube.application.cms.implementations.ImplementationProvider;
import org.gcube.application.cms.implementations.WorkspaceManager;
import org.gcube.application.cms.implementations.utils.UserUtils;
import org.gcube.application.cms.serialization.Serialization;
import org.gcube.application.cms.tests.model.BasicTests;
import org.gcube.application.geoportal.common.model.JSONPathWrapper;
import org.gcube.application.geoportal.common.model.document.Project;
import org.gcube.application.geoportal.common.model.document.access.Access;
import org.gcube.application.geoportal.common.model.document.identification.SpatialReference;
@ -14,17 +11,12 @@ import org.gcube.application.geoportal.common.model.document.lifecycle.Lifecycle
import org.gcube.application.geoportal.common.model.rest.RegisterFileSetRequest;
import org.gcube.application.geoportal.common.model.rest.StepExecutionRequest;
import org.gcube.application.geoportal.common.model.useCaseDescriptor.Field;
import org.gcube.application.geoportal.common.rest.InterfaceConstants;
import org.gcube.application.geoportal.common.utils.StorageUtils;
import org.gcube.application.geoportal.common.utils.tests.GCubeTest;
import org.gcube.application.geoportal.service.utils.UserUtils;
import org.gcube.common.storagehub.model.exceptions.StorageHubException;
import org.junit.Test;
import javax.management.relation.Relation;
import javax.ws.rs.client.Entity;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;
import java.time.LocalDateTime;
import static org.junit.Assert.assertEquals;

View File

@ -4,6 +4,9 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
This library contains gcube-cms plugins for images materializations
## [v1.0.2-SNAPSHOT] - 2023-01-10
- Pom updates
## [v1.0.1] - 2022-12-07
- Pom updates

View File

@ -5,14 +5,14 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>images-plugins</artifactId>
<version>1.0.1</version>
<version>1.0.2-SNAPSHOT</version>
<name>gCube CMS - Images Plugins</name>
<parent>
<groupId>org.gcube.application.cms</groupId>
<artifactId>gcube-cms-suite</artifactId>
<version>1.0.3</version>
<version>1.0.4-SNAPSHOT</version>
</parent>

View File

@ -4,6 +4,9 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
This library contains gcube-cms plugins for notitfications events
## [v1.0.2-SNAPSHOT] - 2023-01-10
- Pom updates
## [v1.0.1] - 2022-12-07
- Pom updates

View File

@ -5,14 +5,14 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>notifications-plugins</artifactId>
<version>1.0.1</version>
<version>1.0.2-SNAPSHOT</version>
<name>gCube CMS - Notifications Plugins</name>
<parent>
<groupId>org.gcube.application.cms</groupId>
<artifactId>gcube-cms-suite</artifactId>
<version>1.0.3</version>
<version>1.0.4-SNAPSHOT</version>
</parent>
<properties>

14
pom.xml
View File

@ -9,7 +9,7 @@
<groupId>org.gcube.application.cms</groupId>
<artifactId>gcube-cms-suite</artifactId>
<packaging>pom</packaging>
<version>1.0.3</version>
<version>1.0.4-SNAPSHOT</version>
<name>Gcube CMS Suite</name>
<description>gCube CMS Suite is a set of components designed to manage complex space-temporal Documents defined by metadata Profiles.</description>
@ -26,17 +26,15 @@
<gcube-smartgears-bom-version>2.1.1</gcube-smartgears-bom-version>
<gcube-portal-bom-version>3.6.3</gcube-portal-bom-version>
<storagehub-version-range>[1.0.0,2.0.0-SNAPSHOT)</storagehub-version-range>
<plugin-framework-version>1.0.1</plugin-framework-version>
<!--dev -->
<!-- <gcube-bom-version>2.1.0-SNAPSHOT</gcube-bom-version>-->
<!-- <gcube-smartgears-bom-version>2.2.0-SNAPSHOT</gcube-smartgears-bom-version>-->
<!-- <gcube-portal-bom-version>3.7.0-SNAPSHOT</gcube-portal-bom-version>-->
<!-- <storagehub-version-range>[2.0.0-SNAPSHOT,3.0.0-SNAPSHOT)</storagehub-version-range>-->
<!--&lt;!&ndash; <storagehub-version-range>[1.0.0,2.0.0-SNAPSHOT)</storagehub-version-range>&ndash;&gt;-->
<!-- <plugin-framework-version>1.0.2-SNAPSHOT</plugin-framework-version>-->
<gcube-bom-version>2.1.0-SNAPSHOT</gcube-bom-version>
<gcube-smartgears-bom-version>2.2.0-SNAPSHOT</gcube-smartgears-bom-version>
<gcube-portal-bom-version>3.7.0-SNAPSHOT</gcube-portal-bom-version>
<storagehub-version-range>[2.0.0-SNAPSHOT,3.0.0-SNAPSHOT)</storagehub-version-range>
<plugin-framework-version>1.0.3-SNAPSHOT</plugin-framework-version>
</properties>

View File

@ -4,6 +4,9 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
This library contains gcube-cms plugins for indexing and materializations in gCube SDI
## [v1.0.2-SNAPSHOT] - 2023-01-10
- Pom updates
## [v1.0.1] - 2022-12-07
- Pom updates
- Introduced module default-lc-managers

View File

@ -5,14 +5,14 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>sdi-plugins</artifactId>
<version>1.0.1</version>
<version>1.0.2-SNAPSHOT</version>
<name>gCube CMS - SDI Plugins</name>
<parent>
<groupId>org.gcube.application.cms</groupId>
<artifactId>gcube-cms-suite</artifactId>
<version>1.0.3</version>
<version>1.0.4-SNAPSHOT</version>
</parent>
<properties>

View File

@ -5,6 +5,7 @@ import lombok.Data;
import lombok.Synchronized;
import lombok.extern.slf4j.Slf4j;
import org.bson.Document;
import org.gcube.application.cms.implementations.utils.UserUtils;
import org.gcube.application.cms.plugins.MaterializationPlugin;
import org.gcube.application.cms.plugins.faults.InitializationException;
import org.gcube.application.cms.plugins.faults.InvalidPluginRequestException;
@ -47,7 +48,9 @@ public class SDIMaterializerPlugin extends AbstractPlugin implements Materializa
private SDIManagerWrapper getSDIManager(){
return sdiManagerMap.get(ContextUtils.getCurrentScope());
String context = UserUtils.getCurrent().getContext();
log.debug("Getting SDIManagerWrapper from cache map for context {}");
return sdiManagerMap.get(context);
}
@Override
@ -55,7 +58,7 @@ public class SDIMaterializerPlugin extends AbstractPlugin implements Materializa
public InitializationReport initInContext() throws InitializationException {
InitializationReport report = new InitializationReport();
try{
String context = ContextUtils.getCurrentScope();
String context = UserUtils.getCurrent().getContext();
if(getSDIManager()==null) {
log.info("Initializing in " + context);
sdiManagerMap.put(context,new SDIManagerWrapper());

View File

@ -1,6 +1,11 @@
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
# Changelog for org.gcube.application.geoportal-client
# Changelog for org.gcube.application.cms.use-cases
## [v1.0.4-SNAPSHOT] - 2023-01-10
- Pom updates
## [v1.0.3] - 2022-12-07
- Pom updates

View File

@ -4,12 +4,12 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>use-cases</artifactId>
<version>1.0.3</version>
<version>1.0.4-SNAPSHOT</version>
<name>CMS Use cases</name>
<parent>
<artifactId>gcube-cms-suite</artifactId>
<groupId>org.gcube.application.cms</groupId>
<version>1.0.3</version>
<version>1.0.4-SNAPSHOT</version>
</parent>

View File

@ -0,0 +1,56 @@
package org.gcube.application.cms.usecases;
import org.gcube.application.cms.tests.TokenSetter;
import org.gcube.application.geoportal.client.UseCaseDescriptors;
import org.gcube.application.geoportal.common.model.rest.QueryRequest;
import org.gcube.application.geoportal.common.rest.Projects;
import org.gcube.application.geoportal.common.rest.UseCaseDescriptorsI;
import org.gcube.application.geoportal.common.utils.tests.GCubeTest;
import org.junit.Assert;
import org.junit.Test;
import java.util.concurrent.atomic.AtomicLong;
import static org.gcube.application.geoportal.client.plugins.GeoportalAbstractPlugin.projects;
import static org.gcube.application.geoportal.client.plugins.GeoportalAbstractPlugin.useCaseDescriptors;
import static org.junit.Assume.assumeTrue;
public class GenericChecks {
UseCaseDescriptorsI getClient(){
assumeTrue(GCubeTest.isTestInfrastructureEnabled());
TokenSetter.set(GCubeTest.getContext());
return useCaseDescriptors().build();
}
@Test
public void getAll() throws Exception {
UseCaseDescriptorsI client =getClient();
QueryRequest request = new QueryRequest();
// All
client.query(request).forEachRemaining(u -> {
try {
System.out.println("Obtained UCD "+u.getId());
client.getById(u.getId()).getId();
Projects pClient = (Projects)projects(u.getId()).build();
AtomicLong counter=new AtomicLong(0);
pClient.query(new QueryRequest()).forEachRemaining( M -> counter.incrementAndGet());
System.out.println("Found "+counter.get()+" elements");
} catch (Exception e) {
e.printStackTrace(System.err);
Assert.fail("Unable to check "+u.getId());
}
});
}
}