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.openecomp.vid.controller.test;
23 import java.io.IOException;
25 import javax.servlet.http.HttpServletRequest;
26 import javax.servlet.http.HttpServletResponse;
28 import org.codehaus.jackson.map.ObjectMapper;
29 import org.openecomp.vid.model.ExceptionResponse;
30 import org.springframework.web.bind.annotation.ExceptionHandler;
31 import org.springframework.web.bind.annotation.PathVariable;
32 import org.springframework.web.bind.annotation.RequestMapping;
33 import org.springframework.web.bind.annotation.RequestMethod;
34 import org.springframework.web.bind.annotation.RestController;
36 import org.openecomp.portalsdk.core.controller.RestrictedBaseController;
39 * The Class TestAaiController.
42 @RequestMapping("testaai")
43 public class TestAaiController extends RestrictedBaseController {
46 * Gets the subscription service type list.
48 * @param globalCustomerId the global customer id
49 * @param request the request
50 * @return the subscription service type list
51 * @throws Exception the exception
53 @RequestMapping(value = "/getSubscriptionServiceTypeList/{globalCustomerId}", method = RequestMethod.GET)
54 public String getSubscriptionServiceTypeList(@PathVariable("globalCustomerId") String globalCustomerId, HttpServletRequest request)
57 System.err.println("GET SUBSCRIPTION SERVICE TYPE LIST: globalCustomerId: " + globalCustomerId);
59 return "[\"vMOG\", \"sevice type 2\", \"sevice type 3\", \"sevice type 4\"]";
66 * @param response the response
67 * @throws IOException Signals that an I/O exception has occurred.
69 @ExceptionHandler(Exception.class)
70 private void exception(Exception e, HttpServletResponse response) throws IOException {
73 * This logging step should preferably be replaced with an appropriate
74 * logging method consistent whatever logging mechanism the rest of the
75 * application code uses.
78 e.printStackTrace(System.err);
80 response.setContentType("application/json; charset=UTF-8");
81 response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
83 ExceptionResponse exceptionResponse = new ExceptionResponse();
84 exceptionResponse.setException(e.getClass().toString().replaceFirst("^.*\\.", ""));
85 exceptionResponse.setMessage(e.getMessage());
87 response.getWriter().write(new ObjectMapper().writeValueAsString(exceptionResponse));
89 response.flushBuffer();