From aa58bd0cb2ea65a2cf5cc826012ce169d94312d1 Mon Sep 17 00:00:00 2001 From: "Niels Erik G. Nielsen" Date: Mon, 16 Dec 2013 22:00:07 -0500 Subject: [PATCH] Support for compound limit expressions Limits with multiple comma-separated expressions were not properly tokenized due to the existance of literal commas in the individual expressions as well. Now literal commas most be escaped by the client of the mkjsf library, as in 'steinbeck\, john' ie: limit=author=steinbeck\, john,date=1947 --- .../com/indexdata/mkjsf/pazpar2/commands/FilterParameter.java | 2 +- .../com/indexdata/mkjsf/pazpar2/commands/LimitParameter.java | 2 +- .../com/indexdata/mkjsf/pazpar2/commands/SearchCommand.java | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/indexdata/mkjsf/pazpar2/commands/FilterParameter.java b/src/main/java/com/indexdata/mkjsf/pazpar2/commands/FilterParameter.java index 4bafeb8..e10edb6 100644 --- a/src/main/java/com/indexdata/mkjsf/pazpar2/commands/FilterParameter.java +++ b/src/main/java/com/indexdata/mkjsf/pazpar2/commands/FilterParameter.java @@ -31,7 +31,7 @@ public class FilterParameter extends CommandParameter { completeValue.append(","); else first=false; - completeValue.append(pz2escape(expr.toString())); + completeValue.append(expr.toString()); } return completeValue.toString(); } diff --git a/src/main/java/com/indexdata/mkjsf/pazpar2/commands/LimitParameter.java b/src/main/java/com/indexdata/mkjsf/pazpar2/commands/LimitParameter.java index 0b98956..93a26fc 100644 --- a/src/main/java/com/indexdata/mkjsf/pazpar2/commands/LimitParameter.java +++ b/src/main/java/com/indexdata/mkjsf/pazpar2/commands/LimitParameter.java @@ -31,7 +31,7 @@ public class LimitParameter extends CommandParameter { completeValue.append(","); else first=false; - completeValue.append(pz2escape(expr.toString())); + completeValue.append(expr.toString()); logger.trace("valueWithExpressions so far: [" + completeValue + "]"); } return completeValue.toString(); diff --git a/src/main/java/com/indexdata/mkjsf/pazpar2/commands/SearchCommand.java b/src/main/java/com/indexdata/mkjsf/pazpar2/commands/SearchCommand.java index dcbb323..f9f76a2 100644 --- a/src/main/java/com/indexdata/mkjsf/pazpar2/commands/SearchCommand.java +++ b/src/main/java/com/indexdata/mkjsf/pazpar2/commands/SearchCommand.java @@ -1,9 +1,7 @@ package com.indexdata.mkjsf.pazpar2.commands; -import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.util.StringTokenizer; import javax.enterprise.context.SessionScoped; import javax.inject.Named; @@ -74,7 +72,8 @@ public class SearchCommand extends Pazpar2Command implements ServiceProxyCommand */ public void setFilter(String compoundExpression) { if (compoundExpression != null && compoundExpression.length()>0) { - String[] subExpressions = compoundExpression.split(","); + // Split expression by commas that are not escaped (with backslash) + String[] subExpressions = compoundExpression.split("(?0) { - String[] subExpressions = compoundExpression.split(","); + // Split expression by commas that are not escaped (with backslash) + String[] subExpressions = compoundExpression.split("(?