- public String toggleRecord(String recid) {\r
- return pz2.toggleRecord(recid);\r
- }\r
- \r
- /* (non-Javadoc)\r
- * @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#getShow()\r
- */\r
- public ShowResponse getShow() {\r
- return pz2.getShow();\r
- }\r
- \r
- /* (non-Javadoc)\r
- * @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#getStat()\r
- */\r
- public StatResponse getStat() {\r
- return pz2.getStat();\r
- }\r
+ public String update (String commands) {\r
+ if (! hasConfigurationErrors()) {\r
+ if (hasQuery()) {\r
+ handleQueryStateChanges(commands);\r
+ logger.debug("Processing request for " + commands); \r
+ List<CommandThread> threadList = new ArrayList<CommandThread>();\r
+ StringTokenizer tokens = new StringTokenizer(commands,",");\r
+ while (tokens.hasMoreElements()) { \r
+ threadList.add(new CommandThread(req.getCommandReadOnly(tokens.nextToken()),searchClient)); \r
+ }\r
+ for (CommandThread thread : threadList) {\r
+ thread.start();\r
+ }\r
+ for (CommandThread thread : threadList) {\r
+ try {\r
+ thread.join();\r
+ } catch (InterruptedException e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+ for (CommandThread thread : threadList) {\r
+ String commandName = thread.getCommand().getName();\r
+ String response = thread.getResponse();\r
+ logger.debug("Response was: " + response);\r
+ Pazpar2ResponseData responseObject = Pazpar2ResponseParser.getParser().getDataObject(response);\r
+ data.put(commandName, responseObject); \r
+ }\r
+ if (commands.equals("record")) {\r
+ logger.debug("Record: Active clients: "+data.getRecord().getActiveClients());\r
+ return data.getRecord().getActiveClients();\r
+ } else {\r
+ return data.getActiveClients();\r
+ } \r
+ } else {\r
+ logger.debug("Skipped requests for " + commands + " as there's not yet a query."); \r
+ data.reset();\r
+ return "0";\r
+ }\r
+ } else {\r
+ logger.error("Did not attempt to execute query since there are configuration errors.");\r
+ return "0";\r
+ }\r