BugFixing
This commit is contained in:
parent
e0daa09d6f
commit
10c450fb2f
|
@ -106,6 +106,13 @@
|
|||
<artifactId>reflections</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--TEST-->
|
||||
<dependency>
|
||||
<groupId>org.gcube.application.cms</groupId>
|
||||
<artifactId>cms-test-commons</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -136,7 +136,7 @@ public class SimpleLifeCycleManager extends AbstractLifeCycleManager implements
|
|||
// dematerialize all
|
||||
blockNonDraft(report);
|
||||
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);
|
||||
for(MaterializationPlugin mat : getMaterializers(report.getTheRequest()))
|
||||
report = deMaterialize(report,mat,new Document("fileSetPath",s));
|
||||
|
|
|
@ -5,6 +5,7 @@ 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.faults.InvalidRequestException;
|
||||
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.rest.QueryRequest;
|
||||
|
@ -181,19 +182,23 @@ public class DefaultDocumentsClient<T extends Project> implements Projects<T> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public T registerFileSet(String id, RegisterFileSetRequest req) throws RemoteException {
|
||||
public T registerFileSet(String id, RegisterFileSetRequest req) throws RemoteException, InvalidRequestException {
|
||||
try {
|
||||
log.debug("Registering FileSet on {} (class {}, useCaseDescriptor {}) with request {} ",
|
||||
id, getManagedClass(),profileID, req);
|
||||
id, getManagedClass(), profileID, req);
|
||||
req.validate();
|
||||
Call<WebTarget, T> call = endpoint -> {
|
||||
return ResponseCommons.check(endpoint.path(profileID).path(InterfaceConstants.Methods.REGISTER_FILES_PATH)
|
||||
.path(id).request(MediaType.APPLICATION_JSON).
|
||||
post(Entity.entity(req, MediaType.APPLICATION_JSON)),getManagedClass());
|
||||
post(Entity.entity(req, MediaType.APPLICATION_JSON)), getManagedClass());
|
||||
};
|
||||
T toReturn = delegate.make(call);
|
||||
log.info("Registered FileSet on {} [useCaseDescriptor {}, class {}] with {}",
|
||||
id,profileID,getManagedClass(),req);
|
||||
id, profileID, getManagedClass(), req);
|
||||
return toReturn;
|
||||
}catch (InvalidRequestException e){
|
||||
log.error("Invalid Request ",e);
|
||||
throw e;
|
||||
}catch(RemoteException e){
|
||||
log.error("Unexpected error ",e);
|
||||
throw e;
|
||||
|
|
|
@ -5,6 +5,7 @@ import org.bson.Document;
|
|||
import org.gcube.application.cms.tests.TestDocuments;
|
||||
import org.gcube.application.cms.tests.model.concessioni.TestConcessioniModel;
|
||||
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.rest.RegisterFileSetRequest;
|
||||
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
|
||||
|
@ -35,7 +36,7 @@ public abstract class GenericUseCases extends BasicVreTests{
|
|||
}
|
||||
|
||||
@Test
|
||||
public void createNew () throws RemoteException, FileNotFoundException, JsonProcessingException {
|
||||
public void createNew () throws RemoteException, FileNotFoundException, JsonProcessingException, InvalidRequestException {
|
||||
String profileID=getUCID();
|
||||
|
||||
Document myDocument= new Document();
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.gcube.application.geoportal.common.rest;
|
||||
|
||||
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.configuration.Configuration;
|
||||
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;
|
||||
|
||||
//FileSets
|
||||
public P registerFileSet(String id, RegisterFileSetRequest req) throws RemoteException;
|
||||
public P registerFileSet(String id, RegisterFileSetRequest req) throws RemoteException, InvalidRequestException;
|
||||
//FileSets
|
||||
public P deleteFileSet(String id, String path, Boolean force) throws RemoteException;
|
||||
}
|
||||
|
|
|
@ -46,6 +46,9 @@ public class JSONPathTests {
|
|||
// 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>() {
|
||||
@Override
|
||||
protected Project run() throws Exception, WebApplicationException {
|
||||
log.info("Registering {} file(s) for Project ({}, ID {}) with {}",
|
||||
request.getStreams().size(),
|
||||
log.info("UCD {} : Project {} Registering Fileset. Request is {}",
|
||||
manager.getUseCaseDescriptor().getId(),
|
||||
id,request);
|
||||
request.validate();
|
||||
|
|
|
@ -26,6 +26,7 @@ import java.util.concurrent.Executors;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.gcube.application.geoportal.client.plugins.GeoportalAbstractPlugin.projects;
|
||||
|
||||
|
@ -62,7 +63,7 @@ public class ExportConcessioniAsProjects {
|
|||
|
||||
TokenSetter.set(targetContext);
|
||||
|
||||
StorageUtils storage = new StorageUtils();
|
||||
// StorageUtils storage = new StorageUtils();
|
||||
|
||||
AtomicLong count = new AtomicLong(0);
|
||||
AtomicLong warnCount = new AtomicLong(0);
|
||||
|
@ -76,7 +77,7 @@ public class ExportConcessioniAsProjects {
|
|||
service.submit(new Runnable(){
|
||||
@Override
|
||||
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 {
|
||||
ArrayList toReturn = new ArrayList();
|
||||
for (PersistedContent content : contents)
|
||||
if (content instanceof WorkspaceContent) {
|
||||
WorkspaceContent wc = (WorkspaceContent) content;
|
||||
toReturn.add(storage.putOntoStorage(new URL(wc.getLink()).openStream(), wc.getName()));
|
||||
}
|
||||
return toReturn;
|
||||
}
|
||||
// public static List<TempFile> upload(List<PersistedContent> contents,StorageUtils storage) throws IOException {
|
||||
// ArrayList toReturn = new ArrayList();
|
||||
// for (PersistedContent content : contents)
|
||||
// if (content instanceof WorkspaceContent) {
|
||||
// WorkspaceContent wc = (WorkspaceContent) content;
|
||||
// toReturn.add(storage.putOntoStorage(new URL(wc.getLink()).openStream(), wc.getName()));
|
||||
// }
|
||||
// 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 {
|
||||
long startTime = System.currentTimeMillis();
|
||||
FileSets.RequestBuilder req=null;
|
||||
|
@ -150,7 +151,10 @@ public class ExportConcessioniAsProjects {
|
|||
req = FileSets.build("$." + ProfiledConcessione.RELAZIONE_SCAVO, "fileset",
|
||||
"$." + ProfiledConcessione.RELAZIONE_SCAVO + "." + Field.CHILDREN
|
||||
+ "[?(@.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());
|
||||
}
|
||||
// upload fileset
|
||||
|
@ -208,7 +212,10 @@ public class ExportConcessioniAsProjects {
|
|||
req = FileSets.build("$." + ProfiledConcessione.IMMAGINI_RAPPRESENTATIVE+"["+i+"]", "fileset",
|
||||
"$." + ProfiledConcessione.IMMAGINI_RAPPRESENTATIVE + "." + Field.CHILDREN
|
||||
+ "[?(@.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());
|
||||
}
|
||||
}
|
||||
|
@ -239,7 +246,10 @@ public class ExportConcessioniAsProjects {
|
|||
req = FileSets.build("$." + ProfiledConcessione.POSIZIONAMENTO_SCAVO, "fileset",
|
||||
"$." + ProfiledConcessione.POSIZIONAMENTO_SCAVO + "." + Field.CHILDREN
|
||||
+ "[?(@.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());
|
||||
}
|
||||
// upload fileset
|
||||
|
@ -277,7 +287,10 @@ public class ExportConcessioniAsProjects {
|
|||
req = FileSets.build("$." + ProfiledConcessione.PIANTE_FINE_SCAVO+"["+i+"]", "fileset",
|
||||
"$." + ProfiledConcessione.PIANTE_FINE_SCAVO + "." + Field.CHILDREN
|
||||
+ "[?(@.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());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue