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 modelInfo = e2eSir.getService().getParameters().getNodeTemplateName();
269 String[] arrayOfInfo = modelInfo.split(":");
270 String serviceInstanceType = arrayOfInfo[0];
272 String serviceId = "";
274 RequestClient requestClient = null;
275 HttpResponse response = null;
277 long subStartTime = System.currentTimeMillis();
278 String sirRequestJson = mapReqJsonToSvcInstReq(e2eSir, requestJSON);
281 requestClient = RequestClientFactory.getRequestClient(recipeLookupResult.getOrchestrationURI(),
282 MsoPropertiesUtils.loadMsoProperties());
284 // Capture audit event
285 msoLogger.debug("MSO API Handler Posting call to BPEL engine for url: " + requestClient.getUrl());
287 response = requestClient.post(requestId, false, recipeLookupResult.getRecipeTimeout(), action.name(),
288 serviceId, null, null, null, null, serviceInstanceType, null, null, null, sirRequestJson);
290 msoLogger.recordMetricEvent(subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
291 "Successfully received response from BPMN engine", "BPMN", recipeLookupResult.getOrchestrationURI(),
293 } catch (Exception e) {
294 msoLogger.recordMetricEvent(subStartTime, MsoLogger.StatusCode.ERROR,
295 MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with BPMN engine", "BPMN",
296 recipeLookupResult.getOrchestrationURI(), null);
297 Response resp = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_GATEWAY,
298 MsoException.ServiceException, "Failed calling bpmn " + e.getMessage(),
299 ErrorNumbers.SVC_NO_SERVER_RESOURCES, null);
300 alarmLogger.sendAlarm("MsoConfigurationError", MsoAlarmLogger.CRITICAL,
301 Messages.errors.get(ErrorNumbers.NO_COMMUNICATION_TO_BPEL));
302 msoLogger.error(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "",
303 MsoLogger.ErrorCode.AvailabilityError, "Exception while communicate with BPMN engine");
304 msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError,
305 "Exception while communicate with BPMN engine");
306 msoLogger.debug("End of the transaction, the final response is: " + (String) resp.getEntity());
310 if (response == null) {
311 Response resp = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_GATEWAY,
312 MsoException.ServiceException, "bpelResponse is null", ErrorNumbers.SVC_NO_SERVER_RESOURCES, null);
313 msoLogger.error(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "",
314 MsoLogger.ErrorCode.BusinessProcesssError, "Null response from BPEL");
315 msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError,
316 "Null response from BPMN");
317 msoLogger.debug(END_OF_THE_TRANSACTION + (String) resp.getEntity());
321 ResponseHandler respHandler = new ResponseHandler(response, requestClient.getType());
322 int bpelStatus = respHandler.getStatus();
324 return beplStatusUpdate(requestId, startTime, msoRequest, requestClient, respHandler, bpelStatus);
327 private void closeCatalogDB(CatalogDatabase db) {
333 private InfraActiveRequests checkForDuplicateRecord(Action action, HashMap<String, String> instanceIdMap,
334 String instanceName, String requestScope) {
335 InfraActiveRequests dupValue = null;
336 if (!(instanceName == null && "service".equals(requestScope)
337 && (action == Action.createInstance || action == Action.activateInstance))) {
338 dupValue = (RequestsDatabase.getInstance()).checkInstanceNameDuplicate(instanceIdMap, instanceName,
344 private Response duplicateRecordFound(Action action, HashMap<String, String> instanceIdMap, long startTime,
345 MsoRequest msoRequest, InfraActiveRequests dup, String instanceName, String requestScope) {
346 String instance = null;
347 if (instanceName != null) {
348 instance = instanceName;
350 instance = instanceIdMap.get(requestScope + "InstanceId");
352 String dupMessage = "Error: Locked instance - This " + requestScope + " (" + instance + ") "
353 + "already has a request being worked with a status of " + dup.getRequestStatus() + " (RequestId - "
354 + dup.getRequestId() + "). The existing request must finish or be cleaned up before proceeding.";
356 Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_CONFLICT, MsoException.ServiceException,
357 dupMessage, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, null);
359 msoLogger.warn(MessageEnum.APIH_DUPLICATE_FOUND, dupMessage, "", "", MsoLogger.ErrorCode.SchemaError,
360 "Duplicate request - Subscriber already has a request for this service");
361 msoRequest.createRequestRecord(Status.FAILED, action);
362 msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, dupMessage);
363 msoLogger.debug(END_OF_THE_TRANSACTION + (String) response.getEntity());
367 private Response beplStatusUpdate(String requestId, long startTime, MsoRequest msoRequest,
368 RequestClient requestClient, ResponseHandler respHandler, int bpelStatus) {
369 // BPEL accepted the request, the request is in progress
370 if (bpelStatus == HttpStatus.SC_ACCEPTED) {
371 String camundaJSONResponseBody = respHandler.getResponseBody();
372 msoLogger.debug("Received from Camunda: " + camundaJSONResponseBody);
373 (RequestsDatabase.getInstance()).updateInfraStatus(requestId, Status.IN_PROGRESS.toString(),
374 Constants.PROGRESS_REQUEST_IN_PROGRESS, Constants.MODIFIED_BY_APIHANDLER);
376 msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
377 "BPMN accepted the request, the request is in progress");
378 msoLogger.debug(END_OF_THE_TRANSACTION + camundaJSONResponseBody);
379 return Response.status(HttpStatus.SC_ACCEPTED).entity(camundaJSONResponseBody).build();
381 List<String> variables = new ArrayList<>();
382 variables.add(bpelStatus + "");
383 String camundaJSONResponseBody = respHandler.getResponseBody();
384 if (camundaJSONResponseBody != null && !camundaJSONResponseBody.isEmpty()) {
385 Response resp = msoRequest.buildServiceErrorResponse(bpelStatus, MsoException.ServiceException,
386 "Request Failed due to BPEL error with HTTP Status= %1 " + '\n' + camundaJSONResponseBody,
387 ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, variables);
388 msoLogger.error(MessageEnum.APIH_BPEL_RESPONSE_ERROR, requestClient.getUrl(), "", "",
389 MsoLogger.ErrorCode.BusinessProcesssError,
390 "Response from BPEL engine is failed with HTTP Status=" + bpelStatus);
391 msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError,
392 "Response from BPMN engine is failed");
393 msoLogger.debug(END_OF_THE_TRANSACTION + (String) resp.getEntity());
396 Response resp = msoRequest.buildServiceErrorResponse(bpelStatus, MsoException.ServiceException,
397 "Request Failed due to BPEL error with HTTP Status= %1",
398 ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, variables);
399 msoLogger.error(MessageEnum.APIH_BPEL_RESPONSE_ERROR, requestClient.getUrl(), "", "",
400 MsoLogger.ErrorCode.BusinessProcesssError, "Response from BPEL engine is empty");
401 msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError,
402 "Response from BPEL engine is empty");
403 msoLogger.debug(END_OF_THE_TRANSACTION + (String) resp.getEntity());
410 * Getting recipes from catalogDb
416 private RecipeLookupResult getServiceInstanceOrchestrationURI(CatalogDatabase db, Action action) {
418 RecipeLookupResult recipeLookupResult = getServiceURI(db, action);
420 if (recipeLookupResult != null) {
421 msoLogger.debug("Orchestration URI is: " + recipeLookupResult.getOrchestrationURI()
422 + ", recipe Timeout is: " + Integer.toString(recipeLookupResult.getRecipeTimeout()));
424 msoLogger.debug("No matching recipe record found");
426 return recipeLookupResult;
430 * Getting recipes from catalogDb
436 private RecipeLookupResult getServiceURI(CatalogDatabase db, Action action) {
438 String defaultServiceModelName = "UUI_DEFAULT";
440 Service serviceRecord = db.getServiceByModelName(defaultServiceModelName);
441 ServiceRecipe recipe = db.getServiceRecipeByModelUUID(serviceRecord.getModelUUID(), action.name());
443 if (recipe == null) {
446 return new RecipeLookupResult(recipe.getOrchestrationUri(), recipe.getRecipeTimeout());
451 * Converting E2EServiceInstanceRequest to ServiceInstanceRequest and
452 * passing it to camunda engine.
457 private String mapReqJsonToSvcInstReq(E2EServiceInstanceRequest e2eSir, String requestJSON) {
459 sir = new ServiceInstancesRequest();
461 String returnString = null;
462 RequestDetails requestDetails = new RequestDetails();
463 ModelInfo modelInfo = new ModelInfo();
466 modelInfo.setModelInvariantId(e2eSir.getService().getServiceDefId());
468 // modelNameVersionId
469 modelInfo.setModelNameVersionId(e2eSir.getService().getTemplateId());
471 String modelInfoValue = e2eSir.getService().getParameters().getNodeTemplateName();
472 String[] arrayOfInfo = modelInfoValue.split(":");
473 String modelName = arrayOfInfo[0];
474 String modelVersion = arrayOfInfo[1];
477 modelInfo.setModelName(modelName);
480 modelInfo.setModelVersion(modelVersion);
483 modelInfo.setModelType(ModelType.service);
485 // setting modelInfo to requestDetails
486 requestDetails.setModelInfo(modelInfo);
488 SubscriberInfo subscriberInfo = new SubscriberInfo();
490 // globalsubscriberId
491 subscriberInfo.setGlobalSubscriberId(e2eSir.getService().getParameters().getGlobalSubscriberId());
494 subscriberInfo.setSubscriberName(e2eSir.getService().getParameters().getSubscriberName());
496 // setting subscriberInfo to requestDetails
497 requestDetails.setSubscriberInfo(subscriberInfo);
499 RequestInfo requestInfo = new RequestInfo();
502 requestInfo.setInstanceName(e2eSir.getService().getName());
505 requestInfo.setSource("UUI");
508 requestInfo.setSuppressRollback(true);
510 // setting requestInfo to requestDetails
511 requestDetails.setRequestInfo(requestInfo);
513 RequestParameters requestParameters = new RequestParameters();
515 // subscriptionServiceType
516 requestParameters.setSubscriptionServiceType("MOG");
519 List<E2EUserParam> userParams;
520 userParams = e2eSir.getService().getParameters().getRequestParameters().getUserParams();
521 List<Map<String, String>> userParamList = new ArrayList<>();
522 Map<String, String> userParamMap = new HashMap<>();
523 //complete json request updated in the camunda
524 userParamMap.put("UUIRequest", requestJSON);
525 userParamMap.put("ServiceInstanceName", e2eSir.getService().getName());
527 Map<String, String> userParamMap3 = null;
528 for (E2EUserParam userp : userParams) {
529 userParamMap.put(userp.getName(), userp.getValue());
530 userParamList.add(userParamMap);
533 requestParameters.setUserParams(userParamList);
535 // setting requestParameters to requestDetails
536 requestDetails.setRequestParameters(requestParameters);
538 sir.setRequestDetails(requestDetails);
540 // converting to string
541 ObjectMapper mapper = new ObjectMapper();
543 returnString = mapper.writeValueAsString(sir);
544 } catch (IOException e) {
545 msoLogger.debug("Exception while converting ServiceInstancesRequest object to string", e);
551 private void createOperationStatusRecord(Action action, String requestId) {
553 AbstractSessionFactoryManager requestsDbSessionFactoryManager = new RequestsDbSessionFactoryManager();
555 Session session = null;
558 session = requestsDbSessionFactoryManager.getSessionFactory().openSession();
559 session.beginTransaction();
561 // if (null == sir) {
562 // sir = new ServiceInstancesRequest();
564 OperationStatus os = new OperationStatus();
565 os.setOperation(action.name());
566 os.setOperationContent("");
567 os.setOperationId("");
570 os.setResult("Processing");
571 os.setServiceId(requestId);
573 os.setFinishedAt(new Timestamp(System.currentTimeMillis()));
574 os.setOperateAt(new Timestamp(System.currentTimeMillis()));
577 session.getTransaction().commit();
579 } catch (Exception e) {
580 msoLogger.error (MessageEnum.APIH_DB_INSERT_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception when creation record request in Operation", e);
582 if (null != session) {