Skip to content

Commit

Permalink
Tmp v1.6.4 (#38)
Browse files Browse the repository at this point in the history
* MODNCIP-15: Specify utf-8 in POST

- utf-8 specified in POST request (FolioRemoteServiceManager) to fix MODNCIP-15
- removed 'Unknown data element' from response when the problem doesn't relate to a data element.  This was confusing. (Constants)
- changed default timeout to 30 seconds instead of 3 to prevent timeout errors when entire system becomes slow.  As before the default can be modified.  (Constants)

* Update news

* Move to vertx 4

* Update news

* Move to vertx 4

* [maven-release-plugin] prepare release v1.6.4

* [maven-release-plugin] prepare for next development iteration
  • Loading branch information
mis306lu authored Mar 6, 2021
1 parent f15b4d7 commit 919600c
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 10 deletions.
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 1.6.4 2021-03-05
* [MODNCIP-15](https://issues.folio.org/browse/MODNCIP-15) - specify UTF-8 in POST
* Default timeout changed to 30 secs (3 was too short - implementers seeing timeouts when system is slow). As before, the default can be modified on startup.
* Attempt checkin if checkout fails due to timeout (for convenience). Only happens when the system gets extremely slow.
* Removed 'Problem element unknown' from the response when the problem doesn't relate to a specific element. This was confusing.
* Moved to vertx 4
## 1.6.3 2020-11-11
* Putting back patron group lookup (was unintentionally removed)
## 1.6.2 2020-11-09
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@ If the service is able to retrieve a UUID for each of the settings it will send
<message>problem processing NCIP request</message>
<exception>java.lang.Exception: The lookup of PALCI_NOTREAL could not be found for relais.instance.type.name</exception>
</Problem>
## FAQ
<b>The NCIP response says read timeout</b>
<br>
In previous versions, the default timeout (which tells mod-ncip how long to wait for a repsonse from the FOLIO services it calls) was set to 3000 (3 seconds). This occassionally caused timeouts when the entire system was slow but could be fixed by increasing the timeout setting mentioned in the Configuration section above (when the module is started (java -jar ...) add this configuration: -Dservice_manager_timeout_ms=6000). However, as of 03/2021 it defaults to 30000 (30 seconds) because 3000 (3 seconds) was not enough at times. This setting can still be adjusted with the '-Dservice_manager_timeout_ms' setting. It just defaults to 30 seconds now instead of 3 to help implementers avoid ever running into the timeout.


## About the NCIP services
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.folio</groupId>
<artifactId>mod-ncip</artifactId>
<version>1.6.4-SNAPSHOT</version>
<version>1.6.5-SNAPSHOT</version>
<name>NCIP</name>
<description>NCIP responder for FOLIO (internal module)</description>

Expand All @@ -15,7 +15,7 @@
</licenses>

<properties>
<vertx.version>3.8.0</vertx.version>
<vertx.version>4.0.0</vertx.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>11</java.version>
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/folio/ncip/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class Constants {
public static final String USER_PROBLEM_ELEMENT = "AuthenticationInput or UserId";
public static final String CHECK_OUT_PROBLEM = "Problem performing checkout";
public static final String CHECK_OUT_INPUT_PROBLEM = "Problem occurred validating input (user id or item id)";
public static final String UNKNOWN_DATA_ELEMENT = "Unknown Data Element";
public static final String UNKNOWN_DATA_ELEMENT = "--";
public static final String CHECK_IN_PROBLEM = "Problem performing check in";
public static final String FATAL_ERROR_OCCURED = "An error occured processing this request. Unable to construct a proper NCIP response with problem element";
public static final String USER_ID_MISSING = "User id missing";
Expand Down Expand Up @@ -78,7 +78,7 @@ public class Constants {
public static final String ADDRESS_TYPES = "/addresstypes";


public static final String DEFAULT_TIMEOUT = "3000";
public static final String DEFAULT_TIMEOUT = "30000";
public static final String SERVICE_MGR_TIMEOUT = "service_manager_timeout_ms";

}
2 changes: 1 addition & 1 deletion src/main/java/org/folio/ncip/FolioNcipHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class FolioNcipHelper {

public FolioNcipHelper(Promise<Void> promise) {
Future<Void> steps = initToolkitDefaults();
steps.setHandler(ar -> {
steps.onComplete(ar -> {
if (ar.succeeded()) {
promise.complete();
} else {
Expand Down
31 changes: 26 additions & 5 deletions src/main/java/org/folio/ncip/FolioRemoteServiceManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public String callApiPost(String uriString, JsonObject body)
HttpUriRequest request = RequestBuilder.post()
.setConfig(config)
.setUri(uriString)
.setEntity(new StringEntity(body.toString()))
.setEntity(new StringEntity(body.toString(),"UTF-8"))
.setHeader(Constants.X_OKAPI_TENANT, okapiHeaders.get(Constants.X_OKAPI_TENANT))
.setHeader(Constants.ACCEPT_TEXT, Constants.CONTENT_JSON_AND_PLAIN).setVersion(HttpVersion.HTTP_1_1)
.setHeader(Constants.CONTENT_TYPE_TEXT, Constants.CONTENT_JSON)
Expand Down Expand Up @@ -351,10 +351,31 @@ public JsonObject checkOut(CheckOutItemInitiationData initData, String agencyId)
jsonObject.put("servicePointId", servicePoint);

String url = baseUrl + Constants.CHECK_OUT_BY_BARCODE;

String checkoutResponse = callApiPost(url, jsonObject);
JsonObject checkoutResponseAsJson = new JsonObject(checkoutResponse);
return checkoutResponseAsJson;
try {
String checkoutResponse = callApiPost(url, jsonObject);
JsonObject checkoutResponseAsJson = new JsonObject(checkoutResponse);
return checkoutResponseAsJson;
}
catch(Exception e) {
//CHECKOUT FAILED - TRY TO CALL CHECKIN TRANSACTION
//SO THE CHECKOUT CAN BE ATTEMPTED AGAIN.
//WE'VE SEEN THE CHECKOUT TIMEOUT WHEN THE ENTIRE SYSTEM
//IS SLOW - AND THE ITEM ENDS UP CHECKED OUT...SO JUST ATTEMPTING
//A CHECKIN FOR CONVENIENCE
logger.error("exception occured during checkout item");
logger.error("attempting a checkin...in case the checkout actually worked");
String returnDate = dtf.format(now);
jsonObject.put("checkInDate", returnDate);
Thread.sleep(4000);
try {
url = baseUrl + Constants.CHECK_IN_BY_BARCODE;
callApiPost(url, jsonObject);
} catch (Exception checkinError) {
logger.error("unable to checkin item: " + itemBarcode);
logger.error(checkinError.getMessage());
}
throw e;
}
}

/**
Expand Down

0 comments on commit 919600c

Please sign in to comment.