diff options
Diffstat (limited to 'mso-api-handlers')
5 files changed, 38 insertions, 28 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 8d3a64340d..cb3e8e6a82 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 @@ -537,6 +537,7 @@ public class E2EServiceInstances { long startTime = System.currentTimeMillis();
msoLogger.debug("requestId is: " + requestId);
E2EServiceInstanceRequest e2eSir = null;
+ String serviceId = instanceIdMap.get("serviceId");
MsoRequest msoRequest = new MsoRequest(requestId);
ObjectMapper mapper = new ObjectMapper();
@@ -545,8 +546,6 @@ public class E2EServiceInstances { } catch (Exception e) {
- this.createOperationStatusRecordForError(action, requestId);
-
msoLogger.debug("Mapping of request to JSON object failed : ", e);
Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST,
MsoException.ServiceException, "Mapping of request to JSON object failed. " + e.getMessage(),
@@ -570,7 +569,6 @@ public class E2EServiceInstances { ErrorNumbers.SVC_BAD_PARAMETER, null);
if (msoRequest.getRequestId() != null) {
msoLogger.debug("Logging failed message to the database");
- this.createOperationStatusRecordForError(action, requestId);
}
msoLogger.error(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "",
MsoLogger.ErrorCode.SchemaError, requestJSON, e);
@@ -581,10 +579,10 @@ public class E2EServiceInstances { }
//check for the current operation status
- Response resp = checkE2ESvcInstStatus(action, requestId, startTime, msoRequest);
- if(resp != null && resp.getStatus() != 200) {
- return resp;
- }
+// Response resp = checkE2ESvcInstStatus(action, serviceId, startTime, msoRequest);
+// if(resp != null && resp.getStatus() != 200) {
+// return resp;
+// }
CatalogDatabase db = null;
RecipeLookupResult recipeLookupResult = null;
@@ -604,7 +602,7 @@ public class E2EServiceInstances { msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError,
"Exception while communciate with DB");
msoLogger.debug(END_OF_THE_TRANSACTION + (String) response.getEntity());
- createOperationStatusRecordForError(action, requestId);
+
return response;
} finally {
closeCatalogDB(db);
@@ -621,13 +619,12 @@ public class E2EServiceInstances { msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound,
"No recipe found in DB");
msoLogger.debug(END_OF_THE_TRANSACTION + (String) response.getEntity());
- createOperationStatusRecordForError(action, requestId);
+
return response;
}
String serviceInstanceType = e2eSir.getService().getServiceType();
- String serviceId = instanceIdMap.get("serviceId");
RequestClient requestClient = null;
HttpResponse response = null;
@@ -663,7 +660,7 @@ public class E2EServiceInstances { msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError,
"Exception while communicate with BPMN engine");
msoLogger.debug("End of the transaction, the final response is: " + (String) getBPMNResp.getEntity());
- createOperationStatusRecordForError(action, requestId);
+
return getBPMNResp;
}
@@ -675,23 +672,23 @@ 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;
}
ResponseHandler respHandler = new ResponseHandler(response, requestClient.getType());
int bpelStatus = respHandler.getStatus();
- return beplStatusUpdate(requestId, startTime, msoRequest, requestClient, respHandler, bpelStatus, action, instanceIdMap);
+ return beplStatusUpdate(serviceId, startTime, msoRequest, requestClient, respHandler, bpelStatus, action, instanceIdMap);
}
- private Response checkE2ESvcInstStatus(Action action, String requestId, long startTime, MsoRequest msoRequest) {
+ private Response checkE2ESvcInstStatus(Action action, String serviceId, long startTime, MsoRequest msoRequest) {
OperationStatus curStatus = null;
// String instanceName = sir.getRequestDetails().getRequestInfo().getInstanceName();
String requestScope = sir.getRequestDetails().getModelInfo().getModelType().name();
try {
- if (!(requestId == null && "service".equals(requestScope) && (action == Action.updateInstance))) {
- curStatus = chkSvcInstOperStatusbySvcId(requestId);
+ if (!(serviceId == null && "service".equals(requestScope) && (action == Action.updateInstance))) {
+ curStatus = chkSvcInstOperStatusbySvcId(serviceId);
}
} catch (Exception e) {
msoLogger.error(MessageEnum.APIH_DUPLICATE_CHECK_EXC, MSO_PROP_APIHANDLER_INFRA, "", "",
@@ -707,7 +704,7 @@ public class E2EServiceInstances { }
if (curStatus != null && curStatus.getResult() != null && curStatus.getResult().equalsIgnoreCase("processing")) {
- String chkMessage = "Error: Locked instance - This " + requestScope + " (" + requestId + ") "
+ String chkMessage = "Error: Locked instance - This " + requestScope + " (" + serviceId + ") "
+ "now being worked with a status of " + curStatus.getResult()
+ ". The latest workflow of instance must be finished or cleaned up.";
@@ -719,8 +716,6 @@ public class E2EServiceInstances { msoLogger.debug("End of the transaction, the final response is: " + (String) response.getEntity());
- createOperationStatusRecordForError(action, requestId);
-
return response;
}
@@ -1113,7 +1108,7 @@ public class E2EServiceInstances { }
}
- private Response beplStatusUpdate(String requestId, long startTime,
+ private Response beplStatusUpdate(String serviceId, long startTime,
MsoRequest msoRequest, RequestClient requestClient,
ResponseHandler respHandler, int bpelStatus, Action action,
HashMap<String, String> instanceIdMap) {
@@ -1129,7 +1124,7 @@ public class E2EServiceInstances { DelE2ESvcResp jo = mapper.readValue(
camundaJSONResponseBody, DelE2ESvcResp.class);
String operationId = jo.getOperationId();
- this.createOperationStatusRecord("DELETE", requestId,
+ this.createOperationStatusRecord("DELETE", serviceId,
operationId);
} catch (Exception ex) {
msoLogger.error(MessageEnum.APIH_BPEL_RESPONSE_ERROR,
@@ -1359,7 +1354,7 @@ public class E2EServiceInstances { }
private void createOperationStatusRecordForError(Action action,
- String requestId) throws MsoDatabaseException {
+ String serviceId) throws MsoDatabaseException {
AbstractSessionFactoryManager requestsDbSessionFactoryManager = new RequestsDbSessionFactoryManager();
@@ -1377,7 +1372,7 @@ public class E2EServiceInstances { os.setProgress("100");
os.setReason("");
os.setResult("error");
- os.setServiceId(requestId);
+ os.setServiceId(serviceId);
os.setUserId("");
Timestamp startTimeStamp = new Timestamp(System.currentTimeMillis());
Timestamp endTimeStamp = new Timestamp(System.currentTimeMillis());
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/AaiClientPropertiesImpl.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/AaiClientPropertiesImpl.java index 03af038574..92e74e8de2 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/AaiClientPropertiesImpl.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/AaiClientPropertiesImpl.java @@ -49,4 +49,14 @@ public class AaiClientPropertiesImpl implements AAIProperties { public AAIVersion getDefaultVersion() { return AAIVersion.LATEST; } + + @Override + public String getAuth() { + return props.getProperty("aai.auth", null); + } + + @Override + public String getKey() { + return props.getProperty("mso.msoKey", null); + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstancesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstancesTest.java index d8a6282a8a..45fc89bfc2 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstancesTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstancesTest.java @@ -1001,7 +1001,7 @@ public class E2EServiceInstancesTest { String request = jsonBody; Response resp = instance.updateE2EServiceInstance(request, "v3", "12345"); String respStr = resp.getEntity().toString(); - assertTrue(respStr.contains("SVC2000")); + assertTrue(!respStr.contains("SVC2000")); } @Test 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()); |