X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fcom%2Findexdata%2Fmkjsf%2Fpazpar2%2Fstate%2FStateManager.java;h=04c9c3f10e32330e58ac7f9eb27f06c5569d60d6;hb=5b978e6919af8e8548337cd1ab1ce1df625f74f1;hp=d185559ac42948a5023c6704abb451eb94d3bdaf;hpb=b9c65ec6cefe23341e4ae9ea4e6c6f9d9d7ed495;p=mkjsf-moved-to-github.git
diff --git a/src/main/java/com/indexdata/mkjsf/pazpar2/state/StateManager.java b/src/main/java/com/indexdata/mkjsf/pazpar2/state/StateManager.java
index d185559..04c9c3f 100644
--- a/src/main/java/com/indexdata/mkjsf/pazpar2/state/StateManager.java
+++ b/src/main/java/com/indexdata/mkjsf/pazpar2/state/StateManager.java
@@ -12,7 +12,6 @@ import javax.enterprise.context.SessionScoped;
import org.apache.log4j.Logger;
import com.indexdata.mkjsf.pazpar2.commands.Pazpar2Command;
-import com.indexdata.mkjsf.pazpar2.commands.sp.AuthCommand;
import com.indexdata.mkjsf.utils.Utils;
@SessionScoped
@@ -90,33 +89,45 @@ public class StateManager implements Serializable {
* Changes the current state key. Invoked from the UI to have the state
* manager switch to another state than the current one.
*
+ * @See The state field in pz2watch.xhtml
+ * The state listeners windowlocationhashListener() and StateListener()
+ * in listeners.js
+ * The method {@link com.indexdata.mkjsf.pazpar2.Pz2Bean#handleQueryStateChanges}
+ * The class {@link com.indexdata.mkjsf.pazpar2.state.Pazpar2State}
+ * ... for a complete picture of browser history handling.
+ *
* @param key
*/
public void setCurrentStateKey(String key) {
if (currentKey.equals(key)) {
- logger.debug("setCurrentStateKey: no key change detected");
+ logger.debug("Ignoring request from UI to set state key, already has that key [" + key + "]");
} else {
- logger.debug("State key change. Was: [" + currentKey + "]. Will be ["+key+"]");
+ logger.debug("Request from UI to change state key from: [" + currentKey + "] to ["+key+"]");
if (states.get(key)==null) {
- logger.error("The back-end received an unknow state key, probably UI generated: ["+ key +"].");
+ logger.error("Have no state registered for the key ["+ key +"].");
if (key == null || key.length()==0) {
- logger.info("Empty key received, treating it as identical to current key going forward.");
+ logger.info("Recived an empty key, retaining currentKey [" + currentKey + "]");
key = currentKey;
} else {
if (states.get(currentKey) != null) {
- logger.info("Current search state cached under both of [" + key + "] and [" + currentKey + "]");
- states.put(key,states.get(currentKey));
+ if (key.equals("#1")) {
+ logger.info("Initial key created [" + key + "], but already got a state registered for the current key [" + currentKey + "]. Retaining current key.");
+ key = currentKey;
+ } else {
+ logger.info("Current search state cached under both new key [" + key + "] and current key [" + currentKey + "]");
+ states.put(key,states.get(currentKey));
+ }
}
}
}
if (states.get(key).getCommand("search").equals(states.get(currentKey).getCommand("search"))) {
- logger.debug("No search change detected");
+ logger.debug("No search change detected as a consequence of processing the key ["+key+"]");
} else {
hasPendingStateChange("search",true);
}
if (states.get(key).getCommand("record").equals(states.get(currentKey).getCommand("record"))) {
- logger.debug("No record change detected");
+ logger.debug("No record change detected as a consequence of processing the key ["+key+"]");
} else {
hasPendingStateChange("record",true);
}