Compare commits

...

35 Commits

Author SHA1 Message Date
Fabio Sinibaldi 7233768700 Section Abstract Relazione 2021-09-20 12:48:59 +02:00
Fabio Sinibaldi 0494aa7039 Fix Names 2021-09-20 12:34:40 +02:00
Fabio Sinibaldi 9e1c46b95b Fix Names 2021-09-09 16:01:00 +02:00
Fabio Sinibaldi e6f826d841 Rename transformation in projection 2021-09-08 16:52:23 +02:00
Fabio Sinibaldi f33ccd3e91 Query filter and transformation as Document 2021-09-08 16:44:57 +02:00
Fabio Sinibaldi fe4110213d Clean File Set 2021-09-03 12:39:12 +02:00
Fabio Sinibaldi f14c243a67 No arguments constructor 2021-09-02 12:42:10 +02:00
Fabio Sinibaldi 8fb4b7625f All arguments constructor 2021-09-01 18:03:22 +02:00
Fabio Sinibaldi bcb5ae8c15 Excluded storage manager snapshot 2021-09-01 17:44:52 +02:00
Fabio Sinibaldi f46b0ba34c Excluded storage manager snapshot 2021-08-06 11:42:52 +02:00
Fabio Sinibaldi cff85e396f Exposed method Unpublish 2021-08-03 16:40:16 +02:00
Fabio Sinibaldi 069e8420c7 Exposed method Unpublish 2021-08-03 16:26:11 +02:00
Fabio Sinibaldi 3408e3e9a4 Force Deletion 2021-08-03 12:39:26 +02:00
Fabio Sinibaldi ebd1b2c5c1 Interface returns Iterator 2021-08-03 12:37:43 +02:00
Fabio Sinibaldi 464a86ac51 Interface returns Iterator 2021-08-03 12:21:25 +02:00
Fabio Sinibaldi 74ccb666bc Merge pull request '1.0.5' (#3) from 1.0.5 into master 2021-01-14 16:49:21 +01:00
Fabio Sinibaldi 31db0d70df releasing 1.0.5 2021-01-14 16:47:02 +01:00
Fabio Sinibaldi 7e083800fd Added void constructor 2021-01-11 12:20:33 +01:00
Fabio Sinibaldi bdb3b6c2cc fixed test model 2021-01-07 11:22:34 +01:00
Fabio Sinibaldi f770bdbcee updated model 2021-01-06 15:46:38 +01:00
Fabio Sinibaldi 01371e8750 updated model 2021-01-06 15:46:38 +01:00
Fabio Sinibaldi dacaa5ef06 Added constructor 2021-01-04 19:08:20 +01:00
Fabio Sinibaldi f30c662e35 Serialization tests 2020-12-22 17:49:15 +01:00
Fabio Sinibaldi f68290afa5 VAlidation report as record field 2020-12-22 11:47:38 +01:00
Fabio Sinibaldi 0630ca9a48 fix file names 2020-12-22 11:40:48 +01:00
Fabio Sinibaldi 8bf718d3a9 Mongo interface 2020-12-22 11:31:54 +01:00
Fabio Sinibaldi e7f2b59844 Destination as path 2020-12-18 17:09:01 +01:00
Fabio Sinibaldi f6756413d6 Path embedded support 2020-12-18 17:05:40 +01:00
Fabio Sinibaldi 888c14ad69 Associated content now has mongo_id 2020-12-18 13:41:28 +01:00
Fabio Sinibaldi 0e9f28909c mongo id 2020-12-17 13:42:31 +01:00
Fabio Sinibaldi 204d4608a0 Changed Exception type 2020-12-17 11:50:44 +01:00
Fabio Sinibaldi 08462b863e Temp files 2020-12-16 17:55:08 +01:00
Fabio Sinibaldi 8b36eb5a8d release 2020-12-07 17:09:44 +01:00
Fabio Sinibaldi a06a92ab72 Model update 2020-12-07 17:08:06 +01:00
Fabio Sinibaldi cdbe3bae12 model update 2020-12-04 12:22:42 +01:00
31 changed files with 739 additions and 135 deletions

View File

@ -2,6 +2,33 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
# Changelog for org.gcube.application.geoportal-common
# [v1.0.6-SNAPSHOT] - 2021-08-3
Forced Deletion
Search & query
Clean Fileset
Interfaces return iterator instead of iterable
Name in WorkspaceContent (https://support.d4science.org/issues/22032)
# [v1.0.5] - 2020-12-9
Mongo Id in record
Mongo Concessioni interface
Added Files.fixFileNAme
ValidationReport as field
Updated Model (#20357)
# [v1.0.4-SNAPSHOT] - 2020-12-9
Projects Rest Interface
TempFile support
# [v1.0.3] - 2020-12-4
Project model update
# [v1.0.2-SNAPSHOT] - 2020-12-4
Model update
## [v1.0.1] - 2020-11-11
Model update

35
pom.xml
View File

@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.gcube.application</groupId>
<artifactId>geoportal-common</artifactId>
<version>1.0.1</version>
<version>1.0.6-SNAPSHOT</version>
<name>Geoportal Common</name>
@ -36,7 +36,7 @@
<dependency>
<groupId>org.gcube.distribution</groupId>
<artifactId>gcube-bom</artifactId>
<version>2.0.0</version>
<version>2.0.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
@ -51,9 +51,12 @@
<version>1.14.8</version>
</dependency>
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>authorization-client</artifactId>
</dependency>
<!-- TEST -->
<dependency>
@ -62,22 +65,34 @@
<scope>test</scope>
<version>4.11</version>
</dependency>
<!-- read JSON -->
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
</dependency>
<!-- jackson java time -->
<!-- jackson java time -->
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>2.8.8</version>
</dependency>
<!-- STORAGE -->
<dependency>
<groupId>org.gcube.contentmanagement</groupId>
<artifactId>storage-manager-core</artifactId>
<version>[2.0.0, 3.0.0-SNAPSHOT)</version>
</dependency>
<dependency>
<groupId>org.gcube.contentmanagement</groupId>
<artifactId>storage-manager-wrapper</artifactId>
<version>[2.0.0, 3.0.0-SNAPSHOT)</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>

View File

@ -0,0 +1,16 @@
package org.gcube.application.geoportal.common.model.legacy;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
@Getter
@Setter
@ToString(callSuper=true)
public class AbstractRelazione extends AssociatedContent{
private String abstractIta;
private String abstractEng;
}

View File

@ -19,7 +19,7 @@ import lombok.Setter;
public abstract class AssociatedContent {
private String mongo_id;
private long id;
private AccessPolicy policy;

View File

@ -71,7 +71,8 @@ public class Concessione extends Record{
private Double centroidLong;
private RelazioneScavo relazioneScavo;
private AssociatedContent abstractRelazione;
private List<UploadedImage> immaginiRappresentative=new ArrayList<UploadedImage>();
private LayerConcessione posizionamentoScavo;
@ -87,6 +88,112 @@ public class Concessione extends Record{
}
public static class Paths{
public final static String RELAZIONE="relazione";
public final static String POSIZIONAMENTO="posizionamentoScavo";
public final static String PIANTE="piante";
public final static String IMMAGINI="immagini";
public final static String ABSTRACT_RELAZIONE="abstract_relazione";
public static final String MONGO_ID="mongo_id";
public final static String piantaByIndex(int index) {return makeByIndex(PIANTE,index);};
public final static String imgByIndex(int index) {return makeByIndex(IMMAGINI,index);};
public final static String piantaById(String id) {return makeByStringField(PIANTE, MONGO_ID, id);};
public final static String imgById(String id) {return makeByStringField(IMMAGINI, MONGO_ID, id);};
private static String makeByIndex(String base,int value) {return String.format("%1$s[%2$d]",base,value);}
private static String makeByStringField(String base,String field,String value)
{return String.format("%1$s.%2$s:\"%3$s\"",base,field,value);}
}
@Override
public AssociatedContent getContentByPath(String path) {
switch(path) {
case Paths.RELAZIONE : return getRelazioneScavo();
case Paths.POSIZIONAMENTO : return getPosizionamentoScavo();
case Paths.ABSTRACT_RELAZIONE: return getAbstractRelazione();
}
if(path.matches("\\w+\\[\\d+\\]")) {
// Array section
String field=path.substring(0,path.lastIndexOf("["));
Integer index=Integer.parseInt(path.substring(path.lastIndexOf("[")+1,path.lastIndexOf("]")));
List<? extends AssociatedContent> list=null;
switch (field) {
case Paths.IMMAGINI : list = immaginiRappresentative; break;
case Paths.PIANTE : list = pianteFineScavo; break;
}
return getByIndex(list,index);
}
if(path.matches("\\w+\\.\\w+\\s*\\:\\s*\\\"\\w+\\\"")) {
// Map section
String field=path.substring(0,path.lastIndexOf("."));
String subField=path.substring(path.indexOf(".")+1,path.lastIndexOf(":")).trim();
String value=path.substring(path.indexOf("\"")+1,path.lastIndexOf("\""));
List<? extends AssociatedContent> list=null;
switch (field) {
case Paths.IMMAGINI : list = immaginiRappresentative; break;
case Paths.PIANTE : list = pianteFineScavo; break;
}
return getByFieldValue(list, subField, value);
}
return null;
}
private static AssociatedContent getByIndex(List<? extends AssociatedContent> list, int index) {
if(list == null )return null;
return list.get(index);
}
// NB only mongo_id is supported in this impl.
private static AssociatedContent getByFieldValue(List<? extends AssociatedContent> list, String field, Object value) {
for(AssociatedContent c: list) {
switch(field) {
case Paths.MONGO_ID : {
if(c.getMongo_id()!=null&&c.getMongo_id().equals(value))
return c;
}
}
}
return null;
}
@Override
public void setAtPath(AssociatedContent toSet, String path) {
switch(path) {
case Paths.RELAZIONE : {
setRelazioneScavo((RelazioneScavo) toSet);
break;
}
case Paths.POSIZIONAMENTO : {
setPosizionamentoScavo((LayerConcessione) toSet);
break;
}
case Paths.ABSTRACT_RELAZIONE:{
setAbstractRelazione((AbstractRelazione)toSet);
break;
}
case Paths.PIANTE : {
if(pianteFineScavo==null)pianteFineScavo=new ArrayList<LayerConcessione>();
pianteFineScavo.add((LayerConcessione) toSet);
break;
}
case Paths.IMMAGINI: {
if(immaginiRappresentative==null)immaginiRappresentative=new ArrayList<UploadedImage>();
pianteFineScavo.add((LayerConcessione) toSet);
break;
}
//TODO MATCH if()case Paths.PIANTa : return
//TODO MATCH if()case Paths.Img : return
}
}
@Override
public ValidationReport validate() {
ValidationReport validator= super.validate();
@ -117,8 +224,7 @@ public class Concessione extends Record{
validator.checkMandatory(paroleChiaveLibere, "Parole chiave libere");
validator.checkMandatory(responsabile,"Responsabile");
validator.checkMandatory(titolareCopyright, "Titolare Copyright");
validator.checkMandatory(titolareLicenza,"Titolare licenza");
@ -127,12 +233,13 @@ public class Concessione extends Record{
if(validator.checkMandatory(relazioneScavo, "Relazione scavo")) {
validator.addChild(relazioneScavo.validateForInsertion());
}
if(validator.checkMandatory(abstractRelazione,"Abstract Relazione")){
validator.addChild(abstractRelazione.validateForInsertion());
}
// if(immaginiRappresentative!=null)
//
// for(UploadedImage img : immaginiRappresentative) {
@ -196,6 +303,13 @@ public class Concessione extends Record{
relazioneScavo.setPolicy(getPolicy());
}
if(abstractRelazione!=null) {
abstractRelazione.setTitolo(ConstraintCheck.defaultFor(abstractRelazione.getTitolo(),getNome()+" abstract relazione di scavo").evaluate());
abstractRelazione.setCreationTime(ConstraintCheck.defaultFor(abstractRelazione.getCreationTime(),getCreationTime()).evaluate());
abstractRelazione.setLicenseID(ConstraintCheck.defaultFor(getLicenzaID(), "CC-BY-4.0").evaluate());
abstractRelazione.setPolicy(getPolicy());
}
if(immaginiRappresentative!=null)
for(UploadedImage img : immaginiRappresentative) {
@ -243,7 +357,7 @@ public class Concessione extends Record{
l.setParoleChiaveLibere(ConstraintCheck.defaultFor(l.getParoleChiaveLibere(),getParoleChiaveLibere()).evaluate());
l.setParoleChiaveICCD(ConstraintCheck.defaultFor(l.getParoleChiaveICCD(),getParoleChiaveICCD()).evaluate());
//TODO Evaluate
l.setBbox(ConstraintCheck.defaultFor(l.getBbox(), BBOX.WORLD_EXTENT).evaluate());
l.setPolicy(ConstraintCheck.defaultFor(l.getPolicy(),getPolicy()).evaluate());;
@ -308,70 +422,17 @@ public class Concessione extends Record{
if (getClass() != obj.getClass())
return false;
Concessione other = (Concessione) obj;
// if (authors == null) {
// if (other.authors != null)
// return false;
// } else if (!authors.equals(other.authors))
// return false;
if(!CollectionsUtils.equalsCollections(authors, other.authors)) return false;
// if (fontiFinanaziamento == null) {
// if (other.fontiFinanaziamento != null)
// return false;
// } else if (!fontiFinanaziamento.equals(other.fontiFinanaziamento))
// return false;
if (!CollectionsUtils.equalsCollections(fontiFinanziamento, other.fontiFinanziamento)) return false;
// if (immaginiRappresentative == null) {
// if (other.immaginiRappresentative != null)
// return false;
// } else if (!immaginiRappresentative.equals(other.immaginiRappresentative))
// return false;
if (!CollectionsUtils.equalsCollections(immaginiRappresentative, other.immaginiRappresentative)) return false;
// if (paroleChiaveICCD == null) {
// if (other.paroleChiaveICCD != null)
// return false;
// } else if (!paroleChiaveICCD.equals(other.paroleChiaveICCD))
// return false;
if (!CollectionsUtils.equalsCollections(paroleChiaveICCD, other.paroleChiaveICCD)) return false;
// if (paroleChiaveLibere == null) {
// if (other.paroleChiaveLibere != null)
// return false;
// } else if (!paroleChiaveLibere.equals(other.paroleChiaveLibere))
// return false;
if (!CollectionsUtils.equalsCollections(paroleChiaveLibere, other.paroleChiaveLibere)) return false;
// if (piantaFineScavo == null) {
// if (other.piantaFineScavo != null)
// return false;
// } else if (!piantaFineScavo.equals(other.piantaFineScavo))
// return false;
if (!CollectionsUtils.equalsCollections(pianteFineScavo, other.pianteFineScavo)) return false;
// if (risorseCorrelate == null) {
// if (other.risorseCorrelate != null)
// return false;
// } else if (!risorseCorrelate.equals(other.risorseCorrelate))
// return false;
if (!CollectionsUtils.equalsCollections(risorseCorrelate, other.risorseCorrelate)) return false;
// if (soggetto == null) {
// if (other.soggetto != null)
// return false;
// } else if (!soggetto.equals(other.soggetto))
// return false;
if (!CollectionsUtils.equalsCollections(soggetto, other.soggetto)) return false;
// if (titolari == null) {
// if (other.titolari != null)
// return false;
// } else if (!titolari.equals(other.titolari))
// return false;
if (!CollectionsUtils.equalsCollections(titolari, other.titolari)) return false;
if (centroidLat == null) {
if (other.centroidLat != null)
return false;
@ -448,5 +509,4 @@ public class Concessione extends Record{
}
}

View File

@ -22,7 +22,7 @@ public class LayerConcessione extends SDILayerDescriptor{
//layer
private String layerName;
private String wmsLink;
private String workspace;
//1.Identificazione

View File

@ -17,6 +17,7 @@ import lombok.ToString;
public abstract class Record {
private String mongo_id;
//Generic Info
private long id;
@ -41,7 +42,7 @@ public abstract class Record {
private ValidationReport report;
public ValidationReport validate() {
@ -50,8 +51,9 @@ public abstract class Record {
validator.checkMandatory(getRecordType(), "Record Type");
validator.checkMandatory(getNome(), "Nome");
return validator;
setReport(validator);
return getReport();
}
public void setDefaults() {
@ -65,6 +67,8 @@ public abstract class Record {
setLicenzaID(ConstraintCheck.defaultFor(getLicenzaID(),"CC-BY").evaluate());
}
public abstract AssociatedContent getContentByPath(String path);
public abstract void setAtPath(AssociatedContent toSet,String path);
}

View File

@ -16,8 +16,7 @@ public class RelazioneScavo extends AssociatedContent {
private String abstractSection;
private List<String> responsabili;
private List<String> soggetto;
@ -36,10 +35,7 @@ public class RelazioneScavo extends AssociatedContent {
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + ((abstractSection == null) ? 0 : abstractSection.hashCode());
// result = prime * result + ((responsabili == null) ? 0 : responsabili.hashCode());
result = prime * result + CollectionsUtils.hashCode(responsabili);
// result = prime * result + ((soggetto == null) ? 0 : soggetto.hashCode());
result = prime * result + CollectionsUtils.hashCode(soggetto);
return result;
}
@ -53,27 +49,11 @@ public class RelazioneScavo extends AssociatedContent {
if (getClass() != obj.getClass())
return false;
RelazioneScavo other = (RelazioneScavo) obj;
if (abstractSection == null) {
if (other.abstractSection != null)
return false;
} else if (!abstractSection.equals(other.abstractSection))
return false;
// if (responsabili == null) {
// if (other.responsabili != null)
// return false;
// } else if (!responsabili.equals(other.responsabili))
// return false;
if(!CollectionsUtils.equalsCollections(responsabili, other.responsabili)) return false;
// if (soggetto == null) {
// if (other.soggetto != null)
// return false;
// } else if (!soggetto.equals(other.soggetto))
// return false;
if(!CollectionsUtils.equalsCollections(soggetto, other.soggetto)) return false;
return true;
}

View File

@ -18,5 +18,8 @@ public abstract class SDILayerDescriptor extends AssociatedContent{
public abstract String getWmsLink();
public abstract void setWmsLink(String wmsLink);
public abstract void setWorkspace(String workspace);
public abstract String getWorkspace();
public abstract BBOX getBbox();
public abstract void setBbox(BBOX toSet);
}

View File

@ -15,4 +15,5 @@ public class WorkspaceContent extends PersistedContent{
private String mimetype;
private String storageID;
private String link;
private String name;
}

View File

@ -5,11 +5,19 @@ import java.util.ArrayList;
import java.util.List;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
public class ValidationReport implements Serializable{
/**
*
*/
private static final long serialVersionUID = -3629142756787381094L;
public static enum ValidationStatus{
PASSED, ERROR, WARNING
}

View File

@ -31,17 +31,13 @@ public class Project {
*
*/
public static enum Status{
VALID,INVALID,PUBLISHED
}
private String _id;
private String profile_id;
private PublicationDetails publication;
private Status status;
private BasicJSONObject document;
private Object document;
private Centroid centroid;
private PublicationDetails publication;
private String json;
}

View File

@ -0,0 +1,11 @@
package org.gcube.application.geoportal.common.model.project;
import java.util.List;
public class Status {
private StatusPhase phase;
private List<String> messages;
}

View File

@ -0,0 +1,13 @@
package org.gcube.application.geoportal.common.model.project;
public enum StatusPhase {
DRAFT,
UNDER_VALIDATION,
INVALID,
VALID,
UNDER_PUBLICATION,
PUBLICATION_ERROR,
PUBLISHED
}

View File

@ -0,0 +1,4 @@
package org.gcube.application.geoportal.common.model.project;

View File

@ -0,0 +1,21 @@
package org.gcube.application.geoportal.common.model.rest;
import java.util.List;
import javax.xml.bind.annotation.XmlRootElement;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.gcube.application.geoportal.common.rest.TempFile;
@XmlRootElement
@Data
@AllArgsConstructor
@NoArgsConstructor
public class AddSectionToConcessioneRequest {
private String destinationPath;
private List<TempFile> streams;
}

View File

@ -0,0 +1,15 @@
package org.gcube.application.geoportal.common.model.rest;
import lombok.Data;
@Data
public class Configuration {
// Index (postgis + layer) Configuration
public PostgisIndexDescriptor index;
// Mongo DB Configuration
// TBD
}

View File

@ -0,0 +1,16 @@
package org.gcube.application.geoportal.common.model.rest;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class DatabaseConnection {
private String user;
private String pwd;
private String url;
}

View File

@ -0,0 +1,13 @@
package org.gcube.application.geoportal.common.model.rest;
import lombok.AllArgsConstructor;
import lombok.Data;
@Data
@AllArgsConstructor
public class PostgisIndexDescriptor {
public DatabaseConnection postgisDBIndex;
public String wmsLink;
}

View File

@ -0,0 +1,28 @@
package org.gcube.application.geoportal.common.model.rest;
import lombok.Data;
import org.bson.Document;
import java.util.List;
@Data
public class QueryRequest {
@Data
public static class PagedRequest{
private int offset;
private int Limit;
}
@Data
public static class OrderedRequest {
public static enum Direction {ASCENDING,DESCENDING}
private Direction direction;
private String json;
private List<String> fields;
}
private Document filter;
private Document projection;
private OrderedRequest ordering;
private PagedRequest paging;
}

View File

@ -1,19 +0,0 @@
package org.gcube.application.geoportal.common.rest;
import java.util.List;
import javax.xml.bind.annotation.XmlRootElement;
import org.gcube.application.geoportal.common.model.legacy.AssociatedContent;
import org.gcube.application.geoportal.common.model.legacy.InputStreamDescriptor;
import lombok.Data;
@XmlRootElement
@Data
public class AddSectionToConcessioneRequest {
private AssociatedContent toRegister;
private List<InputStreamDescriptor> streams;
}

View File

@ -15,6 +15,16 @@ public class InterfaceConstants {
public static final String PROJECTS="projects";
public static final String CONCESSIONI="concessioni";
public static final String MONGO_CONCESSIONI="mongo-concessioni";
public static final String PUBLISH_PATH="publish";
public static final String REGISTER_FILES_PATH="registerFiles";
public static final String DELETE_FILES_PATH="deleteFiles";
public static final String CONFIGURATION_PATH="configuration";
public static final String SEARCH_PATH="search";
public static final String QUERY_PATH="query";
}
public static final class Parameters{
@ -22,10 +32,12 @@ public class InterfaceConstants {
public static final String SECTION_ID="section_id";
public static final String PROFILE_ID="profile_id";
//INVESTIGATE CAPABILITIES
public static final String ORDER_BY="order_by";
public static final String LIMIT="limit";
public static final String OFFSET="offset";
// //INVESTIGATE CAPABILITIES
// public static final String ORDER_BY="order_by";
// public static final String LIMIT="limit";
// public static final String OFFSET="offset";
public static final String FORCE="force";
}

View File

@ -0,0 +1,32 @@
package org.gcube.application.geoportal.common.rest;
import org.gcube.application.geoportal.common.model.legacy.Concessione;
import org.gcube.application.geoportal.common.model.rest.AddSectionToConcessioneRequest;
import org.gcube.application.geoportal.common.model.rest.Configuration;
import org.gcube.application.geoportal.common.model.rest.QueryRequest;
import java.util.Iterator;
public interface MongoConcessioni {
public Concessione createNew(Concessione c) throws Exception;
public void deleteById(String id) throws Exception;
public void deleteById(String id,Boolean force) throws Exception;
public Concessione getById(String id) throws Exception;
public Iterator<Concessione> getList()throws Exception;
public Concessione publish(String id) throws Exception;
public Concessione registerFileSet(String id, AddSectionToConcessioneRequest request) throws Exception;
public Concessione cleanFileSet(String id, String path) throws Exception;
public Concessione update(String id, String jsonUpdate) throws Exception;
public Concessione replace(Concessione replacement) throws Exception;
public void unPublish(String id)throws Exception;
public Configuration getCurrentConfiguration()throws Exception;
public Iterator<Concessione> search(String filter)throws Exception;
public Iterator<Concessione> query(QueryRequest request) throws Exception;
public String queryForJSON(QueryRequest request) throws Exception;
public <T> Iterator<T> queryForType(QueryRequest request,Class<T> clazz) throws Exception;
}

View File

@ -0,0 +1,19 @@
package org.gcube.application.geoportal.common.rest;
import org.gcube.application.geoportal.common.model.project.Project;
import java.util.Iterator;
public interface ProjectsI {
public Iterator<Project> getAll() throws Exception;
public Iterator<Project> getByProfile(String profileId) throws Exception;
public Project getById(String profileId,String id) throws Exception;
public Iterator<Project> getByFilter(String filter)throws Exception;
public Iterator<Project> getByFilter(String filter, String profileId)throws Exception;
public Project registrNew(String profileId, String jsonDocument)throws Exception;
public Project update(String profileId, String projectId,String jsonDocument) throws Exception;
public void deleteById(String profileId, String projectId)throws Exception;
public void deleteById(String profileId, String projectId, Boolean force)throws Exception;
}

View File

@ -0,0 +1,15 @@
package org.gcube.application.geoportal.common.rest;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class TempFile {
private String id;
private String filename;
}

View File

@ -0,0 +1,41 @@
package org.gcube.application.geoportal.common.utils;
import static org.gcube.common.authorization.client.Constants.authorizationService;
import org.gcube.common.authorization.library.AuthorizationEntry;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.scope.api.ScopeProvider;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class ContextUtils {
public static String getCurrentScope(){
try{
String token=SecurityTokenProvider.instance.get();
log.debug("Token is : "+token);
if(token==null) throw new Exception("Security Token is null");
AuthorizationEntry entry = authorizationService().get(token);
return entry.getContext();
}catch(Exception e ){
log.debug("Unable to resolve token, checking scope provider..",e);
return ScopeProvider.instance.get();
}
}
public static String getCurrentCaller(){
try{
String token=SecurityTokenProvider.instance.get();
log.debug("Token is : "+token);
if(token==null) throw new Exception("Security Token is null");
AuthorizationEntry entry = authorizationService().get(token);
return entry.getClientInfo().getId();
}catch(Exception e ){
log.debug("Unable to resolve token, checking scope provider..",e);
return "Unidentified data-transfer user";
}
}
}

View File

@ -37,5 +37,12 @@ public class Files {
}
public static String fixFilename(String toFix) {
if(toFix.contains(".")) {
String prefix=toFix.substring(toFix.lastIndexOf("."));
toFix=toFix.substring(0,toFix.lastIndexOf("."));
return toFix.toLowerCase().replaceAll("[\\*\\+\\/\\\\ \\[\\]\\(\\)\\.\\\"\\:\\;\\|]","_")+prefix;
}
return toFix.toLowerCase().replaceAll("[\\*\\+\\/\\\\ \\[\\]\\(\\)\\.\\\"\\:\\;\\|]","_");
}
}

View File

@ -0,0 +1,55 @@
package org.gcube.application.geoportal.common.utils;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.UUID;
import org.gcube.application.geoportal.common.rest.InterfaceConstants;
import org.gcube.application.geoportal.common.rest.TempFile;
import org.gcube.contentmanagement.blobstorage.service.IClient;
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
import org.gcube.contentmanager.storageclient.wrapper.AccessType;
import org.gcube.contentmanager.storageclient.wrapper.MemoryType;
import org.gcube.contentmanager.storageclient.wrapper.StorageClient;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class StorageUtils {
public static final IClient getClient(){
return new StorageClient(InterfaceConstants.SERVICE_CLASS, InterfaceConstants.SERVICE_NAME, ContextUtils.getCurrentCaller(), AccessType.SHARED, MemoryType.VOLATILE).getClient();
}
private IClient client;
public StorageUtils() {
client=getClient();
}
//return Id
public TempFile putOntoStorage(InputStream source,String filename) throws RemoteBackendException, FileNotFoundException{
log.debug("Uploading source "+filename);
String id=client.put(true).LFile(source).RFile(getUniqueString());
return new TempFile(id,filename);
}
public static final boolean checkStorageId(String id){
return getClient().getHttpUrl().RFile(id)!=null;
}
public static final String getUrlById(String id){
IClient client=getClient();
log.debug("Id is "+id);
return client.getHttpUrl().RFile(id);
}
public static final void removeById(String id){
IClient client=getClient();
client.remove().RFile(id);
}
public static final String getUniqueString(){
return UUID.randomUUID().toString();
}
}

View File

@ -0,0 +1,67 @@
package org.gcube.application.geoportal.common.model;
import static org.junit.Assert.assertEquals;
import java.util.UUID;
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;
import org.gcube.application.geoportal.common.model.legacy.RelazioneScavo;
import org.gcube.application.geoportal.common.model.legacy.UploadedImage;
import org.junit.Test;
public class PathsTest {
@Test
public void embeddedPaths() {
Concessione c=TestModel.prepareConcessione();
c=TestModel.setIds(c);
LayerConcessione p=(LayerConcessione) c.getContentByPath(Paths.POSIZIONAMENTO);
assertEquals(c.getPosizionamentoScavo(), p);
RelazioneScavo rel=(RelazioneScavo) c.getContentByPath(Paths.RELAZIONE);
assertEquals(c.getRelazioneScavo(), rel);
for(int i=0;i<c.getPianteFineScavo().size();i++) {
LayerConcessione l=(LayerConcessione) c.getContentByPath(Paths.piantaByIndex(i));
assertEquals(c.getPianteFineScavo().get(i),l);
}
for(int i=0;i<c.getImmaginiRappresentative().size();i++) {
UploadedImage l=(UploadedImage) c.getContentByPath(Paths.imgByIndex(i));
assertEquals(c.getImmaginiRappresentative().get(i),l);
}
for(int i=0;i<c.getPianteFineScavo().size();i++) {
LayerConcessione layer=c.getPianteFineScavo().get(i);
LayerConcessione l=(LayerConcessione) c.getContentByPath(Paths.piantaById(layer.getMongo_id()));
assertEquals(layer,l);
}
for(int i=0;i<c.getImmaginiRappresentative().size();i++) {
UploadedImage layer=c.getImmaginiRappresentative().get(i);
UploadedImage l=(UploadedImage) c.getContentByPath(Paths.imgById(layer.getMongo_id()));
assertEquals(layer,l);
}
System.out.println();
System.out.println();
}
}

View File

@ -48,4 +48,18 @@ public class SerializationTest {
System.out.println("Concessione is "+concessione.toString());
}
@Test
public void generic() throws JsonProcessingException, IOException {
Concessione conc=TestModel.prepareConcessione();
conc.validate();
full(conc);
}
public void full(Object obj) throws JsonProcessingException, IOException {
String asString=mapper.writeValueAsString(obj);
Object other=mapper.readerFor(obj.getClass()).readValue(asString);
}
}

View File

@ -0,0 +1,130 @@
package org.gcube.application.geoportal.common.model;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.UUID;
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.LayerConcessione;
import org.gcube.application.geoportal.common.model.legacy.RelazioneScavo;
import org.gcube.application.geoportal.common.model.legacy.UploadedImage;
public class TestModel {
private static final String rnd() {
return UUID.randomUUID().toString().replace("-", "_");
}
public static final Concessione setIds(Concessione c) {
c.setMongo_id(rnd());
c.getRelazioneScavo().setMongo_id(rnd());
c.getPosizionamentoScavo().setMongo_id(rnd());
c.getPianteFineScavo().forEach((LayerConcessione l)->{l.setMongo_id(rnd());});
c.getImmaginiRappresentative().forEach((UploadedImage i)->{i.setMongo_id(rnd());});
return c;
}
public static Concessione prepareEmptyConcessione() {
Concessione concessione=new Concessione();
// Generic fields
// Concessione fields
concessione.setNome("MONGO Italia, forse, ma su ");
concessione.setIntroduzione("This is my MONGO project");
concessione.setDescrizioneContenuto("It contains this and that");
concessione.setAuthors(Arrays.asList(new String[] {"Some one","Some, oneelse"}));
concessione.setContributore("Contrib 1");
concessione.setTitolari(Arrays.asList(new String[] {"Some one","Some, oneelse"}));
concessione.setResponsabile("Someone");
concessione.setEditore("Editore");
concessione.setFontiFinanziamento(Arrays.asList(new String[] {"Big pharma","Pentagon"}));
concessione.setSoggetto(Arrays.asList(new String[] {"Research Excavation","Archeology"}));
concessione.setDataInizioProgetto(LocalDateTime.now());
concessione.setDataFineProgetto(LocalDateTime.now());
concessione.setLicenzaID("CC-BY");
concessione.setTitolareLicenza(Arrays.asList(new String[] {"Qualcun altro"}));
concessione.setTitolareCopyright(Arrays.asList(new String[] {"Chiedilo in giro"}));
concessione.setParoleChiaveLibere(Arrays.asList(new String[] {"Robba","Stuff"}));
concessione.setParoleChiaveICCD(Arrays.asList(new String[] {"vattelapesca","somthing something"}));
concessione.setCentroidLat(43.0); //N-S
concessione.setCentroidLong(9.0); //E-W
return concessione;
}
public static Concessione prepareConcessione() {
Concessione concessione=prepareEmptyConcessione();
// Attachments
// Relazione scavo
RelazioneScavo relScavo=new RelazioneScavo();
relScavo.setAbstractEng("simple abstract section");
relScavo.setResponsabili(concessione.getAuthors());
concessione.setRelazioneScavo(relScavo);
//Immagini rappresentative
ArrayList<UploadedImage> imgs=new ArrayList<>();
for(int i=0;i<5;i++) {
UploadedImage img=new UploadedImage();
img.setTitolo("My image number "+i);
img.setDidascalia("You can see my image number "+i);
img.setFormat("TIFF");
img.setCreationTime(LocalDateTime.now());
img.setResponsabili(concessione.getAuthors());
imgs.add(img);
}
concessione.setImmaginiRappresentative(imgs);
//Posizionamento
LayerConcessione posizionamento=new LayerConcessione();
posizionamento.setValutazioneQualita("Secondo me si");
posizionamento.setMetodoRaccoltaDati("Fattobbene");
posizionamento.setScalaAcquisizione("1:10000");
posizionamento.setAuthors(concessione.getAuthors());
concessione.setPosizionamentoScavo(posizionamento);
// Piante fine scavo
ArrayList<LayerConcessione> piante=new ArrayList<LayerConcessione>();
for(int i=0;i<4;i++) {
LayerConcessione pianta=new LayerConcessione();
pianta.setValutazioneQualita("Secondo me si");
pianta.setMetodoRaccoltaDati("Fattobbene");
pianta.setScalaAcquisizione("1:10000");
pianta.setAuthors(concessione.getAuthors());
pianta.setPolicy(AccessPolicy.RESTRICTED);
piante.add(pianta);
}
concessione.setPianteFineScavo(piante);
return concessione;
}
}