+ return policiesId.get(id);
+ }
+
+ public synchronized Policy getPolicy(String id) throws ServiceException {
+ Policy p = policiesId.get(id);
+ if (p == null) {
+ throw new ServiceException("Could not find policy: " + id);
+ }
+ return p;
+ }
+
+ public synchronized Collection<Policy> getAll() {
+ return new Vector<>(policiesId.values());
+ }
+
+ public synchronized Collection<Policy> getForService(String service) {
+ return multiMapGet(policiesService, service);
+ }
+
+ public synchronized Collection<Policy> getForRic(String ric) {
+ return multiMapGet(policiesRic, ric);
+ }
+
+ public synchronized Collection<Policy> getForType(String type) {
+ return multiMapGet(policiesType, type);
+ }
+
+ public synchronized Policy removeId(String id) {
+ Policy p = policiesId.get(id);
+ if (p != null) {
+ remove(p);
+ }
+ return p;
+ }
+
+ public synchronized void remove(Policy policy) {
+ policiesId.remove(policy.id());
+ multiMapRemove(policiesRic, policy.ric().name(), policy);
+ multiMapRemove(policiesService, policy.ownerServiceName(), policy);
+ multiMapRemove(policiesType, policy.type().name(), policy);
+ }
+
+ public synchronized void removePoliciesForRic(String ricName) {
+ Collection<Policy> policiesForRic = getForRic(ricName);
+ for (Policy policy : policiesForRic) {
+ remove(policy);
+ }