nexus site path corrected
[portal.git] / ecomp-portal-BE / src / main / java / org / openecomp / portalapp / portal / controller / GetAccessController.java
1 /*-
2  * ================================================================================
3  * eCOMP Portal
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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  * ================================================================================
19  */
20 package org.openecomp.portalapp.portal.controller;
21
22 import java.io.IOException;
23 import java.util.Collections;
24 import java.util.Comparator;
25 import java.util.List;
26
27 import javax.servlet.http.HttpServletRequest;
28
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;
40
41
42 @RestController
43 @org.springframework.context.annotation.Configuration
44 @EnableAspectJAutoProxy
45 @EPAuditLog
46 public class GetAccessController extends EPUnRestrictedBaseController {
47
48         EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(GetAccessController.class);
49
50         @Autowired
51         GetAccessService getAccessService;
52
53         /**
54          * Sorts the list by ECOMP function name.
55          */
56         private Comparator<GetAccessResult> getAccessComparator = new Comparator<GetAccessResult>() {
57                 public int compare(GetAccessResult o1, GetAccessResult o2) {
58                         return o1.getEcompFunction().compareTo(o2.getEcompFunction());
59                 }
60         };
61         
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);
68                 return appsList;
69         }
70 }