From 4a095277e9825a11d86c88c4ef15d603579361f5 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Fri, 18 Dec 2020 12:27:17 +0100 Subject: [PATCH] added a check --- .../server/GeoportalDataEntryServiceImpl.java | 14 +++++++++----- .../geoportaldataentry/shared/CommitReport.java | 4 ++-- 2 files changed, 11 insertions(+), 7 deletions(-) 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 fe87f43..5ccc559 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 @@ -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 { diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/CommitReport.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/CommitReport.java index 38ecc7d..9e0b07c 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/CommitReport.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/CommitReport.java @@ -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; }