Search in sources :

Example 71 with Email

use of org.gluu.oxtrust.model.scim2.Email in project ORCID-Source by ORCID.

the class RecordTest method testViewRecordFromPublicAPI.

@Test
public void testViewRecordFromPublicAPI() {
    ClientResponse response = publicV2ApiClient.viewRecordXML(getUser1OrcidId());
    assertNotNull(response);
    assertEquals("invalid " + response, 200, response.getStatus());
    Record record = response.getEntity(Record.class);
    assertNotNull(record);
    assertNotNull(record.getOrcidIdentifier());
    assertEquals(getUser1OrcidId(), record.getOrcidIdentifier().getPath());
    //Check the visibility of every activity that exists
    if (record.getActivitiesSummary() != null) {
        if (record.getActivitiesSummary() != null) {
            //Educations
            if (record.getActivitiesSummary().getEducations() != null) {
                Educations e = record.getActivitiesSummary().getEducations();
                if (e.getSummaries() != null) {
                    for (EducationSummary s : e.getSummaries()) {
                        assertNotNull(s.getSource());
                        assertEquals(Visibility.PUBLIC, s.getVisibility());
                    }
                }
            }
            //Employments
            if (record.getActivitiesSummary().getEmployments() != null) {
                Employments e = record.getActivitiesSummary().getEmployments();
                if (e.getSummaries() != null) {
                    for (EmploymentSummary s : e.getSummaries()) {
                        assertNotNull(s.getSource());
                        assertEquals(Visibility.PUBLIC, s.getVisibility());
                    }
                }
            }
            //Fundings
            if (record.getActivitiesSummary().getFundings() != null) {
                Fundings f = record.getActivitiesSummary().getFundings();
                List<FundingGroup> groups = f.getFundingGroup();
                if (groups != null) {
                    for (FundingGroup fGroup : groups) {
                        List<FundingSummary> summaries = fGroup.getFundingSummary();
                        if (summaries != null) {
                            for (FundingSummary s : summaries) {
                                assertNotNull(s.getSource());
                                assertEquals(Visibility.PUBLIC, s.getVisibility());
                            }
                        }
                    }
                }
            }
            //PeerReviews
            if (record.getActivitiesSummary().getPeerReviews() != null) {
                PeerReviews p = record.getActivitiesSummary().getPeerReviews();
                List<PeerReviewGroup> groups = p.getPeerReviewGroup();
                if (groups != null) {
                    for (PeerReviewGroup pGroup : groups) {
                        List<PeerReviewSummary> summaries = pGroup.getPeerReviewSummary();
                        if (summaries != null) {
                            for (PeerReviewSummary s : summaries) {
                                assertNotNull(s.getSource());
                                assertEquals(Visibility.PUBLIC, s.getVisibility());
                            }
                        }
                    }
                }
            }
            //Works
            if (record.getActivitiesSummary().getWorks() != null) {
                Works w = record.getActivitiesSummary().getWorks();
                List<WorkGroup> groups = w.getWorkGroup();
                if (groups != null) {
                    for (WorkGroup wGroup : groups) {
                        List<WorkSummary> summaries = wGroup.getWorkSummary();
                        if (summaries != null) {
                            for (WorkSummary s : summaries) {
                                assertNotNull(s.getSource());
                                assertEquals(Visibility.PUBLIC, s.getVisibility());
                            }
                        }
                    }
                }
            }
        }
    }
    //Check the visibility of every biography elements that exists
    if (record.getPerson() != null) {
        //Address
        if (record.getPerson().getAddresses() != null) {
            Addresses addresses = record.getPerson().getAddresses();
            List<Address> list = addresses.getAddress();
            if (list != null) {
                for (Address o : list) {
                    assertNotNull(o.getSource());
                    assertEquals(Visibility.PUBLIC, o.getVisibility());
                }
            }
        }
        //Biography
        if (record.getPerson().getBiography() != null) {
            Biography b = record.getPerson().getBiography();
            if (b != null) {
                assertNotNull(b.getVisibility());
                assertEquals(Visibility.PUBLIC, b.getVisibility());
            }
        }
        //Emails
        if (record.getPerson().getEmails() != null) {
            Emails emails = record.getPerson().getEmails();
            List<Email> list = emails.getEmails();
            if (list != null) {
                for (Email e : list) {
                    assertNotNull(e.getVisibility());
                    assertEquals(Visibility.PUBLIC, e.getVisibility());
                }
            }
        }
        //External identifiers
        if (record.getPerson().getExternalIdentifiers() != null) {
            PersonExternalIdentifiers extIds = record.getPerson().getExternalIdentifiers();
            List<PersonExternalIdentifier> list = extIds.getExternalIdentifiers();
            if (list != null) {
                for (PersonExternalIdentifier e : list) {
                    assertEquals(Visibility.PUBLIC, e.getVisibility());
                }
            }
        }
        //Keywords
        if (record.getPerson().getKeywords() != null) {
            Keywords keywords = record.getPerson().getKeywords();
            List<Keyword> list = keywords.getKeywords();
            if (list != null) {
                for (Keyword e : list) {
                    assertEquals(Visibility.PUBLIC, e.getVisibility());
                }
            }
        }
        //Name
        if (record.getPerson().getName() != null) {
            Name name = record.getPerson().getName();
            assertEquals(Visibility.PUBLIC, name.getVisibility());
        }
        //Other names
        if (record.getPerson().getOtherNames() != null) {
            OtherNames otherNames = record.getPerson().getOtherNames();
            List<OtherName> list = otherNames.getOtherNames();
            if (list != null) {
                for (OtherName e : list) {
                    assertEquals(Visibility.PUBLIC, e.getVisibility());
                }
            }
        }
        //Researcher urls
        if (record.getPerson().getResearcherUrls() != null) {
            ResearcherUrls rUrls = record.getPerson().getResearcherUrls();
            List<ResearcherUrl> list = rUrls.getResearcherUrls();
            if (list != null) {
                for (ResearcherUrl e : list) {
                    assertEquals(Visibility.PUBLIC, e.getVisibility());
                }
            }
        }
    }
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) Email(org.orcid.jaxb.model.record_v2.Email) Keywords(org.orcid.jaxb.model.record_v2.Keywords) Address(org.orcid.jaxb.model.record_v2.Address) Fundings(org.orcid.jaxb.model.record.summary_v2.Fundings) OtherNames(org.orcid.jaxb.model.record_v2.OtherNames) PeerReviews(org.orcid.jaxb.model.record.summary_v2.PeerReviews) OtherName(org.orcid.jaxb.model.record_v2.OtherName) Name(org.orcid.jaxb.model.record_v2.Name) Addresses(org.orcid.jaxb.model.record_v2.Addresses) WorkGroup(org.orcid.jaxb.model.record.summary_v2.WorkGroup) WorkSummary(org.orcid.jaxb.model.record.summary_v2.WorkSummary) FundingSummary(org.orcid.jaxb.model.record.summary_v2.FundingSummary) Biography(org.orcid.jaxb.model.record_v2.Biography) ResearcherUrls(org.orcid.jaxb.model.record_v2.ResearcherUrls) Record(org.orcid.jaxb.model.record_v2.Record) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl) Emails(org.orcid.jaxb.model.record_v2.Emails) Works(org.orcid.jaxb.model.record.summary_v2.Works) PeerReviewGroup(org.orcid.jaxb.model.record.summary_v2.PeerReviewGroup) Keyword(org.orcid.jaxb.model.record_v2.Keyword) OtherName(org.orcid.jaxb.model.record_v2.OtherName) PersonExternalIdentifier(org.orcid.jaxb.model.record_v2.PersonExternalIdentifier) FundingGroup(org.orcid.jaxb.model.record.summary_v2.FundingGroup) Employments(org.orcid.jaxb.model.record.summary_v2.Employments) PersonExternalIdentifiers(org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers) EducationSummary(org.orcid.jaxb.model.record.summary_v2.EducationSummary) PeerReviewSummary(org.orcid.jaxb.model.record.summary_v2.PeerReviewSummary) Educations(org.orcid.jaxb.model.record.summary_v2.Educations) EmploymentSummary(org.orcid.jaxb.model.record.summary_v2.EmploymentSummary) Test(org.junit.Test)

