diff options
Diffstat (limited to 'mso-api-handlers')
3 files changed, 14 insertions, 9 deletions
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 08fe0f856b..8d3a64340d 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 @@ -533,7 +533,7 @@ public class E2EServiceInstances { private Response updateE2EserviceInstances(String requestJSON, Action action,
HashMap<String, String> instanceIdMap, String version) {
- String requestId = instanceIdMap.get("serviceId");
+ String requestId = UUIDChecker.generateUUID(msoLogger);
long startTime = System.currentTimeMillis();
msoLogger.debug("requestId is: " + requestId);
E2EServiceInstanceRequest e2eSir = null;
@@ -627,7 +627,7 @@ public class E2EServiceInstances { String serviceInstanceType = e2eSir.getService().getServiceType();
- String serviceId = "";
+ String serviceId = instanceIdMap.get("serviceId");
RequestClient requestClient = null;
HttpResponse response = null;
@@ -675,6 +675,7 @@ public class E2EServiceInstances { msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError,
"Null response from BPMN");
msoLogger.debug(END_OF_THE_TRANSACTION + (String) getBPMNResp.getEntity());
+ this.createOperationStatusRecordForError(action, requestId);
return getBPMNResp;
}
@@ -707,9 +708,8 @@ public class E2EServiceInstances { if (curStatus != null && curStatus.getResult() != null && curStatus.getResult().equalsIgnoreCase("processing")) {
String chkMessage = "Error: Locked instance - This " + requestScope + " (" + requestId + ") "
- + "now being worked with a status of " + curStatus.getProgress() + " (ServiceName - "
- + curStatus.getServiceName()
- + "). The existing request must finish or be cleaned up before proceeding.";
+ + "now being worked with a status of " + curStatus.getResult()
+ + ". The latest workflow of instance must be finished or cleaned up.";
Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_CONFLICT,
MsoException.ServiceException, chkMessage, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, null);
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/RequestsDatabase.java b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/RequestsDatabase.java index f69378ec65..9964b93df4 100644 --- a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/RequestsDatabase.java +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/RequestsDatabase.java @@ -643,13 +643,17 @@ public class RequestsDatabase { msoLogger.debug("Execute query on infra active request table"); OperationStatus operStatus = null; + List<Object> list = null; Session session = sessionFactoryRequestDB.getSessionFactory().openSession(); try { session.beginTransaction(); - String hql = "FROM OperationStatus WHERE SERVICE_ID = :service_id"; + String hql = "FROM OperationStatus WHERE SERVICE_ID = :service_id order by OPERATE_AT desc"; Query query = session.createQuery(hql); query.setParameter("service_id", serviceId); - operStatus = (OperationStatus)query.uniqueResult(); + list = query.list(); + if(list != null && list.size() >= 1) { + operStatus = (OperationStatus) list.get(0); + } } finally { if(session != null && session.isOpen()) { diff --git a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/RequestsDatabaseTest.java b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/RequestsDatabaseTest.java index 005a28ec52..aacdd96420 100644 --- a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/RequestsDatabaseTest.java +++ b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/RequestsDatabaseTest.java @@ -33,6 +33,7 @@ import org.junit.runner.RunWith; import org.openecomp.mso.db.AbstractSessionFactoryManager; import java.util.Arrays; +import java.util.List; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -237,8 +238,8 @@ public class RequestsDatabaseTest { @Mocked Query query) throws Exception { new Expectations() {{ sessionFactoryManager.getSessionFactory().openSession(); result = session; - session.createQuery("FROM OperationStatus WHERE SERVICE_ID = :service_id"); result = query; - query.uniqueResult(); result = new OperationStatus(); + session.createQuery("FROM OperationStatus WHERE SERVICE_ID = :service_id order by OPERATE_AT desc"); result = query; + List<Object>list = query.list(); result = new OperationStatus(); }}; assertEquals(OperationStatus.class, requestsDatabase.getOperationStatusByServiceId("123").getClass()); |