UCD Client

This commit is contained in:
Fabio Sinibaldi 2022-03-07 13:59:24 +01:00
parent 2a83ae98bb
commit 16bc565aed
24 changed files with 219 additions and 66 deletions

View File

@ -25,7 +25,7 @@ import java.util.Iterator;
@RequiredArgsConstructor @RequiredArgsConstructor
@Slf4j @Slf4j
public class DefaultProfiledDocumentsClient<T extends Project> implements Projects<T> { public class DefaultDocumentsClient<T extends Project> implements Projects<T> {
@NonNull @NonNull
protected final ProxyDelegate<WebTarget> delegate; protected final ProxyDelegate<WebTarget> delegate;
@ -45,7 +45,7 @@ public class DefaultProfiledDocumentsClient<T extends Project> implements Projec
log.debug("Creating Profiled Document (class {}, useCaseDescriptor {}) with content {} ", log.debug("Creating Profiled Document (class {}, useCaseDescriptor {}) with content {} ",
getManagedClass(),profileID, toCreate); getManagedClass(),profileID, toCreate);
Call<WebTarget, T> call = endpoint -> { Call<WebTarget, T> call = endpoint -> {
return check(endpoint.path(profileID).request(MediaType.APPLICATION_JSON). return ResponseCommons.check(endpoint.path(profileID).request(MediaType.APPLICATION_JSON).
post(Entity.entity(toCreate, MediaType.APPLICATION_JSON)),getManagedClass()); post(Entity.entity(toCreate, MediaType.APPLICATION_JSON)),getManagedClass());
}; };
T toReturn = delegate.make(call); T toReturn = delegate.make(call);
@ -70,7 +70,7 @@ public class DefaultProfiledDocumentsClient<T extends Project> implements Projec
try { try {
log.debug("Deleting ID {}  useCaseDescriptor {}  force {} ", id, profileID, force); log.debug("Deleting ID {}  useCaseDescriptor {}  force {} ", id, profileID, force);
Call<WebTarget, T> call = endpoint -> { Call<WebTarget, T> call = endpoint -> {
return check(endpoint.path(profileID).path(id). return ResponseCommons.check(endpoint.path(profileID).path(id).
queryParam(InterfaceConstants.Parameters.FORCE,force). queryParam(InterfaceConstants.Parameters.FORCE,force).
request(MediaType.APPLICATION_JSON).delete(),getManagedClass()); request(MediaType.APPLICATION_JSON).delete(),getManagedClass());
}; };
@ -91,7 +91,7 @@ public class DefaultProfiledDocumentsClient<T extends Project> implements Projec
log.info("Loading Document ID {} (class {}, useCaseDescriptor {})", log.info("Loading Document ID {} (class {}, useCaseDescriptor {})",
id, getManagedClass(),profileID); id, getManagedClass(),profileID);
Call<WebTarget, T> call = endpoint -> { Call<WebTarget, T> call = endpoint -> {
return check(endpoint.path(profileID).path(id). return ResponseCommons.check(endpoint.path(profileID).path(id).
request(MediaType.APPLICATION_JSON).get(), getManagedClass()); request(MediaType.APPLICATION_JSON).get(), getManagedClass());
}; };
return delegate.make(call); return delegate.make(call);
@ -109,7 +109,7 @@ public class DefaultProfiledDocumentsClient<T extends Project> implements Projec
try { try {
log.info("Loading Configuration for useCaseDescriptor {}", profileID); log.info("Loading Configuration for useCaseDescriptor {}", profileID);
Call<WebTarget, Configuration> call = endpoint -> { Call<WebTarget, Configuration> call = endpoint -> {
return check(endpoint.path(profileID).path(InterfaceConstants.Methods.CONFIGURATION_PATH). return ResponseCommons.check(endpoint.path(profileID).path(InterfaceConstants.Methods.CONFIGURATION_PATH).
request(MediaType.APPLICATION_JSON).get(), Configuration.class); request(MediaType.APPLICATION_JSON).get(), Configuration.class);
}; };
return delegate.make(call); return delegate.make(call);
@ -145,8 +145,8 @@ public class DefaultProfiledDocumentsClient<T extends Project> implements Projec
try { try {
log.debug("Querying useCaseDescriptor {}  for {}",profileID,request); log.debug("Querying useCaseDescriptor {}  for {}",profileID,request);
Call<WebTarget, String> call = endpoint -> { Call<WebTarget, String> call = endpoint -> {
return check(endpoint.path(profileID).path(InterfaceConstants.Methods.QUERY_PATH). return ResponseCommons.check(endpoint.path(profileID).path(InterfaceConstants.Methods.QUERY_PATH).
request(MediaType.APPLICATION_JSON).get(), String.class); request(MediaType.APPLICATION_JSON).post(Entity.entity(request,MediaType.APPLICATION_JSON)), String.class);
}; };
return delegate.make(call); return delegate.make(call);
}catch(RemoteException e){ }catch(RemoteException e){
@ -164,7 +164,7 @@ public class DefaultProfiledDocumentsClient<T extends Project> implements Projec
log.debug("Executing step on {} (class {}, useCaseDescriptor {}) with request {} ", log.debug("Executing step on {} (class {}, useCaseDescriptor {}) with request {} ",
id, getManagedClass(),profileID, request); id, getManagedClass(),profileID, request);
Call<WebTarget, T> call = endpoint -> { Call<WebTarget, T> call = endpoint -> {
return check(endpoint.path(profileID).path(id).request(MediaType.APPLICATION_JSON). return ResponseCommons.check(endpoint.path(profileID).path(id).request(MediaType.APPLICATION_JSON).
post(Entity.entity(request, MediaType.APPLICATION_JSON)),getManagedClass()); post(Entity.entity(request, MediaType.APPLICATION_JSON)),getManagedClass());
}; };
T toReturn = delegate.make(call); T toReturn = delegate.make(call);
@ -186,7 +186,7 @@ public class DefaultProfiledDocumentsClient<T extends Project> implements Projec
log.debug("Registering FileSet on {} (class {}, useCaseDescriptor {}) with request {} ", log.debug("Registering FileSet on {} (class {}, useCaseDescriptor {}) with request {} ",
id, getManagedClass(),profileID, req); id, getManagedClass(),profileID, req);
Call<WebTarget, T> call = endpoint -> { Call<WebTarget, T> call = endpoint -> {
return check(endpoint.path(profileID).path(InterfaceConstants.Methods.REGISTER_FILES_PATH) return ResponseCommons.check(endpoint.path(profileID).path(InterfaceConstants.Methods.REGISTER_FILES_PATH)
.path(id).request(MediaType.APPLICATION_JSON). .path(id).request(MediaType.APPLICATION_JSON).
post(Entity.entity(req, MediaType.APPLICATION_JSON)),getManagedClass()); post(Entity.entity(req, MediaType.APPLICATION_JSON)),getManagedClass());
}; };
@ -209,7 +209,7 @@ public class DefaultProfiledDocumentsClient<T extends Project> implements Projec
log.debug("Deleting Fileset for ID {}  [useCaseDescriptor {}  , class {}] at {} (force {} )", log.debug("Deleting Fileset for ID {}  [useCaseDescriptor {}  , class {}] at {} (force {} )",
id, profileID,getManagedClass(),path, force); id, profileID,getManagedClass(),path, force);
Call<WebTarget, T> call = endpoint -> { Call<WebTarget, T> call = endpoint -> {
return check(endpoint.path(profileID).path(InterfaceConstants.Methods.DELETE_FILES_PATH). return ResponseCommons.check(endpoint.path(profileID).path(InterfaceConstants.Methods.DELETE_FILES_PATH).
path(id).queryParam(InterfaceConstants.Parameters.FORCE,force). path(id).queryParam(InterfaceConstants.Parameters.FORCE,force).
request(MediaType.APPLICATION_JSON). request(MediaType.APPLICATION_JSON).
post(Entity.entity(path, MediaType.APPLICATION_JSON)),getManagedClass()); post(Entity.entity(path, MediaType.APPLICATION_JSON)),getManagedClass());
@ -232,7 +232,7 @@ public class DefaultProfiledDocumentsClient<T extends Project> implements Projec
log.debug("Updateing {}  [useCaseDescriptor {}  , class {}] with ", log.debug("Updateing {}  [useCaseDescriptor {}  , class {}] with ",
id, profileID,getManagedClass(),updatedDocument); id, profileID,getManagedClass(),updatedDocument);
Call<WebTarget, T> call = endpoint -> { Call<WebTarget, T> call = endpoint -> {
return check(endpoint.path(profileID).path(id). return ResponseCommons.check(endpoint.path(profileID).path(id).
request(MediaType.APPLICATION_JSON). request(MediaType.APPLICATION_JSON).
put(Entity.entity(updatedDocument, MediaType.APPLICATION_JSON)),getManagedClass()); put(Entity.entity(updatedDocument, MediaType.APPLICATION_JSON)),getManagedClass());
}; };
@ -248,12 +248,5 @@ public class DefaultProfiledDocumentsClient<T extends Project> implements Projec
} }
} }
protected static<R> R check(Response resp, Class<R> clazz) throws IOException {
String resString=resp.readEntity(String.class);
if(resp.getStatus()<200||resp.getStatus()>=300)
throw new RemoteException("RESP STATUS IS "+resp.getStatus()+". Message : "+resString);
if(clazz!=null)
return Serialization.read(resString, clazz);
else return null;
}
} }

View File

@ -0,0 +1,19 @@
package org.gcube.application.geoportal.client;
import org.gcube.application.geoportal.client.utils.Serialization;
import javax.ws.rs.core.Response;
import java.io.IOException;
import java.rmi.RemoteException;
public class ResponseCommons {
protected static<R> R check(Response resp, Class<R> clazz) throws IOException {
String resString=resp.readEntity(String.class);
if(resp.getStatus()<200||resp.getStatus()>=300)
throw new RemoteException("RESP STATUS IS "+resp.getStatus()+". Message : "+resString);
if(clazz!=null)
return Serialization.read(resString, clazz);
else return null;
}
}

View File

@ -0,0 +1,63 @@
package org.gcube.application.geoportal.client;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.bson.Document;
import org.gcube.application.geoportal.client.utils.Serialization;
import org.gcube.application.geoportal.common.model.rest.QueryRequest;
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
import org.gcube.application.geoportal.common.rest.InterfaceConstants;
import org.gcube.application.geoportal.common.rest.UseCaseDescriptorsI;
import org.gcube.common.clients.Call;
import org.gcube.common.clients.delegates.ProxyDelegate;
import javax.ws.rs.client.Entity;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;
import java.rmi.RemoteException;
import java.util.Iterator;
@RequiredArgsConstructor
@Slf4j
public class UseCaseDescriptors implements UseCaseDescriptorsI {
@NonNull
private final ProxyDelegate<WebTarget> delegate;
@Override
public UseCaseDescriptor create(Document toCreate) throws RemoteException {
throw new RuntimeException("Yet To Implement");
}
@Override
public Iterator<UseCaseDescriptor> query(QueryRequest request) throws Exception {
String json = delegate.make(webTarget ->
ResponseCommons.check(webTarget.path(InterfaceConstants.Methods.QUERY_PATH).
request(MediaType.APPLICATION_JSON).post(Entity.entity(request,MediaType.APPLICATION_JSON)),
String.class));
try{
return Serialization.readCollection(json,UseCaseDescriptor.class);
}catch(Throwable t){
log.error("Unable to query UCD with {} ",request,t);
throw new Exception("Unable to parse collection. Check projection settings.",t);
}
}
@Override
public void deleteById(String id, boolean force) throws RemoteException {
throw new RuntimeException("Yet To Implement");
}
@Override
public UseCaseDescriptor update(String ID, Document toSet) throws RemoteException {
throw new RuntimeException("Yet To Implement");
}
@Override
public UseCaseDescriptor getById(String id) throws Exception {
return delegate.make(webTarget -> ResponseCommons.check(webTarget.path(id).
request(MediaType.APPLICATION_JSON_TYPE).get(),UseCaseDescriptor.class));
}
}

View File

@ -1,23 +1,17 @@
package org.gcube.application.geoportal.client.legacy; package org.gcube.application.geoportal.client.legacy;
import static org.gcube.application.geoportal.client.GeoportalAbstractPlugin.concessioni; import static org.gcube.application.geoportal.client.plugins.GeoportalAbstractPlugin.concessioni;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import org.gcube.application.geoportal.common.model.legacy.Concessione; import org.gcube.application.geoportal.common.model.legacy.Concessione;
import org.gcube.application.geoportal.common.model.legacy.InputStreamDescriptor;
import org.gcube.application.geoportal.common.model.legacy.LayerConcessione;
import org.gcube.application.geoportal.common.model.legacy.RelazioneScavo;
import org.gcube.application.geoportal.common.model.legacy.UploadedImage;
import org.gcube.application.geoportal.common.model.legacy.report.PublicationReport;
import org.gcube.application.geoportal.common.rest.ConcessioniI; import org.gcube.application.geoportal.common.rest.ConcessioniI;
import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.MappingIterator;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectReader; import com.fasterxml.jackson.databind.ObjectReader;
import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.databind.SerializationFeature;

View File

@ -5,7 +5,7 @@ import javax.xml.namespace.QName;
import javax.xml.transform.dom.DOMResult; import javax.xml.transform.dom.DOMResult;
import javax.xml.ws.EndpointReference; import javax.xml.ws.EndpointReference;
import org.gcube.application.geoportal.client.GeoportalAbstractPlugin; import org.gcube.application.geoportal.client.plugins.GeoportalAbstractPlugin;
import org.gcube.application.geoportal.common.rest.ConcessioniI; import org.gcube.application.geoportal.common.rest.ConcessioniI;
import org.gcube.application.geoportal.common.rest.InterfaceConstants; import org.gcube.application.geoportal.common.rest.InterfaceConstants;
import org.gcube.common.calls.jaxrs.GcubeService; import org.gcube.common.calls.jaxrs.GcubeService;

View File

@ -6,7 +6,7 @@ import javax.xml.transform.dom.DOMResult;
import javax.xml.ws.EndpointReference; import javax.xml.ws.EndpointReference;
import org.gcube.application.geoportal.client.DefaultMongoConcessioni; import org.gcube.application.geoportal.client.DefaultMongoConcessioni;
import org.gcube.application.geoportal.client.GeoportalAbstractPlugin; import org.gcube.application.geoportal.client.plugins.GeoportalAbstractPlugin;
import org.gcube.application.geoportal.common.rest.InterfaceConstants; import org.gcube.application.geoportal.common.rest.InterfaceConstants;
import org.gcube.application.geoportal.common.rest.MongoConcessioni; import org.gcube.application.geoportal.common.rest.MongoConcessioni;
import org.gcube.common.calls.jaxrs.GcubeService; import org.gcube.common.calls.jaxrs.GcubeService;

View File

@ -5,7 +5,7 @@ import javax.xml.namespace.QName;
import javax.xml.transform.dom.DOMResult; import javax.xml.transform.dom.DOMResult;
import javax.xml.ws.EndpointReference; import javax.xml.ws.EndpointReference;
import org.gcube.application.geoportal.client.GeoportalAbstractPlugin; import org.gcube.application.geoportal.client.plugins.GeoportalAbstractPlugin;
import org.gcube.application.geoportal.common.rest.InterfaceConstants; import org.gcube.application.geoportal.common.rest.InterfaceConstants;
import org.gcube.common.calls.jaxrs.GcubeService; import org.gcube.common.calls.jaxrs.GcubeService;
import org.gcube.common.calls.jaxrs.TargetFactory; import org.gcube.common.calls.jaxrs.TargetFactory;

View File

@ -1,4 +1,4 @@
package org.gcube.application.geoportal.client; package org.gcube.application.geoportal.client.plugins;
import javax.ws.rs.client.WebTarget; import javax.ws.rs.client.WebTarget;
@ -7,10 +7,7 @@ import org.gcube.application.geoportal.client.legacy.ConcessioniPlugin;
import org.gcube.application.geoportal.client.legacy.MongoConcessioniPlugin; import org.gcube.application.geoportal.client.legacy.MongoConcessioniPlugin;
import org.gcube.application.geoportal.client.legacy.StatefulMongoConcessioniPlugin; import org.gcube.application.geoportal.client.legacy.StatefulMongoConcessioniPlugin;
import org.gcube.application.geoportal.common.model.document.Project; import org.gcube.application.geoportal.common.model.document.Project;
import org.gcube.application.geoportal.common.rest.ConcessioniI; import org.gcube.application.geoportal.common.rest.*;
import org.gcube.application.geoportal.common.rest.InterfaceConstants;
import org.gcube.application.geoportal.common.rest.MongoConcessioni;
import org.gcube.application.geoportal.common.rest.Projects;
import org.gcube.common.clients.Plugin; import org.gcube.common.clients.Plugin;
import org.gcube.common.clients.ProxyBuilder; import org.gcube.common.clients.ProxyBuilder;
import org.gcube.common.clients.ProxyBuilderImpl; import org.gcube.common.clients.ProxyBuilderImpl;
@ -22,28 +19,31 @@ import lombok.AllArgsConstructor;
public abstract class GeoportalAbstractPlugin <S, P> implements Plugin<S, P>{ public abstract class GeoportalAbstractPlugin <S, P> implements Plugin<S, P>{
public static ProxyBuilder<UseCaseDescriptorsI> useCaseDescriptors() {
return new ProxyBuilderImpl<WebTarget, UseCaseDescriptorsI>(new UCDPlugin());
}
public static ProxyBuilder<Projects<Project>> profiledDocuments(String profileID) { public static ProxyBuilder<Projects<Project>> projects(String profileID) {
ProjectsInterfacePlugin plugin=new ProjectsInterfacePlugin(profileID); ProjectsInterfacePlugin plugin=new ProjectsInterfacePlugin(profileID);
return new ProxyBuilderImpl<WebTarget, Projects<Project>>(plugin); return new ProxyBuilderImpl<WebTarget, Projects<Project>>(plugin);
} }
public static <C extends Projects<Project>> ProxyBuilder<C> profiledDocuments(String profileID, Class<C> customClient) { public static <C extends Projects<Project>> ProxyBuilder<C> projects(String profileID, Class<C> customClient) {
ProjectsInterfacePlugin plugin=new ProjectsInterfacePlugin(profileID); ProjectsInterfacePlugin plugin=new ProjectsInterfacePlugin(profileID);
plugin.setCustomClientImplementation(customClient); plugin.setCustomClientImplementation(customClient);
return new ProxyBuilderImpl<WebTarget, C>(plugin); return new ProxyBuilderImpl<WebTarget, C>(plugin);
} }
public static <P extends Project> ProxyBuilder<Projects<P>> public static <P extends Project> ProxyBuilder<Projects<P>>
profiledModel(String profileID, Class<P> customModel ) { customModel(String profileID, Class<P> customModel ) {
ProjectsInterfacePlugin plugin=new ProjectsInterfacePlugin(profileID); ProjectsInterfacePlugin plugin=new ProjectsInterfacePlugin(profileID);
plugin.setProfiledModel(customModel); plugin.setProfiledModel(customModel);
return new ProxyBuilderImpl<WebTarget, Projects<P>>(plugin); return new ProxyBuilderImpl<WebTarget, Projects<P>>(plugin);
} }
public static <P extends Project,C extends Projects<P>> ProxyBuilder<C> public static <P extends Project,C extends Projects<P>> ProxyBuilder<C>
profiledModel(String profileID, Class<P> customModel ,Class<C> customClient) { customModel(String profileID, Class<P> customModel , Class<C> customClient) {
ProjectsInterfacePlugin plugin=new ProjectsInterfacePlugin(profileID); ProjectsInterfacePlugin plugin=new ProjectsInterfacePlugin(profileID);
plugin.setProfiledModel(customModel); plugin.setProfiledModel(customModel);
plugin.setCustomClientImplementation(customClient); plugin.setCustomClientImplementation(customClient);

View File

@ -1,4 +1,4 @@
package org.gcube.application.geoportal.client; package org.gcube.application.geoportal.client.plugins;
import javax.ws.rs.client.WebTarget; import javax.ws.rs.client.WebTarget;
import javax.xml.namespace.QName; import javax.xml.namespace.QName;
@ -10,6 +10,7 @@ import lombok.RequiredArgsConstructor;
import lombok.Setter; import lombok.Setter;
import lombok.SneakyThrows; import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.gcube.application.geoportal.client.DefaultDocumentsClient;
import org.gcube.application.geoportal.common.model.document.Project; import org.gcube.application.geoportal.common.model.document.Project;
import org.gcube.application.geoportal.common.rest.InterfaceConstants; import org.gcube.application.geoportal.common.rest.InterfaceConstants;
import org.gcube.application.geoportal.common.rest.Projects; import org.gcube.application.geoportal.common.rest.Projects;
@ -21,7 +22,7 @@ import org.w3c.dom.Node;
@Slf4j @Slf4j
@RequiredArgsConstructor @RequiredArgsConstructor
public class ProjectsInterfacePlugin<C extends DefaultProfiledDocumentsClient,P extends Project> extends GeoportalAbstractPlugin<WebTarget, Projects<P>>{ public class ProjectsInterfacePlugin<C extends DefaultDocumentsClient,P extends Project> extends GeoportalAbstractPlugin<WebTarget, Projects<P>>{
@NonNull @NonNull
private String profileID; private String profileID;

View File

@ -0,0 +1,41 @@
package org.gcube.application.geoportal.client.plugins;
import org.gcube.application.geoportal.client.UseCaseDescriptors;
import org.gcube.application.geoportal.common.rest.InterfaceConstants;
import org.gcube.application.geoportal.common.rest.UseCaseDescriptorsI;
import org.gcube.common.calls.jaxrs.GcubeService;
import org.gcube.common.calls.jaxrs.TargetFactory;
import org.gcube.common.clients.config.ProxyConfig;
import org.gcube.common.clients.delegates.ProxyDelegate;
import org.w3c.dom.Node;
import javax.ws.rs.client.WebTarget;
import javax.xml.namespace.QName;
import javax.xml.transform.dom.DOMResult;
import javax.xml.ws.EndpointReference;
public class UCDPlugin extends GeoportalAbstractPlugin<WebTarget, UseCaseDescriptorsI>{
@Override
public Exception convert(Exception fault, ProxyConfig<?, ?> config) {
return super.convert(fault, config);
}
@Override
public UseCaseDescriptorsI newProxy(ProxyDelegate<WebTarget> proxyDelegate) {
return new UseCaseDescriptors(proxyDelegate);
}
@Override
public WebTarget resolve(EndpointReference endpointReference, ProxyConfig<?, ?> proxyConfig) throws Exception {
DOMResult result = new DOMResult();
endpointReference.writeTo(result);
Node node =result.getNode();
Node child=node.getFirstChild();
String addressString = child.getTextContent();
GcubeService service = GcubeService.service().
withName(new QName(InterfaceConstants.NAMESPACE,InterfaceConstants.Methods.UCD)).
andPath(InterfaceConstants.Methods.UCD);
return TargetFactory.stubFor(service).at(addressString);
}
}

View File

@ -14,7 +14,7 @@ import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.rmi.RemoteException; import java.rmi.RemoteException;
import static org.gcube.application.geoportal.client.GeoportalAbstractPlugin.projects; import static org.gcube.application.geoportal.client.plugins.GeoportalAbstractPlugin.projects;
public class GenericUseCases { public class GenericUseCases {

View File

@ -1,6 +1,6 @@
package org.gcube.application.geoportal.clients; package org.gcube.application.geoportal.clients;
import org.gcube.application.geoportal.client.DefaultProfiledDocumentsClient; import org.gcube.application.geoportal.client.DefaultDocumentsClient;
import org.gcube.application.geoportal.common.model.document.Project; import org.gcube.application.geoportal.common.model.document.Project;
import org.gcube.application.geoportal.common.model.rest.Configuration; import org.gcube.application.geoportal.common.model.rest.Configuration;
import org.gcube.application.geoportal.common.model.rest.QueryRequest; import org.gcube.application.geoportal.common.model.rest.QueryRequest;
@ -12,7 +12,7 @@ import java.rmi.RemoteException;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.assertTrue;
import static org.gcube.application.geoportal.client.GeoportalAbstractPlugin.*; import static org.gcube.application.geoportal.client.plugins.GeoportalAbstractPlugin.*;
import static org.junit.Assume.assumeTrue; import static org.junit.Assume.assumeTrue;
public class ProfiledDocumentsTest<M extends Project,C extends Projects<M>> extends BasicVreTests{ public class ProfiledDocumentsTest<M extends Project,C extends Projects<M>> extends BasicVreTests{
@ -20,7 +20,7 @@ public class ProfiledDocumentsTest<M extends Project,C extends Projects<M>> exte
protected String getProfileID(){return "profiledConcessioni";} protected String getProfileID(){return "profiledConcessioni";}
protected C getClient(){ protected C getClient(){
return (C) profiledModel(getProfileID(), Project.class,DefaultProfiledDocumentsClient.class).build(); return (C) customModel(getProfileID(), Project.class, DefaultDocumentsClient.class).build();
} }

View File

@ -0,0 +1,51 @@
package org.gcube.application.geoportal.clients;
import org.gcube.application.geoportal.client.utils.Queries;
import org.gcube.application.geoportal.common.model.rest.QueryRequest;
import org.gcube.application.geoportal.common.rest.UseCaseDescriptorsI;
import org.gcube.application.geoportal.common.utils.tests.GCubeTest;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import java.util.concurrent.atomic.AtomicLong;
import static org.gcube.application.geoportal.client.plugins.GeoportalAbstractPlugin.useCaseDescriptors;
import static org.junit.Assume.assumeTrue;
public class UCDTests {
UseCaseDescriptorsI client =null;
@Before
public void getClient(){
assumeTrue(GCubeTest.isTestInfrastructureEnabled());
client =useCaseDescriptors().build();
}
@Test
public void query() throws Exception {
QueryRequest request = new QueryRequest();
// All
AtomicLong counter = new AtomicLong(0l);
client.query(request).forEachRemaining(u ->counter.incrementAndGet());
System.out.println("Count : "+counter.get());
}
@Test
public void getById() throws Exception {
UseCaseDescriptorsI client = useCaseDescriptors().build();
QueryRequest request = new QueryRequest();
// All
client.query(request).forEachRemaining(u -> {
try {
client.getById(u.getId());
} catch (Exception e) {
e.printStackTrace(System.err);
Assert.fail("Unable to get "+u.getId());
}
});
}
}

View File

@ -1,6 +1,6 @@
package org.gcube.application.geoportal.clients.legacy; package org.gcube.application.geoportal.clients.legacy;
import static org.gcube.application.geoportal.client.GeoportalAbstractPlugin.statefulMongoConcessioni; import static org.gcube.application.geoportal.client.plugins.GeoportalAbstractPlugin.statefulMongoConcessioni;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import static org.junit.Assume.assumeTrue; import static org.junit.Assume.assumeTrue;

View File

@ -20,7 +20,7 @@ import java.io.File;
import java.util.Iterator; import java.util.Iterator;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
import static org.gcube.application.geoportal.client.GeoportalAbstractPlugin.mongoConcessioni; import static org.gcube.application.geoportal.client.plugins.GeoportalAbstractPlugin.mongoConcessioni;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import static org.junit.Assume.assumeTrue; import static org.junit.Assume.assumeTrue;

View File

@ -5,17 +5,18 @@ import org.gcube.application.geoportal.common.model.rest.QueryRequest;
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor; import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
import java.rmi.RemoteException; import java.rmi.RemoteException;
import java.util.Iterator;
public interface UseCaseDescriptors { public interface UseCaseDescriptorsI {
public UseCaseDescriptor create(Document toCreate)throws RemoteException; public UseCaseDescriptor create(Document toCreate)throws RemoteException;
public Iterable<UseCaseDescriptor> query(QueryRequest request)throws RemoteException; public Iterator<UseCaseDescriptor> query(QueryRequest request) throws Exception;
public void deleteById(String id,boolean force)throws RemoteException; public void deleteById(String id,boolean force)throws RemoteException;
public UseCaseDescriptor update(String ID, Document toSet)throws RemoteException; public UseCaseDescriptor update(String ID, Document toSet)throws RemoteException;
public UseCaseDescriptor getById(String id)throws RemoteException; public UseCaseDescriptor getById(String id) throws Exception;
} }

View File

@ -13,7 +13,7 @@ import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
import static org.gcube.application.geoportal.client.GeoportalAbstractPlugin.statefulMongoConcessioni; import static org.gcube.application.geoportal.client.plugins.GeoportalAbstractPlugin.statefulMongoConcessioni;
@Slf4j @Slf4j
public class ClearConcessioni { public class ClearConcessioni {

View File

@ -2,7 +2,6 @@ package org.gcube.application.cms.usecases;
import org.gcube.application.cms.tests.TokenSetter; import org.gcube.application.cms.tests.TokenSetter;
import org.gcube.application.cms.usecases.mocks.ConcessionPublisherThread; import org.gcube.application.cms.usecases.mocks.ConcessionPublisherThread;
import org.gcube.application.geoportal.common.utils.FileSets;
import org.gcube.application.geoportal.common.model.legacy.Concessione; import org.gcube.application.geoportal.common.model.legacy.Concessione;
@ -13,7 +12,7 @@ import org.gcube.application.geoportal.common.utils.StorageUtils;
import java.io.File; import java.io.File;
import static org.gcube.application.geoportal.client.GeoportalAbstractPlugin.mongoConcessioni; import static org.gcube.application.geoportal.client.plugins.GeoportalAbstractPlugin.mongoConcessioni;
public class EditFileSet { public class EditFileSet {

View File

@ -22,7 +22,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
import static org.gcube.application.geoportal.client.GeoportalAbstractPlugin.statefulMongoConcessioni; import static org.gcube.application.geoportal.client.plugins.GeoportalAbstractPlugin.statefulMongoConcessioni;
@Slf4j @Slf4j
/* /*

View File

@ -9,7 +9,7 @@ import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
import static org.gcube.application.geoportal.client.GeoportalAbstractPlugin.statefulMongoConcessioni; import static org.gcube.application.geoportal.client.plugins.GeoportalAbstractPlugin.statefulMongoConcessioni;
public class RepublishAll { public class RepublishAll {

View File

@ -5,7 +5,7 @@ import org.gcube.application.geoportal.common.model.legacy.Concessione;
import org.gcube.application.geoportal.common.rest.MongoConcessioni; import org.gcube.application.geoportal.common.rest.MongoConcessioni;
import static org.gcube.application.geoportal.client.GeoportalAbstractPlugin.mongoConcessioni; import static org.gcube.application.geoportal.client.plugins.GeoportalAbstractPlugin.mongoConcessioni;
public class RepublishSingle { public class RepublishSingle {

View File

@ -8,7 +8,6 @@ import org.gcube.application.cms.usecases.mocks.ConcessionPublisherThread;
import org.gcube.application.geoportal.common.model.legacy.Concessione; import org.gcube.application.geoportal.common.model.legacy.Concessione;
import org.gcube.application.geoportal.common.model.rest.AddSectionToConcessioneRequest; import org.gcube.application.geoportal.common.model.rest.AddSectionToConcessioneRequest;
import org.gcube.application.geoportal.common.rest.MongoConcessioni; import org.gcube.application.geoportal.common.rest.MongoConcessioni;
import org.gcube.application.geoportal.common.utils.FileSets;
import org.gcube.application.geoportal.common.utils.StorageUtils; import org.gcube.application.geoportal.common.utils.StorageUtils;
import java.io.File; import java.io.File;
@ -18,7 +17,7 @@ import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
import static org.gcube.application.geoportal.client.GeoportalAbstractPlugin.mongoConcessioni; import static org.gcube.application.geoportal.client.plugins.GeoportalAbstractPlugin.mongoConcessioni;
@Slf4j @Slf4j
public class StressTest { public class StressTest {

View File

@ -26,7 +26,7 @@ import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
import static org.gcube.application.geoportal.client.GeoportalAbstractPlugin.mongoConcessioni; import static org.gcube.application.geoportal.client.plugins.GeoportalAbstractPlugin.mongoConcessioni;
@Slf4j @Slf4j
@RequiredArgsConstructor @RequiredArgsConstructor

View File

@ -4,21 +4,13 @@ import com.opencsv.CSVReader;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.gcube.application.cms.tests.TokenSetter; import org.gcube.application.cms.tests.TokenSetter;
import org.gcube.application.cms.tests.model.concessioni.TestConcessioniModel; import org.gcube.application.cms.tests.model.concessioni.TestConcessioniModel;
import org.gcube.application.geoportal.client.utils.Serialization;
import org.gcube.application.geoportal.common.utils.FileSets;
import org.gcube.application.geoportal.common.model.legacy.Concessione; import org.gcube.application.geoportal.common.model.legacy.Concessione;
import org.gcube.application.geoportal.common.model.legacy.report.ValidationReport;
import org.gcube.application.geoportal.common.rest.MongoConcessioni;
import org.gcube.application.geoportal.common.utils.Files;
import org.gcube.application.geoportal.common.utils.StorageUtils;
import org.gcube.contentmanagement.blobstorage.report.Report;
import java.io.*; import java.io.*;
import java.util.*; import java.util.*;
import java.util.function.Consumer; import java.util.function.Consumer;
import static org.gcube.application.geoportal.client.GeoportalAbstractPlugin.mongoConcessioni;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
@Slf4j @Slf4j