added a check

This commit is contained in:
Francesco Mangiacrapa 2020-12-18 12:27:17 +01:00
parent 729c1d8f1a
commit 4a095277e9
2 changed files with 11 additions and 7 deletions

View File

@ -204,18 +204,22 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
PublicationReport report = manager.commitSafely(publish);
LOG.info("PublicationReport: " + report);
Record registered = report.getTheRecord();
if(registered==null)
throw new Exception(report.prettyPrint());
// String link = "toTest";
CommitReport cRep = new CommitReport();
cRep.setRecordId(registered.getId());
if(registered!=null)
cRep.setRecordId(registered.getId());
cRep.setReport(report.prettyPrint());
switch (report.getStatus()) {
case PASSED:
cRep.setState(STATE.OK);
if(cRep.getRecordId()==null) {
LOG.error("The record id is null!!!");
throw new Exception("Invalid record id");
}
break;
case WARNING:
cRep.setState(STATE.WARN);
@ -235,7 +239,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
} 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 {

View File

@ -29,7 +29,7 @@ public class CommitReport implements Serializable {
}
public STATE state = STATE.UNKNOWN;
public long recordId;
public Long recordId;
public String msg;
public String report;
@ -79,7 +79,7 @@ public class CommitReport implements Serializable {
*
* @return the record id
*/
public long getRecordId() {
public Long getRecordId() {
return recordId;
}