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