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();
}
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();
}
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());
}
Aggregations