Search in sources :

Example 51 with OrcidBio

use of org.orcid.jaxb.model.message.OrcidBio in project ORCID-Source by ORCID.

the class T2OrcidApiServiceDelegatorTest method testAddDuplicatedExtIdsDontModifyProfile.

@Test
public void testAddDuplicatedExtIdsDontModifyProfile() {
    String userOrcid = "0000-0000-0000-0005";
    OrcidMessage message = new OrcidMessage();
    message.setMessageVersion("1.2_rc6");
    message.setOrcidProfile(new OrcidProfile());
    message.getOrcidProfile().setOrcidBio(new OrcidBio());
    ExternalIdentifiers extIds = new ExternalIdentifiers();
    ExternalIdentifier extId1 = new ExternalIdentifier();
    String commonName = "common-name-1-" + System.currentTimeMillis();
    extId1.setExternalIdCommonName(new ExternalIdCommonName(commonName));
    extId1.setExternalIdReference(new ExternalIdReference("ext-id-reference-1"));
    extId1.setExternalIdUrl(new ExternalIdUrl("http://test.orcid.org/" + System.currentTimeMillis()));
    extIds.getExternalIdentifier().add(extId1);
    message.getOrcidProfile().getOrcidBio().setExternalIdentifiers(extIds);
    // Add for client 1
    SecurityContextTestUtils.setUpSecurityContext(userOrcid, "APP-5555555555555555", ScopePathType.PERSON_UPDATE, ScopePathType.PERSON_READ_LIMITED);
    Response r = t2OrcidApiServiceDelegator.addExternalIdentifiers(null, userOrcid, message);
    assertNotNull(r);
    OrcidMessage newMessage1 = (OrcidMessage) r.getEntity();
    assertNotNull(newMessage1);
    assertNotNull(newMessage1.getOrcidProfile());
    assertNotNull(newMessage1.getOrcidProfile().getOrcidBio());
    assertNotNull(newMessage1.getOrcidProfile().getOrcidBio().getExternalIdentifiers());
    assertNotNull(newMessage1.getOrcidProfile().getOrcidBio().getExternalIdentifiers().getExternalIdentifier());
    assertEquals(1, newMessage1.getOrcidProfile().getOrcidBio().getExternalIdentifiers().getExternalIdentifier().size());
    assertEquals(commonName, newMessage1.getOrcidProfile().getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).getExternalIdCommonName().getContent());
    assertEquals("APP-5555555555555555", newMessage1.getOrcidProfile().getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).getSource().retrieveSourcePath());
    // Reset message to add it again
    message = new OrcidMessage();
    message.setMessageVersion("1.2_rc6");
    message.setOrcidProfile(new OrcidProfile());
    message.getOrcidProfile().setOrcidBio(new OrcidBio());
    extId1.setSource(null);
    message.getOrcidProfile().getOrcidBio().setExternalIdentifiers(extIds);
    r = t2OrcidApiServiceDelegator.addExternalIdentifiers(null, userOrcid, message);
    // If we add it again, no error, but it is not duplicated
    assertNotNull(r);
    OrcidMessage newMessage2 = (OrcidMessage) r.getEntity();
    assertNotNull(newMessage2);
    assertNotNull(newMessage2.getOrcidProfile());
    assertNotNull(newMessage2.getOrcidProfile().getOrcidBio());
    assertNotNull(newMessage2.getOrcidProfile().getOrcidBio().getExternalIdentifiers());
    assertNotNull(newMessage2.getOrcidProfile().getOrcidBio().getExternalIdentifiers().getExternalIdentifier());
    assertEquals(1, newMessage2.getOrcidProfile().getOrcidBio().getExternalIdentifiers().getExternalIdentifier().size());
    assertEquals(commonName, newMessage2.getOrcidProfile().getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).getExternalIdCommonName().getContent());
    assertEquals("APP-5555555555555555", newMessage2.getOrcidProfile().getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).getSource().retrieveSourcePath());
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) Response(javax.ws.rs.core.Response) ExternalIdCommonName(org.orcid.jaxb.model.message.ExternalIdCommonName) OrcidBio(org.orcid.jaxb.model.message.OrcidBio) ExternalIdReference(org.orcid.jaxb.model.message.ExternalIdReference) WorkExternalIdentifier(org.orcid.jaxb.model.message.WorkExternalIdentifier) ExternalIdentifier(org.orcid.jaxb.model.message.ExternalIdentifier) FundingExternalIdentifier(org.orcid.jaxb.model.message.FundingExternalIdentifier) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) WorkExternalIdentifiers(org.orcid.jaxb.model.message.WorkExternalIdentifiers) FundingExternalIdentifiers(org.orcid.jaxb.model.message.FundingExternalIdentifiers) ExternalIdentifiers(org.orcid.jaxb.model.message.ExternalIdentifiers) ExternalIdUrl(org.orcid.jaxb.model.message.ExternalIdUrl) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 52 with OrcidBio

use of org.orcid.jaxb.model.message.OrcidBio in project ORCID-Source by ORCID.

the class OrcidProfileManagerImpl method deactivateOrcidProfile.

@Override
@Transactional
@Deprecated
public OrcidProfile deactivateOrcidProfile(OrcidProfile existingOrcidProfile) {
    OrcidProfile blankedOrcidProfile = new OrcidProfile();
    OrcidBio existingBio = existingOrcidProfile.getOrcidBio();
    OrcidBio minimalBio = new OrcidBio();
    ContactDetails minimalContactDetails = new ContactDetails();
    minimalContactDetails.getEmail().addAll(existingBio.getContactDetails().getEmail());
    OrcidInternal minimalOrcidInternal = new OrcidInternal();
    minimalOrcidInternal.setSecurityDetails(existingOrcidProfile.getOrcidInternal().getSecurityDetails());
    OrcidHistory deactivatedOrcidHistory = existingOrcidProfile.getOrcidHistory();
    deactivatedOrcidHistory.setDeactivationDate(new DeactivationDate(DateUtils.convertToXMLGregorianCalendar(new Date())));
    blankedOrcidProfile.setOrcidHistory(deactivatedOrcidHistory);
    // only names names from bio with a visibility setting
    PersonalDetails minimalPersonalDetails = new PersonalDetails();
    minimalPersonalDetails.setOtherNames(null);
    CreditName creditName = new CreditName();
    creditName.setVisibility(Visibility.PUBLIC);
    minimalPersonalDetails.setCreditName(creditName);
    minimalPersonalDetails.setGivenNames(new GivenNames("Given Names Deactivated"));
    minimalPersonalDetails.setFamilyName(new FamilyName("Family Name Deactivated"));
    for (Email email : minimalContactDetails.getEmail()) {
        setVisibilityToPrivate(email);
    }
    setVisibilityToPrivate(minimalPersonalDetails.getOtherNames());
    if (minimalPersonalDetails.getOtherNames() != null && minimalPersonalDetails.getOtherNames().getOtherName() != null) {
        for (OtherName name : minimalPersonalDetails.getOtherNames().getOtherName()) setVisibilityToPrivate(name);
    }
    minimalBio.setPersonalDetails(minimalPersonalDetails);
    minimalBio.setContactDetails(minimalContactDetails);
    minimalBio.setBiography(new Biography());
    minimalBio.setExternalIdentifiers(new ExternalIdentifiers());
    blankedOrcidProfile.setOrcidBio(minimalBio);
    blankedOrcidProfile.setOrcidIdentifier(existingOrcidProfile.getOrcidIdentifier().getPath());
    OrcidProfile profileToReturn = updateOrcidProfile(blankedOrcidProfile);
    userConnectionDao.deleteByOrcid(existingOrcidProfile.getOrcidIdentifier().getPath());
    notificationManager.sendAmendEmail(profileToReturn, AmendedSection.UNKNOWN);
    return profileToReturn;
}
Also used : Email(org.orcid.jaxb.model.message.Email) OrcidBio(org.orcid.jaxb.model.message.OrcidBio) FamilyName(org.orcid.jaxb.model.message.FamilyName) OrcidInternal(org.orcid.jaxb.model.message.OrcidInternal) CreditName(org.orcid.jaxb.model.message.CreditName) OtherName(org.orcid.jaxb.model.message.OtherName) PersonalDetails(org.orcid.jaxb.model.message.PersonalDetails) DeactivationDate(org.orcid.jaxb.model.message.DeactivationDate) Date(java.util.Date) DeactivationDate(org.orcid.jaxb.model.message.DeactivationDate) OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) ContactDetails(org.orcid.jaxb.model.message.ContactDetails) OrcidHistory(org.orcid.jaxb.model.message.OrcidHistory) GivenNames(org.orcid.jaxb.model.message.GivenNames) Biography(org.orcid.jaxb.model.message.Biography) ExternalIdentifiers(org.orcid.jaxb.model.message.ExternalIdentifiers) Transactional(org.springframework.transaction.annotation.Transactional)

Example 53 with OrcidBio

use of org.orcid.jaxb.model.message.OrcidBio in project ORCID-Source by ORCID.

the class OrcidProfileManagerReadOnlyImpl method createReservedForClaimOrcidProfile.

protected OrcidProfile createReservedForClaimOrcidProfile(String orcid, OrcidDeprecated deprecatedInfo, LastModifiedDate lastModifiedDate) {
    OrcidProfile op = new OrcidProfile();
    if (jpaJaxbAdapter != null) {
        op.setOrcidIdentifier(new OrcidIdentifier(jpaJaxbAdapter.getOrcidIdBase(orcid)));
    } else {
        op.setOrcidIdentifier(orcid);
    }
    if (deprecatedInfo != null)
        op.setOrcidDeprecated(deprecatedInfo);
    OrcidHistory oh = new OrcidHistory();
    oh.setClaimed(new Claimed(false));
    oh.setLastModifiedDate(lastModifiedDate);
    op.setOrcidHistory(oh);
    GivenNames gn = new GivenNames();
    PersonalDetails pd = new PersonalDetails();
    gn.setContent(localeManager.resolveMessage("orcid.reserved_for_claim"));
    gn.setVisibility(OrcidVisibilityDefaults.NAMES_DEFAULT.getVisibility());
    pd.setGivenNames(gn);
    OrcidBio ob = new OrcidBio();
    ob.setPersonalDetails(pd);
    op.setOrcidBio(ob);
    return op;
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) OrcidBio(org.orcid.jaxb.model.message.OrcidBio) OrcidIdentifier(org.orcid.jaxb.model.message.OrcidIdentifier) OrcidHistory(org.orcid.jaxb.model.message.OrcidHistory) GivenNames(org.orcid.jaxb.model.message.GivenNames) PersonalDetails(org.orcid.jaxb.model.message.PersonalDetails) Claimed(org.orcid.jaxb.model.message.Claimed)

Example 54 with OrcidBio

use of org.orcid.jaxb.model.message.OrcidBio in project ORCID-Source by ORCID.

the class OrcidMessageUtil method setSourceName.

public void setSourceName(OrcidProfile orcidProfile) {
    if (orcidProfile != null) {
        if (orcidProfile.getOrcidActivities() != null) {
            OrcidActivities orcidActivities = orcidProfile.getOrcidActivities();
            if (orcidActivities.getAffiliations() != null) {
                Affiliations affs = orcidActivities.getAffiliations();
                List<Affiliation> affList = affs.getAffiliation();
                if (affList != null) {
                    for (Affiliation aff : affList) {
                        setSourceName(aff);
                    }
                }
            }
            if (orcidActivities.getFundings() != null) {
                FundingList fundingList = orcidActivities.getFundings();
                List<Funding> fundings = fundingList.getFundings();
                if (fundings != null) {
                    for (Funding funding : fundings) {
                        setSourceName(funding);
                    }
                }
            }
            if (orcidActivities.getOrcidWorks() != null) {
                OrcidWorks orcidWorks = orcidActivities.getOrcidWorks();
                List<OrcidWork> works = orcidWorks.getOrcidWork();
                if (works != null) {
                    for (OrcidWork work : works) {
                        setSourceName(work);
                    }
                }
            }
        }
        if (orcidProfile.getOrcidBio() != null) {
            OrcidBio orcidBio = orcidProfile.getOrcidBio();
            if (orcidBio.getContactDetails() != null) {
                Address address = orcidBio.getContactDetails().getAddress();
                if (address != null) {
                    setSourceName(address);
                }
            }
            if (orcidBio.getExternalIdentifiers() != null) {
                ExternalIdentifiers extIds = orcidBio.getExternalIdentifiers();
                List<ExternalIdentifier> extIdsList = extIds.getExternalIdentifier();
                if (extIdsList != null) {
                    for (ExternalIdentifier extId : extIdsList) {
                        setSourceName(extId);
                    }
                }
            }
            if (orcidBio.getKeywords() != null) {
                Keywords keywords = orcidBio.getKeywords();
                List<Keyword> keywordList = keywords.getKeyword();
                if (keywordList != null) {
                    for (Keyword keyword : keywordList) {
                        setSourceName(keyword);
                    }
                }
            }
            if (orcidBio.getPersonalDetails() != null) {
                OtherNames otherNames = orcidBio.getPersonalDetails().getOtherNames();
                if (otherNames != null) {
                    List<OtherName> otherNameList = otherNames.getOtherName();
                    if (otherNameList != null) {
                        for (OtherName otherName : otherNameList) {
                            setSourceName(otherName);
                        }
                    }
                }
            }
            if (orcidBio.getResearcherUrls() != null) {
                ResearcherUrls rUrls = orcidBio.getResearcherUrls();
                List<ResearcherUrl> rUrlList = rUrls.getResearcherUrl();
                if (rUrlList != null) {
                    for (ResearcherUrl rUrl : rUrlList) {
                        setSourceName(rUrl);
                    }
                }
            }
        }
    }
}
Also used : Keywords(org.orcid.jaxb.model.message.Keywords) OrcidBio(org.orcid.jaxb.model.message.OrcidBio) Address(org.orcid.jaxb.model.message.Address) Keyword(org.orcid.jaxb.model.message.Keyword) Funding(org.orcid.jaxb.model.message.Funding) ExternalIdentifier(org.orcid.jaxb.model.message.ExternalIdentifier) OtherNames(org.orcid.jaxb.model.message.OtherNames) OrcidWork(org.orcid.jaxb.model.message.OrcidWork) OtherName(org.orcid.jaxb.model.message.OtherName) OrcidActivities(org.orcid.jaxb.model.message.OrcidActivities) OrcidWorks(org.orcid.jaxb.model.message.OrcidWorks) FundingList(org.orcid.jaxb.model.message.FundingList) Affiliations(org.orcid.jaxb.model.message.Affiliations) ResearcherUrls(org.orcid.jaxb.model.message.ResearcherUrls) ResearcherUrl(org.orcid.jaxb.model.message.ResearcherUrl) ExternalIdentifiers(org.orcid.jaxb.model.message.ExternalIdentifiers) Affiliation(org.orcid.jaxb.model.message.Affiliation)

