use of org.gluu.oxtrust.model.association.PersonAssociation in project oxTrust by GluuFederation.
the class MapperUtil method map.
/**
* Maps persons association attribute with personAssociation
*
* @param source
* @param destination
* @return
*/
public static PersonAssociation map(GluuCustomPerson source, PersonAssociation destination) {
if (source == null) {
return null;
}
if (destination == null) {
destination = new PersonAssociation();
}
destination.setUserAssociation(source.getInum());
destination.setEntryAssociations(source.getAssociatedClient());
return destination;
}
use of org.gluu.oxtrust.model.association.PersonAssociation in project oxTrust by GluuFederation.
the class ClientAssociationWebService method getAssociatedClients.
@Path("/User/{uid}")
@GET
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getAssociatedClients(@HeaderParam("Authorization") String authorization, @PathParam("uid") String uid) throws Exception {
Response authorizationResponse = processAuthorization(authorization);
if (authorizationResponse != null) {
return authorizationResponse;
}
try {
GluuCustomPerson gluuPerson = personService.getPersonByInum(uid);
if (gluuPerson == null) {
// sets HTTP status code 404 Not Found
return getErrorResponse("Resource " + uid + " not found", Response.Status.NOT_FOUND.getStatusCode());
}
PersonAssociation personAssociation = MapperUtil.map(gluuPerson, null);
URI location = new URI("/ClientAssociation/User/" + uid);
return Response.ok(personAssociation).location(location).build();
} catch (EntryPersistenceException ex) {
log.error("Exception: ", ex);
return getErrorResponse("Resource " + uid + " 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());
}
}
Aggregations