From 6c95c04fa2d9044ea0196b5fe493d7ea30b759f6 Mon Sep 17 00:00:00 2001 From: Daniel Palafox Date: Tue, 2 Apr 2024 12:17:55 -0600 Subject: [PATCH] feature: Start collection daily pub api stats --- .../core/common/manager/EventManager.java | 4 +- .../common/manager/impl/EventManagerImpl.java | 12 +++- .../java/org/orcid/core/togglz/Features.java | 5 +- .../org/orcid/persistence/dao/EventDao.java | 5 ++ .../orcid/persistence/dao/EventStatsDao.java | 2 + .../persistence/dao/impl/EventDaoImpl.java | 21 ++++++- .../dao/impl/EventStatsDaoImpl.java | 43 +++++++++++++- .../persistence/jpa/entities}/EventType.java | 7 ++- .../src/main/resources/db-master.xml | 1 + .../db/updates/dw_papi_event_stats.xml | 45 ++++++++++++++ .../orcid/persistence/dao/EventDaoTest.java | 16 +++++ .../persistence/dao/EventStatsDaoTest.java | 56 +++++++++++++++++- .../server/PublicV3ApiServiceImplV3_0.java | 58 ++++++++++++++++++- .../PublicV3ApiServiceDelegator.java | 3 + .../impl/PublicV3ApiServiceDelegatorImpl.java | 18 ++++++ .../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 +- 27 files changed, 341 insertions(+), 24 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/dw_papi_event_stats.xml 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..b2added5546 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, 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..b842ca4c792 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,14 @@ private String removeAttributesFromUrl(String url) { } return url; } + + @Override + public void createPapiEvent(String clientId, boolean anonymous) { + EventEntity eventEntity = new EventEntity(); + eventEntity.setEventType(EventType.PAPI.getValue()); + eventEntity.setClientId(clientId); + 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 c8400e5889b..23f885383b1 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 @@ -53,7 +53,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..4a631978096 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 @@ -13,5 +13,7 @@ public interface EventStatsDao { void createEventStats(); + void createPapiEventStats(); + List findAll(); } 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..19871339940 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,39 @@ 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, 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, label, CAST(date_created as date) " + + "ORDER BY CAST(date_created as date) DESC;"; + + Query queryList = entityManager.createNativeQuery(query); + List eventsList = queryList.getResultList(); + List eventsListToRemove = new ArrayList<>(); + if (eventsList.size() > 0) { + eventsList.forEach(item -> { + if (item[2] == "anonymous" && item[3] != null && ((BigInteger) item[3]).intValue() < 1000) { + eventsListToRemove.add(item); + } + }); + eventsList.removeAll(eventsListToRemove); + eventsList.forEach(item -> { + String insertQuery = "INSERT INTO event_stats (event_type, client_id, count, date, date_created, last_modified) VALUES (:eventType, :clientId, :count, :date, :dateCreated, :lastModified)"; + Query insertQueryClients = entityManager.createNativeQuery(insertQuery); + insertQueryClients.setParameter("eventType", item[0]); + insertQueryClients.setParameter("clientId", item[1]); + insertQueryClients.setParameter("count", item[3]); + insertQueryClients.setParameter("date", item[4]); + insertQueryClients.setParameter("dateCreated", item[5]); + insertQueryClients.setParameter("lastModified", item[6]); + insertQueryClients.executeUpdate(); + }); + } + } } diff --git a/orcid-core/src/main/java/org/orcid/core/utils/EventType.java b/orcid-persistence/src/main/java/org/orcid/persistence/jpa/entities/EventType.java similarity index 76% rename from orcid-core/src/main/java/org/orcid/core/utils/EventType.java rename to orcid-persistence/src/main/java/org/orcid/persistence/jpa/entities/EventType.java index d5c248dd171..6166e64d144 100644 --- a/orcid-core/src/main/java/org/orcid/core/utils/EventType.java +++ b/orcid-persistence/src/main/java/org/orcid/persistence/jpa/entities/EventType.java @@ -1,4 +1,4 @@ -package org.orcid.core.utils; +package org.orcid.persistence.jpa.entities; public enum EventType { SIGN_IN("Sign-In"), @@ -6,7 +6,8 @@ public enum EventType { AUTHORIZE("Authorize"), AUTHORIZE_DENY("Authorize-Deny"), REAUTHORIZE("Reauthorize"), - PUBLIC_PAGE("Public-Page"); + PUBLIC_PAGE("Public-Page"), + PAPI("Public-API"); private final String value; @@ -17,4 +18,4 @@ public enum EventType { public String getValue() { return value; } -} +} \ No newline at end of file diff --git a/orcid-persistence/src/main/resources/db-master.xml b/orcid-persistence/src/main/resources/db-master.xml index 44b53d3e311..7a97b36f35e 100644 --- a/orcid-persistence/src/main/resources/db-master.xml +++ b/orcid-persistence/src/main/resources/db-master.xml @@ -385,4 +385,5 @@ + diff --git a/orcid-persistence/src/main/resources/db/updates/dw_papi_event_stats.xml b/orcid-persistence/src/main/resources/db/updates/dw_papi_event_stats.xml new file mode 100644 index 00000000000..921b7d03fc4 --- /dev/null +++ b/orcid-persistence/src/main/resources/db/updates/dw_papi_event_stats.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + SELECT event_type, client_id, count, DATE_TRUNC('day', date), DATE_TRUNC('day', date) as last_modified + FROM event_stats WHERE event_type != 'Public-API' + ORDER BY DATE_TRUNC('day', date_created) DESC; + + + + + + SELECT 1 FROM pg_roles WHERE rolname='dw_user' + + GRANT SELECT ON TABLE dw_event_stats to dw_user; + + + + + + + + SELECT event_type, client_id, count, DATE_TRUNC('day', date), DATE_TRUNC('day', date) as last_modified + FROM event_stats WHERE event_type = 'Public-API' + ORDER BY DATE_TRUNC('day', date_created) DESC; + + + + + + SELECT 1 FROM pg_roles WHERE rolname='dw_user' + + GRANT SELECT ON TABLE dw_papi_event_stats to dw_user; + + + \ No newline at end of file diff --git a/orcid-persistence/src/test/java/org/orcid/persistence/dao/EventDaoTest.java b/orcid-persistence/src/test/java/org/orcid/persistence/dao/EventDaoTest.java index 025c8b0d440..e672c47654a 100644 --- a/orcid-persistence/src/test/java/org/orcid/persistence/dao/EventDaoTest.java +++ b/orcid-persistence/src/test/java/org/orcid/persistence/dao/EventDaoTest.java @@ -17,6 +17,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.orcid.persistence.jpa.entities.EventEntity; +import org.orcid.persistence.jpa.entities.EventType; import org.orcid.test.DBUnitTest; import org.orcid.test.OrcidJUnit4ClassRunner; import org.springframework.test.context.ContextConfiguration; @@ -81,4 +82,19 @@ public void testWriteEvent() throws IllegalAccessException { eventDao.delete(eventEntity.getId()); } + + @Test + public void deletePapiEventsByDate() { + List eventEntityList = eventDao.findByEventType(EventType.PAPI); + + assertNotNull(eventEntityList); + assertEquals(3, eventEntityList.size()); + + eventDao.deletePapiEvents(90); + + eventEntityList = eventDao.findByEventType(EventType.PAPI); + + assertNotNull(eventEntityList); + assertEquals(0, eventEntityList.size()); + } } diff --git a/orcid-persistence/src/test/java/org/orcid/persistence/dao/EventStatsDaoTest.java b/orcid-persistence/src/test/java/org/orcid/persistence/dao/EventStatsDaoTest.java index 780f294d37a..9c1409a8479 100644 --- a/orcid-persistence/src/test/java/org/orcid/persistence/dao/EventStatsDaoTest.java +++ b/orcid-persistence/src/test/java/org/orcid/persistence/dao/EventStatsDaoTest.java @@ -36,14 +36,64 @@ public void createEventStats() { List eventStatsEntityList = eventStatsDao.findAll(); assertNotNull(eventStatsEntityList); - assertEquals(1, eventStatsEntityList.size()); + assertEquals(2, eventStatsEntityList.size()); assertEquals(Integer.valueOf(20), eventStatsEntityList.get(0).getCount()); + assertEquals(Integer.valueOf(20), eventStatsEntityList.get(1).getCount()); } - private void createEvents() { + @Test + public void createPapiEventStats() { + createPapiEvents(); + + eventStatsDao.createPapiEventStats(); + + List eventStatsEntityList = eventStatsDao.findAll(); + + assertNotNull(eventStatsEntityList); + assertEquals(3, eventStatsEntityList.size()); + assertEquals(Integer.valueOf(10), eventStatsEntityList.get(0).getCount()); + assertEquals(Integer.valueOf(10), eventStatsEntityList.get(1).getCount()); + assertEquals(Integer.valueOf(1100), eventStatsEntityList.get(2).getCount()); + } + + private void createPapiEvents() { for (int i = 0; i < 20; i++) { EventEntity eventEntity = new EventEntity(); - eventEntity.setEventType("Sign-In"); + eventEntity.setEventType("Public-API"); + eventEntity.setClientId("Client " + (i % 2 == 0 ? 1 : 2)); + LocalDate date = LocalDate.now().minusDays(1); + Instant instant = date.atStartOfDay(ZoneId.systemDefault()).toInstant(); + eventEntity.setDateCreated(Date.from(instant)); + eventDao.createEvent(eventEntity); + } + + for (int i = 0; i < 10; i++) { + EventEntity eventEntity = new EventEntity(); + eventEntity.setEventType("Public-API"); + eventEntity.setClientId("105.21.229.71"); + eventEntity.setLabel("anonymous"); + LocalDate date = LocalDate.now().minusDays(1); + Instant instant = date.atStartOfDay(ZoneId.systemDefault()).toInstant(); + eventEntity.setDateCreated(Date.from(instant)); + eventDao.createEvent(eventEntity); + } + + for (int i = 0; i < 1100; i++) { + EventEntity eventEntity = new EventEntity(); + eventEntity.setEventType("Public-API"); + eventEntity.setClientId("104.20.228.70"); + eventEntity.setLabel("anonymous"); + LocalDate date = LocalDate.now().minusDays(1); + Instant instant = date.atStartOfDay(ZoneId.systemDefault()).toInstant(); + eventEntity.setDateCreated(Date.from(instant)); + eventDao.createEvent(eventEntity); + } + } + + private void createEvents() { + for (int i = 0; i < 40; i++) { + EventEntity eventEntity = new EventEntity(); + eventEntity.setEventType(i % 2 == 0 ? "Sign-In" : "Public-PAPI"); eventEntity.setClientId("Client " + 1); LocalDate date = LocalDate.now().minusDays(1); Instant instant = date.atStartOfDay(ZoneId.systemDefault()).toInstant(); diff --git a/orcid-pub-web/src/main/java/org/orcid/api/publicV3/server/PublicV3ApiServiceImplV3_0.java b/orcid-pub-web/src/main/java/org/orcid/api/publicV3/server/PublicV3ApiServiceImplV3_0.java index 1507919ad57..7581c577c7b 100644 --- a/orcid-pub-web/src/main/java/org/orcid/api/publicV3/server/PublicV3ApiServiceImplV3_0.java +++ b/orcid-pub-web/src/main/java/org/orcid/api/publicV3/server/PublicV3ApiServiceImplV3_0.java @@ -125,7 +125,6 @@ public class PublicV3ApiServiceImplV3_0 { public Response viewSwagger() { return swaggerUIBuilder.build(); } - @GET @Produces(value = { MediaType.APPLICATION_JSON }) @@ -149,6 +148,7 @@ public Response viewStatusJson() { @Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON }) @Path(ACTIVITIES) public Response viewActivities(@PathParam("orcid") String orcid, @Context HttpServletRequest httpRequest) { + serviceDelegator.trackEvents(httpRequest); return serviceDelegator.viewActivities(orcid); } @@ -157,6 +157,7 @@ public Response viewActivities(@PathParam("orcid") String orcid, @Context HttpSe OrcidApiConstants.APPLICATION_CITEPROC }) @Path(WORK + PUTCODE) public Response viewWork(@PathParam("orcid") String orcid, @PathParam("putCode") Long putCode, @Context HttpServletRequest httpRequest) { + serviceDelegator.trackEvents(httpRequest); if (OrcidApiConstants.APPLICATION_CITEPROC.equals(httpRequest.getHeader("Accept"))) return serviceDelegator.viewWorkCitation(orcid, putCode); return serviceDelegator.viewWork(orcid, putCode); @@ -166,6 +167,7 @@ public Response viewWork(@PathParam("orcid") String orcid, @PathParam("putCode") @Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON }) @Path(WORK_SUMMARY + PUTCODE) public Response viewWorkSummary(@PathParam("orcid") String orcid, @PathParam("putCode") Long putCode) { + serviceDelegator.trackEvents(httpRequest); return serviceDelegator.viewWorkSummary(orcid, putCode); } @@ -173,6 +175,7 @@ public Response viewWorkSummary(@PathParam("orcid") String orcid, @PathParam("pu @Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON }) @Path(WORKS) public Response viewWorks(@PathParam("orcid") String orcid) { + serviceDelegator.trackEvents(httpRequest); return serviceDelegator.viewWorks(orcid); } @@ -180,6 +183,7 @@ public Response viewWorks(@PathParam("orcid") String orcid) { @Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON }) @Path(BULK_WORKS) public Response viewSpecifiedWorks(@PathParam("orcid") String orcid, @PathParam("putCodes") String putCodes) { + serviceDelegator.trackEvents(httpRequest); return serviceDelegator.viewBulkWorks(orcid, putCodes); } @@ -187,6 +191,7 @@ public Response viewSpecifiedWorks(@PathParam("orcid") String orcid, @PathParam( @Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON }) @Path(FUNDING + PUTCODE) public Response viewFunding(@PathParam("orcid") String orcid, @PathParam("putCode") Long putCode) { + serviceDelegator.trackEvents(httpRequest); return serviceDelegator.viewFunding(orcid, putCode); } @@ -194,13 +199,15 @@ public Response viewFunding(@PathParam("orcid") String orcid, @PathParam("putCod @Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON }) @Path(FUNDING_SUMMARY + PUTCODE) public Response viewFundingSummary(@PathParam("orcid") String orcid, @PathParam("putCode") Long putCode) { + serviceDelegator.trackEvents(httpRequest); return serviceDelegator.viewFundingSummary(orcid, putCode); } @GET @Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON }) @Path(FUNDINGS) - public Response viewFundings(@PathParam("orcid") String orcid) { + public Response viewFundings(@PathParam("orcid") String orcid) { + serviceDelegator.trackEvents(httpRequest); return serviceDelegator.viewFundings(orcid); } @@ -208,6 +215,7 @@ public Response viewFundings(@PathParam("orcid") String orcid) { @Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON }) @Path(EDUCATION + PUTCODE) public Response viewEducation(@PathParam("orcid") String orcid, @PathParam("putCode") Long putCode) { + serviceDelegator.trackEvents(httpRequest); return serviceDelegator.viewEducation(orcid, putCode); } @@ -215,6 +223,7 @@ public Response viewEducation(@PathParam("orcid") String orcid, @PathParam("putC @Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON }) @Path(EDUCATION_SUMMARY + PUTCODE) public Response viewEducationSummary(@PathParam("orcid") String orcid, @PathParam("putCode") Long putCode) { + serviceDelegator.trackEvents(httpRequest); return serviceDelegator.viewEducationSummary(orcid, putCode); } @@ -222,6 +231,7 @@ public Response viewEducationSummary(@PathParam("orcid") String orcid, @PathPara @Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON }) @Path(EDUCATIONS) public Response viewEducations(@PathParam("orcid") String orcid) { + serviceDelegator.trackEvents(httpRequest); return serviceDelegator.viewEducations(orcid); } @@ -229,6 +239,7 @@ public Response viewEducations(@PathParam("orcid") String orcid) { @Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON }) @Path(EMPLOYMENT + PUTCODE) public Response viewEmployment(@PathParam("orcid") String orcid, @PathParam("putCode") Long putCode) { + serviceDelegator.trackEvents(httpRequest); return serviceDelegator.viewEmployment(orcid, putCode); } @@ -236,6 +247,7 @@ public Response viewEmployment(@PathParam("orcid") String orcid, @PathParam("put @Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON }) @Path(EMPLOYMENT_SUMMARY + PUTCODE) public Response viewEmploymentSummary(@PathParam("orcid") String orcid, @PathParam("putCode") Long putCode) { + serviceDelegator.trackEvents(httpRequest); return serviceDelegator.viewEmploymentSummary(orcid, putCode); } @@ -243,6 +255,7 @@ public Response viewEmploymentSummary(@PathParam("orcid") String orcid, @PathPar @Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON }) @Path(EMPLOYMENTS) public Response viewEmployments(@PathParam("orcid") String orcid) { + serviceDelegator.trackEvents(httpRequest); return serviceDelegator.viewEmployments(orcid); } @@ -250,6 +263,7 @@ public Response viewEmployments(@PathParam("orcid") String orcid) { @Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON }) @Path(PEER_REVIEW + PUTCODE) public Response viewPeerReview(@PathParam("orcid") String orcid, @PathParam("putCode") Long putCode) { + serviceDelegator.trackEvents(httpRequest); return serviceDelegator.viewPeerReview(orcid, putCode); } @@ -257,6 +271,7 @@ public Response viewPeerReview(@PathParam("orcid") String orcid, @PathParam("put @Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON }) @Path(PEER_REVIEW_SUMMARY + PUTCODE) public Response viewPeerReviewSummary(@PathParam("orcid") String orcid, @PathParam("putCode") Long putCode) { + serviceDelegator.trackEvents(httpRequest); return serviceDelegator.viewPeerReviewSummary(orcid, putCode); } @@ -264,6 +279,7 @@ public Response viewPeerReviewSummary(@PathParam("orcid") String orcid, @PathPar @Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON }) @Path(PEER_REVIEWS) public Response viewPeerReviews(@PathParam("orcid") String orcid) { + serviceDelegator.trackEvents(httpRequest); return serviceDelegator.viewPeerReviews(orcid); } @@ -271,6 +287,7 @@ public Response viewPeerReviews(@PathParam("orcid") String orcid) { @Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON }) @Path(RESEARCHER_URLS) public Response viewResearcherUrls(@PathParam("orcid") String orcid) { + serviceDelegator.trackEvents(httpRequest); return serviceDelegator.viewResearcherUrls(orcid); } @@ -278,6 +295,7 @@ public Response viewResearcherUrls(@PathParam("orcid") String orcid) { @Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON }) @Path(RESEARCHER_URLS + PUTCODE) public Response viewResearcherUrl(@PathParam("orcid") String orcid, @PathParam("putCode") String putCode) { + serviceDelegator.trackEvents(httpRequest); return serviceDelegator.viewResearcherUrl(orcid, Long.valueOf(putCode)); } @@ -285,6 +303,7 @@ public Response viewResearcherUrl(@PathParam("orcid") String orcid, @PathParam(" @Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON }) @Path(EMAIL) public Response viewEmails(@PathParam("orcid") String orcid) { + serviceDelegator.trackEvents(httpRequest); return serviceDelegator.viewEmails(orcid); } @@ -292,6 +311,7 @@ public Response viewEmails(@PathParam("orcid") String orcid) { @Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON }) @Path(PERSONAL_DETAILS) public Response viewPersonalDetails(@PathParam("orcid") String orcid) { + serviceDelegator.trackEvents(httpRequest); return serviceDelegator.viewPersonalDetails(orcid); } @@ -299,6 +319,7 @@ public Response viewPersonalDetails(@PathParam("orcid") String orcid) { @Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON }) @Path(OTHER_NAMES) public Response viewOtherNames(@PathParam("orcid") String orcid) { + serviceDelegator.trackEvents(httpRequest); return serviceDelegator.viewOtherNames(orcid); } @@ -306,6 +327,7 @@ public Response viewOtherNames(@PathParam("orcid") String orcid) { @Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON }) @Path(OTHER_NAMES + PUTCODE) public Response viewOtherName(@PathParam("orcid") String orcid, @PathParam("putCode") String putCode) { + serviceDelegator.trackEvents(httpRequest); return serviceDelegator.viewOtherName(orcid, Long.valueOf(putCode)); } @@ -313,6 +335,7 @@ public Response viewOtherName(@PathParam("orcid") String orcid, @PathParam("putC @Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON }) @Path(EXTERNAL_IDENTIFIERS) public Response viewExternalIdentifiers(@PathParam("orcid") String orcid) { + serviceDelegator.trackEvents(httpRequest); return serviceDelegator.viewExternalIdentifiers(orcid); } @@ -320,6 +343,7 @@ public Response viewExternalIdentifiers(@PathParam("orcid") String orcid) { @Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON }) @Path(EXTERNAL_IDENTIFIERS + PUTCODE) public Response viewExternalIdentifier(@PathParam("orcid") String orcid, @PathParam("putCode") String putCode) { + serviceDelegator.trackEvents(httpRequest); return serviceDelegator.viewExternalIdentifier(orcid, Long.valueOf(putCode)); } @@ -327,6 +351,7 @@ public Response viewExternalIdentifier(@PathParam("orcid") String orcid, @PathPa @Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON }) @Path(KEYWORDS) public Response viewKeywords(@PathParam("orcid") String orcid) { + serviceDelegator.trackEvents(httpRequest); return serviceDelegator.viewKeywords(orcid); } @@ -334,6 +359,7 @@ public Response viewKeywords(@PathParam("orcid") String orcid) { @Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON }) @Path(KEYWORDS + PUTCODE) public Response viewKeyword(@PathParam("orcid") String orcid, @PathParam("putCode") String putCode) { + serviceDelegator.trackEvents(httpRequest); return serviceDelegator.viewKeyword(orcid, Long.valueOf(putCode)); } @@ -341,6 +367,7 @@ public Response viewKeyword(@PathParam("orcid") String orcid, @PathParam("putCod @Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON }) @Path(ADDRESS) public Response viewAddresses(@PathParam("orcid") String orcid) { + serviceDelegator.trackEvents(httpRequest); return serviceDelegator.viewAddresses(orcid); } @@ -348,6 +375,7 @@ public Response viewAddresses(@PathParam("orcid") String orcid) { @Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON }) @Path(ADDRESS + PUTCODE) public Response viewAddress(@PathParam("orcid") String orcid, @PathParam("putCode") String putCode) { + serviceDelegator.trackEvents(httpRequest); return serviceDelegator.viewAddress(orcid, Long.valueOf(putCode)); } @@ -355,6 +383,7 @@ public Response viewAddress(@PathParam("orcid") String orcid, @PathParam("putCod @Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON }) @Path(BIOGRAPHY) public Response viewBiography(@PathParam("orcid") String orcid) { + serviceDelegator.trackEvents(httpRequest); return serviceDelegator.viewBiography(orcid); } @@ -362,6 +391,7 @@ public Response viewBiography(@PathParam("orcid") String orcid) { @Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON }) @Path(PERSON) public Response viewPerson(@PathParam("orcid") String orcid) { + serviceDelegator.trackEvents(httpRequest); return serviceDelegator.viewPerson(orcid); } @@ -370,6 +400,7 @@ public Response viewPerson(@PathParam("orcid") String orcid) { @Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON, JSON_LD }) @Path(OrcidApiConstants.RECORD_SIMPLE) public Response viewRecord(@PathParam("orcid") String orcid) { + serviceDelegator.trackEvents(httpRequest); return serviceDelegator.viewRecord(orcid); } @@ -378,6 +409,7 @@ public Response viewRecord(@PathParam("orcid") String orcid) { @Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON }) @Path(OrcidApiConstants.RECORD_RECORD) public Response viewRecordRecord(@PathParam("orcid") String orcid) { + serviceDelegator.trackEvents(httpRequest); return serviceDelegator.viewRecord(orcid); } @@ -385,6 +417,7 @@ public Response viewRecordRecord(@PathParam("orcid") String orcid) { @Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON }) @Path(SEARCH_PATH) public Response searchByQuery(@QueryParam("q") @DefaultValue("") String query, @Context UriInfo uriInfo) { + serviceDelegator.trackEvents(httpRequest); Map> solrParams = new HashMap<>(uriInfo.getQueryParameters()); Response jsonQueryResults = serviceDelegator.searchByQuery(solrParams); return jsonQueryResults; @@ -394,6 +427,7 @@ public Response searchByQuery(@QueryParam("q") @DefaultValue("") String query, @ @Produces(TEXT_CSV) @Path(CSV_SEARCH_PATH) public Response searchByQueryCSV(@QueryParam("q") @DefaultValue("") String query, @Context UriInfo uriInfo) { + serviceDelegator.trackEvents(httpRequest); Map> solrParams = new HashMap<>(uriInfo.getQueryParameters()); Response csvQueryResults = serviceDelegator.searchByQueryCSV(solrParams); return csvQueryResults; @@ -403,6 +437,7 @@ public Response searchByQueryCSV(@QueryParam("q") @DefaultValue("") String query @Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON }) @Path(EXPANDED_SEARCH_PATH) public Response expandedSearchByQuery(@QueryParam("q") @DefaultValue("") String query, @Context UriInfo uriInfo) { + serviceDelegator.trackEvents(httpRequest); Map> solrParams = new HashMap<>(uriInfo.getQueryParameters()); Response queryResults = serviceDelegator.expandedSearchByQuery(solrParams); return queryResults; @@ -411,6 +446,7 @@ public Response expandedSearchByQuery(@QueryParam("q") @DefaultValue("") String @Path(CLIENT_PATH) @Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON }) public Response viewClient(@PathParam("client_id") String clientId) { + serviceDelegator.trackEvents(httpRequest); return serviceDelegator.viewClient(clientId); } @@ -418,6 +454,7 @@ public Response viewClient(@PathParam("client_id") String clientId) { @Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON }) @Path(DISTINCTION + PUTCODE) public Response viewDistinction(@PathParam("orcid") String orcid, @PathParam("putCode") String putCode) { + serviceDelegator.trackEvents(httpRequest); return serviceDelegator.viewDistinction(orcid, Long.valueOf(putCode)); } @@ -425,6 +462,7 @@ public Response viewDistinction(@PathParam("orcid") String orcid, @PathParam("pu @Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON }) @Path(DISTINCTIONS) public Response viewDistinctions(@PathParam("orcid") String orcid) { + serviceDelegator.trackEvents(httpRequest); return serviceDelegator.viewDistinctions(orcid); } @@ -432,6 +470,7 @@ public Response viewDistinctions(@PathParam("orcid") String orcid) { @Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON }) @Path(DISTINCTION_SUMMARY + PUTCODE) public Response viewDistinctionSummary(@PathParam("orcid") String orcid, @PathParam("putCode") String putCode) { + serviceDelegator.trackEvents(httpRequest); return serviceDelegator.viewDistinctionSummary(orcid, Long.valueOf(putCode)); } @@ -439,6 +478,7 @@ public Response viewDistinctionSummary(@PathParam("orcid") String orcid, @PathPa @Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON }) @Path(INVITED_POSITION + PUTCODE) public Response viewInvitedPosition(@PathParam("orcid") String orcid, @PathParam("putCode") String putCode) { + serviceDelegator.trackEvents(httpRequest); return serviceDelegator.viewInvitedPosition(orcid, Long.valueOf(putCode)); } @@ -446,6 +486,7 @@ public Response viewInvitedPosition(@PathParam("orcid") String orcid, @PathParam @Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON }) @Path(INVITED_POSITIONS) public Response viewInvitedPositions(@PathParam("orcid") String orcid) { + serviceDelegator.trackEvents(httpRequest); return serviceDelegator.viewInvitedPositions(orcid); } @@ -453,6 +494,7 @@ public Response viewInvitedPositions(@PathParam("orcid") String orcid) { @Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON }) @Path(INVITED_POSITION_SUMMARY + PUTCODE) public Response viewInvitedPositionSummary(@PathParam("orcid") String orcid, @PathParam("putCode") String putCode) { + serviceDelegator.trackEvents(httpRequest); return serviceDelegator.viewInvitedPositionSummary(orcid, Long.valueOf(putCode)); } @@ -460,6 +502,7 @@ public Response viewInvitedPositionSummary(@PathParam("orcid") String orcid, @Pa @Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON }) @Path(MEMBERSHIP + PUTCODE) public Response viewMembership(@PathParam("orcid") String orcid, @PathParam("putCode") String putCode) { + serviceDelegator.trackEvents(httpRequest); return serviceDelegator.viewMembership(orcid, Long.valueOf(putCode)); } @@ -467,6 +510,7 @@ public Response viewMembership(@PathParam("orcid") String orcid, @PathParam("put @Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON }) @Path(MEMBERSHIPS) public Response viewMemberships(@PathParam("orcid") String orcid) { + serviceDelegator.trackEvents(httpRequest); return serviceDelegator.viewMemberships(orcid); } @@ -474,6 +518,7 @@ public Response viewMemberships(@PathParam("orcid") String orcid) { @Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON }) @Path(MEMBERSHIP_SUMMARY + PUTCODE) public Response viewMembershipSummary(@PathParam("orcid") String orcid, @PathParam("putCode") String putCode) { + serviceDelegator.trackEvents(httpRequest); return serviceDelegator.viewMembershipSummary(orcid, Long.valueOf(putCode)); } @@ -481,6 +526,7 @@ public Response viewMembershipSummary(@PathParam("orcid") String orcid, @PathPar @Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON }) @Path(QUALIFICATION + PUTCODE) public Response viewQualification(@PathParam("orcid") String orcid, @PathParam("putCode") String putCode) { + serviceDelegator.trackEvents(httpRequest); return serviceDelegator.viewQualification(orcid, Long.valueOf(putCode)); } @@ -488,6 +534,7 @@ public Response viewQualification(@PathParam("orcid") String orcid, @PathParam(" @Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON }) @Path(QUALIFICATIONS) public Response viewQualifications(@PathParam("orcid") String orcid) { + serviceDelegator.trackEvents(httpRequest); return serviceDelegator.viewQualifications(orcid); } @@ -495,6 +542,7 @@ public Response viewQualifications(@PathParam("orcid") String orcid) { @Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON }) @Path(QUALIFICATION_SUMMARY + PUTCODE) public Response viewQualificationSummary(@PathParam("orcid") String orcid, @PathParam("putCode") String putCode) { + serviceDelegator.trackEvents(httpRequest); return serviceDelegator.viewQualificationSummary(orcid, Long.valueOf(putCode)); } @@ -502,6 +550,7 @@ public Response viewQualificationSummary(@PathParam("orcid") String orcid, @Path @Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON }) @Path(SERVICE + PUTCODE) public Response viewService(@PathParam("orcid") String orcid, @PathParam("putCode") String putCode) { + serviceDelegator.trackEvents(httpRequest); return serviceDelegator.viewService(orcid, Long.valueOf(putCode)); } @@ -509,6 +558,7 @@ public Response viewService(@PathParam("orcid") String orcid, @PathParam("putCod @Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON }) @Path(SERVICES) public Response viewServices(@PathParam("orcid") String orcid) { + serviceDelegator.trackEvents(httpRequest); return serviceDelegator.viewServices(orcid); } @@ -516,6 +566,7 @@ public Response viewServices(@PathParam("orcid") String orcid) { @Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON }) @Path(SERVICE_SUMMARY + PUTCODE) public Response viewServiceSummary(@PathParam("orcid") String orcid, @PathParam("putCode") String putCode) { + serviceDelegator.trackEvents(httpRequest); return serviceDelegator.viewServiceSummary(orcid, Long.valueOf(putCode)); } @@ -523,6 +574,7 @@ public Response viewServiceSummary(@PathParam("orcid") String orcid, @PathParam( @Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON }) @Path(RESEARCH_RESOURCE + PUTCODE) public Response viewResearchResource(@PathParam("orcid") String orcid, @PathParam("putCode") String putCode) { + serviceDelegator.trackEvents(httpRequest); return serviceDelegator.viewResearchResource(orcid, Long.valueOf(putCode)); } @@ -530,6 +582,7 @@ public Response viewResearchResource(@PathParam("orcid") String orcid, @PathPara @Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON }) @Path(RESEARCH_RESOURCES) public Response viewResearchResources(@PathParam("orcid") String orcid) { + serviceDelegator.trackEvents(httpRequest); return serviceDelegator.viewResearchResources(orcid); } @@ -537,6 +590,7 @@ public Response viewResearchResources(@PathParam("orcid") String orcid) { @Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON }) @Path(RESEARCH_RESOURCE_SUMMARY + PUTCODE) public Response viewResearchResourceSummary(@PathParam("orcid") String orcid, @PathParam("putCode") String putCode) { + serviceDelegator.trackEvents(httpRequest); return serviceDelegator.viewResearchResourceSummary(orcid, Long.valueOf(putCode)); } diff --git a/orcid-pub-web/src/main/java/org/orcid/api/publicV3/server/delegator/PublicV3ApiServiceDelegator.java b/orcid-pub-web/src/main/java/org/orcid/api/publicV3/server/delegator/PublicV3ApiServiceDelegator.java index 368107244b6..a96e8649e0d 100644 --- a/orcid-pub-web/src/main/java/org/orcid/api/publicV3/server/delegator/PublicV3ApiServiceDelegator.java +++ b/orcid-pub-web/src/main/java/org/orcid/api/publicV3/server/delegator/PublicV3ApiServiceDelegator.java @@ -3,6 +3,7 @@ import java.util.List; import java.util.Map; +import javax.servlet.http.HttpServletRequest; import javax.ws.rs.core.Response; /** @@ -132,4 +133,6 @@ public interface PublicV3ApiServiceDelegator> solrParams); + void trackEvents(HttpServletRequest httpRequest); + } diff --git a/orcid-pub-web/src/main/java/org/orcid/api/publicV3/server/delegator/impl/PublicV3ApiServiceDelegatorImpl.java b/orcid-pub-web/src/main/java/org/orcid/api/publicV3/server/delegator/impl/PublicV3ApiServiceDelegatorImpl.java index 783c9db5272..45c6b2e7556 100644 --- a/orcid-pub-web/src/main/java/org/orcid/api/publicV3/server/delegator/impl/PublicV3ApiServiceDelegatorImpl.java +++ b/orcid-pub-web/src/main/java/org/orcid/api/publicV3/server/delegator/impl/PublicV3ApiServiceDelegatorImpl.java @@ -7,6 +7,7 @@ import java.util.Map; import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; @@ -15,6 +16,7 @@ import org.orcid.api.common.writer.citeproc.V3WorkToCiteprocTranslator; import org.orcid.api.publicV3.server.delegator.PublicV3ApiServiceDelegator; import org.orcid.api.publicV3.server.security.PublicAPISecurityManagerV3; +import org.orcid.core.common.manager.EventManager; import org.orcid.core.exception.OrcidBadRequestException; import org.orcid.core.exception.OrcidNoResultException; import org.orcid.core.exception.SearchStartParameterLimitExceededException; @@ -44,6 +46,8 @@ import org.orcid.core.manager.v3.read_only.ResearcherUrlManagerReadOnly; import org.orcid.core.manager.v3.read_only.WorkManagerReadOnly; import org.orcid.core.oauth.openid.OpenIDConnectKeyService; +import org.orcid.core.togglz.Features; +import org.orcid.core.utils.OrcidRequestUtil; import org.orcid.core.utils.v3.ContributorUtils; import org.orcid.core.utils.v3.SourceUtils; import org.orcid.core.version.impl.Api3_0LastModifiedDatesHelper; @@ -209,6 +213,9 @@ public class PublicV3ApiServiceDelegatorImpl @Resource(name = "recordNameManagerReadOnlyV3") private RecordNameManagerReadOnly recordNameManagerReadOnlyV3; + @Resource + private EventManager eventManager; + @Value("${org.orcid.core.baseUri}") private String baseUrl; @@ -961,4 +968,15 @@ public Response viewResearchResourceSummary(String orcid, Long putCode) { return Response.ok(e).build(); } + @Override + public void trackEvents(HttpServletRequest httpRequest) { + boolean anonymous = false; + String clientId = orcidSecurityManager.getClientIdFromAPIRequest(); + if (clientId == null) { + clientId = OrcidRequestUtil.getIpAddress(httpRequest); + anonymous = true; + } + eventManager.createPapiEvent(clientId, anonymous); + } + } diff --git a/orcid-scheduler-web/src/main/java/org/orcid/scheduler/web/event/EventStats.java b/orcid-scheduler-web/src/main/java/org/orcid/scheduler/web/event/EventStats.java index 91d6a941e82..0d83dcf5098 100644 --- a/orcid-scheduler-web/src/main/java/org/orcid/scheduler/web/event/EventStats.java +++ b/orcid-scheduler-web/src/main/java/org/orcid/scheduler/web/event/EventStats.java @@ -5,4 +5,8 @@ public interface EventStats { void saveEventStats(); void deleteEvents(); + + void savePapiEventStats(); + + void deletePapiEvents(); } diff --git a/orcid-scheduler-web/src/main/java/org/orcid/scheduler/web/event/impl/EventStatsImpl.java b/orcid-scheduler-web/src/main/java/org/orcid/scheduler/web/event/impl/EventStatsImpl.java index b77eac25a28..5087e88bbd2 100644 --- a/orcid-scheduler-web/src/main/java/org/orcid/scheduler/web/event/impl/EventStatsImpl.java +++ b/orcid-scheduler-web/src/main/java/org/orcid/scheduler/web/event/impl/EventStatsImpl.java @@ -23,12 +23,13 @@ public class EventStatsImpl implements EventStats { @Value("${org.orcid.scheduler.event.deleteEvents.numberOfDays:90}") private int DELETE_EVENTS_OLDER_THAN_DAYS; + + @Value("${org.orcid.scheduler.event.deletePapiEvents.numberOfDays:90}") + private int DELETE_PAPI_EVENTS_OLDER_THAN_DAYS; @Override public void saveEventStats() { - LocalDate date = LocalDate.now().minusDays(1); - String currentDate = date.getDayOfMonth() + "/" + date.getMonth() + "/" + date.getYear(); - LOGGER.info("Storing aggregate data to event_stats table of the day" + currentDate); + LOGGER.info("Storing aggregate data to event_stats table of the day " + getCurrentDate()); eventStatsDao.createEventStats(); } @@ -39,4 +40,25 @@ public void deleteEvents() { eventDao.deleteEventsByDate(DELETE_EVENTS_OLDER_THAN_DAYS); } } + + @Override + public void savePapiEventStats() { + if (Features.PAPI_EVENTS.isActive()) { + LOGGER.info("Storing aggregate data to event_stats table of the day " + getCurrentDate()); + eventStatsDao.createPapiEventStats(); + } + } + + @Override + public void deletePapiEvents() { + if (Features.PAPI_EVENTS.isActive()) { + LOGGER.info("Deleting events older than "+ DELETE_PAPI_EVENTS_OLDER_THAN_DAYS +" days"); + eventDao.deletePapiEvents(DELETE_PAPI_EVENTS_OLDER_THAN_DAYS); + } + } + + private String getCurrentDate() { + LocalDate date = LocalDate.now().minusDays(1); + return date.getDayOfMonth() + "/" + date.getMonth() + "/" + date.getYear(); + } } diff --git a/orcid-scheduler-web/src/main/resources/orcid-scheduler-context.xml b/orcid-scheduler-web/src/main/resources/orcid-scheduler-context.xml index 4c4af0b225a..0a3bf32b1ea 100644 --- a/orcid-scheduler-web/src/main/resources/orcid-scheduler-context.xml +++ b/orcid-scheduler-web/src/main/resources/orcid-scheduler-context.xml @@ -43,6 +43,8 @@ + + diff --git a/orcid-test/src/main/resources/data/EventEntityData.xml b/orcid-test/src/main/resources/data/EventEntityData.xml index 83aa14b811b..c2f5c16ebc5 100644 --- a/orcid-test/src/main/resources/data/EventEntityData.xml +++ b/orcid-test/src/main/resources/data/EventEntityData.xml @@ -18,4 +18,23 @@ date_created="2023-01-01 15:31:00.00" /> + + + + + + diff --git a/orcid-web/src/main/java/org/orcid/frontend/oauth2/OauthController.java b/orcid-web/src/main/java/org/orcid/frontend/oauth2/OauthController.java index a544d63b92f..8d39c939f21 100644 --- a/orcid-web/src/main/java/org/orcid/frontend/oauth2/OauthController.java +++ b/orcid-web/src/main/java/org/orcid/frontend/oauth2/OauthController.java @@ -23,13 +23,13 @@ import org.orcid.core.oauth.service.OrcidAuthorizationEndpoint; import org.orcid.core.oauth.service.OrcidOAuth2RequestValidator; import org.orcid.core.togglz.Features; -import org.orcid.core.utils.EventType; import org.orcid.frontend.web.controllers.BaseControllerUtil; import org.orcid.frontend.web.controllers.helper.OauthHelper; import org.orcid.frontend.web.exception.OauthInvalidRequestException; import org.orcid.jaxb.model.message.ScopePathType; import org.orcid.persistence.jpa.entities.ClientDetailsEntity; import org.orcid.persistence.jpa.entities.ClientGrantedAuthorityEntity; +import org.orcid.persistence.jpa.entities.EventType; import org.orcid.pojo.ajaxForm.PojoUtil; import org.orcid.pojo.ajaxForm.RequestInfoForm; import org.springframework.security.core.context.SecurityContext; diff --git a/orcid-web/src/main/java/org/orcid/frontend/spring/AjaxAuthenticationSuccessHandler.java b/orcid-web/src/main/java/org/orcid/frontend/spring/AjaxAuthenticationSuccessHandler.java index 599baf46329..46236b48987 100644 --- a/orcid-web/src/main/java/org/orcid/frontend/spring/AjaxAuthenticationSuccessHandler.java +++ b/orcid-web/src/main/java/org/orcid/frontend/spring/AjaxAuthenticationSuccessHandler.java @@ -8,7 +8,7 @@ import org.orcid.core.common.manager.EventManager; import org.orcid.core.togglz.Features; -import org.orcid.core.utils.EventType; +import org.orcid.persistence.jpa.entities.EventType; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.core.Authentication; diff --git a/orcid-web/src/main/java/org/orcid/frontend/spring/ShibbolethAjaxAuthenticationSuccessHandler.java b/orcid-web/src/main/java/org/orcid/frontend/spring/ShibbolethAjaxAuthenticationSuccessHandler.java index c515ff5d4a1..767072bb6b5 100644 --- a/orcid-web/src/main/java/org/orcid/frontend/spring/ShibbolethAjaxAuthenticationSuccessHandler.java +++ b/orcid-web/src/main/java/org/orcid/frontend/spring/ShibbolethAjaxAuthenticationSuccessHandler.java @@ -14,8 +14,8 @@ import org.orcid.core.common.manager.EventManager; import org.orcid.core.manager.InstitutionalSignInManager; import org.orcid.core.togglz.Features; -import org.orcid.core.utils.EventType; import org.orcid.frontend.web.exception.FeatureDisabledException; +import org.orcid.persistence.jpa.entities.EventType; import org.orcid.pojo.RemoteUser; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/orcid-web/src/main/java/org/orcid/frontend/web/controllers/LoginController.java b/orcid-web/src/main/java/org/orcid/frontend/web/controllers/LoginController.java index 3184290f6f7..67485237aaa 100644 --- a/orcid-web/src/main/java/org/orcid/frontend/web/controllers/LoginController.java +++ b/orcid-web/src/main/java/org/orcid/frontend/web/controllers/LoginController.java @@ -24,7 +24,6 @@ import org.orcid.core.oauth.service.OrcidOAuth2RequestValidator; import org.orcid.core.security.OrcidUserDetailsService; import org.orcid.core.togglz.Features; -import org.orcid.core.utils.EventType; import org.orcid.frontend.spring.web.social.config.SocialSignInUtils; import org.orcid.frontend.spring.web.social.config.SocialType; import org.orcid.frontend.spring.web.social.config.UserCookieGenerator; @@ -33,6 +32,7 @@ import org.orcid.jaxb.model.v3.release.common.Visibility; import org.orcid.jaxb.model.v3.release.record.Name; import org.orcid.persistence.jpa.entities.ClientDetailsEntity; +import org.orcid.persistence.jpa.entities.EventType; import org.orcid.persistence.jpa.entities.ProfileEntity; import org.orcid.persistence.jpa.entities.UserconnectionEntity; import org.orcid.persistence.jpa.entities.UserconnectionPK; diff --git a/orcid-web/src/main/java/org/orcid/frontend/web/controllers/OauthAuthorizeController.java b/orcid-web/src/main/java/org/orcid/frontend/web/controllers/OauthAuthorizeController.java index d1f258b4550..f1145848e5b 100644 --- a/orcid-web/src/main/java/org/orcid/frontend/web/controllers/OauthAuthorizeController.java +++ b/orcid-web/src/main/java/org/orcid/frontend/web/controllers/OauthAuthorizeController.java @@ -16,10 +16,10 @@ import org.orcid.core.oauth.OrcidProfileUserDetails; import org.orcid.core.oauth.OrcidRandomValueTokenServices; import org.orcid.core.togglz.Features; -import org.orcid.core.utils.EventType; import org.orcid.frontend.web.controllers.helper.OauthHelper; import org.orcid.jaxb.model.message.ScopePathType; import org.orcid.persistence.jpa.entities.ClientDetailsEntity; +import org.orcid.persistence.jpa.entities.EventType; import org.orcid.pojo.ajaxForm.OauthAuthorizeForm; import org.orcid.pojo.ajaxForm.PojoUtil; import org.orcid.pojo.ajaxForm.RequestInfoForm; 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 8ff400efbe6..1458506b188 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 @@ -44,7 +44,6 @@ import org.orcid.core.manager.v3.read_only.WorkManagerReadOnly; import org.orcid.core.oauth.OrcidOauth2TokenDetailService; import org.orcid.core.togglz.Features; -import org.orcid.core.utils.EventType; import org.orcid.core.utils.v3.SourceUtils; import org.orcid.frontend.web.pagination.Page; import org.orcid.frontend.web.pagination.ResearchResourcePaginator; @@ -62,6 +61,7 @@ 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.ResearcherUrls; +import org.orcid.persistence.jpa.entities.EventType; import org.orcid.persistence.jpa.entities.ProfileEntity; import org.orcid.pojo.PeerReviewMinimizedSummary; import org.orcid.pojo.PublicRecord; 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..2f71c8ba054 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 @@ -35,7 +35,6 @@ import org.orcid.core.profile.history.ProfileHistoryEventType; import org.orcid.core.security.OrcidUserDetailsService; import org.orcid.core.togglz.Features; -import org.orcid.core.utils.EventType; import org.orcid.core.utils.OrcidRequestUtil; import org.orcid.core.utils.OrcidStringUtils; import org.orcid.frontend.email.RecordEmailSender; @@ -52,6 +51,7 @@ 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.persistence.jpa.entities.EventType; import org.orcid.pojo.OrgDisambiguated; import org.orcid.pojo.Redirect; import org.orcid.pojo.ajaxForm.AffiliationForm; diff --git a/orcid-web/src/main/java/org/orcid/frontend/web/controllers/ShibbolethController.java b/orcid-web/src/main/java/org/orcid/frontend/web/controllers/ShibbolethController.java index 818670ab8f6..af640fa637a 100644 --- a/orcid-web/src/main/java/org/orcid/frontend/web/controllers/ShibbolethController.java +++ b/orcid-web/src/main/java/org/orcid/frontend/web/controllers/ShibbolethController.java @@ -22,9 +22,9 @@ import org.orcid.core.oauth.OrcidProfileUserDetails; import org.orcid.core.security.OrcidUserDetailsService; import org.orcid.core.togglz.Features; -import org.orcid.core.utils.EventType; import org.orcid.core.utils.JsonUtils; import org.orcid.frontend.web.exception.FeatureDisabledException; +import org.orcid.persistence.jpa.entities.EventType; import org.orcid.persistence.jpa.entities.ProfileEntity; import org.orcid.persistence.jpa.entities.UserConnectionStatus; import org.orcid.persistence.jpa.entities.UserconnectionEntity;