Search in sources :

Example 51 with Visibility

use of org.orcid.jaxb.model.common_rc4.Visibility in project ORCID-Source by ORCID.

the class PublicAPISecurityManagerV2Test method getOtherNamesElement.

private OtherNames getOtherNamesElement(Visibility... vs) {
    OtherNames otherNames = new OtherNames();
    for (Visibility v : vs) {
        OtherName o = new OtherName();
        o.setVisibility(v);
        if (otherNames.getOtherNames() == null) {
            otherNames.setOtherNames(new ArrayList<OtherName>());
        }
        otherNames.getOtherNames().add(o);
    }
    return otherNames;
}
Also used : OtherNames(org.orcid.jaxb.model.record_v2.OtherNames) OtherName(org.orcid.jaxb.model.record_v2.OtherName) Visibility(org.orcid.jaxb.model.common_v2.Visibility)

Example 52 with Visibility

use of org.orcid.jaxb.model.common_rc4.Visibility in project ORCID-Source by ORCID.

the class PublicAPISecurityManagerV2Test method getWorks.

private Works getWorks(Visibility... vs) {
    Works works = new Works();
    for (Visibility v : vs) {
        WorkGroup g = new WorkGroup();
        WorkSummary s = new WorkSummary();
        s.setVisibility(v);
        g.getWorkSummary().add(s);
        works.getWorkGroup().add(g);
    }
    return works;
}
Also used : WorkGroup(org.orcid.jaxb.model.record.summary_v2.WorkGroup) WorkSummary(org.orcid.jaxb.model.record.summary_v2.WorkSummary) Visibility(org.orcid.jaxb.model.common_v2.Visibility) Works(org.orcid.jaxb.model.record.summary_v2.Works)

Example 53 with Visibility

use of org.orcid.jaxb.model.common_rc4.Visibility in project ORCID-Source by ORCID.

the class PublicAPISecurityManagerV2Test method getResearcherUrlsElement.

private ResearcherUrls getResearcherUrlsElement(Visibility... vs) {
    ResearcherUrls elements = new ResearcherUrls();
    for (Visibility v : vs) {
        ResearcherUrl element = new ResearcherUrl();
        element.setVisibility(v);
        if (elements.getResearcherUrls() == null) {
            elements.setResearcherUrls(new ArrayList<ResearcherUrl>());
        }
        elements.getResearcherUrls().add(element);
    }
    return elements;
}
Also used : ResearcherUrls(org.orcid.jaxb.model.record_v2.ResearcherUrls) Visibility(org.orcid.jaxb.model.common_v2.Visibility) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl)

Example 54 with Visibility

use of org.orcid.jaxb.model.common_rc4.Visibility in project ORCID-Source by ORCID.

the class WorkManagerImpl method setIncomingWorkPrivacy.

private void setIncomingWorkPrivacy(WorkEntity workEntity, ProfileEntity profile) {
    Visibility incomingWorkVisibility = workEntity.getVisibility();
    Visibility defaultWorkVisibility = profile.getActivitiesVisibilityDefault();
    if (profile.getClaimed()) {
        workEntity.setVisibility(defaultWorkVisibility);
    } else if (incomingWorkVisibility == null) {
        workEntity.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.PRIVATE);
    }
}
Also used : Visibility(org.orcid.jaxb.model.common_v2.Visibility)

Example 55 with Visibility

use of org.orcid.jaxb.model.common_rc4.Visibility in project ORCID-Source by ORCID.

the class MemberV2Test method createViewUpdateAndDeleteFunding.