Example 55 with OrcidBio

use of org.orcid.jaxb.model.message.OrcidBio in project ORCID-Source by ORCID.

the class EmailsTest method updateEmailsUsingAlreadyExistingEmailTest.

/**
     * Test update email using already existing email
     * */
@Test
public void updateEmailsUsingAlreadyExistingEmailTest() throws JSONException, InterruptedException {
    String clientId = getClient1ClientId();
    String clientRedirectUri = getClient1RedirectUri();
    String clientSecret = getClient1ClientSecret();
    String userId = getUser1OrcidId();
    String password = getUser1Password();
    String user2Email = getUser2UserName();
    String accessToken = getAccessToken(userId, password, Arrays.asList("/orcid-bio/update"), clientId, clientSecret, clientRedirectUri, true);
    //Email already used by 9999-9999-9999-9990
    ContactDetails contactDetails = new ContactDetails();
    contactDetails.getEmail().add(new Email(user2Email));
    OrcidBio orcidBio = new OrcidBio();
    orcidBio.setContactDetails(contactDetails);
    OrcidProfile orcidProfile = new OrcidProfile();
    orcidProfile.setType(OrcidType.USER);
    orcidProfile.setOrcidBio(orcidBio);
    OrcidMessage orcidMessage = new OrcidMessage();
    orcidMessage.setMessageVersion("1.2");
    orcidMessage.setOrcidProfile(orcidProfile);
    ClientResponse clientResponse = t2OAuthClient_1_2.updateBioDetailsXml(userId, orcidMessage, accessToken);
    assertEquals(400, clientResponse.getStatus());
    OrcidMessage errorMessage = clientResponse.getEntity(OrcidMessage.class);
    assertNotNull(errorMessage);
    assertNotNull(errorMessage.getErrorDesc());
    assertEquals("Bad Request: Invalid incoming message: Email " + user2Email + " belongs to other user", errorMessage.getErrorDesc().getContent());
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) ClientResponse(com.sun.jersey.api.client.ClientResponse) Email(org.orcid.jaxb.model.message.Email) ContactDetails(org.orcid.jaxb.model.message.ContactDetails) OrcidBio(org.orcid.jaxb.model.message.OrcidBio) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) Test(org.junit.Test)

Aggregations

OrcidBio (org.orcid.jaxb.model.message.OrcidBio)56 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)38 PersonalDetails (org.orcid.jaxb.model.message.PersonalDetails)28 Test (org.junit.Test)27 ContactDetails (org.orcid.jaxb.model.message.ContactDetails)23 Email (org.orcid.jaxb.model.message.Email)20 GivenNames (org.orcid.jaxb.model.message.GivenNames)20 OrcidMessage (org.orcid.jaxb.model.message.OrcidMessage)19 ExternalIdentifiers (org.orcid.jaxb.model.message.ExternalIdentifiers)16 FamilyName (org.orcid.jaxb.model.message.FamilyName)16 ExternalIdentifier (org.orcid.jaxb.model.message.ExternalIdentifier)15 CreditName (org.orcid.jaxb.model.message.CreditName)14 BaseTest (org.orcid.core.BaseTest)13 ExternalIdReference (org.orcid.jaxb.model.message.ExternalIdReference)11 WorkExternalIdentifier (org.orcid.jaxb.model.message.WorkExternalIdentifier)11 OrcidHistory (org.orcid.jaxb.model.message.OrcidHistory)10 ExternalIdCommonName (org.orcid.jaxb.model.message.ExternalIdCommonName)9 OtherNames (org.orcid.jaxb.model.message.OtherNames)9 Biography (org.orcid.jaxb.model.message.Biography)8 Keyword (org.orcid.jaxb.model.message.Keyword)8