blob: 53cdde7f2c7fcd651f73aba0b57e6361b0759c5d [file] [log] [blame]
Aharoni, Pavel (pa0916)ca3cb012018-10-22 15:29:57 +03001/*-
2 * ============LICENSE_START=======================================================
3 * OSAM
4 * ================================================================================
5 * Copyright (C) 2018 AT&T
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
22
23package org.onap.osam.controllers;
24
25
26import com.fasterxml.jackson.databind.ObjectMapper;
27import org.onap.osam.model.ExceptionResponse;
28import org.onap.osam.mso.MsoBusinessLogic;
29import org.onap.osam.mso.MsoResponseWrapper;
30import org.onap.osam.mso.rest.Request;
31import org.onap.osam.mso.rest.RequestDetails;
32import org.onap.osam.mso.rest.RequestDetailsWrapper;
33import org.onap.osam.mso.rest.Task;
34import org.onap.portalsdk.core.controller.RestrictedBaseController;
35import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
36import org.springframework.beans.factory.annotation.Autowired;
37import org.springframework.http.HttpStatus;
38import org.springframework.http.ResponseEntity;
39import org.springframework.web.bind.annotation.*;
40
41import javax.servlet.http.HttpServletRequest;
42import javax.servlet.http.HttpServletResponse;
43import java.io.IOException;
44import java.io.PrintWriter;
45import java.io.StringWriter;
46import java.text.DateFormat;
47import java.text.SimpleDateFormat;
48import java.util.Date;
49import java.util.LinkedHashMap;
50import java.util.List;
51
52import static org.onap.osam.utils.Logging.getMethodName;
53
54//import java.util.UUID;
55//import org.springframework.http.ResponseEntity;
56//import org.springframework.http.RequestEntity;
57
58@RestController
59@RequestMapping("mso")
60public class MsoController extends RestrictedBaseController {
61
62 private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(MsoController.class);
63
64 /**
65 * The Constant dateFormat.
66 */
67 private final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
68
69 /**
70 * The Constant SVC_INSTANCE_ID.
71 */
72 public final static String SVC_INSTANCE_ID = "<service_instance_id>";
73 public final static String REQUEST_TYPE = "<request_type>";
74
75 /**
76 * The Constant CONFIGURATION_ID
77 */
78 public final static String CONFIGURATION_ID = "<configuration_id>";
79
80 /**
81 * The Constant VNF_INSTANCE_ID.
82 */
83 public final static String VNF_INSTANCE_ID = "<vnf_instance_id>";
84
85 private final MsoBusinessLogic msoBusinessLogic;
86
87 @Autowired
88 public MsoController(MsoBusinessLogic msoBusinessLogic) {
89 this.msoBusinessLogic = msoBusinessLogic;
90 }
91
92 /**
93 * Creates the svc instance.
94 *
95 * @param request the request
96 * @return the response entity
97 * @throws Exception the exception
98 */
99 @RequestMapping(value = "/mso_create_svc_instance", method = RequestMethod.POST)
100 public ResponseEntity<String> createSvcInstance(HttpServletRequest request, @RequestBody RequestDetails mso_request) {
101 String methodName = "createSvcInstance";
102
103 LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
104
105 // always return OK, the MSO status code is embedded in the body
106
107 MsoResponseWrapper w = msoBusinessLogic.createSvcInstance(mso_request);
108
109 return (new ResponseEntity<>(w.getResponse(), HttpStatus.OK));
110
111 }
112
113 /**
114 * Creates the e2e svc instance.
115 *
116 * @param request the request
117 * @return the response entity
118 * @throws Exception the exception
119 */
120 @RequestMapping(value = "/mso_create_e2e_svc_instance", method = RequestMethod.POST)
121 public ResponseEntity<String> createE2eSvcInstance(HttpServletRequest request, @RequestBody LinkedHashMap<String, Object> mso_request) {
122 String methodName = "createE2eSvcInstance";
123
124 LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
125
126 // always return OK, the MSO status code is embedded in the body
127
128 MsoResponseWrapper w = msoBusinessLogic.createE2eSvcInstance(mso_request.get("requestDetails"));
129
130 return (new ResponseEntity<>(w.getResponse(), HttpStatus.OK));
131
132 }
133
134 /**
135 * Creates the vnf.
136 *
137 * @param serviceInstanceId the service instance id
138 * @param request the request
139 * @return the response entity
140 * @throws Exception the exception
141 */
142 @RequestMapping(value = "/mso_create_vnf_instance/{serviceInstanceId}", method = RequestMethod.POST)
143 public ResponseEntity<String> createVnf(@PathVariable("serviceInstanceId") String serviceInstanceId, HttpServletRequest request, @RequestBody RequestDetails mso_request) {
144
145 MsoResponseWrapper w = msoBusinessLogic.createVnf(mso_request, serviceInstanceId);
146
147 // always return OK, the MSO status code is embedded in the body
148
149 return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
150
151 }
152
153 /**
154 * Creates the nw instance.
155 *
156 * @param serviceInstanceId the service instance id
157 * @param request the request
158 * @return the response entity
159 * @throws Exception the exception
160 */
161 @RequestMapping(value = "/mso_create_nw_instance/{serviceInstanceId}", method = RequestMethod.POST)
162 public ResponseEntity<String> createNwInstance(@PathVariable("serviceInstanceId") String serviceInstanceId, HttpServletRequest request, @RequestBody RequestDetails mso_request) {
163 String methodName = "createNwInstance";
164 LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start, serviceInstanceId = " + serviceInstanceId);
165
166 MsoResponseWrapper w = msoBusinessLogic.createNwInstance(mso_request, serviceInstanceId);
167
168 return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
169
170 }
171
172 /**
173 * Creates the volume group instance.
174 *
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
180 */
181 @RequestMapping(value = "/mso_create_volumegroup_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}", method = RequestMethod.POST)
182 public ResponseEntity<String> createVolumeGroupInstance(@PathVariable("serviceInstanceId") String serviceInstanceId, @PathVariable("vnfInstanceId") String vnfInstanceId,
183 HttpServletRequest request, @RequestBody RequestDetails mso_request) {
184 String methodName = "createVolumeGroupInstance";
185 LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
186
187 MsoResponseWrapper w = msoBusinessLogic.createVolumeGroupInstance(mso_request, serviceInstanceId, vnfInstanceId);
188
189 // always return OK, the MSO status code is embedded in the body
190 return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
191 }
192
193 /**
194 * Creates the vf module instance.
195 *
196 * @param serviceInstanceId the service instance id
197 * @param vnfInstanceId the vnf instance id
198 * @param request the request
199 * @return the response entity
200 * @throws Exception the exception
201 */
202 @RequestMapping(value = "/mso_create_vfmodule_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}", method = RequestMethod.POST)
203 public ResponseEntity<String> createVfModuleInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
204 @PathVariable("vnfInstanceId") String vnfInstanceId, HttpServletRequest request, @RequestBody RequestDetails mso_request) {
205 String methodName = "createVfModuleInstance";
206
207 LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
208
209 MsoResponseWrapper w = msoBusinessLogic.createVfModuleInstance(mso_request, serviceInstanceId, vnfInstanceId);
210
211 // always return OK, the MSO status code is embedded in the body
212
213 return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
214 }
215
216 /**
217 * Creates a configuration instance.
218 *
219 * @param serviceInstanceId the service instance id
220 * @param request the request
221 * @return the response entity
222 * @throws Exception the exception
223 */
224 @RequestMapping(value = "/mso_create_configuration_instance/{serviceInstanceId}/configurations/", method = RequestMethod.POST)
225 public ResponseEntity<String> createConfigurationInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
226 HttpServletRequest request, @RequestBody RequestDetailsWrapper mso_request) {
227 String methodName = "createConfigurationInstance";
228 LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
229
230 MsoResponseWrapper w = msoBusinessLogic.createConfigurationInstance(mso_request, serviceInstanceId);
231
232 // always return OK, the MSO status code is embedded in the body
233
234 return (new ResponseEntity<>(w.getResponse(), HttpStatus.OK));
235 }
236
237 /**
238 * Delete E2e svc instance.
239 *
240 * @param serviceInstanceId the service instance id
241 * @param request the request
242 * @return the response entity
243 * @throws Exception the exception
244 */
245 @RequestMapping(value = "/mso_delete_e2e_svc_instance/{serviceInstanceId}", method = RequestMethod.POST)
246 public ResponseEntity<String> deleteE2eSvcInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
247 HttpServletRequest request, @RequestBody LinkedHashMap<String, Object> mso_request) {
248
249 String methodName = "deleteE2eSvcInstance";
250 LOGGER.debug(EELFLoggerDelegate.debugLogger, "start {}({})", getMethodName(), mso_request);
251
252 MsoResponseWrapper w = msoBusinessLogic.deleteE2eSvcInstance(mso_request.get("requestDetails"), serviceInstanceId);
253
254 LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " w=" + w.getResponse());
255 // always return OK, the MSO status code is embedded in the body
256
257 return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
258
259 }
260
261 /**
262 * Delete svc instance.
263 *
264 * @param serviceInstanceId the service instance id
265 * @param request the request
266 * @return the response entity
267 * @throws Exception the exception
268 */
269
270 @RequestMapping(value = "/mso_delete_svc_instance/{serviceInstanceId}", method = RequestMethod.POST)
271 public String deleteSvcInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
272 HttpServletRequest request, @RequestBody RequestDetails mso_request,
273 @RequestParam(value = "serviceStatus") String serviceStatus) {
274
275 String methodName = "deleteSvcInstance";
276 LOGGER.debug(EELFLoggerDelegate.debugLogger, "start {}({})", getMethodName(), mso_request);
277 MsoResponseWrapper w = msoBusinessLogic.deleteSvcInstance(mso_request, serviceInstanceId, serviceStatus);
278 // always return OK, the MSO status code is embedded in the body
279
280 return w.getResponse();
281 }
282
283 /**
284 * Delete vnf.
285 *
286 * @param serviceInstanceId the service instance id
287 * @param vnfInstanceId the vnf instance id
288 * @param request the request
289 * @return the response entity
290 * @throws Exception the exception
291 */
292 @RequestMapping(value = "/mso_delete_vnf_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}", method = RequestMethod.POST)
293
294 public ResponseEntity<String> deleteVnf(@PathVariable("serviceInstanceId") String serviceInstanceId, @PathVariable("vnfInstanceId") String vnfInstanceId,
295 HttpServletRequest request, @RequestBody RequestDetails mso_request) {
296 String methodName = "deleteVnf";
297
298 LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
299
300 MsoResponseWrapper w = msoBusinessLogic.deleteVnf(mso_request, serviceInstanceId, vnfInstanceId);
301
302 // always return OK, the MSO status code is embedded in the body
303 return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
304
305 }
306
307 /**
308 * Delete configuration instance
309 * @param serviceInstanceId the service instance id
310 * @param configurationId the configuration id
311 * @param mso_request the request
312 * @return the response entity
313 * @throws Exception the exception
314 */
315 @RequestMapping(value = "mso_delete_configuration/{serviceInstanceId}/configurations/{configurationId}",
316 method = RequestMethod.POST)
317 public ResponseEntity<String> deleteConfiguration(
318 @PathVariable("serviceInstanceId") String serviceInstanceId,
319 @PathVariable ("configurationId") String configurationId,
320 @RequestBody RequestDetailsWrapper mso_request) {
321
322 String methodName = "deleteConfiguration";
323 LOGGER.debug(EELFLoggerDelegate.debugLogger,
324 dateFormat.format(new Date()) + "<== " + methodName + " start");
325
326 MsoResponseWrapper w = msoBusinessLogic.deleteConfiguration(mso_request, serviceInstanceId, configurationId);
327
328 // always return OK, the MSO status code is embedded in the body
329 return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
330 }
331
332 /**
333 * Activate configuration instance
334 * @param serviceInstanceId the service instace id
335 * @param configurationId the configuration id
336 * @param mso_request the request
337 * @return the response entity
338 * @throws Exception the exception
339 */
340 @RequestMapping(value = "mso_activate_configuration/{serviceInstanceId}/configurations/{configurationId}",
341 method = RequestMethod.POST)
342 public ResponseEntity<String> activateConfiguration(
343 @PathVariable("serviceInstanceId") String serviceInstanceId,
344 @PathVariable("configurationId") String configurationId,
345 @RequestBody RequestDetails mso_request) {
346
347 MsoResponseWrapper w = msoBusinessLogic.setConfigurationActiveStatus(mso_request, serviceInstanceId, configurationId, true);
348
349 // always return OK, the MSO status code is embedded in the body
350 return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
351 }
352
353 /**
354 * Deactivate configuration instance
355 * @param serviceInstanceId the service instace id
356 * @param configurationId the configuration id
357 * @param mso_request the request
358 * @return the response entity
359 * @throws Exception the exception
360 */
361 @RequestMapping(value = "mso_deactivate_configuration/{serviceInstanceId}/configurations/{configurationId}",
362 method = RequestMethod.POST)
363 public ResponseEntity<String> deactivateConfiguration(
364 @PathVariable("serviceInstanceId") String serviceInstanceId,
365 @PathVariable("configurationId") String configurationId,
366 @RequestBody RequestDetails mso_request) {
367
368 MsoResponseWrapper w = msoBusinessLogic.setConfigurationActiveStatus(mso_request, serviceInstanceId, configurationId, false);
369
370 // always return OK, the MSO status code is embedded in the body
371 return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
372 }
373
374 /**
375 * Disable port on configuration instance
376 * @param serviceInstanceId the service instance id
377 * @param configurationId the configuration instance id
378 * @param mso_request the request
379 * @return the response entity
380 * @throws Exception the exception
381 */
382 @RequestMapping(value = "mso_disable_port_configuration/{serviceInstanceId}/configurations/{configurationId}",
383 method = RequestMethod.POST)
384 public ResponseEntity<String> disablePortOnConfiguration(
385 @PathVariable("serviceInstanceId") String serviceInstanceId,
386 @PathVariable("configurationId") String configurationId,
387 @RequestBody RequestDetails mso_request) {
388
389 MsoResponseWrapper w = msoBusinessLogic.setPortOnConfigurationStatus(mso_request, serviceInstanceId, configurationId, false);
390
391 // always return OK, the MSO status code is embedded in the body
392 return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
393 }
394
395 /**
396 * Enable port on configuration instance
397 * @param serviceInstanceId the service instance id
398 * @param configurationId the configuration instance id
399 * @param mso_request the request
400 * @return the response entity
401 * @throws Exception the exception
402 */
403 @RequestMapping(value = "mso_enable_port_configuration/{serviceInstanceId}/configurations/{configurationId}",
404 method = RequestMethod.POST)
405 public ResponseEntity<String> enablePortOnConfiguration(
406 @PathVariable("serviceInstanceId") String serviceInstanceId,
407 @PathVariable("configurationId") String configurationId,
408 @RequestBody RequestDetails mso_request) {
409
410 MsoResponseWrapper w = msoBusinessLogic.setPortOnConfigurationStatus(mso_request, serviceInstanceId, configurationId, true);
411
412 // always return OK, the MSO status code is embedded in the body
413 return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
414 }
415
416 /**
417 * Delete vf module.
418 *
419 * @param serviceInstanceId the service instance id
420 * @param vnfInstanceId the vnf instance id
421 * @param vfModuleId the vf module id
422 * @param request the request
423 * @return the response entity
424 * @throws Exception the exception
425 */
426 //mso_delete_vf_module/bc305d54-75b4-431b-adb2-eb6b9e546014/vnfs/fe9000-0009-9999/vfmodules/abeeee-abeeee-abeeee
427 @RequestMapping(value = "/mso_delete_vfmodule_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/{vfModuleId}", method = RequestMethod.POST)
428 public ResponseEntity<String> deleteVfModule(
429 @PathVariable("serviceInstanceId") String serviceInstanceId, @PathVariable("vnfInstanceId") String vnfInstanceId,
430 @PathVariable("vfModuleId") String vfModuleId, HttpServletRequest request, @RequestBody RequestDetails mso_request) {
431
432 String methodName = "deleteVfModule";
433 LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
434
435 MsoResponseWrapper w = msoBusinessLogic.deleteVfModule(mso_request, serviceInstanceId, vnfInstanceId, vfModuleId);
436
437 // always return OK, the MSO status code is embedded in the body
438 return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
439 }
440
441 /**
442 * Delete volume group instance.
443 *
444 * @param serviceInstanceId the service instance id
445 * @param vnfInstanceId the vnf instance id
446 * @param volumeGroupId the volume group id
447 * @param request the request
448 * @return the response entity
449 * @throws Exception the exception
450 */
451 @RequestMapping(value = "/mso_delete_volumegroup_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}/volumeGroups/{volumeGroupId}", method = RequestMethod.POST)
452 public ResponseEntity<String> deleteVolumeGroupInstance(
453 @PathVariable("serviceInstanceId") String serviceInstanceId, @PathVariable("vnfInstanceId") String vnfInstanceId, @PathVariable("volumeGroupId") String volumeGroupId,
454 HttpServletRequest request, @RequestBody RequestDetails mso_request) {
455 String methodName = "deleteVolumeGroupInstance";
456 LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
457
458 MsoResponseWrapper w = msoBusinessLogic.deleteVolumeGroupInstance(mso_request, serviceInstanceId, vnfInstanceId, volumeGroupId);
459
460 // always return OK, the MSO status code is embedded in the body
461 return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
462 }
463
464 /**
465 * Delete nw instance.
466 *
467 * @param serviceInstanceId the service instance id
468 * @param networkInstanceId the network instance id
469 * @param request the request
470 * @return the response entity
471 * @throws Exception the exception
472 */
473 @RequestMapping(value = "/mso_delete_nw_instance/{serviceInstanceId}/networks/{networkInstanceId}", method = RequestMethod.POST)
474 public ResponseEntity<String> deleteNwInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
475 @PathVariable("networkInstanceId") String networkInstanceId, HttpServletRequest request, @RequestBody RequestDetails mso_request) {
476 String methodName = "deleteNwInstance";
477 LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
478
479 MsoResponseWrapper w = msoBusinessLogic.deleteNwInstance(mso_request, serviceInstanceId, networkInstanceId);
480
481 // always return OK, the MSO status code is embedded in the body
482 return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
483 }
484
485 /**
486 * Gets the orchestration request.
487 *
488 * @param requestId the request id
489 * @param request the request
490 * @return the orchestration request
491 * @throws Exception the exception
492 */
493 @RequestMapping(value = "/mso_get_orch_req/{requestId}", method = RequestMethod.GET)
494 public ResponseEntity<String> getOrchestrationRequest(@PathVariable("requestId") String requestId,
495 HttpServletRequest request) {
496
497 String methodName = "getOrchestrationRequest";
498 LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
499
500
501 MsoResponseWrapper w = msoBusinessLogic.getOrchestrationRequest(requestId);
502
503 // always return OK, the MSO status code is embedded in the body
504 return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
505 }
506
507 /**
508 * Gets the orchestration requests.
509 *
510 * @param filterString the filter string
511 * @param request the request
512 * @return the orchestration requests
513 * @throws Exception the exception
514 */
515 @RequestMapping(value = "/mso_get_orch_reqs/{filterString}", method = RequestMethod.GET)
516 public ResponseEntity<String> getOrchestrationRequests(@PathVariable("filterString") String filterString,
517 HttpServletRequest request) {
518
519 String methodName = "getOrchestrationRequests";
520 LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
521
522
523 MsoResponseWrapper w = msoBusinessLogic.getOrchestrationRequests(filterString);
524
525 // always return OK, the MSO status code is embedded in the body
526 return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
527 }
528
529 /**
530 * activate to a pnf instance.
531 *
532 * @param serviceInstanceId the id of the service.
533 * @param requestDetails the body of the request.
534 * @return the response entity
535 * @throws Exception the exception
536 */
537 @RequestMapping(value = "/mso_activate_service_instance/{serviceInstanceId}", method = RequestMethod.POST)
538 public ResponseEntity<String> activateServiceInstance(@PathVariable("serviceInstanceId") String serviceInstanceId, @RequestBody RequestDetails requestDetails) {
539 String methodName = "activateServiceInstance";
540 LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
541
542 MsoResponseWrapper w = msoBusinessLogic.setServiceInstanceStatus(requestDetails, serviceInstanceId, true);
543 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
544 }
545
546 /**
547 * deactivate a service instance.
548 *
549 * @param serviceInstanceId the id of the service.
550 * @param requestDetails the body of the request.
551 * @return the response entity
552 * @throws Exception the exception
553 */
554 @RequestMapping(value = "/mso_deactivate_service_instance/{serviceInstanceId}", method = RequestMethod.POST)
555 public ResponseEntity<String> deactivateServiceInstance(@PathVariable("serviceInstanceId") String serviceInstanceId, @RequestBody RequestDetails requestDetails) {
556 String methodName = "deactivateServiceInstance";
557 LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
558
559 MsoResponseWrapper w = msoBusinessLogic.setServiceInstanceStatus(requestDetails, serviceInstanceId, false);
560 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
561 }
562
563 /**
564 * Gets the orchestration requests for the dashboard.
565 * currently its all the orchestration requests with RequestType updateInstance or replaceInstance.
566 * @return the orchestration requests
567 * @throws Exception the exception
568 */
569 @RequestMapping(value = "/mso_get_orch_reqs/dashboard", method = RequestMethod.GET)
570 public List<Request> getOrchestrationRequestsForDashboard() {
571
572 String methodName = "getOrchestrationRequestsForDashboard";
573 LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
574
575
576 return msoBusinessLogic.getOrchestrationRequestsForDashboard();
577 }
578
579 /**
580 * Gets the Manual Tasks for the given request id.
581 *
582 * @param originalRequestId the id of the original request.
583 * @return the tasks
584 * @throws Exception the exception
585 */
586 @RequestMapping(value = "/mso_get_man_task/{originalRequestId}", method = RequestMethod.GET)
587 public List<Task> getManualTasksByRequestId(@PathVariable("originalRequestId") String originalRequestId) {
588
589 String methodName = "getManualTasksByRequestId";
590 LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
591
592 return msoBusinessLogic.getManualTasksByRequestId(originalRequestId);
593 }
594
595 /**
596 * Complete the manual task.
597 *
598 * @param taskId the id of the task to complete.
599 * @param requestDetails the body of the request.
600 * @return the response entity
601 * @throws Exception the exception
602 */
603 @RequestMapping(value = "/mso_post_man_task/{taskId}", method = RequestMethod.POST)
604 public ResponseEntity<String> manualTaskComplete(@PathVariable("taskId") String taskId , @RequestBody RequestDetails requestDetails) {
605
606 String methodName = "manualTaskComplete";
607 LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
608
609 MsoResponseWrapper w = msoBusinessLogic.completeManualTask(requestDetails, taskId);
610 return new ResponseEntity<String>(w.getResponse(), HttpStatus.OK);
611 }
612
613 @RequestMapping(value = "/mso_remove_relationship/{serviceInstanceId}", method = RequestMethod.POST)
614 public ResponseEntity<String> removeRelationshipFromServiceInstance(@PathVariable("serviceInstanceId") String serviceInstanceId ,
615 @RequestBody RequestDetails requestDetails) {
616
617 String methodName = "removeRelationshipFromServiceInstance";
618 LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
619
620 MsoResponseWrapper w;
621 try {
622 w = msoBusinessLogic.removeRelationshipFromServiceInstance(requestDetails, serviceInstanceId);
623 } catch (Exception e){
624 LOGGER.error("Internal error when calling MSO controller logic for {}", methodName, e);
625 return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
626 }
627 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
628 }
629
630 @RequestMapping(value = "/mso_add_relationship/{serviceInstanceId}", method = RequestMethod.POST)
631 public ResponseEntity<String> addRelationshipToServiceInstance(@PathVariable("serviceInstanceId") String serviceInstanceId ,
632 @RequestBody RequestDetails requestDetails) {
633
634 String methodName = "addRelationshipToServiceInstance";
635 LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
636
637 MsoResponseWrapper w;
638 try {
639 w = msoBusinessLogic.addRelationshipToServiceInstance(requestDetails, serviceInstanceId);
640 } catch (Exception e){
641 LOGGER.error("Internal error when calling MSO controller logic for {}", methodName, e);
642 return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
643 }
644 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
645 }
646
647 /**
648 * Exception handler.
649 *
650 * @param e the e
651 * @param response the response
652 * @throws IOException Signals that an I/O exception has occurred.
653 */
654 @ExceptionHandler(Exception.class)
655 private void exceptionHandler(Exception e, HttpServletResponse response) throws IOException {
656
657 /*
658 * The following "logger.error" lines "should" be sufficient for logging the exception.
659 * However, the console output in my Eclipse environment is NOT showing ANY of the
660 * logger statements in this class. Thus the temporary "e.printStackTrace" statement
661 * is also included.
662 */
663
664 String methodName = "exceptionHandler";
665 LOGGER.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
666 StringWriter sw = new StringWriter();
667 e.printStackTrace(new PrintWriter(sw));
668 LOGGER.error(EELFLoggerDelegate.errorLogger, sw.toString());
669
670 /*
671 * Temporary - IF the above mentioned "logger.error" glitch is resolved ...
672 * this statement could be removed since it would then likely result in duplicate
673 * trace output.
674 */
675 e.printStackTrace(System.err);
676
677 response.setContentType("application/json; charset=UTF-8");
678 response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
679
680 ExceptionResponse exceptionResponse = new ExceptionResponse();
681 exceptionResponse.setException(e.getClass().toString().replaceFirst("^.*\\.", ""));
682 exceptionResponse.setMessage(e.getMessage());
683
684 response.getWriter().write(new ObjectMapper().writeValueAsString(exceptionResponse));
685
686 response.flushBuffer();
687
688 }
689}