Search in sources :

Example 71 with Emails

use of org.orcid.jaxb.model.record_rc4.Emails in project ORCID-Source by ORCID.

the class PublicAPISecurityManagerV2Test method filterEmailsTest.

@Test
public void filterEmailsTest() {
    Emails x = getEmailsElement(Visibility.PUBLIC, Visibility.PUBLIC, Visibility.PUBLIC);
    assertEquals(3, x.getEmails().size());
    publicAPISecurityManagerV2.filter(x);
    assertEquals(3, x.getEmails().size());
    assertAllArePublic(x.getEmails());
    x = getEmailsElement(Visibility.PUBLIC, Visibility.PUBLIC, Visibility.LIMITED);
    assertEquals(3, x.getEmails().size());
    publicAPISecurityManagerV2.filter(x);
    assertEquals(2, x.getEmails().size());
    assertAllArePublic(x.getEmails());
    x = getEmailsElement(Visibility.PUBLIC, Visibility.LIMITED, Visibility.PRIVATE);
    assertEquals(3, x.getEmails().size());
    publicAPISecurityManagerV2.filter(x);
    assertEquals(1, x.getEmails().size());
    assertAllArePublic(x.getEmails());
    x = getEmailsElement(Visibility.PRIVATE, Visibility.LIMITED, Visibility.PRIVATE);
    assertEquals(3, x.getEmails().size());
    publicAPISecurityManagerV2.filter(x);
    assertTrue(x.getEmails().isEmpty());
}
Also used : Emails(org.orcid.jaxb.model.record_v2.Emails) Test(org.junit.Test)

Example 72 with Emails

use of org.orcid.jaxb.model.record_rc4.Emails in project ORCID-Source by ORCID.

the class PublicAPISecurityManagerV2Test method getEmailsElement.

private Emails getEmailsElement(Visibility... vs) {
    Emails elements = new Emails();
    for (Visibility v : vs) {
        Email element = new Email();
        element.setVisibility(v);
        if (elements.getEmails() == null) {
            elements.setEmails(new ArrayList<Email>());
        }
        elements.getEmails().add(element);
    }
    return elements;
}
Also used : Email(org.orcid.jaxb.model.record_v2.Email) Visibility(org.orcid.jaxb.model.common_v2.Visibility) Emails(org.orcid.jaxb.model.record_v2.Emails)

Example 73 with Emails

use of org.orcid.jaxb.model.record_rc4.Emails in project ORCID-Source by ORCID.

the class PublicV2ApiServiceDelegatorImpl method viewEmails.

@Override
public Response viewEmails(String orcid) {
    long lastModifiedTime = getLastModifiedTime(orcid);
    Emails emails = emailManagerReadOnly.getPublicEmails(orcid, lastModifiedTime);
    publicAPISecurityManagerV2.filter(emails);
    ElementUtils.setPathToEmail(emails, orcid);
    Api2_0_LastModifiedDatesHelper.calculateLastModified(emails);
    sourceUtilsReadOnly.setSourceName(emails);
    return Response.ok(emails).build();
}
Also used : Emails(org.orcid.jaxb.model.record_v2.Emails)

Example 74 with Emails

use of org.orcid.jaxb.model.record_rc4.Emails in project ORCID-Source by ORCID.

the class ManageProfileController method validateDeprecateProfile.

