private ArrayList<QueuedItem> parseExecutionListResult(final WebserviceResponse response) { final Document resultDoc = response.getResultDoc(); final Node node = resultDoc.selectSingleNode("/result/executions"); final List items = node.selectNodes("execution"); final ArrayList<QueuedItem> list = new ArrayList<QueuedItem>(); if (null != items && items.size() > 0) { for (final Object o : items) { final Node node1 = (Node) o; final String id = node1.selectSingleNode("@id").getStringValue(); final Node jobname = node1.selectSingleNode("job/name"); final Node desc = node1.selectSingleNode("description"); final String name; if (null != jobname) { name = jobname.getStringValue(); } else { name = desc.getStringValue(); } String url = node1.selectSingleNode("@href").getStringValue(); url = makeAbsoluteURL(url); logger.info("\t" + ": " + name + " [" + id + "] <" + url + ">"); list.add(QueuedItemResultImpl.createQueuedItem(id, url, name)); } } return list; }
public Collection<QueuedItem> listDispatcherQueue() throws CentralDispatcherException { final HashMap<String, String> params = new HashMap<String, String>(); params.put("xmlreq", "true"); final WebserviceResponse response; try { response = serverService.makeRundeckRequest(RUNDECK_LIST_EXECUTIONS_PATH, params, null, null); } catch (MalformedURLException e) { throw new CentralDispatcherServerRequestException("Failed to make request", e); } validateResponse(response); //////////////////// // parse result list of queued items, return the collection of QueuedItems /////////////////// final Document resultDoc = response.getResultDoc(); final Node node = resultDoc.selectSingleNode("/result/items"); final List items = node.selectNodes("item"); final ArrayList<QueuedItem> list = new ArrayList<QueuedItem>(); if (null != items && items.size() > 0) { for (final Object o : items) { final Node node1 = (Node) o; final String id = node1.selectSingleNode("id").getStringValue(); final String name = node1.selectSingleNode("name").getStringValue(); String url = node1.selectSingleNode("url").getStringValue(); url = makeAbsoluteURL(url); logger.info("\t" + ": " + name + " [" + id + "] <" + url + ">"); list.add(QueuedItemResultImpl.createQueuedItem(id, url, name)); } } return list; }