\r
private void updateListeners (String command) {\r
for (StateListener lsnr : listeners) {\r
- lsnr.stateUpdate(command);\r
+ lsnr.stateUpdated(command);\r
}\r
}\r
\r
Pazpar2State state = new Pazpar2State(getCurrentState(),command);\r
states.put(state.getKey(), state);\r
currentKey = state.getKey();\r
- hasPendingStateChange(command.getName(),new Boolean(true));\r
+ hasPendingStateChange(command.getName(),new Boolean(true)); \r
+ logger.debug("Updating " + listeners.size() + " listener(s) with state change from " + command);\r
+ updateListeners(command.getName()); \r
} else {\r
logger.debug("Command " + command.getName() + " not found to change the state [" + command.getEncodedQueryString() + "]");\r
}\r
}\r
- \r
- /**\r
- * Gets a detached copy of a command. For the change manager\r
- * to become aware of any changes to the copy it must be \r
- * checked back in with 'checkIn(Pazpar2Command)'\r
- * \r
- * @param commandName\r
- * @return Copy this state's instance of the given command\r
- */\r
- public Pazpar2Command checkOut (String commandName) {\r
- logger.info("Getting " + commandName + " from state manager.");\r
- return getCurrentState().getCommand(commandName).copy();\r
+ \r
+ public Pazpar2Command getCommand (String commandName) {\r
+ return getCurrentState().getCommand(commandName);\r
}\r
\r
public Pazpar2State getCurrentState () {\r
logger.debug("setCurrentStateKey: no key change detected");\r
} else {\r
logger.debug("State key change. Was: [" + currentKey + "]. Will be ["+key+"]");\r
- if (states.get(key).getCommand("search").equals(states.get(currentKey).getCommand("search"))) {\r
- logger.debug("No search change detected");\r
- } else {\r
- hasPendingStateChange("search",true);\r
- }\r
- if (states.get(key).getCommand("record").equals(states.get(currentKey).getCommand("record"))) {\r
- logger.debug("No record change detected");\r
+ if (states.get(key)==null) {\r
+ logger.error("The back-end received an unknow state key."); \r
} else {\r
- hasPendingStateChange("record",true);\r
- }\r
- currentKey = key;\r
+ if (states.get(key).getCommand("search").equals(states.get(currentKey).getCommand("search"))) {\r
+ logger.debug("No search change detected");\r
+ } else {\r
+ hasPendingStateChange("search",true);\r
+ }\r
+ if (states.get(key).getCommand("record").equals(states.get(currentKey).getCommand("record"))) {\r
+ logger.debug("No record change detected");\r
+ } else {\r
+ hasPendingStateChange("record",true);\r
+ }\r
+ currentKey = key;\r
+ } \r
}\r
}\r
\r
*/\r
public void hasPendingStateChange(String command, boolean bool) {\r
pendingStateChanges.put(command, new Boolean(bool));\r
- if (bool) {\r
- logger.debug("Updating listeners with state change from " + command);\r
- updateListeners(command);\r
- }\r
}\r
\r
/**\r