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 056b99e8ea..d975b43664 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 @@ -55,7 +55,7 @@ public enum Features implements Feature { @Label("Enable email domains in the UI") EMAIL_DOMAINS_UI, - @Label("Enable rate limiting for public API. When disabled therate monitoring is on.") + @Label("Enforce rate limiting for public API when disabled the rate monitoring is on. When disabled is the mode is monitoring only.") ENABLE_PAPI_RATE_LIMITING; public boolean isActive() { diff --git a/orcid-persistence/src/main/java/org/orcid/persistence/dao/impl/PublicApiDailyRateLimitDaoImpl.java b/orcid-persistence/src/main/java/org/orcid/persistence/dao/impl/PublicApiDailyRateLimitDaoImpl.java index 487d9a3828..75f7154925 100644 --- a/orcid-persistence/src/main/java/org/orcid/persistence/dao/impl/PublicApiDailyRateLimitDaoImpl.java +++ b/orcid-persistence/src/main/java/org/orcid/persistence/dao/impl/PublicApiDailyRateLimitDaoImpl.java @@ -26,7 +26,7 @@ public PublicApiDailyRateLimitEntity findByClientIdAndRequestDate(String clientI Query nativeQuery = entityManager.createNativeQuery("SELECT * FROM public_api_daily_rate_limit p client_id=:clientId and requestDate=:requestDate", PublicApiDailyRateLimitEntity.class); nativeQuery.setParameter("clientId", clientId); - nativeQuery.setParameter("requestDate", requestDate.toString()); + nativeQuery.setParameter("requestDate", requestDate); List papiRateList = (List) nativeQuery.getResultList(); if (papiRateList != null && papiRateList.size() > 0) { if (papiRateList.size() > 1) { @@ -59,11 +59,11 @@ public PublicApiDailyRateLimitEntity findByIpAddressAndRequestDate(String ipAddr public int countClientRequestsWithLimitExceeded(LocalDate requestDate, int limit) { Query nativeQuery = entityManager.createNativeQuery( "SELECT count(*) FROM public_api_daily_rate_limit p WHERE NOT ((p.client_id = '' OR p.client_id IS NULL)) and p.request_date=:requestDate and p.request_count >=:requestCount"); - nativeQuery.setParameter("requestDate", requestDate.toString()); + nativeQuery.setParameter("requestDate", requestDate); nativeQuery.setParameter("requestCount", limit); - List tsList = nativeQuery.getResultList(); + List tsList = nativeQuery.getResultList(); if (tsList != null && !tsList.isEmpty()) { - return (Integer) tsList.get(0); + return tsList.get(0).intValue(); } return 0; @@ -72,11 +72,11 @@ public int countClientRequestsWithLimitExceeded(LocalDate requestDate, int limit public int countAnonymousRequestsWithLimitExceeded(LocalDate requestDate, int limit) { Query nativeQuery = entityManager.createNativeQuery( "SELECT count(*) FROM public_api_daily_rate_limit p WHERE ((p.client_id = '' OR p.client_id IS NULL)) and p.request_date=:requestDate and p.request_count >=:requestCount"); - nativeQuery.setParameter("requestDate", requestDate.toString()); + nativeQuery.setParameter("requestDate", requestDate); nativeQuery.setParameter("requestCount", limit); - List tsList = nativeQuery.getResultList(); + List tsList = nativeQuery.getResultList(); if (tsList != null && !tsList.isEmpty()) { - return (Integer) tsList.get(0); + return tsList.get(0).intValue(); } return 0; } diff --git a/orcid-scheduler-web/src/main/java/org/orcid/scheduler/report/PapiDailyLimitReport.java b/orcid-scheduler-web/src/main/java/org/orcid/scheduler/report/PapiDailyLimitReport.java index fb03259c43..0e63e4f905 100644 --- a/orcid-scheduler-web/src/main/java/org/orcid/scheduler/report/PapiDailyLimitReport.java +++ b/orcid-scheduler-web/src/main/java/org/orcid/scheduler/report/PapiDailyLimitReport.java @@ -72,7 +72,7 @@ public void papiDailyLimitReport() { LocalDate yesterday = LocalDate.now().minusDays(1); String mode = Features.ENABLE_PAPI_RATE_LIMITING.isActive() ? "ENFORCEMENT" : "MONITORING"; String SLACK_INTRO_MSG = "Public API Rate limit report - Date: " + yesterday.toString() + "\n Current Anonymous Requests Limit: " + anonymousRequestLimit - + "\n Current Public API Clients Limit: " + anonymousRequestLimit + "\n Mode: " + mode; + + "\n Current Public API Clients Limit: " + knownRequestLimit + "\n Mode: " + mode; LOG .info(SLACK_INTRO_MSG); slackManager.sendAlert(SLACK_INTRO_MSG, slackChannel, webhookUrl, webhookUrl);