Tweak to support for state mgmt across xhtml pages
[mkjsf-moved-to-github.git] / src / main / java / com / indexdata / mkjsf / pazpar2 / state / Pazpar2State.java
index e983d5c..015c1be 100644 (file)
@@ -14,6 +14,9 @@ import com.indexdata.mkjsf.pazpar2.commands.SettingsCommand;
 import com.indexdata.mkjsf.pazpar2.commands.ShowCommand;\r
 import com.indexdata.mkjsf.pazpar2.commands.StatCommand;\r
 import com.indexdata.mkjsf.pazpar2.commands.TermlistCommand;\r
+import com.indexdata.mkjsf.pazpar2.commands.sp.AuthCommand;\r
+import com.indexdata.mkjsf.pazpar2.commands.sp.CategoriesCommand;\r
+import com.indexdata.mkjsf.pazpar2.commands.sp.ServiceProxyCommands;\r
 \r
 /**\r
  * Holds a 'pazpar2 state', understood as a full set of pazpar2 commands and \r
@@ -36,8 +39,11 @@ public class Pazpar2State {
     commands.put(Pazpar2Commands.SHOW,     new ShowCommand(mgr));\r
     commands.put(Pazpar2Commands.RECORD,   new RecordCommand(mgr));\r
     commands.put(Pazpar2Commands.TERMLIST, new TermlistCommand(mgr));\r
-    commands.put(Pazpar2Commands.BYTARGET, new BytargetCommand(mgr));    \r
-    key = "#1";\r
+    commands.put(Pazpar2Commands.BYTARGET, new BytargetCommand(mgr));  \r
+\r
+    commands.put(ServiceProxyCommands.AUTH, new AuthCommand(mgr));\r
+    commands.put(ServiceProxyCommands.CATEGORIES, new CategoriesCommand(mgr));\r
+    // key = "#1";\r
   }\r
     \r
   /**\r
@@ -51,7 +57,7 @@ public class Pazpar2State {
     for (String commandName : previousState.commands.keySet()) {\r
       this.commands.put(commandName, previousState.commands.get(commandName).copy());\r
     }\r
-    this.commands.put(newCommand.getName(),newCommand);\r
+    this.commands.put(newCommand.getCommandName(),newCommand);\r
     this.key = getKey();           \r
   }\r
     \r
@@ -65,12 +71,14 @@ public class Pazpar2State {
     if (key == null) {\r
       StringBuilder querystatebuilder = new StringBuilder("");\r
       for (Pazpar2Command command : commands.values()) {\r
-        if (command.hasParameters()) {\r
-          querystatebuilder.append("||"+command.getName()+"::");\r
-          querystatebuilder.append(command.getValueWithExpressions());\r
-        }      \r
+        if (! (command instanceof AuthCommand )) {\r
+          if (command.hasParameters()) {\r
+            querystatebuilder.append("||"+command.getCommandName()+"::");\r
+            querystatebuilder.append(command.getValueWithExpressions());\r
+          }\r
+        }\r
       }            \r
-      key = "#"+querystatebuilder.toString().hashCode();\r
+      key = "#"+querystatebuilder.toString();\r
       return key;\r
     } else {      \r
       return key;\r
@@ -86,9 +94,9 @@ public class Pazpar2State {
   public boolean stateMutating (Pazpar2Command command) {\r
     if (command == null) {\r
       return true;\r
-    } else if (commands.get(command.getName()) == null) {\r
+    } else if (commands.get(command.getCommandName()) == null) {\r
       return true;\r
-    } else if ((command.equals(commands.get(command.getName())))) {\r
+    } else if ((command.equals(commands.get(command.getCommandName())))) {\r
       return false;      \r
     } else {\r
       return true;\r