From 31f2cda50a76a5c18bf2af5ef4a04db8ddb240f5 Mon Sep 17 00:00:00 2001 From: francesco Date: Fri, 30 Oct 2020 15:37:08 +0100 Subject: [PATCH] bug fixes beans mapping according to validation rules implemented on server-side --- .classpath | 1 + .../client/GeoPortalDataEntryApp.java | 2 +- .../server/ConvertToServiceModel.java | 10 +++++++ .../server/GeoportalDataEntryServiceImpl.java | 28 +++++++++---------- 4 files changed, 25 insertions(+), 16 deletions(-) diff --git a/.classpath b/.classpath index 70ce04a..ce272c8 100644 --- a/.classpath +++ b/.classpath @@ -27,6 +27,7 @@ + diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java index b908feb..ac96ec6 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java @@ -122,7 +122,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { for (GeoNaFormCardModel geonaForm : orderedCards) { //TODO TO TEST - //if(geonaForm.getFormCardTitle().equals(ConcessioniFormCardTitle.INFORMAZIONI_DI_PROGETTO)){ + //if(geonaForm.getFormCardTitle().equals(ConcessioniFormCardTitle.RELAZIONE_DI_SCAVO)){ CreateMetadataForm baseForm = new CreateMetadataForm(Arrays.asList(geonaForm.getMetadataProfileBean()),appManagerBus); geonaForm.setMetadataForm(baseForm); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/ConvertToServiceModel.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/ConvertToServiceModel.java index 0b1f25a..e3784e7 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/ConvertToServiceModel.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/ConvertToServiceModel.java @@ -205,6 +205,16 @@ public class ConvertToServiceModel { //TODO } + List politicaDiAccessoLst = mapFields.get("Politica di accesso"); + if(politicaDiAccessoLst!=null && politicaDiAccessoLst.size()>0) { + try { + AccessPolicy ap = AccessPolicy.valueOf(politicaDiAccessoLst.get(0)); + relazioneScavo.setPolicy(ap); + }catch (Exception e) { + LOG.warn("I cannot cast "+politicaDiAccessoLst.get(0) +" to "+AccessPolicy.values(),e); + } + } + List licenzaIdList = mapFields.get("ID Licenza"); if(licenzaIdList!=null && licenzaIdList.size()>0) { relazioneScavo.setLicenseID(licenzaIdList.get(0)); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/GeoportalDataEntryServiceImpl.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/GeoportalDataEntryServiceImpl.java index 354e7ad..096e3af 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/GeoportalDataEntryServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/GeoportalDataEntryServiceImpl.java @@ -16,6 +16,7 @@ import org.gcube.application.geoportal.model.content.UploadedImage; import org.gcube.application.geoportal.model.content.WorkspaceContent; import org.gcube.application.geoportal.model.fault.PublishException; import org.gcube.application.geoportal.model.fault.ValidationException; +import org.gcube.application.geoportal.utils.Serialization; import org.gcube.portlets.user.geoportaldataentry.client.ConcessioniFormCardTitle; import org.gcube.portlets.user.geoportaldataentry.client.GeoportalDataEntryService; import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport; @@ -80,6 +81,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen LOG.debug(ConcessioniFormCardTitle.INFORMAZIONI_DI_PROGETTO+" building with client obj: "+idp); Concessione concessione = ConvertToServiceModel.toConcessione(idp, user); LOG.debug("Built "+ConcessioniFormCardTitle.INFORMAZIONI_DI_PROGETTO+" as server obj: "+concessione); + //saving into back-end manager = ManagerFactory.registerNew(concessione); @@ -162,16 +164,14 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen } }catch (Exception e) { LOG.error("Error on converting form data: ",e); - throw new Exception("Error occurred on saving data, try again or contact the support"); + throw new Exception("Error occurred on saving data, try again or contact the support. Error: "+e.getMessage()); } - + try { //If true -> data are published into the SDI Boolean publish=true; - Concessione registered=manager.commit(publish); - LOG.info("Registered: "+registered); String link = null; try { @@ -195,7 +195,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen return cRep; }catch (ValidationException e1){ LOG.error("Error on validating data: ",e1); - throw new Exception("Error on validating data: "+e1.getReport().toString()); + throw new Exception("Error on validating data: "+Serialization.prettyPrint(e1.getReport())); }catch (PublishException e2) { LOG.error("Error on publishing data: ",e2); throw new Exception("Error on publishing data: "+e2.getMessage()); @@ -203,17 +203,15 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen LOG.error("Error on commiting data: ",e); throw new Exception("Error occurred on saving data, try again or contact the support. Error: "+e.getMessage()); }finally { - /*if(manager!=null) { - try { - manager.shutdown(); - }catch (Exception e) { - //silent - } - - }*/ +// if(manager!=null) { +// try { +// manager.shutdown(); +// }catch (Exception e) { +// //silent +// } +// +// } } - - } @Override