2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
6 * Modifications Copyright (C) 2019 Bell Canada
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.policy.admin;
24 import com.fasterxml.jackson.databind.ObjectMapper;
26 import java.util.HashMap;
29 import javax.servlet.http.HttpServletRequest;
30 import javax.servlet.http.HttpServletResponse;
32 import org.json.JSONObject;
33 import org.onap.policy.common.logging.flexlogger.FlexLogger;
34 import org.onap.policy.common.logging.flexlogger.Logger;
35 import org.onap.portalsdk.core.controller.RestrictedBaseController;
36 import org.onap.portalsdk.core.web.support.JsonMessage;
37 import org.onap.portalsdk.core.web.support.UserUtils;
38 import org.springframework.stereotype.Controller;
39 import org.springframework.web.bind.annotation.RequestMapping;
40 import org.springframework.web.bind.annotation.RequestMethod;
44 public class PolicyUserInfoController extends RestrictedBaseController {
46 private static final Logger LOGGER = FlexLogger.getLogger(PolicyUserInfoController.class);
49 * getPolicyUserInfo - fills the HTTP response with user information.
51 * @param request HttpServletRequest
52 * @param response HttpServletResponse
54 @RequestMapping(value = "/get_PolicyUserInfo", method = RequestMethod.GET)
55 public void getPolicyUserInfo(HttpServletRequest request, HttpServletResponse response) {
57 String userId = UserUtils.getUserSession(request).getOrgUserId();
58 Map<String, Object> model = new HashMap<>();
59 model.put("userid", userId);
60 response.getWriter().write(new JSONObject(new JsonMessage(
61 new ObjectMapper().writeValueAsString(model))).toString());
62 } catch (Exception e) {
63 LOGGER.error("Exception Occurred" + e);