diff options
Diffstat (limited to 'PolicyEngineUtils/src/main/java/org/onap/policy/api')
7 files changed, 386 insertions, 0 deletions
diff --git a/PolicyEngineUtils/src/main/java/org/onap/policy/api/LoadedPolicy.java b/PolicyEngineUtils/src/main/java/org/onap/policy/api/LoadedPolicy.java new file mode 100644 index 000000000..25636fb45 --- /dev/null +++ b/PolicyEngineUtils/src/main/java/org/onap/policy/api/LoadedPolicy.java @@ -0,0 +1,57 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineUtils + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.api; + +import java.util.Map; +/** + * <code>LoadedPolicy</code> defines the Policy that has been Loaded into the PDP. + * + * @version 0.2 + */ +public interface LoadedPolicy { + /** + * Gets the <code>String</code> format of the Policy Name that has been Loaded into the PDP. + * + * @return <code>String</code> format of Policy Name + */ + public String getPolicyName(); + + /** + * Gets the <code>String</code> format of the Policy Version that has been Loaded into the PDP. + * + * @return <code>String</code> format of the Policy Version. + */ + public String getVersionNo(); + + /** + * Gets the <code>Map</code> of <code>String,String</code> format of the Matches if the policy Loaded is of Config Type. + * + * @return the <code>Map</code> of <code>String,String</code> format of the matches in the policy. + */ + public Map<String, String> getMatches(); + + /** + * Gets the <code>UpdateType</code> of {@link org.onap.policy.api.UpdateType} received. + * + * @return <code>UpdateType</code> associated with this <code>PDPNotification</code> + */ + public UpdateType getUpdateType(); +} diff --git a/PolicyEngineUtils/src/main/java/org/onap/policy/api/NotificationHandler.java b/PolicyEngineUtils/src/main/java/org/onap/policy/api/NotificationHandler.java new file mode 100644 index 000000000..6484a9d7e --- /dev/null +++ b/PolicyEngineUtils/src/main/java/org/onap/policy/api/NotificationHandler.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineUtils + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.api; +/** + * Defines the methods which need to run when an Event or Notification is received. + * + * @version 0.1 + */ +public interface NotificationHandler { + /** + * <code>notificationReceived</code> method will be triggered automatically whenever a Notification is received by the PEP. + * + * @param notification <code>PDPNotification</code> of {@link org.onap.policy.api.PDPNotification} is the object that has information of the notification. + */ + public void notificationReceived(PDPNotification notification); +} diff --git a/PolicyEngineUtils/src/main/java/org/onap/policy/api/NotificationType.java b/PolicyEngineUtils/src/main/java/org/onap/policy/api/NotificationType.java new file mode 100644 index 000000000..730ad022d --- /dev/null +++ b/PolicyEngineUtils/src/main/java/org/onap/policy/api/NotificationType.java @@ -0,0 +1,58 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineUtils + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.api; + +/** + * Enumeration of the Update Type that has occurred in the <code>PDPNotification</code> of + * {@link org.onap.policy.api.PDPNotification} + * + * @version 0.1 + */ +public enum NotificationType { + /** + * Indicates that a policy has been updated + */ + UPDATE("update"), + /** + * Indicates that a policy has been removed + */ + REMOVE("remove"), + /** + * Indicates that both update and removal of policy events has occurred. + */ + BOTH("both") + ; + + private String name; + + private NotificationType(String name){ + this.name = name; + } + + /** + * Returns the <code>String</code> format of the Type for this <code>UpdateType</code> + * @return the <code>String</code> Type of <code>UpdateType</code> + */ + @Override + public String toString(){ + return this.name; + } +} diff --git a/PolicyEngineUtils/src/main/java/org/onap/policy/api/PDPNotification.java b/PolicyEngineUtils/src/main/java/org/onap/policy/api/PDPNotification.java new file mode 100644 index 000000000..a88ec06cb --- /dev/null +++ b/PolicyEngineUtils/src/main/java/org/onap/policy/api/PDPNotification.java @@ -0,0 +1,52 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineUtils + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.api; + +import java.util.Collection; + +/** + * Defines the <code>Notification</code> event sent from PDP to Client PEP. + * + * @version 0.2 + */ +public interface PDPNotification { + /** + * Gets the <code>Collection</code> of {@link org.onap.policy.api.RemovedPolicy} objects received. + * + * @return the <code>Collection</code> which consists of <code>RemovedPolicy</code> objects. + */ + public Collection<RemovedPolicy> getRemovedPolicies(); + + /** + * Gets the <code>Collection</code> of {@link org.onap.policy.api.LoadedPolicy} objects receieved. + * + * @return the <code>Collection</code> which consists of <code>UpdatedPolicy</code> objects. + */ + public Collection<LoadedPolicy> getLoadedPolicies(); + + /** + * Gets the <code>NotificationType</code> of {@link org.onap.policy.api.NotificationType} received. + * + * @return <code>NotificationType</code> associated with this <code>PDPNotification</code> + */ + public NotificationType getNotificationType(); + +} diff --git a/PolicyEngineUtils/src/main/java/org/onap/policy/api/PEDependency.java b/PolicyEngineUtils/src/main/java/org/onap/policy/api/PEDependency.java new file mode 100644 index 000000000..d722f1696 --- /dev/null +++ b/PolicyEngineUtils/src/main/java/org/onap/policy/api/PEDependency.java @@ -0,0 +1,90 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineUtils + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.api; + +import org.apache.maven.model.Dependency; +import org.apache.maven.model.Exclusion; + +public class PEDependency{ + + private String groupId; + private String artifactId; + private String version; + private String classifier; + private String type; + private String scope; + private java.util.List<Exclusion> exclusions; + + public String getGroupId() { + return groupId; + } + public void setGroupId(String groupId) { + this.groupId = groupId; + } + public String getArtifactId() { + return artifactId; + } + public void setArtifactId(String artifactId) { + this.artifactId = artifactId; + } + public String getVersion() { + return version; + } + public void setVersion(String version) { + this.version = version; + } + public java.util.List<Exclusion> getExclusions() { + return exclusions; + } + public void setExclusions(java.util.List<Exclusion> exclusions) { + this.exclusions = exclusions; + } + public String getClassifier() { + return classifier; + } + public void setClassifier(String classifier) { + this.classifier = classifier; + } + public String getType() { + return type; + } + public void setType(String type) { + this.type = type; + } + public String getScope() { + return scope; + } + public void setScope(String scope) { + this.scope = scope; + } + + public Dependency getDependency(){ + Dependency dependency = new Dependency(); + dependency.setArtifactId(artifactId); + dependency.setGroupId(groupId); + dependency.setVersion(version); + dependency.setExclusions(exclusions); + dependency.setClassifier(classifier); + dependency.setScope(scope); + dependency.setType(type); + return dependency; + } +} diff --git a/PolicyEngineUtils/src/main/java/org/onap/policy/api/RemovedPolicy.java b/PolicyEngineUtils/src/main/java/org/onap/policy/api/RemovedPolicy.java new file mode 100644 index 000000000..f26c1499a --- /dev/null +++ b/PolicyEngineUtils/src/main/java/org/onap/policy/api/RemovedPolicy.java @@ -0,0 +1,41 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineUtils + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.api; +/** + * <code>RemovedPolicy</code> defines the Policy that has been removed + * + * @version 0.1 + */ +public interface RemovedPolicy { + /** + * Gets the <code>String</code> format of the Policy Name that has been removed. + * + * @return <code>String</code> format of Policy Name + */ + public String getPolicyName(); + + /** + * Gets the <code>String</code> format of the Policy Version that has been removed. + * + * @return <code>String</code> format of Policy Version + */ + public String getVersionNo(); +} diff --git a/PolicyEngineUtils/src/main/java/org/onap/policy/api/UpdateType.java b/PolicyEngineUtils/src/main/java/org/onap/policy/api/UpdateType.java new file mode 100644 index 000000000..deeecddd0 --- /dev/null +++ b/PolicyEngineUtils/src/main/java/org/onap/policy/api/UpdateType.java @@ -0,0 +1,54 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineUtils + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.api; + +/** + * Enumeration of the Update Type that has occurred in the <code>UpdatedPolicy</code> of + * {@link org.onap.policy.api.LoadedPolicy} + * + * @version 0.1 + */ +public enum UpdateType { + /** + * Indicates that a policy has been updated + */ + UPDATE("update"), + /** + * Indicates that a policy is new + */ + NEW("new") + ; + + private String name; + + private UpdateType(String name){ + this.name = name; + } + + /** + * Returns the <code>String</code> format of the Type for this <code>UpdateType</code> + * @return the <code>String</code> Type of <code>UpdateType</code> + */ + @Override + public String toString(){ + return this.name; + } +} |