use of org.gluu.oxtrust.service.scim2.schema.SchemaTypeLoadingFactory in project oxTrust by GluuFederation.
the class SchemaWebService method listSchemas.
/**
* Retrieves the complete schema.
*
* @param authorization
* @return
* @throws Exception
*/
@GET
@Produces(Constants.MEDIA_TYPE_SCIM_JSON + "; charset=utf-8")
@HeaderParam("Accept")
@DefaultValue(Constants.MEDIA_TYPE_SCIM_JSON)
public Response listSchemas(@HeaderParam("Authorization") String authorization) throws Exception {
log.info(" listSchemas() ");
ListResponse listResponse = new ListResponse();
List<String> schemas = new ArrayList<String>();
schemas.add(Constants.LIST_RESPONSE_SCHEMA_ID);
listResponse.setSchemas(schemas);
List<SchemaType> schemaTypes = SchemaTypeMapping.getSchemaInstances();
List<Resource> resources = new ArrayList<Resource>();
SchemaTypeLoadingFactory factory = new SchemaTypeLoadingFactory();
for (SchemaType schemaType : schemaTypes) {
factory.load(appConfiguration, schemaType);
resources.add(schemaType);
}
listResponse.setResources(resources);
listResponse.setTotalResults(schemaTypes.size());
listResponse.setItemsPerPage(10);
listResponse.setStartIndex(1);
URI location = new URI(appConfiguration.getBaseEndpoint() + "/scim/v2/Schemas");
// Serialize to JSON
String json = serialize(listResponse);
return Response.ok(json).location(location).build();
}
use of org.gluu.oxtrust.service.scim2.schema.SchemaTypeLoadingFactory in project oxTrust by GluuFederation.
the class SchemaWebService method getSchemaById.
/**
* Retrieves a schema via its id/urn.
*
* @param authorization
* @param id
* @return
* @throws Exception
*/
@GET
@Path("{id}")
@Produces(Constants.MEDIA_TYPE_SCIM_JSON + "; charset=utf-8")
@HeaderParam("Accept")
@DefaultValue(Constants.MEDIA_TYPE_SCIM_JSON)
public Response getSchemaById(@HeaderParam("Authorization") String authorization, @PathParam("id") String id) throws Exception {
log.info(" getSchemaById(), id = '" + id + "'");
SchemaTypeLoadingFactory factory = new SchemaTypeLoadingFactory();
SchemaType schemaType = factory.load(appConfiguration, id);
if (schemaType == null) {
log.info(" NOT FOUND: schema with id = '" + id + "'");
return Response.status(Response.Status.NOT_FOUND).build();
}
URI location = new URI(appConfiguration.getBaseEndpoint() + "/scim/v2/Schemas/" + id);
// Serialize to JSON
String json = serialize(schemaType);
return Response.ok(json).location(location).build();
}
Aggregations