@RequestMapping(value = "/validate-deprecate-profile.json", method = RequestMethod.POST)
@ResponseBody
public DeprecateProfile validateDeprecateProfile(@RequestBody DeprecateProfile deprecateProfile) {
    validateFormData(deprecateProfile);
    if (!deprecateProfile.getErrors().isEmpty()) {
        return deprecateProfile;
    }
    String currentUserOrcid = getCurrentUserOrcid();
    ProfileEntity primaryEntity = profileEntityCacheManager.retrieve(currentUserOrcid);
    ProfileEntity deprecatingEntity = getDeprecatingEntity(deprecateProfile);
    validateDeprecatingEntity(deprecatingEntity, primaryEntity, deprecateProfile);
    if (deprecateProfile.getErrors() != null && !deprecateProfile.getErrors().isEmpty()) {
        return deprecateProfile;
    }
    validateDeprecateAccountRequest(deprecateProfile, deprecatingEntity);
    if (deprecateProfile.getErrors() != null && !deprecateProfile.getErrors().isEmpty()) {
        return deprecateProfile;
    }
    Emails deprecatingEmails = emailManager.getEmails(deprecatingEntity.getId(), 0l);
    Emails primaryEmails = emailManager.getEmails(primaryEntity.getId(), 0l);
    String primaryAccountName = RecordNameUtils.getPublicName(primaryEntity.getRecordNameEntity());
    String deprecatingAccountName = RecordNameUtils.getPublicName(deprecatingEntity.getRecordNameEntity());
    deprecateProfile.setPrimaryAccountName(primaryAccountName);
    deprecateProfile.setPrimaryOrcid(currentUserOrcid);
    deprecateProfile.setDeprecatingAccountName(deprecatingAccountName);
    deprecateProfile.setDeprecatingOrcid(deprecatingEntity.getId());
    if (deprecatingEmails != null) {
        deprecateProfile.setDeprecatingEmails(deprecatingEmails.getEmails().stream().map(e -> e.getEmail()).collect(Collectors.toList()));
    }
    if (primaryEmails != null) {
        deprecateProfile.setPrimaryEmails(primaryEmails.getEmails().stream().map(e -> e.getEmail()).collect(Collectors.toList()));
    }
    return deprecateProfile;
}
Also used : Emails(org.orcid.jaxb.model.record_v2.Emails) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 75 with Emails

use of org.orcid.jaxb.model.record_rc4.Emails in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegatorImpl method viewEmails.

@Override
public Response viewEmails(String orcid) {
    Emails emails = null;
    long lastModified = getLastModifiedTime(orcid);
    try {
        // return all emails if client has /email/read-private scope
        orcidSecurityManager.checkClientAccessAndScopes(orcid, ScopePathType.EMAIL_READ_PRIVATE);
        emails = emailManagerReadOnly.getEmails(orcid, lastModified);
        // Lets copy the list so we don't modify the cached collection
        List<Email> filteredList = new ArrayList<Email>(emails.getEmails());
        emails = new Emails();
        emails.setEmails(filteredList);
    } catch (OrcidAccessControlException e) {
        emails = emailManagerReadOnly.getEmails(orcid, lastModified);
        // Lets copy the list so we don't modify the cached collection
        List<Email> filteredList = new ArrayList<Email>(emails.getEmails());
        emails = new Emails();
        emails.setEmails(filteredList);
        // Filter just in case client doesn't have the /email/read-private
        // scope
        orcidSecurityManager.checkAndFilter(orcid, emails.getEmails(), ScopePathType.ORCID_BIO_READ_LIMITED);
    }
    ElementUtils.setPathToEmail(emails, orcid);
    Api2_0_LastModifiedDatesHelper.calculateLastModified(emails);
    sourceUtils.setSourceName(emails);
    return Response.ok(emails).build();
}
Also used : Email(org.orcid.jaxb.model.record_v2.Email) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) Emails(org.orcid.jaxb.model.record_v2.Emails) OrcidAccessControlException(org.orcid.core.exception.OrcidAccessControlException)

Aggregations

Emails (org.orcid.jaxb.model.record_v2.Emails)61 Test (org.junit.Test)60 Email (org.orcid.jaxb.model.record_v2.Email)49 Addresses (org.orcid.jaxb.model.record_v2.Addresses)33 Keywords (org.orcid.jaxb.model.record_v2.Keywords)33 OtherNames (org.orcid.jaxb.model.record_v2.OtherNames)33 PersonExternalIdentifiers (org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers)33 ResearcherUrls (org.orcid.jaxb.model.record_v2.ResearcherUrls)33 Address (org.orcid.jaxb.model.record_v2.Address)32 Biography (org.orcid.jaxb.model.record_v2.Biography)32 OtherName (org.orcid.jaxb.model.record_v2.OtherName)32 Keyword (org.orcid.jaxb.model.record_v2.Keyword)31 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)31 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)31 Person (org.orcid.jaxb.model.record_v2.Person)30 Name (org.orcid.jaxb.model.record_v2.Name)29 Record (org.orcid.jaxb.model.record_v2.Record)16 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)15 EmploymentSummary (org.orcid.jaxb.model.record.summary_v2.EmploymentSummary)15 FundingSummary (org.orcid.jaxb.model.record.summary_v2.FundingSummary)15