2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END============================================
20 * ===================================================================
21 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
24 package org.onap.clamp.clds.model;
26 import com.att.eelf.configuration.EELFLogger;
27 import com.att.eelf.configuration.EELFManager;
29 import java.io.Serializable;
30 import java.util.ArrayList;
31 import java.util.List;
33 import javax.ws.rs.NotAuthorizedException;
35 import org.onap.clamp.clds.dao.CldsDao;
36 import org.onap.clamp.clds.service.CldsService;
38 public class CldsServiceData implements Serializable {
40 private static final long serialVersionUID = -9153372664377279423L;
42 protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsServiceData.class);
43 protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger();
45 private String serviceInvariantUUID;
46 private String serviceUUID;
47 private Long ageOfRecord;
48 private List<CldsVfData> cldsVfs;
50 public String getServiceInvariantUUID() {
51 return serviceInvariantUUID;
54 public void setServiceInvariantUUID(String serviceInvariantUUID) {
55 this.serviceInvariantUUID = serviceInvariantUUID;
58 public List<CldsVfData> getCldsVfs() {
62 public void setCldsVfs(List<CldsVfData> cldsVfs) {
63 this.cldsVfs = cldsVfs;
66 public String getServiceUUID() {
70 public void setServiceUUID(String serviceUUID) {
71 this.serviceUUID = serviceUUID;
74 public CldsServiceData getCldsServiceCache(CldsDao cldsDao, String invariantServiceUUID) {
75 return cldsDao.getCldsServiceCache(invariantServiceUUID);
78 public void setCldsServiceCache(CldsDao cldsDao, CldsDBServiceCache cldsDBServiceCache) {
79 cldsDao.setCldsServiceCache(cldsDBServiceCache);
82 public Long getAgeOfRecord() {
86 public void setAgeOfRecord(Long ageOfRecord) {
87 this.ageOfRecord = ageOfRecord;
91 * Filter out any VFs that the user is not authorized for. Use the
92 * CldsService to determine if the user is authorized for a VF.
96 public void filterVfs(CldsService svc) {
97 List<CldsVfData> filteredCldsVfs = new ArrayList<>();
98 if (cldsVfs == null) {
99 logger.debug("cldsVfs == null");
101 for (CldsVfData vf : cldsVfs) {
102 // if user is authorized for the VF then add it to the filtered
105 if (svc.isAuthorizedForVf(vf.getVfInvariantResourceUUID())) {
106 filteredCldsVfs.add(vf);
108 } catch (NotAuthorizedException e) {
109 logger.error("user not authorized for {}" + vf.getVfInvariantResourceUUID(), e);
110 // when not NotAuthorizedException - don't add to
111 // filteredCldsVfs list
115 // new filtered list replaces the list of VFs for the user
116 cldsVfs = filteredCldsVfs;