From e095f54bd644d6a6096b2ae102bddb8f85355e06 Mon Sep 17 00:00:00 2001
From: Camelia Dumitru <62257307+Camelia-Orcid@users.noreply.github.com>
Date: Tue, 26 Mar 2024 15:01:08 +0000
Subject: [PATCH 01/10] mapping to treat diacritics as equivalent for org name
(#7011)
---
.../org/conf/mapping-ISOLatin1Accent.txt | 246 ++++++++++++++++++
solr-config/cores/org/conf/schema.xml | 4 +
2 files changed, 250 insertions(+)
create mode 100644 solr-config/cores/org/conf/mapping-ISOLatin1Accent.txt
diff --git a/solr-config/cores/org/conf/mapping-ISOLatin1Accent.txt b/solr-config/cores/org/conf/mapping-ISOLatin1Accent.txt
new file mode 100644
index 00000000000..ede7742581b
--- /dev/null
+++ b/solr-config/cores/org/conf/mapping-ISOLatin1Accent.txt
@@ -0,0 +1,246 @@
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Syntax:
+# "source" => "target"
+# "source".length() > 0 (source cannot be empty.)
+# "target".length() >= 0 (target can be empty.)
+
+# example:
+# "À" => "A"
+# "\u00C0" => "A"
+# "\u00C0" => "\u0041"
+# "ß" => "ss"
+# "\t" => " "
+# "\n" => ""
+
+# À => A
+"\u00C0" => "A"
+
+# Á => A
+"\u00C1" => "A"
+
+# Â => A
+"\u00C2" => "A"
+
+# Ã => A
+"\u00C3" => "A"
+
+# Ä => A
+"\u00C4" => "A"
+
+# Å => A
+"\u00C5" => "A"
+
+# Æ => AE
+"\u00C6" => "AE"
+
+# Ç => C
+"\u00C7" => "C"
+
+# È => E
+"\u00C8" => "E"
+
+# É => E
+"\u00C9" => "E"
+
+# Ê => E
+"\u00CA" => "E"
+
+# Ë => E
+"\u00CB" => "E"
+
+# Ì => I
+"\u00CC" => "I"
+
+# Í => I
+"\u00CD" => "I"
+
+# Î => I
+"\u00CE" => "I"
+
+# Ï => I
+"\u00CF" => "I"
+
+# IJ => IJ
+"\u0132" => "IJ"
+
+# Ð => D
+"\u00D0" => "D"
+
+# Ñ => N
+"\u00D1" => "N"
+
+# Ò => O
+"\u00D2" => "O"
+
+# Ó => O
+"\u00D3" => "O"
+
+# Ô => O
+"\u00D4" => "O"
+
+# Õ => O
+"\u00D5" => "O"
+
+# Ö => O
+"\u00D6" => "O"
+
+# Ø => O
+"\u00D8" => "O"
+
+# Œ => OE
+"\u0152" => "OE"
+
+# Þ
+"\u00DE" => "TH"
+
+# Ù => U
+"\u00D9" => "U"
+
+# Ú => U
+"\u00DA" => "U"
+
+# Û => U
+"\u00DB" => "U"
+
+# Ü => U
+"\u00DC" => "U"
+
+# Ý => Y
+"\u00DD" => "Y"
+
+# Ÿ => Y
+"\u0178" => "Y"
+
+# à => a
+"\u00E0" => "a"
+
+# á => a
+"\u00E1" => "a"
+
+# â => a
+"\u00E2" => "a"
+
+# ã => a
+"\u00E3" => "a"
+
+# ä => a
+"\u00E4" => "a"
+
+# å => a
+"\u00E5" => "a"
+
+# æ => ae
+"\u00E6" => "ae"
+
+# ç => c
+"\u00E7" => "c"
+
+# è => e
+"\u00E8" => "e"
+
+# é => e
+"\u00E9" => "e"
+
+# ê => e
+"\u00EA" => "e"
+
+# ë => e
+"\u00EB" => "e"
+
+# ì => i
+"\u00EC" => "i"
+
+# í => i
+"\u00ED" => "i"
+
+# î => i
+"\u00EE" => "i"
+
+# ï => i
+"\u00EF" => "i"
+
+# ij => ij
+"\u0133" => "ij"
+
+# ð => d
+"\u00F0" => "d"
+
+# ñ => n
+"\u00F1" => "n"
+
+# ò => o
+"\u00F2" => "o"
+
+# ó => o
+"\u00F3" => "o"
+
+# ô => o
+"\u00F4" => "o"
+
+# õ => o
+"\u00F5" => "o"
+
+# ö => o
+"\u00F6" => "o"
+
+# ø => o
+"\u00F8" => "o"
+
+# œ => oe
+"\u0153" => "oe"
+
+# ß => ss
+"\u00DF" => "ss"
+
+# þ => th
+"\u00FE" => "th"
+
+# ù => u
+"\u00F9" => "u"
+
+# ú => u
+"\u00FA" => "u"
+
+# û => u
+"\u00FB" => "u"
+
+# ü => u
+"\u00FC" => "u"
+
+# ý => y
+"\u00FD" => "y"
+
+# ÿ => y
+"\u00FF" => "y"
+
+# ff => ff
+"\uFB00" => "ff"
+
+# fi => fi
+"\uFB01" => "fi"
+
+# fl => fl
+"\uFB02" => "fl"
+
+# ffi => ffi
+"\uFB03" => "ffi"
+
+# ffl => ffl
+"\uFB04" => "ffl"
+
+# ſt => ft
+"\uFB05" => "ft"
+
+# st => st
+"\uFB06" => "st"
diff --git a/solr-config/cores/org/conf/schema.xml b/solr-config/cores/org/conf/schema.xml
index 173bb8ee6db..c439c93830b 100644
--- a/solr-config/cores/org/conf/schema.xml
+++ b/solr-config/cores/org/conf/schema.xml
@@ -281,12 +281,16 @@
-->
+
+
+
+
From 5b65116b86a2a30f74d92f6141b3a32e7668e8a0 Mon Sep 17 00:00:00 2001
From: github actions
Date: Tue, 26 Mar 2024 15:14:05 +0000
Subject: [PATCH 02/10] v2.55.0 changelog update
---
CHANGELOG.md | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5f9f5e03b6c..0fb7f2020e2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+## v2.55.0 - 2024-03-26
+
+[Full Changelog](https://github.com/ORCID/ORCID-Source/compare/v2.54.0...v2.55.0)
+
## v2.54.0 - 2024-03-19
[Full Changelog](https://github.com/ORCID/ORCID-Source/compare/v2.53.0...v2.54.0)
From 8e7884aa6d71f898f489d27bc883acd1222420cf Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Mon, 1 Apr 2024 09:35:22 -0600
Subject: [PATCH 03/10] Bump guava from 31.1-jre to 32.0.0-jre (#6818)
Bumps [guava](https://github.com/google/guava) from 31.1-jre to 32.0.0-jre.
- [Release notes](https://github.com/google/guava/releases)
- [Commits](https://github.com/google/guava/commits)
---
updated-dependencies:
- dependency-name: com.google.guava:guava
dependency-type: direct:production
...
Signed-off-by: dependabot[bot]
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 4783a7489a8..8db2798b0da 100644
--- a/pom.xml
+++ b/pom.xml
@@ -912,7 +912,7 @@ the software.
com.google.guava
guava
- 31.1-jre
+ 32.0.0-jre
From ea84fb2c999533c54687310470f22b5a87ef741e Mon Sep 17 00:00:00 2001
From: github actions
Date: Mon, 1 Apr 2024 15:55:11 +0000
Subject: [PATCH 04/10] v2.56.0 changelog update
---
CHANGELOG.md | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0fb7f2020e2..bb7bbe5635b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+## v2.56.0 - 2024-04-01
+
+[Full Changelog](https://github.com/ORCID/ORCID-Source/compare/v2.55.0...v2.56.0)
+
## v2.55.0 - 2024-03-26
[Full Changelog](https://github.com/ORCID/ORCID-Source/compare/v2.54.0...v2.55.0)
From ce88ec773fcf031fcc2de89eb121691f74410843 Mon Sep 17 00:00:00 2001
From: Angel Montenegro
Date: Mon, 1 Apr 2024 10:12:55 -0600
Subject: [PATCH 05/10] Multiple fixes202401 (#7013)
* Deactivated records should get 409 on GET requests
* Log short error for some exceptions and fix the affiliation start date validation on registration
---
.../api/common/jaxb/OrcidExceptionMapper.java | 6 +++
.../controllers/RegistrationController.java | 53 +++++++++----------
2 files changed, 32 insertions(+), 27 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 f5d675a56b6..8029a6e5263 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
@@ -35,9 +35,11 @@
import org.orcid.core.exception.OrcidDuplicatedElementException;
import org.orcid.core.exception.OrcidInvalidScopeException;
import org.orcid.core.exception.OrcidNoBioException;
+import org.orcid.core.exception.OrcidNoResultException;
import org.orcid.core.exception.OrcidNonPublicElementException;
import org.orcid.core.exception.OrcidNotClaimedException;
import org.orcid.core.exception.OrcidNotificationException;
+import org.orcid.core.exception.OrcidUnauthorizedException;
import org.orcid.core.exception.OrcidValidationException;
import org.orcid.core.locale.LocaleManager;
import org.orcid.core.manager.OrcidSecurityManager;
@@ -138,6 +140,10 @@ public Response toResponse(Throwable t) {
logShortError(t, clientId);
} else if (t instanceof TokenMgrError) {
logShortError(t, clientId);
+ } else if (t instanceof OrcidNoResultException) {
+ logShortError(t, clientId);
+ } else if (t instanceof OrcidUnauthorizedException) {
+ logShortError(t, clientId);
} else {
LOGGER.error("An exception has occured processing request from client " + clientId, t);
}
diff --git a/orcid-web/src/main/java/org/orcid/frontend/web/controllers/RegistrationController.java b/orcid-web/src/main/java/org/orcid/frontend/web/controllers/RegistrationController.java
index d9af23f4b77..0ee568b55dd 100644
--- a/orcid-web/src/main/java/org/orcid/frontend/web/controllers/RegistrationController.java
+++ b/orcid-web/src/main/java/org/orcid/frontend/web/controllers/RegistrationController.java
@@ -21,12 +21,12 @@
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang.StringUtils;
import org.jasypt.exceptions.EncryptionOperationNotPossibleException;
+import org.orcid.core.common.manager.EventManager;
import org.orcid.core.constants.EmailConstants;
import org.orcid.core.constants.OrcidOauth2Constants;
import org.orcid.core.manager.EncryptionManager;
import org.orcid.core.manager.ProfileEntityCacheManager;
import org.orcid.core.manager.RegistrationManager;
-import org.orcid.core.common.manager.EventManager;
import org.orcid.core.manager.v3.OrcidSearchManager;
import org.orcid.core.manager.v3.ProfileHistoryEventManager;
import org.orcid.core.manager.v3.read_only.AffiliationsManagerReadOnly;
@@ -43,16 +43,12 @@
import org.orcid.frontend.spring.SocialAjaxAuthenticationSuccessHandler;
import org.orcid.frontend.spring.web.social.config.SocialSignInUtils;
import org.orcid.frontend.web.controllers.helper.OauthHelper;
-import org.orcid.frontend.web.controllers.helper.SearchOrcidSolrCriteria;
import org.orcid.frontend.web.util.RecaptchaVerifier;
import org.orcid.jaxb.model.common.AvailableLocales;
import org.orcid.jaxb.model.message.CreationMethod;
import org.orcid.jaxb.model.v3.release.common.Visibility;
-import org.orcid.jaxb.model.v3.release.record.Affiliation;
import org.orcid.jaxb.model.v3.release.record.AffiliationType;
-import org.orcid.jaxb.model.v3.release.record.Employment;
import org.orcid.persistence.constants.SendEmailFrequency;
-import org.orcid.pojo.OrgDisambiguated;
import org.orcid.pojo.Redirect;
import org.orcid.pojo.ajaxForm.AffiliationForm;
import org.orcid.pojo.ajaxForm.Date;
@@ -337,17 +333,17 @@ public void validateRegistrationFields(HttpServletRequest request, Registration
if (!AffiliationType.EMPLOYMENT.equals(AffiliationType.fromValue(affiliationForm.getAffiliationType().getValue()))) {
setError(affiliationForm.getAffiliationType(), "Invalid affiliation type");
}
- if (reg.getAffiliationForm().getDepartmentName() != null) {
+ if (affiliationForm.getDepartmentName() != null) {
if (affiliationForm.getDepartmentName().getValue() != null && affiliationForm.getDepartmentName().getValue().trim().length() > 1000) {
setError(affiliationForm.getDepartmentName(), "common.length_less_1000");
}
}
- if (reg.getAffiliationForm().getRoleTitle() != null) {
+ if (affiliationForm.getRoleTitle() != null) {
if (!PojoUtil.isEmpty(affiliationForm.getRoleTitle()) && affiliationForm.getRoleTitle().getValue().trim().length() > 1000) {
setError(affiliationForm.getRoleTitle(), "common.length_less_1000");
}
}
- if (reg.getAffiliationForm().getStartDate() != null) {
+ if (affiliationForm.getStartDate() != null) {
if(!validDate(affiliationForm.getStartDate())) {
setError(affiliationForm.getStartDate(), "common.dates.invalid");
}
@@ -361,6 +357,9 @@ public void validateRegistrationFields(HttpServletRequest request, Registration
copyErrors(reg.getPassword(), reg);
copyErrors(reg.getPasswordConfirm(), reg);
copyErrors(reg.getTermsOfUse(), reg);
+ if(reg.getAffiliationForm() != null && reg.getAffiliationForm().getStartDate() != null) {
+ copyErrors(reg.getAffiliationForm().getStartDate(), reg);
+ }
additionalEmailsValidateOnRegister(request, reg);
for (Text emailAdditional : reg.getEmailsAdditional()) {
@@ -612,36 +611,36 @@ protected boolean validDate(Date date) {
.toFormatter(),
new DateTimeFormatterBuilder().appendPattern("yyyyMM").parseDefaulting(ChronoField.DAY_OF_MONTH, 1).toFormatter(),
new DateTimeFormatterBuilder().appendPattern("yyyyMMdd").parseStrict().toFormatter() };
- String dateString = date.getYear();
- // If the month is empty and day provided is an invalid date
- if (StringUtils.isBlank(date.getMonth())) {
- if (!StringUtils.isBlank(date.getDay())) {
+ String dateString = date.getYear();
+
+ // If year is blank and month or day is not, then it is invalid
+ if (StringUtils.isBlank(date.getYear())) {
+ if (!StringUtils.isBlank(date.getMonth()) || !StringUtils.isBlank(date.getDay())) {
return false;
}
- }
- else if (StringUtils.isBlank(date.getYear())) {
- if (!StringUtils.isBlank(date.getDay()) && !StringUtils.isBlank(date.getMonth())) {
+ } else if (StringUtils.isBlank(date.getMonth())) {
+ // If the month is empty and day is not empty, then it is invalid
+ if (!StringUtils.isBlank(date.getDay())) {
return false;
}
- }
- else {
- dateString += date.getMonth();
+ } else {
+ dateString += StringUtils.leftPad(date.getMonth(), 2, '0');
if (!StringUtils.isBlank(date.getDay())) {
- dateString += date.getDay();
+ dateString += StringUtils.leftPad(date.getDay(), 2, '0');
}
}
- for (DateTimeFormatter formatter : formatters) {
- try {
- LocalDate localDate = LocalDate.parse(dateString, formatter);
- if (PojoUtil.isEmpty(date.getDay()) || localDate.getDayOfMonth() == Integer.parseInt(date.getDay())) {
- // formatter will correct day to last valid day of month if
- // it is too great
+ if(StringUtils.isBlank(dateString)) {
+ return true;
+ } else {
+ for (DateTimeFormatter formatter : formatters) {
+ try {
+ LocalDate.parse(dateString, formatter);
return true;
+ } catch (DateTimeParseException e) {
}
- } catch (DateTimeParseException e) {
}
- }
+ }
return false;
}
From d43c7a29a08ea02eddc204e65bdc149a7537e8f4 Mon Sep 17 00:00:00 2001
From: github actions
Date: Mon, 1 Apr 2024 16:25:29 +0000
Subject: [PATCH 06/10] v2.57.0 changelog update
---
CHANGELOG.md | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index bb7bbe5635b..bf2066c2e28 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+## v2.57.0 - 2024-04-01
+
+[Full Changelog](https://github.com/ORCID/ORCID-Source/compare/v2.56.0...v2.57.0)
+
## v2.56.0 - 2024-04-01
[Full Changelog](https://github.com/ORCID/ORCID-Source/compare/v2.55.0...v2.56.0)
From 4702228002a96c510452b80be2098ec6b4476788 Mon Sep 17 00:00:00 2001
From: Leonardo Mendoza Fernadez
Date: Wed, 3 Apr 2024 16:44:57 -0600
Subject: [PATCH 07/10]
9181-prod-old-header-layout-displayed-briefly-on-public-page
---
orcid-core/src/main/java/org/orcid/core/togglz/Features.java | 2 --
1 file changed, 2 deletions(-)
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 a8f6a15f7f7..424448ff27e 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
@@ -19,8 +19,6 @@ public enum Features implements Feature {
@Label("Registration 2.1: Add affiliations on registration")
REGISTRATION_2_1,
- @Label("New public record header")
- NEW_RECORD_HEADER,
@Label("Registration 2.0")
REGISTRATION_2_0,
From e2208b0f8d39dd6880ad866662a13979edb9e695 Mon Sep 17 00:00:00 2001
From: github actions
Date: Wed, 3 Apr 2024 23:04:11 +0000
Subject: [PATCH 08/10] v2.57.1 changelog update
---
CHANGELOG.md | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index bf2066c2e28..a08b59d5944 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,9 @@
+## v2.57.1 - 2024-04-03
+
+[Full Changelog](https://github.com/ORCID/ORCID-Source/compare/v2.57.0...v2.57.1)
+
+- [#7017](https://github.com/ORCID/ORCID-Source/pull/7017): 9181-prod-old-header-layout-displayed-briefly-on-public-page
+
## v2.57.0 - 2024-04-01
[Full Changelog](https://github.com/ORCID/ORCID-Source/compare/v2.56.0...v2.57.0)
From ceb7ce361e96d02ecc61a198accb0763bf96b773 Mon Sep 17 00:00:00 2001
From: Daniel Palafox
Date: Wed, 3 Apr 2024 19:34:54 -0600
Subject: [PATCH 09/10] feature: Start collection daily pub api stats (#7016)
* feature: Start collection daily pub api stats
* fix: Delete event stats in tests
* fix: Remove unused class
* feature: Add ip table to event and event_stats
---------
Co-authored-by: Daniel Palafox
---
.../core/common/manager/EventManager.java | 4 +-
.../common/manager/impl/EventManagerImpl.java | 13 +-
.../java/org/orcid/core/togglz/Features.java | 5 +-
.../org/orcid/persistence/dao/EventDao.java | 5 +
.../orcid/persistence/dao/EventStatsDao.java | 5 +
.../persistence/dao/impl/EventDaoImpl.java | 21 +-
.../dao/impl/EventStatsDaoImpl.java | 53 ++-
.../persistence/jpa/entities/EventEntity.java | 10 +
.../jpa/entities/EventStatsEntity.java | 10 +
.../persistence/jpa/entities}/EventType.java | 7 +-
.../src/main/resources/db-master.xml | 2 +
.../db/updates/add_ip_col_in_events.xml | 23 +
.../db/updates/dw_papi_event_stats.xml | 45 ++
.../orcid/persistence/dao/EventDaoTest.java | 16 +
.../persistence/dao/EventStatsDaoTest.java | 76 +++-
.../server/PublicV3ApiServiceImplV3_0.java | 58 ++-
.../PublicV3ApiServiceDelegator.java | 3 +
.../impl/PublicV3ApiServiceDelegatorImpl.java | 14 +
...licV3ApiServiceVersionedDelegatorImpl.java | 420 ------------------
.../orcid/scheduler/web/event/EventStats.java | 4 +
.../web/event/impl/EventStatsImpl.java | 28 +-
.../resources/orcid-scheduler-context.xml | 2 +
.../main/resources/data/EventEntityData.xml | 19 +
.../frontend/oauth2/OauthController.java | 2 +-
.../AjaxAuthenticationSuccessHandler.java | 2 +-
...olethAjaxAuthenticationSuccessHandler.java | 2 +-
.../web/controllers/LoginController.java | 2 +-
.../controllers/OauthAuthorizeController.java | 2 +-
.../controllers/PublicRecordController.java | 2 +-
.../controllers/RegistrationController.java | 2 +-
.../web/controllers/ShibbolethController.java | 2 +-
31 files changed, 414 insertions(+), 445 deletions(-)
rename {orcid-core/src/main/java/org/orcid/core/utils => orcid-persistence/src/main/java/org/orcid/persistence/jpa/entities}/EventType.java (76%)
create mode 100644 orcid-persistence/src/main/resources/db/updates/add_ip_col_in_events.xml
create mode 100644 orcid-persistence/src/main/resources/db/updates/dw_papi_event_stats.xml
delete mode 100644 orcid-pub-web/src/main/java/org/orcid/api/publicV3/server/delegator/impl/PublicV3ApiServiceVersionedDelegatorImpl.java
diff --git a/orcid-core/src/main/java/org/orcid/core/common/manager/EventManager.java b/orcid-core/src/main/java/org/orcid/core/common/manager/EventManager.java
index 51439b40d4b..544c1e3302d 100644
--- a/orcid-core/src/main/java/org/orcid/core/common/manager/EventManager.java
+++ b/orcid-core/src/main/java/org/orcid/core/common/manager/EventManager.java
@@ -2,7 +2,7 @@
import javax.servlet.http.HttpServletRequest;
-import org.orcid.core.utils.EventType;
+import org.orcid.persistence.jpa.entities.EventType;
/**
*
@@ -13,4 +13,6 @@ public interface EventManager {
void createEvent(EventType eventType, HttpServletRequest request);
+ void createPapiEvent(String clientId, String ip, boolean anonymous);
+
}
diff --git a/orcid-core/src/main/java/org/orcid/core/common/manager/impl/EventManagerImpl.java b/orcid-core/src/main/java/org/orcid/core/common/manager/impl/EventManagerImpl.java
index 82cd09d7501..ef94b970d14 100644
--- a/orcid-core/src/main/java/org/orcid/core/common/manager/impl/EventManagerImpl.java
+++ b/orcid-core/src/main/java/org/orcid/core/common/manager/impl/EventManagerImpl.java
@@ -13,12 +13,12 @@
import org.orcid.core.constants.OrcidOauth2Constants;
import org.orcid.core.manager.ClientDetailsEntityCacheManager;
import org.orcid.core.manager.v3.read_only.RecordNameManagerReadOnly;
-import org.orcid.core.utils.EventType;
import org.orcid.jaxb.model.clientgroup.ClientType;
import org.orcid.jaxb.model.v3.release.record.Name;
import org.orcid.persistence.dao.EventDao;
import org.orcid.persistence.jpa.entities.ClientDetailsEntity;
import org.orcid.persistence.jpa.entities.EventEntity;
+import org.orcid.persistence.jpa.entities.EventType;
import org.orcid.pojo.ajaxForm.PojoUtil;
import org.orcid.pojo.ajaxForm.RequestInfoForm;
@@ -105,4 +105,15 @@ private String removeAttributesFromUrl(String url) {
}
return url;
}
+
+ @Override
+ public void createPapiEvent(String clientId, String ip, boolean anonymous) {
+ EventEntity eventEntity = new EventEntity();
+ eventEntity.setEventType(EventType.PAPI.getValue());
+ eventEntity.setClientId(clientId);
+ eventEntity.setIp(ip);
+ eventEntity.setLabel(anonymous ? "anonymous" : null);
+ eventEntity.setDateCreated(new Date());
+ eventDao.createEvent(eventEntity);
+ }
}
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 424448ff27e..42e0745b55d 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
@@ -54,7 +54,10 @@ public enum Features implements Feature {
SEND_ADD_WORKS_EMAILS,
@Label("Delete events older than 90 days from the DB ")
- DELETE_EVENTS;
+ DELETE_EVENTS,
+
+ @Label("Track public events stats ")
+ PAPI_EVENTS;
public boolean isActive() {
return FeatureContext.getFeatureManager().isActive(this);
diff --git a/orcid-persistence/src/main/java/org/orcid/persistence/dao/EventDao.java b/orcid-persistence/src/main/java/org/orcid/persistence/dao/EventDao.java
index 78a2bf775f6..a363136f35b 100644
--- a/orcid-persistence/src/main/java/org/orcid/persistence/dao/EventDao.java
+++ b/orcid-persistence/src/main/java/org/orcid/persistence/dao/EventDao.java
@@ -1,6 +1,7 @@
package org.orcid.persistence.dao;
import org.orcid.persistence.jpa.entities.EventEntity;
+import org.orcid.persistence.jpa.entities.EventType;
import java.util.List;
@@ -18,6 +19,10 @@ public interface EventDao {
void delete(long id);
List findAll();
+
+ List findByEventType(EventType eventType);
void deleteEventsByDate(Integer numberOfDays);
+
+ void deletePapiEvents(Integer numberOfDays);
}
diff --git a/orcid-persistence/src/main/java/org/orcid/persistence/dao/EventStatsDao.java b/orcid-persistence/src/main/java/org/orcid/persistence/dao/EventStatsDao.java
index c0c77b7730f..d0b4e24c867 100644
--- a/orcid-persistence/src/main/java/org/orcid/persistence/dao/EventStatsDao.java
+++ b/orcid-persistence/src/main/java/org/orcid/persistence/dao/EventStatsDao.java
@@ -1,6 +1,7 @@
package org.orcid.persistence.dao;
import org.orcid.persistence.jpa.entities.EventStatsEntity;
+import org.orcid.persistence.jpa.entities.EventType;
import java.util.List;
@@ -13,5 +14,9 @@ public interface EventStatsDao {
void createEventStats();
+ void createPapiEventStats();
+
List findAll();
+
+ void deleteStatsByType(EventType eventType);
}
diff --git a/orcid-persistence/src/main/java/org/orcid/persistence/dao/impl/EventDaoImpl.java b/orcid-persistence/src/main/java/org/orcid/persistence/dao/impl/EventDaoImpl.java
index e3e71561c4e..ef2b15ce69e 100644
--- a/orcid-persistence/src/main/java/org/orcid/persistence/dao/impl/EventDaoImpl.java
+++ b/orcid-persistence/src/main/java/org/orcid/persistence/dao/impl/EventDaoImpl.java
@@ -7,6 +7,7 @@
import org.orcid.persistence.dao.EventDao;
import org.orcid.persistence.jpa.entities.EventEntity;
+import org.orcid.persistence.jpa.entities.EventType;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@@ -49,9 +50,27 @@ public List findAll() {
@Override
@Transactional
public void deleteEventsByDate(Integer numberOfDays) {
- String query = "DELETE FROM event where CAST(date_created as date) < CAST(now() - (CAST('1' AS INTERVAL DAY) * :numberOfDays) as date)";
+ String query = "DELETE FROM event where CAST(date_created as date) < CAST(now() - (CAST('1' AS INTERVAL DAY) * :numberOfDays) as date) AND event_type != :eventType";
Query queryDelete = entityManager.createNativeQuery(query);
+ queryDelete.setParameter("eventType", EventType.PAPI.getValue());
queryDelete.setParameter("numberOfDays", numberOfDays);
queryDelete.executeUpdate();
}
+
+ @Override
+ @Transactional
+ public void deletePapiEvents(Integer numberOfDays) {
+ String query = "DELETE FROM event where CAST(date_created as date) < CAST(now() - (CAST('1' AS INTERVAL DAY) * :numberOfDays) as date) AND event_type = :eventType";
+ Query queryDelete = entityManager.createNativeQuery(query);
+ queryDelete.setParameter("eventType", EventType.PAPI.getValue());
+ queryDelete.setParameter("numberOfDays", numberOfDays);
+ queryDelete.executeUpdate();
+ }
+
+ @Override
+ public List findByEventType(EventType eventType) {
+ TypedQuery query = entityManager.createQuery("from EventEntity where eventType = :eventType", EventEntity.class);
+ query.setParameter("eventType", eventType.getValue());
+ return query.getResultList();
+ }
}
diff --git a/orcid-persistence/src/main/java/org/orcid/persistence/dao/impl/EventStatsDaoImpl.java b/orcid-persistence/src/main/java/org/orcid/persistence/dao/impl/EventStatsDaoImpl.java
index 2e68e076ad5..5245acc6e8e 100644
--- a/orcid-persistence/src/main/java/org/orcid/persistence/dao/impl/EventStatsDaoImpl.java
+++ b/orcid-persistence/src/main/java/org/orcid/persistence/dao/impl/EventStatsDaoImpl.java
@@ -1,6 +1,7 @@
package org.orcid.persistence.dao.impl;
import org.orcid.persistence.dao.EventStatsDao;
+import org.orcid.persistence.jpa.entities.EventType;
import org.orcid.persistence.jpa.entities.EventStatsEntity;
import org.springframework.transaction.annotation.Transactional;
@@ -8,6 +9,9 @@
import javax.persistence.EntityManager;
import javax.persistence.Query;
import javax.persistence.TypedQuery;
+
+import java.math.BigInteger;
+import java.util.ArrayList;
import java.util.List;
/**
@@ -25,9 +29,11 @@ public void createEventStats() {
"INSERT INTO event_stats (event_type, client_id, count, date, date_created, last_modified) " +
"SELECT event_type, client_id, COUNT(id), CAST(e.date_created as date), now(), now() " +
"FROM event as e " +
- "WHERE CAST(e.date_created as date) = CAST(now() - (CAST('1' AS INTERVAL DAY) * 1) as date) " +
+ "WHERE event_type != '"+ EventType.PAPI.getValue() + "' " +
+ "AND CAST(e.date_created as date) = CAST(now() - (CAST('1' AS INTERVAL DAY) * 1) as date) " +
"GROUP BY event_type, client_id, CAST(e.date_created as date) " +
"ORDER BY CAST(e.date_created as date) DESC;";
+
Query insertQuery = entityManager.createNativeQuery(query);
insertQuery.executeUpdate();
}
@@ -37,4 +43,49 @@ public List findAll() {
TypedQuery query = entityManager.createQuery("from EventStatsEntity", EventStatsEntity.class);
return query.getResultList();
}
+
+ @Override
+ @Transactional
+ public void createPapiEventStats() {
+ String query =
+ "SELECT event_type, client_id, ip, label, count(*), CAST(date_created as date), now(), now() " +
+ "FROM event " +
+ "WHERE event_type = '"+ EventType.PAPI.getValue() + "' " +
+ "AND CAST(date_created as date) = CAST(now() - (CAST('1' AS INTERVAL DAY) * 1) as date) " +
+ "GROUP BY event_type, client_id, ip, label, CAST(date_created as date) " +
+ "ORDER BY CAST(date_created as date) DESC;";
+
+ Query queryList = entityManager.createNativeQuery(query);
+ List