diff --git a/NEWS.md b/NEWS.md
index add0589..019cf10 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,4 +1,8 @@
-## 1.15.4 2024-11-12
+## 1.15.6 2024-11-21
+* Fix missing permission issue
+* Use item call number from AcceptItem request if it is provided
+
+## 1.15.5 2024-11-12
* Add new configuration options
* Make sure default values are used
diff --git a/descriptors/ModuleDescriptor-template.json b/descriptors/ModuleDescriptor-template.json
index 664fd32..f48d53a 100644
--- a/descriptors/ModuleDescriptor-template.json
+++ b/descriptors/ModuleDescriptor-template.json
@@ -12,7 +12,7 @@
"permissionsRequired": ["ncip.post"],
"modulePermissions": [
"users.collection.get",
- "automated-patron-blocks.collection.get",
+ "patron-blocks.automated-patron-blocks.collection.get",
"addresstypes.collection.get",
"circulation.requests.item.post",
"circulation-storage.circulation-rules.get",
diff --git a/pom.xml b/pom.xml
index 3906f37..9d4b8bb 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
4.0.0
org.folio
mod-ncip
- 1.15.6-SNAPSHOT
+ 1.15.7-SNAPSHOT
NCIP
NCIP responder for FOLIO (internal module)
@@ -19,7 +19,7 @@
UTF-8
UTF-8
17
- 4.1.0
+ 4.1.1
diff --git a/src/main/java/org/folio/ncip/Constants.java b/src/main/java/org/folio/ncip/Constants.java
index 68f982b..374d992 100644
--- a/src/main/java/org/folio/ncip/Constants.java
+++ b/src/main/java/org/folio/ncip/Constants.java
@@ -117,7 +117,8 @@ public class Constants {
public static final String DEFAULT_FEE_STATUS = "Open";
public static final String BOOLEAN_TRUE = "true";
public static final String NOTE_DOMAIN_REQUESTS = "requests";
- public static final String NOTE_TITLE_TEMPLATE = "ILL Request id: %s";
+ public static final String NOTE_TITLE_TEMPLATE = "ILL Request ID: %s";
+ public static final String NOTE_TITLE_TEMPLATE_CUSTOM_EXTERNAL_REFERNECE = "ILL Request ID: %s, ILL %s: %s";
public static final String NOTE_LINK_TYPE_REQUEST = "request";
public static final String ITEM_STATUS_UNAVAILABLE = "Unavailable";
diff --git a/src/main/java/org/folio/ncip/FolioRemoteServiceManager.java b/src/main/java/org/folio/ncip/FolioRemoteServiceManager.java
index f7cd202..4acd7f5 100644
--- a/src/main/java/org/folio/ncip/FolioRemoteServiceManager.java
+++ b/src/main/java/org/folio/ncip/FolioRemoteServiceManager.java
@@ -421,7 +421,7 @@ public JsonObject checkOut(CheckOutItemInitiationData initData, String agencyId)
try {
String checkoutResponse = callApiPost(url, jsonObject);
JsonObject checkoutResponseAsJson = new JsonObject(checkoutResponse);
- addStaffInfoIfNeeded(agencyId, initData.getRequestId(), checkoutResponseAsJson.getString(Constants.ID), baseUrl);
+ addStaffInfoIfNeeded(agencyId, initData.getRequestId(), checkoutResponseAsJson.getString(Constants.ID), baseUrl, initData.getExternalReference());
return checkoutResponseAsJson;
}
catch(Exception e) {
@@ -446,22 +446,45 @@ public JsonObject checkOut(CheckOutItemInitiationData initData, String agencyId)
}
}
- private void addStaffInfoIfNeeded(String agencyId, RequestId requestId, String loanUuid, String baseUrl){
+ private void addStaffInfoIfNeeded(String agencyId, RequestId requestId, String loanUuid, String baseUrl, RequestId externalReference) {
String noteEnabled = getProperty(agencyId, "request.note.enabled");
- if (Constants.BOOLEAN_TRUE.equalsIgnoreCase(noteEnabled) && requestId != null &&
- requestId.getRequestIdentifierValue() != null) {
- JsonObject staffInfo = new JsonObject();
- staffInfo.put("action", getProperty(agencyId, "checkout.loan.info.type"));
- staffInfo.put("actionComment", String.format(Constants.NOTE_TITLE_TEMPLATE, requestId.getRequestIdentifierValue()));
- try {
- callApiPost(baseUrl + String.format(Constants.ADD_STAFF_INFO_URL, loanUuid), staffInfo);
- } catch (Exception e) {
- logger.error("Unable to add staff info to loan: {}", loanUuid);
- logger.error(e.getMessage());
+ if (Constants.BOOLEAN_TRUE.equalsIgnoreCase(noteEnabled) && requestId != null) {
+ String requestIdentifierValue = requestId.getRequestIdentifierValue();
+
+ if (requestIdentifierValue != null) {
+ JsonObject staffInfo = new JsonObject();
+ String actionComment = generateActionComment(requestIdentifierValue, externalReference);
+ staffInfo.put("action", getProperty(agencyId, "checkout.loan.info.type"));
+ staffInfo.put("actionComment", actionComment);
+
+ try {
+ callApiPost(baseUrl + String.format(Constants.ADD_STAFF_INFO_URL, loanUuid), staffInfo);
+ } catch (Exception e) {
+ logger.error("Unable to add staff info to loan: {}", loanUuid);
+ logger.error(e.getMessage());
+ }
}
}
}
+ private String generateActionComment(String requestIdentifierValue, RequestId externalReference) {
+ if (externalReference != null &&
+ externalReference.getRequestIdentifierValue() != null &&
+ externalReference.getRequestIdentifierType() != null) {
+ return String.format(
+ Constants.NOTE_TITLE_TEMPLATE_CUSTOM_EXTERNAL_REFERNECE,
+ requestIdentifierValue,
+ externalReference.getRequestIdentifierType().getValue(),
+ externalReference.getRequestIdentifierValue()
+ );
+ } else {
+ return String.format(
+ Constants.NOTE_TITLE_TEMPLATE,
+ requestIdentifierValue
+ );
+ }
+ }
+
/**
* The acceptItem method: 1) creates an instance (bib) 2) creates a holding
* record 3) creates an item 4) places the item on hold
diff --git a/src/test/java/org/folio/ncip/CheckOutItem.java b/src/test/java/org/folio/ncip/CheckOutItem.java
index 13c035f..c0ed57d 100644
--- a/src/test/java/org/folio/ncip/CheckOutItem.java
+++ b/src/test/java/org/folio/ncip/CheckOutItem.java
@@ -5,8 +5,7 @@
import java.net.MalformedURLException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
public class CheckOutItem extends TestBase {
@@ -18,4 +17,28 @@ public void callCheckOutItem() throws MalformedURLException {
assertEquals(200, response.getStatusCode());
assertTrue(body.contains(ITEM_ID));
}
+
+ @Test
+ public void callCheckOutItemWithoutExternalReference() throws MalformedURLException {
+ Response response = postData("src/test/resources/mockdata/ncip-checkout-null-request-id-external-reference.xml");
+ String body = response.getBody().prettyPrint();
+ assertEquals(200, response.getStatusCode());
+ assertTrue(body.contains(ITEM_ID));
+ }
+
+ @Test
+ public void callCheckOutItemWithoutExternalReferenceType() throws MalformedURLException {
+ Response response = postData("src/test/resources/mockdata/ncip-checkout-null-external-reference-type.xml");
+ String body = response.getBody().prettyPrint();
+ assertEquals(200, response.getStatusCode());
+ assertTrue(body.contains(ITEM_ID));
+ }
+
+ @Test
+ public void callCheckOutItemEmptyExternalReferenceValue() throws MalformedURLException {
+ Response response = postData("src/test/resources/mockdata/ncip-checkout-null-external-reference-value.xml");
+ String body = response.getBody().prettyPrint();
+ assertEquals(200, response.getStatusCode());
+ assertTrue(body.contains(ITEM_ID));
+ }
}
diff --git a/src/test/resources/mockdata/ncip-checkout-full.xml b/src/test/resources/mockdata/ncip-checkout-full.xml
index 2cc6cdc..0bb0780 100644
--- a/src/test/resources/mockdata/ncip-checkout-full.xml
+++ b/src/test/resources/mockdata/ncip-checkout-full.xml
@@ -22,5 +22,12 @@
relais
js-test-0015
+
+
+ relais
+ ExternReferenz
+ GDFG2343
+
+
\ No newline at end of file
diff --git a/src/test/resources/mockdata/ncip-checkout-null-external-reference-type.xml b/src/test/resources/mockdata/ncip-checkout-null-external-reference-type.xml
new file mode 100644
index 0000000..3eac263
--- /dev/null
+++ b/src/test/resources/mockdata/ncip-checkout-null-external-reference-type.xml
@@ -0,0 +1,32 @@
+
+
+
+
+
+ relais
+
+
+ other
+
+ EZBORROW
+
+
+ relais
+ slnp_one_inst_user
+
+
+ relais
+ tl-a11
+
+
+ relais
+ js-test-0015
+
+
+
+ relais
+ GDFG2343
+
+
+
+
\ No newline at end of file
diff --git a/src/test/resources/mockdata/ncip-checkout-null-external-reference-value.xml b/src/test/resources/mockdata/ncip-checkout-null-external-reference-value.xml
new file mode 100644
index 0000000..c7e0a8d
--- /dev/null
+++ b/src/test/resources/mockdata/ncip-checkout-null-external-reference-value.xml
@@ -0,0 +1,33 @@
+
+
+
+
+
+ relais
+
+
+ other
+
+ EZBORROW
+
+
+ relais
+ slnp_one_inst_user
+
+
+ relais
+ tl-a11
+
+
+ relais
+ js-test-0015
+
+
+
+ relais
+ ExternReferenz
+
+
+
+
+
\ No newline at end of file
diff --git a/src/test/resources/mockdata/ncip-checkout-null-request-id-external-reference.xml b/src/test/resources/mockdata/ncip-checkout-null-request-id-external-reference.xml
new file mode 100644
index 0000000..2cc6cdc
--- /dev/null
+++ b/src/test/resources/mockdata/ncip-checkout-null-request-id-external-reference.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
+ relais
+
+
+ other
+
+ EZBORROW
+
+
+ relais
+ slnp_one_inst_user
+
+
+ relais
+ tl-a11
+
+
+ relais
+ js-test-0015
+
+
+
\ No newline at end of file