Search in sources :

Example 1 with Version

use of org.codehaus.jackson.Version in project oxTrust by GluuFederation.

the class BulkWebService method deserializeToUser.

private User deserializeToUser(String dataString) throws Exception {
    ObjectMapper mapper = new ObjectMapper();
    mapper.disable(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES);
    SimpleModule simpleModule = new SimpleModule("DeserializeToUserModule", new Version(1, 0, 0, ""));
    simpleModule.addDeserializer(User.class, new UserDeserializer());
    mapper.registerModule(simpleModule);
    return mapper.readValue(dataString, User.class);
}
Also used : UserDeserializer(org.gluu.oxtrust.service.scim2.jackson.custom.UserDeserializer) Version(org.codehaus.jackson.Version) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) SimpleModule(org.codehaus.jackson.map.module.SimpleModule)

Example 2 with Version

use of org.codehaus.jackson.Version in project oxTrust by GluuFederation.

the class GroupWebService method serializeToJson.

private String serializeToJson(Object object, String attributesArray) throws Exception {
    ObjectMapper mapper = new ObjectMapper();
    mapper.disable(SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS);
    SimpleModule customScimFilterModule = new SimpleModule("CustomScim2GroupFilterModule", new Version(1, 0, 0, ""));
    ListResponseGroupSerializer serializer = new ListResponseGroupSerializer();
    serializer.setAttributesArray(attributesArray);
    customScimFilterModule.addSerializer(Group.class, serializer);
    mapper.registerModule(customScimFilterModule);
    return mapper.writeValueAsString(object);
}
Also used : Version(org.codehaus.jackson.Version) ListResponseGroupSerializer(org.gluu.oxtrust.service.antlr.scimFilter.util.ListResponseGroupSerializer) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) SimpleModule(org.codehaus.jackson.map.module.SimpleModule)

Example 3 with Version

use of org.codehaus.jackson.Version in project oxTrust by GluuFederation.

the class UserDeserializer method deserialize.

@Override
public User deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
    log.info(" deserialize() ");
    try {
        JsonNode rootNode = jsonParser.readValueAsTree();
        ObjectMapper mapper = new ObjectMapper();
        mapper.disable(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES);
        User user = mapper.readValue(rootNode.toString(), User.class);
        if (user.getSchemas() == null) {
            throw new IllegalArgumentException("Required field \"schemas\" is null or missing.");
        } else if (!user.getSchemas().contains(Constants.USER_CORE_SCHEMA_ID)) {
            throw new IllegalArgumentException("User Core schema is required.");
        } else if (user.getSchemas().contains(Constants.USER_EXT_SCHEMA_ID)) {
            JsonNode userExtensionNode = rootNode.get(Constants.USER_EXT_SCHEMA_ID);
            if (userExtensionNode != null) {
                ExtensionDeserializer deserializer = new ExtensionDeserializer();
                deserializer.setId(Constants.USER_EXT_SCHEMA_ID);
                SimpleModule deserializerModule = new SimpleModule("ExtensionDeserializerModule", new Version(1, 0, 0, ""));
                deserializerModule.addDeserializer(Extension.class, deserializer);
                mapper.registerModule(deserializerModule);
                Extension extension = mapper.readValue(userExtensionNode.toString(), Extension.class);
                user.addExtension(extension);
            } else {
                throw new IllegalArgumentException("User Extension schema is indicated, but value body is absent.");
            }
        }
        return user;
    } catch (Exception e) {
        e.printStackTrace();
        throw new IOException(INTERNAL_SERVER_ERROR_MESSAGE);
    }
}
Also used : Extension(org.gluu.oxtrust.model.scim2.Extension) User(org.gluu.oxtrust.model.scim2.User) Version(org.codehaus.jackson.Version) JsonNode(org.codehaus.jackson.JsonNode) IOException(java.io.IOException) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) SimpleModule(org.codehaus.jackson.map.module.SimpleModule) IOException(java.io.IOException)

Example 4 with Version

use of org.codehaus.jackson.Version in project oxTrust by GluuFederation.

the class FidoDeviceCoreLoadingStrategy 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("FidoDeviceCoreLoadingStrategyModule", new Version(1, 0, 0, ""));
    SchemaTypeFidoDeviceSerializer serializer = new SchemaTypeFidoDeviceSerializer();
    serializer.setSchemaType(schemaType);
    userCoreLoadingStrategyModule.addSerializer(FidoDevice.class, serializer);
    mapper.registerModule(userCoreLoadingStrategyModule);
    mapper.writeValueAsString(createDummyFidoDevice());
    return serializer.getSchemaType();
}
Also used : Meta(org.gluu.oxtrust.model.scim2.Meta) SchemaTypeFidoDeviceSerializer(org.gluu.oxtrust.service.scim2.schema.strategy.serializers.SchemaTypeFidoDeviceSerializer) Version(org.codehaus.jackson.Version) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) SimpleModule(org.codehaus.jackson.map.module.SimpleModule)

Example 5 with Version

use of org.codehaus.jackson.Version in project st-js by st-js.

the class STJSModule method getModule.

/**
 * <p>getModule.</p>
 *
 * @return a {@link org.codehaus.jackson.map.Module} object.
 */
public static Module getModule() {
    SimpleModule module = new STJSSimpleModule("MyModule", new Version(1, 0, 0, null));
    module.addSerializer(new JSArraySerializer());
    module.addSerializer(new JSMapSerializer());
    module.addSerializer(new JSDateSerializer());
    module.addDeserializer(Date.class, new JSDateDeserializer());
    return module;
}
Also used : Version(org.codehaus.jackson.Version) SimpleModule(org.codehaus.jackson.map.module.SimpleModule)

Aggregations

Version (org.codehaus.jackson.Version)15 SimpleModule (org.codehaus.jackson.map.module.SimpleModule)15 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)13 URI (java.net.URI)3 DefaultValue (javax.ws.rs.DefaultValue)3 HeaderParam (javax.ws.rs.HeaderParam)3 Produces (javax.ws.rs.Produces)3 Response (javax.ws.rs.core.Response)3 Meta (org.gluu.oxtrust.model.scim2.Meta)3 DuplicateEntryException (org.gluu.site.ldap.exception.DuplicateEntryException)3 EntryPersistenceException (org.gluu.site.ldap.persistence.exception.EntryPersistenceException)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 GET (javax.ws.rs.GET)2 PersonRequiredFieldsException (org.gluu.oxtrust.exception.PersonRequiredFieldsException)2 GluuCustomPerson (org.gluu.oxtrust.model.GluuCustomPerson)2 Extension (org.gluu.oxtrust.model.scim2.Extension)2 User (org.gluu.oxtrust.model.scim2.User)2 ListResponseGroupSerializer (org.gluu.oxtrust.service.antlr.scimFilter.util.ListResponseGroupSerializer)2 ListResponseUserSerializer (org.gluu.oxtrust.service.antlr.scimFilter.util.ListResponseUserSerializer)2