Example 72 with Email

use of org.gluu.oxtrust.model.scim2.Email in project ORCID-Source by ORCID.

the class AdminController method lookupIdOrEmails.

@RequestMapping(value = "/lookup-id-or-emails.json", method = RequestMethod.POST)
@ResponseBody
public String lookupIdOrEmails(@RequestBody String csvIdOrEmails) {
    List<String> idEmailList = new ArrayList<String>();
    StringBuilder builder = new StringBuilder();
    if (StringUtils.isNotBlank(csvIdOrEmails)) {
        StringTokenizer tokenizer = new StringTokenizer(csvIdOrEmails, INP_STRING_SEPARATOR);
        while (tokenizer.hasMoreTokens()) {
            idEmailList.add(tokenizer.nextToken());
        }
        for (String idEmail : idEmailList) {
            idEmail = idEmail.trim();
            boolean isOrcid = matchesOrcidPattern(idEmail);
            String orcid = idEmail;
            if (!isOrcid) {
                Map<String, String> email = findIdByEmailHelper(idEmail);
                orcid = email.get(idEmail);
            }
            try {
                if (profileEntityManager.orcidExists(orcid)) {
                    Email email = emailManager.findPrimaryEmail(orcid);
                    if (email != null) {
                        builder.append(email.getEmail());
                    } else {
                        builder.append(OUT_NOT_AVAILABLE);
                    }
                    builder.append(OUT_STRING_SEPARATOR).append(orcid);
                } else {
                    if (isOrcid) {
                        builder.append(OUT_NOT_AVAILABLE).append(OUT_STRING_SEPARATOR).append(idEmail);
                    } else {
                        builder.append(idEmail).append(OUT_STRING_SEPARATOR).append(OUT_NOT_AVAILABLE);
                    }
                }
            } catch (Exception e) {
                //Invalid orcid in the params, so, we can just ignore it
                LOGGER.warn("Unable to get info for " + idEmail, e);
            }
            builder.append(OUT_NEW_LINE);
        }
    }
    return builder.toString();
}
Also used : StringTokenizer(java.util.StringTokenizer) Email(org.orcid.jaxb.model.record_v2.Email) ArrayList(java.util.ArrayList) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 73 with Email

use of org.gluu.oxtrust.model.scim2.Email in project ORCID-Source by ORCID.

the class AdminControllerTest method verifyEmailTest.

@Test
public void verifyEmailTest() {
    HttpServletRequest request = mock(HttpServletRequest.class);
    HttpSession session = mock(HttpSession.class);
    when(request.getSession()).thenReturn(session);
    //Add not verified email
    Email email = new Email();
    email.setEmail("not-verified@email.com");
    email.setCurrent(false);
    email.setPrimary(false);
    email.setVerified(false);
    email.setVisibility(Visibility.PUBLIC);
    emailManager.addEmail(request, "4444-4444-4444-4499", email);
    // Verify the email
    adminController.adminVerifyEmail("not-verified@email.com");
    EmailEntity emailEntity = emailDao.find("not-verified@email.com");
    assertNotNull(emailEntity);
    assertTrue(emailEntity.getVerified());
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) Email(org.orcid.jaxb.model.record_v2.Email) HttpSession(javax.servlet.http.HttpSession) EmailEntity(org.orcid.persistence.jpa.entities.EmailEntity) Test(org.junit.Test) BaseControllerTest(org.orcid.frontend.web.util.BaseControllerTest)

Example 74 with Email

use of org.gluu.oxtrust.model.scim2.Email in project ORCID-Source by ORCID.

the class PublicV2ApiServiceDelegatorTest method validatePerson.

