Deleted redundant code
[so.git] / mso-api-handlers / mso-api-handler-infra / src / main / java / org / openecomp / mso / apihandlerinfra / E2EServiceInstances.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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=========================================================
19  */
20
21 package org.openecomp.mso.apihandlerinfra;
22
23 import java.io.IOException;
24 import java.util.ArrayList;
25 import java.util.HashMap;
26 import java.util.List;
27 import java.util.Map;
28
29 import javax.ws.rs.Consumes;
30 import javax.ws.rs.DELETE;
31 import javax.ws.rs.GET;
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;
38
39 import org.apache.http.HttpResponse;
40 import org.apache.http.HttpStatus;
41 import org.codehaus.jackson.map.ObjectMapper;
42 import org.openecomp.mso.apihandler.common.ErrorNumbers;
43 import org.openecomp.mso.apihandler.common.RequestClient;
44 import org.openecomp.mso.apihandler.common.RequestClientFactory;
45 import org.openecomp.mso.apihandler.common.ResponseHandler;
46 import org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans.E2EServiceInstanceRequest;
47 import org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans.E2EUserParam;
48 import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.ModelInfo;
49 import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.RequestDetails;
50 import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.RequestInfo;
51 import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.RequestParameters;
52 import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.ServiceInstancesRequest;
53 import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.SubscriberInfo;
54 import org.openecomp.mso.db.catalog.CatalogDatabase;
55 import org.openecomp.mso.db.catalog.beans.Service;
56 import org.openecomp.mso.db.catalog.beans.ServiceRecipe;
57 import org.openecomp.mso.logger.MessageEnum;
58 import org.openecomp.mso.logger.MsoAlarmLogger;
59 import org.openecomp.mso.logger.MsoLogger;
60 import org.openecomp.mso.requestsdb.InfraActiveRequests;
61 import org.openecomp.mso.requestsdb.RequestsDatabase;
62 import org.openecomp.mso.utils.UUIDChecker;
63
64 import com.wordnik.swagger.annotations.Api;
65 import com.wordnik.swagger.annotations.ApiOperation;
66
67 @Path("/e2eServiceInstances")
68 @Api(value="/e2eServiceInstances",description="API Requests for E2E Service Instances")
69 public class E2EServiceInstances {
70
71         private HashMap<String, String> instanceIdMap = new HashMap<String,String>();
72         private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH);
73         private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger ();
74         public final static String MSO_PROP_APIHANDLER_INFRA = "MSO_PROP_APIHANDLER_INFRA";
75
76         public E2EServiceInstances() {
77         }
78         
79         /**
80      *POST Requests for E2E Service create Instance on a version provided
81      */
82
83         @POST
84         @Path("/{version:[vV][3-5]}")
85         @Consumes(MediaType.APPLICATION_JSON)
86         @Produces(MediaType.APPLICATION_JSON)
87         @ApiOperation(value="Create a E2E Service Instance on a version provided",response=Response.class)
88         public Response createE2EServiceInstance(String request, @PathParam("version") String version) {
89
90         return E2EserviceInstances(request, Action.createInstance,      null, version);
91         }
92
93         /**
94      *DELETE Requests for E2E Service delete Instance on a specified version and serviceId
95      */
96         
97         @DELETE
98         @Path("/{version:[vV][3-5]}/{serviceId}")
99         @Consumes(MediaType.APPLICATION_JSON)
100         @Produces(MediaType.APPLICATION_JSON)
101         @ApiOperation(value="Delete E2E Service Instance on a specified version and serviceId",response=Response.class)
102         public Response deleteE2EServiceInstance(String request, @PathParam("version") String version, @PathParam("serviceId") String serviceId) {
103
104         instanceIdMap.put("serviceId", serviceId);
105
106         return E2EserviceInstances(request, Action.deleteInstance, null, version);
107         }
108         
109         private Response E2EserviceInstances(String requestJSON, Action action,
110         HashMap<String, String> instanceIdMap, String version) {
111
112                 String requestId = UUIDChecker.generateUUID(msoLogger);
113                 long startTime = System.currentTimeMillis();
114                 msoLogger.debug("requestId is: " + requestId);
115                 E2EServiceInstanceRequest sir = null;
116
117                 MsoRequest msoRequest = new MsoRequest(requestId);
118                 ObjectMapper mapper = new ObjectMapper();
119                 try {
120                         sir = mapper
121                                         .readValue(requestJSON, E2EServiceInstanceRequest.class);
122
123                 } catch (Exception e) {
124
125                         msoLogger.debug("Mapping of request to JSON object failed : ", e);
126                         Response response = msoRequest.buildServiceErrorResponse(
127                                         HttpStatus.SC_BAD_REQUEST,
128                                         MsoException.ServiceException,
129                                         "Mapping of request to JSON object failed.  "
130                                                         + e.getMessage(), ErrorNumbers.SVC_BAD_PARAMETER,
131                                                         null);
132                         msoLogger.error(MessageEnum.APIH_REQUEST_VALIDATION_ERROR,
133                                         MSO_PROP_APIHANDLER_INFRA, "", "",
134                                         MsoLogger.ErrorCode.SchemaError, requestJSON, e);
135                         msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
136                                         MsoLogger.ResponseCode.SchemaError,
137                                         "Mapping of request to JSON object failed");
138                         msoLogger.debug("End of the transaction, the final response is: "
139                                         + (String) response.getEntity());
140                         return response;
141                 }
142
143                 InfraActiveRequests dup = null;
144                 String instanceName = sir.getService().getName();
145                 String requestScope = sir.getService().getParameters().getNodeType();
146
147                 try {
148                         if(!(instanceName==null && "service".equals(requestScope) && (action == Action.createInstance || action
149                                         == Action.activateInstance))){
150                                 dup = (RequestsDatabase.getInstance()).checkInstanceNameDuplicate (instanceIdMap, instanceName, requestScope);
151                         }
152                 } catch (Exception e) {
153                         msoLogger.error (MessageEnum.APIH_DUPLICATE_CHECK_EXC, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.DataError, "Error during duplicate check ", e);
154
155                         Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_INTERNAL_SERVER_ERROR, MsoException.ServiceException,
156                                         e.getMessage(),
157                                         ErrorNumbers.SVC_DETAILED_SERVICE_ERROR,
158                                         null) ;
159
160
161                         msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, "Error during duplicate check");
162                         msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
163                         return response;
164                 }
165
166                 if (dup != null) {
167                         // Found the duplicate record. Return the appropriate error.
168                         String instance = null;
169                         if(instanceName != null){
170                                 instance = instanceName;
171                         }else{
172                                 instance = instanceIdMap.get(requestScope + "InstanceId");
173                         }
174                         String dupMessage = "Error: Locked instance - This " + requestScope + " (" + instance + ") " + "already has a request being worked with a status of " + dup.getRequestStatus() + " (RequestId - " + dup.getRequestId() + "). The existing request must finish or be cleaned up before proceeding.";
175
176                         Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_CONFLICT, MsoException.ServiceException,
177                                         dupMessage,
178                                         ErrorNumbers.SVC_DETAILED_SERVICE_ERROR,
179                                         null) ;
180
181
182                         msoLogger.warn (MessageEnum.APIH_DUPLICATE_FOUND, dupMessage, "", "", MsoLogger.ErrorCode.SchemaError, "Duplicate request - Subscriber already has a request for this service");
183                         msoRequest.createRequestRecord (Status.FAILED, action);
184                         msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, dupMessage);
185                         msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
186                         return response;
187                 }
188
189                 CatalogDatabase db = null;
190                 try {
191                         db = CatalogDatabase.getInstance();
192                 } catch (Exception e) {
193                         msoLogger.error (MessageEnum.APIH_DB_ACCESS_EXC, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.AvailabilityError, "Exception while communciate with Catalog DB", e);
194                         msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
195                         Response response = msoRequest.buildServiceErrorResponse (HttpStatus.SC_NOT_FOUND,
196                                         MsoException.ServiceException,
197                                         "No communication to catalog DB " + e.getMessage (),
198                                         ErrorNumbers.SVC_NO_SERVER_RESOURCES,
199                                         null);
200                         alarmLogger.sendAlarm ("MsoDatabaseAccessError",
201                                         MsoAlarmLogger.CRITICAL,
202                                         Messages.errors.get (ErrorNumbers.NO_COMMUNICATION_TO_CATALOG_DB));
203                         msoRequest.createRequestRecord (Status.FAILED,action);
204                         msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, "Exception while communciate with DB");
205                         msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
206                         return response;
207                 }
208
209
210                 RecipeLookupResult recipeLookupResult = null;
211
212                 try {
213                         recipeLookupResult = getServiceInstanceOrchestrationURI(db, sir, action);
214                 } catch (Exception e) {
215                         msoLogger.error (MessageEnum.APIH_DB_ACCESS_EXC, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.DataError, "Exception while querying Catalog DB", e);
216                         msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
217                         Response response = msoRequest.buildServiceErrorResponse (HttpStatus.SC_NOT_FOUND,
218                                         MsoException.ServiceException,
219                                         "Recipe could not be retrieved from catalog DB " + e.getMessage (),
220                                         ErrorNumbers.SVC_GENERAL_SERVICE_ERROR,
221                                         null);
222                         alarmLogger.sendAlarm ("MsoDatabaseAccessError",
223                                         MsoAlarmLogger.CRITICAL,
224                                         Messages.errors.get (ErrorNumbers.ERROR_FROM_CATALOG_DB));
225                         msoRequest.createRequestRecord (Status.FAILED,action);
226                         msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, "Exception while querying Catalog DB");
227                         msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
228                         db.close();
229                         return response;
230                 }
231                 finally{
232                         if(null != db)
233                         {
234                                 db.close();
235                         }
236
237                 }
238
239                 if (recipeLookupResult == null) {
240                         msoLogger.error (MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.DataError, "No recipe found in DB");
241                         msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
242                         Response response = msoRequest.buildServiceErrorResponse (HttpStatus.SC_NOT_FOUND,
243                                         MsoException.ServiceException,
244                                         "Recipe does not exist in catalog DB",
245                                         ErrorNumbers.SVC_GENERAL_SERVICE_ERROR,
246                                         null);
247                         msoRequest.createRequestRecord (Status.FAILED, action);
248                         msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, "No recipe found in DB");
249                         msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
250
251                         return response;
252                 }
253
254
255                 String modelInfo = sir.getService().getParameters().getNodeTemplateName();
256                 String[] arrayOfInfo = modelInfo.split(":");
257                 String serviceInstanceType = arrayOfInfo[0];
258
259
260
261                 String serviceId = "";
262
263                 RequestClient requestClient = null;
264                 HttpResponse response = null;
265
266                 long subStartTime = System.currentTimeMillis();
267                 String sirRequestJson = mappingObtainedRequestJSONToServiceInstanceRequest(sir);
268
269                 try {
270                         requestClient = RequestClientFactory.getRequestClient (recipeLookupResult.getOrchestrationURI (), MsoPropertiesUtils.loadMsoProperties ());
271
272                         // Capture audit event
273                         msoLogger.debug ("MSO API Handler Posting call to BPEL engine for url: " + requestClient.getUrl ());
274
275                         response = requestClient.post(requestId, false,
276                                         recipeLookupResult.getRecipeTimeout(),
277                                         action.name(), serviceId, null, null, null, null, serviceInstanceType,
278                                         null, null, null, sirRequestJson);
279
280                         msoLogger.recordMetricEvent(subStartTime,
281                                         MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
282                                         "Successfully received response from BPMN engine", "BPMN",
283                                         recipeLookupResult.getOrchestrationURI(), null);
284                 } catch (Exception e) {
285                         msoLogger.recordMetricEvent(subStartTime,
286                                         MsoLogger.StatusCode.ERROR,
287                                         MsoLogger.ResponseCode.CommunicationError,
288                                         "Exception while communicate with BPMN engine", "BPMN",
289                                         recipeLookupResult.getOrchestrationURI(), null);
290                         Response resp = msoRequest.buildServiceErrorResponse(
291                                         HttpStatus.SC_BAD_GATEWAY, MsoException.ServiceException,
292                                         "Failed calling bpmn " + e.getMessage(),
293                                         ErrorNumbers.SVC_NO_SERVER_RESOURCES, null);
294                         alarmLogger.sendAlarm("MsoConfigurationError",
295                                         MsoAlarmLogger.CRITICAL,
296                                         Messages.errors.get(ErrorNumbers.NO_COMMUNICATION_TO_BPEL));
297                         msoLogger.error(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR,
298                                         MSO_PROP_APIHANDLER_INFRA, "", "",
299                                         MsoLogger.ErrorCode.AvailabilityError,
300                                         "Exception while communicate with BPMN engine");
301                         msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
302                                         MsoLogger.ResponseCode.CommunicationError,
303                                         "Exception while communicate with BPMN engine");
304                         msoLogger.debug("End of the transaction, the final response is: "
305                                         + (String) resp.getEntity());
306                         return resp;
307                 }
308
309                 if (response == null) {
310                         Response resp = msoRequest.buildServiceErrorResponse(
311                                         HttpStatus.SC_BAD_GATEWAY, MsoException.ServiceException,
312                                         "bpelResponse is null",
313                                         ErrorNumbers.SVC_NO_SERVER_RESOURCES, null);
314                         msoLogger.error(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR,
315                                         MSO_PROP_APIHANDLER_INFRA, "", "",
316                                         MsoLogger.ErrorCode.BusinessProcesssError,
317                                         "Null response from BPEL");
318                         msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
319                                         MsoLogger.ResponseCode.InternalError,
320                                         "Null response from BPMN");
321                         msoLogger.debug("End of the transaction, the final response is: "
322                                         + (String) resp.getEntity());
323                         return resp;
324                 }
325
326                 ResponseHandler respHandler = new ResponseHandler(response,
327                                 requestClient.getType());
328                 int bpelStatus = respHandler.getStatus();
329
330                 // BPEL accepted the request, the request is in progress
331                 if (bpelStatus == HttpStatus.SC_ACCEPTED) {
332                         String camundaJSONResponseBody = respHandler.getResponseBody();
333                         msoLogger
334                         .debug("Received from Camunda: " + camundaJSONResponseBody);
335                         (RequestsDatabase.getInstance()).updateInfraStatus(requestId,
336                                         Status.IN_PROGRESS.toString(),
337                                         Constants.PROGRESS_REQUEST_IN_PROGRESS,
338                                         Constants.MODIFIED_BY_APIHANDLER);
339
340                         msoLogger.recordAuditEvent(startTime,
341                                         MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
342                                         "BPMN accepted the request, the request is in progress");
343                         msoLogger.debug("End of the transaction, the final response is: "
344                                         + (String) camundaJSONResponseBody);
345                         return Response.status(HttpStatus.SC_ACCEPTED)
346                                         .entity(camundaJSONResponseBody).build();
347                 } else {
348                         List<String> variables = new ArrayList<String>();
349                         variables.add(bpelStatus + "");
350                         String camundaJSONResponseBody = respHandler.getResponseBody();
351                         if (camundaJSONResponseBody != null
352                                         && !camundaJSONResponseBody.isEmpty()) {
353                                 Response resp = msoRequest.buildServiceErrorResponse(
354                                                 bpelStatus, MsoException.ServiceException,
355                                                 "Request Failed due to BPEL error with HTTP Status= %1 "
356                                                                 + '\n' + camundaJSONResponseBody,
357                                                                 ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, variables);
358                                 msoLogger.error(MessageEnum.APIH_BPEL_RESPONSE_ERROR,
359                                                 requestClient.getUrl(), "", "",
360                                                 MsoLogger.ErrorCode.BusinessProcesssError,
361                                                 "Response from BPEL engine is failed with HTTP Status="
362                                                                 + bpelStatus);
363                                 msoLogger.recordAuditEvent(startTime,
364                                                 MsoLogger.StatusCode.ERROR,
365                                                 MsoLogger.ResponseCode.InternalError,
366                                                 "Response from BPMN engine is failed");
367                                 msoLogger
368                                 .debug("End of the transaction, the final response is: "
369                                                 + (String) resp.getEntity());
370                                 return resp;
371                         } else {
372                                 Response resp = msoRequest
373                                                 .buildServiceErrorResponse(
374                                                                 bpelStatus,
375                                                                 MsoException.ServiceException,
376                                                                 "Request Failed due to BPEL error with HTTP Status= %1",
377                                                                 ErrorNumbers.SVC_DETAILED_SERVICE_ERROR,
378                                                                 variables);
379                                 msoLogger.error(MessageEnum.APIH_BPEL_RESPONSE_ERROR,
380                                                 requestClient.getUrl(), "", "",
381                                                 MsoLogger.ErrorCode.BusinessProcesssError,
382                                                 "Response from BPEL engine is empty");
383                                 msoLogger.recordAuditEvent(startTime,
384                                                 MsoLogger.StatusCode.ERROR,
385                                                 MsoLogger.ResponseCode.InternalError,
386                                                 "Response from BPEL engine is empty");
387                                 msoLogger
388                                 .debug("End of the transaction, the final response is: "
389                                                 + (String) resp.getEntity());
390                                 return resp;
391                         }
392                 }
393         }
394
395         private RecipeLookupResult getServiceInstanceOrchestrationURI(
396                         CatalogDatabase db, E2EServiceInstanceRequest sir, Action action) {
397
398                 RecipeLookupResult recipeLookupResult = null;
399
400                 recipeLookupResult = getServiceURI(db, sir, action);
401
402                 if (recipeLookupResult != null) {
403                         msoLogger.debug ("Orchestration URI is: " + recipeLookupResult.getOrchestrationURI() + ", recipe Timeout is: " + Integer.toString(recipeLookupResult.getRecipeTimeout ()));
404                 }
405                 else {
406                         msoLogger.debug("No matching recipe record found");
407                 }
408                 return recipeLookupResult;
409         }
410
411         private RecipeLookupResult getServiceURI(CatalogDatabase db,
412                         E2EServiceInstanceRequest sir, Action action) {
413
414                 String defaultServiceModelName = "UUI_DEFAULT";
415
416                 Service serviceRecord = null;
417                 ServiceRecipe recipe = null;
418
419                 serviceRecord = db.getServiceByModelName(defaultServiceModelName);
420                 recipe = db.getServiceRecipeByModelUUID(serviceRecord.getModelUUID(), action.name());
421
422                 if (recipe == null) {
423                         return null;
424                 }
425                 return new RecipeLookupResult(recipe.getOrchestrationUri(),
426                                 recipe.getRecipeTimeout());
427
428         }
429
430         private String mappingObtainedRequestJSONToServiceInstanceRequest(E2EServiceInstanceRequest e2eSir){
431
432                 ServiceInstancesRequest sir = new ServiceInstancesRequest();
433
434                 String returnString = null;
435                 RequestDetails requestDetails = new RequestDetails();
436                 ModelInfo modelInfo = new ModelInfo();
437                 
438                 //ModelInvariantId
439                 modelInfo.setModelInvariantId(e2eSir.getService().getServiceDefId());
440                 
441                 //modelNameVersionId
442                 modelInfo.setModelNameVersionId(e2eSir.getService().getTemplateId());
443                 
444                 String modelInfoValue = e2eSir.getService().getParameters().getNodeTemplateName();
445                 String[] arrayOfInfo = modelInfoValue.split(":");
446                 String modelName = arrayOfInfo[0];
447                 String modelVersion = arrayOfInfo[1];
448                 
449                 //modelName
450                 modelInfo.setModelName(modelName);
451                 
452                 //modelVersion
453                 modelInfo.setModelVersion(modelVersion);
454                 
455                 //modelType
456                 //if(ModelType.service.equals(e2eSir.getService().getParameters().getNodeType())){
457                         modelInfo.setModelType(ModelType.service);
458                 //}
459                 
460                 //setting modelInfo to requestDetails
461                 requestDetails.setModelInfo(modelInfo);
462                 
463                 SubscriberInfo subscriberInfo = new SubscriberInfo();
464
465                 //globalsubscriberId
466                 subscriberInfo.setGlobalSubscriberId(e2eSir.getService().getParameters().getGlobalSubscriberId());
467
468                 //subscriberName
469                 subscriberInfo.setSubscriberName(e2eSir.getService().getParameters().getSubscriberName());
470                 
471                 //setting subscriberInfo to requestDetails
472                 requestDetails.setSubscriberInfo(subscriberInfo);
473                 
474                 RequestInfo requestInfo = new RequestInfo();
475                 
476                 //instanceName
477                 requestInfo.setInstanceName(e2eSir.getService().getName());
478
479                 //source
480                 requestInfo.setSource("UUI");
481
482                 //suppressRollback
483                 requestInfo.setSuppressRollback(true);
484
485                 //setting requestInfo to requestDetails
486                 requestDetails.setRequestInfo(requestInfo);
487                 
488                 RequestParameters requestParameters = new RequestParameters();
489                 
490                 //subscriptionServiceType
491                 requestParameters.setSubscriptionServiceType("MOG");
492
493                 //Userparams
494                 List<E2EUserParam> userParams;
495                 userParams = e2eSir.getService().getParameters().getRequestParameters().getUserParams();
496                 List<Map<String, String>> userParamList = new ArrayList<>();
497                 Map<String,String> userParamMap= new HashMap<>();
498                 for(E2EUserParam userp: userParams){
499                         userParamMap.put(userp.getName(), userp.getValue());
500                         userParamList.add(userParamMap);
501                 }
502
503                 requestParameters.setUserParams(userParamList);
504                 
505                 //setting requestParameters to requestDetails
506                 requestDetails.setRequestParameters(requestParameters);
507                 
508                 sir.setRequestDetails(requestDetails);
509
510                 //converting to string
511                 ObjectMapper mapper = new ObjectMapper();
512                 try {
513                         returnString = mapper.writeValueAsString(sir);
514                 } catch (IOException e) {
515                         msoLogger.debug("Exception while converting ServiceInstancesRequest object to string", e);
516                 }
517
518                 return returnString;
519         }
520 }