2 * ================================================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property
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 * ================================================================================
20 package org.openecomp.portalapp.controller.sample;
22 import java.util.HashMap;
23 import java.util.List;
26 import javax.servlet.http.HttpServletRequest;
27 import javax.servlet.http.HttpServletResponse;
29 import org.json.JSONObject;
30 import org.openecomp.portalsdk.core.controller.RestrictedBaseController;
31 import org.openecomp.portalsdk.core.domain.User;
32 import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
33 import org.openecomp.portalsdk.core.service.UserProfileService;
34 import org.openecomp.portalsdk.core.web.support.JsonMessage;
35 import org.openecomp.portalsdk.core.web.support.UserUtils;
36 import org.springframework.beans.factory.annotation.Autowired;
37 import org.springframework.stereotype.Controller;
38 import org.springframework.web.bind.annotation.RequestMapping;
39 import org.springframework.web.bind.annotation.RequestMethod;
40 import org.springframework.web.servlet.ModelAndView;
42 import com.fasterxml.jackson.databind.ObjectMapper;
46 public class CollaborateListController extends RestrictedBaseController{
48 UserProfileService service;
49 EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(CollaborateListController.class);
51 @RequestMapping(value = {"/collaborate_list" }, method = RequestMethod.GET)
52 public ModelAndView ProfileSearch(HttpServletRequest request) {
53 Map<String, Object> model = new HashMap<String, Object>();
54 ObjectMapper mapper = new ObjectMapper();
55 User user = UserUtils.getUserSession(request);
57 List<User> profileList =null;
59 profileList = service.findAllUserWithOnOffline(user.getOrgUserId());
60 model.put("profileList", mapper.writeValueAsString(profileList));
61 } catch (Exception e) {
62 logger.error(EELFLoggerDelegate.errorLogger, "Error happened during collaborate list search" + e.getMessage());
65 return new ModelAndView(getViewName(),"model", model);
68 @RequestMapping(value = {"/get_collaborate_list" }, method = RequestMethod.GET)
69 public void getCollaborateList(HttpServletRequest request,HttpServletResponse response) {
71 ObjectMapper mapper = new ObjectMapper();
72 User user = UserUtils.getUserSession(request);
74 List<User> profileList =null;
76 profileList = service.findAllUserWithOnOffline(user.getOrgUserId());
77 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(profileList));
78 JSONObject j = new JSONObject(msg);
79 response.getWriter().write(j.toString());
80 } catch (Exception e) {
81 logger.error(EELFLoggerDelegate.errorLogger, "Error happened during get collaborate list" + e.getMessage());