diff --git a/orcid-api-web/src/main/java/org/orcid/api/memberV3/server/delegator/impl/MemberV3ApiServiceDelegatorImpl.java b/orcid-api-web/src/main/java/org/orcid/api/memberV3/server/delegator/impl/MemberV3ApiServiceDelegatorImpl.java index d73eb5bcb1..5df29f5eed 100644 --- a/orcid-api-web/src/main/java/org/orcid/api/memberV3/server/delegator/impl/MemberV3ApiServiceDelegatorImpl.java +++ b/orcid-api-web/src/main/java/org/orcid/api/memberV3/server/delegator/impl/MemberV3ApiServiceDelegatorImpl.java @@ -886,7 +886,7 @@ public Response viewEmails(String orcid) { orcidSecurityManager.checkAndFilter(orcid, emails.getEmails(), ScopePathType.ORCID_BIO_READ_LIMITED); } - processProfessionalEmails(emails); + emailDomainManager.processProfessionalEmailsForV3API(emails); ElementUtils.setPathToEmail(emails, orcid); Api3_0LastModifiedDatesHelper.calculateLastModified(emails); @@ -1166,6 +1166,7 @@ public Response viewPerson(String orcid) { checkProfileStatus(orcid, true); Person person = personDetailsManagerReadOnly.getPersonDetails(orcid, false); orcidSecurityManager.checkAndFilter(orcid, person); + emailDomainManager.processProfessionalEmailsForV3API(person.getEmails()); ElementUtils.setPathToPerson(person, orcid); Api3_0LastModifiedDatesHelper.calculateLastModified(person); sourceUtils.setSourceName(person); @@ -1228,23 +1229,6 @@ private void validateSearchParams(Map> queryMap) { } } - private void processProfessionalEmails(Emails emails) { - for (Email email : emails.getEmails()) { - if (email.isVerified()) { - String domain = email.getEmail().split("@")[1]; - List domainInfos = emailDomainManager.findByEmailDomain(domain); - // Set appropriate source name and source id for professional emails - for(EmailDomainEntity domainInfo: domainInfos) { - if (domainInfo != null && domainInfo.getCategory().equals(EmailDomainEntity.DomainCategory.PROFESSIONAL)) { - email.setSource(sourceEntityUtils.convertEmailSourceToOrcidValidator(email.getSource())); - break; - } - } - - } - } - } - @Override public Response viewClient(String clientId) { orcidSecurityManager.checkScopes(ScopePathType.READ_PUBLIC); diff --git a/orcid-api-web/src/test/java/org/orcid/api/memberV2/server/delegator/MemberV2ApiServiceDelegator_EmailsTest.java b/orcid-api-web/src/test/java/org/orcid/api/memberV2/server/delegator/MemberV2ApiServiceDelegator_EmailsTest.java index 8823b33602..480892d05d 100644 --- a/orcid-api-web/src/test/java/org/orcid/api/memberV2/server/delegator/MemberV2ApiServiceDelegator_EmailsTest.java +++ b/orcid-api-web/src/test/java/org/orcid/api/memberV2/server/delegator/MemberV2ApiServiceDelegator_EmailsTest.java @@ -203,11 +203,11 @@ public void checkSourceOnEmail_EmailEndpointTest() { private void checkEmails(Emails emails) { assertEquals(2, emails.getEmails().size()); for(Email e : emails.getEmails()) { - if(e.getEmail().equals("public_0000-0000-0000-0001@test.orcid.org")) { - assertFalse(e.isVerified()); - // The source and name on non verified professional email addresses should not change - assertEquals("APP-5555555555555555", e.getSource().retrieveSourcePath()); - assertEquals("Source Client 1", e.getSource().getSourceName().getContent()); + if(e.getEmail().equals("limited_verified_0000-0000-0000-0001@test.orcid.org")) { + assertTrue(e.isVerified()); + // The source and name on verified professional email addresses should change + assertEquals("0000-0000-0000-0000", e.getSource().retrieveSourcePath()); + assertEquals("ORCID email validation", e.getSource().getSourceName().getContent()); } else if(e.getEmail().equals("verified_non_professional@nonprofessional.org")) { assertTrue(e.isVerified()); // The source and name on non professional email addresses should not change diff --git a/orcid-api-web/src/test/java/org/orcid/api/memberV2/server/delegator/MemberV2ApiServiceDelegator_ReadPersonTest.java b/orcid-api-web/src/test/java/org/orcid/api/memberV2/server/delegator/MemberV2ApiServiceDelegator_ReadPersonTest.java index a731a6488a..00f70fc0f3 100644 --- a/orcid-api-web/src/test/java/org/orcid/api/memberV2/server/delegator/MemberV2ApiServiceDelegator_ReadPersonTest.java +++ b/orcid-api-web/src/test/java/org/orcid/api/memberV2/server/delegator/MemberV2ApiServiceDelegator_ReadPersonTest.java @@ -633,7 +633,7 @@ private void assertAllPublicButEmails(Person p) { } @Test - public void checkSourceOnEmail_EmailEndpointTest() { + public void checkSourceOnEmail_PersonEndpointTest() { String orcid = "0000-0000-0000-0001"; SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.READ_LIMITED); Response r = serviceDelegator.viewPerson(orcid); @@ -645,11 +645,11 @@ public void checkSourceOnEmail_EmailEndpointTest() { private void checkEmails(Emails emails) { assertEquals(2, emails.getEmails().size()); for(Email e : emails.getEmails()) { - if(e.getEmail().equals("public_0000-0000-0000-0001@test.orcid.org")) { - assertFalse(e.isVerified()); - // The source and name on non verified professional email addresses should not change - assertEquals("APP-5555555555555555", e.getSource().retrieveSourcePath()); - assertEquals("Source Client 1", e.getSource().getSourceName().getContent()); + if(e.getEmail().equals("limited_verified_0000-0000-0000-0001@test.orcid.org")) { + assertTrue(e.isVerified()); + // The source and name on verified professional email addresses should change + assertEquals("0000-0000-0000-0000", e.getSource().retrieveSourcePath()); + assertEquals("ORCID email validation", e.getSource().getSourceName().getContent()); } else if(e.getEmail().equals("verified_non_professional@nonprofessional.org")) { assertTrue(e.isVerified()); // The source and name on non professional email addresses should not change diff --git a/orcid-api-web/src/test/java/org/orcid/api/memberV2/server/delegator/MemberV2ApiServiceDelegator_ReadRecordTest.java b/orcid-api-web/src/test/java/org/orcid/api/memberV2/server/delegator/MemberV2ApiServiceDelegator_ReadRecordTest.java index 60d745cee7..a09cce6c24 100644 --- a/orcid-api-web/src/test/java/org/orcid/api/memberV2/server/delegator/MemberV2ApiServiceDelegator_ReadRecordTest.java +++ b/orcid-api-web/src/test/java/org/orcid/api/memberV2/server/delegator/MemberV2ApiServiceDelegator_ReadRecordTest.java @@ -1157,7 +1157,7 @@ private void assertAllPublicButEmails(Person p) { } @Test - public void checkSourceOnEmail_EmailEndpointTest() { + public void checkSourceOnEmail_RecordEndpointTest() { String orcid = "0000-0000-0000-0001"; SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.READ_LIMITED); Response r = serviceDelegator.viewRecord(orcid); @@ -1170,11 +1170,11 @@ public void checkSourceOnEmail_EmailEndpointTest() { private void checkEmails(Emails emails) { assertEquals(2, emails.getEmails().size()); for(Email e : emails.getEmails()) { - if(e.getEmail().equals("public_0000-0000-0000-0001@test.orcid.org")) { - assertFalse(e.isVerified()); - // The source and name on non verified professional email addresses should not change - assertEquals("APP-5555555555555555", e.getSource().retrieveSourcePath()); - assertEquals("Source Client 1", e.getSource().getSourceName().getContent()); + if(e.getEmail().equals("limited_verified_0000-0000-0000-0001@test.orcid.org")) { + assertTrue(e.isVerified()); + // The source and name on verified professional email addresses should change + assertEquals("0000-0000-0000-0000", e.getSource().retrieveSourcePath()); + assertEquals("ORCID email validation", e.getSource().getSourceName().getContent()); } else if(e.getEmail().equals("verified_non_professional@nonprofessional.org")) { assertTrue(e.isVerified()); // The source and name on non professional email addresses should not change diff --git a/orcid-api-web/src/test/java/org/orcid/api/memberV3/server/delegator/MemberV3ApiServiceDelegator_ReadPersonTest.java b/orcid-api-web/src/test/java/org/orcid/api/memberV3/server/delegator/MemberV3ApiServiceDelegator_ReadPersonTest.java index b24df67910..cf9dcee9c5 100644 --- a/orcid-api-web/src/test/java/org/orcid/api/memberV3/server/delegator/MemberV3ApiServiceDelegator_ReadPersonTest.java +++ b/orcid-api-web/src/test/java/org/orcid/api/memberV3/server/delegator/MemberV3ApiServiceDelegator_ReadPersonTest.java @@ -642,7 +642,7 @@ private void assertAllPublicButEmails(Person p) { @Test public void checkSourceOnEmail_PersonEndpointTest() { String orcid = "0000-0000-0000-0001"; - SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.EMAIL_READ_PRIVATE); + SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.READ_LIMITED); Response r = serviceDelegator.viewPerson(orcid); Person p = (Person) r.getEntity(); assertNotNull(p.getEmails());