Search in sources :

Example 1 with AttributeDataType

use of org.gluu.model.attribute.AttributeDataType in project oxTrust by GluuFederation.

the class GluuAttributeValidator method validate.

@Override
public void validate(FacesContext context, UIComponent comp, Object value) {
    String attributeValue;
    if (value instanceof AttributeDataType) {
        attributeValue = ((AttributeDataType) value).getValue();
    } else {
        attributeValue = (String) value;
    }
    if (StringHelper.isEmpty(attributeValue)) {
        FacesMessage message = new FacesMessage("Value is required");
        message.setSeverity(FacesMessage.SEVERITY_ERROR);
        throw new ValidatorException(message);
    }
}
Also used : AttributeDataType(org.gluu.model.attribute.AttributeDataType) ValidatorException(javax.faces.validator.ValidatorException) FacesMessage(javax.faces.application.FacesMessage)

Example 2 with AttributeDataType

use of org.gluu.model.attribute.AttributeDataType in project oxTrust by GluuFederation.

the class ImportPersonConfiguration method createAttributeFromConfig.

private GluuAttribute createAttributeFromConfig(String prefix) {
    String attributeName = importConfiguration.getString(prefix + ATTRIBUTE_LDAP_NAME_SUFFIX, null);
    String displayName = importConfiguration.getString(prefix + ATTRIBUTE_DISPLAY_NAME_SUFFIX, null);
    String dataType = importConfiguration.getString(prefix + ATTRIBUTE_DATA_TYPE_SUFFIX, null);
    boolean required = importConfiguration.getBoolean(prefix + ATTRIBUTE_DATA_REQUIRED_SUFFIX, false);
    if (StringHelper.isNotEmpty(attributeName) && StringHelper.isNotEmpty(displayName) && StringHelper.isNotEmpty(dataType)) {
        AttributeDataType attributeDataType = AttributeDataType.getByValue(dataType);
        if (attributeDataType != null) {
            GluuAttribute attr = new GluuAttribute();
            attr.setName(attributeName);
            attr.setDisplayName(displayName);
            attr.setDataType(attributeDataType);
            attr.setRequred(required);
            return attr;
        }
    }
    return null;
}
Also used : AttributeDataType(org.gluu.model.attribute.AttributeDataType) GluuAttribute(org.gluu.model.GluuAttribute)

Example 3 with AttributeDataType

use of org.gluu.model.attribute.AttributeDataType in project oxTrust by GluuFederation.

the class ImportPersonConfiguration method createAttributeFromConfig.

private GluuAttribute createAttributeFromConfig(ImportPerson importPerson) {
    String attributeName = importPerson.getLdapName();
    String displayName = importPerson.getDisplayName();
    String dataType = importPerson.getDataType();
    boolean required = importPerson.getRequired();
    if (StringHelper.isNotEmpty(attributeName) && StringHelper.isNotEmpty(displayName) && StringHelper.isNotEmpty(dataType)) {
        AttributeDataType attributeDataType = AttributeDataType.getByValue(dataType);
        if (attributeDataType != null) {
            GluuAttribute attr = new GluuAttribute();
            attr.setName(attributeName);
            attr.setDisplayName(displayName);
            attr.setDataType(attributeDataType);
            attr.setRequred(required);
            return attr;
        }
    }
    return null;
}
Also used : AttributeDataType(org.gluu.model.attribute.AttributeDataType) GluuAttribute(org.gluu.model.GluuAttribute)

Aggregations

AttributeDataType (org.gluu.model.attribute.AttributeDataType)3 GluuAttribute (org.gluu.model.GluuAttribute)2 FacesMessage (javax.faces.application.FacesMessage)1 ValidatorException (javax.faces.validator.ValidatorException)1