+ public String update (String commands) {\r
+ if (! hasConfigurationErrors()) {\r
+ if (commandsAreValid(commands)) {\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(pzreq.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
+ responseLogger.debug("Response was: " + response);\r
+ Pazpar2ResponseData responseObject = Pazpar2ResponseParser.getParser().getDataObject(response);\r
+ pzresp.put(commandName, responseObject); \r
+ }\r
+ if (commands.equals("record")) {\r
+ logger.debug("Record: Active clients: "+pzresp.getRecord().getActiveClients());\r
+ return pzresp.getRecord().getActiveClients();\r
+ } else {\r
+ return pzresp.getActiveClients();\r
+ } \r
+ } else {\r
+ logger.debug("Skipped requests for " + commands + " as there's not yet a query."); \r
+ pzresp.reset();\r
+ return "0";\r
+ }\r
+ } else {\r
+ logger.error("Did not attemt to run command(s) due to a validation error.");\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
+ \r