BugFixing
This commit is contained in:
parent
e0daa09d6f
commit
10c450fb2f
|
@ -106,6 +106,13 @@
|
||||||
<artifactId>reflections</artifactId>
|
<artifactId>reflections</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!--TEST-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gcube.application.cms</groupId>
|
||||||
|
<artifactId>cms-test-commons</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
|
@ -136,7 +136,7 @@ public class SimpleLifeCycleManager extends AbstractLifeCycleManager implements
|
||||||
// dematerialize all
|
// dematerialize all
|
||||||
blockNonDraft(report);
|
blockNonDraft(report);
|
||||||
JSONPathWrapper wrapper = new JSONPathWrapper(report.getTheRequest().getDocument().getTheDocument().toJson());
|
JSONPathWrapper wrapper = new JSONPathWrapper(report.getTheRequest().getDocument().getTheDocument().toJson());
|
||||||
for (String s : wrapper.getMatchingPaths("..*[?(@." + RegisteredFileSet.PAYLOADS + ")]")){
|
for (String s : wrapper.getMatchingPaths("$..[?(@." + RegisteredFileSet.PAYLOADS + ")]")){
|
||||||
log.info("Requesting dematerialization for {} ",s);
|
log.info("Requesting dematerialization for {} ",s);
|
||||||
for(MaterializationPlugin mat : getMaterializers(report.getTheRequest()))
|
for(MaterializationPlugin mat : getMaterializers(report.getTheRequest()))
|
||||||
report = deMaterialize(report,mat,new Document("fileSetPath",s));
|
report = deMaterialize(report,mat,new Document("fileSetPath",s));
|
||||||
|
|
|
@ -5,6 +5,7 @@ import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.bson.Document;
|
import org.bson.Document;
|
||||||
import org.gcube.application.geoportal.client.utils.Serialization;
|
import org.gcube.application.geoportal.client.utils.Serialization;
|
||||||
|
import org.gcube.application.geoportal.common.faults.InvalidRequestException;
|
||||||
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.configuration.Configuration;
|
import org.gcube.application.geoportal.common.model.configuration.Configuration;
|
||||||
import org.gcube.application.geoportal.common.model.rest.QueryRequest;
|
import org.gcube.application.geoportal.common.model.rest.QueryRequest;
|
||||||
|
@ -181,10 +182,11 @@ public class DefaultDocumentsClient<T extends Project> implements Projects<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T registerFileSet(String id, RegisterFileSetRequest req) throws RemoteException {
|
public T registerFileSet(String id, RegisterFileSetRequest req) throws RemoteException, InvalidRequestException {
|
||||||
try {
|
try {
|
||||||
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);
|
||||||
|
req.validate();
|
||||||
Call<WebTarget, T> call = endpoint -> {
|
Call<WebTarget, T> call = endpoint -> {
|
||||||
return ResponseCommons.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).
|
||||||
|
@ -194,6 +196,9 @@ public class DefaultDocumentsClient<T extends Project> implements Projects<T> {
|
||||||
log.info("Registered FileSet on {} [useCaseDescriptor {}, class {}] with {}",
|
log.info("Registered FileSet on {} [useCaseDescriptor {}, class {}] with {}",
|
||||||
id, profileID, getManagedClass(), req);
|
id, profileID, getManagedClass(), req);
|
||||||
return toReturn;
|
return toReturn;
|
||||||
|
}catch (InvalidRequestException e){
|
||||||
|
log.error("Invalid Request ",e);
|
||||||
|
throw e;
|
||||||
}catch(RemoteException e){
|
}catch(RemoteException e){
|
||||||
log.error("Unexpected error ",e);
|
log.error("Unexpected error ",e);
|
||||||
throw e;
|
throw e;
|
||||||
|
|
|
@ -5,6 +5,7 @@ import org.bson.Document;
|
||||||
import org.gcube.application.cms.tests.TestDocuments;
|
import org.gcube.application.cms.tests.TestDocuments;
|
||||||
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.client.utils.Serialization;
|
||||||
|
import org.gcube.application.geoportal.common.faults.InvalidRequestException;
|
||||||
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.RegisterFileSetRequest;
|
import org.gcube.application.geoportal.common.model.rest.RegisterFileSetRequest;
|
||||||
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
|
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
|
||||||
|
@ -35,7 +36,7 @@ public abstract class GenericUseCases extends BasicVreTests{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void createNew () throws RemoteException, FileNotFoundException, JsonProcessingException {
|
public void createNew () throws RemoteException, FileNotFoundException, JsonProcessingException, InvalidRequestException {
|
||||||
String profileID=getUCID();
|
String profileID=getUCID();
|
||||||
|
|
||||||
Document myDocument= new Document();
|
Document myDocument= new Document();
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package org.gcube.application.geoportal.common.rest;
|
package org.gcube.application.geoportal.common.rest;
|
||||||
|
|
||||||
import org.bson.Document;
|
import org.bson.Document;
|
||||||
|
import org.gcube.application.geoportal.common.faults.InvalidRequestException;
|
||||||
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.configuration.Configuration;
|
import org.gcube.application.geoportal.common.model.configuration.Configuration;
|
||||||
import org.gcube.application.geoportal.common.model.rest.QueryRequest;
|
import org.gcube.application.geoportal.common.model.rest.QueryRequest;
|
||||||
|
@ -35,7 +36,7 @@ public interface Projects<P extends Project> {
|
||||||
public P performStep(String id, StepExecutionRequest request) throws RemoteException;
|
public P performStep(String id, StepExecutionRequest request) throws RemoteException;
|
||||||
|
|
||||||
//FileSets
|
//FileSets
|
||||||
public P registerFileSet(String id, RegisterFileSetRequest req) throws RemoteException;
|
public P registerFileSet(String id, RegisterFileSetRequest req) throws RemoteException, InvalidRequestException;
|
||||||
//FileSets
|
//FileSets
|
||||||
public P deleteFileSet(String id, String path, Boolean force) throws RemoteException;
|
public P deleteFileSet(String id, String path, Boolean force) throws RemoteException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,9 @@ public class JSONPathTests {
|
||||||
// WMS
|
// WMS
|
||||||
System.out.println(documentNavigator.getByPath("$..wms"));
|
System.out.println(documentNavigator.getByPath("$..wms"));
|
||||||
|
|
||||||
|
|
||||||
|
System.out.println(documentNavigator.getMatchingPaths("$..[?(@." + RegisteredFileSet.PAYLOADS + ")]"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -107,8 +107,7 @@ public class ProfiledDocuments {
|
||||||
return new GuardedMethod<Project>() {
|
return new GuardedMethod<Project>() {
|
||||||
@Override
|
@Override
|
||||||
protected Project run() throws Exception, WebApplicationException {
|
protected Project run() throws Exception, WebApplicationException {
|
||||||
log.info("Registering {} file(s) for Project ({}, ID {}) with {}",
|
log.info("UCD {} : Project {} Registering Fileset. Request is {}",
|
||||||
request.getStreams().size(),
|
|
||||||
manager.getUseCaseDescriptor().getId(),
|
manager.getUseCaseDescriptor().getId(),
|
||||||
id,request);
|
id,request);
|
||||||
request.validate();
|
request.validate();
|
||||||
|
|
|
@ -26,6 +26,7 @@ import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static org.gcube.application.geoportal.client.plugins.GeoportalAbstractPlugin.projects;
|
import static org.gcube.application.geoportal.client.plugins.GeoportalAbstractPlugin.projects;
|
||||||
|
|
||||||
|
@ -62,7 +63,7 @@ public class ExportConcessioniAsProjects {
|
||||||
|
|
||||||
TokenSetter.set(targetContext);
|
TokenSetter.set(targetContext);
|
||||||
|
|
||||||
StorageUtils storage = new StorageUtils();
|
// StorageUtils storage = new StorageUtils();
|
||||||
|
|
||||||
AtomicLong count = new AtomicLong(0);
|
AtomicLong count = new AtomicLong(0);
|
||||||
AtomicLong warnCount = new AtomicLong(0);
|
AtomicLong warnCount = new AtomicLong(0);
|
||||||
|
@ -76,7 +77,7 @@ public class ExportConcessioniAsProjects {
|
||||||
service.submit(new Runnable(){
|
service.submit(new Runnable(){
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
publish(c,client,storage,errCount,count);
|
publish(c,client,errCount,count);
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
});
|
});
|
||||||
|
@ -91,18 +92,18 @@ public class ExportConcessioniAsProjects {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static List<TempFile> upload(List<PersistedContent> contents,StorageUtils storage) throws IOException {
|
// public static List<TempFile> upload(List<PersistedContent> contents,StorageUtils storage) throws IOException {
|
||||||
ArrayList toReturn = new ArrayList();
|
// ArrayList toReturn = new ArrayList();
|
||||||
for (PersistedContent content : contents)
|
// for (PersistedContent content : contents)
|
||||||
if (content instanceof WorkspaceContent) {
|
// if (content instanceof WorkspaceContent) {
|
||||||
WorkspaceContent wc = (WorkspaceContent) content;
|
// WorkspaceContent wc = (WorkspaceContent) content;
|
||||||
toReturn.add(storage.putOntoStorage(new URL(wc.getLink()).openStream(), wc.getName()));
|
// toReturn.add(storage.putOntoStorage(new URL(wc.getLink()).openStream(), wc.getName()));
|
||||||
}
|
// }
|
||||||
return toReturn;
|
// return toReturn;
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
private static void publish(Concessione c, Projects<Project> client, StorageUtils storage, AtomicLong errCount,AtomicLong count){
|
private static void publish(Concessione c, Projects<Project> client, AtomicLong errCount,AtomicLong count){
|
||||||
try {
|
try {
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
FileSets.RequestBuilder req=null;
|
FileSets.RequestBuilder req=null;
|
||||||
|
@ -150,7 +151,10 @@ public class ExportConcessioniAsProjects {
|
||||||
req = FileSets.build("$." + ProfiledConcessione.RELAZIONE_SCAVO, "fileset",
|
req = FileSets.build("$." + ProfiledConcessione.RELAZIONE_SCAVO, "fileset",
|
||||||
"$." + ProfiledConcessione.RELAZIONE_SCAVO + "." + Field.CHILDREN
|
"$." + ProfiledConcessione.RELAZIONE_SCAVO + "." + Field.CHILDREN
|
||||||
+ "[?(@.fileset)]");
|
+ "[?(@.fileset)]");
|
||||||
req.addAll(upload(content,storage));
|
req.addAll(content.stream().
|
||||||
|
filter(p -> p instanceof WorkspaceContent)
|
||||||
|
.map(p -> new TempFile(null, ((WorkspaceContent) p).getLink(), ((WorkspaceContent) p).getName()))
|
||||||
|
.collect(Collectors.toList()));
|
||||||
project = client.registerFileSet(project.getId(),req.getTheRequest());
|
project = client.registerFileSet(project.getId(),req.getTheRequest());
|
||||||
}
|
}
|
||||||
// upload fileset
|
// upload fileset
|
||||||
|
@ -208,7 +212,10 @@ public class ExportConcessioniAsProjects {
|
||||||
req = FileSets.build("$." + ProfiledConcessione.IMMAGINI_RAPPRESENTATIVE+"["+i+"]", "fileset",
|
req = FileSets.build("$." + ProfiledConcessione.IMMAGINI_RAPPRESENTATIVE+"["+i+"]", "fileset",
|
||||||
"$." + ProfiledConcessione.IMMAGINI_RAPPRESENTATIVE + "." + Field.CHILDREN
|
"$." + ProfiledConcessione.IMMAGINI_RAPPRESENTATIVE + "." + Field.CHILDREN
|
||||||
+ "[?(@.fileset)]");
|
+ "[?(@.fileset)]");
|
||||||
req.addAll(upload(content,storage));
|
req.addAll(content.stream().
|
||||||
|
filter(p -> p instanceof WorkspaceContent)
|
||||||
|
.map(p -> new TempFile(null, ((WorkspaceContent) p).getLink(), ((WorkspaceContent) p).getName()))
|
||||||
|
.collect(Collectors.toList()));
|
||||||
project = client.registerFileSet(project.getId(),req.getTheRequest());
|
project = client.registerFileSet(project.getId(),req.getTheRequest());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -239,7 +246,10 @@ public class ExportConcessioniAsProjects {
|
||||||
req = FileSets.build("$." + ProfiledConcessione.POSIZIONAMENTO_SCAVO, "fileset",
|
req = FileSets.build("$." + ProfiledConcessione.POSIZIONAMENTO_SCAVO, "fileset",
|
||||||
"$." + ProfiledConcessione.POSIZIONAMENTO_SCAVO + "." + Field.CHILDREN
|
"$." + ProfiledConcessione.POSIZIONAMENTO_SCAVO + "." + Field.CHILDREN
|
||||||
+ "[?(@.fileset)]");
|
+ "[?(@.fileset)]");
|
||||||
req.addAll(upload(content,storage));
|
req.addAll(content.stream().
|
||||||
|
filter(p -> p instanceof WorkspaceContent)
|
||||||
|
.map(p -> new TempFile(null, ((WorkspaceContent) p).getLink(), ((WorkspaceContent) p).getName()))
|
||||||
|
.collect(Collectors.toList()));
|
||||||
project = client.registerFileSet(project.getId(),req.getTheRequest());
|
project = client.registerFileSet(project.getId(),req.getTheRequest());
|
||||||
}
|
}
|
||||||
// upload fileset
|
// upload fileset
|
||||||
|
@ -277,7 +287,10 @@ public class ExportConcessioniAsProjects {
|
||||||
req = FileSets.build("$." + ProfiledConcessione.PIANTE_FINE_SCAVO+"["+i+"]", "fileset",
|
req = FileSets.build("$." + ProfiledConcessione.PIANTE_FINE_SCAVO+"["+i+"]", "fileset",
|
||||||
"$." + ProfiledConcessione.PIANTE_FINE_SCAVO + "." + Field.CHILDREN
|
"$." + ProfiledConcessione.PIANTE_FINE_SCAVO + "." + Field.CHILDREN
|
||||||
+ "[?(@.fileset)]");
|
+ "[?(@.fileset)]");
|
||||||
req.addAll(upload(content,storage));
|
req.addAll(content.stream().
|
||||||
|
filter(p -> p instanceof WorkspaceContent)
|
||||||
|
.map(p -> new TempFile(null, ((WorkspaceContent) p).getLink(), ((WorkspaceContent) p).getName()))
|
||||||
|
.collect(Collectors.toList()));
|
||||||
project = client.registerFileSet(project.getId(),req.getTheRequest());
|
project = client.registerFileSet(project.getId(),req.getTheRequest());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue