Search in sources :

Example 6 with ResearcherUrls

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

the class MemberV3ApiServiceDelegator_ResearcherUrlsTest method testViewResearcherUrlsReadPublic.

@Test
public void testViewResearcherUrlsReadPublic() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_PUBLIC);
    Response r = serviceDelegator.viewResearcherUrls(ORCID);
    ResearcherUrls elements = (ResearcherUrls) r.getEntity();
    assertNotNull(elements);
    assertEquals("/0000-0000-0000-0003/researcher-urls", elements.getPath());
    for (ResearcherUrl element : elements.getResearcherUrls()) {
        if (!element.retrieveSourcePath().equals("APP-5555555555555555") && !Visibility.PUBLIC.equals(element.getVisibility())) {
            fail("Element " + element.getPutCode() + " is not source of APP-5555555555555555 and is not public");
        }
    }
}
Also used : Response(javax.ws.rs.core.Response) ResearcherUrls(org.orcid.jaxb.model.v3.dev1.record.ResearcherUrls) ResearcherUrl(org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 7 with ResearcherUrls

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

the class OrcidInfo method publicPreview.

@RequestMapping(value = { "/{orcid:(?:\\d{4}-){3,}\\d{3}[\\dX]}", "/{orcid:(?:\\d{4}-){3,}\\d{3}[\\dX]}/print" })
public ModelAndView publicPreview(HttpServletRequest request, HttpServletResponse response, @RequestParam(value = "page", defaultValue = "1") int pageNo, @RequestParam(value = "v", defaultValue = "0") int v, @RequestParam(value = "maxResults", defaultValue = "15") int maxResults, @PathVariable("orcid") String orcid) {
    ProfileEntity profile = null;
    try {
        profile = profileEntityCacheManager.retrieve(orcid);
    } catch (Exception e) {
        response.setStatus(HttpStatus.NOT_FOUND.value());
        return new ModelAndView("error-404");
    }
    try {
        // Check if the profile is deprecated, non claimed or locked
        orcidSecurityManager.checkProfile(orcid);
    } catch (OrcidDeprecatedException | OrcidNotClaimedException | LockedException | DeactivatedException e) {
        ModelAndView mav = new ModelAndView("public_profile_unavailable");
        mav.addObject("effectiveUserOrcid", orcid);
        String displayName = "";
        if (e instanceof OrcidDeprecatedException) {
            PersonalDetails publicPersonalDetails = personalDetailsManager.getPublicPersonalDetails(orcid);
            if (publicPersonalDetails.getName() != null) {
                Name name = publicPersonalDetails.getName();
                if (name.getVisibility().equals(Visibility.PUBLIC)) {
                    if (name.getCreditName() != null && !PojoUtil.isEmpty(name.getCreditName().getContent())) {
                        displayName = name.getCreditName().getContent();
                    } else {
                        if (name.getGivenNames() != null && !PojoUtil.isEmpty(name.getGivenNames().getContent())) {
                            displayName = name.getGivenNames().getContent() + " ";
                        }
                        if (name.getFamilyName() != null && !PojoUtil.isEmpty(name.getFamilyName().getContent())) {
                            displayName += name.getFamilyName().getContent();
                        }
                    }
                }
            }
            mav.addObject("deprecated", true);
            mav.addObject("primaryRecord", profile.getPrimaryRecord().getId());
        } else if (e instanceof OrcidNotClaimedException) {
            displayName = localeManager.resolveMessage("orcid.reserved_for_claim");
        } else if (e instanceof LockedException) {
            mav.addObject("locked", true);
            mav.addObject("isPublicProfile", true);
            displayName = localeManager.resolveMessage("public_profile.deactivated.given_names") + " " + localeManager.resolveMessage("public_profile.deactivated.family_name");
        } else {
            mav.addObject("deactivated", true);
            displayName = localeManager.resolveMessage("public_profile.deactivated.given_names") + " " + localeManager.resolveMessage("public_profile.deactivated.family_name");
        }
        if (!PojoUtil.isEmpty(displayName)) {
            mav.addObject("title", getMessage("layout.public-layout.title", displayName, orcid));
            mav.addObject("displayName", displayName);
        }
        return mav;
    }
    long lastModifiedTime = getLastModifiedTime(orcid);
    ModelAndView mav = null;
    if (request.getRequestURI().contains("/print")) {
        mav = new ModelAndView("print_public_record");
        mav.addObject("hideUserVoiceScript", true);
    } else {
        mav = new ModelAndView("public_profile_v3");
    }
    mav.addObject("isPublicProfile", true);
    mav.addObject("effectiveUserOrcid", orcid);
    mav.addObject("lastModifiedTime", lastModifiedTime);
    boolean isProfileEmtpy = true;
    PersonalDetails publicPersonalDetails = personalDetailsManager.getPublicPersonalDetails(orcid);
    // Fill personal details
    if (publicPersonalDetails != null) {
        // Get display name
        String displayName = "";
        if (publicPersonalDetails.getName() != null) {
            Name name = publicPersonalDetails.getName();
            if (name.getVisibility().equals(Visibility.PUBLIC)) {
                if (name.getCreditName() != null && !PojoUtil.isEmpty(name.getCreditName().getContent())) {
                    displayName = name.getCreditName().getContent();
                } else {
                    if (name.getGivenNames() != null && !PojoUtil.isEmpty(name.getGivenNames().getContent())) {
                        displayName = name.getGivenNames().getContent() + " ";
                    }
                    if (name.getFamilyName() != null && !PojoUtil.isEmpty(name.getFamilyName().getContent())) {
                        displayName += name.getFamilyName().getContent();
                    }
                }
            }
        }
        if (!PojoUtil.isEmpty(displayName)) {
            // <Published Name> (<ORCID iD>) - ORCID | Connecting Research
            // and Researchers
            mav.addObject("title", getMessage("layout.public-layout.title", displayName.trim(), orcid));
            mav.addObject("displayName", displayName);
        }
        // Get biography
        if (publicPersonalDetails.getBiography() != null) {
            Biography bio = publicPersonalDetails.getBiography();
            if (Visibility.PUBLIC.equals(bio.getVisibility()) && !PojoUtil.isEmpty(bio.getContent())) {
                isProfileEmtpy = false;
                mav.addObject("biography", bio);
            }
        }
        // Fill other names
        OtherNames publicOtherNames = publicPersonalDetails.getOtherNames();
        if (publicOtherNames != null && publicOtherNames.getOtherNames() != null) {
            Iterator<OtherName> it = publicOtherNames.getOtherNames().iterator();
            while (it.hasNext()) {
                OtherName otherName = it.next();
                if (!Visibility.PUBLIC.equals(otherName.getVisibility())) {
                    it.remove();
                }
            }
        }
        Map<String, List<OtherName>> groupedOtherNames = groupOtherNames(publicOtherNames);
        mav.addObject("publicGroupedOtherNames", groupedOtherNames);
    }
    // Fill biography elements
    // Fill country
    Addresses publicAddresses = addressManager.getPublicAddresses(orcid);
    Map<String, String> countryNames = new HashMap<String, String>();
    if (publicAddresses != null && publicAddresses.getAddress() != null) {
        Address publicAddress = null;
        // The primary address will be the one with the lowest display index
        for (Address address : publicAddresses.getAddress()) {
            countryNames.put(address.getCountry().getValue().value(), getcountryName(address.getCountry().getValue().value()));
            if (publicAddress == null) {
                publicAddress = address;
            }
        }
        if (publicAddress != null) {
            mav.addObject("publicAddress", publicAddress);
            mav.addObject("countryNames", countryNames);
            Map<String, List<Address>> groupedAddresses = groupAddresses(publicAddresses);
            mav.addObject("publicGroupedAddresses", groupedAddresses);
        }
    }
    // Fill keywords
    Keywords publicKeywords = keywordManager.getPublicKeywords(orcid);
    Map<String, List<Keyword>> groupedKeywords = groupKeywords(publicKeywords);
    mav.addObject("publicGroupedKeywords", groupedKeywords);
    // Fill researcher urls
    ResearcherUrls publicResearcherUrls = researcherUrlManager.getPublicResearcherUrls(orcid);
    Map<String, List<ResearcherUrl>> groupedResearcherUrls = groupResearcherUrls(publicResearcherUrls);
    mav.addObject("publicGroupedResearcherUrls", groupedResearcherUrls);
    // Fill emails
    Emails publicEmails = emailManager.getPublicEmails(orcid);
    Map<String, List<Email>> groupedEmails = groupEmails(publicEmails);
    mav.addObject("publicGroupedEmails", groupedEmails);
    // Fill external identifiers
    PersonExternalIdentifiers publicPersonExternalIdentifiers = externalIdentifierManager.getPublicExternalIdentifiers(orcid);
    Map<String, List<PersonExternalIdentifier>> groupedExternalIdentifiers = groupExternalIdentifiers(publicPersonExternalIdentifiers);
    mav.addObject("publicGroupedPersonExternalIdentifiers", groupedExternalIdentifiers);
    LinkedHashMap<Long, Affiliation> affiliationMap = new LinkedHashMap<>();
    LinkedHashMap<Long, Funding> fundingMap = new LinkedHashMap<>();
    LinkedHashMap<Long, PeerReview> peerReviewMap = new LinkedHashMap<>();
    if (worksPaginator.getPublicWorksCount(orcid) > 0) {
        isProfileEmtpy = false;
    }
    affiliationMap = activityManager.affiliationMap(orcid);
    if (affiliationMap.size() > 0) {
        isProfileEmtpy = false;
    } else {
        mav.addObject("affiliationsEmpty", true);
    }
    fundingMap = activityManager.fundingMap(orcid);
    if (fundingMap.size() > 0)
        isProfileEmtpy = false;
    else {
        mav.addObject("fundingEmpty", true);
    }
    peerReviewMap = activityManager.pubPeerReviewsMap(orcid);
    if (peerReviewMap.size() > 0) {
        isProfileEmtpy = false;
    } else {
        mav.addObject("peerReviewsEmpty", true);
    }
    ObjectMapper mapper = new ObjectMapper();
    try {
        String affiliationIdsJson = mapper.writeValueAsString(affiliationMap.keySet());
        String fundingIdsJson = mapper.writeValueAsString(fundingMap.keySet());
        String peerReviewIdsJson = mapper.writeValueAsString(peerReviewMap.keySet());
        mav.addObject("affiliationIdsJson", StringEscapeUtils.escapeEcmaScript(affiliationIdsJson));
        mav.addObject("fundingIdsJson", StringEscapeUtils.escapeEcmaScript(fundingIdsJson));
        mav.addObject("peerReviewIdsJson", StringEscapeUtils.escapeEcmaScript(peerReviewIdsJson));
        mav.addObject("isProfileEmpty", isProfileEmtpy);
    } catch (JsonGenerationException e) {
        e.printStackTrace();
    } catch (JsonMappingException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    if (!profile.isReviewed()) {
        if (isProfileValidForIndex(profile)) {
            int countTokens = orcidOauth2TokenService.findCountByUserName(orcid, lastModifiedTime);
            if (!profile.isAccountNonLocked() || countTokens == 0 || (!CreationMethod.WEBSITE.value().equals(profile.getCreationMethod()) && !CreationMethod.DIRECT.value().equals(profile.getCreationMethod()))) {
                mav.addObject("noIndex", true);
            }
        } else {
            mav.addObject("noIndex", true);
        }
    }
    return mav;
}
Also used : Keywords(org.orcid.jaxb.model.v3.dev1.record.Keywords) Address(org.orcid.jaxb.model.v3.dev1.record.Address) OtherNames(org.orcid.jaxb.model.v3.dev1.record.OtherNames) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Funding(org.orcid.jaxb.model.v3.dev1.record.Funding) ModelAndView(org.springframework.web.servlet.ModelAndView) DeactivatedException(org.orcid.core.exception.DeactivatedException) OtherName(org.orcid.jaxb.model.v3.dev1.record.OtherName) Name(org.orcid.jaxb.model.v3.dev1.record.Name) LinkedHashMap(java.util.LinkedHashMap) Addresses(org.orcid.jaxb.model.v3.dev1.record.Addresses) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) Biography(org.orcid.jaxb.model.v3.dev1.record.Biography) ResearcherUrls(org.orcid.jaxb.model.v3.dev1.record.ResearcherUrls) List(java.util.List) ArrayList(java.util.ArrayList) Emails(org.orcid.jaxb.model.v3.dev1.record.Emails) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Affiliation(org.orcid.jaxb.model.v3.dev1.record.Affiliation) LockedException(org.orcid.core.security.aop.LockedException) OtherName(org.orcid.jaxb.model.v3.dev1.record.OtherName) IOException(java.io.IOException) PersonalDetails(org.orcid.jaxb.model.v3.dev1.record.PersonalDetails) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) OrcidNotClaimedException(org.orcid.core.exception.OrcidNotClaimedException) OrcidDeprecatedException(org.orcid.core.exception.OrcidDeprecatedException) LockedException(org.orcid.core.security.aop.LockedException) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) JsonGenerationException(com.fasterxml.jackson.core.JsonGenerationException) IOException(java.io.IOException) DeactivatedException(org.orcid.core.exception.DeactivatedException) PersonExternalIdentifiers(org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifiers) OrcidDeprecatedException(org.orcid.core.exception.OrcidDeprecatedException) OrcidNotClaimedException(org.orcid.core.exception.OrcidNotClaimedException) JsonGenerationException(com.fasterxml.jackson.core.JsonGenerationException) PeerReview(org.orcid.jaxb.model.v3.dev1.record.PeerReview) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 8 with ResearcherUrls

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

