use of org.gluu.oxtrust.model.association.ClientAssociation in project oxTrust by GluuFederation.
the class ClientAssociationWebService method getAssociatedPersons.
@Path("/Client/{cid}")
@GET
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getAssociatedPersons(@HeaderParam("Authorization") String authorization, @PathParam("cid") String cid) throws Exception {
Response authorizationResponse = processAuthorization(authorization);
if (authorizationResponse != null) {
return authorizationResponse;
}
try {
log.info("getting the client");
OxAuthClient client = clientService.getClientByInum(cid);
if (client == null) {
// sets HTTP status code 404 Not Found
return getErrorResponse("Resource " + cid + " not found", Response.Status.NOT_FOUND.getStatusCode());
}
log.info("mapping client attributes");
ClientAssociation clientAssociation = MapperUtil.map(client, null);
log.info("getting URL");
URI location = new URI("/ClientAssociation/Client/" + cid);
log.info("returning response");
return Response.ok(clientAssociation).location(location).build();
} catch (EntryPersistenceException ex) {
log.error("Exception: ", ex);
return getErrorResponse("Resource " + cid + " not found", Response.Status.NOT_FOUND.getStatusCode());
} catch (Exception ex) {
log.error("Exception: ", ex);
return getErrorResponse(INTERNAL_SERVER_ERROR_MESSAGE, Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
}
}
use of org.gluu.oxtrust.model.association.ClientAssociation in project oxTrust by GluuFederation.
the class MapperUtil method map.
/**
* Maps Clients association attribute with ClientAssociation
*
* @param source
* @param destination
* @return
*/
public static ClientAssociation map(OxAuthClient source, ClientAssociation destination) {
if (source == null) {
return null;
}
if (destination == null) {
destination = new ClientAssociation();
}
destination.setEntryAssociation(source.getInum());
destination.setUserAssociations(source.getAssociatedPersons());
return destination;
}
Aggregations