integrated the commitSafely
This commit is contained in:
parent
ae01d80937
commit
729c1d8f1a
|
@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
|
||||||
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
|
||||||
|
## [v1.2.0-SNAPSHOT] - 2020-12-18
|
||||||
|
|
||||||
|
#### Enhancements
|
||||||
|
|
||||||
|
[#20357] new requirements
|
||||||
|
|
||||||
|
|
||||||
## [v1.1.0] - 2020-12-1
|
## [v1.1.0] - 2020-12-1
|
||||||
|
|
||||||
#### Enhancements
|
#### Enhancements
|
||||||
|
|
|
@ -255,10 +255,14 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
||||||
case WARN:
|
case WARN:
|
||||||
alert.setType(AlertType.WARNING);
|
alert.setType(AlertType.WARNING);
|
||||||
geoNaMainForm.enableButtonSave(true);
|
geoNaMainForm.enableButtonSave(true);
|
||||||
|
if(result.getReport()!=null)
|
||||||
|
modal.add(new Alert(result.getReport(), AlertType.INFO));
|
||||||
break;
|
break;
|
||||||
case ERROR:
|
case ERROR:
|
||||||
alert.setType(AlertType.ERROR);
|
alert.setType(AlertType.ERROR);
|
||||||
geoNaMainForm.enableButtonSave(true);
|
geoNaMainForm.enableButtonSave(true);
|
||||||
|
if(result.getReport()!=null)
|
||||||
|
modal.add(new Alert(result.getReport(), AlertType.INFO));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -9,14 +9,12 @@ import java.util.Map;
|
||||||
import org.gcube.application.geoportal.managers.ConcessioneManager;
|
import org.gcube.application.geoportal.managers.ConcessioneManager;
|
||||||
import org.gcube.application.geoportal.managers.ManagerFactory;
|
import org.gcube.application.geoportal.managers.ManagerFactory;
|
||||||
import org.gcube.application.geoportal.model.InputStreamDescriptor;
|
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.Concessione;
|
||||||
import org.gcube.application.geoportal.model.concessioni.LayerConcessione;
|
import org.gcube.application.geoportal.model.concessioni.LayerConcessione;
|
||||||
import org.gcube.application.geoportal.model.concessioni.RelazioneScavo;
|
import org.gcube.application.geoportal.model.concessioni.RelazioneScavo;
|
||||||
import org.gcube.application.geoportal.model.content.UploadedImage;
|
import org.gcube.application.geoportal.model.content.UploadedImage;
|
||||||
import org.gcube.application.geoportal.model.content.WorkspaceContent;
|
import org.gcube.application.geoportal.model.report.PublicationReport;
|
||||||
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.geoportalcommon.GeoportalCommon;
|
import org.gcube.application.geoportalcommon.GeoportalCommon;
|
||||||
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
|
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
|
||||||
import org.gcube.portlets.user.geoportaldataentry.client.ConcessioniFormCardTitle;
|
import org.gcube.portlets.user.geoportaldataentry.client.ConcessioniFormCardTitle;
|
||||||
|
@ -203,33 +201,37 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
||||||
|
|
||||||
// If true -> data are published into the SDI
|
// If true -> data are published into the SDI
|
||||||
Boolean publish = true;
|
Boolean publish = true;
|
||||||
Concessione registered = manager.commit(publish);
|
PublicationReport report = manager.commitSafely(publish);
|
||||||
LOG.info("Registered: " + registered);
|
LOG.info("PublicationReport: " + report);
|
||||||
String link = null;
|
Record registered = report.getTheRecord();
|
||||||
try {
|
|
||||||
link = ((WorkspaceContent) registered.getRelazioneScavo().getActualContent().get(0)).getLink();
|
if(registered==null)
|
||||||
} catch (Exception e) {
|
throw new Exception(report.prettyPrint());
|
||||||
LOG.warn("Not able to check public link ", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
// String link = "toTest";
|
// String link = "toTest";
|
||||||
CommitReport cRep = new CommitReport();
|
CommitReport cRep = new CommitReport();
|
||||||
cRep.setRecordId(registered.getId());
|
cRep.setRecordId(registered.getId());
|
||||||
if (link != null) {
|
cRep.setReport(report.prettyPrint());
|
||||||
|
|
||||||
|
switch (report.getStatus()) {
|
||||||
|
case PASSED:
|
||||||
cRep.setState(STATE.OK);
|
cRep.setState(STATE.OK);
|
||||||
cRep.setMsg("Project saved successfully");
|
break;
|
||||||
} else {
|
case WARNING:
|
||||||
cRep.setState(STATE.WARN);
|
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;
|
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) {
|
} catch (Exception e) {
|
||||||
LOG.error("Error on commiting data: ", e);
|
LOG.error("Error on commiting data: ", e);
|
||||||
throw new Exception(
|
throw new Exception(
|
||||||
|
|
Loading…
Reference in New Issue