2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2018 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 * ===================================================================
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.service.CldsService;
37 public class CldsServiceData implements Serializable {
39 private static final long serialVersionUID = -9153372664377279423L;
40 protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsServiceData.class);
41 protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger();
42 private String serviceInvariantUuid;
43 private String serviceUiod;
44 private Long ageOfRecord;
45 private List<CldsVfData> cldsVfs;
47 public String getServiceInvariantUUID() {
48 return serviceInvariantUuid;
51 public void setServiceInvariantUUID(String serviceInvariantUuid) {
52 this.serviceInvariantUuid = serviceInvariantUuid;
55 public List<CldsVfData> getCldsVfs() {
59 public void setCldsVfs(List<CldsVfData> cldsVfs) {
60 this.cldsVfs = cldsVfs;
63 public String getServiceUUID() {
67 public void setServiceUUID(String serviceUuid) {
68 this.serviceUiod = serviceUuid;
71 public Long getAgeOfRecord() {
75 public void setAgeOfRecord(Long ageOfRecord) {
76 this.ageOfRecord = ageOfRecord;
80 * Filter out any VFs that the user is not authorized for. Use the
81 * CldsService to determine if the user is authorized for a VF.
83 * @param svc The clds service
85 public void filterVfs(CldsService svc) {
86 List<CldsVfData> filteredCldsVfs = new ArrayList<>();
87 if (cldsVfs == null) {
88 logger.debug("cldsVfs == null");
90 for (CldsVfData vf : cldsVfs) {
91 // if user is authorized for the VF then add it to the filtered
94 if (svc.isAuthorizedForVf(vf.getVfInvariantResourceUUID())) {
95 filteredCldsVfs.add(vf);
97 } catch (NotAuthorizedException e) {
98 logger.error("user not authorized for {}" + vf.getVfInvariantResourceUUID(), e);
99 // when not NotAuthorizedException - don't add to
100 // filteredCldsVfs list
104 // new filtered list replaces the list of VFs for the user
105 cldsVfs = filteredCldsVfs;