use of org.wso2.charon3.core.attributes.SimpleAttribute in project charon by wso2.
the class AbstractSCIMObject method setLocation.
/*
* set the location of the meta attribute
*
* @param location
*/
public void setLocation(String location) throws CharonException, BadRequestException {
// create the location attribute as defined in schema.
SimpleAttribute locationAttribute = (SimpleAttribute) DefaultAttributeFactory.createAttribute(SCIMSchemaDefinitions.LOCATION, new SimpleAttribute(SCIMConstants.CommonSchemaConstants.LOCATION, location));
// check meta complex attribute already exist.
if (getMetaAttribute() != null) {
ComplexAttribute metaAttribute = getMetaAttribute();
// check version attribute already exist
if (metaAttribute.isSubAttributeExist(locationAttribute.getName())) {
String error = "Read only attribute is tried to modify";
throw new CharonException(error);
} else {
metaAttribute.setSubAttribute(locationAttribute);
}
} else {
// create meta attribute and set the sub attribute.
createMetaAttribute();
getMetaAttribute().setSubAttribute(locationAttribute);
}
}
use of org.wso2.charon3.core.attributes.SimpleAttribute in project charon by wso2.
the class AbstractSCIMObject method setId.
/*
* Set a value for the id attribute. If attribute not already created in the resource,
* create attribute and set the value.
* Unique identifier for the SCIM Resource as defined by the Service Provider
* This is read-only. So can only set once.
*
* @param id Unique identifier for the SCIM Resource as defined by the Service Provider.
* @throws CharonException
* @throws BadRequestException
*/
public void setId(String id) throws CharonException, BadRequestException {
if (isAttributeExist(SCIMConstants.CommonSchemaConstants.ID)) {
String error = "Read only attribute is trying to be modified";
throw new CharonException(error);
} else {
SimpleAttribute idAttribute = new SimpleAttribute(SCIMConstants.CommonSchemaConstants.ID, id);
idAttribute = (SimpleAttribute) DefaultAttributeFactory.createAttribute(SCIMSchemaDefinitions.ID, idAttribute);
this.setAttribute(idAttribute);
}
}
use of org.wso2.charon3.core.attributes.SimpleAttribute in project charon by wso2.
the class Group method setDisplayName.
/*
* set the display name of the group
* @param displayName
* @throws CharonException
* @throws BadRequestException
*/
public void setDisplayName(String displayName) throws CharonException, BadRequestException {
if (this.isAttributeExist(SCIMConstants.GroupSchemaConstants.DISPLAY_NAME)) {
((SimpleAttribute) this.attributeList.get(SCIMConstants.GroupSchemaConstants.DISPLAY_NAME)).updateValue(displayName);
} else {
SimpleAttribute displayAttribute = new SimpleAttribute(SCIMConstants.GroupSchemaConstants.DISPLAY_NAME, displayName);
displayAttribute = (SimpleAttribute) DefaultAttributeFactory.createAttribute(SCIMSchemaDefinitions.SCIMGroupSchemaDefinition.DISPLAY_NAME, displayAttribute);
this.attributeList.put(SCIMConstants.GroupSchemaConstants.DISPLAY_NAME, displayAttribute);
}
}
use of org.wso2.charon3.core.attributes.SimpleAttribute in project charon by wso2.
the class Group method getMembers.
/*
* get the members of the group
* @return
*/
public List<Object> getMembers() {
List<Object> memberList = new ArrayList<>();
if (this.isAttributeExist(SCIMConstants.GroupSchemaConstants.MEMBERS)) {
MultiValuedAttribute members = (MultiValuedAttribute) this.attributeList.get(SCIMConstants.GroupSchemaConstants.MEMBERS);
List<Attribute> subValuesList = members.getAttributeValues();
for (Attribute subValue : subValuesList) {
ComplexAttribute complexAttribute = (ComplexAttribute) subValue;
Map<String, Attribute> subAttributesList = complexAttribute.getSubAttributesList();
if (subAttributesList != null && subAttributesList.containsKey(SCIMConstants.CommonSchemaConstants.VALUE)) {
memberList.add(((SimpleAttribute) (subAttributesList.get(SCIMConstants.CommonSchemaConstants.VALUE))).getValue());
}
}
return memberList;
} else {
return null;
}
}
use of org.wso2.charon3.core.attributes.SimpleAttribute in project charon by wso2.
the class ListedResource method setItemsPerPage.
/*
* paginated listed resource items per page settings
* @param itemsPerPage
*/
public void setItemsPerPage(int itemsPerPage) {
if (!isAttributeExist(SCIMConstants.ListedResourceSchemaConstants.ITEMS_PER_PAGE)) {
SimpleAttribute totalResultsAttribute = new SimpleAttribute(SCIMConstants.ListedResourceSchemaConstants.ITEMS_PER_PAGE, itemsPerPage);
// No need to let the Default attribute factory to handle the attribute, as this is
// not officially defined as SCIM attribute, hence have no characteristics defined
// TODO: may be we can let the default attribute factory to handle it?
attributeList.put(SCIMConstants.ListedResourceSchemaConstants.ITEMS_PER_PAGE, totalResultsAttribute);
} else {
((SimpleAttribute) attributeList.get(SCIMConstants.ListedResourceSchemaConstants.ITEMS_PER_PAGE)).setValue(itemsPerPage);
}
}
Aggregations