Search in sources :

Example 1 with MemberInfo

use of org.orcid.internal.util.MemberInfo in project ORCID-Source by ORCID.

the class InternalApiServiceDelegatorImpl method viewMemberInfo.

@Override
public Response viewMemberInfo(String memberIdOrName) {
    Member member = memberManager.getMember(memberIdOrName);
    if (member == null || (member.getErrors() != null && !member.getErrors().isEmpty())) {
        OrcidError orcidError = new OrcidError();
        orcidError.setResponseCode(404);
        orcidError.setErrorCode(0);
        orcidError.setMoreInfo("Unable to find member info for: " + memberIdOrName);
        orcidError.setDeveloperMessage("Member id or name not found for: " + memberIdOrName);
        orcidError.setUserMessage("Unable to find member info for: " + memberIdOrName);
        return Response.status(Response.Status.NOT_FOUND).entity(orcidError).build();
    }
    MemberInfo memberInfo = MemberInfo.fromMember(member);
    return Response.ok(memberInfo).build();
}
Also used : OrcidError(org.orcid.jaxb.model.error_v2.OrcidError) MemberInfo(org.orcid.internal.util.MemberInfo) Member(org.orcid.pojo.ajaxForm.Member)

Example 2 with MemberInfo

use of org.orcid.internal.util.MemberInfo in project ORCID-Source by ORCID.

the class InternalApiServiceDelegatorTest method viewMemberInfo.

@Test
public void viewMemberInfo() {
    String memberId = "5555-5555-5555-5558";
    Response response = internalApiServiceDelegator.viewMemberInfo(memberId);
    assertNotNull(response);
    MemberInfo info = (MemberInfo) response.getEntity();
    assertNotNull(info);
    assertEquals(memberId, info.getId());
    assertNotNull(info.getName());
    assertNotNull(info.getClients());
    assertFalse(info.getClients().isEmpty());
    response = internalApiServiceDelegator.viewMemberInfo(info.getName());
    assertNotNull(response);
    MemberInfo infoByName = (MemberInfo) response.getEntity();
    assertNotNull(infoByName);
    assertEquals(memberId, infoByName.getId());
    assertEquals(info, infoByName);
    response = internalApiServiceDelegator.viewMemberInfo("invalid name");
    assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatus());
    OrcidError error = (OrcidError) response.getEntity();
    assertNotNull(error);
    assertEquals(new Integer(0), error.getErrorCode());
    assertEquals("Member id or name not found for: invalid name", error.getDeveloperMessage());
}
Also used : LastModifiedResponse(org.orcid.internal.util.LastModifiedResponse) Response(javax.ws.rs.core.Response) OrcidError(org.orcid.jaxb.model.error_v2.OrcidError) MemberInfo(org.orcid.internal.util.MemberInfo) Test(org.junit.Test) DBUnitTest(org.orcid.test.DBUnitTest)

Aggregations

MemberInfo (org.orcid.internal.util.MemberInfo)2 OrcidError (org.orcid.jaxb.model.error_v2.OrcidError)2 Response (javax.ws.rs.core.Response)1 Test (org.junit.Test)1 LastModifiedResponse (org.orcid.internal.util.LastModifiedResponse)1 Member (org.orcid.pojo.ajaxForm.Member)1 DBUnitTest (org.orcid.test.DBUnitTest)1