\r
import org.apache.log4j.Logger;\r
\r
-import com.indexdata.pz2utils4jsf.pazpar2.commands.CommandReadOnly;\r
import com.indexdata.pz2utils4jsf.pazpar2.commands.Pazpar2Command;\r
import com.indexdata.pz2utils4jsf.utils.Utils;\r
\r
states.put(state.getKey(), state);\r
currentKey = state.getKey();\r
hasPendingStateChange(command.getName(),new Boolean(true)); \r
- logger.debug("Updating listeners with state change from " + command);\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.debug("Getting " + commandName + " from state manager.");\r
- return getCurrentState().getCommand(commandName).copy();\r
- }\r
- \r
- public CommandReadOnly getCommand (String commandName) {\r
+ \r
+ public Pazpar2Command getCommand (String commandName) {\r
return getCurrentState().getCommand(commandName);\r
}\r
\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