This commit is contained in:
Fabio Sinibaldi 2021-09-23 16:50:33 +02:00
parent 2ff8c34f44
commit d4702fdee0
18 changed files with 123 additions and 73 deletions

View File

@ -58,38 +58,11 @@
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<!-- read JSON -->
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
</dependency>
<!-- 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> <dependency>
<groupId>ch.qos.logback</groupId> <groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId> <artifactId>logback-classic</artifactId>

View File

@ -38,11 +38,15 @@ public class Files {
} }
public static String fixFilename(String toFix) { public static String fixFilename(String toFix) {
String extension="";
if(toFix.contains(".")) { if(toFix.contains(".")) {
String prefix=toFix.substring(toFix.lastIndexOf(".")); //preserve extension
toFix=toFix.substring(0,toFix.lastIndexOf(".")); int index=toFix.indexOf(".");
return toFix.toLowerCase().replaceAll("[\\*\\+\\/\\\\ \\[\\]\\(\\)\\.\\\"\\:\\;\\|]","_")+prefix; extension=toFix.substring(index);
//only escape before extension
toFix=toFix.substring(0,toFix.indexOf("."));
} }
return toFix.toLowerCase().replaceAll("[\\*\\+\\/\\\\ \\[\\]\\(\\)\\.\\\"\\:\\;\\|]","_"); return toFix.toLowerCase().
replaceAll("[\\*\\+\\/\\\\ \\[\\]\\(\\)\\.\\\"\\:\\;\\|]","_")+extension;
} }
} }

View File

@ -0,0 +1,26 @@
package org.gcube.application.geoportal.common;
import lombok.extern.slf4j.Slf4j;
import org.gcube.application.geoportal.common.utils.Files;
import org.junit.Test;
import java.io.File;
import static org.junit.Assert.assertTrue;
@Slf4j
public class FilesTests {
@Test
public void testNames(){
for(String name : new File("../test-data/concessioni").list()){
if(name.contains(".")) {
String originalExtension = name.substring(name.indexOf("."));
String obtained = Files.fixFilename(name);
log.info(name + "->" + obtained + "[" + originalExtension + "]");
assertTrue(obtained.endsWith(originalExtension));
}
}
}
}

View File

