From f951b7d3105cc57e4b4d0bc880efe0a7fe0b1476 Mon Sep 17 00:00:00 2001
From: OleksandrVidinieiev
<56632770+OleksandrVidinieiev@users.noreply.github.com>
Date: Thu, 24 Oct 2024 14:00:58 +0000
Subject: [PATCH] MODFEE-391: Upgrade to RMB 35.3.0 (#295)
* MODFEE-391 Upgrade to RMB 35.3.0
* MODFEE-391 Upgrade apache commons lang3 to 3.17.0
* MODFEE-391 Add commons-io 2.17.0
* MODFEE-391 Increase wait timeout in tests
* MODFEE-391 Do not override parameter constraint configuration
* MODFEE-391 Fix typo
---
.github/workflows/postgres.yml | 26 ++++++++
pom.xml | 10 ++-
ramls/accounts.raml | 1 -
ramls/actual-cost-fee-fine.raml | 1 -
ramls/comments.raml | 1 -
ramls/feefine-reports.raml | 1 -
ramls/feefineactions.raml | 1 -
ramls/feefines.raml | 1 -
ramls/lost-item-fee-policy.raml | 1 -
ramls/manual-block-templates.raml | 1 -
ramls/manualblocks.raml | 1 -
ramls/overdue-fine-policy.raml | 1 -
ramls/owners.raml | 1 -
ramls/payments.raml | 1 -
ramls/raml-util | 2 +-
ramls/refunds.raml | 1 -
ramls/transfer-criteria.raml | 1 -
ramls/transfers.raml | 1 -
ramls/waiver.raml | 1 -
.../java/org/folio/rest/impl/AccountsAPI.java | 48 +++++++--------
.../java/org/folio/rest/impl/CommentsAPI.java | 54 ++++++++--------
.../folio/rest/impl/FeeFineActionsAPI.java | 47 +++++++-------
.../java/org/folio/rest/impl/FeeFinesAPI.java | 59 +++++++++---------
.../rest/impl/LostItemFeePoliciesAPI.java | 32 +++-------
.../rest/impl/ManualBlockTemplatesAPI.java | 29 +++++----
.../org/folio/rest/impl/ManualBlocksAPI.java | 54 +++++++++-------
.../rest/impl/OverdueFinePoliciesAPI.java | 33 +++-------
.../java/org/folio/rest/impl/OwnersAPI.java | 50 ++++++++-------
.../java/org/folio/rest/impl/PaymentsAPI.java | 57 +++++++++--------
.../java/org/folio/rest/impl/RefundsAPI.java | 56 +++++++++--------
.../folio/rest/impl/TransferCriteriaAPI.java | 61 +++++++++++--------
.../org/folio/rest/impl/TransfersAPI.java | 54 +++++++++-------
.../java/org/folio/rest/impl/WaivesAPI.java | 56 +++++++++--------
.../java/org/folio/test/support/ApiTests.java | 2 +-
34 files changed, 396 insertions(+), 350 deletions(-)
create mode 100644 .github/workflows/postgres.yml
diff --git a/.github/workflows/postgres.yml b/.github/workflows/postgres.yml
new file mode 100644
index 00000000..9a1470bd
--- /dev/null
+++ b/.github/workflows/postgres.yml
@@ -0,0 +1,26 @@
+name: postgres
+on:
+ workflow_dispatch:
+ inputs:
+ postgres:
+ description: "List of postgres container images, to be injected as TESTCONTAINERS_POSTGRES_IMAGE"
+ default: '["postgres:16-alpine", "postgres:18-alpine"]'
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ postgres: ${{ fromJSON(github.event.inputs.postgres) }}
+ fail-fast: false
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ submodules: true
+ - uses: actions/setup-java@v4
+ with:
+ distribution: 'temurin'
+ java-version: '17'
+ cache: maven
+ - run: mvn --batch-mode verify
+ env:
+ TESTCONTAINERS_POSTGRES_IMAGE: ${{ matrix.postgres }}
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 4e8bf8fb..540c744f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -18,7 +18,7 @@
UTF-8
UTF-8
4.5.5
- 35.2.0
+ 35.3.0
${basedir}/ramls
5434
@@ -166,8 +166,14 @@
org.apache.commons
commons-lang3
- 3.12.0
+ 3.17.0
+
+ commons-io
+ commons-io
+ 2.17.0
+
+
org.apache.maven
maven-model
diff --git a/ramls/accounts.raml b/ramls/accounts.raml
index 937f76e8..49b5b7ca 100644
--- a/ramls/accounts.raml
+++ b/ramls/accounts.raml
@@ -23,7 +23,6 @@ traits:
orderable: !include raml-util/traits/orderable.raml
pageable: !include raml-util/traits/pageable.raml
searchable: !include raml-util/traits/searchable.raml
- language: !include raml-util/traits/language.raml
validate: !include raml-util/traits/validation.raml
facets: !include raml-util/traits/facets.raml
diff --git a/ramls/actual-cost-fee-fine.raml b/ramls/actual-cost-fee-fine.raml
index 668bdd8b..5d691215 100644
--- a/ramls/actual-cost-fee-fine.raml
+++ b/ramls/actual-cost-fee-fine.raml
@@ -15,7 +15,6 @@ types:
errors: !include raml-util/schemas/errors.schema
traits:
- language: !include raml-util/traits/language.raml
validate: !include raml-util/traits/validation.raml
/actual-cost-fee-fine:
diff --git a/ramls/comments.raml b/ramls/comments.raml
index 57c9c42a..385de592 100644
--- a/ramls/comments.raml
+++ b/ramls/comments.raml
@@ -16,7 +16,6 @@ traits:
orderable: !include raml-util/traits/orderable.raml
pageable: !include raml-util/traits/pageable.raml
searchable: !include raml-util/traits/searchable.raml
- language: !include raml-util/traits/language.raml
validate: !include raml-util/traits/validation.raml
facets: !include raml-util/traits/facets.raml
diff --git a/ramls/feefine-reports.raml b/ramls/feefine-reports.raml
index 86dbd85c..a0cfc98b 100644
--- a/ramls/feefine-reports.raml
+++ b/ramls/feefine-reports.raml
@@ -28,7 +28,6 @@ types:
traits:
validate: !include raml-util/traits/validation.raml
- language: !include raml-util/traits/language.raml
/feefine-reports:
/refund:
diff --git a/ramls/feefineactions.raml b/ramls/feefineactions.raml
index 9afa7bf0..2d50b17f 100644
--- a/ramls/feefineactions.raml
+++ b/ramls/feefineactions.raml
@@ -27,7 +27,6 @@ traits:
orderable: !include raml-util/traits/orderable.raml
pageable: !include raml-util/traits/pageable.raml
searchable: !include raml-util/traits/searchable.raml
- language: !include raml-util/traits/language.raml
validate: !include raml-util/traits/validation.raml
resourceTypes:
diff --git a/ramls/feefines.raml b/ramls/feefines.raml
index b13c9918..1fbda346 100644
--- a/ramls/feefines.raml
+++ b/ramls/feefines.raml
@@ -17,7 +17,6 @@ traits:
orderable: !include raml-util/traits/orderable.raml
pageable: !include raml-util/traits/pageable.raml
searchable: !include raml-util/traits/searchable.raml
- language: !include raml-util/traits/language.raml
validate: !include raml-util/traits/validation.raml
facets: !include raml-util/traits/facets.raml
diff --git a/ramls/lost-item-fee-policy.raml b/ramls/lost-item-fee-policy.raml
index 83a190dd..b44fbcc5 100644
--- a/ramls/lost-item-fee-policy.raml
+++ b/ramls/lost-item-fee-policy.raml
@@ -17,7 +17,6 @@ traits:
orderable: !include raml-util/traits/orderable.raml
pageable: !include raml-util/traits/pageable.raml
searchable: !include raml-util/traits/searchable.raml
- language: !include raml-util/traits/language.raml
validate: !include raml-util/traits/validation.raml
resourceTypes:
diff --git a/ramls/manual-block-templates.raml b/ramls/manual-block-templates.raml
index c4f9db06..9c23254f 100644
--- a/ramls/manual-block-templates.raml
+++ b/ramls/manual-block-templates.raml
@@ -16,7 +16,6 @@ traits:
orderable: !include raml-util/traits/orderable.raml
pageable: !include raml-util/traits/pageable.raml
searchable: !include raml-util/traits/searchable.raml
- language: !include raml-util/traits/language.raml
validate: !include raml-util/traits/validation.raml
resourceTypes:
diff --git a/ramls/manualblocks.raml b/ramls/manualblocks.raml
index 88565c40..3c3d9241 100644
--- a/ramls/manualblocks.raml
+++ b/ramls/manualblocks.raml
@@ -16,7 +16,6 @@ traits:
orderable: !include raml-util/traits/orderable.raml
pageable: !include raml-util/traits/pageable.raml
searchable: !include raml-util/traits/searchable.raml
- language: !include raml-util/traits/language.raml
validate: !include raml-util/traits/validation.raml
resourceTypes:
diff --git a/ramls/overdue-fine-policy.raml b/ramls/overdue-fine-policy.raml
index c6c5ea4f..4ec16741 100644
--- a/ramls/overdue-fine-policy.raml
+++ b/ramls/overdue-fine-policy.raml
@@ -17,7 +17,6 @@ traits:
orderable: !include raml-util/traits/orderable.raml
pageable: !include raml-util/traits/pageable.raml
searchable: !include raml-util/traits/searchable.raml
- language: !include raml-util/traits/language.raml
validate: !include raml-util/traits/validation.raml
resourceTypes:
diff --git a/ramls/owners.raml b/ramls/owners.raml
index 48a400fa..11e987ba 100644
--- a/ramls/owners.raml
+++ b/ramls/owners.raml
@@ -16,7 +16,6 @@ traits:
orderable: !include raml-util/traits/orderable.raml
pageable: !include raml-util/traits/pageable.raml
searchable: !include raml-util/traits/searchable.raml
- language: !include raml-util/traits/language.raml
validate: !include raml-util/traits/validation.raml
resourceTypes:
diff --git a/ramls/payments.raml b/ramls/payments.raml
index 5287d607..e83ef7bb 100644
--- a/ramls/payments.raml
+++ b/ramls/payments.raml
@@ -16,7 +16,6 @@ traits:
orderable: !include raml-util/traits/orderable.raml
pageable: !include raml-util/traits/pageable.raml
searchable: !include raml-util/traits/searchable.raml
- language: !include raml-util/traits/language.raml
validate: !include raml-util/traits/validation.raml
facets: !include raml-util/traits/facets.raml
diff --git a/ramls/raml-util b/ramls/raml-util
index b446568c..f48a63f3 160000
--- a/ramls/raml-util
+++ b/ramls/raml-util
@@ -1 +1 @@
-Subproject commit b446568c550e43db0ea8bda11182dfd1d27aa32e
+Subproject commit f48a63f3e45b9a3b437d21c3a61ed10b8ceb5f25
diff --git a/ramls/refunds.raml b/ramls/refunds.raml
index 949ec67e..d325ae3a 100644
--- a/ramls/refunds.raml
+++ b/ramls/refunds.raml
@@ -16,7 +16,6 @@ traits:
orderable: !include raml-util/traits/orderable.raml
pageable: !include raml-util/traits/pageable.raml
searchable: !include raml-util/traits/searchable.raml
- language: !include raml-util/traits/language.raml
validate: !include raml-util/traits/validation.raml
facets: !include raml-util/traits/facets.raml
diff --git a/ramls/transfer-criteria.raml b/ramls/transfer-criteria.raml
index fe363649..8b363148 100644
--- a/ramls/transfer-criteria.raml
+++ b/ramls/transfer-criteria.raml
@@ -16,7 +16,6 @@ traits:
orderable: !include raml-util/traits/orderable.raml
pageable: !include raml-util/traits/pageable.raml
searchable: !include raml-util/traits/searchable.raml
- language: !include raml-util/traits/language.raml
validate: !include raml-util/traits/validation.raml
resourceTypes:
diff --git a/ramls/transfers.raml b/ramls/transfers.raml
index ca20e95b..87220c9d 100644
--- a/ramls/transfers.raml
+++ b/ramls/transfers.raml
@@ -16,7 +16,6 @@ traits:
orderable: !include raml-util/traits/orderable.raml
pageable: !include raml-util/traits/pageable.raml
searchable: !include raml-util/traits/searchable.raml
- language: !include raml-util/traits/language.raml
validate: !include raml-util/traits/validation.raml
facets: !include raml-util/traits/facets.raml
diff --git a/ramls/waiver.raml b/ramls/waiver.raml
index 2b04cc61..f71a9b82 100644
--- a/ramls/waiver.raml
+++ b/ramls/waiver.raml
@@ -16,7 +16,6 @@ traits:
orderable: !include raml-util/traits/orderable.raml
pageable: !include raml-util/traits/pageable.raml
searchable: !include raml-util/traits/searchable.raml
- language: !include raml-util/traits/language.raml
validate: !include raml-util/traits/validation.raml
facets: !include raml-util/traits/facets.raml
diff --git a/src/main/java/org/folio/rest/impl/AccountsAPI.java b/src/main/java/org/folio/rest/impl/AccountsAPI.java
index 2f0e628f..22d84aa9 100644
--- a/src/main/java/org/folio/rest/impl/AccountsAPI.java
+++ b/src/main/java/org/folio/rest/impl/AccountsAPI.java
@@ -6,6 +6,7 @@
import static org.folio.rest.domain.Action.REFUND;
import static org.folio.rest.domain.Action.TRANSFER;
import static org.folio.rest.domain.Action.WAIVE;
+import static org.folio.rest.tools.messages.Messages.DEFAULT_LANGUAGE;
import java.util.List;
import java.util.Map;
@@ -126,10 +127,10 @@ private Future setAdditionalFields(Vertx vertx, Map okapiH
@Validate
@Override
- public void getAccounts(String query, String orderBy, AccountsGetOrder order, int offset, int limit, List facets,
- String lang,
- Map okapiHeaders, Handler> asyncResultHandler,
- Context vertxContext) {
+ public void getAccounts(String query, String orderBy, AccountsGetOrder order, String totalRecords,
+ int offset, int limit, List facets, Map okapiHeaders,
+ Handler> asyncResultHandler, Context vertxContext) {
+
String tenantId = TenantTool.calculateTenantId(okapiHeaders.get(OKAPI_HEADER_TENANT));
List facetList = FacetManager.convertFacetStrings2FacetFields(facets, "jsonb");
try {
@@ -176,7 +177,7 @@ public void getAccounts(String query, String orderBy, AccountsGetOrder order, in
} else {
asyncResultHandler.handle(succeededFuture(
GetAccountsResponse.respond500WithTextPlain(
- messages.getMessage(lang,
+ messages.getMessage(DEFAULT_LANGUAGE,
MessageConsts.InternalServerError))));
}
}
@@ -190,7 +191,7 @@ public void getAccounts(String query, String orderBy, AccountsGetOrder order, in
} else {
asyncResultHandler.handle(succeededFuture(
GetAccountsResponse.respond500WithTextPlain(
- messages.getMessage(lang,
+ messages.getMessage(DEFAULT_LANGUAGE,
MessageConsts.InternalServerError))));
}
}
@@ -198,11 +199,8 @@ public void getAccounts(String query, String orderBy, AccountsGetOrder order, in
@Validate
@Override
- public void postAccounts(String lang,
- Account entity,
- Map okapiHeaders,
- Handler> asyncResultHandler,
- Context vertxContext) {
+ public void postAccounts(Account entity, Map okapiHeaders,
+ Handler> asyncResultHandler, Context vertxContext) {
PgUtil.post(ACCOUNTS_TABLE, entity, okapiHeaders, vertxContext,
PostAccountsResponse.class, post -> {
@@ -216,8 +214,9 @@ public void postAccounts(String lang,
@Validate
@Override
- public void getAccountsByAccountId(String accountId, String lang, Map okapiHeaders,
+ public void getAccountsByAccountId(String accountId, Map okapiHeaders,
Handler> asyncResultHandler, Context vertxContext) {
+
try {
vertxContext.runOnContext(v -> {
String tenantId = TenantTool.calculateTenantId(okapiHeaders.get(OKAPI_HEADER_TENANT));
@@ -235,19 +234,19 @@ public void getAccountsByAccountId(String accountId, String lang, Map accountList = getReply.result().getResults();
if (accountList.isEmpty()) {
asyncResultHandler.handle(succeededFuture(
GetAccountsByAccountIdResponse.respond404WithTextPlain("Account"
- + messages.getMessage(lang,
+ + messages.getMessage(DEFAULT_LANGUAGE,
MessageConsts.ObjectDoesNotExist))));
} else if (accountList.size() > 1) {
logger.error("Multiple accounts found with the same id");
asyncResultHandler.handle(succeededFuture(
GetAccountsByAccountIdResponse.respond500WithTextPlain(
- messages.getMessage(lang,
+ messages.getMessage(DEFAULT_LANGUAGE,
MessageConsts.InternalServerError))));
} else {
setAdditionalFields(vertxContext.owner(), okapiHeaders, accountList)
@@ -262,20 +261,21 @@ public void getAccountsByAccountId(String accountId, String lang, Map okapiHeaders,
+ public void deleteAccountsByAccountId(String accountId, Map okapiHeaders,
Handler> asyncResultHandler, Context vertxContext) {
+
try {
vertxContext.runOnContext(v -> {
String tenantId = TenantTool.calculateTenantId(okapiHeaders.get(OKAPI_HEADER_TENANT));
@@ -304,7 +304,7 @@ public void deleteAccountsByAccountId(String accountId, String lang, Map okapiHeaders,
- Handler> asyncResultHandler, Context vertxContext) {
+ public void putAccountsByAccountId(String accountId, Account entity,
+ Map okapiHeaders, Handler> asyncResultHandler,
+ Context vertxContext) {
new AccountUpdateService(okapiHeaders, vertxContext)
.updateAccount(accountId, entity)
diff --git a/src/main/java/org/folio/rest/impl/CommentsAPI.java b/src/main/java/org/folio/rest/impl/CommentsAPI.java
index 4d0dc4cd..13d22225 100644
--- a/src/main/java/org/folio/rest/impl/CommentsAPI.java
+++ b/src/main/java/org/folio/rest/impl/CommentsAPI.java
@@ -1,5 +1,7 @@
package org.folio.rest.impl;
+import static org.folio.rest.tools.messages.Messages.DEFAULT_LANGUAGE;
+
import io.vertx.core.AsyncResult;
import io.vertx.core.Context;
import io.vertx.core.Future;
@@ -47,10 +49,10 @@ private CQLWrapper getCQL(String query, int limit, int offset) throws CQL2PgJSON
@Validate
@Override
- public void getComments(String query, String orderBy, CommentsGetOrder order, int offset, int limit, List facets,
- String lang,
- Map okapiHeaders, Handler> asyncResultHandler,
- Context vertxContext) {
+ public void getComments(String query, String orderBy, CommentsGetOrder order, String totalRecords,
+ int offset, int limit, List facets, Map okapiHeaders,
+ Handler> asyncResultHandler, Context vertxContext) {
+
String tenantId = TenantTool.calculateTenantId(okapiHeaders.get(OKAPI_HEADER_TENANT));
List facetList = FacetManager.convertFacetStrings2FacetFields(facets, "jsonb");
try {
@@ -93,7 +95,7 @@ public void getComments(String query, String orderBy, CommentsGetOrder order, in
} else {
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(
GetCommentsResponse.respond500WithTextPlain(
- messages.getMessage(lang,
+ messages.getMessage(DEFAULT_LANGUAGE,
MessageConsts.InternalServerError))));
}
}
@@ -107,7 +109,7 @@ public void getComments(String query, String orderBy, CommentsGetOrder order, in
} else {
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(
GetCommentsResponse.respond500WithTextPlain(
- messages.getMessage(lang,
+ messages.getMessage(DEFAULT_LANGUAGE,
MessageConsts.InternalServerError))));
}
}
@@ -115,7 +117,7 @@ public void getComments(String query, String orderBy, CommentsGetOrder order, in
@Validate
@Override
- public void postComments(String lang, Comment entity, Map okapiHeaders,
+ public void postComments(Comment entity, Map okapiHeaders,
Handler> asyncResultHandler, Context vertxContext) {
if (entity.getId() == null) {
entity.setId(UUID.randomUUID().toString());
@@ -141,7 +143,7 @@ public void postComments(String lang, Comment entity, Map okapiH
postgresClient.rollbackTx(beginTx, rollback -> {
asyncResultHandler.handle(Future.succeededFuture(
PostCommentsResponse.respond400WithTextPlain(
- messages.getMessage(lang, MessageConsts.UnableToProcessRequest))));
+ messages.getMessage(DEFAULT_LANGUAGE, MessageConsts.UnableToProcessRequest))));
});
}
} catch (Exception e) {
@@ -162,13 +164,13 @@ public void postComments(String lang, Comment entity, Map okapiH
} catch (Exception e) {
asyncResultHandler.handle(Future.succeededFuture(
PostCommentsResponse.respond500WithTextPlain(
- messages.getMessage(lang, MessageConsts.InternalServerError))));
+ messages.getMessage(DEFAULT_LANGUAGE, MessageConsts.InternalServerError))));
}
}
@Validate
@Override
- public void getCommentsByCommentId(String commentId, String lang, Map okapiHeaders,
+ public void getCommentsByCommentId(String commentId, Map okapiHeaders,
Handler> asyncResultHandler, Context vertxContext) {
try {
vertxContext.runOnContext(v -> {
@@ -187,19 +189,19 @@ public void getCommentsByCommentId(String commentId, String lang, Map commentList = getReply.result().getResults();
if (commentList.isEmpty()) {
asyncResultHandler.handle(Future.succeededFuture(
GetCommentsByCommentIdResponse.respond404WithTextPlain("Comment"
- + messages.getMessage(lang,
+ + messages.getMessage(DEFAULT_LANGUAGE,
MessageConsts.ObjectDoesNotExist))));
} else if (commentList.size() > 1) {
logger.error("Multiple comments found with the same id");
asyncResultHandler.handle(Future.succeededFuture(
GetCommentsByCommentIdResponse.respond500WithTextPlain(
- messages.getMessage(lang,
+ messages.getMessage(DEFAULT_LANGUAGE,
MessageConsts.InternalServerError))));
} else {
asyncResultHandler.handle(Future.succeededFuture(
@@ -211,19 +213,19 @@ public void getCommentsByCommentId(String commentId, String lang, Map okapiHeaders,
+ public void deleteCommentsByCommentId(String commentId, Map okapiHeaders,
Handler> asyncResultHandler, Context vertxContext) {
try {
vertxContext.runOnContext(v -> {
@@ -251,7 +253,7 @@ public void deleteCommentsByCommentId(String commentId, String lang, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) {
+ public void putCommentsByCommentId(String commentId, Comment entity,
+ Map okapiHeaders, Handler> asyncResultHandler,
+ Context vertxContext) {
+
try {
if (commentId == null) {
logger.error("commentId is missing");
@@ -304,7 +308,7 @@ public void putCommentsByCommentId(String commentId, String lang, Comment entity
logger.error(getReply.cause().getLocalizedMessage());
asyncResultHandler.handle(Future.succeededFuture(
PutCommentsByCommentIdResponse.respond500WithTextPlain(
- messages.getMessage(lang,
+ messages.getMessage(DEFAULT_LANGUAGE,
MessageConsts.InternalServerError))));
} else if (getReply.result().getResults().size() == 1) {
try {
@@ -321,7 +325,7 @@ public void putCommentsByCommentId(String commentId, String lang, Comment entity
} catch (Exception e) {
logger.error(e.getLocalizedMessage(), e);
asyncResultHandler.handle(Future.succeededFuture(
- PutCommentsByCommentIdResponse.respond500WithTextPlain(messages.getMessage(lang,
+ PutCommentsByCommentIdResponse.respond500WithTextPlain(messages.getMessage(DEFAULT_LANGUAGE,
MessageConsts.InternalServerError))));
}
} else if (getReply.result().getResults().isEmpty()) {
@@ -336,14 +340,14 @@ public void putCommentsByCommentId(String commentId, String lang, Comment entity
logger.error(e.getLocalizedMessage(), e);
asyncResultHandler.handle(Future.succeededFuture(
PutCommentsByCommentIdResponse.respond500WithTextPlain(
- messages.getMessage(lang, MessageConsts.InternalServerError))));
+ messages.getMessage(DEFAULT_LANGUAGE, MessageConsts.InternalServerError))));
}
});
} catch (Exception e) {
logger.error(e.getLocalizedMessage(), e);
asyncResultHandler.handle(Future.succeededFuture(
PutCommentsByCommentIdResponse.respond500WithTextPlain(
- messages.getMessage(lang, MessageConsts.InternalServerError))));
+ messages.getMessage(DEFAULT_LANGUAGE, MessageConsts.InternalServerError))));
}
}
}
diff --git a/src/main/java/org/folio/rest/impl/FeeFineActionsAPI.java b/src/main/java/org/folio/rest/impl/FeeFineActionsAPI.java
index 2995f4e7..557026de 100644
--- a/src/main/java/org/folio/rest/impl/FeeFineActionsAPI.java
+++ b/src/main/java/org/folio/rest/impl/FeeFineActionsAPI.java
@@ -1,8 +1,8 @@
package org.folio.rest.impl;
import static org.apache.commons.lang3.BooleanUtils.isTrue;
-import static org.folio.rest.domain.Action.CREDIT;
import static org.folio.rest.service.LogEventPublisher.LogEventPayloadType.FEE_FINE;
+import static org.folio.rest.tools.messages.Messages.DEFAULT_LANGUAGE;
import java.io.IOException;
import java.util.List;
@@ -61,7 +61,7 @@ private CQLWrapper getCQL(String query, int limit, int offset)
@Validate
@Override
public void getFeefineactions(String query, String orderBy, FeefineactionsGetOrder order,
- int offset, int limit, String lang, Map okapiHeaders,
+ String totalRecords, int offset, int limit, Map okapiHeaders,
Handler> asyncResultHandler, Context vertxContext) {
String tenantId = TenantTool.calculateTenantId(okapiHeaders.get(OKAPI_HEADER_TENANT));
@@ -112,7 +112,7 @@ public void getFeefineactions(String query, String orderBy, FeefineactionsGetOrd
} else {
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(
GetFeefineactionsResponse.respond500WithTextPlain(
- messages.getMessage(lang,
+ messages.getMessage(DEFAULT_LANGUAGE,
MessageConsts.InternalServerError))));
}
}
@@ -130,7 +130,7 @@ public void getFeefineactions(String query, String orderBy, FeefineactionsGetOrd
} else {
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(
GetFeefineactionsResponse.respond500WithTextPlain(
- messages.getMessage(lang,
+ messages.getMessage(DEFAULT_LANGUAGE,
MessageConsts.InternalServerError))));
}
}
@@ -138,9 +138,8 @@ public void getFeefineactions(String query, String orderBy, FeefineactionsGetOrd
@Validate
@Override
- public void postFeefineactions(String lang, Feefineaction entity,
- Map okapiHeaders, Handler> asyncResultHandler,
- Context vertxContext) {
+ public void postFeefineactions(Feefineaction entity, Map okapiHeaders,
+ Handler> asyncResultHandler, Context vertxContext) {
Promise postCompleted = Promise.promise();
PgUtil.post(FEEFINEACTIONS_TABLE, entity, okapiHeaders, vertxContext,
@@ -172,7 +171,7 @@ private void publishLogEvent(Feefineaction entity, Map okapiHead
@Validate
@Override
- public void getFeefineactionsByFeefineactionId(String feefineactionId, String lang,
+ public void getFeefineactionsByFeefineactionId(String feefineactionId,
Map okapiHeaders, Handler> asyncResultHandler,
Context vertxContext) {
@@ -192,19 +191,19 @@ public void getFeefineactionsByFeefineactionId(String feefineactionId, String la
logger.error(getReply.result());
asyncResultHandler.handle(Future.succeededFuture(
GetFeefineactionsByFeefineactionIdResponse.respond500WithTextPlain(
- messages.getMessage(lang, MessageConsts.InternalServerError))));
+ messages.getMessage(DEFAULT_LANGUAGE, MessageConsts.InternalServerError))));
} else {
List feefineactionList = getReply.result().getResults();
if (feefineactionList.isEmpty()) {
asyncResultHandler.handle(Future.succeededFuture(
GetFeefineactionsByFeefineactionIdResponse.respond404WithTextPlain(
- "Feefineaction" + messages.getMessage(lang,
+ "Feefineaction" + messages.getMessage(DEFAULT_LANGUAGE,
MessageConsts.ObjectDoesNotExist))));
} else if (feefineactionList.size() > 1) {
logger.error("Multiple feefineactions found with the same id");
asyncResultHandler.handle(Future.succeededFuture(
GetFeefineactionsByFeefineactionIdResponse.respond500WithTextPlain(
- messages.getMessage(lang,
+ messages.getMessage(DEFAULT_LANGUAGE,
MessageConsts.InternalServerError))));
} else {
asyncResultHandler.handle(Future.succeededFuture(
@@ -217,19 +216,19 @@ public void getFeefineactionsByFeefineactionId(String feefineactionId, String la
logger.error(e.getMessage());
asyncResultHandler.handle(Future.succeededFuture(
GetFeefineactionsResponse.respond500WithTextPlain(messages.getMessage(
- lang, MessageConsts.InternalServerError))));
+ DEFAULT_LANGUAGE, MessageConsts.InternalServerError))));
}
});
} catch (Exception e) {
asyncResultHandler.handle(Future.succeededFuture(
GetFeefineactionsResponse.respond500WithTextPlain(messages.getMessage(
- lang, MessageConsts.InternalServerError))));
+ DEFAULT_LANGUAGE, MessageConsts.InternalServerError))));
}
}
@Validate
@Override
- public void deleteFeefineactionsByFeefineactionId(String feefineactionId, String lang,
+ public void deleteFeefineactionsByFeefineactionId(String feefineactionId,
Map okapiHeaders, Handler> asyncResultHandler,
Context vertxContext) {
@@ -262,7 +261,7 @@ public void deleteFeefineactionsByFeefineactionId(String feefineactionId, String
if (error == null) {
asyncResultHandler.handle(Future.succeededFuture(
DeleteFeefineactionsByFeefineactionIdResponse.respond500WithTextPlain(
- messages.getMessage(lang, MessageConsts.InternalServerError))));
+ messages.getMessage(DEFAULT_LANGUAGE, MessageConsts.InternalServerError))));
} else {
asyncResultHandler.handle(Future.succeededFuture(
DeleteFeefineactionsByFeefineactionIdResponse.respond400WithTextPlain(error)));
@@ -274,7 +273,7 @@ public void deleteFeefineactionsByFeefineactionId(String feefineactionId, String
asyncResultHandler.handle(
Future.succeededFuture(
DeleteFeefineactionsByFeefineactionIdResponse.respond500WithTextPlain(
- messages.getMessage(lang,
+ messages.getMessage(DEFAULT_LANGUAGE,
MessageConsts.InternalServerError))));
}
@@ -284,16 +283,16 @@ public void deleteFeefineactionsByFeefineactionId(String feefineactionId, String
asyncResultHandler.handle(
Future.succeededFuture(
DeleteFeefineactionsByFeefineactionIdResponse.respond500WithTextPlain(
- messages.getMessage(lang,
+ messages.getMessage(DEFAULT_LANGUAGE,
MessageConsts.InternalServerError))));
}
}
@Validate
@Override
- public void putFeefineactionsByFeefineactionId(String feefineactionId, String lang,
- Feefineaction entity, Map okapiHeaders,
- Handler> asyncResultHandler, Context vertxContext) {
+ public void putFeefineactionsByFeefineactionId(String feefineactionId, Feefineaction entity,
+ Map okapiHeaders, Handler> asyncResultHandler,
+ Context vertxContext) {
try {
if (feefineactionId == null) {
@@ -318,7 +317,7 @@ public void putFeefineactionsByFeefineactionId(String feefineactionId, String la
logger.error(getReply.cause().getLocalizedMessage());
asyncResultHandler.handle(Future.succeededFuture(
PutFeefineactionsByFeefineactionIdResponse.respond500WithTextPlain(
- messages.getMessage(lang,
+ messages.getMessage(DEFAULT_LANGUAGE,
MessageConsts.InternalServerError))));
} else if (getReply.result().getResults().size() == 1) {
try {
@@ -336,7 +335,7 @@ public void putFeefineactionsByFeefineactionId(String feefineactionId, String la
} catch (Exception e) {
asyncResultHandler.handle(Future.succeededFuture(
PutFeefineactionsByFeefineactionIdResponse
- .respond500WithTextPlain(messages.getMessage(lang,
+ .respond500WithTextPlain(messages.getMessage(DEFAULT_LANGUAGE,
MessageConsts.InternalServerError))));
}
} else if (getReply.result().getResults().isEmpty()) {
@@ -353,14 +352,14 @@ public void putFeefineactionsByFeefineactionId(String feefineactionId, String la
logger.error(e.getLocalizedMessage(), e);
asyncResultHandler.handle(Future.succeededFuture(
PutFeefineactionsByFeefineactionIdResponse.respond500WithTextPlain(
- messages.getMessage(lang, MessageConsts.InternalServerError))));
+ messages.getMessage(DEFAULT_LANGUAGE, MessageConsts.InternalServerError))));
}
});
} catch (Exception e) {
logger.error(e.getLocalizedMessage(), e);
asyncResultHandler.handle(Future.succeededFuture(
PutFeefineactionsByFeefineactionIdResponse.respond500WithTextPlain(
- messages.getMessage(lang, MessageConsts.InternalServerError))));
+ messages.getMessage(DEFAULT_LANGUAGE, MessageConsts.InternalServerError))));
}
}
}
diff --git a/src/main/java/org/folio/rest/impl/FeeFinesAPI.java b/src/main/java/org/folio/rest/impl/FeeFinesAPI.java
index 209f7ab0..901b54ce 100644
--- a/src/main/java/org/folio/rest/impl/FeeFinesAPI.java
+++ b/src/main/java/org/folio/rest/impl/FeeFinesAPI.java
@@ -2,6 +2,7 @@
import static io.vertx.core.Future.succeededFuture;
import static org.folio.rest.jaxrs.resource.Feefines.PostFeefinesResponse.respond422WithApplicationJson;
+import static org.folio.rest.tools.messages.Messages.DEFAULT_LANGUAGE;
import static org.folio.rest.utils.ErrorHelper.createErrors;
import java.io.IOException;
@@ -57,8 +58,10 @@ private CQLWrapper getCQL(String query, int limit, int offset) throws CQL2PgJSON
@Validate
@Override
- public void getFeefines(String query, String orderBy, FeefinesGetOrder order, int offset, int limit, List facets,
- String lang, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) {
+ public void getFeefines(String query, String orderBy, FeefinesGetOrder order, String totalRecords,
+ int offset, int limit, List facets, Map okapiHeaders,
+ Handler> asyncResultHandler, Context vertxContext) {
+
String tenantId = TenantTool.calculateTenantId(okapiHeaders.get(OKAPI_HEADER_TENANT));
List facetList = FacetManager.convertFacetStrings2FacetFields(facets, "jsonb");
try {
@@ -102,7 +105,7 @@ public void getFeefines(String query, String orderBy, FeefinesGetOrder order, in
} else {
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(
GetFeefinesResponse.respond500WithTextPlain(
- messages.getMessage(lang,
+ messages.getMessage(DEFAULT_LANGUAGE,
MessageConsts.InternalServerError))));
}
}
@@ -117,7 +120,7 @@ public void getFeefines(String query, String orderBy, FeefinesGetOrder order, in
} else {
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(
GetFeefinesResponse.respond500WithTextPlain(
- messages.getMessage(lang,
+ messages.getMessage(DEFAULT_LANGUAGE,
MessageConsts.InternalServerError))));
}
}
@@ -125,8 +128,9 @@ public void getFeefines(String query, String orderBy, FeefinesGetOrder order, in
@Validate
@Override
- public void postFeefines(String lang, Feefine entity, Map okapiHeaders,
+ public void postFeefines(Feefine entity, Map okapiHeaders,
Handler> asyncResultHandler, Context vertxContext) {
+
if (entity.getId() == null) {
entity.setId(UUID.randomUUID().toString());
}
@@ -156,7 +160,7 @@ public void postFeefines(String lang, Feefine entity, Map okapiH
postgresClient.rollbackTx(beginTx, rollback -> {
asyncResultHandler.handle(Future.succeededFuture(
PostFeefinesResponse.respond400WithTextPlain(
- messages.getMessage(lang, MessageConsts.UnableToProcessRequest))));
+ messages.getMessage(DEFAULT_LANGUAGE, MessageConsts.UnableToProcessRequest))));
});
}
} catch (Exception e) {
@@ -178,14 +182,15 @@ public void postFeefines(String lang, Feefine entity, Map okapiH
} catch (Exception e) {
asyncResultHandler.handle(Future.succeededFuture(
PostFeefinesResponse.respond500WithTextPlain(
- messages.getMessage(lang, MessageConsts.InternalServerError))));
+ messages.getMessage(DEFAULT_LANGUAGE, MessageConsts.InternalServerError))));
}
}
@Validate
@Override
- public void getFeefinesByFeefineId(String feefineId, String lang, Map okapiHeaders,
+ public void getFeefinesByFeefineId(String feefineId, Map okapiHeaders,
Handler> asyncResultHandler, Context vertxContext) {
+
try {
vertxContext.runOnContext(v -> {
String tenantId = TenantTool.calculateTenantId(okapiHeaders.get(OKAPI_HEADER_TENANT));
@@ -202,19 +207,19 @@ public void getFeefinesByFeefineId(String feefineId, String lang, Map feefineList = getReply.result().getResults();
if (feefineList.isEmpty()) {
asyncResultHandler.handle(Future.succeededFuture(
GetFeefinesByFeefineIdResponse.respond404WithTextPlain("Feefine"
- + messages.getMessage(lang,
+ + messages.getMessage(DEFAULT_LANGUAGE,
MessageConsts.ObjectDoesNotExist))));
} else if (feefineList.size() > 1) {
logger.error("Multiple feefines found with the same id");
asyncResultHandler.handle(Future.succeededFuture(
GetFeefinesByFeefineIdResponse.respond500WithTextPlain(
- messages.getMessage(lang,
+ messages.getMessage(DEFAULT_LANGUAGE,
MessageConsts.InternalServerError))));
} else {
asyncResultHandler.handle(Future.succeededFuture(
@@ -226,24 +231,22 @@ public void getFeefinesByFeefineId(String feefineId, String lang, Map okapiHeaders,
- Handler> asyncResultHandler,
- Context vertxContext) {
+ public void deleteFeefinesByFeefineId(String feefineId, Map okapiHeaders,
+ Handler> asyncResultHandler, Context vertxContext) {
+
try {
vertxContext.runOnContext(v -> {
// Automatic fee/fine types can't be deleted
@@ -276,7 +279,7 @@ public void deleteFeefinesByFeefineId(String feefineId,
logger.error(error, deleteReply.cause());
if (error == null) {
asyncResultHandler.handle(Future.succeededFuture(DeleteFeefinesByFeefineIdResponse.respond500WithTextPlain(
- messages.getMessage(lang, MessageConsts.InternalServerError))));
+ messages.getMessage(DEFAULT_LANGUAGE, MessageConsts.InternalServerError))));
} else {
asyncResultHandler.handle(
Future.succeededFuture(DeleteFeefinesByFeefineIdResponse.respond400WithTextPlain(error)));
@@ -288,7 +291,7 @@ public void deleteFeefinesByFeefineId(String feefineId,
asyncResultHandler.handle(
Future.succeededFuture(
DeleteFeefinesByFeefineIdResponse.respond500WithTextPlain(
- messages.getMessage(lang,
+ messages.getMessage(DEFAULT_LANGUAGE,
MessageConsts.InternalServerError))));
}
@@ -298,17 +301,15 @@ public void deleteFeefinesByFeefineId(String feefineId,
asyncResultHandler.handle(
Future.succeededFuture(
DeleteFeefinesByFeefineIdResponse.respond500WithTextPlain(
- messages.getMessage(lang,
+ messages.getMessage(DEFAULT_LANGUAGE,
MessageConsts.InternalServerError))));
}
}
@Validate
@Override
- public void putFeefinesByFeefineId(String feefineId,
- String lang, Feefine entity,
- Map okapiHeaders,
- Handler> asyncResultHandler,
+ public void putFeefinesByFeefineId(String feefineId, Feefine entity,
+ Map okapiHeaders, Handler> asyncResultHandler,
Context vertxContext) {
try {
@@ -339,7 +340,7 @@ public void putFeefinesByFeefineId(String feefineId,
logger.error(getReply.cause().getLocalizedMessage());
asyncResultHandler.handle(Future.succeededFuture(
PutFeefinesByFeefineIdResponse.respond500WithTextPlain(
- messages.getMessage(lang,
+ messages.getMessage(DEFAULT_LANGUAGE,
MessageConsts.InternalServerError))));
} else if (getReply.result().getResults().size() == 1) {
try {
@@ -355,7 +356,7 @@ public void putFeefinesByFeefineId(String feefineId,
});
} catch (Exception e) {
asyncResultHandler.handle(Future.succeededFuture(
- PutFeefinesByFeefineIdResponse.respond500WithTextPlain(messages.getMessage(lang,
+ PutFeefinesByFeefineIdResponse.respond500WithTextPlain(messages.getMessage(DEFAULT_LANGUAGE,
MessageConsts.InternalServerError))));
}
} else if (getReply.result().getResults().isEmpty()) {
@@ -370,14 +371,14 @@ public void putFeefinesByFeefineId(String feefineId,
logger.error(e.getLocalizedMessage(), e);
asyncResultHandler.handle(Future.succeededFuture(
PutFeefinesByFeefineIdResponse.respond500WithTextPlain(
- messages.getMessage(lang, MessageConsts.InternalServerError))));
+ messages.getMessage(DEFAULT_LANGUAGE, MessageConsts.InternalServerError))));
}
});
} catch (Exception e) {
logger.error(e.getLocalizedMessage(), e);
asyncResultHandler.handle(Future.succeededFuture(
PutFeefinesByFeefineIdResponse.respond500WithTextPlain(
- messages.getMessage(lang, MessageConsts.InternalServerError))));
+ messages.getMessage(DEFAULT_LANGUAGE, MessageConsts.InternalServerError))));
}
}
diff --git a/src/main/java/org/folio/rest/impl/LostItemFeePoliciesAPI.java b/src/main/java/org/folio/rest/impl/LostItemFeePoliciesAPI.java
index eabbc732..821cd9f5 100644
--- a/src/main/java/org/folio/rest/impl/LostItemFeePoliciesAPI.java
+++ b/src/main/java/org/folio/rest/impl/LostItemFeePoliciesAPI.java
@@ -32,13 +32,9 @@ public class LostItemFeePoliciesAPI implements LostItemFeesPolicies {
@Validate
@Override
- public void getLostItemFeesPolicies(String query,
- String orderBy,
- LostItemFeesPoliciesGetOrder order,
- int offset, int limit,
- String lang,
- Map okapiHeaders,
- Handler> asyncResultHandler,
+ public void getLostItemFeesPolicies(String query, String orderBy,
+ LostItemFeesPoliciesGetOrder order, String totalRecords, int offset, int limit,
+ Map okapiHeaders, Handler> asyncResultHandler,
Context vertxContext) {
PgUtil.get(TABLE_NAME, LostItemFeePolicy.class, LostItemFeePolicies.class, query, offset, limit, okapiHeaders, vertxContext,
@@ -47,11 +43,8 @@ public void getLostItemFeesPolicies(String query,
@Validate
@Override
- public void postLostItemFeesPolicies(String lang,
- LostItemFeePolicy entity,
- Map okapiHeaders,
- Handler> asyncResultHandler,
- Context vertxContext) {
+ public void postLostItemFeesPolicies(LostItemFeePolicy entity, Map okapiHeaders,
+ Handler> asyncResultHandler, Context vertxContext) {
if (refuseWhenLostItemProcessingFeeIsNegative(entity, asyncResultHandler)) {
return;
@@ -72,9 +65,7 @@ public void postLostItemFeesPolicies(String lang,
@Validate
@Override
public void getLostItemFeesPoliciesByLostItemFeePolicyId(String lostItemFeePolicyId,
- String lang,
- Map okapiHeaders,
- Handler> asyncResultHandler,
+ Map okapiHeaders, Handler> asyncResultHandler,
Context vertxContext) {
PgUtil.getById(TABLE_NAME, LostItemFeePolicy.class, lostItemFeePolicyId, okapiHeaders, vertxContext,
@@ -84,9 +75,7 @@ public void getLostItemFeesPoliciesByLostItemFeePolicyId(String lostItemFeePolic
@Validate
@Override
public void deleteLostItemFeesPoliciesByLostItemFeePolicyId(String lostItemFeePolicyId,
- String lang,
- Map okapiHeaders,
- Handler> asyncResultHandler,
+ Map okapiHeaders, Handler> asyncResultHandler,
Context vertxContext) {
PgUtil.deleteById(TABLE_NAME, lostItemFeePolicyId, okapiHeaders, vertxContext,
@@ -96,11 +85,8 @@ public void deleteLostItemFeesPoliciesByLostItemFeePolicyId(String lostItemFeePo
@Validate
@Override
public void putLostItemFeesPoliciesByLostItemFeePolicyId(String lostItemFeePolicyId,
- String lang,
- LostItemFeePolicy entity,
- Map okapiHeaders,
- Handler> asyncResultHandler,
- Context vertxContext) {
+ LostItemFeePolicy entity, Map okapiHeaders,
+ Handler> asyncResultHandler, Context vertxContext) {
if (refuseWhenLostItemProcessingFeeIsNegative(entity, asyncResultHandler)) {
return;
diff --git a/src/main/java/org/folio/rest/impl/ManualBlockTemplatesAPI.java b/src/main/java/org/folio/rest/impl/ManualBlockTemplatesAPI.java
index bc59c50d..ae28bc9c 100644
--- a/src/main/java/org/folio/rest/impl/ManualBlockTemplatesAPI.java
+++ b/src/main/java/org/folio/rest/impl/ManualBlockTemplatesAPI.java
@@ -9,6 +9,7 @@
import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.Pattern;
+
import javax.ws.rs.core.Response;
import org.folio.rest.annotations.Validate;
@@ -25,10 +26,12 @@ public class ManualBlockTemplatesAPI implements ManualBlockTemplates {
@Override
@Validate
public void getManualBlockTemplates(String query, String orderBy,
- ManualBlockTemplatesGetOrder order, @Min(0) @Max(2147483647) int offset,
- @Min(0) @Max(2147483647) int limit, @Pattern(regexp = "[a-zA-Z]{2}") String lang,
+ ManualBlockTemplatesGetOrder order,
+ @Pattern(regexp = "exact|estimated|none|auto") String totalRecords,
+ @Min(0) @Max(2147483647) int offset, @Min(0) @Max(2147483647) int limit,
Map okapiHeaders, Handler> asyncResultHandler,
Context vertxContext) {
+
PgUtil
.get(TEMPLATES_TABLE, ManualBlockTemplate.class, ManualBlockTemplateCollection.class, query,
offset, limit, okapiHeaders, vertxContext, GetManualBlockTemplatesResponse.class,
@@ -37,37 +40,37 @@ public void getManualBlockTemplates(String query, String orderBy,
@Override
@Validate
- public void postManualBlockTemplates(@Pattern(regexp = "[a-zA-Z]{2}") String lang,
- ManualBlockTemplate entity, Map okapiHeaders,
+ public void postManualBlockTemplates(ManualBlockTemplate entity, Map okapiHeaders,
Handler> asyncResultHandler, Context vertxContext) {
+
PgUtil.post(TEMPLATES_TABLE, entity, okapiHeaders, vertxContext,
PostManualBlockTemplatesResponse.class, asyncResultHandler);
-
}
@Override
@Validate
- public void getManualBlockTemplatesById(String id, @Pattern(regexp = "[a-zA-Z]{2}") String lang,
- Map okapiHeaders, Handler> asyncResultHandler,
- Context vertxContext) {
+ public void getManualBlockTemplatesById(String id, Map okapiHeaders,
+ Handler> asyncResultHandler, Context vertxContext) {
+
PgUtil.getById(TEMPLATES_TABLE, ManualBlockTemplate.class, id, okapiHeaders, vertxContext,
GetManualBlockTemplatesByIdResponse.class, asyncResultHandler);
}
@Override
@Validate
- public void putManualBlockTemplatesById(String id, @Pattern(regexp = "[a-zA-Z]{2}") String lang,
- ManualBlockTemplate entity, Map okapiHeaders,
- Handler> asyncResultHandler, Context vertxContext) {
+ public void putManualBlockTemplatesById(String id, ManualBlockTemplate entity,
+ Map okapiHeaders, Handler> asyncResultHandler,
+ Context vertxContext) {
+
PgUtil.put(TEMPLATES_TABLE, entity, id, okapiHeaders, vertxContext,
PutManualBlockTemplatesByIdResponse.class, asyncResultHandler);
}
@Override
@Validate
- public void deleteManualBlockTemplatesById(String id,
- @Pattern(regexp = "[a-zA-Z]{2}") String lang, Map okapiHeaders,
+ public void deleteManualBlockTemplatesById(String id, Map okapiHeaders,
Handler> asyncResultHandler, Context vertxContext) {
+
PgUtil.deleteById(TEMPLATES_TABLE, id, okapiHeaders, vertxContext,
DeleteManualBlockTemplatesByIdResponse.class, asyncResultHandler);
}
diff --git a/src/main/java/org/folio/rest/impl/ManualBlocksAPI.java b/src/main/java/org/folio/rest/impl/ManualBlocksAPI.java
index c6ce11de..ead8691e 100644
--- a/src/main/java/org/folio/rest/impl/ManualBlocksAPI.java
+++ b/src/main/java/org/folio/rest/impl/ManualBlocksAPI.java
@@ -3,6 +3,7 @@
import static org.folio.rest.service.LogEventPublisher.LogEventPayloadType.MANUAL_BLOCK_CREATED;
import static org.folio.rest.service.LogEventPublisher.LogEventPayloadType.MANUAL_BLOCK_DELETED;
import static org.folio.rest.service.LogEventPublisher.LogEventPayloadType.MANUAL_BLOCK_MODIFIED;
+import static org.folio.rest.tools.messages.Messages.DEFAULT_LANGUAGE;
import java.io.IOException;
import java.util.List;
@@ -56,8 +57,10 @@ private CQLWrapper getCQL(String query, int limit, int offset) throws CQL2PgJSON
@Validate
@Override
- public void getManualblocks(String query, String orderBy, ManualblocksGetOrder order, int offset, int limit, String lang,
- Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) {
+ public void getManualblocks(String query, String orderBy, ManualblocksGetOrder order,
+ String totalRecords, int offset, int limit, Map okapiHeaders,
+ Handler> asyncResultHandler, Context vertxContext) {
+
String tenantId = TenantTool.calculateTenantId(okapiHeaders.get(OKAPI_HEADER_TENANT));
try {
@@ -100,7 +103,7 @@ public void getManualblocks(String query, String orderBy, ManualblocksGetOrder o
} else {
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(
GetManualblocksResponse.respond500WithTextPlain(
- messages.getMessage(lang,
+ messages.getMessage(DEFAULT_LANGUAGE,
MessageConsts.InternalServerError))));
}
}
@@ -115,7 +118,7 @@ public void getManualblocks(String query, String orderBy, ManualblocksGetOrder o
} else {
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(
GetManualblocksResponse.respond500WithTextPlain(
- messages.getMessage(lang,
+ messages.getMessage(DEFAULT_LANGUAGE,
MessageConsts.InternalServerError))));
}
}
@@ -123,8 +126,9 @@ public void getManualblocks(String query, String orderBy, ManualblocksGetOrder o
@Validate
@Override
- public void postManualblocks(String lang, Manualblock entity, Map okapiHeaders,
+ public void postManualblocks(Manualblock entity, Map okapiHeaders,
Handler> asyncResultHandler, Context vertxContext) {
+
if (entity.getId() == null) {
entity.setId(UUID.randomUUID().toString());
}
@@ -153,7 +157,7 @@ public void postManualblocks(String lang, Manualblock entity, Map {
asyncResultHandler.handle(Future.succeededFuture(
PostManualblocksResponse.respond400WithTextPlain(
- messages.getMessage(lang, MessageConsts.UnableToProcessRequest))));
+ messages.getMessage(DEFAULT_LANGUAGE, MessageConsts.UnableToProcessRequest))));
});
}
} catch (Exception e) {
@@ -176,15 +180,16 @@ public void postManualblocks(String lang, Manualblock entity, Map okapiHeaders,
+ public void getManualblocksByManualblockId(String manualblockId, Map okapiHeaders,
Handler> asyncResultHandler, Context vertxContext) {
+
try {
vertxContext.runOnContext(v -> {
String tenantId = TenantTool.calculateTenantId(okapiHeaders.get(OKAPI_HEADER_TENANT));
@@ -202,19 +207,19 @@ public void getManualblocksByManualblockId(String manualblockId, String lang, Ma
logger.error(getReply.result());
asyncResultHandler.handle(Future.succeededFuture(
GetManualblocksByManualblockIdResponse.respond500WithTextPlain(
- messages.getMessage(lang, MessageConsts.InternalServerError))));
+ messages.getMessage(DEFAULT_LANGUAGE, MessageConsts.InternalServerError))));
} else {
List manualblockList = getReply.result().getResults();
if (manualblockList.isEmpty()) {
asyncResultHandler.handle(Future.succeededFuture(
GetManualblocksByManualblockIdResponse.respond404WithTextPlain("Manualblock"
- + messages.getMessage(lang,
+ + messages.getMessage(DEFAULT_LANGUAGE,
MessageConsts.ObjectDoesNotExist))));
} else if (manualblockList.size() > 1) {
logger.error("Multiple manualblocks found with the same id");
asyncResultHandler.handle(Future.succeededFuture(
GetManualblocksByManualblockIdResponse.respond500WithTextPlain(
- messages.getMessage(lang,
+ messages.getMessage(DEFAULT_LANGUAGE,
MessageConsts.InternalServerError))));
} else {
asyncResultHandler.handle(Future.succeededFuture(
@@ -226,22 +231,23 @@ public void getManualblocksByManualblockId(String manualblockId, String lang, Ma
logger.error(e.getMessage());
asyncResultHandler.handle(Future.succeededFuture(
GetManualblocksResponse.respond500WithTextPlain(messages.getMessage(
- lang, MessageConsts.InternalServerError))));
+ DEFAULT_LANGUAGE, MessageConsts.InternalServerError))));
}
});
} catch (Exception e) {
asyncResultHandler.handle(Future.succeededFuture(
GetManualblocksResponse.respond500WithTextPlain(messages.getMessage(
- lang, MessageConsts.InternalServerError))));
+ DEFAULT_LANGUAGE, MessageConsts.InternalServerError))));
}
}
@Validate
@Override
- public void deleteManualblocksByManualblockId(String manualblockId, String lang, Map okapiHeaders,
+ public void deleteManualblocksByManualblockId(String manualblockId, Map okapiHeaders,
Handler> asyncResultHandler, Context vertxContext) {
+
try {
vertxContext.runOnContext(v -> {
String tenantId = TenantTool.calculateTenantId(okapiHeaders.get(OKAPI_HEADER_TENANT));
@@ -282,7 +288,7 @@ public void deleteManualblocksByManualblockId(String manualblockId, String lang,
if (error == null) {
asyncResultHandler.handle(
Future.succeededFuture(DeleteManualblocksByManualblockIdResponse.respond500WithTextPlain(
- messages.getMessage(lang, MessageConsts.InternalServerError))
+ messages.getMessage(DEFAULT_LANGUAGE, MessageConsts.InternalServerError))
));
} else {
asyncResultHandler.handle(
@@ -304,7 +310,7 @@ public void deleteManualblocksByManualblockId(String manualblockId, String lang,
asyncResultHandler.handle(
Future.succeededFuture(
DeleteManualblocksByManualblockIdResponse.respond500WithTextPlain(
- messages.getMessage(lang,
+ messages.getMessage(DEFAULT_LANGUAGE,
MessageConsts.InternalServerError))));
}
@@ -313,15 +319,17 @@ public void deleteManualblocksByManualblockId(String manualblockId, String lang,
asyncResultHandler.handle(
Future.succeededFuture(
DeleteManualblocksByManualblockIdResponse.respond500WithTextPlain(
- messages.getMessage(lang,
+ messages.getMessage(DEFAULT_LANGUAGE,
MessageConsts.InternalServerError))));
}
}
@Validate
@Override
- public void putManualblocksByManualblockId(String manualblockId, String lang, Manualblock entity,
- Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) {
+ public void putManualblocksByManualblockId(String manualblockId, Manualblock entity,
+ Map okapiHeaders, Handler> asyncResultHandler,
+ Context vertxContext) {
+
try {
if (manualblockId == null) {
logger.error("manualblockId is missing ");
@@ -344,7 +352,7 @@ public void putManualblocksByManualblockId(String manualblockId, String lang, Ma
logger.error(getReply.cause().getLocalizedMessage());
asyncResultHandler.handle(Future.succeededFuture(
PutManualblocksByManualblockIdResponse.respond500WithTextPlain(
- messages.getMessage(lang,
+ messages.getMessage(DEFAULT_LANGUAGE,
MessageConsts.InternalServerError))));
} else if (getReply.result().getResults().size() == 1) {
try {
@@ -362,7 +370,7 @@ public void putManualblocksByManualblockId(String manualblockId, String lang, Ma
});
} catch (Exception e) {
asyncResultHandler.handle(Future.succeededFuture(
- PutManualblocksByManualblockIdResponse.respond500WithTextPlain(messages.getMessage(lang,
+ PutManualblocksByManualblockIdResponse.respond500WithTextPlain(messages.getMessage(DEFAULT_LANGUAGE,
MessageConsts.InternalServerError))));
}
} else if (getReply.result().getResults().isEmpty()) {
@@ -377,7 +385,7 @@ public void putManualblocksByManualblockId(String manualblockId, String lang, Ma
logger.error(e.getLocalizedMessage(), e);
asyncResultHandler.handle(Future.succeededFuture(
PutManualblocksByManualblockIdResponse.respond500WithTextPlain(
- messages.getMessage(lang, MessageConsts.InternalServerError))));
+ messages.getMessage(DEFAULT_LANGUAGE, MessageConsts.InternalServerError))));
}
});
@@ -385,7 +393,7 @@ public void putManualblocksByManualblockId(String manualblockId, String lang, Ma
logger.error(e.getLocalizedMessage(), e);
asyncResultHandler.handle(Future.succeededFuture(
PutManualblocksByManualblockIdResponse.respond500WithTextPlain(
- messages.getMessage(lang, MessageConsts.InternalServerError))));
+ messages.getMessage(DEFAULT_LANGUAGE, MessageConsts.InternalServerError))));
}
}
diff --git a/src/main/java/org/folio/rest/impl/OverdueFinePoliciesAPI.java b/src/main/java/org/folio/rest/impl/OverdueFinePoliciesAPI.java
index 0d824999..0d065aa8 100644
--- a/src/main/java/org/folio/rest/impl/OverdueFinePoliciesAPI.java
+++ b/src/main/java/org/folio/rest/impl/OverdueFinePoliciesAPI.java
@@ -33,14 +33,9 @@ public class OverdueFinePoliciesAPI implements OverdueFinesPolicies {
@Validate
@Override
- public void getOverdueFinesPolicies(String query,
- String orderBy,
- OverdueFinesPoliciesGetOrder order,
- int offset, int limit,
- String lang,
- Map okapiHeaders,
- Handler> asyncResultHandler,
- Context vertxContext) {
+ public void getOverdueFinesPolicies(String query, String orderBy, OverdueFinesPoliciesGetOrder order,
+ String totalRecords, int offset, int limit, Map okapiHeaders,
+ Handler> asyncResultHandler, Context vertxContext) {
PgUtil.get(TABLE_NAME, OverdueFinePolicy.class, OverdueFinePolicies.class, query, offset, limit, okapiHeaders, vertxContext,
GetOverdueFinesPoliciesResponse.class, asyncResultHandler);
@@ -48,11 +43,8 @@ public void getOverdueFinesPolicies(String query,
@Validate
@Override
- public void postOverdueFinesPolicies(String lang,
- OverdueFinePolicy entity,
- Map okapiHeaders,
- Handler> asyncResultHandler,
- Context vertxContext) {
+ public void postOverdueFinesPolicies(OverdueFinePolicy entity, Map okapiHeaders,
+ Handler> asyncResultHandler, Context vertxContext) {
if (containsNegativeQuantity(entity)) {
ImmutablePair errorInformation = getErrorInformation(entity);
@@ -77,9 +69,7 @@ public void postOverdueFinesPolicies(String lang,
@Validate
@Override
public void getOverdueFinesPoliciesByOverdueFinePolicyId(String overdueFinePolicyId,
- String lang,
- Map okapiHeaders,
- Handler> asyncResultHandler,
+ Map okapiHeaders, Handler> asyncResultHandler,
Context vertxContext) {
PgUtil.getById(TABLE_NAME, OverdueFinePolicy.class, overdueFinePolicyId, okapiHeaders, vertxContext,
@@ -89,9 +79,7 @@ public void getOverdueFinesPoliciesByOverdueFinePolicyId(String overdueFinePolic
@Validate
@Override
public void deleteOverdueFinesPoliciesByOverdueFinePolicyId(String overdueFinePolicyId,
- String lang,
- Map okapiHeaders,
- Handler> asyncResultHandler,
+ Map okapiHeaders, Handler> asyncResultHandler,
Context vertxContext) {
PgUtil.deleteById(TABLE_NAME, overdueFinePolicyId, okapiHeaders, vertxContext,
@@ -101,11 +89,8 @@ public void deleteOverdueFinesPoliciesByOverdueFinePolicyId(String overdueFinePo
@Validate
@Override
public void putOverdueFinesPoliciesByOverdueFinePolicyId(String overdueFinePolicyId,
- String lang,
- OverdueFinePolicy entity,
- Map okapiHeaders,
- Handler> asyncResultHandler,
- Context vertxContext) {
+ OverdueFinePolicy entity, Map okapiHeaders,
+ Handler> asyncResultHandler, Context vertxContext) {
if (containsNegativeQuantity(entity)) {
ImmutablePair errorInformation = getErrorInformation(entity);
diff --git a/src/main/java/org/folio/rest/impl/OwnersAPI.java b/src/main/java/org/folio/rest/impl/OwnersAPI.java
index 6c63b256..a80a64c5 100644
--- a/src/main/java/org/folio/rest/impl/OwnersAPI.java
+++ b/src/main/java/org/folio/rest/impl/OwnersAPI.java
@@ -1,5 +1,7 @@
package org.folio.rest.impl;
+import static org.folio.rest.tools.messages.Messages.DEFAULT_LANGUAGE;
+
import io.vertx.core.AsyncResult;
import io.vertx.core.Context;
import io.vertx.core.Future;
@@ -48,8 +50,10 @@ private CQLWrapper getCQL(String query, int limit, int offset) throws CQL2PgJSON
@Validate
@Override
- public void getOwners(String query, String orderBy, OwnersGetOrder order, int offset, int limit, String lang,
- Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) {
+ public void getOwners(String query, String orderBy, OwnersGetOrder order, String totalRecords,
+ int offset, int limit, Map okapiHeaders,
+ Handler> asyncResultHandler, Context vertxContext) {
+
String tenantId = TenantTool.calculateTenantId(okapiHeaders.get(OKAPI_HEADER_TENANT));
try {
@@ -92,7 +96,7 @@ public void getOwners(String query, String orderBy, OwnersGetOrder order, int of
} else {
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(
GetOwnersResponse.respond500WithTextPlain(
- messages.getMessage(lang,
+ messages.getMessage(DEFAULT_LANGUAGE,
MessageConsts.InternalServerError))));
}
}
@@ -107,7 +111,7 @@ public void getOwners(String query, String orderBy, OwnersGetOrder order, int of
} else {
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(
GetOwnersResponse.respond500WithTextPlain(
- messages.getMessage(lang,
+ messages.getMessage(DEFAULT_LANGUAGE,
MessageConsts.InternalServerError))));
}
}
@@ -115,8 +119,9 @@ public void getOwners(String query, String orderBy, OwnersGetOrder order, int of
@Validate
@Override
- public void postOwners(String lang, Owner entity, Map okapiHeaders,
+ public void postOwners(Owner entity, Map okapiHeaders,
Handler> asyncResultHandler, Context vertxContext) {
+
if (entity.getId() == null) {
entity.setId(UUID.randomUUID().toString());
}
@@ -141,7 +146,7 @@ public void postOwners(String lang, Owner entity, Map okapiHeade
postgresClient.rollbackTx(beginTx, rollback -> {
asyncResultHandler.handle(Future.succeededFuture(
PostOwnersResponse.respond400WithTextPlain(
- messages.getMessage(lang, MessageConsts.UnableToProcessRequest))));
+ messages.getMessage(DEFAULT_LANGUAGE, MessageConsts.UnableToProcessRequest))));
});
}
} catch (Exception e) {
@@ -164,15 +169,16 @@ public void postOwners(String lang, Owner entity, Map okapiHeade
} catch (Exception e) {
asyncResultHandler.handle(Future.succeededFuture(
PostOwnersResponse.respond500WithTextPlain(
- messages.getMessage(lang, MessageConsts.InternalServerError))));
+ messages.getMessage(DEFAULT_LANGUAGE, MessageConsts.InternalServerError))));
}
}
@Validate
@Override
- public void getOwnersByOwnerId(String ownerId, String lang, Map okapiHeaders,
+ public void getOwnersByOwnerId(String ownerId, Map okapiHeaders,
Handler> asyncResultHandler, Context vertxContext) {
+
try {
vertxContext.runOnContext(v -> {
String tenantId = TenantTool.calculateTenantId(okapiHeaders.get(OKAPI_HEADER_TENANT));
@@ -190,19 +196,19 @@ public void getOwnersByOwnerId(String ownerId, String lang, Map
logger.error(getReply.result());
asyncResultHandler.handle(Future.succeededFuture(
GetOwnersByOwnerIdResponse.respond500WithTextPlain(
- messages.getMessage(lang, MessageConsts.InternalServerError))));
+ messages.getMessage(DEFAULT_LANGUAGE, MessageConsts.InternalServerError))));
} else {
List ownerList = getReply.result().getResults();
if (ownerList.isEmpty()) {
asyncResultHandler.handle(Future.succeededFuture(
GetOwnersByOwnerIdResponse.respond404WithTextPlain("Owner"
- + messages.getMessage(lang,
+ + messages.getMessage(DEFAULT_LANGUAGE,
MessageConsts.ObjectDoesNotExist))));
} else if (ownerList.size() > 1) {
logger.error("Multiple owners found with the same id");
asyncResultHandler.handle(Future.succeededFuture(
GetOwnersByOwnerIdResponse.respond500WithTextPlain(
- messages.getMessage(lang,
+ messages.getMessage(DEFAULT_LANGUAGE,
MessageConsts.InternalServerError))));
} else {
asyncResultHandler.handle(Future.succeededFuture(
@@ -214,21 +220,21 @@ public void getOwnersByOwnerId(String ownerId, String lang, Map
logger.error(e.getMessage());
asyncResultHandler.handle(Future.succeededFuture(
GetOwnersResponse.respond500WithTextPlain(messages.getMessage(
- lang, MessageConsts.InternalServerError))));
+ DEFAULT_LANGUAGE, MessageConsts.InternalServerError))));
}
});
} catch (Exception e) {
asyncResultHandler.handle(Future.succeededFuture(
GetOwnersResponse.respond500WithTextPlain(messages.getMessage(
- lang, MessageConsts.InternalServerError))));
+ DEFAULT_LANGUAGE, MessageConsts.InternalServerError))));
}
}
@Validate
@Override
- public void deleteOwnersByOwnerId(String ownerId, String lang, Map okapiHeaders,
+ public void deleteOwnersByOwnerId(String ownerId, Map okapiHeaders,
Handler> asyncResultHandler, Context vertxContext) {
try {
vertxContext.runOnContext(v -> {
@@ -257,7 +263,7 @@ public void deleteOwnersByOwnerId(String ownerId, String lang, Map okapiHeaders,
+ public void putOwnersByOwnerId(String ownerId, Owner entity, Map okapiHeaders,
Handler> asyncResultHandler, Context vertxContext) {
try {
if (ownerId == null) {
@@ -311,7 +317,7 @@ public void putOwnersByOwnerId(String ownerId, String lang, Owner entity, Map facets,
- String lang,
- Map okapiHeaders, Handler> asyncResultHandler,
- Context vertxContext) {
+ public void getPayments(String query, String orderBy, PaymentsGetOrder order, String totalRecords,
+ int offset, int limit, List facets, Map okapiHeaders,
+ Handler> asyncResultHandler, Context vertxContext) {
+
String tenantId = TenantTool.calculateTenantId(okapiHeaders.get(OKAPI_HEADER_TENANT));
List facetList = FacetManager.convertFacetStrings2FacetFields(facets, "jsonb");
try {
@@ -92,7 +94,7 @@ public void getPayments(String query, String orderBy, PaymentsGetOrder order, in
} else {
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(
GetPaymentsResponse.respond500WithTextPlain(
- messages.getMessage(lang,
+ messages.getMessage(DEFAULT_LANGUAGE,
MessageConsts.InternalServerError))));
}
}
@@ -106,7 +108,7 @@ public void getPayments(String query, String orderBy, PaymentsGetOrder order, in
} else {
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(
GetPaymentsResponse.respond500WithTextPlain(
- messages.getMessage(lang,
+ messages.getMessage(DEFAULT_LANGUAGE,
MessageConsts.InternalServerError))));
}
}
@@ -114,8 +116,9 @@ public void getPayments(String query, String orderBy, PaymentsGetOrder order, in
@Validate
@Override
- public void postPayments(String lang, Payment entity, Map okapiHeaders,
+ public void postPayments(Payment entity, Map okapiHeaders,
Handler> asyncResultHandler, Context vertxContext) {
+
if (entity.getId() == null) {
entity.setId(UUID.randomUUID().toString());
}
@@ -140,7 +143,7 @@ public void postPayments(String lang, Payment entity, Map okapiH
postgresClient.rollbackTx(beginTx, rollback -> {
asyncResultHandler.handle(Future.succeededFuture(
PostPaymentsResponse.respond400WithTextPlain(
- messages.getMessage(lang, MessageConsts.UnableToProcessRequest))));
+ messages.getMessage(DEFAULT_LANGUAGE, MessageConsts.UnableToProcessRequest))));
});
}
} catch (Exception e) {
@@ -161,14 +164,15 @@ public void postPayments(String lang, Payment entity, Map okapiH
} catch (Exception e) {
asyncResultHandler.handle(Future.succeededFuture(
PostPaymentsResponse.respond500WithTextPlain(
- messages.getMessage(lang, MessageConsts.InternalServerError))));
+ messages.getMessage(DEFAULT_LANGUAGE, MessageConsts.InternalServerError))));
}
}
@Validate
@Override
- public void getPaymentsByPaymentId(String paymentId, String lang, Map okapiHeaders,
+ public void getPaymentsByPaymentId(String paymentId, Map okapiHeaders,
Handler> asyncResultHandler, Context vertxContext) {
+
try {
vertxContext.runOnContext(v -> {
String tenantId = TenantTool.calculateTenantId(okapiHeaders.get(OKAPI_HEADER_TENANT));
@@ -186,19 +190,19 @@ public void getPaymentsByPaymentId(String paymentId, String lang, Map paymentList = getReply.result().getResults();
if (paymentList.isEmpty()) {
asyncResultHandler.handle(Future.succeededFuture(
GetPaymentsByPaymentIdResponse.respond404WithTextPlain("Payment"
- + messages.getMessage(lang,
+ + messages.getMessage(DEFAULT_LANGUAGE,
MessageConsts.ObjectDoesNotExist))));
} else if (paymentList.size() > 1) {
logger.error("Multiple payments found with the same id");
asyncResultHandler.handle(Future.succeededFuture(
GetPaymentsByPaymentIdResponse.respond500WithTextPlain(
- messages.getMessage(lang,
+ messages.getMessage(DEFAULT_LANGUAGE,
MessageConsts.InternalServerError))));
} else {
asyncResultHandler.handle(Future.succeededFuture(
@@ -210,20 +214,21 @@ public void getPaymentsByPaymentId(String paymentId, String lang, Map okapiHeaders,
+ public void deletePaymentsByPaymentId(String paymentId, Map okapiHeaders,
Handler> asyncResultHandler, Context vertxContext) {
+
try {
vertxContext.runOnContext(v -> {
String tenantId = TenantTool.calculateTenantId(okapiHeaders.get(OKAPI_HEADER_TENANT));
@@ -250,7 +255,7 @@ public void deletePaymentsByPaymentId(String paymentId, String lang, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) {
+ public void putPaymentsByPaymentId(String paymentId, Payment entity,
+ Map okapiHeaders, Handler> asyncResultHandler,
+ Context vertxContext) {
+
try {
if (paymentId == null) {
logger.error("paymentId is missing");
@@ -303,7 +310,7 @@ public void putPaymentsByPaymentId(String paymentId, String lang, Payment entity
logger.error(getReply.cause().getLocalizedMessage());
asyncResultHandler.handle(Future.succeededFuture(
PutPaymentsByPaymentIdResponse.respond500WithTextPlain(
- messages.getMessage(lang,
+ messages.getMessage(DEFAULT_LANGUAGE,
MessageConsts.InternalServerError))));
} else if (getReply.result().getResults().size() == 1) {
try {
@@ -319,7 +326,7 @@ public void putPaymentsByPaymentId(String paymentId, String lang, Payment entity
});
} catch (Exception e) {
asyncResultHandler.handle(Future.succeededFuture(
- PutPaymentsByPaymentIdResponse.respond500WithTextPlain(messages.getMessage(lang,
+ PutPaymentsByPaymentIdResponse.respond500WithTextPlain(messages.getMessage(DEFAULT_LANGUAGE,
MessageConsts.InternalServerError))));
}
} else if (getReply.result().getResults().isEmpty()) {
@@ -334,14 +341,14 @@ public void putPaymentsByPaymentId(String paymentId, String lang, Payment entity
logger.error(e.getLocalizedMessage(), e);
asyncResultHandler.handle(Future.succeededFuture(
PutPaymentsByPaymentIdResponse.respond500WithTextPlain(
- messages.getMessage(lang, MessageConsts.InternalServerError))));
+ messages.getMessage(DEFAULT_LANGUAGE, MessageConsts.InternalServerError))));
}
});
} catch (Exception e) {
logger.error(e.getLocalizedMessage(), e);
asyncResultHandler.handle(Future.succeededFuture(
PutPaymentsByPaymentIdResponse.respond500WithTextPlain(
- messages.getMessage(lang, MessageConsts.InternalServerError))));
+ messages.getMessage(DEFAULT_LANGUAGE, MessageConsts.InternalServerError))));
}
}
}
diff --git a/src/main/java/org/folio/rest/impl/RefundsAPI.java b/src/main/java/org/folio/rest/impl/RefundsAPI.java
index 74b21655..7e87afb0 100644
--- a/src/main/java/org/folio/rest/impl/RefundsAPI.java
+++ b/src/main/java/org/folio/rest/impl/RefundsAPI.java
@@ -1,5 +1,7 @@
package org.folio.rest.impl;
+import static org.folio.rest.tools.messages.Messages.DEFAULT_LANGUAGE;
+
import io.vertx.core.AsyncResult;
import io.vertx.core.Context;
import io.vertx.core.Future;
@@ -46,10 +48,10 @@ private CQLWrapper getCQL(String query, int limit, int offset) throws CQL2PgJSON
@Validate
@Override
- public void getRefunds(String query, String orderBy, RefundsGetOrder order, int offset, int limit, List facets,
- String lang,
- Map okapiHeaders, Handler> asyncResultHandler,
- Context vertxContext) {
+ public void getRefunds(String query, String orderBy, RefundsGetOrder order, String totalRecords,
+ int offset, int limit, List facets, Map okapiHeaders,
+ Handler> asyncResultHandler, Context vertxContext) {
+
String tenantId = TenantTool.calculateTenantId(okapiHeaders.get(OKAPI_HEADER_TENANT));
List facetList = FacetManager.convertFacetStrings2FacetFields(facets, "jsonb");
try {
@@ -92,7 +94,7 @@ public void getRefunds(String query, String orderBy, RefundsGetOrder order, int
} else {
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(
GetRefundsResponse.respond500WithTextPlain(
- messages.getMessage(lang,
+ messages.getMessage(DEFAULT_LANGUAGE,
MessageConsts.InternalServerError))));
}
}
@@ -106,7 +108,7 @@ public void getRefunds(String query, String orderBy, RefundsGetOrder order, int
} else {
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(
GetRefundsResponse.respond500WithTextPlain(
- messages.getMessage(lang,
+ messages.getMessage(DEFAULT_LANGUAGE,
MessageConsts.InternalServerError))));
}
}
@@ -114,8 +116,9 @@ public void getRefunds(String query, String orderBy, RefundsGetOrder order, int
@Validate
@Override
- public void postRefunds(String lang, Refund entity, Map okapiHeaders,
+ public void postRefunds(Refund entity, Map okapiHeaders,
Handler> asyncResultHandler, Context vertxContext) {
+
if (entity.getId() == null) {
entity.setId(UUID.randomUUID().toString());
}
@@ -139,7 +142,7 @@ public void postRefunds(String lang, Refund entity, Map okapiHea
postgresClient.rollbackTx(beginTx, rollback -> {
asyncResultHandler.handle(Future.succeededFuture(
PostRefundsResponse.respond400WithTextPlain(
- messages.getMessage(lang, MessageConsts.UnableToProcessRequest))));
+ messages.getMessage(DEFAULT_LANGUAGE, MessageConsts.UnableToProcessRequest))));
});
}
} catch (Exception e) {
@@ -160,14 +163,15 @@ public void postRefunds(String lang, Refund entity, Map okapiHea
} catch (Exception e) {
asyncResultHandler.handle(Future.succeededFuture(
PostRefundsResponse.respond500WithTextPlain(
- messages.getMessage(lang, MessageConsts.InternalServerError))));
+ messages.getMessage(DEFAULT_LANGUAGE, MessageConsts.InternalServerError))));
}
}
@Validate
@Override
- public void getRefundsByRefundId(String refundId, String lang, Map okapiHeaders,
+ public void getRefundsByRefundId(String refundId, Map okapiHeaders,
Handler> asyncResultHandler, Context vertxContext) {
+
try {
vertxContext.runOnContext(v -> {
String tenantId = TenantTool.calculateTenantId(okapiHeaders.get(OKAPI_HEADER_TENANT));
@@ -185,19 +189,19 @@ public void getRefundsByRefundId(String refundId, String lang, Map refundList = getReply.result().getResults();
if (refundList.isEmpty()) {
asyncResultHandler.handle(Future.succeededFuture(
GetRefundsByRefundIdResponse.respond404WithTextPlain("Refund"
- + messages.getMessage(lang,
+ + messages.getMessage(DEFAULT_LANGUAGE,
MessageConsts.ObjectDoesNotExist))));
} else if (refundList.size() > 1) {
logger.error("Multiple refunds found with the same id");
asyncResultHandler.handle(Future.succeededFuture(
GetRefundsByRefundIdResponse.respond500WithTextPlain(
- messages.getMessage(lang,
+ messages.getMessage(DEFAULT_LANGUAGE,
MessageConsts.InternalServerError))));
} else {
asyncResultHandler.handle(Future.succeededFuture(
@@ -209,20 +213,21 @@ public void getRefundsByRefundId(String refundId, String lang, Map okapiHeaders,
+ public void deleteRefundsByRefundId(String refundId, Map okapiHeaders,
Handler> asyncResultHandler, Context vertxContext) {
+
try {
vertxContext.runOnContext(v -> {
String tenantId = TenantTool.calculateTenantId(okapiHeaders.get(OKAPI_HEADER_TENANT));
@@ -249,7 +254,7 @@ public void deleteRefundsByRefundId(String refundId, String lang, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) {
+ public void putRefundsByRefundId(String refundId, Refund entity, Map okapiHeaders,
+ Handler> asyncResultHandler, Context vertxContext) {
+
try {
if (refundId == null) {
logger.error("refundId is missing");
@@ -302,7 +308,7 @@ public void putRefundsByRefundId(String refundId, String lang, Refund entity,
logger.error(getReply.cause().getLocalizedMessage());
asyncResultHandler.handle(Future.succeededFuture(
PutRefundsByRefundIdResponse.respond500WithTextPlain(
- messages.getMessage(lang,
+ messages.getMessage(DEFAULT_LANGUAGE,
MessageConsts.InternalServerError))));
} else if (getReply.result().getResults().size() == 1) {
try {
@@ -318,7 +324,7 @@ public void putRefundsByRefundId(String refundId, String lang, Refund entity,
});
} catch (Exception e) {
asyncResultHandler.handle(Future.succeededFuture(
- PutRefundsByRefundIdResponse.respond500WithTextPlain(messages.getMessage(lang,
+ PutRefundsByRefundIdResponse.respond500WithTextPlain(messages.getMessage(DEFAULT_LANGUAGE,
MessageConsts.InternalServerError))));
}
} else if (getReply.result().getResults().isEmpty()) {
@@ -333,14 +339,14 @@ public void putRefundsByRefundId(String refundId, String lang, Refund entity,
logger.error(e.getLocalizedMessage(), e);
asyncResultHandler.handle(Future.succeededFuture(
PutRefundsByRefundIdResponse.respond500WithTextPlain(
- messages.getMessage(lang, MessageConsts.InternalServerError))));
+ messages.getMessage(DEFAULT_LANGUAGE, MessageConsts.InternalServerError))));
}
});
} catch (Exception e) {
logger.error(e.getLocalizedMessage(), e);
asyncResultHandler.handle(Future.succeededFuture(
PutRefundsByRefundIdResponse.respond500WithTextPlain(
- messages.getMessage(lang, MessageConsts.InternalServerError))));
+ messages.getMessage(DEFAULT_LANGUAGE, MessageConsts.InternalServerError))));
}
}
}
diff --git a/src/main/java/org/folio/rest/impl/TransferCriteriaAPI.java b/src/main/java/org/folio/rest/impl/TransferCriteriaAPI.java
index 54c6fef8..de701026 100644
--- a/src/main/java/org/folio/rest/impl/TransferCriteriaAPI.java
+++ b/src/main/java/org/folio/rest/impl/TransferCriteriaAPI.java
@@ -1,5 +1,7 @@
package org.folio.rest.impl;
+import static org.folio.rest.tools.messages.Messages.DEFAULT_LANGUAGE;
+
import io.vertx.core.AsyncResult;
import io.vertx.core.Context;
import io.vertx.core.Handler;
@@ -48,8 +50,10 @@ private CQLWrapper getCQL(String query, int limit, int offset) throws CQL2PgJSON
@Validate
@Override
- public void getTransferCriterias(String query, String orderBy, TransferCriteriasGetOrder order, int offset, int limit,
- String lang, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) {
+ public void getTransferCriterias(String query, String orderBy, TransferCriteriasGetOrder order,
+ String totalRecords, int offset, int limit, Map okapiHeaders,
+ Handler> asyncResultHandler, Context vertxContext) {
+
String tenantId = TenantTool.calculateTenantId(okapiHeaders.get(OKAPI_HEADER_TENANT));
try {
@@ -92,7 +96,7 @@ public void getTransferCriterias(String query, String orderBy, TransferCriterias
} else {
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(
GetTransferCriteriasResponse.respond500WithTextPlain(
- messages.getMessage(lang,
+ messages.getMessage(DEFAULT_LANGUAGE,
MessageConsts.InternalServerError))));
}
}
@@ -107,7 +111,7 @@ public void getTransferCriterias(String query, String orderBy, TransferCriterias
} else {
asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(
GetTransferCriteriasResponse.respond500WithTextPlain(
- messages.getMessage(lang,
+ messages.getMessage(DEFAULT_LANGUAGE,
MessageConsts.InternalServerError))));
}
}
@@ -115,8 +119,9 @@ public void getTransferCriterias(String query, String orderBy, TransferCriterias
@Validate
@Override
- public void postTransferCriterias(String lang, TransferCriteria entity, Map okapiHeaders,
+ public void postTransferCriterias(TransferCriteria entity, Map okapiHeaders,
Handler> asyncResultHandler, Context vertxContext) {
+
if (entity.getId() == null) {
entity.setId(UUID.randomUUID().toString());
}
@@ -142,7 +147,7 @@ public void postTransferCriterias(String lang, TransferCriteria entity, Map {
asyncResultHandler.handle(Future.succeededFuture(
PostTransferCriteriasResponse.respond400WithTextPlain(
- messages.getMessage(lang, MessageConsts.UnableToProcessRequest))));
+ messages.getMessage(DEFAULT_LANGUAGE, MessageConsts.UnableToProcessRequest))));
});
}
} catch (Exception e) {
@@ -165,14 +170,16 @@ public void postTransferCriterias(String lang, TransferCriteria entity, Map okapiHeaders,
- Handler> asyncResultHandler, Context vertxContext) {
+ public void getTransferCriteriasByTransferCriteriaId(String transferCriteriaId,
+ Map okapiHeaders, Handler> asyncResultHandler,
+ Context vertxContext) {
+
try {
vertxContext.runOnContext(v -> {
String tenantId = TenantTool.calculateTenantId(okapiHeaders.get(OKAPI_HEADER_TENANT));
@@ -191,19 +198,19 @@ public void getTransferCriteriasByTransferCriteriaId(String transferCriteriaId,
logger.error(getReply.result());
asyncResultHandler.handle(Future.succeededFuture(
GetTransferCriteriasByTransferCriteriaIdResponse.respond500WithTextPlain(
- messages.getMessage(lang, MessageConsts.InternalServerError))));
+ messages.getMessage(DEFAULT_LANGUAGE, MessageConsts.InternalServerError))));
} else {
List transferCriteriaList = getReply.result().getResults();
if (transferCriteriaList.isEmpty()) {
asyncResultHandler.handle(Future.succeededFuture(
GetTransferCriteriasByTransferCriteriaIdResponse.respond404WithTextPlain("TransferCriteria"
- + messages.getMessage(lang,
+ + messages.getMessage(DEFAULT_LANGUAGE,
MessageConsts.ObjectDoesNotExist))));
} else if (transferCriteriaList.size() > 1) {
logger.error("Multiple transferCriterias found with the same id");
asyncResultHandler.handle(Future.succeededFuture(
GetTransferCriteriasByTransferCriteriaIdResponse.respond500WithTextPlain(
- messages.getMessage(lang,
+ messages.getMessage(DEFAULT_LANGUAGE,
MessageConsts.InternalServerError))));
} else {
asyncResultHandler.handle(Future.succeededFuture(
@@ -216,21 +223,23 @@ public void getTransferCriteriasByTransferCriteriaId(String transferCriteriaId,
logger.error(e.getMessage());
asyncResultHandler.handle(Future.succeededFuture(
GetTransferCriteriasResponse.respond500WithTextPlain(messages.getMessage(
- lang, MessageConsts.InternalServerError))));
+ DEFAULT_LANGUAGE, MessageConsts.InternalServerError))));
}
});
} catch (Exception e) {
asyncResultHandler.handle(Future.succeededFuture(
GetTransferCriteriasResponse.respond500WithTextPlain(messages.getMessage(
- lang, MessageConsts.InternalServerError))));
+ DEFAULT_LANGUAGE, MessageConsts.InternalServerError))));
}
}
@Validate
@Override
- public void deleteTransferCriteriasByTransferCriteriaId(String transferCriteriaId, String lang,
- Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) {
+ public void deleteTransferCriteriasByTransferCriteriaId(String transferCriteriaId,
+ Map okapiHeaders, Handler> asyncResultHandler,
+ Context vertxContext) {
+
try {
vertxContext.runOnContext(v -> {
String tenantId = TenantTool.calculateTenantId(okapiHeaders.get(OKAPI_HEADER_TENANT));
@@ -259,7 +268,7 @@ public void deleteTransferCriteriasByTransferCriteriaId(String transferCriteriaI
if (error == null) {
asyncResultHandler.handle(
Future.succeededFuture(DeleteTransferCriteriasByTransferCriteriaIdResponse.respond500WithTextPlain(
- messages.getMessage(lang, MessageConsts.InternalServerError))
+ messages.getMessage(DEFAULT_LANGUAGE, MessageConsts.InternalServerError))
));
} else {
asyncResultHandler.handle(
@@ -274,7 +283,7 @@ public void deleteTransferCriteriasByTransferCriteriaId(String transferCriteriaI
asyncResultHandler.handle(
Future.succeededFuture(
DeleteTransferCriteriasByTransferCriteriaIdResponse.respond500WithTextPlain(
- messages.getMessage(lang,
+ messages.getMessage(DEFAULT_LANGUAGE,
MessageConsts.InternalServerError))));
}
@@ -283,15 +292,17 @@ public void deleteTransferCriteriasByTransferCriteriaId(String transferCriteriaI
asyncResultHandler.handle(
Future.succeededFuture(
DeleteTransferCriteriasByTransferCriteriaIdResponse.respond500WithTextPlain(
- messages.getMessage(lang,
+ messages.getMessage(DEFAULT_LANGUAGE,
MessageConsts.InternalServerError))));
}
}
@Validate
@Override
- public void putTransferCriteriasByTransferCriteriaId(String transferCriteriaId, String lang, TransferCriteria entity,
- Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) {
+ public void putTransferCriteriasByTransferCriteriaId(String transferCriteriaId,
+ TransferCriteria entity, Map okapiHeaders,
+ Handler