Publication fixes

This commit is contained in:
Fabio Sinibaldi 2021-01-04 16:58:40 +01:00
parent b1e88ad283
commit 2d2bb132e0
9 changed files with 34 additions and 21 deletions

View File

@ -6,8 +6,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
Mongo integration with Concessione
Project interface
TempFile management
WorkspaceContent for Concessioni-over-mongo
WorkspaceContent and publication for Concessioni-over-mongo
## [v1.0.3] 2020-11-11
Fixed HTTP method

View File

@ -98,6 +98,8 @@ public class SDIManager {
WorkspaceManager wsManager=new WorkspaceManager();
currentElement.getActualContent().forEach((PersistedContent c)->{
try {
if(c instanceof WorkspaceContent) {
@ -160,7 +162,8 @@ public class SDIManager {
GeoServerRESTPublisher publisher=gis.getCurrentGeoServer().getPublisher();
log.debug("Trying to create remote workspace : "+workspace);
createWorkspace(workspace);
createWorkspace(workspace);
log.debug("Publishing remote folder "+remoteFolder);
URL directoryPath=new URL("file:"+remoteFolder+"/"+completeFileName);

View File

@ -39,6 +39,8 @@ public class StorageClientProvider extends AbstractScopedMap<IClient>{
protected void dispose(IClient toDispose) {
try {
toDispose.close();
}catch (NullPointerException e) {
// expected if closed without uploading
}catch(Throwable t) {
log.warn(" unable to dispose "+toDispose,t);
}

View File

@ -271,6 +271,7 @@ public class ConcessioniMongoManager extends MongoManager{
log.debug("Registered "+wsContent+" for "+content);
content.getActualContent().add(wsContent);
}
content.setMongo_id(asString(new ObjectId()));
}
}

View File

@ -27,7 +27,7 @@ import org.json.JSONObject;
import lombok.extern.slf4j.Slf4j;
@Path("mongo-concessioni")
@Path(InterfaceConstants.Methods.MONGO_CONCESSIONI)
@Slf4j
public class ConcessioniOverMongo {
@ -137,7 +137,7 @@ public class ConcessioniOverMongo {
@PUT
@Produces(MediaType.APPLICATION_JSON)
@Path("/publish/{"+InterfaceConstants.Parameters.PROJECT_ID+"}")
@Path("/{"+InterfaceConstants.Methods.PUBLISH_PATH+"}/{"+InterfaceConstants.Parameters.PROJECT_ID+"}")
public String publish(@PathParam(InterfaceConstants.Parameters.PROJECT_ID) String id) {
return new GuardedMethod<String> () {
@Override
@ -151,7 +151,7 @@ public class ConcessioniOverMongo {
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Path("/registerFiles/{"+InterfaceConstants.Parameters.PROJECT_ID+"}")
@Path("/"+InterfaceConstants.Methods.REGISTER_FILES_PATH+"/{"+InterfaceConstants.Parameters.PROJECT_ID+"}")
public String registerFile(@PathParam(InterfaceConstants.Parameters.PROJECT_ID) String id,String jsonRequest) {
return new GuardedMethod<String> () {
@Override

View File

@ -1,11 +1,11 @@
package org.gcube.application.geoportal.service;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;
@ -16,28 +16,26 @@ import javax.ws.rs.core.Response;
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.report.ValidationReport;
import org.gcube.application.geoportal.common.model.legacy.LayerConcessione;
import org.gcube.application.geoportal.common.model.legacy.report.ValidationReport.ValidationStatus;
import org.gcube.application.geoportal.common.rest.AddSectionToConcessioneRequest;
import org.gcube.application.geoportal.common.rest.InterfaceConstants;
import org.gcube.application.geoportal.common.rest.TempFile;
import org.gcube.application.geoportal.common.utils.Files;
import org.gcube.application.geoportal.common.utils.StorageUtils;
import org.gcube.application.geoportal.service.legacy.TokenSetter;
import org.gcube.application.geoportal.service.utils.Serialization;
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import com.fasterxml.jackson.core.JsonProcessingException;
public class ConcessioniOverMongoTest extends BasicServiceTestUnit{
private static final String PATH="mongo-concessioni";
private static final String PATH=InterfaceConstants.Methods.MONGO_CONCESSIONI;
private static final String PUBLISH_PATH="publish";
private static final String FILES_PATH="registerFiles";
private static final String PUBLISH_PATH=InterfaceConstants.Methods.PUBLISH_PATH;
private static final String FILES_PATH=InterfaceConstants.Methods.REGISTER_FILES_PATH;
@Before
@ -151,7 +149,7 @@ public class ConcessioniOverMongoTest extends BasicServiceTestUnit{
@Test
public void publish() throws Exception {
WebTarget target=target(PATH);
Concessione c=TestModel.prepareConcessione();
Concessione c=TestModel.prepareConcessione(1,2);
c.setNome("Concessione : publish test");
@ -164,8 +162,8 @@ public class ConcessioniOverMongoTest extends BasicServiceTestUnit{
upload(target,c.getMongo_id(),Paths.RELAZIONE,"relazione.pdf");
upload(target,c.getMongo_id(),Paths.POSIZIONAMENTO,"pos.shp","pos.shx");
upload(target,c.getMongo_id(),Paths.piantaByIndex(0),"pos.shp","pos.shx");
// Clash on workspaces
upload(target,c.getMongo_id(),Paths.piantaByIndex(0),"pianta.shp","pianta.shx");
upload(target,c.getMongo_id(),Paths.imgByIndex(0),"immagine.png");
upload(target,c.getMongo_id(),Paths.imgByIndex(1),"immagine2.png");
@ -175,8 +173,15 @@ public class ConcessioniOverMongoTest extends BasicServiceTestUnit{
Concessione published=publish(target, c);
System.out.println("Published : "+published);
assertNotNull(published.getReport());
assertNotEquals(published.getReport().getStatus(),ValidationStatus.ERROR);
assertEquals(published.getReport().getStatus(),ValidationStatus.PASSED);
assertEquals(published.getImmaginiRappresentative().size(),2);
assertEquals(published.getPianteFineScavo().size(),1);
assertNotNull(published.getPosizionamentoScavo().getWmsLink());
for(LayerConcessione l : published.getPianteFineScavo())
assertNotNull(l.getWmsLink());
assertNotNull(published.getCentroidLat());
assertNotNull(published.getCentroidLong());
}

View File

@ -71,8 +71,11 @@ public class TestModel {
public static final String rnd() {
return new ObjectId().toHexString();
}
public static Concessione prepareConcessione() {
return prepareConcessione(4,2);
}
public static Concessione prepareConcessione(int pianteCount ,int imgsCount) {
Concessione concessione=prepareEmptyConcessione();
@ -89,7 +92,7 @@ public class TestModel {
concessione.setRelazioneScavo(relScavo);
//Immagini rappresentative
ArrayList<UploadedImage> imgs=new ArrayList<>();
for(int i=0;i<5;i++) {
for(int i=0;i<imgsCount;i++) {
UploadedImage img=new UploadedImage();
img.setTitolo("My image number "+i);
img.setDidascalia("You can see my image number "+i);
@ -109,7 +112,7 @@ public class TestModel {
// Piante fine scavo
ArrayList<LayerConcessione> piante=new ArrayList<LayerConcessione>();
for(int i=0;i<4;i++) {
for(int i=0;i<pianteCount;i++) {
LayerConcessione pianta=new LayerConcessione();
pianta.setValutazioneQualita("Secondo me si");
pianta.setMetodoRaccoltaDati("Fattobbene");

Binary file not shown.

Binary file not shown.