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.service;
23 import java.security.GeneralSecurityException;
24 import java.util.ArrayList;
25 import java.util.LinkedList;
26 import java.util.List;
27 import java.util.TreeSet;
29 import org.openecomp.portalapp.portal.domain.EPApp;
30 import org.openecomp.portalapp.portal.logging.aop.EPMetricsLog;
31 import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
32 import org.openecomp.portalsdk.core.service.DataAccessService;
33 import org.springframework.beans.factory.annotation.Autowired;
34 import org.springframework.context.annotation.EnableAspectJAutoProxy;
35 import org.springframework.stereotype.Service;
36 import org.springframework.transaction.annotation.Transactional;
38 import com.att.nsa.cambria.client.CambriaClientFactory;
39 import com.att.nsa.cambria.client.CambriaTopicManager;
41 @Service("epAppService")
43 @org.springframework.context.annotation.Configuration
44 @EnableAspectJAutoProxy
46 public class EPAppServiceImpl extends EPAppCommonServiceImpl implements EPAppService {
48 private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(EPAppServiceImpl.class);
51 private DataAccessService dataAccessService;
54 public List<EPApp> getUserRemoteApps(String id) {
56 StringBuilder query = new StringBuilder();
58 query.append("SELECT * FROM FN_APP join FN_USER_ROLE ON FN_USER_ROLE.APP_ID = FN_APP.APP_ID where ");
60 "FN_USER_ROLE.USER_ID = " + id + " AND FN_USER_ROLE.ROLE_ID != " + SUPER_ADMIN_ROLE_ID);
61 query.append(" AND FN_APP.ENABLED = 'Y'");
63 TreeSet<EPApp> distinctApps = new TreeSet<EPApp>();
65 @SuppressWarnings("unchecked")
66 List<EPApp> adminApps = dataAccessService.executeSQLQuery(query.toString(), EPApp.class, null);
67 for (EPApp app : adminApps) {
68 distinctApps.add(app);
71 List<EPApp> userApps = new ArrayList<EPApp>();
72 userApps.addAll(distinctApps);
77 public CambriaTopicManager getTopicManager(LinkedList<String> urlList, String key, String secret) throws GeneralSecurityException, Exception{
78 return CambriaClientFactory.createTopicManager( null, urlList, key, secret);