@ -116,7 +116,11 @@ public class SDIManager {
FileContainer fc=wsManager.getFileById(wc.getStorageID()); FileContainer fc=wsManager.getFileById(wc.getStorageID());
String completeFilename=Files.fixFilename(fc.get().getName()); String completeFilename=Files.fixFilename(fc.get().getName());
String filename=completeFilename.contains(".")?completeFilename.substring(0, completeFilename.lastIndexOf(".")):completeFilename;
String filename=
completeFilename.contains(".")?
completeFilename.substring(0, completeFilename.indexOf(".")):completeFilename;
Destination destination=new Destination(completeFilename); Destination destination=new Destination(completeFilename);

View File

@ -175,13 +175,14 @@ public class ConcessioniOverMongoTest extends BasicServiceTestUnit{
} }
// @Test @Test
// public void handlePrecise() throws Exception { public void handlePrecise() throws Exception {
// WebTarget target=target(PATH); //Republishing
// String id="610415af02ad3d05b5f81ee3"; WebTarget target=target(PATH);
// publish(target,unpublish(target,id)); String id="610415af02ad3d05b5f81ee3";
// target.path(id).queryParam(InterfaceConstants.Parameters.FORCE,true).request(MediaType.APPLICATION_JSON).delete(); publish(target,unpublish(target,id));
// } target.path(id).queryParam(InterfaceConstants.Parameters.FORCE,true).request(MediaType.APPLICATION_JSON).delete();
}
@ -275,8 +276,9 @@ public class ConcessioniOverMongoTest extends BasicServiceTestUnit{
assertEquals(published.getImmaginiRappresentative().size(),2); assertEquals(published.getImmaginiRappresentative().size(),2);
assertEquals(published.getPianteFineScavo().size(),1); 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());
}
assertNotNull(published.getCentroidLat()); assertNotNull(published.getCentroidLat());
assertNotNull(published.getCentroidLong()); assertNotNull(published.getCentroidLong());
} }
@ -295,10 +297,13 @@ public class ConcessioniOverMongoTest extends BasicServiceTestUnit{
upload(storage,target,c.getMongo_id(),Paths.RELAZIONE,"relazione.pdf"); upload(storage,target,c.getMongo_id(),Paths.RELAZIONE,"relazione.pdf");
upload(storage,target,c.getMongo_id(),Paths.ABSTRACT_RELAZIONE,"relazione.pdf"); upload(storage,target,c.getMongo_id(),Paths.ABSTRACT_RELAZIONE,"relazione.pdf");
upload(storage,target,c.getMongo_id(),Paths.POSIZIONAMENTO,"pos.shp","pos.shx"); upload(storage,target,c.getMongo_id(),Paths.POSIZIONAMENTO,
TestModel.getBaseFolder().list((file,name)->{return name.startsWith("pos");}));
// Clash on workspaces // Clash on workspaces
upload(storage,target,c.getMongo_id(),Paths.piantaByIndex(0),"pianta.shp","pianta.shx"); upload(storage,target,c.getMongo_id(),Paths.piantaByIndex(0),
TestModel.getBaseFolder().list((file,name)->{return name.startsWith("pianta");}));
upload(storage,target,c.getMongo_id(),Paths.imgByIndex(0),"immagine.png"); upload(storage,target,c.getMongo_id(),Paths.imgByIndex(0),"immagine.png");
upload(storage,target,c.getMongo_id(),Paths.imgByIndex(1),"immagine2.png"); upload(storage,target,c.getMongo_id(),Paths.imgByIndex(1),"immagine2.png");

View File

@ -39,4 +39,10 @@ public class SDITests {
Assert.assertTrue(dbMatcher.find()); Assert.assertTrue(dbMatcher.find());
System.out.println("DB :\t"+dbMatcher.group()); System.out.println("DB :\t"+dbMatcher.group());
} }
@Test
public void registerFileSet(){
}
} }

View File

@ -1,31 +1,46 @@
package org.gcube.application.geoportal.service.ws; package org.gcube.application.geoportal.service.ws;
import org.gcube.application.geoportal.service.TokenSetter; import org.gcube.application.geoportal.service.TokenSetter;
import org.gcube.common.storagehub.client.dsl.FolderContainer;
import org.gcube.common.storagehub.client.dsl.StorageHubClient; 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.*;
public class DescribeWSFolder { public class DescribeWSFolder {
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 folderID="fea4a885-7e60-4294-83d0-82162e7462f4"; String folderID="28774602-6423-4870-9afb-f8f4b585b438";
Boolean recursive = true;
TokenSetter.set(context); TokenSetter.set(context);
StorageHubClient shc = new StorageHubClient(); shc= new StorageHubClient();
FolderItem folder=shc.open(folderID).asFolder().get(); FolderContainer folder=shc.open(folderID).asFolder();
System.out.println("PATH : "+folder.getPath()); FolderItem item=folder.get();
System.out.println("HIDDEN : "+folder.isHidden()); System.out.print("PATH : "+item.getPath()+"\tHIDDEN : "+item.isHidden()+"\tDescription : "+item.getDescription());
System.out.println("Description : "+folder.getDescription());
System.out.println("Listing... "); System.out.println("Listing... ");
for (Item item : shc.open(folderID).asFolder().list().getItems()) { print(folder,"");
System.out.println("name:" + item.getName() + " is a File?: " + (item instanceof AbstractFileItem)); // for (Item i : folder.list().includeHidden().getItems()) {
System.out.println("name:" + item.getName() + " is a folder?: " + (item instanceof FolderItem)); // System.out.println("name:" + i.getName() + " type " + i.getPrimaryType());
System.out.println("name:" + item.getName() + " is a shared folder?: " + (item instanceof SharedFolder)); //
System.out.println("name:" + item.getName() + " is a VRE folder?: " + (item instanceof VreFolder)); //// System.out.println("name:" + i.getName() + " is a File?: " + (i instanceof AbstractFileItem));
//// System.out.println("name:" + i.getName() + " is a folder?: " + (i instanceof FolderItem));
//// System.out.println("name:" + i.getName() + " is a shared folder?: " + (i instanceof SharedFolder));
//// System.out.println("name:" + i.getName() + " is a VRE folder?: " + (i instanceof VreFolder));
// }
}
private static final void print(FolderContainer folder,String pad) throws StorageHubException {
for (Item i : folder.list().includeHidden().getItems()) {
System.out.println(pad+"name:" + i.getName() + " type " + i.getPrimaryType());
if(i instanceof FolderItem){
print(shc.open(i.getId()).asFolder(),pad+"\t");
}
} }
} }
} }

