* ============LICENSE_START=======================================================
* ONAP Policy Engine
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 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.
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
-import org.onap.policy.utils.PolicyContainer;
-import org.onap.policy.utils.PolicyItemSetChangeNotifier;
+import org.onap.policy.rest.util.PolicyContainer;
+import org.onap.policy.rest.util.PolicyItemSetChangeNotifier;
import org.onap.policy.xacml.api.XACMLErrorConstants;
import org.onap.policy.xacml.api.pap.OnapPDP;
import org.onap.policy.xacml.api.pap.OnapPDPGroup;
import com.att.research.xacml.api.pap.PAPException;
import com.att.research.xacml.api.pap.PDP;
-//import com.att.research.xacml.api.pap.PDP;
-//import com.att.research.xacml.api.pap.PDPGroup;
import com.att.research.xacml.api.pap.PDPPIPConfig;
import com.att.research.xacml.api.pap.PDPPolicy;
public class PDPGroupContainer extends PolicyItemSetChangeNotifier implements PolicyContainer.Indexed, PolicyContainer.ItemSetChangeNotifier {
private static final long serialVersionUID = 1L;
- private static Logger LOGGER = FlexLogger.getLogger(PDPGroupContainer.class);
+ private static final Logger LOGGER = FlexLogger.getLogger(PDPGroupContainer.class);
/**
* String identifier of a file's "Id" property.
*/
- private static String PROPERTY_ID = "Id";
+ private static final String PROPERTY_ID = "Id";
/**
* String identifier of a file's "name" property.
*/
- private static String PROPERTY_NAME = "Name";
+ private static final String PROPERTY_NAME = "Name";
/**
* String identifier of a file's "Description" property.
*/
- private static String PROPERTY_DESCRIPTION = "Description";
+ private static final String PROPERTY_DESCRIPTION = "Description";
/**
* String identifier of a file's "Default" property.
*/
- private static String PROPERTY_DEFAULT = "Default";
+ private static final String PROPERTY_DEFAULT = "Default";
/**
* String identifier of a file's "Status" property.
*/
- private static String PROPERTY_STATUS = "Status";
+ private static final String PROPERTY_STATUS = "Status";
/**
* String identifier of a file's "PDPs" property.
*/
- private static String PROPERTY_PDPS = "PDPs";
+ private static final String PROPERTY_PDPS = "PDPs";
/**
* String identifier of a file's "Policies" property.
*/
- private static String PROPERTY_POLICIES = "Policies";
+ private static final String PROPERTY_POLICIES = "Policies";
/**
* String identifier of a file's "PIP Configurations" property.
*/
- private static String PROPERTY_PIPCONFIG = "PIP Configurations";
+ private static final String PROPERTY_PIPCONFIG = "PIP Configurations";
/**
* String identifier of a file's "Selected" property.
*/
- private static String PROPERTY_SELECTED = "Selected";
+ private static final String PROPERTY_SELECTED = "Selected";
/**
* List of the string identifiers for the available properties.
*/
- private static Collection<String> PDP_PROPERTIES;
+ private static Collection<String> pDPProperties;
- private PAPPolicyEngine papEngine = null;
- protected List<OnapPDPGroup> groups = Collections.synchronizedList(new ArrayList<OnapPDPGroup>());
+ private transient PAPPolicyEngine papEngine = null;
+ protected transient List<OnapPDPGroup> groups = Collections.synchronizedList(new ArrayList<OnapPDPGroup>());
public PDPGroupContainer(PAPPolicyEngine papPolicyEngine) {
super();
//
//
//
- this.papEngine = (PAPPolicyEngine) papPolicyEngine;
+ this.papEngine = papPolicyEngine;
//
//
//
}
public boolean isSupported(Object itemId) {
- if (itemId instanceof OnapPDPGroup) {
- return true;
- }
- return false;
+ return itemId instanceof OnapPDPGroup;
}
public synchronized void refreshGroups() {
public void makeDefault(OnapPDPGroup group) {
try {
- this.papEngine.SetDefaultGroup(group);
+ this.papEngine.setDefaultGroup(group);
} catch (PAPException e) {
String message = "Unable to set Default Group on server: " + e;
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + message, e);
@Override
public Collection<?> getContainerPropertyIds() {
- return PDP_PROPERTIES;
+ return pDPProperties;
}
@Override
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("containsId: " + itemId);
}
- if (this.isSupported(itemId) == false) {
+ if (! this.isSupported(itemId)) {
return false;
}
return this.groups.contains(itemId);
}
@Override
- public Object addItem() throws UnsupportedOperationException {
+ public Object addItem() {
throw new UnsupportedOperationException("PDP Container cannot add a given item.");
}
- public void addNewGroup(String name, String description) throws NullPointerException, PAPException {
+ public void addNewGroup(String name, String description) throws PAPException {
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("addNewGroup " + name + " " + description);
}
this.papEngine.newGroup(name, description);
}
- public void addNewPDP(String id, OnapPDPGroup group, String name, String description, int jmxport) throws NullPointerException, PAPException {
+ public void addNewPDP(String id, OnapPDPGroup group, String name, String description, int jmxport) throws PAPException {
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("addNewPDP " + id + " " + name + " " + description + " " + jmxport);
}
}
@Override
- public boolean addContainerProperty(Object propertyId, Class<?> type, Object defaultValue) throws UnsupportedOperationException {
+ public boolean addContainerProperty(Object propertyId, Class<?> type, Object defaultValue) {
throw new UnsupportedOperationException("Cannot add a container property.");
}
@Override
- public boolean removeContainerProperty(Object propertyId) throws UnsupportedOperationException {
+ public boolean removeContainerProperty(Object propertyId) {
throw new UnsupportedOperationException("Cannot remove a container property.");
}
@Override
- public boolean removeAllItems() throws UnsupportedOperationException {
+ public boolean removeAllItems() {
throw new UnsupportedOperationException("PDP Container cannot remove all items. You must have at least the Default group.");
}
@Override
public Object nextItemId(Object itemId) {
- if (this.isSupported(itemId) == false) {
+ if (! this.isSupported(itemId)) {
return null;
}
int index = this.groups.indexOf(itemId);
@Override
public Object prevItemId(Object itemId) {
- if (this.isSupported(itemId) == false) {
+ if (! this.isSupported(itemId)) {
return null;
}
int index = this.groups.indexOf(itemId);
@Override
public Object firstItemId() {
synchronized (this.groups) {
- if (this.groups.size() > 0) {
+ if (!this.groups.isEmpty()) {
return this.groups.get(0);
}
}
@Override
public Object lastItemId() {
synchronized (this.groups) {
- if (this.groups.size() > 0) {
+ if (!this.groups.isEmpty()) {
return this.groups.get(this.groups.size() - 1);
}
}
@Override
public boolean isFirstId(Object itemId) {
synchronized (this.groups) {
- if (this.groups.size() > 0) {
- return (this.groups.get(0).equals(itemId));
+ if (!this.groups.isEmpty()) {
+ return this.groups.get(0).equals(itemId);
}
}
return false;
@Override
public boolean isLastId(Object itemId) {
synchronized (this.groups) {
- if (this.groups.size() > 0) {
- return (this.groups.get(this.groups.size() - 1).equals(itemId));
+ if (!this.groups.isEmpty()) {
+ return this.groups.get(this.groups.size() - 1).equals(itemId);
}
}
return false;
}
@Override
- public Object addItemAfter(Object previousItemId) throws UnsupportedOperationException {
+ public Object addItemAfter(Object previousItemId) {
throw new UnsupportedOperationException("Cannot addItemAfter, there really is no real ordering.");
}
}
@Override
- public Object addItemAt(int index) throws UnsupportedOperationException {
+ public Object addItemAt(int index) {
throw new UnsupportedOperationException("Cannot addItemAt");
}
@Override
- public boolean removeItem(Object itemId) throws UnsupportedOperationException {
+ public boolean removeItem(Object itemId) {
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("removeItem: " + itemId);
}
- if (this.isSupported(itemId) == false) {
+ if (! this.isSupported(itemId)) {
return false;
}
//
// You cannot remove the default group
//
- if (((OnapPDPGroup) itemId).getId().equals("Default")) {
+ if (PROPERTY_DEFAULT.equals(((OnapPDPGroup) itemId).getId())) {
throw new UnsupportedOperationException("You can't remove the Default Group.");
}
//