From a28bf4862191b9b1e2bd6a43963b5659c23ec3e3 Mon Sep 17 00:00:00 2001 From: Leonardo Mendoza Fernadez Date: Tue, 27 Feb 2024 12:34:08 -0600 Subject: [PATCH 1/6] lmendoza/wordpress-headless --- orcid-core/src/main/java/org/orcid/core/togglz/Features.java | 5 +++++ 1 file changed, 5 insertions(+) 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 1363a5845a9..e82777a7031 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 @@ -6,6 +6,11 @@ public enum Features implements Feature { + + @Label("Homepage Headless WordPress") + WORDPRESS_HOME_PAGE, + + @Label("Registration 2.1: Add affiliations on registration") REGISTRATION_2_1, From 65f45615412ef1d9b20e3f656b5fce3a1693de1e Mon Sep 17 00:00:00 2001 From: Angel Montenegro Date: Tue, 27 Feb 2024 15:13:06 -0600 Subject: [PATCH 2/6] Deactivated records should get 409 on GET requests (#7000) * Deactivated records should get 409 on GET requests * Better unit tests --- .../api/common/jaxb/OrcidExceptionMapper.java | 2 + .../impl/MemberV3ApiServiceDelegatorImpl.java | 12 +-- ...MemberV3ApiServiceDelegatorErrorsTest.java | 99 ++++++++++++++++++- .../v3/impl/OrcidSecurityManagerImpl.java | 6 +- 4 files changed, 102 insertions(+), 17 deletions(-) diff --git a/orcid-api-common/src/main/java/org/orcid/api/common/jaxb/OrcidExceptionMapper.java b/orcid-api-common/src/main/java/org/orcid/api/common/jaxb/OrcidExceptionMapper.java index 81f74a10d2b..d96850ceb37 100644 --- a/orcid-api-common/src/main/java/org/orcid/api/common/jaxb/OrcidExceptionMapper.java +++ b/orcid-api-common/src/main/java/org/orcid/api/common/jaxb/OrcidExceptionMapper.java @@ -111,6 +111,8 @@ public Response toResponse(Throwable t) { logShortError(t, clientId); } else if (t instanceof LockedException) { logShortError(t, clientId); + } else if (t instanceof DeactivatedException) { + logShortError(t, clientId); } else if (t instanceof ClientDeactivatedException) { logShortError(t, clientId); } else if (t instanceof OrcidNonPublicElementException) { 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 64c6535d0bf..a3fb41eb9a5 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 @@ -1642,16 +1642,8 @@ public Response deleteResearchResource(String orcid, Long putCode) { return Response.noContent().build(); } - private void checkProfileStatus(String orcid, boolean readOperation) { - try { - orcidSecurityManager.checkProfile(orcid); - } catch (DeactivatedException e) { - // If it is a read operation, ignore the deactivated status since we - // are going to return the empty element with the deactivation date - if (!readOperation) { - throw e; - } - } + private void checkProfileStatus(String orcid, boolean readOperation) throws DeactivatedException { + orcidSecurityManager.checkProfile(orcid); } private Map addParmsMismatchedPutCode(Long urlPutCode, Long bodyPutCode) { diff --git a/orcid-api-web/src/test/java/org/orcid/api/memberV3/server/delegator/MemberV3ApiServiceDelegatorErrorsTest.java b/orcid-api-web/src/test/java/org/orcid/api/memberV3/server/delegator/MemberV3ApiServiceDelegatorErrorsTest.java index 96330083161..de34b5c5e6c 100644 --- a/orcid-api-web/src/test/java/org/orcid/api/memberV3/server/delegator/MemberV3ApiServiceDelegatorErrorsTest.java +++ b/orcid-api-web/src/test/java/org/orcid/api/memberV3/server/delegator/MemberV3ApiServiceDelegatorErrorsTest.java @@ -1764,28 +1764,119 @@ public void test3_0() { /** * Deactivated elements tests - */ - @Test - public void testViewDeactivatedRecordDontThrowError() { + */ + @Test(expected = DeactivatedException.class) + public void testDeactivatedRecordViewActivities() { SecurityContextTestUtils.setUpSecurityContext("0000-0000-0000-0007", ScopePathType.READ_LIMITED); serviceDelegator.viewActivities(deactivatedUserOrcid); + fail(); + } + + @Test(expected = DeactivatedException.class) + public void testDeactivatedRecordViewRecord() { + SecurityContextTestUtils.setUpSecurityContext("0000-0000-0000-0007", ScopePathType.READ_LIMITED); serviceDelegator.viewRecord(deactivatedUserOrcid); + fail(); + } + + @Test(expected = DeactivatedException.class) + public void testDeactivatedRecordViewPerson() { + SecurityContextTestUtils.setUpSecurityContext("0000-0000-0000-0007", ScopePathType.READ_LIMITED); serviceDelegator.viewPerson(deactivatedUserOrcid); + fail(); + } + + @Test(expected = DeactivatedException.class) + public void testDeactivatedRecordViewAddresses() { + SecurityContextTestUtils.setUpSecurityContext("0000-0000-0000-0007", ScopePathType.READ_LIMITED); serviceDelegator.viewAddresses(deactivatedUserOrcid); + fail(); + } + + @Test(expected = DeactivatedException.class) + public void testDeactivatedRecordViewEducations() { + SecurityContextTestUtils.setUpSecurityContext("0000-0000-0000-0007", ScopePathType.READ_LIMITED); serviceDelegator.viewEducations(deactivatedUserOrcid); + fail(); + } + + @Test(expected = DeactivatedException.class) + public void testDeactivatedRecordViewEmails() { + SecurityContextTestUtils.setUpSecurityContext("0000-0000-0000-0007", ScopePathType.READ_LIMITED); serviceDelegator.viewEmails(deactivatedUserOrcid); + fail(); + } + + @Test(expected = DeactivatedException.class) + public void testDeactivatedRecordViewEmployments() { + SecurityContextTestUtils.setUpSecurityContext("0000-0000-0000-0007", ScopePathType.READ_LIMITED); serviceDelegator.viewEmployments(deactivatedUserOrcid); + fail(); + } + + @Test(expected = DeactivatedException.class) + public void testDeactivatedRecordViewExternalIdentifiers() { + SecurityContextTestUtils.setUpSecurityContext("0000-0000-0000-0007", ScopePathType.READ_LIMITED); serviceDelegator.viewExternalIdentifiers(deactivatedUserOrcid); + fail(); + } + + @Test(expected = DeactivatedException.class) + public void testDeactivatedRecordViewFundings() { + SecurityContextTestUtils.setUpSecurityContext("0000-0000-0000-0007", ScopePathType.READ_LIMITED); serviceDelegator.viewFundings(deactivatedUserOrcid); + fail(); + } + + @Test(expected = DeactivatedException.class) + public void testDeactivatedRecordViewKeywords() { + SecurityContextTestUtils.setUpSecurityContext("0000-0000-0000-0007", ScopePathType.READ_LIMITED); serviceDelegator.viewKeywords(deactivatedUserOrcid); + fail(); + } + + @Test(expected = DeactivatedException.class) + public void testDeactivatedRecordViewOtherNames() { + SecurityContextTestUtils.setUpSecurityContext("0000-0000-0000-0007", ScopePathType.READ_LIMITED); serviceDelegator.viewOtherNames(deactivatedUserOrcid); + fail(); + } + + @Test(expected = DeactivatedException.class) + public void testDeactivatedRecordViewPeerReviews() { + SecurityContextTestUtils.setUpSecurityContext("0000-0000-0000-0007", ScopePathType.READ_LIMITED); serviceDelegator.viewPeerReviews(deactivatedUserOrcid); + fail(); + } + + @Test(expected = DeactivatedException.class) + public void testDeactivatedRecordViewPersonalDetails() { + SecurityContextTestUtils.setUpSecurityContext("0000-0000-0000-0007", ScopePathType.READ_LIMITED); serviceDelegator.viewPersonalDetails(deactivatedUserOrcid); + fail(); + } + + @Test(expected = DeactivatedException.class) + public void testDeactivatedRecordViewResearcherUrls() { + SecurityContextTestUtils.setUpSecurityContext("0000-0000-0000-0007", ScopePathType.READ_LIMITED); serviceDelegator.viewResearcherUrls(deactivatedUserOrcid); + fail(); + } + + @Test(expected = DeactivatedException.class) + public void testDeactivatedRecordViewResearchResources() { + SecurityContextTestUtils.setUpSecurityContext("0000-0000-0000-0007", ScopePathType.READ_LIMITED); serviceDelegator.viewResearchResources(deactivatedUserOrcid); + fail(); + } + + @Test(expected = DeactivatedException.class) + public void testDeactivatedRecordViewWorks() { + SecurityContextTestUtils.setUpSecurityContext("0000-0000-0000-0007", ScopePathType.READ_LIMITED); serviceDelegator.viewWorks(deactivatedUserOrcid); + fail(); } - + @Test(expected = DeactivatedException.class) public void testDeactivatedRecordCreateWork() { serviceDelegator.createWork(deactivatedUserOrcid, null); diff --git a/orcid-core/src/main/java/org/orcid/core/manager/v3/impl/OrcidSecurityManagerImpl.java b/orcid-core/src/main/java/org/orcid/core/manager/v3/impl/OrcidSecurityManagerImpl.java index 59b415afdc0..5067b4195e3 100644 --- a/orcid-core/src/main/java/org/orcid/core/manager/v3/impl/OrcidSecurityManagerImpl.java +++ b/orcid-core/src/main/java/org/orcid/core/manager/v3/impl/OrcidSecurityManagerImpl.java @@ -202,15 +202,15 @@ public void checkProfile(String orcid) throws NoResultException, OrcidDeprecated // Check if the user record is locked if (!profile.isAccountNonLocked()) { - LockedException lockedException = new LockedException(); + LockedException lockedException = new LockedException(orcid + " is locked"); lockedException.setOrcid(profile.getId()); throw lockedException; } // Check if the user record is deactivated if (profile.getDeactivationDate() != null) { - DeactivatedException exception = new DeactivatedException(); - exception.setOrcid(orcid); + DeactivatedException exception = new DeactivatedException(orcid + " is deactivated"); + exception.setOrcid(orcid); throw exception; } } From c4c4263f0097070ad21712753c1ca322f2c50e1e Mon Sep 17 00:00:00 2001 From: github actions Date: Tue, 27 Feb 2024 21:25:59 +0000 Subject: [PATCH 3/6] v2.51.4 changelog update --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 32c510cfe53..ba3040508cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## v2.51.4 - 2024-02-27 + +[Full Changelog](https://github.com/ORCID/ORCID-Source/compare/v2.51.3...v2.51.4) + ## v2.51.3 - 2024-02-27 [Full Changelog](https://github.com/ORCID/ORCID-Source/compare/v2.51.2...v2.51.3) From bcb38edc4cc71b3f10e6662c9e0edc305ec369d7 Mon Sep 17 00:00:00 2001 From: github actions Date: Wed, 28 Feb 2024 02:07:10 +0000 Subject: [PATCH 4/6] v2.51.5 changelog update --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ba3040508cd..1d8e90c1a70 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## v2.51.5 - 2024-02-28 + +[Full Changelog](https://github.com/ORCID/ORCID-Source/compare/v2.51.4...v2.51.5) + +- [#6999](https://github.com/ORCID/ORCID-Source/pull/6999): lmendoza/wordpress-headless + ## v2.51.4 - 2024-02-27 [Full Changelog](https://github.com/ORCID/ORCID-Source/compare/v2.51.3...v2.51.4) From 91704ae358f3f99e10e3a67b463ebbd232a7e98b Mon Sep 17 00:00:00 2001 From: Camelia Dumitru <62257307+Camelia-Orcid@users.noreply.github.com> Date: Wed, 28 Feb 2024 13:59:42 +0000 Subject: [PATCH 5/6] 60 prod no change put request behaviour (#7001) * Added the check for put requests when the source is not the same * Fixed the failing testcase, added testcase for update with different sources * Attempt to fix the race issue with random token generation * Fixed the equality check for string * Fixed the equality check for the source entity * Changed the developer message code * Fixed 400 error * replacing explicitly ${activity} with work string --- .../java/org/orcid/core/manager/impl/WorkManagerImpl.java | 5 +++-- .../java/org/orcid/core/manager/v3/impl/WorkManagerImpl.java | 3 +-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/orcid-core/src/main/java/org/orcid/core/manager/impl/WorkManagerImpl.java b/orcid-core/src/main/java/org/orcid/core/manager/impl/WorkManagerImpl.java index e3017a17470..342eda67f77 100644 --- a/orcid-core/src/main/java/org/orcid/core/manager/impl/WorkManagerImpl.java +++ b/orcid-core/src/main/java/org/orcid/core/manager/impl/WorkManagerImpl.java @@ -355,6 +355,7 @@ public Work updateWork(String orcid, Work work, boolean isApiRequest) { Work workSaved = jpaJaxbWorkAdapter.toWork(workEntity); WorkForm workFormSaved = WorkForm.valueOf(workSaved, maxContributorsForUI); + String devMessage = localeManager.resolveMessage("apiError.9010.developerMessage").replace("${activity}", "work"); if (workFormSaved.compare(WorkForm.valueOf(work, maxContributorsForUI))) { SourceEntity sourceEntity = sourceManager.retrieveSourceEntity(); @@ -362,13 +363,13 @@ public Work updateWork(String orcid, Work work, boolean isApiRequest) { if (sourceEntity.getSourceProfile() != null && sourceEntity.getSourceProfile().getId() != null) { client = sourceEntity.getSourceProfile().getId(); if(!StringUtils.equals(client, orcid) ) { - throw new OrcidForbiddenException(localeManager.resolveMessage("apiError.9010.developerMessage","work")); + throw new OrcidForbiddenException(devMessage ); } } if (sourceEntity.getSourceClient() != null && sourceEntity.getSourceClient().getClientName() != null) { client = sourceEntity.getSourceClient().getClientName(); if(!StringUtils.equals(sourceEntity.getSourceClient().getClientId(), workEntity.getClientSourceId()) ) { - throw new OrcidForbiddenException(localeManager.resolveMessage("apiError.9010.developerMessage","work")); + throw new OrcidForbiddenException(devMessage ); } } LOGGER.info("There is no changes in the work with putCode " + work.getPutCode() + " send it by " + client); diff --git a/orcid-core/src/main/java/org/orcid/core/manager/v3/impl/WorkManagerImpl.java b/orcid-core/src/main/java/org/orcid/core/manager/v3/impl/WorkManagerImpl.java index cef0b778523..cdb636c282f 100644 --- a/orcid-core/src/main/java/org/orcid/core/manager/v3/impl/WorkManagerImpl.java +++ b/orcid-core/src/main/java/org/orcid/core/manager/v3/impl/WorkManagerImpl.java @@ -375,9 +375,8 @@ public Work updateWork(String orcid, Work work, boolean isApiRequest) { if (workFormSaved.compare(WorkForm.valueOf(work, maxContributorsForUI))) { if (activeSource != null) { - if(!activeSource.equals(workSaved.getSource())) { - throw new OrcidForbiddenException(localeManager.resolveMessage("apiError.9010.developerMessage","work")); + throw new OrcidForbiddenException(localeManager.resolveMessage("apiError.9010.developerMessage").replace("${activity}", "work")); } } From b2adbfeeb27364aaeee6eb1d6bc0839598686dcc Mon Sep 17 00:00:00 2001 From: github actions Date: Wed, 28 Feb 2024 14:12:59 +0000 Subject: [PATCH 6/6] v2.51.6 changelog update --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d8e90c1a70..79a8393a526 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## v2.51.6 - 2024-02-28 + +[Full Changelog](https://github.com/ORCID/ORCID-Source/compare/v2.51.5...v2.51.6) + ## v2.51.5 - 2024-02-28 [Full Changelog](https://github.com/ORCID/ORCID-Source/compare/v2.51.4...v2.51.5)