View File

@ -5,7 +5,10 @@ public class DisplayWorkspaceTree {
public static void main(String[] args) { public static void main(String[] args) {
String context="/gcube/devsec/devVRE"; String context="/gcube/devsec/devVRE";
String folderId=null; // NB null == String folderId=null;
// NB null ==
} }

View File

@ -0,0 +1 @@
UTF-8

Binary file not shown.

View File

@ -0,0 +1 @@
GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<metadata xml:lang="en"><Esri><CreaDate>20200224</CreaDate><CreaTime>09370600</CreaTime><ArcGISFormat>1.0</ArcGISFormat><SyncOnce>TRUE</SyncOnce><DataProperties><lineage><Process ToolSource="c:\program files (x86)\arcgis\desktop10.6\ArcToolbox\Toolboxes\Data Management Tools.tbx\Project" Date="20200224" Time="093706">Project MAG_Anomalies F:\PROGETTI\Vulci\CONSEGNA_WGS84\Mag_anomalies_WGS84.shp GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]] Monte_Mario_To_WGS_1984_4 PROJCS['Monte_Mario_Italy_2',GEOGCS['GCS_Monte_Mario',DATUM['D_Monte_Mario',SPHEROID['International_1924',6378388.0,297.0]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Transverse_Mercator'],PARAMETER['False_Easting',2520000.0],PARAMETER['False_Northing',0.0],PARAMETER['Central_Meridian',15.0],PARAMETER['Scale_Factor',0.9996],PARAMETER['Latitude_Of_Origin',0.0],UNIT['Meter',1.0]] NO_PRESERVE_SHAPE # NO_VERTICAL</Process></lineage></DataProperties></Esri></metadata>

Binary file not shown.

View File

@ -0,0 +1,28 @@
package org.gcube.application.cms.usecases;
import org.gcube.application.cms.tests.TokenSetter;
import org.gcube.application.geoportal.client.legacy.ConcessioniManagerI;
import org.gcube.application.geoportal.common.model.legacy.Concessione;
import org.gcube.application.geoportal.common.rest.MongoConcessioni;
import static org.gcube.application.geoportal.client.GeoportalAbstractPlugin.mongoConcessioni;
public class RepublishSingle {
public static void main(String[] args) throws Exception {
TokenSetter.set("/gcube/devsec/devVRE");
String id="6138c3a002ad3d1f0cd659f4";
MongoConcessioni manager=mongoConcessioni().build();
manager.unPublish(id);
System.out.println("Going to publish... ");
Concessione c=manager.publish(id);
System.out.println("Result is "+c);
System.out.println("REPORT STATUST : "+c.getReport().getStatus());
}
}

View File

@ -1,18 +0,0 @@
package org.gcube.application.cms.usecases;
import org.gcube.application.cms.tests.TokenSetter;
import org.gcube.application.geoportal.client.legacy.ConcessioniManagerI;
import static org.gcube.application.geoportal.client.GeoportalAbstractPlugin.statefulMongoConcessioni;
public class UnpublishSingle {
public static void main(String[] args) throws Exception {
TokenSetter.set("/gcube/devsec/devVRE");
ConcessioniManagerI manager=statefulMongoConcessioni().build();
manager.publish("610415af02ad3d05b5f81ee3");
}
}