Search in sources :

Example 6 with SchemaType

use of org.gluu.oxtrust.model.scim2.schema.SchemaType in project oxTrust by GluuFederation.

the class GroupCoreLoadingStrategy method load.

@Override
public SchemaType load(AppConfiguration appConfiguration, SchemaType schemaType) throws Exception {
    log.info(" load() ");
    Meta meta = new Meta();
    meta.setLocation(appConfiguration.getBaseEndpoint() + "/scim/v2/Schemas/" + schemaType.getId());
    meta.setResourceType("Schema");
    schemaType.setMeta(meta);
    // Use serializer to walk the class structure
    ObjectMapper mapper = new ObjectMapper();
    mapper.disable(SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS);
    SimpleModule groupCoreLoadingStrategyModule = new SimpleModule("GroupCoreLoadingStrategyModule", new Version(1, 0, 0, ""));
    SchemaTypeGroupSerializer serializer = new SchemaTypeGroupSerializer();
    serializer.setSchemaType(schemaType);
    groupCoreLoadingStrategyModule.addSerializer(Group.class, serializer);
    mapper.registerModule(groupCoreLoadingStrategyModule);
    mapper.writeValueAsString(createDummyGroup());
    return serializer.getSchemaType();
}
Also used : Meta(org.gluu.oxtrust.model.scim2.Meta) SchemaTypeGroupSerializer(org.gluu.oxtrust.service.scim2.schema.strategy.serializers.SchemaTypeGroupSerializer) Version(org.codehaus.jackson.Version) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) SimpleModule(org.codehaus.jackson.map.module.SimpleModule)

Example 7 with SchemaType

use of org.gluu.oxtrust.model.scim2.schema.SchemaType in project oxTrust by GluuFederation.

the class UserCoreLoadingStrategy method load.

@Override
public SchemaType load(AppConfiguration appConfiguration, SchemaType schemaType) throws Exception {
    log.info(" load() ");
    Meta meta = new Meta();
    meta.setLocation(appConfiguration.getBaseEndpoint() + "/scim/v2/Schemas/" + schemaType.getId());
    meta.setResourceType("Schema");
    schemaType.setMeta(meta);
    // Use serializer to walk the class structure
    ObjectMapper mapper = new ObjectMapper();
    mapper.disable(SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS);
    SimpleModule userCoreLoadingStrategyModule = new SimpleModule("UserCoreLoadingStrategyModule", new Version(1, 0, 0, ""));
    SchemaTypeUserSerializer serializer = new SchemaTypeUserSerializer();
    serializer.setSchemaType(schemaType);
    userCoreLoadingStrategyModule.addSerializer(User.class, serializer);
    mapper.registerModule(userCoreLoadingStrategyModule);
    mapper.writeValueAsString(createDummyUser());
    return serializer.getSchemaType();
}
Also used : SchemaTypeUserSerializer(org.gluu.oxtrust.service.scim2.schema.strategy.serializers.SchemaTypeUserSerializer) Meta(org.gluu.oxtrust.model.scim2.Meta) Version(org.codehaus.jackson.Version) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) SimpleModule(org.codehaus.jackson.map.module.SimpleModule)

Example 8 with SchemaType

use of org.gluu.oxtrust.model.scim2.schema.SchemaType in project oxTrust by GluuFederation.

the class UserExtensionLoadingStrategy method load.

