From 8568c74e9f44d72e3cc1e8c81e4028f5ba5d254e Mon Sep 17 00:00:00 2001 From: seshukm Date: Fri, 27 Oct 2017 18:02:02 +0530 Subject: correction for the delete flow IssueId: SO-259 Change-Id: Ibb7a78bc13628ffd2c9d2569dd40542adb9f299d Signed-off-by: seshukm --- .../mso/apihandlerinfra/E2EServiceInstances.java | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'mso-api-handlers/mso-api-handler-infra/src/main/java') diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstances.java index ecd0e4d4cc..c5827046d6 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstances.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstances.java @@ -40,6 +40,7 @@ import javax.ws.rs.core.Response; import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; import org.codehaus.jackson.map.ObjectMapper; +import org.eclipse.jetty.io.RuntimeIOException; import org.hibernate.Session; import org.json.JSONObject; import org.openecomp.mso.apihandler.common.ErrorNumbers; @@ -67,6 +68,7 @@ import org.openecomp.mso.db.catalog.beans.ServiceRecipe; import org.openecomp.mso.logger.MessageEnum; import org.openecomp.mso.logger.MsoAlarmLogger; import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.properties.MsoDatabaseException; import org.openecomp.mso.requestsdb.InfraActiveRequests; import org.openecomp.mso.requestsdb.OperationStatus; import org.openecomp.mso.requestsdb.RequestsDatabase; @@ -761,7 +763,7 @@ public class E2EServiceInstances { } - private void createOperationStatusRecordForError(Action action, String requestId) { + private void createOperationStatusRecordForError(Action action, String requestId) throws MsoDatabaseException{ AbstractSessionFactoryManager requestsDbSessionFactoryManager = new RequestsDbSessionFactoryManager(); @@ -780,21 +782,24 @@ public class E2EServiceInstances { os.setResult("error"); os.setServiceId(requestId); os.setUserId(""); - os.setFinishedAt(new Timestamp(System.currentTimeMillis())); - os.setOperateAt(new Timestamp(System.currentTimeMillis())); + Timestamp startTimeStamp = new Timestamp (System.currentTimeMillis()); + Timestamp endTimeStamp = new Timestamp (System.currentTimeMillis()); + os.setFinishedAt(endTimeStamp); + os.setOperateAt(startTimeStamp); session.save(os); session.getTransaction().commit(); } catch (Exception e) { msoLogger.error (MessageEnum.APIH_DB_INSERT_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception when creation record request in Operation", e); + throw new MsoDatabaseException("Data did inserted in Operatus Status Table for failure", e); } finally { if (null != session) { session.close(); } } } - private void createOperationStatusRecord(String actionNm, String serviceId, String operationId) { + private void createOperationStatusRecord(String actionNm, String serviceId, String operationId) throws MsoDatabaseException{ AbstractSessionFactoryManager requestsDbSessionFactoryManager = new RequestsDbSessionFactoryManager(); @@ -814,14 +819,17 @@ public class E2EServiceInstances { os.setServiceId(serviceId); //TODO : to be updated... os.setUserId(""); - os.setFinishedAt(new Timestamp(System.currentTimeMillis())); - os.setOperateAt(new Timestamp(System.currentTimeMillis())); + Timestamp startTimeStamp = new Timestamp (System.currentTimeMillis()); + Timestamp endTimeStamp = new Timestamp (System.currentTimeMillis()); + os.setFinishedAt(endTimeStamp); + os.setOperateAt(startTimeStamp); session.save(os); session.getTransaction().commit(); } catch (Exception e) { msoLogger.error (MessageEnum.APIH_DB_INSERT_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception when creation record request in Operation", e); + throw new MsoDatabaseException("Data did inserted in Operatus Status Table", e); } finally { if (null != session) { session.close(); -- cgit 1.2.3-korg