Search in sources :

Example 71 with PeerReview

use of org.orcid.jaxb.model.v3.dev1.record.PeerReview in project ORCID-Source by ORCID.

the class MemberV3ApiServiceDelegatorImpl method updatePeerReview.

@Override
public Response updatePeerReview(String orcid, Long putCode, PeerReview peerReview) {
    orcidSecurityManager.checkClientAccessAndScopes(orcid, ScopePathType.PEER_REVIEW_UPDATE);
    if (!putCode.equals(peerReview.getPutCode())) {
        Map<String, String> params = new HashMap<String, String>();
        params.put("urlPutCode", String.valueOf(putCode));
        params.put("bodyPutCode", String.valueOf(peerReview.getPutCode()));
        throw new MismatchedPutCodeException(params);
    }
    clearSource(peerReview);
    PeerReview updatedPeerReview = peerReviewManager.updatePeerReview(orcid, peerReview, true);
    sourceUtils.setSourceName(updatedPeerReview);
    return Response.ok(updatedPeerReview).build();
}
Also used : HashMap(java.util.HashMap) PeerReview(org.orcid.jaxb.model.v3.dev1.record.PeerReview) MismatchedPutCodeException(org.orcid.core.exception.MismatchedPutCodeException)

Example 72 with PeerReview

use of org.orcid.jaxb.model.v3.dev1.record.PeerReview in project ORCID-Source by ORCID.

the class MemberV3ApiServiceDelegatorImpl method viewPeerReview.

@Override
public Response viewPeerReview(String orcid, Long putCode) {
    PeerReview p = peerReviewManagerReadOnly.getPeerReview(orcid, putCode);
    orcidSecurityManager.checkAndFilter(orcid, p, ScopePathType.PEER_REVIEW_READ_LIMITED);
    ActivityUtils.setPathToActivity(p, orcid);
    sourceUtils.setSourceName(p);
    return Response.ok(p).build();
}
Also used : PeerReview(org.orcid.jaxb.model.v3.dev1.record.PeerReview)

Example 73 with PeerReview

use of org.orcid.jaxb.model.v3.dev1.record.PeerReview in project ORCID-Source by ORCID.

the class MemberV3Dev1Test method testAddPeerReviewWithInvalidGroupingId.

@Test
public void testAddPeerReviewWithInvalidGroupingId() throws JSONException, InterruptedException, URISyntaxException {
    PeerReview peerReview = (PeerReview) unmarshallFromPath("/record_3.0_dev1/samples/read_samples/peer-review-3.0_dev1.xml", PeerReview.class);
    peerReview.setPutCode(null);
    peerReview.setGroupId("Invalid group id " + System.currentTimeMillis());
    peerReview.getExternalIdentifiers().getExternalIdentifier().clear();
    ExternalID pExtId = new ExternalID();
    pExtId.setValue("Work Id " + System.currentTimeMillis());
    pExtId.setType(WorkExternalIdentifierType.AGR.value());
    pExtId.setRelationship(Relationship.SELF);
    peerReview.getExternalIdentifiers().getExternalIdentifier().add(pExtId);
    String accessToken = getAccessToken();
    // Pattern not valid
    ClientResponse postResponse = memberV3Dev1ApiClientImpl.createPeerReviewXml(this.getUser1OrcidId(), peerReview, accessToken);
    assertNotNull(postResponse);
    assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), postResponse.getStatus());
    // Null group id
    peerReview.setGroupId(null);
    postResponse = memberV3Dev1ApiClientImpl.createPeerReviewXml(this.getUser1OrcidId(), peerReview, accessToken);
    assertNotNull(postResponse);
    assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), postResponse.getStatus());
    // Empty group id
    peerReview.setGroupId("");
    postResponse = memberV3Dev1ApiClientImpl.createPeerReviewXml(this.getUser1OrcidId(), peerReview, accessToken);
    assertNotNull(postResponse);
    assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), postResponse.getStatus());
    // Invalid group id
    peerReview.setGroupId("orcid-generated:" + peerReview.getGroupId());
    postResponse = memberV3Dev1ApiClientImpl.createPeerReviewXml(this.getUser1OrcidId(), peerReview, accessToken);
    assertNotNull(postResponse);
    assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), postResponse.getStatus());
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) PeerReview(org.orcid.jaxb.model.v3.dev1.record.PeerReview) Test(org.junit.Test)

Aggregations

PeerReview (org.orcid.jaxb.model.v3.dev1.record.PeerReview)66 Test (org.junit.Test)49 Response (javax.ws.rs.core.Response)20 DBUnitTest (org.orcid.test.DBUnitTest)20 ExternalID (org.orcid.jaxb.model.v3.dev1.record.ExternalID)12 PeerReviewEntity (org.orcid.persistence.jpa.entities.PeerReviewEntity)9 SourceEntity (org.orcid.persistence.jpa.entities.SourceEntity)9 Url (org.orcid.jaxb.model.v3.dev1.common.Url)8 Funding (org.orcid.jaxb.model.v3.dev1.record.Funding)8 ResearcherUrl (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl)8 Work (org.orcid.jaxb.model.v3.dev1.record.Work)7 BaseTest (org.orcid.core.BaseTest)6 Title (org.orcid.jaxb.model.v3.dev1.common.Title)6 Education (org.orcid.jaxb.model.v3.dev1.record.Education)6 WorkTitle (org.orcid.jaxb.model.v3.dev1.record.WorkTitle)6 PeerReviewSummary (org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewSummary)6 ArrayList (java.util.ArrayList)5 Day (org.orcid.jaxb.model.v3.dev1.common.Day)5 Month (org.orcid.jaxb.model.v3.dev1.common.Month)5 Year (org.orcid.jaxb.model.v3.dev1.common.Year)5