|
|
|
@ -9,14 +9,12 @@ import java.util.Map;
|
|
|
|
|
import org.gcube.application.geoportal.managers.ConcessioneManager;
|
|
|
|
|
import org.gcube.application.geoportal.managers.ManagerFactory;
|
|
|
|
|
import org.gcube.application.geoportal.model.InputStreamDescriptor;
|
|
|
|
|
import org.gcube.application.geoportal.model.Record;
|
|
|
|
|
import org.gcube.application.geoportal.model.concessioni.Concessione;
|
|
|
|
|
import org.gcube.application.geoportal.model.concessioni.LayerConcessione;
|
|
|
|
|
import org.gcube.application.geoportal.model.concessioni.RelazioneScavo;
|
|
|
|
|
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.application.geoportal.model.report.PublicationReport;
|
|
|
|
|
import org.gcube.application.geoportalcommon.GeoportalCommon;
|
|
|
|
|
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
|
|
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.ConcessioniFormCardTitle;
|
|
|
|
@ -98,6 +96,18 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
|
|
|
|
|
|
|
|
|
// saving into back-end
|
|
|
|
|
manager = ManagerFactory.registerNew(concessione);
|
|
|
|
|
|
|
|
|
|
// ABSTRACT_RELAZIONE_DI_SCAVO
|
|
|
|
|
list = toMap.get(ConcessioniFormCardTitle.ABSTRACT_RELAZIONE_DI_SCAVO);
|
|
|
|
|
if (list == null || list.isEmpty() || list.get(0) == null || list.get(0).getListGDB() == null)
|
|
|
|
|
throw new Exception(
|
|
|
|
|
"Error: no data found for " + ConcessioniFormCardTitle.ABSTRACT_RELAZIONE_DI_SCAVO.getTitle());
|
|
|
|
|
|
|
|
|
|
listGDB = list.get(0).getListGDB();
|
|
|
|
|
GenericDatasetBean ards = listGDB.get(0);
|
|
|
|
|
LOG.debug("\n\n");
|
|
|
|
|
LOG.debug(ConcessioniFormCardTitle.ABSTRACT_RELAZIONE_DI_SCAVO + " building with client obj: " + ards);
|
|
|
|
|
RelazioneScavo abstractRelazioneDiScavo = ConvertToServiceModel.toAbstractRelazioneScavo(ards);
|
|
|
|
|
|
|
|
|
|
// RELAZIONE_DI_SCAVO
|
|
|
|
|
list = toMap.get(ConcessioniFormCardTitle.RELAZIONE_DI_SCAVO);
|
|
|
|
@ -109,7 +119,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
|
|
|
|
GenericDatasetBean rds = listGDB.get(0);
|
|
|
|
|
LOG.debug("\n\n");
|
|
|
|
|
LOG.debug(ConcessioniFormCardTitle.RELAZIONE_DI_SCAVO + " building with client obj: " + rds);
|
|
|
|
|
RelazioneScavo relazioneDiScavo = ConvertToServiceModel.toRelazioneScavo(rds);
|
|
|
|
|
RelazioneScavo relazioneDiScavo = ConvertToServiceModel.toRelazioneScavo(abstractRelazioneDiScavo, rds);
|
|
|
|
|
LOG.debug("Built " + ConcessioniFormCardTitle.RELAZIONE_DI_SCAVO + " as server obj: " + relazioneDiScavo);
|
|
|
|
|
// Should be only one
|
|
|
|
|
for (FileUploaded fileUploaded : rds.getFilesUploaded()) {
|
|
|
|
@ -191,37 +201,45 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
|
|
|
|
|
|
|
|
|
// If true -> data are published into the SDI
|
|
|
|
|
Boolean publish = true;
|
|
|
|
|
Concessione registered = manager.commit(publish);
|
|
|
|
|
LOG.info("Registered: " + registered);
|
|
|
|
|
String link = null;
|
|
|
|
|
try {
|
|
|
|
|
link = ((WorkspaceContent) registered.getRelazioneScavo().getActualContent().get(0)).getLink();
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
LOG.warn("Not able to check public link ", e);
|
|
|
|
|
}
|
|
|
|
|
PublicationReport report = manager.commitSafely(publish);
|
|
|
|
|
LOG.info("PublicationReport: " + report);
|
|
|
|
|
Record registered = report.getTheRecord();
|
|
|
|
|
|
|
|
|
|
// String link = "toTest";
|
|
|
|
|
CommitReport cRep = new CommitReport();
|
|
|
|
|
cRep.setRecordId(registered.getId());
|
|
|
|
|
if (link != null) {
|
|
|
|
|
|
|
|
|
|
if(registered!=null)
|
|
|
|
|
cRep.setRecordId(registered.getId());
|
|
|
|
|
|
|
|
|
|
cRep.setReport(report.prettyPrint());
|
|
|
|
|
|
|
|
|
|
switch (report.getStatus()) {
|
|
|
|
|
case PASSED:
|
|
|
|
|
cRep.setState(STATE.OK);
|
|
|
|
|
cRep.setMsg("Project saved successfully");
|
|
|
|
|
} else {
|
|
|
|
|
if(cRep.getRecordId()==null) {
|
|
|
|
|
LOG.error("The record id is null!!!");
|
|
|
|
|
throw new Exception("Invalid record id");
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case WARNING:
|
|
|
|
|
cRep.setState(STATE.WARN);
|
|
|
|
|
cRep.setMsg("Project saved with errors");
|
|
|
|
|
cRep.setMsg(report.getWarningMessages().toString());
|
|
|
|
|
break;
|
|
|
|
|
case ERROR:
|
|
|
|
|
cRep.setState(STATE.ERROR);
|
|
|
|
|
cRep.setMsg(report.getErrorMessages().toString());
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
cRep.setState(STATE.UNKNOWN);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return cRep;
|
|
|
|
|
} catch (ValidationException e1) {
|
|
|
|
|
LOG.error("Error on validating data: ", e1);
|
|
|
|
|
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());
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
LOG.error("Error on commiting data: ", e);
|
|
|
|
|
throw new Exception(
|
|
|
|
|
"Error occurred on saving data, try again or contact the support. Error: " + e.getMessage());
|
|
|
|
|
"Error occurred on saving data. Error: " + e.getMessage());
|
|
|
|
|
} finally {
|
|
|
|
|
// if(manager!=null) {
|
|
|
|
|
// try {
|
|
|
|
|