Search in sources :

Example 1 with Syntax

use of com.sun.identity.sm.AttributeSchema.Syntax in project OpenAM by OpenRock.

the class SmsResourceProvider method addType.

private void addType(JsonValue result, String pointer, AttributeSchema attribute, ResourceBundle schemaI18n, ResourceBundle consoleI18n, Context context) {
    String type = null;
    AttributeSchema.Type attributeType = attribute.getType();
    AttributeSchema.Syntax syntax = attribute.getSyntax();
    if (attributeType == AttributeSchema.Type.LIST && (attribute.getUIType() == AttributeSchema.UIType.GLOBALMAPLIST || attribute.getUIType() == AttributeSchema.UIType.MAPLIST)) {
        type = OBJECT_TYPE;
        JsonValue fieldType = json(object());
        if (attribute.hasChoiceValues()) {
            addEnumChoices(fieldType, attribute, schemaI18n, consoleI18n, context);
        } else {
            fieldType.add(TYPE, STRING_TYPE);
        }
        result.addPermissive(new JsonPointer(pointer + "/" + PATTERN_PROPERTIES), object(field(".*", fieldType.getObject())));
    } else if (attributeType == AttributeSchema.Type.LIST) {
        type = ARRAY_TYPE;
        result.addPermissive(new JsonPointer(pointer + "/" + ITEMS), object(field(TYPE, getTypeFromSyntax(attribute.getSyntax()))));
        if (attribute.hasChoiceValues()) {
            addEnumChoices(result.get(new JsonPointer(pointer + "/" + ITEMS)), attribute, schemaI18n, consoleI18n, context);
        }
    } else if (attributeType.equals(AttributeSchema.Type.MULTIPLE_CHOICE)) {
        type = ARRAY_TYPE;
        result.addPermissive(new JsonPointer(pointer + "/" + ITEMS), object(field(TYPE, getTypeFromSyntax(attribute.getSyntax()))));
        addEnumChoices(result.get(new JsonPointer(pointer + "/" + ITEMS)), attribute, schemaI18n, consoleI18n, context);
    } else if (attributeType.equals(AttributeSchema.Type.SINGLE_CHOICE)) {
        addEnumChoices(result.get(new JsonPointer(pointer)), attribute, schemaI18n, consoleI18n, context);
    } else {
        type = getTypeFromSyntax(syntax);
    }
    if (type != null) {
        result.addPermissive(new JsonPointer(pointer + "/" + TYPE), type);
    }
    if (AttributeSchema.Syntax.PASSWORD.equals(syntax)) {
        result.addPermissive(new JsonPointer(pointer + "/" + FORMAT), PASSWORD_TYPE);
    }
}
Also used : AttributeSchema(com.sun.identity.sm.AttributeSchema) JsonValue(org.forgerock.json.JsonValue) Syntax(com.sun.identity.sm.AttributeSchema.Syntax) JsonPointer(org.forgerock.json.JsonPointer)

Aggregations

AttributeSchema (com.sun.identity.sm.AttributeSchema)1 Syntax (com.sun.identity.sm.AttributeSchema.Syntax)1 JsonPointer (org.forgerock.json.JsonPointer)1 JsonValue (org.forgerock.json.JsonValue)1