2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 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=========================================================
21 package org.onap.policy.admin;
23 import java.util.HashMap;
26 import javax.servlet.http.HttpServletRequest;
27 import javax.servlet.http.HttpServletResponse;
29 import org.json.JSONObject;
30 import org.onap.policy.common.logging.flexlogger.FlexLogger;
31 import org.onap.policy.common.logging.flexlogger.Logger;
32 import org.onap.portalsdk.core.controller.RestrictedBaseController;
33 import org.onap.portalsdk.core.web.support.JsonMessage;
34 import org.onap.portalsdk.core.web.support.UserUtils;
35 import org.springframework.stereotype.Controller;
36 import org.springframework.web.bind.annotation.RequestMapping;
37 import org.springframework.web.bind.annotation.RequestMethod;
39 import com.fasterxml.jackson.databind.ObjectMapper;
43 public class PolicyUserInfoController extends RestrictedBaseController {
45 private static final Logger LOGGER = FlexLogger.getLogger(PolicyUserInfoController.class);
47 @RequestMapping(value = "/get_PolicyUserInfo", method = RequestMethod.GET)
48 public void getPolicyUserInfo(HttpServletRequest request, HttpServletResponse response) {
51 String userId = UserUtils.getUserSession(request).getOrgUserId();
52 Map<String, Object> model = new HashMap<>();
53 ObjectMapper mapper = new ObjectMapper();
54 model.put("userid", userId);
55 msg = new JsonMessage(mapper.writeValueAsString(model));
56 JSONObject j = new JSONObject(msg);
57 response.getWriter().write(j.toString());
58 } catch (Exception e) {
59 LOGGER.error("Exception Occurred" + e);