Logging
This commit is contained in:
parent
41af4e3bc9
commit
fbda3ce866
|
@ -4,6 +4,7 @@ import java.io.File;
|
|||
import java.io.IOException;
|
||||
|
||||
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.profile.Profile;
|
||||
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.datatype.jsr310.JavaTimeModule;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class SerializationTest {
|
||||
|
||||
|
||||
|
@ -48,6 +51,12 @@ public class SerializationTest {
|
|||
Concessione concessione=mapper.readerFor(Concessione.class).readValue(new File(TestModel.getBaseFolder(),"Concessione.json"));
|
||||
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
|
||||
|
|
|
@ -7,6 +7,7 @@ import org.gcube.application.geoportal.common.rest.TempFile;
|
|||
public interface ConcessioniManagerI extends MongoConcessioni{
|
||||
|
||||
|
||||
public Concessione getCurrent();
|
||||
public Concessione addImmagineRappresentativa(UploadedImage toAdd,TempFile f) throws Exception;
|
||||
public Concessione addPiantaFineScavo(LayerConcessione toAdd,TempFile...files)throws Exception;
|
||||
public Concessione setPosizionamento(LayerConcessione toSet,TempFile...files)throws Exception;
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
|||
|
||||
import javax.ws.rs.client.WebTarget;
|
||||
|
||||
import lombok.Getter;
|
||||
import org.gcube.application.geoportal.client.DefaultMongoConcessioni;
|
||||
import org.gcube.application.geoportal.common.model.legacy.*;
|
||||
import org.gcube.application.geoportal.common.utils.FileSets;
|
||||
|
@ -21,97 +22,98 @@ public class StatefulMongoConcessioni extends DefaultMongoConcessioni implements
|
|||
super(delegate);
|
||||
}
|
||||
|
||||
private Concessione currentC=null;
|
||||
@Getter
|
||||
private Concessione current =null;
|
||||
private StorageUtils storage=new StorageUtils();
|
||||
|
||||
|
||||
// Override methods to handle state
|
||||
@Override
|
||||
public Concessione createNew(Concessione c) throws Exception {
|
||||
currentC=super.createNew(c);
|
||||
return currentC;
|
||||
current =super.createNew(c);
|
||||
return current;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Concessione getById(String id) throws Exception {
|
||||
currentC= super.getById(id);
|
||||
return currentC;
|
||||
current = super.getById(id);
|
||||
return current;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Concessione publish() throws Exception {
|
||||
if(currentC==null) throw new Exception("Invalid operation : current Concessione is null.");
|
||||
currentC=super.publish(currentC.getMongo_id());
|
||||
return currentC;
|
||||
if(current ==null) throw new Exception("Invalid operation : current Concessione is null.");
|
||||
current =super.publish(current.getMongo_id());
|
||||
return current;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void delete() throws Exception {
|
||||
if(currentC==null) throw new Exception("Invalid operation : current Concessione is null.");
|
||||
super.deleteById(currentC.getMongo_id());
|
||||
currentC=null;
|
||||
if(current ==null) throw new Exception("Invalid operation : current Concessione is null.");
|
||||
super.deleteById(current.getMongo_id());
|
||||
current =null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Concessione addImmagineRappresentativa(UploadedImage toAdd, TempFile f) throws Exception {
|
||||
if(currentC==null) throw new Exception("Invalid operation : current Concessione is null.");
|
||||
if(currentC.getImmaginiRappresentative()==null) currentC.setImmaginiRappresentative(new ArrayList<UploadedImage>());
|
||||
currentC.getImmaginiRappresentative().add(toAdd);
|
||||
currentC=replace(currentC);
|
||||
if(current ==null) throw new Exception("Invalid operation : current Concessione is null.");
|
||||
if(current.getImmaginiRappresentative()==null) current.setImmaginiRappresentative(new ArrayList<UploadedImage>());
|
||||
current.getImmaginiRappresentative().add(toAdd);
|
||||
current =replace(current);
|
||||
|
||||
|
||||
currentC=super.registerFileSet(currentC.getMongo_id(),
|
||||
FileSets.build(Paths.imgByIndex(currentC.getImmaginiRappresentative().size()-1),f).getTheRequest());
|
||||
return currentC;
|
||||
current =super.registerFileSet(current.getMongo_id(),
|
||||
FileSets.build(Paths.imgByIndex(current.getImmaginiRappresentative().size()-1),f).getTheRequest());
|
||||
return current;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Concessione addPiantaFineScavo(LayerConcessione toAdd, TempFile... files) throws Exception {
|
||||
if(currentC==null) throw new Exception("Invalid operation : current Concessione is null.");
|
||||
if(currentC.getPianteFineScavo()==null) currentC.setPianteFineScavo(new ArrayList<>());
|
||||
currentC.getPianteFineScavo().add(toAdd);
|
||||
currentC=replace(currentC);
|
||||
if(current ==null) throw new Exception("Invalid operation : current Concessione is null.");
|
||||
if(current.getPianteFineScavo()==null) current.setPianteFineScavo(new ArrayList<>());
|
||||
current.getPianteFineScavo().add(toAdd);
|
||||
current =replace(current);
|
||||
|
||||
|
||||
currentC=super.registerFileSet(currentC.getMongo_id(),
|
||||
FileSets.build(Paths.piantaByIndex(currentC.getPianteFineScavo().size()-1),files).getTheRequest());
|
||||
return currentC;
|
||||
current =super.registerFileSet(current.getMongo_id(),
|
||||
FileSets.build(Paths.piantaByIndex(current.getPianteFineScavo().size()-1),files).getTheRequest());
|
||||
return current;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Concessione setPosizionamento(LayerConcessione toSet, TempFile... files) throws Exception {
|
||||
if(currentC==null) throw new Exception("Invalid operation : current Concessione is null.");
|
||||
currentC.setPosizionamentoScavo(toSet);
|
||||
currentC=replace(currentC);
|
||||
if(current ==null) throw new Exception("Invalid operation : current Concessione is null.");
|
||||
current.setPosizionamentoScavo(toSet);
|
||||
current =replace(current);
|
||||
|
||||
|
||||
currentC=super.registerFileSet(currentC.getMongo_id(),
|
||||
current =super.registerFileSet(current.getMongo_id(),
|
||||
FileSets.build(Paths.POSIZIONAMENTO,files).getTheRequest());
|
||||
return currentC;
|
||||
return current;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Concessione setRelazioneScavo(RelazioneScavo toSet, TempFile... files) throws Exception {
|
||||
if(currentC==null) throw new Exception("Invalid operation : current Concessione is null.");
|
||||
currentC.setRelazioneScavo(toSet);
|
||||
currentC=replace(currentC);
|
||||
if(current ==null) throw new Exception("Invalid operation : current Concessione is null.");
|
||||
current.setRelazioneScavo(toSet);
|
||||
current =replace(current);
|
||||
|
||||
|
||||
currentC=super.registerFileSet(currentC.getMongo_id(),
|
||||
current =super.registerFileSet(current.getMongo_id(),
|
||||
FileSets.build(Paths.RELAZIONE,files).getTheRequest());
|
||||
return currentC;
|
||||
return current;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Concessione setAbstractRelazioneScavo(AbstractRelazione toSet, TempFile... files) throws Exception {
|
||||
if(currentC==null) throw new Exception("Invalid operation : current Concessione is null.");
|
||||
currentC.setAbstractRelazione(toSet);
|
||||
currentC=replace(currentC);
|
||||
if(current ==null) throw new Exception("Invalid operation : current Concessione is null.");
|
||||
current.setAbstractRelazione(toSet);
|
||||
current =replace(current);
|
||||
|
||||
currentC=super.registerFileSet(currentC.getMongo_id(),
|
||||
current =super.registerFileSet(current.getMongo_id(),
|
||||
FileSets.build(Paths.ABSTRACT_RELAZIONE,files).getTheRequest());
|
||||
return currentC;
|
||||
return current;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -7,7 +7,8 @@ public class BasicVreTests {
|
|||
|
||||
@BeforeClass
|
||||
public static void setScope(){
|
||||
// TokenSetter.set("/gcube/devNext/NextNext");
|
||||
// TokenSetter.set("/pred4s/preprod/preVRE");
|
||||
// TokenSetter.set("/d4science.research-infrastructures.eu/D4OS/GeoNA-Prototype");
|
||||
TokenSetter.set("/gcube/devsec/devVRE");
|
||||
}
|
||||
|
||||
|
|
|
@ -10,10 +10,7 @@ import java.io.FileNotFoundException;
|
|||
import org.gcube.application.cms.tests.model.TestModel;
|
||||
import org.gcube.application.geoportal.client.legacy.ConcessioniManagerI;
|
||||
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.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.*;
|
||||
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.utils.Files;
|
||||
|
@ -35,6 +32,9 @@ public class StatefulClientTests extends BasicVreTests{
|
|||
toRegister.setNome("Mock module");
|
||||
manager.createNew(toRegister);
|
||||
|
||||
|
||||
|
||||
|
||||
Concessione source=TestModel.prepareConcessione();
|
||||
|
||||
|
||||
|
@ -42,7 +42,7 @@ public class StatefulClientTests extends BasicVreTests{
|
|||
|
||||
// TEMP Files are hosted in INFRASTRUCTURE's VOLATILE AREA
|
||||
TempFile toUpload=storage.putOntoStorage(
|
||||
new File(TestModel.getBaseFolder(),"immagine.png"), "immagine.png");
|
||||
new File(TestModel.getBaseFolder(),"immagine1.png"), "immagine.png");
|
||||
|
||||
manager.addImmagineRappresentativa(toRegisterImg, toUpload);
|
||||
|
||||
|
@ -50,14 +50,17 @@ public class StatefulClientTests extends BasicVreTests{
|
|||
//Alternative Method
|
||||
InputStreamDescriptor isDesc=
|
||||
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);
|
||||
|
||||
source.getRelazioneScavo().setPolicy(AccessPolicy.EMBARGOED);
|
||||
assertEquals(AccessPolicy.EMBARGOED,source.getRelazioneScavo().getPolicy());
|
||||
|
||||
//Relazione
|
||||
manager.setRelazioneScavo(source.getRelazioneScavo(),
|
||||
storage.putOntoStorage(new File(TestModel.getBaseFolder(),"relazione.pdf"), "relazione_it.pdf"),
|
||||
storage.putOntoStorage(new File(TestModel.getBaseFolder(),"relazione.pdf"), "relazione_en.pdf"));
|
||||
assertEquals(AccessPolicy.EMBARGOED,manager.getCurrent().getRelazioneScavo().getPolicy());
|
||||
|
||||
//Abstract
|
||||
manager.setAbstractRelazioneScavo(
|
||||
|
@ -66,6 +69,7 @@ public class StatefulClientTests extends BasicVreTests{
|
|||
storage.putOntoStorage(new File(TestModel.getBaseFolder(),"relazione.pdf"), "abstract_relazione_en.pdf"));
|
||||
|
||||
|
||||
|
||||
// Posizionamento scavo
|
||||
|
||||
manager.setPosizionamento(source.getPosizionamentoScavo(),
|
||||
|
@ -79,7 +83,11 @@ public class StatefulClientTests extends BasicVreTests{
|
|||
// 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");})));
|
||||
|
||||
return manager.publish();
|
||||
|
||||
|
||||
Concessione toReturn=manager.publish();
|
||||
assertEquals(AccessPolicy.EMBARGOED,toReturn.getRelazioneScavo().getPolicy());
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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.TestQueries;
|
||||
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.Concessione.Paths;
|
||||
import org.gcube.application.geoportal.common.model.legacy.report.ValidationReport.ValidationStatus;
|
||||
|
@ -130,7 +131,7 @@ public class StatelessClientTests extends BasicVreTests{
|
|||
|
||||
|
||||
@Test
|
||||
public void testPublsh() throws Exception {
|
||||
public void testPublish() throws Exception {
|
||||
Concessione c=prepare();
|
||||
|
||||
assertTrue(c.getReport().getStatus().equals(ValidationStatus.PASSED));
|
||||
|
@ -174,31 +175,43 @@ public class StatelessClientTests extends BasicVreTests{
|
|||
Concessione c= client.createNew(TestModel.prepareConcessione(1,numImgs));
|
||||
StorageUtils storage = new StorageUtils();
|
||||
|
||||
c.getRelazioneScavo().setPolicy(AccessPolicy.EMBARGOED);
|
||||
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")));
|
||||
|
||||
client.registerFileSet(mongoId,
|
||||
FileSets.prepareRequest(storage,Paths.RELAZIONE,new File(TestModel.getBaseFolder(),"relazione.pdf")));
|
||||
assertEquals(AccessPolicy.EMBARGOED,c.getRelazioneScavo().getPolicy());
|
||||
|
||||
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++)
|
||||
client.registerFileSet(mongoId,
|
||||
c=client.registerFileSet(mongoId,
|
||||
FileSets.build(Paths.imgByIndex(i)).
|
||||
add(storage.putOntoStorage(new File(TestModel.getBaseFolder(),"immagine"+(i+1)+".png"),
|
||||
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")));
|
||||
|
||||
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")));
|
||||
|
||||
assertEquals(AccessPolicy.EMBARGOED,c.getRelazioneScavo().getPolicy());
|
||||
|
||||
c=client.publish(mongoId);
|
||||
assertEquals(AccessPolicy.EMBARGOED,c.getRelazioneScavo().getPolicy());
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,4 +37,7 @@ public class DefaultsTests {
|
|||
c.setDefaults();
|
||||
assertEquals(AccessPolicy.EMBARGOED,c.getRelazioneScavo().getPolicy());
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -82,14 +82,19 @@ public class ConcessioniMongoManager extends MongoManager{
|
|||
|
||||
|
||||
public Concessione registerNew(Concessione toRegister) throws IOException {
|
||||
log.trace("Registering {} ",toRegister);
|
||||
log.trace("Going to register {} ",toRegister);
|
||||
toRegister.setDefaults();
|
||||
log.trace("Concessione with defaults is {}",toRegister);
|
||||
ObjectId id=insert(asDocument(toRegister), collectionName);
|
||||
|
||||
log.trace("Obtained id {}",id);
|
||||
Concessione toReturn=asConcessione(getById(id,collectionName));
|
||||
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 {
|
||||
|
@ -98,14 +103,14 @@ public class ConcessioniMongoManager extends MongoManager{
|
|||
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);
|
||||
Concessione toReturn=asConcessione(update(asId(id),asDoc(json),collectionName));
|
||||
log.debug("Refreshing defaults..");
|
||||
toReturn.setDefaults();
|
||||
return asConcessione(replace(asDocument(toReturn),collectionName));
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
|
||||
public Iterable<Concessione> list(){
|
||||
|
|
|
@ -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);
|
||||
}
|
|
@ -19,8 +19,9 @@ public class BasicServiceTestUnit extends JerseyTest {
|
|||
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
|
||||
public static void init() {
|
||||
|
||||
|
|
|
@ -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.TestQueries;
|
||||
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.Paths;
|
||||
import org.gcube.application.geoportal.common.model.legacy.LayerConcessione;
|
||||
|
@ -300,8 +301,7 @@ public class ConcessioniOverMongoTest extends BasicServiceTestUnit{
|
|||
assertNotNull(published.getReport());
|
||||
assertEquals(ValidationStatus.PASSED,published.getReport().getStatus());
|
||||
|
||||
assertEquals(published.getImmaginiRappresentative().size(),2);
|
||||
assertEquals(published.getPianteFineScavo().size(),1);
|
||||
|
||||
assertNotNull(published.getPosizionamentoScavo().getWmsLink());
|
||||
for(LayerConcessione l : published.getPianteFineScavo()) {
|
||||
assertNotNull(l.getWmsLink());
|
||||
|
@ -317,6 +317,9 @@ public class ConcessioniOverMongoTest extends BasicServiceTestUnit{
|
|||
|
||||
Concessione c=TestModel.prepareConcessione(layers.size(),1);
|
||||
|
||||
c.getRelazioneScavo().setPolicy(AccessPolicy.EMBARGOED);
|
||||
assertEquals(AccessPolicy.EMBARGOED,c.getRelazioneScavo().getPolicy());
|
||||
|
||||
c.setNome("Concessione : publish test ");
|
||||
StorageUtils storage=new StorageUtils();
|
||||
|
||||
|
@ -324,8 +327,12 @@ public class ConcessioniOverMongoTest extends BasicServiceTestUnit{
|
|||
// Register new
|
||||
c=register(target,c);
|
||||
|
||||
assertEquals(AccessPolicy.EMBARGOED,c.getRelazioneScavo().getPolicy());
|
||||
|
||||
//Upload files
|
||||
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");
|
||||
|
||||
|
||||
|
@ -333,7 +340,7 @@ public class ConcessioniOverMongoTest extends BasicServiceTestUnit{
|
|||
c=upload(storage,target,c.getMongo_id(),Paths.POSIZIONAMENTO,
|
||||
// TestModel.getBaseFolder().list((file,name)->{return name.startsWith("pianta.shp");}));
|
||||
layers.get(keys[0]).toArray(new File[0]));
|
||||
|
||||
assertEquals(AccessPolicy.EMBARGOED,c.getRelazioneScavo().getPolicy());
|
||||
|
||||
// Clash on workspaces
|
||||
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");}));
|
||||
layers.get(key).toArray(new File[0]));
|
||||
}
|
||||
assertEquals(AccessPolicy.EMBARGOED,c.getRelazioneScavo().getPolicy());
|
||||
|
||||
// Immagini
|
||||
for (int i = 0; i <c.getImmaginiRappresentative().size() ; i++) {
|
||||
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){
|
||||
|
|
|
@ -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.items.*;
|
||||
|
||||
import java.text.CharacterIterator;
|
||||
import java.text.StringCharacterIterator;
|
||||
import java.util.List;
|
||||
|
||||
public class DescribeWSFolder {
|
||||
|
||||
|
||||
static StorageHubClient shc =null;
|
||||
|
||||
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";
|
||||
Boolean recursive = true;
|
||||
|
||||
|
@ -21,21 +26,46 @@ public class DescribeWSFolder {
|
|||
shc= new StorageHubClient();
|
||||
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();
|
||||
System.out.print("PATH : "+item.getPath()+"\tHIDDEN : "+item.isHidden()+"\tDescription : "+item.getDescription());
|
||||
|
||||
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 {
|
||||
for (Item i : folder.list().includeHidden().getItems()) {
|
||||
private static final Long print(FolderContainer folder,String pad,Boolean recursive) throws StorageHubException {
|
||||
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()+"]");
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<logger name="org.gcube.application" level="DEBUG">
|
||||
</logger>
|
||||
|
||||
<root level="DEBUG">
|
||||
<root level="ERROR">
|
||||
<appender-ref ref="STDOUT" />
|
||||
|
||||
</root>
|
||||
|
|
|
@ -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_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"
|
||||
"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"
|
||||
"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"
|
||||
|
|
|
|
@ -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"
|
|
|
@ -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"
|
|
|
@ -19,7 +19,11 @@ import static org.gcube.application.geoportal.client.GeoportalAbstractPlugin.sta
|
|||
public class ClearConcessioni {
|
||||
|
||||
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();
|
||||
|
||||
|
@ -35,9 +39,9 @@ public class ClearConcessioni {
|
|||
|
||||
Iterator<Concessione> it=null;
|
||||
// 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)->{
|
||||
|
@ -46,7 +50,7 @@ public class ClearConcessioni {
|
|||
@Override
|
||||
public void run() {
|
||||
try{
|
||||
TokenSetter.set("/gcube/devsec/devVRE");
|
||||
TokenSetter.set(context);
|
||||
String currentId=c.getMongo_id();
|
||||
if(currentId==null) {
|
||||
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());
|
||||
if(found.get()==count.get()) service.shutdown();
|
||||
}
|
||||
|
|
|
@ -33,9 +33,9 @@ public class Export {
|
|||
|
||||
public static void main(String[] args) {
|
||||
|
||||
File dir= new File("/Users/fabioisti/git/geoportal-client/import1628178107083");
|
||||
// String targetContext="/pred4s/preprod/preVRE";
|
||||
String targetContext= "/org/gcube/devsec/devVRE";
|
||||
File dir= new File("/Users/fabioisti/git/gcube-cms-suite/import1632326294149");
|
||||
String targetContext="/d4science.research-infrastructures.eu/D4OS/GeoNA-Prototype";
|
||||
// String targetContext= "/gcube/devsec/devVRE";
|
||||
|
||||
|
||||
|
||||
|
@ -101,6 +101,7 @@ public class Export {
|
|||
c.setFolderId(null);
|
||||
c.setMongo_id(null);
|
||||
|
||||
|
||||
// PUSH PROJECT
|
||||
manager.createNew(c);
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ public class StressTest {
|
|||
private static ExecutorService service = Executors.newFixedThreadPool(5);
|
||||
|
||||
public static void main(String[] args) throws FileNotFoundException {
|
||||
TokenSetter.set("/gcube/devsec/devVRE");
|
||||
TokenSetter.set("/pred4s/preprod/preVRE");
|
||||
AtomicLong executed=new AtomicLong(0);
|
||||
|
||||
AddSectionToConcessioneRequest request= FileSets.prepareRequest(
|
||||
|
@ -42,7 +42,7 @@ public class StressTest {
|
|||
c.setNome("Stress test");
|
||||
c.setDefaults();
|
||||
c=client.createNew(c);
|
||||
client.registerFileSet(c.getMongo_id(),request);
|
||||
// client.registerFileSet(c.getMongo_id(),request);
|
||||
}catch(Throwable t){
|
||||
System.err.println(t);
|
||||
try {Thread.sleep(1000);} catch (InterruptedException i) {}
|
||||
|
|
|
@ -26,7 +26,9 @@ public class MockFromFolder {
|
|||
|
||||
public static void main(String[] args) throws Exception {
|
||||
//PARAMS
|
||||
String context= "/gcube/devsec/devVRE";
|
||||
// String context= "/gcube/devsec/devVRE";
|
||||
String context = "/pred4s/preprod/preVRE";
|
||||
|
||||
|
||||
File descriptorsBaseFolder=new File(TestModel.getBaseFolder(),"packages");
|
||||
|
||||
|
@ -36,15 +38,19 @@ public class MockFromFolder {
|
|||
|
||||
//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
|
||||
configurations.put("DATASET_GNA_01.csv","/Users/fabioisti/Documents/DATASET_GNA_01");
|
||||
//DATASET_GNA_02
|
||||
configurations.put("DATASET_GNA_02.csv","/Users/fabioisti/Documents/DATASET_GNA_02");
|
||||
// invio_08_02
|
||||
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");
|
||||
|
||||
//reinvii
|
||||
configurations.put("reinvii.csv","/Users/fabioisti/Documents/reinvii");
|
||||
|
||||
TokenSetter.set(context);
|
||||
|
||||
long start= System.currentTimeMillis();
|
||||
|
|
Loading…
Reference in New Issue