public Collection<IStoredJob> listStoredJobs( final IStoredJobsQuery iStoredJobsQuery, final OutputStream output) throws CentralDispatcherException { final HashMap<String, String> params = new HashMap<String, String>(); params.put("xmlreq", "true"); final String nameMatch = iStoredJobsQuery.getNameMatch(); String groupMatch = iStoredJobsQuery.getGroupMatch(); final String projectFilter = iStoredJobsQuery.getProjectFilter(); final String commandFilter = iStoredJobsQuery.getCommand(); final String idlistFilter = iStoredJobsQuery.getIdlist(); final String typeFilter = iStoredJobsQuery.getType(); final String resourceFilter = iStoredJobsQuery.getResource(); if (null != nameMatch) { params.put("jobFilter", nameMatch); } if (null != groupMatch) { final Matcher matcher = Pattern.compile("^/*(.+?)/*$").matcher(groupMatch); if (matcher.matches()) { // strip leading and trailing slashes groupMatch = matcher.group(1); } params.put("groupPath", groupMatch); } if (null != projectFilter) { params.put("projFilter", projectFilter); } if (null != resourceFilter) { params.put("objFilter", resourceFilter); } if (null != typeFilter) { params.put("typeFilter", typeFilter); } if (null != commandFilter) { params.put("cmdFilter", commandFilter); } if (null != idlistFilter) { params.put("idlist", idlistFilter); } params.put("xmlreq", "true"); // 2. send request via ServerService final WebserviceResponse response; try { response = serverService.makeRundeckRequest(RUNDECK_LIST_STORED_JOBS_PATH, params, null, null); } catch (MalformedURLException e) { throw new CentralDispatcherServerRequestException("Failed to make request", e); } validateJobsResponse(response); //////////////////// // parse result list of queued items, return the collection of QueuedItems /////////////////// final Document resultDoc = response.getResultDoc(); final Node node = resultDoc.selectSingleNode("/joblist"); final ArrayList<IStoredJob> list = new ArrayList<IStoredJob>(); if (null == node) { return list; } final List items = node.selectNodes("job"); 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(); final String url = createJobURL(id); final Node gnode = node1.selectSingleNode("group"); final String group = null != gnode ? gnode.getStringValue() : null; final String description = node1.selectSingleNode("description").getStringValue(); list.add(StoredJobImpl.create(id, name, url, group, description)); } } if (null != output) { // write output doc to the outputstream final OutputFormat format = OutputFormat.createPrettyPrint(); try { final XMLWriter writer = new XMLWriter(output, format); writer.write(resultDoc); writer.flush(); } catch (IOException e) { throw new CentralDispatcherServerRequestException(e); } } return list; }