138 Map<String, GluuCustomAttribute> customAttributesMap =
new HashMap<String, GluuCustomAttribute>();
139 for (GluuCustomAttribute sourceCustomAttribute : sourcePerson.getCustomAttributes()) {
140 customAttributesMap.put(StringHelper.toLowerCase(sourceCustomAttribute.getName()), sourceCustomAttribute);
143 List<GluuCustomAttribute> resultAttributes =
new ArrayList<GluuCustomAttribute>();
146 Set<String> processedAttributeNames =
new HashSet<String>();
147 for (Entry<String, String> targetServerAttributeEntry : targetServerAttributesMapping.entrySet()) {
148 String sourceKeyAttributeName = StringHelper.toLowerCase(targetServerAttributeEntry.getValue());
149 String targetKeyAttributeName = targetServerAttributeEntry.getKey();
151 processedAttributeNames.add(sourceKeyAttributeName);
153 GluuCustomAttribute gluuCustomAttribute = customAttributesMap.get(sourceKeyAttributeName);
154 if (gluuCustomAttribute != null) {
155 String[] values = gluuCustomAttribute.getValues();
156 String[] clonedValue = ArrayHelper.arrayClone(values);
158 GluuCustomAttribute gluuCustomAttributeCopy =
new GluuCustomAttribute(targetKeyAttributeName, clonedValue);
159 gluuCustomAttributeCopy.setName(targetKeyAttributeName);
160 resultAttributes.add(gluuCustomAttributeCopy);
165 for (Entry<String, GluuCustomAttribute> sourceCustomAttributeEntry : customAttributesMap.entrySet()) {
166 if (!processedAttributeNames.contains(sourceCustomAttributeEntry.getKey())) {
167 targetPerson.setAttribute(sourceCustomAttributeEntry.getValue());
171 for (GluuCustomAttribute resultAttribute : resultAttributes) {
172 targetPerson.setAttribute(resultAttribute);