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;
22 import java.io.IOException;
23 import java.util.HashMap;
24 import java.util.List;
27 import javax.servlet.http.HttpServletRequest;
29 import org.openecomp.portalapp.portal.logging.aop.EPAuditLog;
30 import org.openecomp.portalapp.portal.utils.EcompPortalUtils;
31 import org.openecomp.portalapp.service.EPProfileService;
32 import org.openecomp.portalsdk.core.domain.Profile;
33 import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
34 import org.springframework.beans.factory.annotation.Autowired;
35 import org.springframework.context.annotation.EnableAspectJAutoProxy;
36 import org.springframework.stereotype.Controller;
37 import org.springframework.web.bind.annotation.RequestMapping;
38 import org.springframework.web.bind.annotation.RequestMethod;
39 import org.springframework.web.servlet.ModelAndView;
41 import com.fasterxml.jackson.core.JsonGenerationException;
42 import com.fasterxml.jackson.databind.JsonMappingException;
43 import com.fasterxml.jackson.databind.ObjectMapper;
47 @org.springframework.context.annotation.Configuration
48 @EnableAspectJAutoProxy
50 public class UserProfileController extends EPRestrictedBaseController {
53 EPProfileService service;
55 EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(UserProfileController.class);
57 @RequestMapping(value = {"/user_profile" }, method = RequestMethod.GET)
58 public ModelAndView ProfileSearch(HttpServletRequest request) {
59 Map<String, Object> model = new HashMap<String, Object>();
60 ObjectMapper mapper = new ObjectMapper();
63 List<Profile> profileList = service.findAll();
64 model.put("customerInfo", mapper.writeValueAsString(profileList));
65 } catch (JsonGenerationException e) {
66 logger.error(EELFLoggerDelegate.errorLogger, "Encountered an JsonGenerationException while performing the ProfileSearch, Details:" + EcompPortalUtils.getStackTrace(e));
67 } catch (JsonMappingException e) {
68 logger.error(EELFLoggerDelegate.errorLogger, "Encountered an JsonMappingException while performing the ProfileSearch, Details:" + EcompPortalUtils.getStackTrace(e));
69 } catch (IOException e) {
70 logger.error(EELFLoggerDelegate.errorLogger, "Encountered an IOException while performing the ProfileSearch, Details:" + EcompPortalUtils.getStackTrace(e));
71 } catch (Exception e) {
72 logger.error(EELFLoggerDelegate.errorLogger, "Encountered an Exception while performing the ProfileSearch, Details:" + EcompPortalUtils.getStackTrace(e));
75 return new ModelAndView("user_profile", "model", model);