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.openecomp.portalapp.controller.EPUnRestrictedBaseController;
30 import org.openecomp.portalapp.portal.domain.GetAccessResult;
31 import org.openecomp.portalapp.portal.logging.aop.EPAuditLog;
32 import org.openecomp.portalapp.portal.service.GetAccessService;
33 import org.openecomp.portalapp.portal.utils.EcompPortalUtils;
34 import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
35 import org.springframework.beans.factory.annotation.Autowired;
36 import org.springframework.context.annotation.EnableAspectJAutoProxy;
37 import org.springframework.web.bind.annotation.RequestMapping;
38 import org.springframework.web.bind.annotation.RequestMethod;
39 import org.springframework.web.bind.annotation.RestController;
43 @org.springframework.context.annotation.Configuration
44 @EnableAspectJAutoProxy
46 public class GetAccessController extends EPUnRestrictedBaseController {
48 EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(GetAccessController.class);
51 GetAccessService getAccessService;
54 * Sorts the list by ECOMP function name.
56 private Comparator<GetAccessResult> getAccessComparator = new Comparator<GetAccessResult>() {
57 public int compare(GetAccessResult o1, GetAccessResult o2) {
58 return o1.getEcompFunction().compareTo(o2.getEcompFunction());
62 @RequestMapping(value = { "/portalApi/getAppList" }, method = RequestMethod.GET, produces = "application/json")
63 public List<GetAccessResult> getAppList(HttpServletRequest request) throws IOException {
64 List<GetAccessResult> appsList = null;
65 appsList = getAccessService.getAppAccessList();
66 Collections.sort(appsList, getAccessComparator);
67 EcompPortalUtils.logAndSerializeObject("/portalApi/getAppList", "result =", appsList);