use of org.jdom.Element in project intellij-community by JetBrains.
the class FogBugzRepository method login.
private void login(@NotNull PostMethod method) throws Exception {
LOG.debug("Requesting new token");
int status = getHttpClient().executeMethod(method);
if (status != 200) {
throw new Exception("Error logging in: " + method.getStatusLine());
}
Document document = new SAXBuilder(false).build(method.getResponseBodyAsStream()).getDocument();
XPath path = XPath.newInstance("/response/token");
Element result = (Element) path.selectSingleNode(document);
if (result == null) {
Element error = (Element) XPath.newInstance("/response/error").selectSingleNode(document);
throw new Exception(error == null ? "Error logging in" : error.getText());
}
myToken = result.getTextTrim();
}
use of org.jdom.Element in project intellij-community by JetBrains.
the class XPathResponseHandler method selectTasksList.
@NotNull
@Override
protected List<Object> selectTasksList(@NotNull String response, int max) throws Exception {
Document document = new SAXBuilder(false).build(new StringReader(response));
Element root = document.getRootElement();
XPath xPath = lazyCompile(getSelector(TASKS).getPath());
@SuppressWarnings("unchecked") List<Object> rawTaskElements = xPath.selectNodes(root);
if (!rawTaskElements.isEmpty() && !(rawTaskElements.get(0) instanceof Element)) {
throw new Exception(String.format("Expression '%s' should match list of XML elements. Got '%s' instead.", xPath.getXPath(), rawTaskElements.toString()));
}
return rawTaskElements.subList(0, Math.min(rawTaskElements.size(), max));
}
use of org.jdom.Element in project intellij-community by JetBrains.
the class ProjectViewContextProvider method saveContext.
public void saveContext(Element toElement) throws WriteExternalException {
for (AbstractProjectViewPane pane : myPanes) {
Element paneElement = new Element(pane.getId());
pane.writeExternal(paneElement);
toElement.addContent(paneElement);
}
}
use of org.jdom.Element in project intellij-community by JetBrains.
the class WorkingContextManager method saveContext.
public void saveContext(Element toElement) {
for (WorkingContextProvider provider : Extensions.getExtensions(WorkingContextProvider.EP_NAME, myProject)) {
try {
Element child = new Element(provider.getId());
provider.saveContext(child);
toElement.addContent(child);
} catch (WriteExternalException e) {
LOG.error(e);
}
}
}
use of org.jdom.Element in project intellij-community by JetBrains.
the class XDebuggerBreakpointsContextProvider method saveContext.
@Override
public void saveContext(Element toElement) throws WriteExternalException {
XBreakpointManagerImpl.BreakpointManagerState state = myBreakpointManager.getState();
Element serialize = XmlSerializer.serialize(state, new SerializationFilter() {
@Override
public boolean accepts(@NotNull Accessor accessor, @NotNull Object bean) {
return accessor.read(bean) != null;
}
});
toElement.addContent(serialize.removeContent());
}
Aggregations