@Test
public void createViewUpdateAndDeleteFunding() throws JSONException, InterruptedException, URISyntaxException {
    long time = System.currentTimeMillis();
    Funding funding = (Funding) unmarshallFromPath("/record_2.0/samples/read_samples/funding-2.0.xml", Funding.class);
    funding.setPutCode(null);
    funding.setVisibility(Visibility.PUBLIC);
    funding.getExternalIdentifiers().getExternalIdentifier().clear();
    ExternalID fExtId = new ExternalID();
    fExtId.setType(FundingExternalIdentifierType.GRANT_NUMBER.value());
    fExtId.setValue("Funding Id " + time);
    fExtId.setRelationship(Relationship.SELF);
    funding.getExternalIdentifiers().getExternalIdentifier().add(fExtId);
    String accessToken = getAccessToken();
    ClientResponse postResponse = memberV2ApiClient.createFundingXml(this.getUser1OrcidId(), funding, accessToken);
    assertNotNull(postResponse);
    assertEquals(Response.Status.CREATED.getStatusCode(), postResponse.getStatus());
    String locationPath = postResponse.getLocation().getPath();
    assertTrue("Location header path should match pattern, but was " + locationPath, locationPath.matches(".*/v2.0/" + this.getUser1OrcidId() + "/funding/\\d+"));
    ClientResponse getResponse = memberV2ApiClient.viewLocationXml(postResponse.getLocation(), accessToken);
    assertEquals(Response.Status.OK.getStatusCode(), getResponse.getStatus());
    Funding gotFunding = getResponse.getEntity(Funding.class);
    assertEquals("common:title", gotFunding.getTitle().getTitle().getContent());
    assertEquals("common:translated-title", gotFunding.getTitle().getTranslatedTitle().getContent());
    assertEquals("en", gotFunding.getTitle().getTranslatedTitle().getLanguageCode());
    //Save the original visibility
    Visibility originalVisibility = gotFunding.getVisibility();
    Visibility updatedVisibility = Visibility.PRIVATE.equals(originalVisibility) ? Visibility.LIMITED : Visibility.PRIVATE;
    //Verify you cant update the visibility
    gotFunding.setVisibility(updatedVisibility);
    ClientResponse putResponse = memberV2ApiClient.updateLocationXml(postResponse.getLocation(), accessToken, gotFunding);
    assertEquals(Response.Status.FORBIDDEN.getStatusCode(), putResponse.getStatus());
    OrcidError error = putResponse.getEntity(OrcidError.class);
    assertNotNull(error);
    assertEquals(Integer.valueOf(9035), error.getErrorCode());
    //Set the visibility again to the initial one
    gotFunding.setVisibility(originalVisibility);
    gotFunding.getTitle().getTitle().setContent("Updated title");
    gotFunding.getTitle().getTranslatedTitle().setContent("Updated translated title");
    gotFunding.getTitle().getTranslatedTitle().setLanguageCode("es");
    putResponse = memberV2ApiClient.updateLocationXml(postResponse.getLocation(), accessToken, gotFunding);
    assertEquals(Response.Status.OK.getStatusCode(), putResponse.getStatus());
    ClientResponse getAfterUpdateResponse = memberV2ApiClient.viewLocationXml(postResponse.getLocation(), accessToken);
    assertEquals(Response.Status.OK.getStatusCode(), getAfterUpdateResponse.getStatus());
    Funding gotAfterUpdateFunding = getAfterUpdateResponse.getEntity(Funding.class);
    assertEquals("Updated title", gotAfterUpdateFunding.getTitle().getTitle().getContent());
    assertEquals("Updated translated title", gotAfterUpdateFunding.getTitle().getTranslatedTitle().getContent());
    assertEquals("es", gotAfterUpdateFunding.getTitle().getTranslatedTitle().getLanguageCode());
    ClientResponse deleteResponse = memberV2ApiClient.deleteFundingXml(this.getUser1OrcidId(), gotFunding.getPutCode(), accessToken);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), deleteResponse.getStatus());
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) OrcidError(org.orcid.jaxb.model.error_v2.OrcidError) Funding(org.orcid.jaxb.model.record_v2.Funding) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) Visibility(org.orcid.jaxb.model.common_v2.Visibility) Test(org.junit.Test)

Aggregations

Visibility (org.orcid.jaxb.model.common_v2.Visibility)55 Test (org.junit.Test)36 ClientResponse (com.sun.jersey.api.client.ClientResponse)35 SourceEntity (org.orcid.persistence.jpa.entities.SourceEntity)12 HashMap (java.util.HashMap)10 OrcidError (org.orcid.jaxb.model.error_v2.OrcidError)10 OrcidError (org.orcid.jaxb.model.error_rc1.OrcidError)9 Visibility (org.orcid.jaxb.model.common_rc2.Visibility)8 ExternalID (org.orcid.jaxb.model.record_v2.ExternalID)8 Date (java.util.Date)7 Visibility (org.orcid.jaxb.model.common_rc1.Visibility)7 Visibility (org.orcid.jaxb.model.common_rc3.Visibility)6 OrcidDuplicatedElementException (org.orcid.core.exception.OrcidDuplicatedElementException)5 Funding (org.orcid.jaxb.model.record_v2.Funding)5 PeerReview (org.orcid.jaxb.model.record_v2.PeerReview)5 Work (org.orcid.jaxb.model.record_v2.Work)5 ProfileEntity (org.orcid.persistence.jpa.entities.ProfileEntity)5 Visibility (org.orcid.jaxb.model.common_rc4.Visibility)4 OrcidError (org.orcid.jaxb.model.error_rc3.OrcidError)4 OrgEntity (org.orcid.persistence.jpa.entities.OrgEntity)4