use of org.gluu.model.GluuAttribute in project oxTrust by GluuFederation.
the class CustomAttributeAction method removeCustomAttribute.
public void removeCustomAttribute(String inum) {
if (StringHelper.isEmpty(inum)) {
return;
}
GluuAttribute tmpAttribute = attributeInums.get(inum);
if ((tmpAttribute == null) || !containsCustomAttribute(tmpAttribute)) {
return;
}
String id = this.attributeIds.get(tmpAttribute);
this.availableAttributeIds.add(id);
for (Iterator<GluuCustomAttribute> iterator = this.customAttributes.iterator(); iterator.hasNext(); ) {
GluuCustomAttribute tmpGluuPersonAttribute = iterator.next();
if (tmpAttribute.equals(tmpGluuPersonAttribute.getMetadata())) {
iterator.remove();
break;
}
}
}
use of org.gluu.model.GluuAttribute in project oxTrust by GluuFederation.
the class CustomAttributeAction method renderAttribute.
public void renderAttribute(ComponentSystemEvent event) {
// Replace dummy component id with real one
String dummyId = event.getComponent().getAttributes().get("aid").toString();
String clientId = event.getComponent().getClientId();
GluuAttribute attribute = this.attributeToIds.get(dummyId);
this.attributeIds.put(attribute, clientId);
}
use of org.gluu.model.GluuAttribute in project oxTrust by GluuFederation.
the class CustomAttributeAction method initCustomAttributes.
public void initCustomAttributes(List<GluuAttribute> attributes, List<GluuCustomAttribute> customAttributes, List<String> origins, String[] objectClassTypes, String[] objectClassDisplayNames) {
this.attributes = attributes;
this.customAttributes = customAttributes;
this.origCustomAttributes = new ArrayList<GluuCustomAttribute>(customAttributes);
// Set meta-data and sort by metadata.displayName
attributeService.setAttributeMetadata(customAttributes, this.attributes);
attributeService.sortCustomAttributes(customAttributes, "metadata.displayName");
// Prepare map which allows to build tab
this.attributeByOrigin = groupAttributesByOrigin(this.attributes);
// Init special list and maps
this.availableAttributeIds = new ArrayList<String>();
this.attributeIds = new IdentityHashMap<GluuAttribute, String>();
this.attributeToIds = new HashMap<String, GluuAttribute>();
this.attributeInums = new HashMap<String, GluuAttribute>();
int componentId = 1;
for (GluuAttribute attribute : attributes) {
log.debug("attribute: {}", attribute.getName());
String id = "a" + String.valueOf(componentId++) + "Id";
this.availableAttributeIds.add(id);
this.attributeInums.put(attribute.getInum(), attribute);
this.attributeIds.put(attribute, id);
this.attributeToIds.put(id, attribute);
}
// Init origin display names
this.originDisplayNames = attributeService.getAllAttributeOriginDisplayNames(origins, objectClassTypes, objectClassDisplayNames);
this.activeOrigin = this.originDisplayNames.get(origins.get(0));
// Sync Ids map
for (GluuCustomAttribute personAttribute : customAttributes) {
if (personAttribute.getMetadata() != null) {
String id = this.attributeIds.get(personAttribute.getMetadata());
this.availableAttributeIds.remove(id);
}
}
}
use of org.gluu.model.GluuAttribute in project oxTrust by GluuFederation.
the class CustomAttributeAction method addCustomAttribute.
public void addCustomAttribute(String inum, boolean mandatory) {
if (StringHelper.isEmpty(inum)) {
return;
}
GluuAttribute tmpAttribute = attributeInums.get(inum);
if ((tmpAttribute == null) || containsCustomAttribute(tmpAttribute)) {
return;
}
String id = this.attributeIds.get(tmpAttribute);
this.availableAttributeIds.remove(id);
GluuCustomAttribute tmpGluuPersonAttribute = new GluuCustomAttribute(tmpAttribute.getName(), (String) null, true, mandatory);
tmpGluuPersonAttribute.setMetadata(tmpAttribute);
this.customAttributes.add(tmpGluuPersonAttribute);
}
use of org.gluu.model.GluuAttribute in project oxTrust by GluuFederation.
the class CustomAttributeAction method removeMultiValuesInAttributes.
public void removeMultiValuesInAttributes(String inum, boolean mandatory, String removeValue) {
if (StringHelper.isEmpty(inum)) {
return;
}
GluuAttribute tmpAttribute = this.attributeInums.get(inum);
if (tmpAttribute == null) {
return;
}
String id = this.attributeIds.get(tmpAttribute);
this.availableAttributeIds.remove(id);
String[] values = null;
String[] newValues = null;
int index = 0;
for (GluuCustomAttribute customAttribute : this.customAttributes) {
if (tmpAttribute.equals(customAttribute.getMetadata())) {
values = customAttribute.getValues();
newValues = removeElementFromArray(values, removeValue);
break;
}
index++;
}
removeCustomAttribute(inum);
GluuCustomAttribute tmpGluuPersonAttribute = new GluuCustomAttribute(tmpAttribute.getName(), newValues, true, mandatory);
tmpGluuPersonAttribute.setMetadata(tmpAttribute);
this.customAttributes.add(index, tmpGluuPersonAttribute);
}
Aggregations