From: Niels Erik G. Nielsen Date: Tue, 17 Dec 2013 03:00:07 +0000 (-0500) Subject: Support for compound limit expressions X-Git-Tag: v0.0.7~13 X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=aa58bd0cb2ea65a2cf5cc826012ce169d94312d1;p=mkjsf-moved-to-github.git 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 --- 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("(?