aboutsummaryrefslogtreecommitdiff
path: root/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/AttributeProvidersMap.java
diff options
context:
space:
mode:
Diffstat (limited to 'id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/AttributeProvidersMap.java')
-rw-r--r--id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/AttributeProvidersMap.java28
1 files changed, 22 insertions, 6 deletions
diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/AttributeProvidersMap.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/AttributeProvidersMap.java
index 85aec2625..c59109092 100644
--- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/AttributeProvidersMap.java
+++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/AttributeProvidersMap.java
@@ -14,13 +14,12 @@ import org.apache.log4j.Logger;
*
* @see LinkedHashMap
*/
-public class AttributeProvidersMap extends LinkedHashMap<AttributeSource, IPersonalAttributeList>
- implements IAttributeProvidersMap {
+public class AttributeProvidersMap extends LinkedHashMap<AttributeSource, IPersonalAttributeList> implements IAttributeProvidersMap {
/**
* Logger object.
*/
private static final Logger LOG = Logger.getLogger(AttributeProvidersMap.class.getName());
-
+
/**
* Unique identifier.
*/
@@ -72,10 +71,9 @@ public class AttributeProvidersMap extends LinkedHashMap<AttributeSource, IPerso
LOG.trace("Source details: type [" + source.getSourceType() + "], URL [" + source.getProviderURL() + "]");
- if(source.getSourceType() == AttributeSource.SOURCE_LOCAL_APROVIDER) {
+ if (source.getSourceType() == AttributeSource.SOURCE_LOCAL_APROVIDER) {
LOG.trace("-> Attribute Provider: ID [" + source.getProvider().getProviderId() + "], name [" + source.getProvider().getProviderName() + "]");
- }
- else {
+ } else {
LOG.trace("-> Country: ID [" + source.getCountry().getCountryId() + "], name [" + source.getCountry().getCountryName() + "]");
}
@@ -93,4 +91,22 @@ public class AttributeProvidersMap extends LinkedHashMap<AttributeSource, IPerso
}
LOG.trace("END\n=======================");
}
+
+ public void mergeWith(IAttributeProvidersMap aPMap) {
+ Iterator<AttributeSource> maKeys = aPMap.keyIterator();
+ while (maKeys.hasNext()) {
+ AttributeSource key = maKeys.next();
+ IPersonalAttributeList l2 = aPMap.get(key);
+ if (containsKey(key)) {
+ IPersonalAttributeList l1 = get(key);
+ for (PersonalAttribute pa : l2) {
+ if (!l1.containsKey(pa.getName())) {
+ l1.add(pa);
+ }
+ }
+ } else {
+ put(key, l2);
+ }
+ }
+ }
}