mirror of
https://github.com/Fishwaldo/rundeck-api-java-client.git
synced 2025-07-06 04:58:26 +00:00
Patch rundeck API v11 bug for execution query results
This commit is contained in:
parent
18ec800264
commit
c8e1315612
2 changed files with 51 additions and 3 deletions
|
@ -1587,13 +1587,26 @@ public class RundeckClient implements Serializable {
|
|||
.param(new ExecutionQueryParameters(query))
|
||||
.param("max", max)
|
||||
.param("offset", offset),
|
||||
new PagedResultParser<RundeckExecution>(
|
||||
new ListParser<RundeckExecution>(new ExecutionParser(), "execution"),
|
||||
rootXpath()+"/executions"
|
||||
patchApiV11Response(
|
||||
new PagedResultParser<RundeckExecution>(
|
||||
new ListParser<RundeckExecution>(new ExecutionParser(), "execution"),
|
||||
rootXpath() + "/executions"
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix potential buggy response from Rundeck, where <result> wrapper exists
|
||||
* even if it should not.
|
||||
* @param parser
|
||||
* @return
|
||||
*/
|
||||
private XmlNodeParser<PagedResults<RundeckExecution>> patchApiV11Response
|
||||
(final PagedResultParser<RundeckExecution> parser) {
|
||||
return new PagedResultParser_BugPatchV11<RundeckExecution>(parser);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a single execution, identified by the given ID
|
||||
*
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
package org.rundeck.api.parser;
|
||||
|
||||
import org.dom4j.DocumentHelper;
|
||||
import org.dom4j.Element;
|
||||
import org.dom4j.Node;
|
||||
import org.rundeck.api.util.PagedResults;
|
||||
|
||||
/**
|
||||
* WRaps a {@link PagedResultParser} to detect whether the result XML incorrectly is wrapped with a
|
||||
* <result> element.
|
||||
*
|
||||
* @author Greg Schueler <greg@simplifyops.com>
|
||||
* @since 2014-11-07
|
||||
*/
|
||||
public class PagedResultParser_BugPatchV11<T> implements XmlNodeParser<PagedResults<T>> {
|
||||
PagedResultParser<T> parser;
|
||||
|
||||
public PagedResultParser_BugPatchV11(final PagedResultParser<T> parser) {
|
||||
this.parser = parser;
|
||||
}
|
||||
|
||||
@Override public PagedResults<T> parseXmlNode(final Node node) {
|
||||
Node sourceNode = node;
|
||||
final Node tested = sourceNode.selectSingleNode(parser.getXpath());
|
||||
if (null == tested && !parser.getXpath().startsWith("result")) {
|
||||
//prepend /result
|
||||
if (null != sourceNode.selectSingleNode("result" + parser.getXpath())) {
|
||||
sourceNode = sourceNode.selectSingleNode("result" + parser.getXpath());
|
||||
sourceNode.getParent().remove(sourceNode);
|
||||
DocumentHelper.createDocument((Element) sourceNode);
|
||||
}
|
||||
}
|
||||
return parser.parseXmlNode(sourceNode);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue