X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fcom%2Findexdata%2Fpz2utils4jsf%2Fpazpar2%2Fstate%2FStateManager.java;h=f1ae6b6859b0ef716486b95617e19e333d9ba002;hb=801fbed2d559e224160d473e0860dd765354569f;hp=14951e604530b7b23118366278251f9e06172bac;hpb=977e4983e28683dd8a7d9fd19b0daee3ac349a3a;p=mkjsf-moved-to-github.git diff --git a/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/state/StateManager.java b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/state/StateManager.java index 14951e6..f1ae6b6 100644 --- a/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/state/StateManager.java +++ b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/state/StateManager.java @@ -46,7 +46,7 @@ public class StateManager implements Serializable { private void updateListeners (String command) { for (StateListener lsnr : listeners) { - lsnr.stateUpdate(command); + lsnr.stateUpdated(command); } } @@ -68,23 +68,16 @@ public class StateManager implements Serializable { Pazpar2State state = new Pazpar2State(getCurrentState(),command); states.put(state.getKey(), state); currentKey = state.getKey(); - hasPendingStateChange(command.getName(),new Boolean(true)); + hasPendingStateChange(command.getName(),new Boolean(true)); + logger.debug("Updating " + listeners.size() + " listener(s) with state change from " + command); + updateListeners(command.getName()); } else { logger.debug("Command " + command.getName() + " not found to change the state [" + command.getEncodedQueryString() + "]"); } } - - /** - * Gets a detached copy of a command. For the change manager - * to become aware of any changes to the copy it must be - * checked back in with 'checkIn(Pazpar2Command)' - * - * @param commandName - * @return Copy this state's instance of the given command - */ - public Pazpar2Command checkOut (String commandName) { - logger.info("Getting " + commandName + " from state manager."); - return getCurrentState().getCommand(commandName).copy(); + + public Pazpar2Command getCommand (String commandName) { + return getCurrentState().getCommand(commandName); } public Pazpar2State getCurrentState () { @@ -102,17 +95,21 @@ public class StateManager implements Serializable { logger.debug("setCurrentStateKey: no key change detected"); } else { logger.debug("State key change. Was: [" + currentKey + "]. Will be ["+key+"]"); - if (states.get(key).getCommand("search").equals(states.get(currentKey).getCommand("search"))) { - logger.debug("No search change detected"); - } else { - hasPendingStateChange("search",true); - } - if (states.get(key).getCommand("record").equals(states.get(currentKey).getCommand("record"))) { - logger.debug("No record change detected"); + if (states.get(key)==null) { + logger.error("The back-end received an unknow state key."); } else { - hasPendingStateChange("record",true); - } - currentKey = key; + if (states.get(key).getCommand("search").equals(states.get(currentKey).getCommand("search"))) { + logger.debug("No search change detected"); + } else { + hasPendingStateChange("search",true); + } + if (states.get(key).getCommand("record").equals(states.get(currentKey).getCommand("record"))) { + logger.debug("No record change detected"); + } else { + hasPendingStateChange("record",true); + } + currentKey = key; + } } } @@ -127,10 +124,6 @@ public class StateManager implements Serializable { */ public void hasPendingStateChange(String command, boolean bool) { pendingStateChanges.put(command, new Boolean(bool)); - if (bool) { - logger.debug("Updating listeners with state change from " + command); - updateListeners(command); - } } /**