Skip to content

Commit

Permalink
Speculative fix for APIX search results incorrectly being exported un…
Browse files Browse the repository at this point in the history
…-embellished.
  • Loading branch information
jannistsiroyannis committed Nov 16, 2023
1 parent 0e24793 commit 10247be
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,9 @@ public void doGet2(HttpServletRequest request, HttpServletResponse response) thr
{
Set<String> resultingIDs = search(request);

Map<String, Document> resultingDocumentsMap = Utils.s_whelk.bulkLoad(new ArrayList<>(resultingIDs));
List<Document> resultingDocuments = new ArrayList<>();
for (String key : resultingDocumentsMap.keySet())
resultingDocuments.add(resultingDocumentsMap.get(key));

boolean includeHold = request.getParameter("x-holdings") != null && request.getParameter("x-holdings").equalsIgnoreCase("true");

Utils.send200Response(response, Xml.formatApixSearchResponse(resultingDocuments, includeHold, request.getParameterMap()));
Utils.send200Response(response, Xml.formatApixSearchResponse(new ArrayList<>(resultingIDs), includeHold, request.getParameterMap()));
}

private Set<String> search(HttpServletRequest request)
Expand Down
5 changes: 3 additions & 2 deletions apix_server/src/main/java/whelk/apixserver/Xml.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public static String formatApixGetRecordResponse(String marcXmlString,
return docToString(xmlDoc);
}

public static String formatApixSearchResponse(List<whelk.Document> resultingDocuments,
public static String formatApixSearchResponse(List<String> resultingIDs,
boolean includeHold, Map<String, String[]> parameterMap)
throws TransformerException, IOException, SAXException
{
Expand Down Expand Up @@ -143,8 +143,9 @@ public static String formatApixSearchResponse(List<whelk.Document> resultingDocu

Element records = xmlDoc.createElement("records");
result.appendChild(records);
for (whelk.Document document : resultingDocuments)
for (String id : resultingIDs)
{
whelk.Document document = Utils.s_whelk.loadEmbellished(id);
Element record = xmlDoc.createElement("record");
records.appendChild(record);

Expand Down

0 comments on commit 10247be

Please sign in to comment.