private void validatePerson(Person person) {
    assertNotNull(person);
    assertNotNull(person.getLastModifiedDate());
    assertNotNull(person.getLastModifiedDate().getValue());
    assertNotNull(person.getAddresses());
    assertEquals("/0000-0000-0000-0003/address", person.getAddresses().getPath());
    assertNotNull(person.getAddresses().getLastModifiedDate());
    assertNotNull(person.getAddresses().getLastModifiedDate().getValue());
    assertEquals(1, person.getAddresses().getAddress().size());
    Address address = person.getAddresses().getAddress().get(0);
    assertEquals(Iso3166Country.US, address.getCountry().getValue());
    assertEquals(Visibility.PUBLIC.value(), address.getVisibility().value());
    assertEquals(Long.valueOf(9), address.getPutCode());
    assertEquals("/0000-0000-0000-0003/address/9", address.getPath());
    assertEquals("APP-5555555555555555", address.getSource().retrieveSourcePath());
    assertNotNull(person.getBiography());
    assertEquals(Visibility.PUBLIC.value(), person.getBiography().getVisibility().value());
    assertEquals("Biography for 0000-0000-0000-0003", person.getBiography().getContent());
    assertNotNull(person.getBiography().getLastModifiedDate());
    assertNotNull(person.getBiography().getLastModifiedDate().getValue());
    assertEquals("/0000-0000-0000-0003/biography", person.getBiography().getPath());
    assertNotNull(person.getEmails());
    assertNotNull(person.getEmails().getLastModifiedDate());
    assertNotNull(person.getEmails().getLastModifiedDate().getValue());
    assertEquals(1, person.getEmails().getEmails().size());
    Email email = person.getEmails().getEmails().get(0);
    assertEquals("public_0000-0000-0000-0003@test.orcid.org", email.getEmail());
    assertNotNull(email.getLastModifiedDate());
    assertNotNull(email.getLastModifiedDate().getValue());
    assertEquals("APP-5555555555555555", email.getSource().retrieveSourcePath());
    assertEquals(Visibility.PUBLIC.value(), email.getVisibility().value());
    assertNotNull(person.getExternalIdentifiers());
    assertNotNull(person.getExternalIdentifiers().getLastModifiedDate());
    assertNotNull(person.getExternalIdentifiers().getLastModifiedDate().getValue());
    assertEquals("/0000-0000-0000-0003/external-identifiers", person.getExternalIdentifiers().getPath());
    assertEquals(1, person.getExternalIdentifiers().getExternalIdentifiers().size());
    PersonExternalIdentifier extId = person.getExternalIdentifiers().getExternalIdentifiers().get(0);
    assertNotNull(extId);
    assertNotNull(extId.getLastModifiedDate());
    assertNotNull(extId.getLastModifiedDate().getValue());
    assertEquals(Long.valueOf(13), extId.getPutCode());
    assertEquals("public_type", extId.getType());
    assertNotNull(extId.getUrl());
    assertEquals("http://ext-id/public_ref", extId.getUrl().getValue());
    assertEquals(Visibility.PUBLIC.value(), extId.getVisibility().value());
    assertEquals("/0000-0000-0000-0003/external-identifiers/13", extId.getPath());
    assertEquals("APP-5555555555555555", extId.getSource().retrieveSourcePath());
    assertNotNull(person.getKeywords());
    assertNotNull(person.getKeywords().getLastModifiedDate());
    assertNotNull(person.getKeywords().getLastModifiedDate().getValue());
    assertEquals(1, person.getKeywords().getKeywords().size());
    assertNotNull(person.getKeywords().getLastModifiedDate());
    assertEquals("/0000-0000-0000-0003/keywords", person.getKeywords().getPath());
    Keyword keyword = person.getKeywords().getKeywords().get(0);
    assertNotNull(keyword);
    assertNotNull(keyword.getLastModifiedDate());
    assertNotNull(keyword.getLastModifiedDate().getValue());
    assertEquals(Long.valueOf(9), keyword.getPutCode());
    assertEquals("PUBLIC", keyword.getContent());
    assertEquals(Visibility.PUBLIC.value(), keyword.getVisibility().value());
    assertEquals("/0000-0000-0000-0003/keywords/9", keyword.getPath());
    assertEquals("APP-5555555555555555", keyword.getSource().retrieveSourcePath());
    assertNotNull(person.getName());
    assertNotNull(person.getName().getLastModifiedDate());
    assertNotNull(person.getName().getLastModifiedDate().getValue());
    assertEquals("Credit Name", person.getName().getCreditName().getContent());
    assertEquals("Family Name", person.getName().getFamilyName().getContent());
    assertEquals("Given Names", person.getName().getGivenNames().getContent());
    assertEquals(Visibility.PUBLIC.value(), person.getName().getVisibility().value());
    assertNotNull(person.getOtherNames());
    assertEquals("/0000-0000-0000-0003/other-names", person.getOtherNames().getPath());
    assertNotNull(person.getOtherNames().getLastModifiedDate());
    assertNotNull(person.getOtherNames().getLastModifiedDate().getValue());
    assertEquals(1, person.getOtherNames().getOtherNames().size());
    OtherName otherName = person.getOtherNames().getOtherNames().get(0);
    assertEquals("Other Name PUBLIC", otherName.getContent());
    assertNotNull(otherName.getLastModifiedDate());
    assertNotNull(otherName.getLastModifiedDate().getValue());
    assertEquals("/0000-0000-0000-0003/other-names/13", otherName.getPath());
    assertEquals(Long.valueOf(13), otherName.getPutCode());
    assertEquals("APP-5555555555555555", otherName.getSource().retrieveSourcePath());
    assertEquals(Visibility.PUBLIC.value(), otherName.getVisibility().value());
    assertNotNull(person.getResearcherUrls());
    assertEquals(1, person.getResearcherUrls().getResearcherUrls().size());
    assertNotNull(person.getResearcherUrls().getLastModifiedDate());
    assertNotNull(person.getResearcherUrls().getLastModifiedDate().getValue());
    assertEquals("/0000-0000-0000-0003/researcher-urls", person.getResearcherUrls().getPath());
    ResearcherUrl rUrl = person.getResearcherUrls().getResearcherUrls().get(0);
    assertNotNull(rUrl);
    assertNotNull(rUrl.getLastModifiedDate());
    assertNotNull(rUrl.getLastModifiedDate().getValue());
    assertNotNull(rUrl.getUrl());
    assertEquals("http://www.researcherurl.com?id=13", rUrl.getUrl().getValue());
    assertEquals("public_rurl", rUrl.getUrlName());
    assertEquals(Visibility.PUBLIC.value(), rUrl.getVisibility().value());
    assertEquals("/0000-0000-0000-0003/researcher-urls/13", rUrl.getPath());
    assertEquals("APP-5555555555555555", rUrl.getSource().retrieveSourcePath());
    assertEquals("/0000-0000-0000-0003/person", person.getPath());
}
Also used : Email(org.orcid.jaxb.model.record_v2.Email) Address(org.orcid.jaxb.model.record_v2.Address) Keyword(org.orcid.jaxb.model.record_v2.Keyword) OtherName(org.orcid.jaxb.model.record_v2.OtherName) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl) PersonExternalIdentifier(org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)

