This commit is contained in:
Fabio Sinibaldi 2021-11-12 16:41:25 +01:00
parent 41af4e3bc9
commit fbda3ce866
20 changed files with 230 additions and 90 deletions

View File

@ -4,6 +4,7 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import org.gcube.application.cms.tests.model.TestModel; import org.gcube.application.cms.tests.model.TestModel;
import org.gcube.application.geoportal.common.model.legacy.AccessPolicy;
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.profile.Profile; import org.gcube.application.geoportal.common.model.profile.Profile;
import org.gcube.application.geoportal.common.utils.Files; import org.gcube.application.geoportal.common.utils.Files;
@ -17,6 +18,8 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import static org.junit.Assert.assertEquals;
public class SerializationTest { public class SerializationTest {
@ -46,8 +49,14 @@ public class SerializationTest {
@Test @Test
public void readConcessione() throws JsonProcessingException, IOException { public void readConcessione() throws JsonProcessingException, IOException {
Concessione concessione=mapper.readerFor(Concessione.class).readValue(new File(TestModel.getBaseFolder(),"Concessione.json")); Concessione concessione=mapper.readerFor(Concessione.class).readValue(new File(TestModel.getBaseFolder(),"Concessione.json"));
System.out.println("Concessione is "+concessione.toString()); System.out.println("Concessione is "+concessione.toString());
concessione.getRelazioneScavo().setPolicy(AccessPolicy.EMBARGOED);
assertEquals(AccessPolicy.EMBARGOED,concessione.getRelazioneScavo().getPolicy());
concessione=mapper.readerFor(Concessione.class).readValue(mapper.writeValueAsString(concessione));
assertEquals(AccessPolicy.EMBARGOED,concessione.getRelazioneScavo().getPolicy());
} }
@Test @Test

View File

@ -7,6 +7,7 @@ import org.gcube.application.geoportal.common.rest.TempFile;
public interface ConcessioniManagerI extends MongoConcessioni{ public interface ConcessioniManagerI extends MongoConcessioni{
public Concessione getCurrent();
public Concessione addImmagineRappresentativa(UploadedImage toAdd,TempFile f) throws Exception; public Concessione addImmagineRappresentativa(UploadedImage toAdd,TempFile f) throws Exception;
public Concessione addPiantaFineScavo(LayerConcessione toAdd,TempFile...files)throws Exception; public Concessione addPiantaFineScavo(LayerConcessione toAdd,TempFile...files)throws Exception;
public Concessione setPosizionamento(LayerConcessione toSet,TempFile...files)throws Exception; public Concessione setPosizionamento(LayerConcessione toSet,TempFile...files)throws Exception;

View File

@ -4,6 +4,7 @@ import java.util.ArrayList;
import javax.ws.rs.client.WebTarget; import javax.ws.rs.client.WebTarget;
import lombok.Getter;
import org.gcube.application.geoportal.client.DefaultMongoConcessioni; import org.gcube.application.geoportal.client.DefaultMongoConcessioni;
import org.gcube.application.geoportal.common.model.legacy.*; import org.gcube.application.geoportal.common.model.legacy.*;
import org.gcube.application.geoportal.common.utils.FileSets; import org.gcube.application.geoportal.common.utils.FileSets;
@ -21,97 +22,98 @@ public class StatefulMongoConcessioni extends DefaultMongoConcessioni implements
super(delegate); super(delegate);
} }
private Concessione currentC=null; @Getter
private Concessione current =null;
private StorageUtils storage=new StorageUtils(); private StorageUtils storage=new StorageUtils();
// Override methods to handle state // Override methods to handle state
@Override @Override
public Concessione createNew(Concessione c) throws Exception { public Concessione createNew(Concessione c) throws Exception {
currentC=super.createNew(c); current =super.createNew(c);
return currentC; return current;
} }
@Override @Override
public Concessione getById(String id) throws Exception { public Concessione getById(String id) throws Exception {
currentC= super.getById(id); current = super.getById(id);
return currentC; return current;
} }
@Override @Override
public Concessione publish() throws Exception { public Concessione publish() throws Exception {
if(currentC==null) throw new Exception("Invalid operation : current Concessione is null."); if(current ==null) throw new Exception("Invalid operation : current Concessione is null.");
currentC=super.publish(currentC.getMongo_id()); current =super.publish(current.getMongo_id());
return currentC; return current;
} }
@Override @Override
public void delete() throws Exception { public void delete() throws Exception {
if(currentC==null) throw new Exception("Invalid operation : current Concessione is null."); if(current ==null) throw new Exception("Invalid operation : current Concessione is null.");
super.deleteById(currentC.getMongo_id()); super.deleteById(current.getMongo_id());
currentC=null; current =null;
} }
@Override @Override
public Concessione addImmagineRappresentativa(UploadedImage toAdd, TempFile f) throws Exception { public Concessione addImmagineRappresentativa(UploadedImage toAdd, TempFile f) throws Exception {
if(currentC==null) throw new Exception("Invalid operation : current Concessione is null."); if(current ==null) throw new Exception("Invalid operation : current Concessione is null.");
if(currentC.getImmaginiRappresentative()==null) currentC.setImmaginiRappresentative(new ArrayList<UploadedImage>()); if(current.getImmaginiRappresentative()==null) current.setImmaginiRappresentative(new ArrayList<UploadedImage>());
currentC.getImmaginiRappresentative().add(toAdd); current.getImmaginiRappresentative().add(toAdd);
currentC=replace(currentC); current =replace(current);
currentC=super.registerFileSet(currentC.getMongo_id(), current =super.registerFileSet(current.getMongo_id(),
FileSets.build(Paths.imgByIndex(currentC.getImmaginiRappresentative().size()-1),f).getTheRequest()); FileSets.build(Paths.imgByIndex(current.getImmaginiRappresentative().size()-1),f).getTheRequest());
return currentC; return current;
} }
@Override @Override
public Concessione addPiantaFineScavo(LayerConcessione toAdd, TempFile... files) throws Exception { public Concessione addPiantaFineScavo(LayerConcessione toAdd, TempFile... files) throws Exception {
if(currentC==null) throw new Exception("Invalid operation : current Concessione is null."); if(current ==null) throw new Exception("Invalid operation : current Concessione is null.");
if(currentC.getPianteFineScavo()==null) currentC.setPianteFineScavo(new ArrayList<>()); if(current.getPianteFineScavo()==null) current.setPianteFineScavo(new ArrayList<>());
currentC.getPianteFineScavo().add(toAdd); current.getPianteFineScavo().add(toAdd);
currentC=replace(currentC); current =replace(current);
currentC=super.registerFileSet(currentC.getMongo_id(), current =super.registerFileSet(current.getMongo_id(),
FileSets.build(Paths.piantaByIndex(currentC.getPianteFineScavo().size()-1),files).getTheRequest()); FileSets.build(Paths.piantaByIndex(current.getPianteFineScavo().size()-1),files).getTheRequest());
return currentC; return current;
} }
@Override @Override
public Concessione setPosizionamento(LayerConcessione toSet, TempFile... files) throws Exception { public Concessione setPosizionamento(LayerConcessione toSet, TempFile... files) throws Exception {
if(currentC==null) throw new Exception("Invalid operation : current Concessione is null."); if(current ==null) throw new Exception("Invalid operation : current Concessione is null.");
currentC.setPosizionamentoScavo(toSet); current.setPosizionamentoScavo(toSet);
currentC=replace(currentC); current =replace(current);
currentC=super.registerFileSet(currentC.getMongo_id(), current =super.registerFileSet(current.getMongo_id(),
FileSets.build(Paths.POSIZIONAMENTO,files).getTheRequest()); FileSets.build(Paths.POSIZIONAMENTO,files).getTheRequest());
return currentC; return current;
} }
@Override @Override
public Concessione setRelazioneScavo(RelazioneScavo toSet, TempFile... files) throws Exception { public Concessione setRelazioneScavo(RelazioneScavo toSet, TempFile... files) throws Exception {
if(currentC==null) throw new Exception("Invalid operation : current Concessione is null."); if(current ==null) throw new Exception("Invalid operation : current Concessione is null.");
currentC.setRelazioneScavo(toSet); current.setRelazioneScavo(toSet);
currentC=replace(currentC); current =replace(current);
currentC=super.registerFileSet(currentC.getMongo_id(), current =super.registerFileSet(current.getMongo_id(),
FileSets.build(Paths.RELAZIONE,files).getTheRequest()); FileSets.build(Paths.RELAZIONE,files).getTheRequest());
return currentC; return current;
} }
@Override @Override
public Concessione setAbstractRelazioneScavo(AbstractRelazione toSet, TempFile... files) throws Exception { public Concessione setAbstractRelazioneScavo(AbstractRelazione toSet, TempFile... files) throws Exception {
if(currentC==null) throw new Exception("Invalid operation : current Concessione is null."); if(current ==null) throw new Exception("Invalid operation : current Concessione is null.");
currentC.setAbstractRelazione(toSet); current.setAbstractRelazione(toSet);
currentC=replace(currentC); current =replace(current);
currentC=super.registerFileSet(currentC.getMongo_id(), current =super.registerFileSet(current.getMongo_id(),
FileSets.build(Paths.ABSTRACT_RELAZIONE,files).getTheRequest()); FileSets.build(Paths.ABSTRACT_RELAZIONE,files).getTheRequest());
return currentC; return current;
} }

View File

@ -7,8 +7,9 @@ public class BasicVreTests {
@BeforeClass @BeforeClass
public static void setScope(){ public static void setScope(){
// TokenSetter.set("/gcube/devNext/NextNext"); // TokenSetter.set("/pred4s/preprod/preVRE");
TokenSetter.set("/gcube/devsec/devVRE"); // TokenSetter.set("/d4science.research-infrastructures.eu/D4OS/GeoNA-Prototype");
TokenSetter.set("/gcube/devsec/devVRE");
} }

View File

@ -10,10 +10,7 @@ import java.io.FileNotFoundException;
import org.gcube.application.cms.tests.model.TestModel; import org.gcube.application.cms.tests.model.TestModel;
import org.gcube.application.geoportal.client.legacy.ConcessioniManagerI; import org.gcube.application.geoportal.client.legacy.ConcessioniManagerI;
import org.gcube.application.geoportal.client.utils.Serialization; import org.gcube.application.geoportal.client.utils.Serialization;
import org.gcube.application.geoportal.common.model.legacy.Concessione; import org.gcube.application.geoportal.common.model.legacy.*;
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.UploadedImage;
import org.gcube.application.geoportal.common.model.legacy.report.ValidationReport.ValidationStatus; import org.gcube.application.geoportal.common.model.legacy.report.ValidationReport.ValidationStatus;
import org.gcube.application.geoportal.common.rest.TempFile; import org.gcube.application.geoportal.common.rest.TempFile;
import org.gcube.application.geoportal.common.utils.Files; import org.gcube.application.geoportal.common.utils.Files;
@ -35,6 +32,9 @@ public class StatefulClientTests extends BasicVreTests{
toRegister.setNome("Mock module"); toRegister.setNome("Mock module");
manager.createNew(toRegister); manager.createNew(toRegister);
Concessione source=TestModel.prepareConcessione(); Concessione source=TestModel.prepareConcessione();
@ -42,7 +42,7 @@ public class StatefulClientTests extends BasicVreTests{
// TEMP Files are hosted in INFRASTRUCTURE's VOLATILE AREA // TEMP Files are hosted in INFRASTRUCTURE's VOLATILE AREA
TempFile toUpload=storage.putOntoStorage( TempFile toUpload=storage.putOntoStorage(
new File(TestModel.getBaseFolder(),"immagine.png"), "immagine.png"); new File(TestModel.getBaseFolder(),"immagine1.png"), "immagine.png");
manager.addImmagineRappresentativa(toRegisterImg, toUpload); manager.addImmagineRappresentativa(toRegisterImg, toUpload);
@ -50,14 +50,17 @@ public class StatefulClientTests extends BasicVreTests{
//Alternative Method //Alternative Method
InputStreamDescriptor isDesc= InputStreamDescriptor isDesc=
new InputStreamDescriptor(new FileInputStream(new File(TestModel.getBaseFolder(), new InputStreamDescriptor(new FileInputStream(new File(TestModel.getBaseFolder(),
"immagine.png")), "San Mauro_drone totale.JPG"); "immagine1.png")), "San Mauro_drone totale.JPG");
manager.addImmagineRappresentativa(toRegisterImg, isDesc); manager.addImmagineRappresentativa(toRegisterImg, isDesc);
source.getRelazioneScavo().setPolicy(AccessPolicy.EMBARGOED);
assertEquals(AccessPolicy.EMBARGOED,source.getRelazioneScavo().getPolicy());
//Relazione //Relazione
manager.setRelazioneScavo(source.getRelazioneScavo(), manager.setRelazioneScavo(source.getRelazioneScavo(),
storage.putOntoStorage(new File(TestModel.getBaseFolder(),"relazione.pdf"), "relazione_it.pdf"), storage.putOntoStorage(new File(TestModel.getBaseFolder(),"relazione.pdf"), "relazione_it.pdf"),
storage.putOntoStorage(new File(TestModel.getBaseFolder(),"relazione.pdf"), "relazione_en.pdf")); storage.putOntoStorage(new File(TestModel.getBaseFolder(),"relazione.pdf"), "relazione_en.pdf"));
assertEquals(AccessPolicy.EMBARGOED,manager.getCurrent().getRelazioneScavo().getPolicy());
//Abstract //Abstract
manager.setAbstractRelazioneScavo( manager.setAbstractRelazioneScavo(
@ -66,6 +69,7 @@ public class StatefulClientTests extends BasicVreTests{
storage.putOntoStorage(new File(TestModel.getBaseFolder(),"relazione.pdf"), "abstract_relazione_en.pdf")); storage.putOntoStorage(new File(TestModel.getBaseFolder(),"relazione.pdf"), "abstract_relazione_en.pdf"));
// Posizionamento scavo // Posizionamento scavo
manager.setPosizionamento(source.getPosizionamentoScavo(), manager.setPosizionamento(source.getPosizionamentoScavo(),
@ -78,8 +82,12 @@ public class StatefulClientTests extends BasicVreTests{
new File(TestModel.getBaseFolder(),"pianta.shp"),"pianta.shp")); new File(TestModel.getBaseFolder(),"pianta.shp"),"pianta.shp"));
// new File("/Users/fabioisti/Documents/invio_08_05/Montalto di Castro (VT)_Vulci_Indagini non invasive_Doc. paragr._Va/CONSEGNA_WGS84") // new File("/Users/fabioisti/Documents/invio_08_05/Montalto di Castro (VT)_Vulci_Indagini non invasive_Doc. paragr._Va/CONSEGNA_WGS84")
// .listFiles((file,name)->{return name.startsWith("Mag_anomalies_WGS84");}))); // .listFiles((file,name)->{return name.startsWith("Mag_anomalies_WGS84");})));
return manager.publish();
Concessione toReturn=manager.publish();
assertEquals(AccessPolicy.EMBARGOED,toReturn.getRelazioneScavo().getPolicy());
return toReturn;
} }

View File

@ -15,6 +15,7 @@ import org.gcube.application.cms.tests.model.TestFilters;
import org.gcube.application.cms.tests.model.TestModel; import org.gcube.application.cms.tests.model.TestModel;
import org.gcube.application.cms.tests.model.TestQueries; import org.gcube.application.cms.tests.model.TestQueries;
import org.gcube.application.geoportal.client.utils.Queries; import org.gcube.application.geoportal.client.utils.Queries;
import org.gcube.application.geoportal.client.utils.Serialization;
import org.gcube.application.geoportal.common.model.legacy.*; import org.gcube.application.geoportal.common.model.legacy.*;
import org.gcube.application.geoportal.common.model.legacy.Concessione.Paths; import org.gcube.application.geoportal.common.model.legacy.Concessione.Paths;
import org.gcube.application.geoportal.common.model.legacy.report.ValidationReport.ValidationStatus; import org.gcube.application.geoportal.common.model.legacy.report.ValidationReport.ValidationStatus;
@ -130,7 +131,7 @@ public class StatelessClientTests extends BasicVreTests{
@Test @Test
public void testPublsh() throws Exception { public void testPublish() throws Exception {
Concessione c=prepare(); Concessione c=prepare();
assertTrue(c.getReport().getStatus().equals(ValidationStatus.PASSED)); assertTrue(c.getReport().getStatus().equals(ValidationStatus.PASSED));
@ -174,31 +175,43 @@ public class StatelessClientTests extends BasicVreTests{
Concessione c= client.createNew(TestModel.prepareConcessione(1,numImgs)); Concessione c= client.createNew(TestModel.prepareConcessione(1,numImgs));
StorageUtils storage = new StorageUtils(); StorageUtils storage = new StorageUtils();
c.getRelazioneScavo().setPolicy(AccessPolicy.EMBARGOED);
String mongoId=c.getMongo_id(); String mongoId=c.getMongo_id();
c=client.update(mongoId, Serialization.write(c));
client.registerFileSet(mongoId, assertEquals(AccessPolicy.EMBARGOED,c.getRelazioneScavo().getPolicy());
c=client.registerFileSet(mongoId,
FileSets.prepareRequest(storage,Paths.RELAZIONE,new File(TestModel.getBaseFolder(),"relazione.pdf"))); FileSets.prepareRequest(storage,Paths.RELAZIONE,new File(TestModel.getBaseFolder(),"relazione.pdf")));
client.registerFileSet(mongoId, assertEquals(AccessPolicy.EMBARGOED,c.getRelazioneScavo().getPolicy());
FileSets.prepareRequest(storage,Paths.RELAZIONE,new File(TestModel.getBaseFolder(),"relazione.pdf")));
c=client.registerFileSet(mongoId,
FileSets.prepareRequest(storage,Paths.ABSTRACT_RELAZIONE,new File(TestModel.getBaseFolder(),"relazione.pdf")));
assertEquals(AccessPolicy.EMBARGOED,c.getRelazioneScavo().getPolicy());
for(int i=0;i<numImgs;i++) for(int i=0;i<numImgs;i++)
client.registerFileSet(mongoId, c=client.registerFileSet(mongoId,
FileSets.build(Paths.imgByIndex(i)). FileSets.build(Paths.imgByIndex(i)).
add(storage.putOntoStorage(new File(TestModel.getBaseFolder(),"immagine"+(i+1)+".png"), add(storage.putOntoStorage(new File(TestModel.getBaseFolder(),"immagine"+(i+1)+".png"),
i+"San Mauro_drone totale.JPG")).getTheRequest()); i+"San Mauro_drone totale.JPG")).getTheRequest());
assertEquals(AccessPolicy.EMBARGOED,c.getRelazioneScavo().getPolicy());
client.registerFileSet(mongoId, c=client.registerFileSet(mongoId,
FileSets.prepareRequest(storage,Paths.POSIZIONAMENTO,new File(TestModel.getBaseFolder(),"pos.shp"))); FileSets.prepareRequest(storage,Paths.POSIZIONAMENTO,new File(TestModel.getBaseFolder(),"pos.shp")));
client.registerFileSet(mongoId, assertEquals(AccessPolicy.EMBARGOED,c.getRelazioneScavo().getPolicy());
c=client.registerFileSet(mongoId,
FileSets.prepareRequest(storage,Paths.piantaByIndex(0),new File(TestModel.getBaseFolder(),"pianta.shp"))); FileSets.prepareRequest(storage,Paths.piantaByIndex(0),new File(TestModel.getBaseFolder(),"pianta.shp")));
assertEquals(AccessPolicy.EMBARGOED,c.getRelazioneScavo().getPolicy());
c=client.publish(mongoId); c=client.publish(mongoId);
assertEquals(AccessPolicy.EMBARGOED,c.getRelazioneScavo().getPolicy());
return c; return c;
} }

View File

@ -37,4 +37,7 @@ public class DefaultsTests {
c.setDefaults(); c.setDefaults();
assertEquals(AccessPolicy.EMBARGOED,c.getRelazioneScavo().getPolicy()); assertEquals(AccessPolicy.EMBARGOED,c.getRelazioneScavo().getPolicy());
} }
} }

View File

@ -82,14 +82,19 @@ public class ConcessioniMongoManager extends MongoManager{
public Concessione registerNew(Concessione toRegister) throws IOException { public Concessione registerNew(Concessione toRegister) throws IOException {
log.trace("Registering {} ",toRegister); log.trace("Going to register {} ",toRegister);
toRegister.setDefaults(); toRegister.setDefaults();
log.trace("Concessione with defaults is {}",toRegister);
ObjectId id=insert(asDocument(toRegister), collectionName); ObjectId id=insert(asDocument(toRegister), collectionName);
log.trace("Obtained id {}",id);
Concessione toReturn=asConcessione(getById(id,collectionName)); Concessione toReturn=asConcessione(getById(id,collectionName));
toReturn.setMongo_id(asString(id)); toReturn.setMongo_id(asString(id));
return asConcessione(replace(asDocument(toReturn),collectionName));
toReturn = asConcessione(replace(asDocument(toReturn),collectionName));
log.debug("Registered {} ",toReturn);
return toReturn;
} }
public Concessione replace(Concessione toRegister) throws IOException { public Concessione replace(Concessione toRegister) throws IOException {
@ -98,14 +103,14 @@ public class ConcessioniMongoManager extends MongoManager{
return asConcessione(replace(asDocument(toRegister),collectionName)); return asConcessione(replace(asDocument(toRegister),collectionName));
} }
public Concessione update(String id,String json) throws IOException { /* public Concessione update(String id,String json) throws IOException {
log.trace("Updating id {} with {} ",id,json); log.trace("Updating id {} with {} ",id,json);
Concessione toReturn=asConcessione(update(asId(id),asDoc(json),collectionName)); Concessione toReturn=asConcessione(update(asId(id),asDoc(json),collectionName));
log.debug("Refreshing defaults.."); log.debug("Refreshing defaults..");
toReturn.setDefaults(); toReturn.setDefaults();
return asConcessione(replace(asDocument(toReturn),collectionName)); return asConcessione(replace(asDocument(toReturn),collectionName));
} }
*/
public Iterable<Concessione> list(){ public Iterable<Concessione> list(){

View File

@ -0,0 +1,40 @@
package org.gcube.application.geoportal.service.engine.mongo;
import org.gcube.application.geoportal.common.model.rest.QueryRequest;
public interface MongoManagerI<T> {
// create
public T registerNew(T toRegister);
// update
public T update(String id,T toSet);
// delete
public void delete(String id);
// get By ID
public T getByID(String id);
// query
public Iterable<T> query(QueryRequest request);
// materialize
public T materialize(String id);
// dematerialize
public T dematerialize(String id);
// index
public T index(String id);
// deIndex
public T deIndex(String id);
}

View File

@ -19,8 +19,9 @@ public class BasicServiceTestUnit extends JerseyTest {
return new GeoPortalService(); return new GeoPortalService();
} }
protected static String scope="/gcube/devsec/devVRE"; // protected static String scope="/gcube/devsec/devVRE";
// protected static String scope="/pred4s/preprod/preVRE";
protected static String scope="/d4science.research-infrastructures.eu/D4OS/GeoNA-Prototype";
@BeforeClass @BeforeClass
public static void init() { public static void init() {

View File

@ -4,6 +4,7 @@ import org.gcube.application.cms.tests.TokenSetter;
import org.gcube.application.cms.tests.model.TestFilters; import org.gcube.application.cms.tests.model.TestFilters;
import org.gcube.application.cms.tests.model.TestQueries; import org.gcube.application.cms.tests.model.TestQueries;
import org.gcube.application.cms.tests.model.TestModel; import org.gcube.application.cms.tests.model.TestModel;
import org.gcube.application.geoportal.common.model.legacy.AccessPolicy;
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.Concessione.Paths; import org.gcube.application.geoportal.common.model.legacy.Concessione.Paths;
import org.gcube.application.geoportal.common.model.legacy.LayerConcessione; import org.gcube.application.geoportal.common.model.legacy.LayerConcessione;
@ -300,8 +301,7 @@ public class ConcessioniOverMongoTest extends BasicServiceTestUnit{
assertNotNull(published.getReport()); assertNotNull(published.getReport());
assertEquals(ValidationStatus.PASSED,published.getReport().getStatus()); assertEquals(ValidationStatus.PASSED,published.getReport().getStatus());
assertEquals(published.getImmaginiRappresentative().size(),2);
assertEquals(published.getPianteFineScavo().size(),1);
assertNotNull(published.getPosizionamentoScavo().getWmsLink()); assertNotNull(published.getPosizionamentoScavo().getWmsLink());
for(LayerConcessione l : published.getPianteFineScavo()) { for(LayerConcessione l : published.getPianteFineScavo()) {
assertNotNull(l.getWmsLink()); assertNotNull(l.getWmsLink());
@ -317,6 +317,9 @@ public class ConcessioniOverMongoTest extends BasicServiceTestUnit{
Concessione c=TestModel.prepareConcessione(layers.size(),1); Concessione c=TestModel.prepareConcessione(layers.size(),1);
c.getRelazioneScavo().setPolicy(AccessPolicy.EMBARGOED);
assertEquals(AccessPolicy.EMBARGOED,c.getRelazioneScavo().getPolicy());
c.setNome("Concessione : publish test "); c.setNome("Concessione : publish test ");
StorageUtils storage=new StorageUtils(); StorageUtils storage=new StorageUtils();
@ -324,8 +327,12 @@ public class ConcessioniOverMongoTest extends BasicServiceTestUnit{
// Register new // Register new
c=register(target,c); c=register(target,c);
assertEquals(AccessPolicy.EMBARGOED,c.getRelazioneScavo().getPolicy());
//Upload files //Upload files
c=upload(storage,target,c.getMongo_id(),Paths.RELAZIONE,"relazione.pdf"); c=upload(storage,target,c.getMongo_id(),Paths.RELAZIONE,"relazione.pdf");
assertEquals(AccessPolicy.EMBARGOED,c.getRelazioneScavo().getPolicy());
c=upload(storage,target,c.getMongo_id(),Paths.ABSTRACT_RELAZIONE,"relazione.pdf"); c=upload(storage,target,c.getMongo_id(),Paths.ABSTRACT_RELAZIONE,"relazione.pdf");
@ -333,7 +340,7 @@ public class ConcessioniOverMongoTest extends BasicServiceTestUnit{
c=upload(storage,target,c.getMongo_id(),Paths.POSIZIONAMENTO, c=upload(storage,target,c.getMongo_id(),Paths.POSIZIONAMENTO,
// TestModel.getBaseFolder().list((file,name)->{return name.startsWith("pianta.shp");})); // TestModel.getBaseFolder().list((file,name)->{return name.startsWith("pianta.shp");}));
layers.get(keys[0]).toArray(new File[0])); layers.get(keys[0]).toArray(new File[0]));
assertEquals(AccessPolicy.EMBARGOED,c.getRelazioneScavo().getPolicy());
// Clash on workspaces // Clash on workspaces
for(int i=0;i<c.getPianteFineScavo().size();i++) { for(int i=0;i<c.getPianteFineScavo().size();i++) {
@ -345,14 +352,18 @@ public class ConcessioniOverMongoTest extends BasicServiceTestUnit{
// TestModel.getBaseFolder().list((file,name)->{return name.startsWith("pianta.shp");})); // TestModel.getBaseFolder().list((file,name)->{return name.startsWith("pianta.shp");}));
layers.get(key).toArray(new File[0])); layers.get(key).toArray(new File[0]));
} }
assertEquals(AccessPolicy.EMBARGOED,c.getRelazioneScavo().getPolicy());
// Immagini // Immagini
for (int i = 0; i <c.getImmaginiRappresentative().size() ; i++) { for (int i = 0; i <c.getImmaginiRappresentative().size() ; i++) {
c=upload(storage,target,c.getMongo_id(),Paths.imgByIndex(0),"immagine"+(i+1)+".png"); c=upload(storage,target,c.getMongo_id(),Paths.imgByIndex(0),"immagine"+(i+1)+".png");
} }
assertEquals(AccessPolicy.EMBARGOED,c.getRelazioneScavo().getPolicy());
return publish(target, c.getMongo_id()); Concessione toReturn= publish(target, c.getMongo_id());
assertEquals(AccessPolicy.EMBARGOED,toReturn.getRelazioneScavo().getPolicy());
return toReturn;
} }
public static long count(Iterator<?> iterator){ public static long count(Iterator<?> iterator){

View File

@ -7,13 +7,18 @@ import org.gcube.common.storagehub.client.dsl.StorageHubClient;
import org.gcube.common.storagehub.model.exceptions.StorageHubException; import org.gcube.common.storagehub.model.exceptions.StorageHubException;
import org.gcube.common.storagehub.model.items.*; import org.gcube.common.storagehub.model.items.*;
import java.text.CharacterIterator;
import java.text.StringCharacterIterator;
import java.util.List;
public class DescribeWSFolder { public class DescribeWSFolder {
static StorageHubClient shc =null; static StorageHubClient shc =null;
public static void main(String[] args) throws StorageHubException { public static void main(String[] args) throws StorageHubException {
String context="/gcube/devsec/devVRE"; // String context="/gcube/devsec/devVRE";
String context="/d4science.research-infrastructures.eu/D4OS/GeoNA-Prototype";
String folderID="46b376db-32d7-4411-ad04-ca3dadab5f5b"; String folderID="46b376db-32d7-4411-ad04-ca3dadab5f5b";
Boolean recursive = true; Boolean recursive = true;
@ -21,21 +26,46 @@ public class DescribeWSFolder {
shc= new StorageHubClient(); shc= new StorageHubClient();
shc.openVREFolder().get().getDescription(); shc.openVREFolder().get().getDescription();
FolderContainer folder=shc.open(folderID).asFolder(); // FolderContainer folder=shc.open(folderID).asFolder();
FolderContainer folder = WorkspaceManager.getApplicationBaseFolder(shc);
FolderItem item=folder.get(); FolderItem item=folder.get();
System.out.print("PATH : "+item.getPath()+"\tHIDDEN : "+item.isHidden()+"\tDescription : "+item.getDescription()); System.out.print("PATH : "+item.getPath()+"\tHIDDEN : "+item.isHidden()+"\tDescription : "+item.getDescription());
System.out.println("Listing... "); System.out.println("Listing... ");
print(folder,""); Long size=print(folder,"",recursive);
System.out.println("Size : "+humanReadableByteCountBin(size));
} }
private static final void print(FolderContainer folder,String pad) throws StorageHubException { private static final Long print(FolderContainer folder,String pad,Boolean recursive) throws StorageHubException {
for (Item i : folder.list().includeHidden().getItems()) { Long toReturn=new Long(0);
List<? extends Item> items =folder.list().includeHidden().withContent().getItems();
System.out.println(pad+"Elements : "+items.size());
for (Item i : items) {
System.out.println(pad+ i.getName() + " [" + i.getPrimaryType()+"]"); System.out.println(pad+ i.getName() + " [" + i.getPrimaryType()+"]");
if(i instanceof FolderItem){ if(i instanceof FolderItem){
print(shc.open(i.getId()).asFolder(),pad+"\t"); if(recursive)
toReturn+= print(shc.open(i.getId()).asFolder(),pad+"\t",recursive);
}else if (i instanceof AbstractFileItem){
// toReturn+=shc.open(i.getId()).asFile().get().getContent().getSize();
toReturn+=((AbstractFileItem) i).getContent().getSize();
} }
} }
return toReturn;
}
public static String humanReadableByteCountBin(long bytes) {
long absB = bytes == Long.MIN_VALUE ? Long.MAX_VALUE : Math.abs(bytes);
if (absB < 1024) {
return bytes + " B";
}
long value = absB;
CharacterIterator ci = new StringCharacterIterator("KMGTPE");
for (int i = 40; i >= 0 && absB > 0xfffccccccccccccL >> i; i -= 10) {
value >>= 10;
ci.next();
}
value *= Long.signum(bytes);
return String.format("%.1f %ciB", value / 1024.0, ci.current());
} }
} }

View File

@ -10,7 +10,7 @@
<logger name="org.gcube.application" level="DEBUG"> <logger name="org.gcube.application" level="DEBUG">
</logger> </logger>
<root level="DEBUG"> <root level="ERROR">
<appender-ref ref="STDOUT" /> <appender-ref ref="STDOUT" />
</root> </root>

View File

@ -9,7 +9,6 @@
"GNA_AQUILEIAcomellimoro_2019_rev","GNA_AQUILEIAcomellimoro_2019_rev/GNA_topografia_AQUILEIAcomellimoro_2019/D.Posizionamento_AQU19COM/Tav01_line_posizionamento_EPSG4326.shp" "GNA_AQUILEIAcomellimoro_2019_rev","GNA_AQUILEIAcomellimoro_2019_rev/GNA_topografia_AQUILEIAcomellimoro_2019/D.Posizionamento_AQU19COM/Tav01_line_posizionamento_EPSG4326.shp"
"GNA_Poggio Pimperiale_Poggibonsi","GNA_Poggio Pimperiale_Poggibonsi/5591449/GNA_topografia_PoggioImperiale/POSIZIONAMENTO/POSIZIONAMENTO A22.shp" "GNA_Poggio Pimperiale_Poggibonsi","GNA_Poggio Pimperiale_Poggibonsi/5591449/GNA_topografia_PoggioImperiale/POSIZIONAMENTO/POSIZIONAMENTO A22.shp"
"Jesolo (Ve) - Loc. San Mauro e Torre del Caligo","Jesolo (Ve) - Loc. San Mauro e Torre del Caligo/GNA_topografia_Jesolo/GIS_shp/Area di Scavo 2019.shp" "Jesolo (Ve) - Loc. San Mauro e Torre del Caligo","Jesolo (Ve) - Loc. San Mauro e Torre del Caligo/GNA_topografia_Jesolo/GIS_shp/Area di Scavo 2019.shp"
"Monterotondo (RM)_loc. Tor Mancina_documentazione fine scavo 2019 (paragr. IVa)","Monterotondo (RM)_loc. Tor Mancina_documentazione fine scavo 2019 (paragr. IVa)/IVa_D_E_F_GNA_topografia_Via Nomentum-Eretum/pianta fine scavo fasi.dxf"
"Quarto d'Altino -Loc. Fornace","Quarto d'Altino -Loc. Fornace/Cupitò/GNA_Altino_posizionamento_shp/ALT19_area survey_EPSG4326.shp" "Quarto d'Altino -Loc. Fornace","Quarto d'Altino -Loc. Fornace/Cupitò/GNA_Altino_posizionamento_shp/ALT19_area survey_EPSG4326.shp"
"Tolfa (RM)_Bufalareccia_documentazione IVa 2019","Tolfa (RM)_Bufalareccia_documentazione IVa 2019/IVa_D_GNA_posizionamento dei limiti in formato vectoriale_Bufalareccia 2019/BUFFA_POLYGON_.shp" "Tolfa (RM)_Bufalareccia_documentazione IVa 2019","Tolfa (RM)_Bufalareccia_documentazione IVa 2019/IVa_D_GNA_posizionamento dei limiti in formato vectoriale_Bufalareccia 2019/BUFFA_POLYGON_.shp"
"UNIME_ LAINO_REV","UNIME_ LAINO_REV/D. Limiti saggi/laino 2019 limiti saggi/SAGGI.shp" "UNIME_ LAINO_REV","UNIME_ LAINO_REV/D. Limiti saggi/laino 2019 limiti saggi/SAGGI.shp"

1 Acquacadda_Nuxis_2019_def Acquacadda_Nuxis_2019_def/D_posizionamento saggi_NUXIS 2019/Areale saggi Nuxis - Grotta di Acquacadda.shp
9 GNA_AQUILEIAcomellimoro_2019_rev GNA_AQUILEIAcomellimoro_2019_rev/GNA_topografia_AQUILEIAcomellimoro_2019/D.Posizionamento_AQU19COM/Tav01_line_posizionamento_EPSG4326.shp
10 GNA_Poggio Pimperiale_Poggibonsi GNA_Poggio Pimperiale_Poggibonsi/5591449/GNA_topografia_PoggioImperiale/POSIZIONAMENTO/POSIZIONAMENTO A22.shp
11 Jesolo (Ve) - Loc. San Mauro e Torre del Caligo Jesolo (Ve) - Loc. San Mauro e Torre del Caligo/GNA_topografia_Jesolo/GIS_shp/Area di Scavo 2019.shp
Monterotondo (RM)_loc. Tor Mancina_documentazione fine scavo 2019 (paragr. IVa) Monterotondo (RM)_loc. Tor Mancina_documentazione fine scavo 2019 (paragr. IVa)/IVa_D_E_F_GNA_topografia_Via Nomentum-Eretum/pianta fine scavo fasi.dxf
12 Quarto d'Altino -Loc. Fornace Quarto d'Altino -Loc. Fornace/Cupitò/GNA_Altino_posizionamento_shp/ALT19_area survey_EPSG4326.shp
13 Tolfa (RM)_Bufalareccia_documentazione IVa 2019 Tolfa (RM)_Bufalareccia_documentazione IVa 2019/IVa_D_GNA_posizionamento dei limiti in formato vectoriale_Bufalareccia 2019/BUFFA_POLYGON_.shp
14 UNIME_ LAINO_REV UNIME_ LAINO_REV/D. Limiti saggi/laino 2019 limiti saggi/SAGGI.shp

View File

@ -1 +1,5 @@
"GNA_AQUILEIAcomellimoro_2019_rev","GNA_AQUILEIAcomellimoro_2019_rev/GNA_topografia_AQUILEIAcomellimoro_2019/D.Posizionamento_AQU19COM/Tav01_line_posizionamento_EPSG4326.shp"
"UsiniTomestighes","UsiniTomestighes/GNA_TOMESTIGHES_2019/GNA_Topografia_Tomestighes/D_GNA_Posizionamento_limiti_aree_indagate/Limiti.shp"
"GNA_Poggio Pimperiale_Poggibonsi","GNA_Poggio Pimperiale_Poggibonsi/5591449/GNA_topografia_PoggioImperiale/POSIZIONAMENTO/POSIZIONAMENTO A22.shp"
"UNIME_ LAINO_REV","UNIME_ LAINO_REV/D. Limiti saggi/laino 2019 limiti saggi/SAGGI.shp"
"UsiniTomestighes","UsiniTomestighes/GNA_TOMESTIGHES_2019/GNA_Topografia_Tomestighes/D_GNA_Posizionamento_limiti_aree_indagate/Limiti.shp" "UsiniTomestighes","UsiniTomestighes/GNA_TOMESTIGHES_2019/GNA_Topografia_Tomestighes/D_GNA_Posizionamento_limiti_aree_indagate/Limiti.shp"
1 UsiniTomestighes GNA_AQUILEIAcomellimoro_2019_rev UsiniTomestighes/GNA_TOMESTIGHES_2019/GNA_Topografia_Tomestighes/D_GNA_Posizionamento_limiti_aree_indagate/Limiti.shp GNA_AQUILEIAcomellimoro_2019_rev/GNA_topografia_AQUILEIAcomellimoro_2019/D.Posizionamento_AQU19COM/Tav01_line_posizionamento_EPSG4326.shp
1 GNA_AQUILEIAcomellimoro_2019_rev GNA_AQUILEIAcomellimoro_2019_rev/GNA_topografia_AQUILEIAcomellimoro_2019/D.Posizionamento_AQU19COM/Tav01_line_posizionamento_EPSG4326.shp
2 UsiniTomestighes UsiniTomestighes/GNA_TOMESTIGHES_2019/GNA_Topografia_Tomestighes/D_GNA_Posizionamento_limiti_aree_indagate/Limiti.shp
3 GNA_Poggio Pimperiale_Poggibonsi GNA_Poggio Pimperiale_Poggibonsi/5591449/GNA_topografia_PoggioImperiale/POSIZIONAMENTO/POSIZIONAMENTO A22.shp
4 UNIME_ LAINO_REV UNIME_ LAINO_REV/D. Limiti saggi/laino 2019 limiti saggi/SAGGI.shp
5 UsiniTomestighes UsiniTomestighes UsiniTomestighes/GNA_TOMESTIGHES_2019/GNA_Topografia_Tomestighes/D_GNA_Posizionamento_limiti_aree_indagate/Limiti.shp UsiniTomestighes/GNA_TOMESTIGHES_2019/GNA_Topografia_Tomestighes/D_GNA_Posizionamento_limiti_aree_indagate/Limiti.shp

View File

@ -0,0 +1,2 @@
"GNA_ELAIUSSA_FAC-SIMILE_2021","GNA_ELAIUSSA_FAC-SIMILE_2021/GNA_topografia_Elaiussa/POSIZIONAMENTO/Elaiussa_EPSG4326.shp"
"GNA_Ferrandina_2020_inserimento","GNA_Ferrandina_2020_inserimento/New Folder With Items/topografia/Posizionamento_Ferrandina_2020.shp"
1 GNA_ELAIUSSA_FAC-SIMILE_2021 GNA_ELAIUSSA_FAC-SIMILE_2021/GNA_topografia_Elaiussa/POSIZIONAMENTO/Elaiussa_EPSG4326.shp
2 GNA_Ferrandina_2020_inserimento GNA_Ferrandina_2020_inserimento/New Folder With Items/topografia/Posizionamento_Ferrandina_2020.shp

View File

@ -19,7 +19,11 @@ import static org.gcube.application.geoportal.client.GeoportalAbstractPlugin.sta
public class ClearConcessioni { public class ClearConcessioni {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
TokenSetter.set("/gcube/devsec/devVRE"); // String context="/gcube/devsec/devVRE";
String context="/pred4s/preprod/preVRE";
TokenSetter.set(context);
ConcessioniManagerI manager=statefulMongoConcessioni().build(); ConcessioniManagerI manager=statefulMongoConcessioni().build();
@ -35,9 +39,9 @@ public class ClearConcessioni {
Iterator<Concessione> it=null; Iterator<Concessione> it=null;
// it=manager.getList(); // it=manager.getList();
it=manager.search("{\"creationUser\" : {\"$exists\" : \"false\"}}"); it=manager.search("{\"nome\" : {$regex : \"Mock .*\"}, \"creationTime\" :{$gt : \"2021-10-18T13:58:53.326\"}}");
ExecutorService service = Executors.newFixedThreadPool(10); ExecutorService service = Executors.newFixedThreadPool(3);
it.forEachRemaining((Concessione c)->{ it.forEachRemaining((Concessione c)->{
@ -46,7 +50,7 @@ public class ClearConcessioni {
@Override @Override
public void run() { public void run() {
try{ try{
TokenSetter.set("/gcube/devsec/devVRE"); TokenSetter.set(context);
String currentId=c.getMongo_id(); String currentId=c.getMongo_id();
if(currentId==null) { if(currentId==null) {
System.out.println("ID IS NULL " + c); System.out.println("ID IS NULL " + c);
@ -70,7 +74,7 @@ public class ClearConcessioni {
}); });
}); });
while (!service.awaitTermination(2, TimeUnit.MINUTES)) { while (!service.awaitTermination(1, TimeUnit.MINUTES)) {
log.info("Waiting .. completed {}, out of {} ",count.get(),found.get()); log.info("Waiting .. completed {}, out of {} ",count.get(),found.get());
if(found.get()==count.get()) service.shutdown(); if(found.get()==count.get()) service.shutdown();
} }

View File

@ -33,9 +33,9 @@ public class Export {
public static void main(String[] args) { public static void main(String[] args) {
File dir= new File("/Users/fabioisti/git/geoportal-client/import1628178107083"); File dir= new File("/Users/fabioisti/git/gcube-cms-suite/import1632326294149");
// String targetContext="/pred4s/preprod/preVRE"; String targetContext="/d4science.research-infrastructures.eu/D4OS/GeoNA-Prototype";
String targetContext= "/org/gcube/devsec/devVRE"; // String targetContext= "/gcube/devsec/devVRE";
@ -101,6 +101,7 @@ public class Export {
c.setFolderId(null); c.setFolderId(null);
c.setMongo_id(null); c.setMongo_id(null);
// PUSH PROJECT // PUSH PROJECT
manager.createNew(c); manager.createNew(c);

View File

@ -25,7 +25,7 @@ public class StressTest {
private static ExecutorService service = Executors.newFixedThreadPool(5); private static ExecutorService service = Executors.newFixedThreadPool(5);
public static void main(String[] args) throws FileNotFoundException { public static void main(String[] args) throws FileNotFoundException {
TokenSetter.set("/gcube/devsec/devVRE"); TokenSetter.set("/pred4s/preprod/preVRE");
AtomicLong executed=new AtomicLong(0); AtomicLong executed=new AtomicLong(0);
AddSectionToConcessioneRequest request= FileSets.prepareRequest( AddSectionToConcessioneRequest request= FileSets.prepareRequest(
@ -42,7 +42,7 @@ public class StressTest {
c.setNome("Stress test"); c.setNome("Stress test");
c.setDefaults(); c.setDefaults();
c=client.createNew(c); c=client.createNew(c);
client.registerFileSet(c.getMongo_id(),request); // client.registerFileSet(c.getMongo_id(),request);
}catch(Throwable t){ }catch(Throwable t){
System.err.println(t); System.err.println(t);
try {Thread.sleep(1000);} catch (InterruptedException i) {} try {Thread.sleep(1000);} catch (InterruptedException i) {}

View File

@ -26,7 +26,9 @@ public class MockFromFolder {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
//PARAMS //PARAMS
String context= "/gcube/devsec/devVRE"; // String context= "/gcube/devsec/devVRE";
String context = "/pred4s/preprod/preVRE";
File descriptorsBaseFolder=new File(TestModel.getBaseFolder(),"packages"); File descriptorsBaseFolder=new File(TestModel.getBaseFolder(),"packages");
@ -36,16 +38,20 @@ public class MockFromFolder {
//Concessioni 04-03 //Concessioni 04-03
configurations.put("concessioni04-03.csv","/Users/fabioisti/Documents/Concessioni 04-03/"); configurations.put("concessioni04-03.csv","/Users/fabioisti/Documents/Concessioni 04-03/");
// configurations.put("concessioni04-03_filtered.csv","/Users/fabioisti/Documents/Concessioni 04-03/");
//DATASET_GNA_01 //DATASET_GNA_01
configurations.put("DATASET_GNA_01.csv","/Users/fabioisti/Documents/DATASET_GNA_01"); configurations.put("DATASET_GNA_01.csv","/Users/fabioisti/Documents/DATASET_GNA_01");
//DATASET_GNA_02 //DATASET_GNA_02
configurations.put("DATASET_GNA_02.csv","/Users/fabioisti/Documents/DATASET_GNA_02"); configurations.put("DATASET_GNA_02.csv","/Users/fabioisti/Documents/DATASET_GNA_02");
// invio_08_02 // invio_08_02
configurations.put("invio_08_05.csv","/Users/fabioisti/Documents/invio_08_05"); configurations.put("invio_08_05.csv","/Users/fabioisti/Documents/invio_08_05");
// concessioni 23_04 // // concessioni 23_04
configurations.put("concessioni_23_04.csv","/Users/fabioisti/Documents/Concessioni_23_04"); configurations.put("concessioni_23_04.csv","/Users/fabioisti/Documents/Concessioni_23_04");
TokenSetter.set(context); //reinvii
configurations.put("reinvii.csv","/Users/fabioisti/Documents/reinvii");
TokenSetter.set(context);
long start= System.currentTimeMillis(); long start= System.currentTimeMillis();