From 2e95d8cb4ed8fe1b6a71fad07637fd23674f623c Mon Sep 17 00:00:00 2001 From: amontenegro Date: Thu, 14 Dec 2023 15:56:59 -0600 Subject: [PATCH] Removing multiple togglz --- .../impl/MemberV2ApiServiceDelegatorImpl.java | 15 +--- .../impl/MemberV3ApiServiceDelegatorImpl.java | 17 +---- ...emberV2ApiServiceDelegator_EmailsTest.java | 62 +++------------- ...rV2ApiServiceDelegator_ReadPersonTest.java | 69 +++++------------- ...rV2ApiServiceDelegator_ReadRecordTest.java | 72 ++++++------------ ...emberV3ApiServiceDelegator_EmailsTest.java | 52 ++----------- ...rV3ApiServiceDelegator_ReadPersonTest.java | 73 ++++++------------- ...rV3ApiServiceDelegator_ReadRecordTest.java | 68 +++++------------ .../impl/OrcidGenerationManagerImpl.java | 20 ++--- .../impl/OrgDisambiguatedManagerImpl.java | 4 +- .../impl/EmailManagerReadOnlyImpl.java | 9 +-- .../PersonDetailsManagerReadOnlyImpl.java | 22 ++---- ...GroupingSuggestionManagerReadOnlyImpl.java | 4 - .../impl/RecordManagerReadOnlyImpl.java | 5 +- .../impl/WorkManagerReadOnlyImpl.java | 14 +--- .../openid/OpenIDConnectTokenEnhancer.java | 6 +- .../orcid/core/solr/OrcidSolrOrgsClient.java | 8 +- .../java/org/orcid/core/togglz/Features.java | 39 +--------- .../manager/OrcidGenerationManagerTest.java | 23 ------ .../manager/v3/PersonDetailsManagerTest.java | 17 ++--- .../core/manager/v3/RecordManagerTest.java | 7 +- .../web/controllers/AdminController.java | 5 +- .../web/controllers/BaseController.java | 6 +- .../controllers/PublicRecordController.java | 42 +++++------ 24 files changed, 159 insertions(+), 500 deletions(-) diff --git a/orcid-api-web/src/main/java/org/orcid/api/memberV2/server/delegator/impl/MemberV2ApiServiceDelegatorImpl.java b/orcid-api-web/src/main/java/org/orcid/api/memberV2/server/delegator/impl/MemberV2ApiServiceDelegatorImpl.java index e0cada2eabc..5777518cca2 100644 --- a/orcid-api-web/src/main/java/org/orcid/api/memberV2/server/delegator/impl/MemberV2ApiServiceDelegatorImpl.java +++ b/orcid-api-web/src/main/java/org/orcid/api/memberV2/server/delegator/impl/MemberV2ApiServiceDelegatorImpl.java @@ -14,7 +14,6 @@ import javax.annotation.Resource; import javax.ws.rs.core.Response; -import org.apache.commons.lang3.StringEscapeUtils; import org.orcid.api.common.util.ActivityUtils; import org.orcid.api.common.util.ApiUtils; import org.orcid.api.common.util.ElementUtils; @@ -57,7 +56,6 @@ import org.orcid.core.manager.read_only.RecordManagerReadOnly; import org.orcid.core.manager.read_only.ResearcherUrlManagerReadOnly; import org.orcid.core.manager.read_only.WorkManagerReadOnly; -import org.orcid.core.togglz.Features; import org.orcid.core.utils.ContributorUtils; import org.orcid.core.utils.SourceUtils; import org.orcid.core.version.impl.Api2_0_LastModifiedDatesHelper; @@ -770,23 +768,14 @@ public Response viewEmails(String orcid) { // return all emails if client has /email/read-private scope orcidSecurityManager.checkClientAccessAndScopes(orcid, ScopePathType.EMAIL_READ_PRIVATE); - if (Features.HIDE_UNVERIFIED_EMAILS.isActive()) { - emails = emailManagerReadOnly.getVerifiedEmails(orcid); - } else { - emails = emailManagerReadOnly.getEmails(orcid); - } + emails = emailManagerReadOnly.getVerifiedEmails(orcid); // Lets copy the list so we don't modify the cached collection List filteredList = new ArrayList(emails.getEmails()); emails = new Emails(); emails.setEmails(filteredList); } catch (OrcidAccessControlException e) { - - if (Features.HIDE_UNVERIFIED_EMAILS.isActive()) { - emails = emailManagerReadOnly.getVerifiedEmails(orcid); - } else { - emails = emailManagerReadOnly.getEmails(orcid); - } + emails = emailManagerReadOnly.getVerifiedEmails(orcid); // Lets copy the list so we don't modify the cached collection List filteredList = new ArrayList(emails.getEmails()); 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 566294140d3..ab7091f909d 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 @@ -64,7 +64,6 @@ import org.orcid.core.manager.v3.read_only.ResearchResourceManagerReadOnly; import org.orcid.core.manager.v3.read_only.ResearcherUrlManagerReadOnly; import org.orcid.core.manager.v3.read_only.WorkManagerReadOnly; -import org.orcid.core.togglz.Features; import org.orcid.core.utils.SourceEntityUtils; import org.orcid.core.utils.v3.ContributorUtils; import org.orcid.core.utils.v3.SourceUtils; @@ -855,24 +854,14 @@ public Response viewEmails(String orcid) { try { // return all emails if client has /email/read-private scope orcidSecurityManager.checkClientAccessAndScopes(orcid, ScopePathType.EMAIL_READ_PRIVATE); - - if (Features.HIDE_UNVERIFIED_EMAILS.isActive()) { - emails = emailManagerReadOnly.getVerifiedEmails(orcid); - } else { - emails = emailManagerReadOnly.getEmails(orcid); - } + emails = emailManagerReadOnly.getVerifiedEmails(orcid); // Lets copy the list so we don't modify the cached collection List filteredList = new ArrayList(emails.getEmails()); emails = new Emails(); emails.setEmails(filteredList); } catch (OrcidAccessControlException e) { - - if (Features.HIDE_UNVERIFIED_EMAILS.isActive()) { - emails = emailManagerReadOnly.getVerifiedEmails(orcid); - } else { - emails = emailManagerReadOnly.getEmails(orcid); - } + emails = emailManagerReadOnly.getVerifiedEmails(orcid); // Lets copy the list so we don't modify the cached collection List filteredList = new ArrayList(emails.getEmails()); @@ -1160,7 +1149,7 @@ public Response viewPersonalDetails(String orcid) { @Override public Response viewPerson(String orcid) { checkProfileStatus(orcid, true); - Person person = personDetailsManagerReadOnly.getPersonDetails(orcid, !Features.HIDE_UNVERIFIED_EMAILS.isActive()); + Person person = personDetailsManagerReadOnly.getPersonDetails(orcid, false); orcidSecurityManager.checkAndFilter(orcid, person); ElementUtils.setPathToPerson(person, orcid); Api3_0LastModifiedDatesHelper.calculateLastModified(person); 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 8fe393ceaec..25d8e13026e 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 @@ -1,10 +1,7 @@ package org.orcid.api.memberV2.server.delegator; -import static org.hamcrest.core.AnyOf.anyOf; -import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -14,14 +11,12 @@ import javax.annotation.Resource; import javax.ws.rs.core.Response; -import org.orcid.test.DBUnitTest; -import org.orcid.test.helper.Utils; + import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; import org.orcid.core.exception.OrcidUnauthorizedException; -import org.orcid.core.togglz.Features; import org.orcid.core.utils.SecurityContextTestUtils; import org.orcid.jaxb.model.common_v2.Visibility; import org.orcid.jaxb.model.groupid_v2.GroupIdRecord; @@ -39,7 +34,9 @@ import org.orcid.jaxb.model.record_v2.ResearcherUrl; import org.orcid.jaxb.model.record_v2.Work; import org.orcid.jaxb.model.record_v2.WorkBulk; +import org.orcid.test.DBUnitTest; import org.orcid.test.OrcidJUnit4ClassRunner; +import org.orcid.test.helper.Utils; import org.springframework.test.context.ContextConfiguration; @RunWith(OrcidJUnit4ClassRunner.class) @@ -142,50 +139,13 @@ public void testViewEmails() { assertEquals("/4444-4444-4444-4443/email", emails.getPath()); Utils.verifyLastModified(emails.getLastModifiedDate()); assertNotNull(emails.getEmails()); - - if (Features.HIDE_UNVERIFIED_EMAILS.isActive()) { - assertEquals(1, emails.getEmails().size()); - Email email = emails.getEmails().get(0); - Utils.verifyLastModified(email.getLastModifiedDate()); - assertEquals(email.getEmail(), "teddybass3private@semantico.com"); - assertEquals(Visibility.PRIVATE, email.getVisibility()); - assertEquals("APP-5555555555555555", email.retrieveSourcePath()); - assertEquals(true, email.isVerified()); - assertEquals(false, email.isPrimary()); - } else { - assertEquals(3, emails.getEmails().size()); - for (Email email : emails.getEmails()) { - Utils.verifyLastModified(email.getLastModifiedDate()); - assertThat(email.getEmail(), anyOf(is("teddybass2@semantico.com"), is("teddybass3public@semantico.com"), is("teddybass3private@semantico.com"))); - switch (email.getEmail()) { - case "teddybass2@semantico.com": - assertEquals(Visibility.LIMITED, email.getVisibility()); - assertEquals("4444-4444-4444-4443", email.retrieveSourcePath()); - assertEquals(false, email.isVerified()); - assertEquals(false, email.isPrimary()); - break; - case "teddybass3public@semantico.com": - assertEquals(Visibility.PUBLIC, email.getVisibility()); - assertEquals("4444-4444-4444-4443", email.retrieveSourcePath()); - assertEquals(false, email.isVerified()); - assertEquals(false, email.isPrimary()); - break; - case "teddybass3private@semantico.com": - assertEquals(Visibility.PRIVATE, email.getVisibility()); - assertEquals("APP-5555555555555555", email.retrieveSourcePath()); - assertEquals(true, email.isVerified()); - assertEquals(false, email.isPrimary()); - break; - case "peter@sellers.com": - assertEquals(Visibility.PRIVATE, email.getVisibility()); - assertEquals("APP-5555555555555555", email.retrieveSourcePath()); - assertEquals(false, email.isVerified()); - assertEquals(true, email.isPrimary()); - break; - default: - fail("Invalid email: " + email.getEmail()); - } - } - } + assertEquals(1, emails.getEmails().size()); + Email email = emails.getEmails().get(0); + Utils.verifyLastModified(email.getLastModifiedDate()); + assertEquals(email.getEmail(), "teddybass3private@semantico.com"); + assertEquals(Visibility.PRIVATE, email.getVisibility()); + assertEquals("APP-5555555555555555", email.retrieveSourcePath()); + assertEquals(true, email.isVerified()); + assertEquals(false, email.isPrimary()); } } 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 10ffee9214b..0a5bd4d75da 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 @@ -17,7 +17,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.orcid.core.exception.OrcidUnauthorizedException; -import org.orcid.core.togglz.Features; import org.orcid.core.utils.SecurityContextTestUtils; import org.orcid.jaxb.model.common_v2.Visibility; import org.orcid.jaxb.model.groupid_v2.GroupIdRecord; @@ -515,58 +514,28 @@ public void testReadPrivateEmails_OtherThingsJustPublic_Person() { Emails email = p.getEmails(); assertNotNull(email); Utils.verifyLastModified(email.getLastModifiedDate()); - - if (Features.HIDE_UNVERIFIED_EMAILS.isActive()) { - assertEquals(4, email.getEmails().size()); - - boolean found1 = false, found2 = false, found3 = false, found4 = false; - - for (Email element : email.getEmails()) { - 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 if (element.getEmail().equals("self_limited_0000-0000-0000-0003@test.orcid.org")) { - found4 = true; - } else { - fail("Invalid email " + element.getEmail()); - } - } - - assertTrue(found1); - assertTrue(found2); - assertTrue(found3); - assertTrue(found4); - } else { - assertEquals(5, email.getEmails().size()); - - boolean found1 = false, found2 = false, found3 = false, found4 = false, found5 = false; - - for (Email element : email.getEmails()) { - 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 if (element.getEmail().equals("self_limited_0000-0000-0000-0003@test.orcid.org")) { - found4 = true; - } else if (element.getEmail().equals("self_private_0000-0000-0000-0003@test.orcid.org")) { - found5 = true; - } else { - fail("Invalid email " + element.getEmail()); - } + assertEquals(4, email.getEmails().size()); + + boolean found1 = false, found2 = false, found3 = false, found4 = false; + + for (Email element : email.getEmails()) { + 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 if (element.getEmail().equals("self_limited_0000-0000-0000-0003@test.orcid.org")) { + found4 = true; + } else { + fail("Invalid email " + element.getEmail()); } - - assertTrue(found1); - assertTrue(found2); - assertTrue(found3); - assertTrue(found4); - assertTrue(found5); } + assertTrue(found1); + assertTrue(found2); + assertTrue(found3); + assertTrue(found4); this.assertAllPublicButEmails(p); } 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 a188cc5fe4e..5f42ab91375 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 @@ -18,7 +18,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.orcid.core.exception.OrcidUnauthorizedException; -import org.orcid.core.togglz.Features; import org.orcid.core.utils.SecurityContextTestUtils; import org.orcid.jaxb.model.common_v2.Iso3166Country; import org.orcid.jaxb.model.common_v2.Locale; @@ -1004,59 +1003,30 @@ public void testReadPrivateEmails_OtherThingsJustPublic_Record() { assertNotNull(p.getEmails()); Emails email = p.getEmails(); assertNotNull(email); - Utils.verifyLastModified(email.getLastModifiedDate()); - - if (Features.HIDE_UNVERIFIED_EMAILS.isActive()) { - assertEquals(4, email.getEmails().size()); - - boolean found1 = false, found2 = false, found3 = false, found4 = false; - - for (Email element : email.getEmails()) { - 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 if (element.getEmail().equals("self_limited_0000-0000-0000-0003@test.orcid.org")) { - found4 = true; - } else { - fail("Invalid email " + element.getEmail()); - } - } - - assertTrue(found1); - assertTrue(found2); - assertTrue(found3); - assertTrue(found4); - } else { - assertEquals(5, email.getEmails().size()); - - boolean found1 = false, found2 = false, found3 = false, found4 = false, found5 = false; - - for (Email element : email.getEmails()) { - 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 if (element.getEmail().equals("self_limited_0000-0000-0000-0003@test.orcid.org")) { - found4 = true; - } else if (element.getEmail().equals("self_private_0000-0000-0000-0003@test.orcid.org")) { - found5 = true; - } else { - fail("Invalid email " + element.getEmail()); - } + Utils.verifyLastModified(email.getLastModifiedDate()); + assertEquals(4, email.getEmails().size()); + + boolean found1 = false, found2 = false, found3 = false, found4 = false; + + for (Email element : email.getEmails()) { + 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 if (element.getEmail().equals("self_limited_0000-0000-0000-0003@test.orcid.org")) { + found4 = true; + } else { + fail("Invalid email " + element.getEmail()); } - - assertTrue(found1); - assertTrue(found2); - assertTrue(found3); - assertTrue(found4); - assertTrue(found5); } + assertTrue(found1); + assertTrue(found2); + assertTrue(found3); + assertTrue(found4); + this.assertAllPublicButEmails(p); } diff --git a/orcid-api-web/src/test/java/org/orcid/api/memberV3/server/delegator/MemberV3ApiServiceDelegator_EmailsTest.java b/orcid-api-web/src/test/java/org/orcid/api/memberV3/server/delegator/MemberV3ApiServiceDelegator_EmailsTest.java index f8841c21c28..bff3f1a21a6 100644 --- a/orcid-api-web/src/test/java/org/orcid/api/memberV3/server/delegator/MemberV3ApiServiceDelegator_EmailsTest.java +++ b/orcid-api-web/src/test/java/org/orcid/api/memberV3/server/delegator/MemberV3ApiServiceDelegator_EmailsTest.java @@ -150,50 +150,12 @@ public void testViewEmails() { assertEquals("/4444-4444-4444-4443/email", emails.getPath()); Utils.verifyLastModified(emails.getLastModifiedDate()); assertNotNull(emails.getEmails()); - - if (Features.HIDE_UNVERIFIED_EMAILS.isActive()) { - assertEquals(1, emails.getEmails().size()); - Email email = emails.getEmails().get(0); - assertEquals("teddybass3private@semantico.com", email.getEmail()); - assertEquals(Visibility.PRIVATE, email.getVisibility()); - assertEquals("APP-5555555555555555", email.retrieveSourcePath()); - assertEquals(true, email.isVerified()); - assertEquals(false, email.isPrimary()); - } else { - assertEquals(3, emails.getEmails().size()); - for (Email email : emails.getEmails()) { - Utils.verifyLastModified(email.getLastModifiedDate()); - assertThat(email.getEmail(), anyOf(is("teddybass2@semantico.com"), is("teddybass3public@semantico.com"), is("teddybass3private@semantico.com"))); - switch (email.getEmail()) { - case "teddybass2@semantico.com": - assertEquals(Visibility.LIMITED, email.getVisibility()); - assertEquals("4444-4444-4444-4443", email.retrieveSourcePath()); - assertEquals(false, email.isVerified()); - assertEquals(false, email.isPrimary()); - break; - case "teddybass3public@semantico.com": - assertEquals(Visibility.PUBLIC, email.getVisibility()); - assertEquals("4444-4444-4444-4443", email.retrieveSourcePath()); - assertEquals(false, email.isVerified()); - assertEquals(false, email.isPrimary()); - break; - case "teddybass3private@semantico.com": - assertEquals(Visibility.PRIVATE, email.getVisibility()); - assertEquals("APP-5555555555555555", email.retrieveSourcePath()); - assertEquals(true, email.isVerified()); - assertEquals(false, email.isPrimary()); - break; - case "peter@sellers.com": - assertEquals(Visibility.PRIVATE, email.getVisibility()); - assertEquals("APP-5555555555555555", email.retrieveSourcePath()); - assertEquals(false, email.isVerified()); - assertEquals(true, email.isPrimary()); - break; - default: - fail("Invalid email: " + email.getEmail()); - break; - } - } - } + assertEquals(1, emails.getEmails().size()); + Email email = emails.getEmails().get(0); + assertEquals("teddybass3private@semantico.com", email.getEmail()); + assertEquals(Visibility.PRIVATE, email.getVisibility()); + assertEquals("APP-5555555555555555", email.retrieveSourcePath()); + assertEquals(true, email.isVerified()); + assertEquals(false, email.isPrimary()); } } 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 982a3b7bf78..ed43bc74c25 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 @@ -17,7 +17,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.orcid.core.exception.OrcidUnauthorizedException; -import org.orcid.core.togglz.Features; import org.orcid.core.utils.SecurityContextTestUtils; import org.orcid.jaxb.model.groupid_v2.GroupIdRecord; import org.orcid.jaxb.model.message.ScopePathType; @@ -521,58 +520,30 @@ public void testReadPrivateEmails_OtherThingsJustPublic_Person() { Emails email = p.getEmails(); assertNotNull(email); Utils.verifyLastModified(email.getLastModifiedDate()); - - if (Features.HIDE_UNVERIFIED_EMAILS.isActive()) { - assertEquals(4, email.getEmails().size()); - - boolean found1 = false, found2 = false, found3 = false, found4 = false; - - for (Email element : email.getEmails()) { - 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 if (element.getEmail().equals("self_limited_0000-0000-0000-0003@test.orcid.org")) { - found4 = true; - } else { - fail("Invalid email " + element.getEmail()); - } - } - - assertTrue(found1); - assertTrue(found2); - assertTrue(found3); - assertTrue(found4); - } else { - assertEquals(4, email.getEmails().size()); - - boolean found1 = false, found2 = false, found3 = false, found4 = false, found5 = false; - - for (Email element : email.getEmails()) { - 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 if (element.getEmail().equals("self_private_0000-0000-0000-0003@test.orcid.org")) { - found5 = true; - } else if (element.getEmail().equals("self_limited_0000-0000-0000-0003@test.orcid.org")) { - found4 = true; - } else { - fail("Invalid email " + element.getEmail()); - } + + assertEquals(4, email.getEmails().size()); + + boolean found1 = false, found2 = false, found3 = false, found4 = false; + + for (Email element : email.getEmails()) { + 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 if (element.getEmail().equals("self_limited_0000-0000-0000-0003@test.orcid.org")) { + found4 = true; + } else { + fail("Invalid email " + element.getEmail()); } - - assertTrue(found1); - assertTrue(found2); - assertTrue(found3); - assertTrue(found4); - assertTrue(found5); } - + + assertTrue(found1); + assertTrue(found2); + assertTrue(found3); + assertTrue(found4); + this.assertAllPublicButEmails(p); } diff --git a/orcid-api-web/src/test/java/org/orcid/api/memberV3/server/delegator/MemberV3ApiServiceDelegator_ReadRecordTest.java b/orcid-api-web/src/test/java/org/orcid/api/memberV3/server/delegator/MemberV3ApiServiceDelegator_ReadRecordTest.java index ca2c7d55282..65c5508cc1e 100644 --- a/orcid-api-web/src/test/java/org/orcid/api/memberV3/server/delegator/MemberV3ApiServiceDelegator_ReadRecordTest.java +++ b/orcid-api-web/src/test/java/org/orcid/api/memberV3/server/delegator/MemberV3ApiServiceDelegator_ReadRecordTest.java @@ -18,7 +18,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.orcid.core.exception.OrcidUnauthorizedException; -import org.orcid.core.togglz.Features; import org.orcid.core.utils.SecurityContextTestUtils; import org.orcid.jaxb.model.common.AvailableLocales; import org.orcid.jaxb.model.common.FundingType; @@ -1212,57 +1211,28 @@ public void testReadPrivateEmails_OtherThingsJustPublic_Record() { assertNotNull(email); Utils.verifyLastModified(email.getLastModifiedDate()); - if (Features.HIDE_UNVERIFIED_EMAILS.isActive()) { - assertEquals(4, email.getEmails().size()); - - boolean found1 = false, found2 = false, found3 = false, found4 = false; - - for (Email element : email.getEmails()) { - 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 if (element.getEmail().equals("self_limited_0000-0000-0000-0003@test.orcid.org")) { - found4 = true; - } else { - fail("Invalid email " + element.getEmail()); - } - } - - assertTrue(found1); - assertTrue(found2); - assertTrue(found3); - assertTrue(found4); - } else { - assertEquals(5, email.getEmails().size()); - - boolean found1 = false, found2 = false, found3 = false, found4 = false, found5 = false; - - for (Email element : email.getEmails()) { - 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 if (element.getEmail().equals("self_limited_0000-0000-0000-0003@test.orcid.org")) { - found4 = true; - } else if (element.getEmail().equals("self_private_0000-0000-0000-0003@test.orcid.org")) { - found5 = true; - } else { - fail("Invalid email " + element.getEmail()); - } + assertEquals(4, email.getEmails().size()); + + boolean found1 = false, found2 = false, found3 = false, found4 = false; + + for (Email element : email.getEmails()) { + 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 if (element.getEmail().equals("self_limited_0000-0000-0000-0003@test.orcid.org")) { + found4 = true; + } else { + fail("Invalid email " + element.getEmail()); } - - assertTrue(found1); - assertTrue(found2); - assertTrue(found3); - assertTrue(found4); - assertTrue(found5); } + assertTrue(found1); + assertTrue(found2); + assertTrue(found3); + assertTrue(found4); this.assertAllPublicButEmails(p); } diff --git a/orcid-core/src/main/java/org/orcid/core/manager/impl/OrcidGenerationManagerImpl.java b/orcid-core/src/main/java/org/orcid/core/manager/impl/OrcidGenerationManagerImpl.java index 2f6b61a8187..abcb572ee20 100644 --- a/orcid-core/src/main/java/org/orcid/core/manager/impl/OrcidGenerationManagerImpl.java +++ b/orcid-core/src/main/java/org/orcid/core/manager/impl/OrcidGenerationManagerImpl.java @@ -9,7 +9,6 @@ import org.orcid.core.crypto.OrcidCheckDigitGenerator; import org.orcid.core.manager.OrcidGenerationManager; import org.orcid.core.manager.ProfileEntityManager; -import org.orcid.core.togglz.Features; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -55,18 +54,13 @@ private boolean isInRecentOrcidCache(String formattedOrcid) { private long getRandomNumber() { Random random = new Random(); - // Is the new range of IDs enabled? - if(Features.ENABLE_NEW_IDS.isActive()) { - long randomLong = (long) (ORCID_BASE_V2_MIN + (random.nextDouble() * ORCID_IDS_V2_RANGE_SIZE)); - // Verify random is between valid range - while(randomLong < ORCID_BASE_V2_MIN || randomLong > ORCID_BASE_V2_MAX) { - randomLong = (long) (ORCID_BASE_V2_MIN + (random.nextDouble() * ORCID_IDS_V2_RANGE_SIZE)); - } - - return randomLong; - } else { - return (long) (ORCID_BASE_MIN + (random.nextDouble() * (ORCID_BASE_MAX - ORCID_BASE_MIN + 1))); - } + long randomLong = (long) (ORCID_BASE_V2_MIN + (random.nextDouble() * ORCID_IDS_V2_RANGE_SIZE)); + // Verify random is between valid range + while(randomLong < ORCID_BASE_V2_MIN || randomLong > ORCID_BASE_V2_MAX) { + randomLong = (long) (ORCID_BASE_V2_MIN + (random.nextDouble() * ORCID_IDS_V2_RANGE_SIZE)); + } + + return randomLong; } private String formatOrcid(String orcid) { diff --git a/orcid-core/src/main/java/org/orcid/core/manager/impl/OrgDisambiguatedManagerImpl.java b/orcid-core/src/main/java/org/orcid/core/manager/impl/OrgDisambiguatedManagerImpl.java index 03faaeb9208..74c078876a9 100644 --- a/orcid-core/src/main/java/org/orcid/core/manager/impl/OrgDisambiguatedManagerImpl.java +++ b/orcid-core/src/main/java/org/orcid/core/manager/impl/OrgDisambiguatedManagerImpl.java @@ -19,7 +19,6 @@ import org.orcid.core.orgs.extId.normalizer.OrgDisambiguatedExternalIdNormalizer; import org.orcid.core.orgs.grouping.OrgGrouping; import org.orcid.core.solr.OrcidSolrOrgsClient; -import org.orcid.core.togglz.Features; import org.orcid.persistence.dao.OrgDao; import org.orcid.persistence.dao.OrgDisambiguatedDao; import org.orcid.persistence.dao.OrgDisambiguatedExternalIdentifierDao; @@ -199,8 +198,7 @@ synchronized public void processOrgsWithIncorrectPopularity() { @Override public List searchOrgsFromSolr(String searchTerm, int firstResult, int maxResult, boolean fundersOnly) { - List docs = orcidSolrOrgsClient.getOrgs(searchTerm, firstResult, maxResult, fundersOnly, - Features.ENABLE_PROMOTION_OF_CHOSEN_ORGS.isActive()); + List docs = orcidSolrOrgsClient.getOrgs(searchTerm, firstResult, maxResult, fundersOnly); List ret = new ArrayList(); for (OrgDisambiguatedSolrDocument doc : docs) { OrgDisambiguated org = convertSolrDocument(doc); diff --git a/orcid-core/src/main/java/org/orcid/core/manager/read_only/impl/EmailManagerReadOnlyImpl.java b/orcid-core/src/main/java/org/orcid/core/manager/read_only/impl/EmailManagerReadOnlyImpl.java index 506c9dfef2b..0a4a20b6364 100644 --- a/orcid-core/src/main/java/org/orcid/core/manager/read_only/impl/EmailManagerReadOnlyImpl.java +++ b/orcid-core/src/main/java/org/orcid/core/manager/read_only/impl/EmailManagerReadOnlyImpl.java @@ -108,13 +108,8 @@ public Emails getVerifiedEmails(String orcid) { @Override public Emails getPublicEmails(String orcid) { - if (Features.HIDE_UNVERIFIED_EMAILS.isActive()) { - List entities = emailDao.findPublicEmails(orcid, getLastModified(orcid)); - return toEmails(entities); - } else { - List entities = emailDao.findPublicEmailsIncludeUnverified(orcid); - return toEmails(entities); - } + List entities = emailDao.findPublicEmails(orcid, getLastModified(orcid)); + return toEmails(entities); } private Emails toEmails(List entities) { diff --git a/orcid-core/src/main/java/org/orcid/core/manager/read_only/impl/PersonDetailsManagerReadOnlyImpl.java b/orcid-core/src/main/java/org/orcid/core/manager/read_only/impl/PersonDetailsManagerReadOnlyImpl.java index cb555f4677d..404dd3267bf 100644 --- a/orcid-core/src/main/java/org/orcid/core/manager/read_only/impl/PersonDetailsManagerReadOnlyImpl.java +++ b/orcid-core/src/main/java/org/orcid/core/manager/read_only/impl/PersonDetailsManagerReadOnlyImpl.java @@ -1,7 +1,6 @@ package org.orcid.core.manager.read_only.impl; import java.util.ArrayList; -import java.util.List; import java.util.stream.Collectors; import org.orcid.core.manager.read_only.AddressManagerReadOnly; @@ -13,23 +12,22 @@ import org.orcid.core.manager.read_only.ProfileKeywordManagerReadOnly; import org.orcid.core.manager.read_only.RecordNameManagerReadOnly; import org.orcid.core.manager.read_only.ResearcherUrlManagerReadOnly; -import org.orcid.core.togglz.Features; import org.orcid.jaxb.model.common_v2.Visibility; -import org.orcid.jaxb.model.record_v2.Addresses; import org.orcid.jaxb.model.record_v2.Address; +import org.orcid.jaxb.model.record_v2.Addresses; import org.orcid.jaxb.model.record_v2.Biography; -import org.orcid.jaxb.model.record_v2.Emails; import org.orcid.jaxb.model.record_v2.Email; -import org.orcid.jaxb.model.record_v2.Keywords; +import org.orcid.jaxb.model.record_v2.Emails; import org.orcid.jaxb.model.record_v2.Keyword; +import org.orcid.jaxb.model.record_v2.Keywords; import org.orcid.jaxb.model.record_v2.Name; -import org.orcid.jaxb.model.record_v2.OtherNames; import org.orcid.jaxb.model.record_v2.OtherName; +import org.orcid.jaxb.model.record_v2.OtherNames; import org.orcid.jaxb.model.record_v2.Person; -import org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers; import org.orcid.jaxb.model.record_v2.PersonExternalIdentifier; -import org.orcid.jaxb.model.record_v2.ResearcherUrls; +import org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers; import org.orcid.jaxb.model.record_v2.ResearcherUrl; +import org.orcid.jaxb.model.record_v2.ResearcherUrls; public class PersonDetailsManagerReadOnlyImpl extends ManagerReadOnlyBaseImpl implements PersonDetailsManagerReadOnly { @@ -125,13 +123,7 @@ public Person getPersonDetails(String orcid) { Emails emails = emailManager.getEmails(orcid); if (emails.getEmails() != null) { Emails filteredEmails = new Emails(); - - if (Features.HIDE_UNVERIFIED_EMAILS.isActive()) { - filteredEmails.setEmails(new ArrayList(emails.getEmails().stream().filter(e -> e.isVerified()).collect(Collectors.toList()))); - } else { - filteredEmails.setEmails(new ArrayList(emails.getEmails())); - } - + filteredEmails.setEmails(new ArrayList(emails.getEmails().stream().filter(e -> e.isVerified()).collect(Collectors.toList()))); person.setEmails(filteredEmails); } return person; diff --git a/orcid-core/src/main/java/org/orcid/core/manager/v3/read_only/impl/GroupingSuggestionManagerReadOnlyImpl.java b/orcid-core/src/main/java/org/orcid/core/manager/v3/read_only/impl/GroupingSuggestionManagerReadOnlyImpl.java index 5e864029289..789e9449380 100644 --- a/orcid-core/src/main/java/org/orcid/core/manager/v3/read_only/impl/GroupingSuggestionManagerReadOnlyImpl.java +++ b/orcid-core/src/main/java/org/orcid/core/manager/v3/read_only/impl/GroupingSuggestionManagerReadOnlyImpl.java @@ -6,7 +6,6 @@ import org.orcid.core.manager.v3.GroupingSuggestionsCacheManager; import org.orcid.core.manager.v3.read_only.GroupingSuggestionManagerReadOnly; -import org.orcid.core.togglz.Features; import org.orcid.pojo.grouping.WorkGroupingSuggestion; import org.orcid.pojo.grouping.WorkGroupingSuggestions; import org.orcid.pojo.grouping.WorkGroupingSuggestionsCount; @@ -18,9 +17,6 @@ public class GroupingSuggestionManagerReadOnlyImpl implements GroupingSuggestion @Override public WorkGroupingSuggestions getGroupingSuggestions(String orcid) { - if (!Features.GROUPING_SUGGESTIONS.isActive()) { - return null; - } boolean more = groupingSuggestionsCacheManager.getGroupingSuggestionCount(orcid) > SUGGESTION_BATCH_SIZE; List suggestions = groupingSuggestionsCacheManager.getGroupingSuggestions(orcid, SUGGESTION_BATCH_SIZE); return getWorkGroupingSuggestions(suggestions, more); diff --git a/orcid-core/src/main/java/org/orcid/core/manager/v3/read_only/impl/RecordManagerReadOnlyImpl.java b/orcid-core/src/main/java/org/orcid/core/manager/v3/read_only/impl/RecordManagerReadOnlyImpl.java index c01b2539881..c10ca1e3ad0 100644 --- a/orcid-core/src/main/java/org/orcid/core/manager/v3/read_only/impl/RecordManagerReadOnlyImpl.java +++ b/orcid-core/src/main/java/org/orcid/core/manager/v3/read_only/impl/RecordManagerReadOnlyImpl.java @@ -9,7 +9,7 @@ import org.orcid.core.manager.v3.read_only.EmailManagerReadOnly; import org.orcid.core.manager.v3.read_only.PersonDetailsManagerReadOnly; import org.orcid.core.manager.v3.read_only.RecordManagerReadOnly; -import org.orcid.core.togglz.Features; +import org.orcid.core.utils.DateUtils; import org.orcid.core.utils.SourceEntityUtils; import org.orcid.jaxb.model.common.AvailableLocales; import org.orcid.jaxb.model.common.OrcidType; @@ -27,7 +27,6 @@ import org.orcid.jaxb.model.v3.release.record.SubmissionDate; import org.orcid.persistence.jpa.entities.ProfileEntity; import org.orcid.pojo.ajaxForm.PojoUtil; -import org.orcid.core.utils.DateUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -89,7 +88,7 @@ public Record getRecord(String orcid, boolean filterVersionOfIdentifiers) { record.setOrcidIdentifier(getOrcidIdentifier(orcid)); record.setPreferences(getPreferences(orcid)); record.setActivitiesSummary(activitiesSummaryManager.getActivitiesSummary(orcid, filterVersionOfIdentifiers)); - record.setPerson(personDetailsManager.getPersonDetails(orcid, !Features.HIDE_UNVERIFIED_EMAILS.isActive())); + record.setPerson(personDetailsManager.getPersonDetails(orcid, false)); return record; } diff --git a/orcid-core/src/main/java/org/orcid/core/manager/v3/read_only/impl/WorkManagerReadOnlyImpl.java b/orcid-core/src/main/java/org/orcid/core/manager/v3/read_only/impl/WorkManagerReadOnlyImpl.java index 482135b1e89..e381fc39b1b 100644 --- a/orcid-core/src/main/java/org/orcid/core/manager/v3/read_only/impl/WorkManagerReadOnlyImpl.java +++ b/orcid-core/src/main/java/org/orcid/core/manager/v3/read_only/impl/WorkManagerReadOnlyImpl.java @@ -309,11 +309,8 @@ public Works groupWorksAndGenerateGroupingSuggestions(List summarie groupGenerator.group(work); } Works works = processGroupedWorks(groupGenerator.getGroups()); - - if (Features.GROUPING_SUGGESTIONS.isActive()) { - List suggestions = groupGenerator.getGroupingSuggestions(orcid); - groupingSuggestionsManager.cacheGroupingSuggestions(orcid, suggestions); - } + List suggestions = groupGenerator.getGroupingSuggestions(orcid); + groupingSuggestionsManager.cacheGroupingSuggestions(orcid, suggestions); return works; } @@ -324,11 +321,8 @@ public WorksExtended groupWorksExtendedAndGenerateGroupingSuggestions(List suggestions = groupGenerator.getGroupingSuggestions(orcid); - groupingSuggestionsManager.cacheGroupingSuggestions(orcid, suggestions); - } + List suggestions = groupGenerator.getGroupingSuggestions(orcid); + groupingSuggestionsManager.cacheGroupingSuggestions(orcid, suggestions); return works; } diff --git a/orcid-core/src/main/java/org/orcid/core/oauth/openid/OpenIDConnectTokenEnhancer.java b/orcid-core/src/main/java/org/orcid/core/oauth/openid/OpenIDConnectTokenEnhancer.java index a2e7fc2c175..2b6e0429add 100644 --- a/orcid-core/src/main/java/org/orcid/core/oauth/openid/OpenIDConnectTokenEnhancer.java +++ b/orcid-core/src/main/java/org/orcid/core/oauth/openid/OpenIDConnectTokenEnhancer.java @@ -106,11 +106,7 @@ public String buildIdToken(OAuth2AccessToken accessToken, String orcid, String c twentyFourHrs.add(Calendar.DAY_OF_YEAR, 1); claims.issueTime(now); - if(Features.ID_TOKEN_24_HOURS_LIFESPAN.isActive()) { - claims.expirationTime(twentyFourHrs.getTime()); - } else { - claims.expirationTime(accessToken.getExpiration()); - } + claims.expirationTime(twentyFourHrs.getTime()); claims.jwtID(UUID.randomUUID().toString()); if (nonce != null) diff --git a/orcid-core/src/main/java/org/orcid/core/solr/OrcidSolrOrgsClient.java b/orcid-core/src/main/java/org/orcid/core/solr/OrcidSolrOrgsClient.java index be4c57fa21a..b35c09b9262 100644 --- a/orcid-core/src/main/java/org/orcid/core/solr/OrcidSolrOrgsClient.java +++ b/orcid-core/src/main/java/org/orcid/core/solr/OrcidSolrOrgsClient.java @@ -1,6 +1,6 @@ package org.orcid.core.solr; -import static org.orcid.core.solr.SolrConstants.*; +import static org.orcid.core.solr.SolrConstants.ORG_DISAMBIGUATED_ID; import java.io.IOException; import java.text.MessageFormat; @@ -51,11 +51,7 @@ public OrgDisambiguatedSolrDocument findById(Long id) { return null; } - public List getOrgs(String searchTerm, int firstResult, int maxResult, boolean promoteChosenOrgs) { - return getOrgs(searchTerm, firstResult, maxResult, false, promoteChosenOrgs); - } - - public List getOrgs(String searchTerm, int firstResult, int maxResult, boolean fundersOnly, boolean promoteChosenOrgs) { + public List getOrgs(String searchTerm, int firstResult, int maxResult, boolean fundersOnly) { StringBuilder queryString = new StringBuilder(SOLR_ORGS_QUERY.replace("%s", searchTerm)); if (fundersOnly) { queryString.append(" AND is-funding-org:true"); diff --git a/orcid-core/src/main/java/org/orcid/core/togglz/Features.java b/orcid-core/src/main/java/org/orcid/core/togglz/Features.java index 345a8cc0269..ec5978bcc45 100644 --- a/orcid-core/src/main/java/org/orcid/core/togglz/Features.java +++ b/orcid-core/src/main/java/org/orcid/core/togglz/Features.java @@ -21,15 +21,9 @@ public enum Features implements Feature { @Label("Redirect PUT token actions from *.pub.orcid.org to *.orcid.org") REDIRECT_PUT_TOKEN_ENDPOINT, - @Label("New Developer tools") - NEW_DEVELOPER_TOOLS, - @Label("Stop sending notification if work has not been updated") STOP_SENDING_NOTIFICATION_WORK_NOT_UPDATED, - @Label("Move client from a member to another member") - MOVE_CLIENT, - @Label("Enable Crazy Egg") CRAZY_EGG, @@ -44,17 +38,9 @@ public enum Features implements Feature { @Label("Spam button") SPAM_BUTTON, - @Label("Enable 2019 header") - ENABLE_HEADER2, - + @Label("Shows an alert message when a user goes to /signin and is already signed in\n") RE_LOGGIN_ALERT, - - @Label("Arabic translation") - LANG_AR, - - @Label("New footer") - NEW_FOOTER, @Label("Reset password send email in all cases") RESET_PASSWORD_EMAIL, @@ -71,36 +57,18 @@ public enum Features implements Feature { @Label("Self service org ids") SELF_SERVICE_ORG_IDS, - @Label("Check external id resolution in UI") - EX_ID_RESOLVER, - @Label("Remove https://orcid.org from OpenID id_tokens") OPENID_SIMPLE_SUBJECT, - @Label("Enable manual work grouping") - MANUAL_WORK_GROUPING, - - @Label("Grouping suggestions") - GROUPING_SUGGESTIONS, - - @Label("Enable promotion of chosen orgs in search") - ENABLE_PROMOTION_OF_CHOSEN_ORGS, - @Label("Enable the API record create endpoint for QA purposes") ENABLE_RECORD_CREATE_ENDPOINT, - @Label("Hide unverified emails") - HIDE_UNVERIFIED_EMAILS, - @Label("User OBO") USER_OBO, @Label("Works failure debug") WORKS_FAILURE_DEBUG, - @Label("ID token 24 hours lifespan") - ID_TOKEN_24_HOURS_LIFESPAN, - @Label("Promote a client from public client to be a member") UPGRADE_PUBLIC_CLIENT, @@ -114,10 +82,7 @@ public enum Features implements Feature { ENABLE_ACCOUNT_LOCKOUT, @Label("Do not lock the account on the UI when the lockout threshold is exceeded") - ACCOUNT_LOCKOUT_SIMULATION, - - @Label("Enable the new 100M ID's range") - ENABLE_NEW_IDS, + ACCOUNT_LOCKOUT_SIMULATION, @Label("Send verification emails for 2, 7 and 28 days. If disabled 2 days only verification emails will be sent.") SEND_ALL_VERIFICATION_EMAILS, diff --git a/orcid-core/src/test/java/org/orcid/core/manager/OrcidGenerationManagerTest.java b/orcid-core/src/test/java/org/orcid/core/manager/OrcidGenerationManagerTest.java index 864c1f66ed5..b8ece29b573 100644 --- a/orcid-core/src/test/java/org/orcid/core/manager/OrcidGenerationManagerTest.java +++ b/orcid-core/src/test/java/org/orcid/core/manager/OrcidGenerationManagerTest.java @@ -31,31 +31,8 @@ public class OrcidGenerationManagerTest extends BaseTest { private static final Logger logger = Logger.getLogger(OrcidGenerationManagerTest.class); - @Test - public void testCreateNewOrcidV1() { - togglzRule.disable(Features.ENABLE_NEW_IDS); - Set orcids = new HashSet(); - for (int i = 0; i < 20000; i++) { - String orcid = orcidGenerationManager.createNewOrcid(); - - assertNotNull("ORCID is null", orcid); - assertTrue("ORCID is in wrong format " + orcid, orcid.matches("(\\d{4}-){3}\\d{3}[\\dX]")); - assertTrue("ORCID has invalid check character " + orcid, OrcidCheckDigitGenerator.validate(orcid)); - assertFalse("ORCID has already been used " + orcid + " number of elements cached: " + orcids.size(), orcids.contains(orcid)); - - String baseDigits = orcid.substring(0, orcid.length() - 1).replace("-", ""); - long numericOrcid = Long.valueOf(baseDigits); - assertTrue("Numeric value of ORCID is too low " + orcid, numericOrcid >= OrcidGenerationManager.ORCID_BASE_MIN); - assertTrue("Numeric value of ORCID is too high " + orcid, numericOrcid <= OrcidGenerationManager.ORCID_BASE_MAX); - - orcids.add(orcid); - logger.info("Got ORCID = " + orcid); - } - } - @Test public void testCreateNewOrcidV2() { - togglzRule.enable(Features.ENABLE_NEW_IDS); Set orcids = new HashSet(); for (int i = 0; i < 1000000; i++) { String orcid = orcidGenerationManager.createNewOrcid(); diff --git a/orcid-core/src/test/java/org/orcid/core/manager/v3/PersonDetailsManagerTest.java b/orcid-core/src/test/java/org/orcid/core/manager/v3/PersonDetailsManagerTest.java index 2b369b20501..9636e3397ba 100644 --- a/orcid-core/src/test/java/org/orcid/core/manager/v3/PersonDetailsManagerTest.java +++ b/orcid-core/src/test/java/org/orcid/core/manager/v3/PersonDetailsManagerTest.java @@ -47,7 +47,7 @@ public static void removeDBUnitData() throws Exception { @Test public void testGetPersonDetails() { - Person person = personDetailsManager.getPersonDetails(ORCID, !Features.HIDE_UNVERIFIED_EMAILS.isActive()); + Person person = personDetailsManager.getPersonDetails(ORCID, false); assertNotNull(person); assertNotNull(person.getExternalIdentifiers()); @@ -72,16 +72,11 @@ public void testGetPersonDetails() { assertNotNull(person.getEmails()); assertNotNull(person.getEmails().getEmails()); - - if (Features.HIDE_UNVERIFIED_EMAILS.isActive()) { - assertEquals(4, person.getEmails().getEmails().size()); - - for (Email email : person.getEmails().getEmails()) { - assertTrue(email.isVerified()); - } - } else { - assertEquals(5, person.getEmails().getEmails().size()); - } + assertEquals(4, person.getEmails().getEmails().size()); + + for (Email email : person.getEmails().getEmails()) { + assertTrue(email.isVerified()); + } assertNotNull(person.getBiography()); assertEquals(Visibility.PUBLIC, person.getBiography().getVisibility()); diff --git a/orcid-core/src/test/java/org/orcid/core/manager/v3/RecordManagerTest.java b/orcid-core/src/test/java/org/orcid/core/manager/v3/RecordManagerTest.java index 527478472bb..05a7b8e07e2 100644 --- a/orcid-core/src/test/java/org/orcid/core/manager/v3/RecordManagerTest.java +++ b/orcid-core/src/test/java/org/orcid/core/manager/v3/RecordManagerTest.java @@ -13,7 +13,6 @@ import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; -import org.orcid.core.togglz.Features; import org.orcid.jaxb.model.v3.release.common.Visibility; import org.orcid.jaxb.model.v3.release.record.Person; import org.orcid.jaxb.model.v3.release.record.Record; @@ -77,11 +76,7 @@ public void testGetRecord() { assertNotNull(person.getEmails()); assertNotNull(person.getEmails().getEmails()); - if (Features.HIDE_UNVERIFIED_EMAILS.isActive()) { - assertEquals(4, person.getEmails().getEmails().size()); - } else { - assertEquals(5, person.getEmails().getEmails().size()); - } + assertEquals(4, person.getEmails().getEmails().size()); assertNotNull(person.getBiography()); assertEquals(Visibility.PUBLIC, person.getBiography().getVisibility()); diff --git a/orcid-web/src/main/java/org/orcid/frontend/web/controllers/AdminController.java b/orcid-web/src/main/java/org/orcid/frontend/web/controllers/AdminController.java index 2badc25731a..989c9a90445 100644 --- a/orcid-web/src/main/java/org/orcid/frontend/web/controllers/AdminController.java +++ b/orcid-web/src/main/java/org/orcid/frontend/web/controllers/AdminController.java @@ -1061,7 +1061,7 @@ private String getOrcidFromParam(String orcidOrEmail) { @RequestMapping(value = "/validate-client-conversion.json", method = RequestMethod.POST) public @ResponseBody ConvertClient validateClientConversion(HttpServletRequest serverRequest, HttpServletResponse response, @RequestBody ConvertClient data) throws IllegalAccessException { - if (!Features.UPGRADE_PUBLIC_CLIENT.isActive() && !Features.MOVE_CLIENT.isActive()) { + if (!Features.UPGRADE_PUBLIC_CLIENT.isActive()) { throw new IllegalAccessException("Feature UPGRADE_PUBLIC_CLIENT is disabled"); } data.setGroupIdNotFound(false); @@ -1145,9 +1145,6 @@ private String getOrcidFromParam(String orcidOrEmail) { @RequestMapping(value = "/move-client.json", method = RequestMethod.POST) public @ResponseBody ConvertClient moveClient(HttpServletRequest serverRequest, HttpServletResponse response, @RequestBody ConvertClient data) throws IllegalAccessException { - if (!Features.MOVE_CLIENT.isActive()) { - throw new IllegalAccessException("Feature UPGRADE_PUBLIC_CLIENT is disabled"); - } isAdmin(serverRequest, response); data = validateClientConversion(serverRequest, response, data); if (data.isClientNotFound() || !data.isAlreadyMember() || data.isGroupIdNotFound() || data.isClientDeactivated()) { diff --git a/orcid-web/src/main/java/org/orcid/frontend/web/controllers/BaseController.java b/orcid-web/src/main/java/org/orcid/frontend/web/controllers/BaseController.java index 396f12e5b5a..9f4de5863c2 100644 --- a/orcid-web/src/main/java/org/orcid/frontend/web/controllers/BaseController.java +++ b/orcid-web/src/main/java/org/orcid/frontend/web/controllers/BaseController.java @@ -918,11 +918,7 @@ protected String getCurrentUserOrcid() { publicEmails = emailManagerReadOnly.getEmails(orcid); } Emails filteredEmails = new Emails(); - if (Features.HIDE_UNVERIFIED_EMAILS.isActive()) { - filteredEmails.setEmails(new ArrayList(publicEmails.getEmails().stream().filter(e -> e.isVerified()).collect(Collectors.toList()))); - } else { - filteredEmails.setEmails(new ArrayList(publicEmails.getEmails())); - } + filteredEmails.setEmails(new ArrayList(publicEmails.getEmails().stream().filter(e -> e.isVerified()).collect(Collectors.toList()))); Map> groupedEmails = groupEmails(filteredEmails); publicRecordPersonDetails.setPublicGroupedEmails(groupedEmails); diff --git a/orcid-web/src/main/java/org/orcid/frontend/web/controllers/PublicRecordController.java b/orcid-web/src/main/java/org/orcid/frontend/web/controllers/PublicRecordController.java index b4f8ab05aa4..8ff400efbe6 100644 --- a/orcid-web/src/main/java/org/orcid/frontend/web/controllers/PublicRecordController.java +++ b/orcid-web/src/main/java/org/orcid/frontend/web/controllers/PublicRecordController.java @@ -1,5 +1,21 @@ package org.orcid.frontend.web.controllers; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; +import java.util.GregorianCalendar; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import javax.annotation.Resource; +import javax.xml.datatype.XMLGregorianCalendar; + import org.orcid.core.common.manager.EventManager; import org.orcid.core.exception.DeactivatedException; import org.orcid.core.exception.LockedException; @@ -42,12 +58,9 @@ import org.orcid.jaxb.model.v3.release.record.Emails; import org.orcid.jaxb.model.v3.release.record.Keywords; import org.orcid.jaxb.model.v3.release.record.Name; -import org.orcid.jaxb.model.v3.release.record.OtherName; import org.orcid.jaxb.model.v3.release.record.OtherNames; -import org.orcid.jaxb.model.v3.release.record.Person; import org.orcid.jaxb.model.v3.release.record.PersonExternalIdentifiers; import org.orcid.jaxb.model.v3.release.record.PersonalDetails; -import org.orcid.jaxb.model.v3.release.record.Record; import org.orcid.jaxb.model.v3.release.record.ResearcherUrls; import org.orcid.persistence.jpa.entities.ProfileEntity; import org.orcid.pojo.PeerReviewMinimizedSummary; @@ -75,21 +88,6 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; -import javax.annotation.Resource; -import javax.xml.datatype.XMLGregorianCalendar; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Comparator; -import java.util.GregorianCalendar; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.stream.Collectors; -import java.util.stream.Stream; - @Controller public class PublicRecordController extends BaseWorkspaceController { @@ -294,12 +292,8 @@ PublicRecord getRecord(String orcid) { publicEmails = emailManagerReadOnly.getPublicEmails(orcid); Emails filteredEmails = new Emails(); - if (Features.HIDE_UNVERIFIED_EMAILS.isActive()) { - filteredEmails.setEmails(new ArrayList<>(publicEmails.getEmails().stream().filter(Email::isVerified).collect(Collectors.toList()))); - } else { - filteredEmails.setEmails(new ArrayList<>(publicEmails.getEmails())); - } - + filteredEmails.setEmails(new ArrayList<>(publicEmails.getEmails().stream().filter(Email::isVerified).collect(Collectors.toList()))); + publicRecord.setEmails(org.orcid.pojo.ajaxForm.Emails.valueOf(filteredEmails)); // Fill external identifiers