2 * ============LICENSE_START=======================================================
\r
4 * ================================================================================
\r
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
\r
6 * ================================================================================
\r
7 * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * you may not use this file except in compliance with the License.
\r
9 * You may obtain a copy of the License at
\r
11 * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * Unless required by applicable law or agreed to in writing, software
\r
14 * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * See the License for the specific language governing permissions and
\r
17 * limitations under the License.
\r
18 * ============LICENSE_END=========================================================
\r
21 package org.openecomp.vid.controller;
\r
24 import java.io.BufferedReader;
\r
25 import java.io.IOException;
\r
26 import java.io.InputStreamReader;
\r
27 import java.io.OutputStream;
\r
28 import java.io.PrintWriter;
\r
29 import java.io.StringWriter;
\r
30 import java.text.DateFormat;
\r
31 import java.text.SimpleDateFormat;
\r
32 import java.util.ArrayList;
\r
33 //import java.util.UUID;
\r
34 import java.util.Date;
\r
35 import java.util.Iterator;
\r
36 import java.util.List;
\r
37 import java.util.Map;
\r
38 import java.util.Scanner;
\r
39 import java.util.stream.Collectors;
\r
41 import javax.servlet.http.HttpServletRequest;
\r
42 import javax.servlet.http.HttpServletResponse;
\r
44 import org.codehaus.jackson.JsonEncoding;
\r
45 import org.codehaus.jackson.JsonFactory;
\r
46 import org.codehaus.jackson.JsonGenerator;
\r
47 import org.codehaus.jackson.JsonParser;
\r
48 import org.codehaus.jackson.JsonToken;
\r
49 import org.glassfish.jersey.client.ClientResponse;
\r
50 import org.json.simple.JSONArray;
\r
51 import org.json.simple.JSONObject;
\r
52 import org.json.simple.parser.JSONParser;
\r
53 import org.openecomp.vid.model.ExceptionResponse;
\r
54 import org.openecomp.vid.mso.*;
\r
55 import org.openecomp.vid.mso.rest.*;
\r
56 import org.springframework.http.HttpStatus;
\r
57 //import org.springframework.http.ResponseEntity;
\r
58 //import org.springframework.http.RequestEntity;
\r
59 import org.springframework.http.ResponseEntity;
\r
60 import org.springframework.web.bind.annotation.ExceptionHandler;
\r
61 import org.springframework.web.bind.annotation.PathVariable;
\r
62 import org.springframework.web.bind.annotation.RequestBody;
\r
63 import org.springframework.web.bind.annotation.RequestMapping;
\r
64 import org.springframework.web.bind.annotation.RequestMethod;
\r
65 import org.springframework.web.bind.annotation.RestController;
\r
66 import org.springframework.web.servlet.ModelAndView;
\r
68 import org.openecomp.portalsdk.core.controller.RestrictedBaseController;
\r
69 import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
\r
70 import org.openecomp.portalsdk.core.util.SystemProperties;
\r
71 import com.fasterxml.jackson.databind.ObjectMapper;
\r
72 import com.fasterxml.jackson.databind.ObjectReader;
\r
73 import com.fasterxml.jackson.databind.DeserializationFeature;
\r
76 * The Class MsoController.
\r
79 @RequestMapping("mso")
\r
80 public class MsoController extends RestrictedBaseController {
\r
90 EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MsoController.class);
\r
93 * The Constant dateFormat.
\r
95 final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
\r
98 * The Constant SVC_INSTANCE_ID.
\r
100 public final static String SVC_INSTANCE_ID = "<service_instance_id>";
\r
101 public final static String REQUEST_TYPE = "<request_type>";
\r
104 * The Constant VNF_INSTANCE_ID.
\r
106 public final static String VNF_INSTANCE_ID = "<vnf_instance_id>";
\r
111 * @param request the request
\r
112 * @return the model and view
\r
114 public ModelAndView welcome(HttpServletRequest request) {
\r
115 logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== MsoController welcome start");
\r
116 logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + " MSO_SERVER_URL=" +
\r
117 SystemProperties.getProperty(MsoProperties.MSO_SERVER_URL) );
\r
118 return new ModelAndView(getViewName());
\r
123 * @see org.openecomp.portalsdk.core.controller.RestrictedBaseController#getViewName()
\r
125 public String getViewName() {
\r
131 * @see org.openecomp.portalsdk.core.controller.RestrictedBaseController#setViewName(java.lang.String)
\r
133 public void setViewName(String viewName) {
\r
134 this.viewName = viewName;
\r
139 * Creates the svc instance.
\r
141 * @param request the request
\r
142 * @return the response entity
\r
143 * @throws Exception the exception
\r
145 @RequestMapping(value = "/mso_create_svc_instance", method = RequestMethod.POST)
\r
146 public ResponseEntity<String> createSvcInstance(HttpServletRequest request, @RequestBody RequestDetails mso_request) throws Exception {
\r
147 String methodName = "createSvcInstance";
\r
149 logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
\r
151 MsoBusinessLogic mbl = new MsoBusinessLogic();
\r
152 // always return OK, the MSO status code is embedded in the body
\r
154 MsoResponseWrapper w = mbl.createSvcInstance(mso_request);
\r
156 return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
\r
162 * Creates the svc instance.
\r
164 * @param request the request
\r
165 * @return the response entity
\r
166 * @throws Exception the exception
\r
169 public ResponseEntity<String> createSvcInstanceNewRest(HttpServletRequest request, @RequestBody RequestDetails mso_request) throws Exception {
\r
170 String methodName = "createSvcInstance";
\r
172 logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
\r
174 MsoBusinessLogicNew mbln = new MsoBusinessLogicNew();
\r
176 // always return OK, the MSO status code is embedded in the body
\r
178 MsoResponseWrapper w = mbln.createSvcInstanceRest(mso_request);
\r
183 return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
\r
188 * Creates the svc instance.
\r
190 * @param request the request
\r
191 * @return the response entity
\r
192 * @throws Exception the exception
\r
195 public ResponseEntity<String> createSvcInstanceNew(HttpServletRequest request, @RequestBody RequestDetails mso_request) throws Exception {
\r
196 String methodName = "createSvcInstance";
\r
198 logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
\r
200 MsoBusinessLogicNew mbln = new MsoBusinessLogicNew();
\r
201 // always return OK, the MSO status code is embedded in the body
\r
203 MsoResponseWrapper w = mbln.createSvcInstance(mso_request);
\r
209 return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
\r
216 * @param serviceInstanceId the service instance id
\r
217 * @param request the request
\r
218 * @return the response entity
\r
219 * @throws Exception the exception
\r
221 @RequestMapping(value = "/mso_create_vnf_instance/{serviceInstanceId}", method = RequestMethod.POST)
\r
222 public ResponseEntity<String> createVnf(@PathVariable("serviceInstanceId") String serviceInstanceId, HttpServletRequest request, @RequestBody RequestDetails mso_request) throws Exception {
\r
224 MsoBusinessLogic mbl = new MsoBusinessLogic();
\r
226 MsoResponseWrapper w = mbl.createVnf(mso_request, serviceInstanceId);
\r
228 // always return OK, the MSO status code is embedded in the body
\r
230 return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
\r
235 * Creates the nw instance.
\r
237 * @param serviceInstanceId the service instance id
\r
238 * @param request the request
\r
239 * @return the response entity
\r
240 * @throws Exception the exception
\r
242 @RequestMapping(value = "/mso_create_nw_instance/{serviceInstanceId}", method = RequestMethod.POST)
\r
243 public ResponseEntity<String> createNwInstance(@PathVariable("serviceInstanceId") String serviceInstanceId, HttpServletRequest request, @RequestBody RequestDetails mso_request) throws Exception {
\r
244 String methodName = "createNwInstance";
\r
245 logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start, serviceInstanceId = " + serviceInstanceId);
\r
247 MsoBusinessLogic mbl = new MsoBusinessLogic();
\r
249 MsoResponseWrapper w = mbl.createNwInstance(mso_request, serviceInstanceId);
\r
251 return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
\r
256 * Creates the volume group instance.
\r
258 * @param serviceInstanceId the service instance id
\r
259 * @param vnfInstanceId the vnf instance id
\r
260 * @param request the request
\r
261 * @return the response entity
\r
262 * @throws Exception the exception
\r
264 @RequestMapping(value = "/mso_create_volumegroup_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}", method = RequestMethod.POST)
\r
265 public ResponseEntity<String> createVolumeGroupInstance(@PathVariable("serviceInstanceId") String serviceInstanceId, @PathVariable("vnfInstanceId") String vnfInstanceId,
\r
266 HttpServletRequest request, @RequestBody RequestDetails mso_request) throws Exception {
\r
267 String methodName = "createVolumeGroupInstance";
\r
268 logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
\r
270 MsoBusinessLogic mbl = new MsoBusinessLogic();
\r
272 MsoResponseWrapper w = mbl.createVolumeGroupInstance(mso_request, serviceInstanceId, vnfInstanceId);
\r
274 // always return OK, the MSO status code is embedded in the body
\r
275 return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
\r
279 * Creates the vf module instance.
\r
281 * @param serviceInstanceId the service instance id
\r
282 * @param vnfInstanceId the vnf instance id
\r
283 * @param request the request
\r
284 * @return the response entity
\r
285 * @throws Exception the exception
\r
287 @RequestMapping(value = "/mso_create_vfmodule_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}", method = RequestMethod.POST)
\r
288 public ResponseEntity<String> createVfModuleInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
\r
289 @PathVariable("vnfInstanceId") String vnfInstanceId, HttpServletRequest request, @RequestBody RequestDetails mso_request) throws Exception {
\r
290 String methodName = "createVfModuleInstance";
\r
292 logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
\r
294 MsoBusinessLogic mbl = new MsoBusinessLogic();
\r
296 MsoResponseWrapper w = mbl.createVfModuleInstance(mso_request, serviceInstanceId, vnfInstanceId);
\r
298 // always return OK, the MSO status code is embedded in the body
\r
300 return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
\r
304 * Creates the instance.
\r
306 * @param request the request
\r
307 * @param path the path
\r
308 * @return the mso response wrapper
\r
309 * @throws ClientHandlerException the client handler exception
\r
310 * @throws Exception the exception
\r
312 protected MsoResponseWrapper createInstance(RequestDetails request, String path) throws Exception {
\r
313 String methodName = "createInstance";
\r
314 logger.debug(dateFormat.format(new Date()) + "<== " + methodName + " start");
\r
317 MsoRestInterfaceIfc restController = new MsoRestInterface();
\r
318 logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " calling Post, request = (" + request + ")");
\r
320 RestObject<String> restObjStr = new RestObject<String>();
\r
321 String str = new String();
\r
322 restObjStr.set(str);
\r
323 restController.<String>Post(str, request, "", path, restObjStr);
\r
324 MsoResponseWrapper w = MsoUtil.wrapResponse(restObjStr);
\r
326 logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " w=" + w.getResponse());
\r
328 } catch (Exception e) {
\r
329 logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
\r
330 logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
\r
336 * Delete svc instance.
\r
338 * @param serviceInstanceId the service instance id
\r
339 * @param request the request
\r
340 * @return the response entity
\r
341 * @throws Exception the exception
\r
343 @RequestMapping(value = "/mso_delete_svc_instance/{serviceInstanceId}", method = RequestMethod.POST)
\r
344 public ResponseEntity<String> deleteSvcInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
\r
345 HttpServletRequest request, @RequestBody RequestDetails mso_request) throws Exception {
\r
347 String methodName = "deleteSvcInstance";
\r
348 logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
\r
350 MsoBusinessLogic mbl = new MsoBusinessLogic();
\r
352 MsoResponseWrapper w = mbl.deleteSvcInstance(mso_request, serviceInstanceId);
\r
354 logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " w=" + w.getResponse());
\r
355 // always return OK, the MSO status code is embedded in the body
\r
357 return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
\r
364 * @param serviceInstanceId the service instance id
\r
365 * @param vnfInstanceId the vnf instance id
\r
366 * @param request the request
\r
367 * @return the response entity
\r
368 * @throws Exception the exception
\r
370 @RequestMapping(value = "/mso_delete_vnf_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}", method = RequestMethod.POST)
\r
372 public ResponseEntity<String> deleteVnf(@PathVariable("serviceInstanceId") String serviceInstanceId, @PathVariable("vnfInstanceId") String vnfInstanceId,
\r
373 HttpServletRequest request, @RequestBody RequestDetails mso_request) throws Exception {
\r
374 String methodName = "deleteVnf";
\r
376 logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
\r
378 MsoBusinessLogic mlb = new MsoBusinessLogic();
\r
380 MsoResponseWrapper w = mlb.deleteVnf(mso_request, serviceInstanceId, vnfInstanceId);
\r
382 // always return OK, the MSO status code is embedded in the body
\r
383 return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
\r
388 * Delete vf module.
\r
390 * @param serviceInstanceId the service instance id
\r
391 * @param vnfInstanceId the vnf instance id
\r
392 * @param vfModuleId the vf module id
\r
393 * @param request the request
\r
394 * @return the response entity
\r
395 * @throws Exception the exception
\r
397 //mso_delete_vf_module/bc305d54-75b4-431b-adb2-eb6b9e546014/vnfs/fe9000-0009-9999/vfmodules/abeeee-abeeee-abeeee
\r
398 @RequestMapping(value = "/mso_delete_vfmodule_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/{vfModuleId}", method = RequestMethod.POST)
\r
399 public ResponseEntity<String> deleteVfModule(
\r
400 @PathVariable("serviceInstanceId") String serviceInstanceId, @PathVariable("vnfInstanceId") String vnfInstanceId,
\r
401 @PathVariable("vfModuleId") String vfModuleId, HttpServletRequest request, @RequestBody RequestDetails mso_request) throws Exception {
\r
403 String methodName = "deleteVfModule";
\r
404 logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
\r
406 MsoBusinessLogic mbl = new MsoBusinessLogic();
\r
408 MsoResponseWrapper w = mbl.deleteVfModule(mso_request, serviceInstanceId, vnfInstanceId, vfModuleId);
\r
410 // always return OK, the MSO status code is embedded in the body
\r
411 return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
\r
416 * Delete volume group instance.
\r
418 * @param serviceInstanceId the service instance id
\r
419 * @param vnfInstanceId the vnf instance id
\r
420 * @param volumeGroupId the volume group id
\r
421 * @param request the request
\r
422 * @return the response entity
\r
423 * @throws Exception the exception
\r
425 @RequestMapping(value = "/mso_delete_volumegroup_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}/volumeGroups/{volumeGroupId}", method = RequestMethod.POST)
\r
426 public ResponseEntity<String> deleteVolumeGroupInstance(
\r
427 @PathVariable("serviceInstanceId") String serviceInstanceId, @PathVariable("vnfInstanceId") String vnfInstanceId, @PathVariable("volumeGroupId") String volumeGroupId,
\r
428 HttpServletRequest request, @RequestBody RequestDetails mso_request) throws Exception {
\r
429 String methodName = "deleteVolumeGroupInstance";
\r
430 logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
\r
432 MsoBusinessLogic mbl = new MsoBusinessLogic();
\r
434 MsoResponseWrapper w = mbl.deleteVolumeGroupInstance(mso_request, serviceInstanceId, vnfInstanceId, volumeGroupId);
\r
436 // always return OK, the MSO status code is embedded in the body
\r
437 return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
\r
441 * Delete nw instance.
\r
443 * @param serviceInstanceId the service instance id
\r
444 * @param networkInstanceId the network instance id
\r
445 * @param request the request
\r
446 * @return the response entity
\r
447 * @throws Exception the exception
\r
449 @RequestMapping(value = "/mso_delete_nw_instance/{serviceInstanceId}/networks/{networkInstanceId}", method = RequestMethod.POST)
\r
450 public ResponseEntity<String> deleteNwInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
\r
451 @PathVariable("networkInstanceId") String networkInstanceId, HttpServletRequest request, @RequestBody RequestDetails mso_request) throws Exception {
\r
452 String methodName = "deleteNwInstance";
\r
453 logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
\r
455 MsoBusinessLogic mbl = new MsoBusinessLogic();
\r
457 MsoResponseWrapper w = mbl.deleteNwInstance(mso_request, serviceInstanceId, networkInstanceId);
\r
459 // always return OK, the MSO status code is embedded in the body
\r
460 return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
\r
465 * Gets the orchestration request.
\r
467 * @param requestId the request id
\r
468 * @param request the request
\r
469 * @return the orchestration request
\r
470 * @throws Exception the exception
\r
472 @RequestMapping(value = "/mso_get_orch_req/{requestId}", method = RequestMethod.GET)
\r
473 public ResponseEntity<String> getOrchestrationRequest(@PathVariable("requestId") String requestId,
\r
474 HttpServletRequest request) throws Exception {
\r
476 String methodName = "getOrchestrationRequest";
\r
477 logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
\r
480 MsoBusinessLogic mbl = new MsoBusinessLogic();
\r
482 MsoResponseWrapper w = mbl.getOrchestrationRequest(requestId);
\r
484 // always return OK, the MSO status code is embedded in the body
\r
485 return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
\r
490 * Gets the orchestration requests.
\r
492 * @param filterString the filter string
\r
493 * @param request the request
\r
494 * @return the orchestration requests
\r
495 * @throws Exception the exception
\r
497 @RequestMapping(value = "/mso_get_orch_reqs/{filterString}", method = RequestMethod.GET)
\r
498 public ResponseEntity<String> getOrchestrationRequests(@PathVariable("filterString") String filterString,
\r
499 HttpServletRequest request) throws Exception {
\r
501 String methodName = "getOrchestrationRequests";
\r
502 logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
\r
505 MsoBusinessLogic mbl = new MsoBusinessLogic();
\r
507 MsoResponseWrapper w = mbl.getOrchestrationRequests(filterString);
\r
509 // always return OK, the MSO status code is embedded in the body
\r
510 return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
\r
515 * activate to a pnf instance.
\r
517 * @param serviceInstanceId the id of the service.
\r
518 * @param requestDetails the body of the request.
\r
519 * @return the response entity
\r
520 * @throws Exception the exception
\r
522 @RequestMapping(value = "/mso_activate_service_instance/{serviceInstanceId}", method = RequestMethod.POST)
\r
523 public ResponseEntity<String> activateServiceInstance(@PathVariable("serviceInstanceId") String serviceInstanceId, @RequestBody RequestDetails requestDetails) throws Exception {
\r
524 String methodName = "activateServiceInstance";
\r
525 logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
\r
527 MsoBusinessLogic mbl = new MsoBusinessLogic();
\r
529 MsoResponseWrapper w = mbl.activateServiceInstance(requestDetails, serviceInstanceId);
\r
530 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
\r
535 * Gets the orchestration requests for the dashboard.
\r
536 * currently its all the orchestration requests with RequestType updateInstance or replaceInstance.
\r
537 * @return the orchestration requests
\r
538 * @throws Exception the exception
\r
540 @RequestMapping(value = "/mso_get_orch_reqs/dashboard", method = RequestMethod.GET)
\r
541 public List<Request> getOrchestrationRequestsForDashboard() throws Exception {
\r
543 String methodName = "getOrchestrationRequestsForDashboard";
\r
544 logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
\r
547 MsoBusinessLogic mbl = new MsoBusinessLogic();
\r
549 return mbl.getOrchestrationRequestsForDashboard();
\r
553 * Gets the Manual Tasks for the given request id.
\r
555 * @param originalRequestId the id of the original request.
\r
556 * @return the tasks
\r
557 * @throws Exception the exception
\r
559 @RequestMapping(value = "/mso_get_man_task/{originalRequestId}", method = RequestMethod.GET)
\r
560 public List<Task> getManualTasksByRequestId(@PathVariable("originalRequestId") String originalRequestId) throws Exception {
\r
562 String methodName = "getManualTasksByRequestId";
\r
563 logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
\r
566 MsoBusinessLogic mbl = new MsoBusinessLogic();
\r
568 return mbl.getManualTasksByRequestId(originalRequestId);
\r
574 * Complete the manual task.
\r
576 * @param taskId the id of the task to complete.
\r
577 * @param requestDetails the body of the request.
\r
578 * @return the response entity
\r
579 * @throws Exception the exception
\r
581 @RequestMapping(value = "/mso_post_man_task/{taskId}", method = RequestMethod.POST)
\r
582 public ResponseEntity<String> manualTaskComplete(@PathVariable("taskId") String taskId , @RequestBody RequestDetails requestDetails) throws Exception {
\r
584 String methodName = "manualTaskComplete";
\r
585 logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
\r
587 MsoBusinessLogic mbl = new MsoBusinessLogic();
\r
589 MsoResponseWrapper w = mbl.completeManualTask(requestDetails, taskId);
\r
590 return new ResponseEntity<String>(w.getResponse(), HttpStatus.OK);
\r
598 * Gets the orchestration requests for svc instance.
\r
600 * @param svc_instance_id the svc instance id
\r
601 * @return the orchestration requests for svc instance
\r
602 * @throws Exception the exception
\r
604 // public MsoResponseWrapper getOrchestrationRequestsForSvcInstance(String svc_instance_id) throws Exception {
\r
606 // String methodName = "getOrchestrationRequestsForSvcInstance";
\r
607 // logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
\r
608 // MsoResponseWrapper w = null;
\r
611 // MsoRestInterfaceIfc restController = MsoRestInterfaceFactory.getInstance();
\r
612 // String p = SystemProperties.getProperty(MsoProperties.MSO_REST_API_GET_ORC_REQS);
\r
613 // String path = p + svc_instance_id;
\r
615 // RestObject<String> restObjStr = new RestObject<String>();
\r
616 // String str = new String();
\r
617 // restObjStr.set(str);
\r
619 // restController.<String>Get(str, "", path, restObjStr);
\r
620 // w = MsoUtil.wrapResponse(restObjStr);
\r
621 // logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " w=" + w.getResponse());
\r
623 // } catch (Exception e) {
\r
624 // logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
\r
625 // logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
\r
632 * Exception handler.
\r
635 * @param response the response
\r
636 * @throws IOException Signals that an I/O exception has occurred.
\r
638 @ExceptionHandler(Exception.class)
\r
639 private void exceptionHandler(Exception e, HttpServletResponse response) throws IOException {
\r
642 * The following "logger.error" lines "should" be sufficient for logging the exception.
\r
643 * However, the console output in my Eclipse environment is NOT showing ANY of the
\r
644 * logger statements in this class. Thus the temporary "e.printStackTrace" statement
\r
645 * is also included.
\r
648 String methodName = "exceptionHandler";
\r
649 logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
\r
650 StringWriter sw = new StringWriter();
\r
651 e.printStackTrace(new PrintWriter(sw));
\r
652 logger.error(EELFLoggerDelegate.errorLogger, sw.toString());
\r
655 * Temporary - IF the above mentioned "logger.error" glitch is resolved ...
\r
656 * this statement could be removed since it would then likely result in duplicate
\r
659 e.printStackTrace(System.err);
\r
661 response.setContentType("application/json; charset=UTF-8");
\r
662 response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
\r
664 ExceptionResponse exceptionResponse = new ExceptionResponse();
\r
665 exceptionResponse.setException(e.getClass().toString().replaceFirst("^.*\\.", ""));
\r
666 exceptionResponse.setMessage(e.getMessage());
\r
668 response.getWriter().write(new ObjectMapper().writeValueAsString(exceptionResponse));
\r
670 response.flushBuffer();
\r
675 * Parses the orchestration requests for svc instance.
\r
677 * @param resp the resp
\r
679 * @throws ParseException the parse exception
\r
680 * @throws Exception the exception
\r
682 @SuppressWarnings("unchecked")
\r
683 public List<JSONObject> parseOrchestrationRequestsForSvcInstance(ClientResponse resp) throws org.json.simple.parser.ParseException, Exception {
\r
685 String methodName = "parseOrchestrationRequestsForSvcInstance";
\r
687 ArrayList<JSONObject> json_list = new ArrayList<JSONObject>();
\r
689 String rlist_str = resp.readEntity(String.class);
\r
690 logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + " Response string: " + rlist_str);
\r
692 JSONParser parser = new JSONParser();
\r
694 Object obj = parser.parse(rlist_str);
\r
696 JSONObject jsonObject = (JSONObject) obj;
\r
698 JSONArray requestList = (JSONArray) jsonObject.get("requestList");
\r
700 if (requestList != null && !(requestList.isEmpty()))
\r
701 for (Object container : requestList) {
\r
703 JSONObject containerJsonObj = (JSONObject) container;
\r
704 //logger.debug(dateFormat.format(new Date()) + "<== " + "." + methodName + " reqJsonObj: " + containerJsonObj.toJSONString());
\r
705 JSONObject reqJsonObj = (JSONObject) containerJsonObj.get("request");
\r
707 //logger.debug(dateFormat.format(new Date()) + "<== " + "." + methodName + " reqJsonObj.requestId: " +
\r
708 // reqJsonObj.get("requestId") );
\r
709 JSONObject result = new JSONObject();
\r
711 result.put("requestId", reqJsonObj.get("requestId"));
\r
712 if (reqJsonObj.get("requestType") != null) {
\r
713 result.put("requestType", (reqJsonObj.get("requestType").toString()));
\r
715 JSONObject req_status = (JSONObject) reqJsonObj.get("requestStatus");
\r
716 if (req_status != null) {
\r
717 result.put("timestamp", (req_status.get("timestamp")));
\r
718 result.put("requestState", (req_status.get("requestState")));
\r
719 result.put("statusMessage", (req_status.get("statusMessage")));
\r
720 result.put("percentProgress", (req_status.get("percentProgress")));
\r
722 json_list.add(result);
\r
724 } catch (org.json.simple.parser.ParseException pe) {
\r
725 logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + " Parse exception: " + pe.toString());
\r
727 } catch (Exception e) {
\r
728 logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + " Exception: " + e.toString());
\r
731 return (json_list);
\r
735 * Retrieve request object.
\r
737 * @param request the request
\r
738 * @return the request details
\r
739 * @throws Exception the exception
\r
741 public RequestDetails retrieveRequestObject(HttpServletRequest request, @RequestBody RequestDetails mso_request) throws Exception {
\r
743 String methodName = "retrieveRequestObject";
\r
744 logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
\r
746 ObjectMapper mapper = new ObjectMapper();
\r
747 //JSON from String to Object
\r
748 //RequestDetails mso_request;
\r
751 //mso_request = new RequestDetails();
\r
752 //mso_request = mapper.readValue(request.getInputStream(), RequestDetails.class);
\r
753 } catch (Exception e) {
\r
754 logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + methodName + " Unable to read json object RequestDetails e=" + e.getMessage());
\r
757 if (mso_request == null) {
\r
758 logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + methodName + " mso_request is null");
\r
759 throw new Exception("RequestDetails is missing");
\r
762 String json_req = mapper.writeValueAsString(mso_request);
\r
763 logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " request=[" + json_req + "]");
\r
764 } catch (Exception e) {
\r
765 logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + methodName + " Unable to convert RequestDetails to json string e=" + e.getMessage());
\r
768 return (mso_request);
\r