2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. 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.onap.vid.controller;
24 import com.fasterxml.jackson.databind.ObjectMapper;
25 import org.onap.vid.model.ExceptionResponse;
26 import org.onap.vid.mso.MsoBusinessLogic;
27 import org.onap.vid.mso.MsoResponseWrapper;
28 import org.onap.vid.mso.rest.Request;
29 import org.onap.vid.mso.rest.RequestDetails;
30 import org.onap.vid.mso.rest.Task;
31 import org.openecomp.portalsdk.core.controller.RestrictedBaseController;
32 import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
33 import org.springframework.beans.factory.annotation.Autowired;
34 import org.springframework.http.HttpStatus;
35 import org.springframework.http.ResponseEntity;
36 import org.springframework.web.bind.annotation.*;
38 import javax.servlet.http.HttpServletRequest;
39 import javax.servlet.http.HttpServletResponse;
40 import java.io.IOException;
41 import java.io.PrintWriter;
42 import java.io.StringWriter;
43 import java.text.DateFormat;
44 import java.text.SimpleDateFormat;
45 import java.util.Date;
46 import java.util.List;
48 //import java.util.UUID;
49 //import org.springframework.http.ResponseEntity;
50 //import org.springframework.http.RequestEntity;
53 * The Class MsoController.
56 @RequestMapping("mso")
57 public class MsoController extends RestrictedBaseController {
62 private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(MsoController.class);
65 * The Constant dateFormat.
67 final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
70 * The Constant SVC_INSTANCE_ID.
72 public final static String SVC_INSTANCE_ID = "<service_instance_id>";
73 public final static String REQUEST_TYPE = "<request_type>";
76 * The Constant CONFIGURATION_ID
78 public final static String CONFIGURATION_ID = "<configuration_id>";
81 * The Constant VNF_INSTANCE_ID.
83 public final static String VNF_INSTANCE_ID = "<vnf_instance_id>";
85 private final MsoBusinessLogic msoBusinessLogic;
88 public MsoController(MsoBusinessLogic msoBusinessLogic) {
89 this.msoBusinessLogic = msoBusinessLogic;
93 * Creates the svc instance.
95 * @param request the request
96 * @return the response entity
97 * @throws Exception the exception
99 @RequestMapping(value = "/mso_create_svc_instance", method = RequestMethod.POST)
100 public ResponseEntity<String> createSvcInstance(HttpServletRequest request, @RequestBody RequestDetails mso_request) throws Exception {
101 String methodName = "createSvcInstance";
103 LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
105 // always return OK, the MSO status code is embedded in the body
107 MsoResponseWrapper w = msoBusinessLogic.createSvcInstance(mso_request);
109 return (new ResponseEntity<>(w.getResponse(), HttpStatus.OK));
116 * @param serviceInstanceId the service instance id
117 * @param request the request
118 * @return the response entity
119 * @throws Exception the exception
121 @RequestMapping(value = "/mso_create_vnf_instance/{serviceInstanceId}", method = RequestMethod.POST)
122 public ResponseEntity<String> createVnf(@PathVariable("serviceInstanceId") String serviceInstanceId, HttpServletRequest request, @RequestBody RequestDetails mso_request) throws Exception {
124 MsoResponseWrapper w = msoBusinessLogic.createVnf(mso_request, serviceInstanceId);
126 // always return OK, the MSO status code is embedded in the body
128 return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
133 * Creates the nw instance.
135 * @param serviceInstanceId the service instance id
136 * @param request the request
137 * @return the response entity
138 * @throws Exception the exception
140 @RequestMapping(value = "/mso_create_nw_instance/{serviceInstanceId}", method = RequestMethod.POST)
141 public ResponseEntity<String> createNwInstance(@PathVariable("serviceInstanceId") String serviceInstanceId, HttpServletRequest request, @RequestBody RequestDetails mso_request) throws Exception {
142 String methodName = "createNwInstance";
143 LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start, serviceInstanceId = " + serviceInstanceId);
145 MsoResponseWrapper w = msoBusinessLogic.createNwInstance(mso_request, serviceInstanceId);
147 return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
152 * Creates the volume group instance.
154 * @param serviceInstanceId the service instance id
155 * @param vnfInstanceId the vnf instance id
156 * @param request the request
157 * @return the response entity
158 * @throws Exception the exception
160 @RequestMapping(value = "/mso_create_volumegroup_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}", method = RequestMethod.POST)
161 public ResponseEntity<String> createVolumeGroupInstance(@PathVariable("serviceInstanceId") String serviceInstanceId, @PathVariable("vnfInstanceId") String vnfInstanceId,
162 HttpServletRequest request, @RequestBody RequestDetails mso_request) throws Exception {
163 String methodName = "createVolumeGroupInstance";
164 LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
166 MsoResponseWrapper w = msoBusinessLogic.createVolumeGroupInstance(mso_request, serviceInstanceId, vnfInstanceId);
168 // always return OK, the MSO status code is embedded in the body
169 return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
173 * Creates the vf module instance.
175 * @param serviceInstanceId the service instance id
176 * @param vnfInstanceId the vnf instance id
177 * @param request the request
178 * @return the response entity
179 * @throws Exception the exception
181 @RequestMapping(value = "/mso_create_vfmodule_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}", method = RequestMethod.POST)
182 public ResponseEntity<String> createVfModuleInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
183 @PathVariable("vnfInstanceId") String vnfInstanceId, HttpServletRequest request, @RequestBody RequestDetails mso_request) throws Exception {
184 String methodName = "createVfModuleInstance";
186 LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
188 MsoResponseWrapper w = msoBusinessLogic.createVfModuleInstance(mso_request, serviceInstanceId, vnfInstanceId);
190 // always return OK, the MSO status code is embedded in the body
192 return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
196 * Creates a configuration instance.
198 * @param serviceInstanceId the service instance id
199 * @param request the request
200 * @return the response entity
201 * @throws Exception the exception
203 @RequestMapping(value = "/mso_create_configuration_instance/{serviceInstanceId}/configurations/", method = RequestMethod.POST)
204 public ResponseEntity<String> createConfigurationInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
205 HttpServletRequest request, @RequestBody RequestDetails mso_request) throws Exception {
206 String methodName = "createConfigurationInstance";
207 LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
209 MsoResponseWrapper w = msoBusinessLogic.createConfigurationInstance(mso_request, serviceInstanceId);
211 // always return OK, the MSO status code is embedded in the body
213 return (new ResponseEntity<>(w.getResponse(), HttpStatus.OK));
217 * Delete svc instance.
219 * @param serviceInstanceId the service instance id
220 * @param request the request
221 * @return the response entity
222 * @throws Exception the exception
224 @RequestMapping(value = "/mso_delete_svc_instance/{serviceInstanceId}", method = RequestMethod.POST)
225 public ResponseEntity<String> deleteSvcInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
226 HttpServletRequest request, @RequestBody RequestDetails mso_request) throws Exception {
228 String methodName = "deleteSvcInstance";
229 LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
231 MsoResponseWrapper w = msoBusinessLogic.deleteSvcInstance(mso_request, serviceInstanceId);
233 LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " w=" + w.getResponse());
234 // always return OK, the MSO status code is embedded in the body
236 return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
243 * @param serviceInstanceId the service instance id
244 * @param vnfInstanceId the vnf instance id
245 * @param request the request
246 * @return the response entity
247 * @throws Exception the exception
249 @RequestMapping(value = "/mso_delete_vnf_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}", method = RequestMethod.POST)
251 public ResponseEntity<String> deleteVnf(@PathVariable("serviceInstanceId") String serviceInstanceId, @PathVariable("vnfInstanceId") String vnfInstanceId,
252 HttpServletRequest request, @RequestBody RequestDetails mso_request) throws Exception {
253 String methodName = "deleteVnf";
255 LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
257 MsoResponseWrapper w = msoBusinessLogic.deleteVnf(mso_request, serviceInstanceId, vnfInstanceId);
259 // always return OK, the MSO status code is embedded in the body
260 return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
265 * Delete configuration instance
266 * @param serviceInstanceId the service instance id
267 * @param configurationId the configuration id
268 * @param mso_request the request
269 * @return the response entity
270 * @throws Exception the exception
272 @RequestMapping(value = "mso_delete_configuration/{serviceInstanceId}/configurations/{configurationId}",
273 method = RequestMethod.POST)
274 public ResponseEntity<String> deleteConfiguration(
275 @PathVariable("serviceInstanceId") String serviceInstanceId,
276 @PathVariable ("configurationId") String configurationId,
277 @RequestBody RequestDetails mso_request) throws Exception {
279 String methodName = "deleteConfiguration";
280 LOGGER.debug(EELFLoggerDelegate.debugLogger,
281 dateFormat.format(new Date()) + "<== " + methodName + " start");
283 MsoResponseWrapper w = msoBusinessLogic.deleteConfiguration(mso_request, serviceInstanceId, configurationId);
285 // always return OK, the MSO status code is embedded in the body
286 return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
290 * Activate configuration instance
291 * @param serviceInstanceId the service instace id
292 * @param configurationId the configuration id
293 * @param mso_request the request
294 * @return the response entity
295 * @throws Exception the exception
297 @RequestMapping(value = "mso_activate_configuration/{serviceInstanceId}/configurations/{configurationId}",
298 method = RequestMethod.POST)
299 public ResponseEntity<String> activateConfiguration(
300 @PathVariable("serviceInstanceId") String serviceInstanceId,
301 @PathVariable("configurationId") String configurationId,
302 @RequestBody RequestDetails mso_request) throws Exception {
304 MsoResponseWrapper w = msoBusinessLogic.setConfigurationActiveStatus(mso_request, serviceInstanceId, configurationId, true);
306 // always return OK, the MSO status code is embedded in the body
307 return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
311 * Deactivate configuration instance
312 * @param serviceInstanceId the service instace id
313 * @param configurationId the configuration id
314 * @param mso_request the request
315 * @return the response entity
316 * @throws Exception the exception
318 @RequestMapping(value = "mso_deactivate_configuration/{serviceInstanceId}/configurations/{configurationId}",
319 method = RequestMethod.POST)
320 public ResponseEntity<String> deactivateConfiguration(
321 @PathVariable("serviceInstanceId") String serviceInstanceId,
322 @PathVariable("configurationId") String configurationId,
323 @RequestBody RequestDetails mso_request) throws Exception {
325 MsoResponseWrapper w = msoBusinessLogic.setConfigurationActiveStatus(mso_request, serviceInstanceId, configurationId, false);
327 // always return OK, the MSO status code is embedded in the body
328 return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
332 * Disable port on configuration instance
333 * @param serviceInstanceId the service instance id
334 * @param configurationId the configuration instance id
335 * @param mso_request the request
336 * @return the response entity
337 * @throws Exception the exception
339 @RequestMapping(value = "mso_disable_port_configuration/{serviceInstanceId}/configurations/{configurationId}",
340 method = RequestMethod.POST)
341 public ResponseEntity<String> disablePortOnConfiguration(
342 @PathVariable("serviceInstanceId") String serviceInstanceId,
343 @PathVariable("configurationId") String configurationId,
344 @RequestBody RequestDetails mso_request) throws Exception {
346 MsoResponseWrapper w = msoBusinessLogic.setPortOnConfigurationStatus(mso_request, serviceInstanceId, configurationId, false);
348 // always return OK, the MSO status code is embedded in the body
349 return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
353 * Enable port on configuration instance
354 * @param serviceInstanceId the service instance id
355 * @param configurationId the configuration instance id
356 * @param mso_request the request
357 * @return the response entity
358 * @throws Exception the exception
360 @RequestMapping(value = "mso_enable_port_configuration/{serviceInstanceId}/configurations/{configurationId}",
361 method = RequestMethod.POST)
362 public ResponseEntity<String> enablePortOnConfiguration(
363 @PathVariable("serviceInstanceId") String serviceInstanceId,
364 @PathVariable("configurationId") String configurationId,
365 @RequestBody RequestDetails mso_request) throws Exception {
367 MsoResponseWrapper w = msoBusinessLogic.setPortOnConfigurationStatus(mso_request, serviceInstanceId, configurationId, true);
369 // always return OK, the MSO status code is embedded in the body
370 return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
376 * @param serviceInstanceId the service instance id
377 * @param vnfInstanceId the vnf instance id
378 * @param vfModuleId the vf module id
379 * @param request the request
380 * @return the response entity
381 * @throws Exception the exception
383 //mso_delete_vf_module/bc305d54-75b4-431b-adb2-eb6b9e546014/vnfs/fe9000-0009-9999/vfmodules/abeeee-abeeee-abeeee
384 @RequestMapping(value = "/mso_delete_vfmodule_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/{vfModuleId}", method = RequestMethod.POST)
385 public ResponseEntity<String> deleteVfModule(
386 @PathVariable("serviceInstanceId") String serviceInstanceId, @PathVariable("vnfInstanceId") String vnfInstanceId,
387 @PathVariable("vfModuleId") String vfModuleId, HttpServletRequest request, @RequestBody RequestDetails mso_request) throws Exception {
389 String methodName = "deleteVfModule";
390 LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
392 MsoResponseWrapper w = msoBusinessLogic.deleteVfModule(mso_request, serviceInstanceId, vnfInstanceId, vfModuleId);
394 // always return OK, the MSO status code is embedded in the body
395 return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
400 * Delete volume group instance.
402 * @param serviceInstanceId the service instance id
403 * @param vnfInstanceId the vnf instance id
404 * @param volumeGroupId the volume group id
405 * @param request the request
406 * @return the response entity
407 * @throws Exception the exception
409 @RequestMapping(value = "/mso_delete_volumegroup_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}/volumeGroups/{volumeGroupId}", method = RequestMethod.POST)
410 public ResponseEntity<String> deleteVolumeGroupInstance(
411 @PathVariable("serviceInstanceId") String serviceInstanceId, @PathVariable("vnfInstanceId") String vnfInstanceId, @PathVariable("volumeGroupId") String volumeGroupId,
412 HttpServletRequest request, @RequestBody RequestDetails mso_request) throws Exception {
413 String methodName = "deleteVolumeGroupInstance";
414 LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
416 MsoResponseWrapper w = msoBusinessLogic.deleteVolumeGroupInstance(mso_request, serviceInstanceId, vnfInstanceId, volumeGroupId);
418 // always return OK, the MSO status code is embedded in the body
419 return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
423 * Delete nw instance.
425 * @param serviceInstanceId the service instance id
426 * @param networkInstanceId the network instance id
427 * @param request the request
428 * @return the response entity
429 * @throws Exception the exception
431 @RequestMapping(value = "/mso_delete_nw_instance/{serviceInstanceId}/networks/{networkInstanceId}", method = RequestMethod.POST)
432 public ResponseEntity<String> deleteNwInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
433 @PathVariable("networkInstanceId") String networkInstanceId, HttpServletRequest request, @RequestBody RequestDetails mso_request) throws Exception {
434 String methodName = "deleteNwInstance";
435 LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
437 MsoResponseWrapper w = msoBusinessLogic.deleteNwInstance(mso_request, serviceInstanceId, networkInstanceId);
439 // always return OK, the MSO status code is embedded in the body
440 return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
445 * Gets the orchestration request.
447 * @param requestId the request id
448 * @param request the request
449 * @return the orchestration request
450 * @throws Exception the exception
452 @RequestMapping(value = "/mso_get_orch_req/{requestId}", method = RequestMethod.GET)
453 public ResponseEntity<String> getOrchestrationRequest(@PathVariable("requestId") String requestId,
454 HttpServletRequest request) throws Exception {
456 String methodName = "getOrchestrationRequest";
457 LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
460 MsoResponseWrapper w = msoBusinessLogic.getOrchestrationRequest(requestId);
462 // always return OK, the MSO status code is embedded in the body
463 return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
468 * Gets the orchestration requests.
470 * @param filterString the filter string
471 * @param request the request
472 * @return the orchestration requests
473 * @throws Exception the exception
475 @RequestMapping(value = "/mso_get_orch_reqs/{filterString}", method = RequestMethod.GET)
476 public ResponseEntity<String> getOrchestrationRequests(@PathVariable("filterString") String filterString,
477 HttpServletRequest request) throws Exception {
479 String methodName = "getOrchestrationRequests";
480 LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
483 MsoResponseWrapper w = msoBusinessLogic.getOrchestrationRequests(filterString);
485 // always return OK, the MSO status code is embedded in the body
486 return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
491 * activate to a pnf instance.
493 * @param serviceInstanceId the id of the service.
494 * @param requestDetails the body of the request.
495 * @return the response entity
496 * @throws Exception the exception
498 @RequestMapping(value = "/mso_activate_service_instance/{serviceInstanceId}", method = RequestMethod.POST)
499 public ResponseEntity<String> activateServiceInstance(@PathVariable("serviceInstanceId") String serviceInstanceId, @RequestBody RequestDetails requestDetails) throws Exception {
500 String methodName = "activateServiceInstance";
501 LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
503 MsoResponseWrapper w = msoBusinessLogic.setServiceInstanceStatus(requestDetails, serviceInstanceId, true);
504 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
508 * deactivate a service instance.
510 * @param serviceInstanceId the id of the service.
511 * @param requestDetails the body of the request.
512 * @return the response entity
513 * @throws Exception the exception
515 @RequestMapping(value = "/mso_deactivate_service_instance/{serviceInstanceId}", method = RequestMethod.POST)
516 public ResponseEntity<String> deactivateServiceInstance(@PathVariable("serviceInstanceId") String serviceInstanceId, @RequestBody RequestDetails requestDetails) throws Exception {
517 String methodName = "deactivateServiceInstance";
518 LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
520 MsoResponseWrapper w = msoBusinessLogic.setServiceInstanceStatus(requestDetails, serviceInstanceId, false);
521 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
526 * Gets the orchestration requests for the dashboard.
527 * currently its all the orchestration requests with RequestType updateInstance or replaceInstance.
528 * @return the orchestration requests
529 * @throws Exception the exception
531 @RequestMapping(value = "/mso_get_orch_reqs/dashboard", method = RequestMethod.GET)
532 public List<Request> getOrchestrationRequestsForDashboard() throws Exception {
534 String methodName = "getOrchestrationRequestsForDashboard";
535 LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
538 return msoBusinessLogic.getOrchestrationRequestsForDashboard();
542 * Gets the Manual Tasks for the given request id.
544 * @param originalRequestId the id of the original request.
546 * @throws Exception the exception
548 @RequestMapping(value = "/mso_get_man_task/{originalRequestId}", method = RequestMethod.GET)
549 public List<Task> getManualTasksByRequestId(@PathVariable("originalRequestId") String originalRequestId) throws Exception {
551 String methodName = "getManualTasksByRequestId";
552 LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
554 return msoBusinessLogic.getManualTasksByRequestId(originalRequestId);
560 * Complete the manual task.
562 * @param taskId the id of the task to complete.
563 * @param requestDetails the body of the request.
564 * @return the response entity
565 * @throws Exception the exception
567 @RequestMapping(value = "/mso_post_man_task/{taskId}", method = RequestMethod.POST)
568 public ResponseEntity<String> manualTaskComplete(@PathVariable("taskId") String taskId , @RequestBody RequestDetails requestDetails) throws Exception {
570 String methodName = "manualTaskComplete";
571 LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
573 MsoResponseWrapper w = msoBusinessLogic.completeManualTask(requestDetails, taskId);
574 return new ResponseEntity<String>(w.getResponse(), HttpStatus.OK);
577 @RequestMapping(value = "/mso_remove_relationship/{serviceInstanceId}", method = RequestMethod.POST)
578 public ResponseEntity<String> removeRelationshipFromServiceInstance(@PathVariable("serviceInstanceId") String serviceInstanceId ,
579 @RequestBody RequestDetails requestDetails) throws Exception {
581 String methodName = "removeRelationshipFromServiceInstance";
582 LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
584 MsoResponseWrapper w;
586 w = msoBusinessLogic.removeRelationshipFromServiceInstance(requestDetails, serviceInstanceId);
587 } catch (Exception e){
588 LOGGER.error("Internal error when calling MSO controller logic for {}", methodName, e);
589 return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
591 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
594 @RequestMapping(value = "/mso_add_relationship/{serviceInstanceId}", method = RequestMethod.POST)
595 public ResponseEntity<String> addRelationshipToServiceInstance(@PathVariable("serviceInstanceId") String serviceInstanceId ,
596 @RequestBody RequestDetails requestDetails) throws Exception {
598 String methodName = "addRelationshipToServiceInstance";
599 LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
601 MsoResponseWrapper w;
603 w = msoBusinessLogic.addRelationshipToServiceInstance(requestDetails, serviceInstanceId);
604 } catch (Exception e){
605 LOGGER.error("Internal error when calling MSO controller logic for {}", methodName, e);
606 return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
608 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
616 * @param response the response
617 * @throws IOException Signals that an I/O exception has occurred.
619 @ExceptionHandler(Exception.class)
620 private void exceptionHandler(Exception e, HttpServletResponse response) throws IOException {
623 * The following "logger.error" lines "should" be sufficient for logging the exception.
624 * However, the console output in my Eclipse environment is NOT showing ANY of the
625 * logger statements in this class. Thus the temporary "e.printStackTrace" statement
629 String methodName = "exceptionHandler";
630 LOGGER.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
631 StringWriter sw = new StringWriter();
632 e.printStackTrace(new PrintWriter(sw));
633 LOGGER.error(EELFLoggerDelegate.errorLogger, sw.toString());
636 * Temporary - IF the above mentioned "logger.error" glitch is resolved ...
637 * this statement could be removed since it would then likely result in duplicate
640 e.printStackTrace(System.err);
642 response.setContentType("application/json; charset=UTF-8");
643 response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
645 ExceptionResponse exceptionResponse = new ExceptionResponse();
646 exceptionResponse.setException(e.getClass().toString().replaceFirst("^.*\\.", ""));
647 exceptionResponse.setMessage(e.getMessage());
649 response.getWriter().write(new ObjectMapper().writeValueAsString(exceptionResponse));
651 response.flushBuffer();