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.portal.controller;
22 import java.io.IOException;
23 import java.util.Collections;
24 import java.util.Comparator;
25 import java.util.List;
27 import javax.servlet.http.HttpServletRequest;
29 import org.springframework.beans.factory.annotation.Autowired;
30 import org.springframework.context.annotation.EnableAspectJAutoProxy;
31 import org.springframework.web.bind.annotation.RequestMapping;
32 import org.springframework.web.bind.annotation.RequestMethod;
33 import org.springframework.web.bind.annotation.RestController;
35 import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
36 import org.openecomp.portalapp.controller.EPUnRestrictedBaseController;
37 import org.openecomp.portalapp.portal.domain.EPUser;
38 import org.openecomp.portalapp.portal.domain.GetAccessResult;
39 import org.openecomp.portalapp.portal.logging.aop.EPAuditLog;
40 import org.openecomp.portalapp.portal.service.GetAccessService;
41 import org.openecomp.portalapp.portal.utils.EcompPortalUtils;
42 import org.openecomp.portalapp.util.EPUserUtils;
45 @org.springframework.context.annotation.Configuration
46 @EnableAspectJAutoProxy
48 public class GetAccessController extends EPUnRestrictedBaseController {
50 EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(GetAccessController.class);
53 GetAccessService getAccessService;
56 * Sorts the list by ECOMP function name.
58 private Comparator<GetAccessResult> getAccessComparator = new Comparator<GetAccessResult>() {
59 public int compare(GetAccessResult o1, GetAccessResult o2) {
60 return o1.getAppName().compareTo(o2.getAppName());
64 @RequestMapping(value = { "/portalApi/getAppList" }, method = RequestMethod.GET, produces = "application/json")
65 public List<GetAccessResult> getAppList(HttpServletRequest request) throws IOException {
66 List<GetAccessResult> appsList = null;
67 EPUser user = EPUserUtils.getUserSession(request);
68 appsList = getAccessService.getAppAccessList(user);
69 Collections.sort(appsList, getAccessComparator);
70 EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/getAppList", "result =", appsList);