diff --git a/NEWS.md b/NEWS.md
index b1f3b1c45..853553855 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,5 +1,14 @@
## 3.14.0 - Unreleased
+## 3.13.1 (Released)
+
+This release includes bug fixes for incorrect characters
+
+[Full Changelog](https://github.com/folio-org/mod-oai-pmh/compare/v3.13.0...v3.13.1)
+
+### Bug fixes
+* [MODOAIPMH-540](https://issues.folio.org/browse/MODOAIPMH-540) Error while converting record to xml
+
## 3.13.0 (Released)
This release includes dependency updates and minor fixes
diff --git a/pom.xml b/pom.xml
index eb00bb715..5537d7b9b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -2,7 +2,7 @@
4.0.0
org.folio
mod-oai-pmh
- 3.13.1-SNAPSHOT
+ 3.13.2-SNAPSHOT
OAI-PMH Repository Business Logic
Business logic to support the Open Archives Initiative Protocol for Metadata Harvesting
diff --git a/ramls/schemas/OAI-PMH.xsd b/ramls/schemas/OAI-PMH.xsd
index cb1fd4830..953d29fe1 100644
--- a/ramls/schemas/OAI-PMH.xsd
+++ b/ramls/schemas/OAI-PMH.xsd
@@ -89,6 +89,7 @@
+
diff --git a/src/main/java/org/folio/oaipmh/Constants.java b/src/main/java/org/folio/oaipmh/Constants.java
index 8a1dfabc5..21238c70c 100644
--- a/src/main/java/org/folio/oaipmh/Constants.java
+++ b/src/main/java/org/folio/oaipmh/Constants.java
@@ -103,6 +103,7 @@ private Constants() {
public static final String LIST_ILLEGAL_ARGUMENTS_ERROR = "Verb '%s', argument 'resumptionToken' is exclusive, no others maybe specified with it.";
public static final String INVALID_RESUMPTION_TOKEN = "Verb '%s', argument resumptionToken is invalid";
public static final String NO_RECORD_FOUND_ERROR = "There were no records found matching the search criteria";
+ public static final String INVALID_CHARACTER_IN_THE_RECORD = "Invalid character in the record.";
public static final String BAD_DATESTAMP_FORMAT_ERROR = "Bad datestamp format for '%s=%s' argument.";
public static final String RECORD_METADATA_PREFIX_PARAM_ERROR = "The request is missing required arguments. There is no metadataPrefix.";
public static final String RECORD_NOT_FOUND_ERROR = "No matching identifier in repository.";
diff --git a/src/main/java/org/folio/oaipmh/helpers/AbstractGetRecordsHelper.java b/src/main/java/org/folio/oaipmh/helpers/AbstractGetRecordsHelper.java
index de9dee1f7..eb37d82e5 100644
--- a/src/main/java/org/folio/oaipmh/helpers/AbstractGetRecordsHelper.java
+++ b/src/main/java/org/folio/oaipmh/helpers/AbstractGetRecordsHelper.java
@@ -472,8 +472,10 @@ protected Future processRecords(Context ctx, Request request,
Promise oaiResponsePromise = Promise.promise();
buildRecords(ctx, request, items).onSuccess(recordsMap -> {
Response response;
- if (recordsMap.isEmpty()) {
+ if (noRecordsFoundResultCheck(recordsMap, items, request.getVerb())) {
response = buildNoRecordsFoundOaiResponse(oaipmh, request);
+ } else if (conversionIntoJaxbObjectIssueCheck(recordsMap, items, request.getVerb())) {
+ response = conversionIntoJaxbObjectIssueResponse(oaipmh, request);
} else {
addRecordsToOaiResponse(oaipmh, recordsMap.values());
addResumptionTokenToOaiResponse(oaipmh, resumptionToken);
@@ -484,6 +486,22 @@ protected Future processRecords(Context ctx, Request request,
return oaiResponsePromise.future();
}
+ boolean noRecordsFoundResultCheck(Map recordsMap, JsonArray items, VerbType verb){
+ return recordsMap.isEmpty() &&
+ (jsonArrayIsEmpty(items) || (jsonArrayNotEmpty(items) && VerbType.GET_RECORD != verb));
+ }
+
+ boolean conversionIntoJaxbObjectIssueCheck(Map recordsMap, JsonArray items, VerbType verb){
+ return recordsMap.isEmpty() && jsonArrayNotEmpty(items) && VerbType.GET_RECORD == verb;
+ }
+
+ private boolean jsonArrayNotEmpty(JsonArray ja){
+ return ja != null && !ja.isEmpty();
+ }
+ private boolean jsonArrayIsEmpty(JsonArray ja){
+ return !jsonArrayNotEmpty(ja);
+ }
+
/**
* Builds {@link Map} with storage id as key and {@link RecordType} with populated header if there is any,
* otherwise empty map is returned
@@ -496,7 +514,7 @@ private Future