the class PublicV3ApiServiceDelegatorTest method testViewResearcherUrls.

@Test
public void testViewResearcherUrls() {
    Response response = serviceDelegator.viewResearcherUrls(ORCID);
    assertNotNull(response);
    ResearcherUrls rUrls = (ResearcherUrls) response.getEntity();
    assertNotNull(rUrls);
    assertNotNull(rUrls.getLastModifiedDate());
    assertNotNull(rUrls.getLastModifiedDate().getValue());
    assertEquals("/0000-0000-0000-0003/researcher-urls", rUrls.getPath());
    assertEquals(1, rUrls.getResearcherUrls().size());
    ResearcherUrl rUrl = rUrls.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());
}
Also used : Response(javax.ws.rs.core.Response) ResearcherUrls(org.orcid.jaxb.model.v3.dev1.record.ResearcherUrls) ResearcherUrl(org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 9 with ResearcherUrls

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

the class PublicAPISecurityManagerV3Test method filterResearcherUrlsTest.

@Test
public void filterResearcherUrlsTest() {
    ResearcherUrls x = getResearcherUrlsElement(Visibility.PUBLIC, Visibility.PUBLIC, Visibility.PUBLIC);
    assertEquals(3, x.getResearcherUrls().size());
    publicAPISecurityManagerV3.filter(x);
    assertEquals(3, x.getResearcherUrls().size());
    assertAllArePublic(x.getResearcherUrls());
    x = getResearcherUrlsElement(Visibility.PUBLIC, Visibility.PUBLIC, Visibility.LIMITED);
    assertEquals(3, x.getResearcherUrls().size());
    publicAPISecurityManagerV3.filter(x);
    assertEquals(2, x.getResearcherUrls().size());
    assertAllArePublic(x.getResearcherUrls());
    x = getResearcherUrlsElement(Visibility.PUBLIC, Visibility.LIMITED, Visibility.PRIVATE);
    assertEquals(3, x.getResearcherUrls().size());
    publicAPISecurityManagerV3.filter(x);
    assertEquals(1, x.getResearcherUrls().size());
    assertAllArePublic(x.getResearcherUrls());
    x = getResearcherUrlsElement(Visibility.PRIVATE, Visibility.LIMITED, Visibility.PRIVATE);
    assertEquals(3, x.getResearcherUrls().size());
    publicAPISecurityManagerV3.filter(x);
    assertTrue(x.getResearcherUrls().isEmpty());
}
Also used : ResearcherUrls(org.orcid.jaxb.model.v3.dev1.record.ResearcherUrls) Test(org.junit.Test)

Example 10 with ResearcherUrls

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

the class PersonDetailsManagerReadOnlyImpl method getPublicPersonDetails.

@Override
public Person getPublicPersonDetails(String orcid) {
    long lastModifiedTime = getLastModified(orcid);
    Person person = new Person();
    Name name = recordNameManager.getRecordName(orcid);
    if (Visibility.PUBLIC.equals(name.getVisibility())) {
        person.setName(name);
    }
    Biography bio = biographyManager.getPublicBiography(orcid);
    if (bio != null) {
        person.setBiography(bio);
    }
    Addresses addresses = addressManager.getPublicAddresses(orcid);
    if (addresses.getAddress() != null) {
        Addresses filteredAddresses = new Addresses();
        filteredAddresses.setAddress(new ArrayList<Address>(addresses.getAddress()));
        person.setAddresses(filteredAddresses);
    }
    PersonExternalIdentifiers extIds = externalIdentifierManager.getPublicExternalIdentifiers(orcid);
    if (extIds.getExternalIdentifiers() != null) {
        PersonExternalIdentifiers filteredExtIds = new PersonExternalIdentifiers();
        filteredExtIds.setExternalIdentifiers(new ArrayList<PersonExternalIdentifier>(extIds.getExternalIdentifiers()));
        person.setExternalIdentifiers(filteredExtIds);
    }
    Keywords keywords = profileKeywordManager.getPublicKeywords(orcid);
    if (keywords.getKeywords() != null) {
        Keywords filteredKeywords = new Keywords();
        filteredKeywords.setKeywords(new ArrayList<Keyword>(keywords.getKeywords()));
        person.setKeywords(filteredKeywords);
    }
    OtherNames otherNames = otherNameManager.getPublicOtherNames(orcid);
    if (otherNames.getOtherNames() != null) {
        OtherNames filteredOtherNames = new OtherNames();
        filteredOtherNames.setOtherNames(new ArrayList<OtherName>(otherNames.getOtherNames()));
        person.setOtherNames(filteredOtherNames);
    }
    ResearcherUrls rUrls = researcherUrlManager.getPublicResearcherUrls(orcid);
    if (rUrls.getResearcherUrls() != null) {
        ResearcherUrls filteredRUrls = new ResearcherUrls();
        filteredRUrls.setResearcherUrls(new ArrayList<ResearcherUrl>(rUrls.getResearcherUrls()));
        person.setResearcherUrls(filteredRUrls);
    }
    Emails emails = emailManager.getPublicEmails(orcid);
    if (emails.getEmails() != null) {
        Emails filteredEmails = new Emails();
        filteredEmails.setEmails(new ArrayList<Email>(emails.getEmails()));
        person.setEmails(filteredEmails);
    }
    return person;
}
Also used : Keywords(org.orcid.jaxb.model.v3.dev1.record.Keywords) Email(org.orcid.jaxb.model.v3.dev1.record.Email) Address(org.orcid.jaxb.model.v3.dev1.record.Address) Keyword(org.orcid.jaxb.model.v3.dev1.record.Keyword) OtherNames(org.orcid.jaxb.model.v3.dev1.record.OtherNames) OtherName(org.orcid.jaxb.model.v3.dev1.record.OtherName) PersonExternalIdentifier(org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier) OtherName(org.orcid.jaxb.model.v3.dev1.record.OtherName) Name(org.orcid.jaxb.model.v3.dev1.record.Name) Addresses(org.orcid.jaxb.model.v3.dev1.record.Addresses) PersonExternalIdentifiers(org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifiers) Biography(org.orcid.jaxb.model.v3.dev1.record.Biography) ResearcherUrls(org.orcid.jaxb.model.v3.dev1.record.ResearcherUrls) ResearcherUrl(org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl) Emails(org.orcid.jaxb.model.v3.dev1.record.Emails) Person(org.orcid.jaxb.model.v3.dev1.record.Person)

Aggregations

ResearcherUrls (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrls)52 ResearcherUrl (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl)44 Test (org.junit.Test)38 OtherNames (org.orcid.jaxb.model.v3.dev1.record.OtherNames)34 Addresses (org.orcid.jaxb.model.v3.dev1.record.Addresses)33 Keywords (org.orcid.jaxb.model.v3.dev1.record.Keywords)33 PersonExternalIdentifiers (org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifiers)33 Biography (org.orcid.jaxb.model.v3.dev1.record.Biography)32 Address (org.orcid.jaxb.model.v3.dev1.record.Address)31 Emails (org.orcid.jaxb.model.v3.dev1.record.Emails)31 Email (org.orcid.jaxb.model.v3.dev1.record.Email)30 Keyword (org.orcid.jaxb.model.v3.dev1.record.Keyword)30 OtherName (org.orcid.jaxb.model.v3.dev1.record.OtherName)30 PersonExternalIdentifier (org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier)30 Name (org.orcid.jaxb.model.v3.dev1.record.Name)26 Person (org.orcid.jaxb.model.v3.dev1.record.Person)25 Record (org.orcid.jaxb.model.v3.dev1.record.Record)13 DistinctionSummary (org.orcid.jaxb.model.v3.dev1.record.summary.DistinctionSummary)13 EducationSummary (org.orcid.jaxb.model.v3.dev1.record.summary.EducationSummary)13 EmploymentSummary (org.orcid.jaxb.model.v3.dev1.record.summary.EmploymentSummary)13