Renames Pz2Bean to Pz2Service
[mkjsf-moved-to-github.git] / src / main / java / com / indexdata / mkjsf / pazpar2 / state / StateManager.java
index 04c9c3f..7616f1e 100644 (file)
@@ -7,14 +7,11 @@ import java.util.HashMap;
 import java.util.List;\r
 import java.util.Map;\r
 \r
-import javax.enterprise.context.SessionScoped;\r
-\r
 import org.apache.log4j.Logger;\r
 \r
 import com.indexdata.mkjsf.pazpar2.commands.Pazpar2Command;\r
 import com.indexdata.mkjsf.utils.Utils;\r
 \r
-@SessionScoped\r
 public class StateManager implements Serializable {\r
   \r
   private static final long serialVersionUID = 8152558351351730035L;\r
@@ -25,16 +22,16 @@ public class StateManager implements Serializable {
                                                                 /* SP extras */ "auth","categories"));\r
   Map<String,Boolean> pendingStateChanges = new HashMap<String,Boolean>();\r
   private static Logger logger = Logger.getLogger(StateManager.class);\r
-  private List<StateListener> listeners = new ArrayList<StateListener>();\r
+  private List<StateListener> listeners = new ArrayList<StateListener>();  \r
   \r
   public StateManager () {\r
     logger.info("Initializing a Pazpar2 state manager [" + Utils.objectId(this) + "]");\r
-    Pazpar2State initialState = new Pazpar2State(this);\r
+    Pazpar2State initialState = new Pazpar2State();\r
     states.put(initialState.getKey(), initialState);\r
     currentKey = initialState.getKey();\r
     for (String command : allCommands) {\r
       pendingStateChanges.put(command, new Boolean(false));\r
-    }\r
+    }    \r
   }\r
   \r
   public void addStateListener(StateListener listener) {\r
@@ -65,12 +62,12 @@ public class StateManager implements Serializable {
    */\r
   public void checkIn(Pazpar2Command command) {\r
     if (getCurrentState().stateMutating(command)) {\r
-      logger.debug("State changed by: " + command.getCommandName());\r
+      logger.info("State changed by: " + command.getCommandName());\r
       Pazpar2State state = new Pazpar2State(getCurrentState(),command);\r
       states.put(state.getKey(), state);\r
       currentKey = state.getKey();\r
       hasPendingStateChange(command.getCommandName(),new Boolean(true));      \r
-      logger.debug("Updating " + listeners.size() + " listener(s) with state change from " + command);\r
+      logger.info("Updating " + listeners.size() + " listener(s) with state change from " + command);\r
       updateListeners(command.getCommandName());      \r
     } else {\r
       logger.debug("Command " + command.getCommandName() + " not found to change the state [" + command.getEncodedQueryString() + "]");\r
@@ -92,7 +89,7 @@ public class StateManager implements Serializable {
    * @See  The state field in pz2watch.xhtml<br/> \r
    *       The state listeners windowlocationhashListener() and StateListener()\r
    *       in listeners.js<br/>\r
-   *       The method {@link com.indexdata.mkjsf.pazpar2.Pz2Bean#handleQueryStateChanges}<br/>\r
+   *       The method {@link com.indexdata.mkjsf.pazpar2.Pz2Service#handleQueryStateChanges}<br/>\r
    *       The class {@link com.indexdata.mkjsf.pazpar2.state.Pazpar2State}<br/> \r
    * ... for a complete picture of browser history handling.\r
    * \r
@@ -100,18 +97,18 @@ public class StateManager implements Serializable {
    */\r
   public void setCurrentStateKey(String key) {    \r
     if (currentKey.equals(key)) {\r
-      logger.debug("Ignoring request from UI to set state key, already has that key [" + key + "]");\r
+      logger.info("Ignoring request from UI to set state key, already has that key [" + key + "]");\r
     } else {\r
-      logger.debug("Request from UI to change state key from: [" + currentKey + "] to ["+key+"]");\r
+      logger.info("Request from UI to change state key from: [" + currentKey + "] to ["+key+"]");\r
       if (states.get(key)==null) {\r
         logger.error("Have no state registered for the key ["+ key +"].");\r
         if (key == null || key.length()==0) {\r
-          logger.info("Recived an empty key, retaining currentKey [" + currentKey + "]");\r
+          logger.debug("Recived an empty key, retaining currentKey [" + currentKey + "]");\r
           key = currentKey;\r
         } else {\r
           if (states.get(currentKey) != null) {\r
             if (key.equals("#1")) {\r
-              logger.info("Initial key created [" + key + "], but already got a state registered for the current key [" + currentKey + "]. Retaining current key.");\r
+              logger.debug("Initial key created [" + key + "], but already got a state registered for the current key [" + currentKey + "]. Retaining current key.");\r
               key = currentKey;\r
             } else {\r
               logger.info("Current search state cached under both new key [" + key + "] and current key [" + currentKey + "]");\r