- getItemSetChangeListeners().add(listener);
- }
-
- @Override
- public Object nextItemId(Object itemId) {
- if (this.isSupported(itemId) == false) {
- return null;
- }
- int index = this.groups.indexOf(itemId);
- if (index == -1) {
- //
- // We don't know this group
- //
- return null;
- }
- //
- // Is it the last one?
- //
- if (index == this.groups.size() - 1) {
- //
- // Yes
- //
- return null;
- }
- //
- // Return the next one
- //
- return this.groups.get(index + 1);
- }
-
- @Override
- public Object prevItemId(Object itemId) {
- if (this.isSupported(itemId) == false) {
- return null;
- }
- int index = this.groups.indexOf(itemId);
- if (index == -1) {
- //
- // We don't know this group
- //
- return null;
- }
- //
- // Is it the first one?
- //
- if (index == 0) {
- //
- // Yes
- //
- return null;
- }
- //
- // Return the previous one
- //
- return this.groups.get(index - 1);
- }
-
- @Override
- public Object firstItemId() {
- synchronized (this.groups) {
- if (this.groups.size() > 0) {
- return this.groups.get(0);
- }
- }
- return null;
- }
-
- @Override
- public Object lastItemId() {
- synchronized (this.groups) {
- if (this.groups.size() > 0) {
- return this.groups.get(this.groups.size() - 1);
- }
- }
- return null;
- }
-
- @Override
- public boolean isFirstId(Object itemId) {
- synchronized (this.groups) {
- if (this.groups.size() > 0) {
- 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));
- }
- }
- return false;
- }
-
- @Override
- public Object addItemAfter(Object previousItemId) throws UnsupportedOperationException {
- throw new UnsupportedOperationException("Cannot addItemAfter, there really is no real ordering.");
- }
-
- @Override
- public int indexOfId(Object itemId) {
- return this.groups.indexOf(itemId);
- }
-
- @Override
- public Object getIdByIndex(int index) {
- return this.groups.get(index);
- }
-
- @Override
- public List<?> getItemIds(int startIndex, int numberOfItems) {
- synchronized (this.groups) {
- int endIndex = startIndex + numberOfItems;
- if (endIndex > this.groups.size()) {
- endIndex = this.groups.size() - 1;
- }
- return this.groups.subList(startIndex, endIndex);
- }
- }
-
- @Override
- public Object addItemAt(int index) throws UnsupportedOperationException {
- throw new UnsupportedOperationException("Cannot addItemAt");
- }
-
- @Override
- public boolean removeItem(Object itemId) throws UnsupportedOperationException {
- if (LOGGER.isTraceEnabled()) {
- LOGGER.trace("removeItem: " + itemId);
- }
- if (this.isSupported(itemId) == false) {
- return false;
- }
- //
- // You cannot remove the default group
- //
- if (((OnapPDPGroup) itemId).getId().equals("Default")) {
- throw new UnsupportedOperationException("You can't remove the Default Group.");
- }
- //
- // Remove PDPGroup and move any PDP's in it into the default group
- //
- try {
- this.papEngine.removeGroup((OnapPDPGroup) itemId, this.papEngine.getDefaultGroup());
- return true;
- } catch (NullPointerException | PAPException e) {
- LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Failed to remove group", e);
- }
- return false;
- }
-
- public class PDPGroupItem{
- private final OnapPDPGroup group;
-
- public PDPGroupItem(OnapPDPGroup itemId) {
- this.group = itemId;
- }
-
- public String getId() {
- if (LOGGER.isTraceEnabled()) {
- LOGGER.trace("getId: " + this.group);
- }
- return this.group.getId();
- }
-
- public String getName() {
- if (LOGGER.isTraceEnabled()) {
- LOGGER.trace("getName: " + this.group);
- }
- return this.group.getName();
- }
-
- public String getDescription() {
- if (LOGGER.isTraceEnabled()) {
- LOGGER.trace("getDescription: " + this.group);
- }
- return this.group.getDescription();
- }
-
- public Boolean getDefault() {
- if (LOGGER.isTraceEnabled()) {
- LOGGER.trace("getDefault: " + this.group);
- }
- return this.group.isDefaultGroup();
- }
-
-
- public String getStatus() {
- return this.group.getStatus().getStatus().toString();
- }
-
- public Set<PDP> getPDPs() {
- return Collections.unmodifiableSet(this.group.getPdps());
- }
-
- public Set<PDPPolicy> getPolicies() {
- if (LOGGER.isTraceEnabled()) {
- LOGGER.trace("getPolicies: " + this.group);
- }
- return this.group.getPolicies();
- }
-
- public Set<PDPPIPConfig> getPipConfigs() {
- if (LOGGER.isTraceEnabled()) {
- LOGGER.trace("getPIPConfigs: " + this.group);
- }
- return this.group.getPipConfigs();
- }
- }
+ getItemSetChangeListeners().add(listener);
+ }
+
+ @Override
+ public Object nextItemId(Object itemId) {
+ if (!this.isSupported(itemId)) {
+ return null;
+ }
+ int index = this.groups.indexOf(itemId);
+ if (index == -1) {
+ //
+ // We don't know this group
+ //
+ return null;
+ }
+ //
+ // Is it the last one?
+ //
+ if (index == this.groups.size() - 1) {
+ //
+ // Yes
+ //
+ return null;
+ }
+ //
+ // Return the next one
+ //
+ return this.groups.get(index + 1);
+ }
+
+ @Override
+ public Object prevItemId(Object itemId) {
+ if (!this.isSupported(itemId)) {
+ return null;
+ }
+ int index = this.groups.indexOf(itemId);
+ if (index == -1) {
+ //
+ // We don't know this group
+ //
+ return null;
+ }
+ //
+ // Is it the first one?
+ //
+ if (index == 0) {
+ //
+ // Yes
+ //
+ return null;
+ }
+ //
+ // Return the previous one
+ //
+ return this.groups.get(index - 1);
+ }
+
+ @Override
+ public Object firstItemId() {
+ synchronized (this.groups) {
+ if (!this.groups.isEmpty()) {
+ return this.groups.get(0);
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public Object lastItemId() {
+ synchronized (this.groups) {
+ if (!this.groups.isEmpty()) {
+ return this.groups.get(this.groups.size() - 1);
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public boolean isFirstId(Object itemId) {
+ synchronized (this.groups) {
+ 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.isEmpty()) {
+ return this.groups.get(this.groups.size() - 1).equals(itemId);
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public Object addItemAfter(Object previousItemId) {
+ throw new UnsupportedOperationException("Cannot addItemAfter, there really is no real ordering.");
+ }
+
+ @Override
+ public int indexOfId(Object itemId) {
+ return this.groups.indexOf(itemId);
+ }
+
+ @Override
+ public Object getIdByIndex(int index) {
+ return this.groups.get(index);
+ }
+
+ @Override
+ public Object addItemAt(int index) {
+ throw new UnsupportedOperationException("Cannot addItemAt");
+ }
+
+ @Override
+ public boolean removeItem(Object itemId) {
+ if (LOGGER.isTraceEnabled()) {
+ LOGGER.trace("removeItem: " + itemId);
+ }
+ if (!this.isSupported(itemId)) {
+ return false;
+ }
+ //
+ // You cannot remove the default group
+ //
+ if (PROPERTY_DEFAULT.equals(((OnapPDPGroup) itemId).getId())) {
+ throw new UnsupportedOperationException("You can't remove the Default Group.");
+ }
+ //
+ // Remove PDPGroup and move any PDP's in it into the default group
+ //
+ try {
+ this.papEngine.removeGroup((OnapPDPGroup) itemId, this.papEngine.getDefaultGroup());
+ return true;
+ } catch (NullPointerException | PAPException e) {
+ LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Failed to remove group", e);
+ }
+ return false;
+ }