2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
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 * ============LICENSE_END=========================================================
21 package org.onap.policy.xacml.std.pap;
23 import com.att.research.xacml.api.pap.PDPPIPConfig;
24 import com.att.research.xacml.api.pap.PDPPolicy;
25 import com.att.research.xacml.api.pap.PDPStatus;
27 import java.io.Serializable;
28 import java.util.Collections;
29 import java.util.HashSet;
30 import java.util.Properties;
33 import org.onap.policy.xacml.api.pap.OnapPDP;
35 public class StdPDP extends StdPDPItemSetChangeNotifier implements OnapPDP, Comparable<StdPDP>, Serializable {
36 private static final long serialVersionUID = 1L;
42 private String description;
44 private Integer jmxport = 0;
46 private transient PDPStatus status = new StdPDPStatus();
48 private transient Set<PDPPolicy> policies = new HashSet<>();
50 private transient Set<PDPPIPConfig> pipConfigs = new HashSet<>();
54 // Default constructor
58 public StdPDP(String id, Integer jmxport) {
59 this(id, null, null, jmxport);
62 public StdPDP(String id, String name, Integer jmxport) {
63 this(id, name, null, jmxport);
71 * @param description String
72 * @param jmxport Integer
74 public StdPDP(String id, String name, String description, Integer jmxport) {
77 this.description = description;
78 if (jmxport != null) {
79 this.jmxport = jmxport;
87 * @param properties Properties
89 public StdPDP(String id, Properties properties) {
92 this.initialize(properties);
98 * @param properties Properties
100 public void initialize(Properties properties) {
101 for (Object key : properties.keySet()) {
102 if (key.toString().startsWith(this.id + ".")) {
103 if (key.toString().endsWith(".name")) {
104 this.name = properties.getProperty(key.toString());
105 } else if (key.toString().endsWith(".description")) {
106 this.description = properties.getProperty(key.toString());
107 } else if (key.toString().endsWith(".jmxport")) {
108 if (properties.getProperty(key.toString()) != null
109 && properties.getProperty(key.toString()).trim().length() > 0) {
110 this.jmxport = Integer.valueOf(properties.getProperty(key.toString()));
120 public String getId() {
124 public void setId(String id) {
129 public String getName() {
134 public void setName(String name) {
136 this.firePDPChanged(this);
140 public String getDescription() {
141 return this.description;
145 public void setDescription(String description) {
146 this.description = description;
147 this.firePDPChanged(this);
151 public PDPStatus getStatus() {
155 public void setStatus(PDPStatus status) {
156 this.status = status;
160 public Set<PDPPolicy> getPolicies() {
161 return Collections.unmodifiableSet(this.policies);
164 public void setPolicies(Set<PDPPolicy> policies) {
165 this.policies = policies;
169 public Set<PDPPIPConfig> getPipConfigs() {
170 return Collections.unmodifiableSet(this.pipConfigs);
173 public void setPipConfigs(Set<PDPPIPConfig> pipConfigs) {
174 this.pipConfigs = pipConfigs;
178 public void setJmxPort(Integer jmxport) {
179 this.jmxport = jmxport;
183 public Integer getJmxPort() {
188 public int hashCode() {
189 final int prime = 31;
191 result = prime * result + ((id == null) ? 0 : id.hashCode());
196 public boolean equals(Object obj) {
203 if (getClass() != obj.getClass()) {
206 StdPDP other = (StdPDP) obj;
208 if (other.id != null) {
211 } else if (!id.equals(other.id)) {
218 public String toString() {
219 return "StdPDP [id=" + id + ", name=" + name + ", description=" + description + ", jmxport=" + jmxport
220 + ", status=" + status + ", policies=" + policies + ", pipConfigs=" + pipConfigs + "]";
224 // Comparable interface
227 public int compareTo(StdPDP object) {
228 if (object == null) {
231 if (object.name == null) {
237 return name.compareTo(object.name);