@Override
public SchemaType load(AppConfiguration appConfiguration, SchemaType schemaType) throws Exception {
    log.info(" load() ");
    Meta meta = new Meta();
    meta.setLocation(appConfiguration.getBaseEndpoint() + "/scim/v2/Schemas/" + schemaType.getId());
    meta.setResourceType("Schema");
    schemaType.setMeta(meta);
    // List<GluuAttribute> scimCustomAttributes = attributeService.getSCIMRelatedAttributesImpl(attributeService.getCustomAttributes());
    List<GluuAttribute> scimCustomAttributes = attributeService.getSCIMRelatedAttributes();
    List<AttributeHolder> attributeHolders = new ArrayList<AttributeHolder>();
    for (GluuAttribute scimCustomAttribute : scimCustomAttributes) {
        AttributeHolder attributeHolder = new AttributeHolder();
        attributeHolder.setName(scimCustomAttribute.getName());
        if (scimCustomAttribute.getDataType() != null) {
            String typeStr = "";
            GluuAttributeDataType attributeDataType = scimCustomAttribute.getDataType();
            if (attributeDataType.equals(GluuAttributeDataType.STRING)) {
                typeStr = "string";
            } else if (attributeDataType.equals(GluuAttributeDataType.PHOTO)) {
                typeStr = "reference";
                attributeHolder.getReferenceTypes().add("external");
            } else if (attributeDataType.equals(GluuAttributeDataType.DATE)) {
                typeStr = "dateTime";
            } else if (attributeDataType.equals(GluuAttributeDataType.NUMERIC)) {
                typeStr = "decimal";
            } else {
                log.info(" NO MATCH: scimCustomAttribute.getDataType().getDisplayName() = " + scimCustomAttribute.getDataType().getDisplayName());
                typeStr = "string";
            }
            attributeHolder.setType(typeStr);
        }
        attributeHolder.setDescription(scimCustomAttribute.getDescription());
        attributeHolder.setRequired(scimCustomAttribute.isRequred());
        if (scimCustomAttribute.getOxMultivaluedAttribute() != null) {
            Boolean multiValued = Boolean.parseBoolean(scimCustomAttribute.getOxMultivaluedAttribute().getValue());
            attributeHolder.setMultiValued(multiValued);
        }
        attributeHolders.add(attributeHolder);
    }
    UserExtensionSchema userExtensionSchema = (UserExtensionSchema) schemaType;
    userExtensionSchema.setAttributeHolders(attributeHolders);
    return userExtensionSchema;
}
Also used : Meta(org.gluu.oxtrust.model.scim2.Meta) AttributeHolder(org.gluu.oxtrust.model.scim2.schema.AttributeHolder) ArrayList(java.util.ArrayList) UserExtensionSchema(org.gluu.oxtrust.model.scim2.schema.extension.UserExtensionSchema) GluuAttributeDataType(org.xdi.model.GluuAttributeDataType) GluuAttribute(org.xdi.model.GluuAttribute)

Example 9 with SchemaType

use of org.gluu.oxtrust.model.scim2.schema.SchemaType in project oxTrust by GluuFederation.

the class FilterUtil method stripScim2Schema.

public static String stripScim2Schema(String uri) {
    for (SchemaType schemaType : SchemaTypeMapping.getSchemaInstances()) {
        String schema = schemaType.getId() + ":";
        if (uri.startsWith(schema)) {
            int index = uri.indexOf(schema) + schema.length();
            uri = uri.substring(index);
            break;
        }
    }
    return uri;
}
Also used : SchemaType(org.gluu.oxtrust.model.scim2.schema.SchemaType)

Aggregations

ObjectMapper (org.codehaus.jackson.map.ObjectMapper)6 ArrayList (java.util.ArrayList)4 Meta (org.gluu.oxtrust.model.scim2.Meta)4 AttributeHolder (org.gluu.oxtrust.model.scim2.schema.AttributeHolder)4 IOException (java.io.IOException)3 Map (java.util.Map)3 JsonNode (org.codehaus.jackson.JsonNode)3 Version (org.codehaus.jackson.Version)3 SimpleModule (org.codehaus.jackson.map.module.SimpleModule)3 Iterator (java.util.Iterator)2 List (java.util.List)2 ArrayNode (org.codehaus.jackson.node.ArrayNode)2 ObjectNode (org.codehaus.jackson.node.ObjectNode)2 SchemaType (org.gluu.oxtrust.model.scim2.schema.SchemaType)2 UserExtensionSchema (org.gluu.oxtrust.model.scim2.schema.extension.UserExtensionSchema)2 URI (java.net.URI)1 DefaultValue (javax.ws.rs.DefaultValue)1 GET (javax.ws.rs.GET)1 HeaderParam (javax.ws.rs.HeaderParam)1 Produces (javax.ws.rs.Produces)1