X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fcom%2Findexdata%2Fmkjsf%2Fpazpar2%2Fcommands%2FPazpar2Command.java;h=f61642cc201bd17f6fe7c1af68a36538d8a35c79;hb=499264a3ac955aafd1a9c3a0f280ec9a9bcdcfd0;hp=a4fa51f11f2168c0575affd6a295cb9ae9e79ae3;hpb=8f451e761c251dcb4b01a2a11ee759e2ec3c1105;p=mkjsf-moved-to-github.git diff --git a/src/main/java/com/indexdata/mkjsf/pazpar2/commands/Pazpar2Command.java b/src/main/java/com/indexdata/mkjsf/pazpar2/commands/Pazpar2Command.java index a4fa51f..f61642c 100644 --- a/src/main/java/com/indexdata/mkjsf/pazpar2/commands/Pazpar2Command.java +++ b/src/main/java/com/indexdata/mkjsf/pazpar2/commands/Pazpar2Command.java @@ -50,7 +50,7 @@ public abstract class Pazpar2Command implements Serializable { } /** - * Commands must implement this method to provide an completely detached, deep clone of + * Commands must implement this method to provide a completely detached, deep clone of * themselves. * * The clone is needed by the state manager to transfer commands with current setting @@ -80,7 +80,7 @@ public abstract class Pazpar2Command implements Serializable { /** * Executes the commands with the currently selected parameters, while adding - * the parameters provided + * the parameters provided in the vararg * @param parameters A list of parameters on the form [key=value] * * @return Response data object based on the Pazpar2 service response @@ -95,7 +95,30 @@ public abstract class Pazpar2Command implements Serializable { } return run(); } - + + /** + * Executes the commands with the currently selected parameters, while adding + * the parameters provided in the 'delimiter'-separated String. + * + * Note: This is for Glassfish/JBoss support. With Tomcat7 the method + * runWith(String... parameters) can be used directly from EL + * with a vararg + * + * @param parameters A list of parameters separated by 'delimiter' + * @param delimiter The separator character of the String 'parameters' + * + * @return Response data object based on the Pazpar2 service response + */ + public ResponseDataObject runWith2(String parameters, String delimiter) { + StringTokenizer params = new StringTokenizer(parameters,delimiter); + String[] vararg = new String[params.countTokens()]; + int i=0; + while (params.hasMoreTokens()) { + vararg[i++] = params.nextToken(); + } + return runWith(vararg); + } + /** * Executes the command in a thread. * @@ -244,12 +267,14 @@ public abstract class Pazpar2Command implements Serializable { } public void removeExpressions(String parameterName, String... expressionFields) { - Pazpar2Command copy = this.copy(); - copy.getParameter(parameterName).removeExpressions(expressionFields); - if (!getParameter(parameterName).hasValue() && !getParameter(parameterName).hasExpressions()) { - copy.parameters.remove(parameterName); + if (this.getParameter(parameterName) != null) { + Pazpar2Command copy = this.copy(); + copy.getParameter(parameterName).removeExpressions(expressionFields); + if (!getParameter(parameterName).hasValue() && !getParameter(parameterName).hasExpressions()) { + copy.parameters.remove(parameterName); + } + checkInState(copy); } - checkInState(copy); } public boolean hasParameters () {