Search in sources :

Example 16 with ExtensionField

use of io.jans.scim.model.scim2.extensions.ExtensionField in project jans by JanssenProject.

the class SchemaWebService method getSchemaInstance.

private SchemaResource getSchemaInstance(Class<? extends BaseScimResource> clazz, String urn) throws Exception {
    if (ScimResourceUtil.getDefaultSchemaUrn(clazz).equals(urn))
        // Process core attributes
        return getSchemaInstance(clazz);
    else {
        // process extension attributes
        SchemaResource resource = null;
        Class<? extends BaseScimResource> schemaCls = SchemaResource.class;
        // Find the appropriate extension
        List<Extension> extensions = extService.getResourceExtensions(clazz);
        for (Extension extension : extensions) {
            if (extension.getUrn().equals(urn)) {
                Meta meta = new Meta();
                meta.setResourceType(ScimResourceUtil.getType(schemaCls));
                meta.setLocation(endpointUrl + "/" + urn);
                resource = new SchemaResource();
                resource.setId(urn);
                resource.setName(extension.getName());
                resource.setDescription(extension.getDescription());
                resource.setMeta(meta);
                List<SchemaAttribute> attribs = new ArrayList<>();
                for (ExtensionField field : extension.getFields().values()) {
                    SchemaAttribute schAttr = new SchemaAttribute();
                    schAttr.setName(field.getName());
                    schAttr.setMultiValued(field.isMultiValued());
                    schAttr.setDescription(field.getDescription());
                    schAttr.setRequired(false);
                    schAttr.setCanonicalValues(null);
                    schAttr.setCaseExact(false);
                    schAttr.setMutability(AttributeDefinition.Mutability.READ_WRITE.getName());
                    schAttr.setReturned(AttributeDefinition.Returned.DEFAULT.getName());
                    schAttr.setUniqueness(AttributeDefinition.Uniqueness.NONE.getName());
                    schAttr.setReferenceTypes(null);
                    AttributeDefinition.Type type = field.getAttributeDefinitionType();
                    schAttr.setType(type == null ? null : type.getName());
                    schAttr.setSubAttributes(null);
                    attribs.add(schAttr);
                }
                resource.setAttributes(attribs);
                break;
            }
        }
        return resource;
    }
}
Also used : Extension(io.jans.scim.model.scim2.extensions.Extension) Meta(io.jans.scim.model.scim2.Meta) ExtensionField(io.jans.scim.model.scim2.extensions.ExtensionField) ArrayList(java.util.ArrayList) AttributeDefinition(io.jans.scim.model.scim2.AttributeDefinition) SchemaAttribute(io.jans.scim.model.scim2.provider.schema.SchemaAttribute) SchemaResource(io.jans.scim.model.scim2.provider.schema.SchemaResource)

Aggregations

ExtensionField (io.jans.scim.model.scim2.extensions.ExtensionField)8 Extension (io.jans.scim.model.scim2.extensions.Extension)7 ExtensionField (org.gluu.oxtrust.model.scim2.extensions.ExtensionField)7 Extension (org.gluu.oxtrust.model.scim2.extensions.Extension)5 HashMap (java.util.HashMap)3 Type (io.jans.scim.model.scim2.AttributeDefinition.Type)2 Attribute (io.jans.scim.model.scim2.annotations.Attribute)2 CompValueType (io.jans.scim.service.antlr.scimFilter.enums.CompValueType)2 ArrayList (java.util.ArrayList)2 Type (org.gluu.oxtrust.model.scim2.AttributeDefinition.Type)2 Attribute (org.gluu.oxtrust.model.scim2.annotations.Attribute)2 CompValueType (org.gluu.oxtrust.service.antlr.scimFilter.enums.CompValueType)2 GluuAttribute (io.jans.model.GluuAttribute)1 Filter (io.jans.orm.search.filter.Filter)1 SCIMException (io.jans.scim.model.exception.SCIMException)1 AttributeDefinition (io.jans.scim.model.scim2.AttributeDefinition)1 Meta (io.jans.scim.model.scim2.Meta)1 SchemaAttribute (io.jans.scim.model.scim2.provider.schema.SchemaAttribute)1 SchemaResource (io.jans.scim.model.scim2.provider.schema.SchemaResource)1 ScimFilterParser (io.jans.scim.service.antlr.scimFilter.antlr4.ScimFilterParser)1