Search in sources :

Example 1 with PersonAssociation

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;
}
Also used : PersonAssociation(org.gluu.oxtrust.model.association.PersonAssociation)

Example 2 with PersonAssociation

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());
    }
}
Also used : Response(javax.ws.rs.core.Response) GluuCustomPerson(org.gluu.oxtrust.model.GluuCustomPerson) EntryPersistenceException(org.gluu.site.ldap.persistence.exception.EntryPersistenceException) PersonAssociation(org.gluu.oxtrust.model.association.PersonAssociation) URI(java.net.URI) EntryPersistenceException(org.gluu.site.ldap.persistence.exception.EntryPersistenceException) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

PersonAssociation (org.gluu.oxtrust.model.association.PersonAssociation)2 URI (java.net.URI)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 Response (javax.ws.rs.core.Response)1 GluuCustomPerson (org.gluu.oxtrust.model.GluuCustomPerson)1 EntryPersistenceException (org.gluu.site.ldap.persistence.exception.EntryPersistenceException)1