Example 75 with Email

use of org.gluu.oxtrust.model.scim2.Email in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_EmailsTest method testReadPublicScope_Emails.

@Test
public void testReadPublicScope_Emails() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_PUBLIC);
    Response r = serviceDelegator.viewEmails(ORCID);
    assertNotNull(r);
    assertEquals(Emails.class.getName(), r.getEntity().getClass().getName());
    Emails email = (Emails) r.getEntity();
    assertNotNull(email);
    assertEquals("/0000-0000-0000-0003/email", email.getPath());
    Utils.verifyLastModified(email.getLastModifiedDate());
    assertEquals(3, email.getEmails().size());
    boolean found1 = false;
    boolean found2 = false;
    boolean found3 = false;
    for (Email element : email.getEmails()) {
        Utils.verifyLastModified(element.getLastModifiedDate());
        if (element.getEmail().equals("public_0000-0000-0000-0003@test.orcid.org")) {
            found1 = true;
        } else if (element.getEmail().equals("limited_0000-0000-0000-0003@test.orcid.org")) {
            found2 = true;
        } else if (element.getEmail().equals("private_0000-0000-0000-0003@test.orcid.org")) {
            found3 = true;
        } else {
            fail("Invalid put code " + element.getPutCode());
        }
    }
    assertTrue(found1);
    assertTrue(found2);
    assertTrue(found3);
}
Also used : Response(javax.ws.rs.core.Response) Email(org.orcid.jaxb.model.record_v2.Email) Emails(org.orcid.jaxb.model.record_v2.Emails) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

Email (org.orcid.jaxb.model.record_v2.Email)82 Test (org.junit.Test)78 Emails (org.orcid.jaxb.model.record_v2.Emails)49 Address (org.orcid.jaxb.model.record_v2.Address)41 Keyword (org.orcid.jaxb.model.record_v2.Keyword)41 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)41 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)41 OtherName (org.orcid.jaxb.model.record_v2.OtherName)39 Person (org.orcid.jaxb.model.record_v2.Person)35 Biography (org.orcid.jaxb.model.record_v2.Biography)34 OtherNames (org.orcid.jaxb.model.record_v2.OtherNames)33 Addresses (org.orcid.jaxb.model.record_v2.Addresses)31 Keywords (org.orcid.jaxb.model.record_v2.Keywords)31 PersonExternalIdentifiers (org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers)31 ResearcherUrls (org.orcid.jaxb.model.record_v2.ResearcherUrls)31 Name (org.orcid.jaxb.model.record_v2.Name)30 Record (org.orcid.jaxb.model.record_v2.Record)19 ArrayList (java.util.ArrayList)18 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)18 EmploymentSummary (org.orcid.jaxb.model.record.summary_v2.EmploymentSummary)18