Code Review
/
nonrtric.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Fix bug in SDNC, read controller info from yaml
[nonrtric.git]
/
policy-agent
/
src
/
main
/
java
/
org
/
oransc
/
policyagent
/
repository
/
Policies.java
diff --git
a/policy-agent/src/main/java/org/oransc/policyagent/repository/Policies.java
b/policy-agent/src/main/java/org/oransc/policyagent/repository/Policies.java
index
7b7b17c
..
a279db5
100644
(file)
--- a/
policy-agent/src/main/java/org/oransc/policyagent/repository/Policies.java
+++ b/
policy-agent/src/main/java/org/oransc/policyagent/repository/Policies.java
@@
-21,8
+21,10
@@
package org.oransc.policyagent.repository;
import java.util.Collection;
package org.oransc.policyagent.repository;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.HashMap;
import java.util.Map;
+import java.util.Set;
import java.util.Vector;
import org.oransc.policyagent.exceptions.ServiceException;
import java.util.Vector;
import org.oransc.policyagent.exceptions.ServiceException;
@@
-67,7
+69,15
@@
public class Policies {
if (map == null) {
return new Vector<Policy>();
}
if (map == null) {
return new Vector<Policy>();
}
- return map.values();
+ return Collections.unmodifiableCollection(map.values());
+ }
+
+ public synchronized boolean containsPolicy(String id) {
+ return policiesId.containsKey(id);
+ }
+
+ public synchronized Policy get(String id) {
+ return policiesId.get(id);
}
public synchronized Policy getPolicy(String id) throws ServiceException {
}
public synchronized Policy getPolicy(String id) throws ServiceException {
@@
-79,7
+89,7
@@
public class Policies {
}
public synchronized Collection<Policy> getAll() {
}
public synchronized Collection<Policy> getAll() {
- return
policiesId.values(
);
+ return
Collections.unmodifiableCollection(policiesId.values()
);
}
public synchronized Collection<Policy> getForService(String service) {
}
public synchronized Collection<Policy> getForService(String service) {
@@
-113,10
+123,10
@@
public class Policies {
return policiesId.size();
}
return policiesId.size();
}
- public void clear() {
- for (String id : policiesId.keySet()) {
- removeId(id);
+ public synchronized void clear() {
+ while (policiesId.size() > 0) {
+ Set<String> keys = policiesId.keySet();
+ removeId(keys.iterator().next());
}
}
}
}
-
}
}