2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.mso.apihandlerinfra;
23 import java.io.IOException;
24 import java.sql.Timestamp;
25 import java.util.ArrayList;
26 import java.util.HashMap;
27 import java.util.List;
30 import javax.ws.rs.Consumes;
31 import javax.ws.rs.DELETE;
32 import javax.ws.rs.POST;
33 import javax.ws.rs.Path;
34 import javax.ws.rs.PathParam;
35 import javax.ws.rs.Produces;
36 import javax.ws.rs.core.MediaType;
37 import javax.ws.rs.core.Response;
39 import org.apache.http.HttpResponse;
40 import org.apache.http.HttpStatus;
41 import org.codehaus.jackson.map.ObjectMapper;
42 import org.hibernate.Session;
44 import org.openecomp.mso.apihandler.common.ErrorNumbers;
45 import org.openecomp.mso.apihandler.common.RequestClient;
46 import org.openecomp.mso.apihandler.common.RequestClientFactory;
47 import org.openecomp.mso.apihandler.common.ResponseHandler;
48 import org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans.E2EServiceInstanceRequest;
49 import org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans.E2EUserParam;
50 import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.ModelInfo;
51 import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.RequestDetails;
52 import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.RequestInfo;
53 import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.RequestParameters;
54 import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.ServiceInstancesRequest;
55 import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.SubscriberInfo;
56 import org.openecomp.mso.db.AbstractSessionFactoryManager;
57 import org.openecomp.mso.db.catalog.CatalogDatabase;
58 import org.openecomp.mso.db.catalog.beans.Service;
59 import org.openecomp.mso.db.catalog.beans.ServiceRecipe;
60 import org.openecomp.mso.logger.MessageEnum;
61 import org.openecomp.mso.logger.MsoAlarmLogger;
62 import org.openecomp.mso.logger.MsoLogger;
63 import org.openecomp.mso.requestsdb.InfraActiveRequests;
64 import org.openecomp.mso.requestsdb.OperationStatus;
65 import org.openecomp.mso.requestsdb.RequestsDatabase;
66 import org.openecomp.mso.requestsdb.RequestsDbSessionFactoryManager;
67 import org.openecomp.mso.utils.UUIDChecker;
69 import com.wordnik.swagger.annotations.Api;
70 import com.wordnik.swagger.annotations.ApiOperation;
72 @Path("/e2eServiceInstances")
73 @Api(value = "/e2eServiceInstances", description = "API Requests for E2E Service Instances")
74 public class E2EServiceInstances {
76 private HashMap<String, String> instanceIdMap = new HashMap<>();
77 private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH);
78 private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger();
79 public static final String MSO_PROP_APIHANDLER_INFRA = "MSO_PROP_APIHANDLER_INFRA";
80 private ServiceInstancesRequest sir = null;
82 public static final String END_OF_THE_TRANSACTION = "End of the transaction, the final response is: ";
83 public static final String EXCEPTION_CREATING_DB_RECORD = "Exception while creating record in DB";
84 public static final String EXCEPTION_COMMUNICATE_BPMN_ENGINE = "Exception while communicate with BPMN engine";
87 * POST Requests for E2E Service create Instance on a version provided
91 @Path("/{version:[vV][3-5]}")
92 @Consumes(MediaType.APPLICATION_JSON)
93 @Produces(MediaType.APPLICATION_JSON)
94 @ApiOperation(value = "Create a E2E Service Instance on a version provided", response = Response.class)
95 public Response createE2EServiceInstance(String request, @PathParam("version") String version) {
97 return processE2EserviceInstances(request, Action.createInstance, null, version);
101 * DELETE Requests for E2E Service delete Instance on a specified version
106 @Path("/{version:[vV][3-5]}/{serviceId}")
107 @Consumes(MediaType.APPLICATION_JSON)
108 @Produces(MediaType.APPLICATION_JSON)
109 @ApiOperation(value = "Delete E2E Service Instance on a specified version and serviceId", response = Response.class)
110 public Response deleteE2EServiceInstance(String request, @PathParam("version") String version,
111 @PathParam("serviceId") String serviceId) {
113 instanceIdMap.put("serviceId", serviceId);
115 return processE2EserviceInstances(request, Action.deleteInstance, null, version);
118 private Response processE2EserviceInstances(String requestJSON, Action action,
119 HashMap<String, String> instanceIdMap, String version) {
121 String requestId = UUIDChecker.generateUUID(msoLogger);
122 long startTime = System.currentTimeMillis();
123 msoLogger.debug("requestId is: " + requestId);
124 E2EServiceInstanceRequest e2eSir = null;
126 MsoRequest msoRequest = new MsoRequest(requestId);
127 ObjectMapper mapper = new ObjectMapper();
129 e2eSir = mapper.readValue(requestJSON, E2EServiceInstanceRequest.class);
131 } catch (Exception e) {
133 msoLogger.debug("Mapping of request to JSON object failed : ", e);
134 Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST,
135 MsoException.ServiceException, "Mapping of request to JSON object failed. " + e.getMessage(),
136 ErrorNumbers.SVC_BAD_PARAMETER, null);
137 msoLogger.error(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "",
138 MsoLogger.ErrorCode.SchemaError, requestJSON, e);
139 msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError,
140 "Mapping of request to JSON object failed");
141 msoLogger.debug("End of the transaction, the final response is: " + (String) response.getEntity());
145 mapReqJsonToSvcInstReq(e2eSir, requestJSON);
146 sir.getRequestDetails().getRequestParameters().setaLaCarte(true);
148 msoRequest.parse(sir, instanceIdMap, action, version);
149 } catch (Exception e) {
150 msoLogger.debug("Validation failed: ", e);
151 Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST,
152 MsoException.ServiceException, "Error parsing request. " + e.getMessage(),
153 ErrorNumbers.SVC_BAD_PARAMETER, null);
154 if (msoRequest.getRequestId() != null) {
155 msoLogger.debug("Logging failed message to the database");
156 msoRequest.createRequestRecord(Status.FAILED, action);
158 msoLogger.error(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "",
159 MsoLogger.ErrorCode.SchemaError, requestJSON, e);
160 msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError,
161 "Validation of the input request failed");
162 msoLogger.debug("End of the transaction, the final response is: " + (String) response.getEntity());
166 InfraActiveRequests dup = null;
167 // String instanceName = sir.getService().getName();
168 // String requestScope = sir.getService().getParameters().getNodeType();
169 String instanceName = sir.getRequestDetails().getRequestInfo().getInstanceName();
170 String requestScope = sir.getRequestDetails().getModelInfo().getModelType().name();
172 if (!(instanceName == null && "service".equals(requestScope)
173 && (action == Action.createInstance || action == Action.activateInstance))) {
174 dup = (RequestsDatabase.getInstance()).checkInstanceNameDuplicate(instanceIdMap, instanceName,
177 } catch (Exception e) {
178 msoLogger.error(MessageEnum.APIH_DUPLICATE_CHECK_EXC, MSO_PROP_APIHANDLER_INFRA, "", "",
179 MsoLogger.ErrorCode.DataError, "Error during duplicate check ", e);
181 Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_INTERNAL_SERVER_ERROR,
182 MsoException.ServiceException, e.getMessage(), ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, null);
184 msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError,
185 "Error during duplicate check");
186 msoLogger.debug("End of the transaction, the final response is: " + (String) response.getEntity());
191 // Found the duplicate record. Return the appropriate error.
192 String instance = null;
193 if (instanceName != null) {
194 instance = instanceName;
196 instance = instanceIdMap.get(requestScope + "InstanceId");
198 String dupMessage = "Error: Locked instance - This " + requestScope + " (" + instance + ") "
199 + "already has a request being worked with a status of " + dup.getRequestStatus() + " (RequestId - "
200 + dup.getRequestId() + "). The existing request must finish or be cleaned up before proceeding.";
202 Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_CONFLICT,
203 MsoException.ServiceException, dupMessage, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, null);
205 msoLogger.warn(MessageEnum.APIH_DUPLICATE_FOUND, dupMessage, "", "", MsoLogger.ErrorCode.SchemaError,
206 "Duplicate request - Subscriber already has a request for this service");
207 msoRequest.createRequestRecord(Status.FAILED, action);
208 msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict,
210 msoLogger.debug("End of the transaction, the final response is: " + (String) response.getEntity());
214 CatalogDatabase db = null;
215 RecipeLookupResult recipeLookupResult = null;
217 db = CatalogDatabase.getInstance();
218 recipeLookupResult = getServiceInstanceOrchestrationURI(db, action);
219 } catch (Exception e) {
220 msoLogger.error(MessageEnum.APIH_DB_ACCESS_EXC, MSO_PROP_APIHANDLER_INFRA, "", "",
221 MsoLogger.ErrorCode.AvailabilityError, "Exception while communciate with Catalog DB", e);
222 msoRequest.setStatus(org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
223 Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND,
224 MsoException.ServiceException, "No communication to catalog DB " + e.getMessage(),
225 ErrorNumbers.SVC_NO_SERVER_RESOURCES, null);
226 alarmLogger.sendAlarm("MsoDatabaseAccessError", MsoAlarmLogger.CRITICAL,
227 Messages.errors.get(ErrorNumbers.NO_COMMUNICATION_TO_CATALOG_DB));
228 msoRequest.createRequestRecord(Status.FAILED, action);
229 msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError,
230 "Exception while communciate with DB");
231 msoLogger.debug(END_OF_THE_TRANSACTION + (String) response.getEntity());
237 if (recipeLookupResult == null) {
238 msoLogger.error(MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, MSO_PROP_APIHANDLER_INFRA, "", "",
239 MsoLogger.ErrorCode.DataError, "No recipe found in DB");
240 msoRequest.setStatus(org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
241 Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND,
242 MsoException.ServiceException, "Recipe does not exist in catalog DB",
243 ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null);
244 msoRequest.createRequestRecord(Status.FAILED, action);
245 msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound,
246 "No recipe found in DB");
247 msoLogger.debug(END_OF_THE_TRANSACTION + (String) response.getEntity());
253 msoRequest.createRequestRecord(Status.PENDING, action);
254 //createOperationStatusRecord(action, requestId);
255 } catch (Exception e) {
256 msoLogger.error(MessageEnum.APIH_DB_ACCESS_EXC_REASON, "Exception while creating record in DB", "", "",
257 MsoLogger.ErrorCode.SchemaError, "Exception while creating record in DB", e);
258 msoRequest.setStatus(org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
259 Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_INTERNAL_SERVER_ERROR,
260 MsoException.ServiceException, "Exception while creating record in DB " + e.getMessage(),
261 ErrorNumbers.SVC_BAD_PARAMETER, null);
262 msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError,
263 "Exception while creating record in DB");
264 msoLogger.debug("End of the transaction, the final response is: " + (String) response.getEntity());
268 String serviceInstanceType = e2eSir.getService().getParameters().getServiceType();
270 String serviceId = "";
271 RequestClient requestClient = null;
272 HttpResponse response = null;
274 long subStartTime = System.currentTimeMillis();
275 String sirRequestJson = mapReqJsonToSvcInstReq(e2eSir, requestJSON);
278 requestClient = RequestClientFactory.getRequestClient(recipeLookupResult.getOrchestrationURI(),
279 MsoPropertiesUtils.loadMsoProperties());
281 // Capture audit event
282 msoLogger.debug("MSO API Handler Posting call to BPEL engine for url: " + requestClient.getUrl());
284 response = requestClient.post(requestId, false, recipeLookupResult.getRecipeTimeout(), action.name(),
285 serviceId, null, null, null, null, serviceInstanceType, null, null, null, sirRequestJson);
287 msoLogger.recordMetricEvent(subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
288 "Successfully received response from BPMN engine", "BPMN", recipeLookupResult.getOrchestrationURI(),
290 } catch (Exception e) {
291 msoLogger.recordMetricEvent(subStartTime, MsoLogger.StatusCode.ERROR,
292 MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with BPMN engine", "BPMN",
293 recipeLookupResult.getOrchestrationURI(), null);
294 Response resp = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_GATEWAY,
295 MsoException.ServiceException, "Failed calling bpmn " + e.getMessage(),
296 ErrorNumbers.SVC_NO_SERVER_RESOURCES, null);
297 alarmLogger.sendAlarm("MsoConfigurationError", MsoAlarmLogger.CRITICAL,
298 Messages.errors.get(ErrorNumbers.NO_COMMUNICATION_TO_BPEL));
299 msoLogger.error(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "",
300 MsoLogger.ErrorCode.AvailabilityError, "Exception while communicate with BPMN engine");
301 msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError,
302 "Exception while communicate with BPMN engine");
303 msoLogger.debug("End of the transaction, the final response is: " + (String) resp.getEntity());
307 if (response == null) {
308 Response resp = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_GATEWAY,
309 MsoException.ServiceException, "bpelResponse is null", ErrorNumbers.SVC_NO_SERVER_RESOURCES, null);
310 msoLogger.error(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "",
311 MsoLogger.ErrorCode.BusinessProcesssError, "Null response from BPEL");
312 msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError,
313 "Null response from BPMN");
314 msoLogger.debug(END_OF_THE_TRANSACTION + (String) resp.getEntity());
318 ResponseHandler respHandler = new ResponseHandler(response, requestClient.getType());
319 int bpelStatus = respHandler.getStatus();
321 return beplStatusUpdate(requestId, startTime, msoRequest, requestClient, respHandler, bpelStatus);
324 private void closeCatalogDB(CatalogDatabase db) {
330 private InfraActiveRequests checkForDuplicateRecord(Action action, HashMap<String, String> instanceIdMap,
331 String instanceName, String requestScope) {
332 InfraActiveRequests dupValue = null;
333 if (!(instanceName == null && "service".equals(requestScope)
334 && (action == Action.createInstance || action == Action.activateInstance))) {
335 dupValue = (RequestsDatabase.getInstance()).checkInstanceNameDuplicate(instanceIdMap, instanceName,
341 private Response duplicateRecordFound(Action action, HashMap<String, String> instanceIdMap, long startTime,
342 MsoRequest msoRequest, InfraActiveRequests dup, String instanceName, String requestScope) {
343 String instance = null;
344 if (instanceName != null) {
345 instance = instanceName;
347 instance = instanceIdMap.get(requestScope + "InstanceId");
349 String dupMessage = "Error: Locked instance - This " + requestScope + " (" + instance + ") "
350 + "already has a request being worked with a status of " + dup.getRequestStatus() + " (RequestId - "
351 + dup.getRequestId() + "). The existing request must finish or be cleaned up before proceeding.";
353 Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_CONFLICT, MsoException.ServiceException,
354 dupMessage, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, null);
356 msoLogger.warn(MessageEnum.APIH_DUPLICATE_FOUND, dupMessage, "", "", MsoLogger.ErrorCode.SchemaError,
357 "Duplicate request - Subscriber already has a request for this service");
358 msoRequest.createRequestRecord(Status.FAILED, action);
359 msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, dupMessage);
360 msoLogger.debug(END_OF_THE_TRANSACTION + (String) response.getEntity());
364 private Response beplStatusUpdate(String requestId, long startTime, MsoRequest msoRequest,
365 RequestClient requestClient, ResponseHandler respHandler, int bpelStatus) {
366 // BPEL accepted the request, the request is in progress
367 if (bpelStatus == HttpStatus.SC_ACCEPTED) {
368 String camundaJSONResponseBody = respHandler.getResponseBody();
369 msoLogger.debug("Received from Camunda: " + camundaJSONResponseBody);
370 (RequestsDatabase.getInstance()).updateInfraStatus(requestId, Status.IN_PROGRESS.toString(),
371 Constants.PROGRESS_REQUEST_IN_PROGRESS, Constants.MODIFIED_BY_APIHANDLER);
373 msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
374 "BPMN accepted the request, the request is in progress");
375 msoLogger.debug(END_OF_THE_TRANSACTION + camundaJSONResponseBody);
376 return Response.status(HttpStatus.SC_ACCEPTED).entity(camundaJSONResponseBody).build();
378 List<String> variables = new ArrayList<>();
379 variables.add(bpelStatus + "");
380 String camundaJSONResponseBody = respHandler.getResponseBody();
381 if (camundaJSONResponseBody != null && !camundaJSONResponseBody.isEmpty()) {
382 Response resp = msoRequest.buildServiceErrorResponse(bpelStatus, MsoException.ServiceException,
383 "Request Failed due to BPEL error with HTTP Status= %1 " + '\n' + camundaJSONResponseBody,
384 ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, variables);
385 msoLogger.error(MessageEnum.APIH_BPEL_RESPONSE_ERROR, requestClient.getUrl(), "", "",
386 MsoLogger.ErrorCode.BusinessProcesssError,
387 "Response from BPEL engine is failed with HTTP Status=" + bpelStatus);
388 msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError,
389 "Response from BPMN engine is failed");
390 msoLogger.debug(END_OF_THE_TRANSACTION + (String) resp.getEntity());
393 Response resp = msoRequest.buildServiceErrorResponse(bpelStatus, MsoException.ServiceException,
394 "Request Failed due to BPEL error with HTTP Status= %1",
395 ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, variables);
396 msoLogger.error(MessageEnum.APIH_BPEL_RESPONSE_ERROR, requestClient.getUrl(), "", "",
397 MsoLogger.ErrorCode.BusinessProcesssError, "Response from BPEL engine is empty");
398 msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError,
399 "Response from BPEL engine is empty");
400 msoLogger.debug(END_OF_THE_TRANSACTION + (String) resp.getEntity());
407 * Getting recipes from catalogDb
413 private RecipeLookupResult getServiceInstanceOrchestrationURI(CatalogDatabase db, Action action) {
415 RecipeLookupResult recipeLookupResult = getServiceURI(db, action);
417 if (recipeLookupResult != null) {
418 msoLogger.debug("Orchestration URI is: " + recipeLookupResult.getOrchestrationURI()
419 + ", recipe Timeout is: " + Integer.toString(recipeLookupResult.getRecipeTimeout()));
421 msoLogger.debug("No matching recipe record found");
423 return recipeLookupResult;
427 * Getting recipes from catalogDb
433 private RecipeLookupResult getServiceURI(CatalogDatabase db, Action action) {
435 String defaultServiceModelName = "UUI_DEFAULT";
437 Service serviceRecord = db.getServiceByModelName(defaultServiceModelName);
438 ServiceRecipe recipe = db.getServiceRecipeByModelUUID(serviceRecord.getModelUUID(), action.name());
440 if (recipe == null) {
443 return new RecipeLookupResult(recipe.getOrchestrationUri(), recipe.getRecipeTimeout());
448 * Converting E2EServiceInstanceRequest to ServiceInstanceRequest and
449 * passing it to camunda engine.
454 private String mapReqJsonToSvcInstReq(E2EServiceInstanceRequest e2eSir, String requestJSON) {
456 sir = new ServiceInstancesRequest();
458 String returnString = null;
459 RequestDetails requestDetails = new RequestDetails();
460 ModelInfo modelInfo = new ModelInfo();
463 modelInfo.setModelInvariantId(e2eSir.getService().getServiceDefId());
465 // modelNameVersionId
466 modelInfo.setModelNameVersionId(e2eSir.getService().getTemplateId());
468 // String modelInfoValue = e2eSir.getService().getParameters().getNodeTemplateName();
469 // String[] arrayOfInfo = modelInfoValue.split(":");
470 // String modelName = arrayOfInfo[0];
471 // String modelVersion = arrayOfInfo[1];
472 String modelName = "voLTE";
473 String modelVersion = "1.0";
475 modelInfo.setModelName(modelName);
478 modelInfo.setModelVersion(modelVersion);
481 modelInfo.setModelType(ModelType.service);
483 // setting modelInfo to requestDetails
484 requestDetails.setModelInfo(modelInfo);
486 SubscriberInfo subscriberInfo = new SubscriberInfo();
488 // globalsubscriberId
489 subscriberInfo.setGlobalSubscriberId(e2eSir.getService().getParameters().getGlobalSubscriberId());
492 subscriberInfo.setSubscriberName(e2eSir.getService().getParameters().getSubscriberName());
494 // setting subscriberInfo to requestDetails
495 requestDetails.setSubscriberInfo(subscriberInfo);
497 RequestInfo requestInfo = new RequestInfo();
500 requestInfo.setInstanceName(e2eSir.getService().getName());
503 requestInfo.setSource("UUI");
506 requestInfo.setSuppressRollback(true);
508 // setting requestInfo to requestDetails
509 requestDetails.setRequestInfo(requestInfo);
511 RequestParameters requestParameters = new RequestParameters();
513 // subscriptionServiceType
514 requestParameters.setSubscriptionServiceType("MOG");
517 List<E2EUserParam> userParams;
518 //userParams = e2eSir.getService().getParameters().getRequestParameters().getUserParams();
519 List<Map<String, String>> userParamList = new ArrayList<>();
520 Map<String, String> userParamMap = new HashMap<>();
521 //complete json request updated in the camunda
522 userParamMap.put("UUIRequest", requestJSON);
523 userParamMap.put("ServiceInstanceName", e2eSir.getService().getName());
525 // Map<String, String> userParamMap3 = null;
526 // for (E2EUserParam userp : userParams) {
527 // userParamMap.put(userp.getName(), userp.getValue());
530 userParamList.add(userParamMap);
531 requestParameters.setUserParams(userParamList);
533 // setting requestParameters to requestDetails
534 requestDetails.setRequestParameters(requestParameters);
536 sir.setRequestDetails(requestDetails);
538 // converting to string
539 ObjectMapper mapper = new ObjectMapper();
541 returnString = mapper.writeValueAsString(sir);
542 } catch (IOException e) {
543 msoLogger.debug("Exception while converting ServiceInstancesRequest object to string", e);
549 private void createOperationStatusRecord(Action action, String requestId) {
551 AbstractSessionFactoryManager requestsDbSessionFactoryManager = new RequestsDbSessionFactoryManager();
553 Session session = null;
556 session = requestsDbSessionFactoryManager.getSessionFactory().openSession();
557 session.beginTransaction();
559 // if (null == sir) {
560 // sir = new ServiceInstancesRequest();
562 OperationStatus os = new OperationStatus();
563 os.setOperation(action.name());
564 os.setOperationContent("");
565 os.setOperationId("");
568 os.setResult("Processing");
569 os.setServiceId(requestId);
571 os.setFinishedAt(new Timestamp(System.currentTimeMillis()));
572 os.setOperateAt(new Timestamp(System.currentTimeMillis()));
575 session.getTransaction().commit();
577 } catch (Exception e) {
578 msoLogger.error (MessageEnum.APIH_DB_INSERT_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception when creation record request in Operation", e);
580 if (null != session) {