use of org.apache.xmlrpc.XmlRpcClient in project jspwiki by apache.
the class PingWeblogsComFilter method postSave.
/**
* {@inheritDoc}
*/
public void postSave(WikiContext context, String pagecontent) {
String blogName = context.getPage().getName();
WikiEngine engine = context.getEngine();
int blogentryTxt = blogName.indexOf("_blogentry_");
if (blogentryTxt == -1) {
// This is not a weblog entry.
return;
}
blogName = blogName.substring(0, blogentryTxt);
if (blogName.equals(engine.getFrontPage())) {
blogName = null;
}
try {
XmlRpcClient xmlrpc = new XmlRpcClient(m_pingURL);
Vector<String> params = new Vector<String>();
// FIXME: Must be settable
params.addElement("The Butt Ugly Weblog");
params.addElement(engine.getURL(WikiContext.VIEW, blogName, null, true));
if (log.isDebugEnabled())
log.debug("Pinging weblogs.com with URL: " + engine.getURL(WikiContext.VIEW, blogName, null, true));
xmlrpc.executeAsync("weblogUpdates.ping", params, new AsyncCallback() {
public void handleError(Exception ex, URL url, String method) {
log.error("Unable to execute weblogs.com ping to URL: " + url.toString(), ex);
}
public void handleResult(Object result, URL url, String method) {
Hashtable res = (Hashtable) result;
Boolean flerror = (Boolean) res.get("flerror");
String msg = (String) res.get("message");
if (flerror.booleanValue()) {
log.error("Failed to ping: " + msg);
}
log.info("Weblogs.com has been pinged.");
}
});
} catch (MalformedURLException e) {
log.error("Malformed URL", e);
}
}
use of org.apache.xmlrpc.XmlRpcClient in project intellij-plugins by JetBrains.
the class NetworkUtil method sendMessage.
private static Object sendMessage(XmlRpcTarget target, String xmlRpcId, String method, List<Object> parameters) {
checkParameters(parameters, method);
String url = "http://" + target.getAddress().getHostAddress() + ':' + target.getPort() + "/rpc2";
String fullMethodName = xmlRpcId + '.' + method;
String logLine = "Call [" + url + "] " + fullMethodName;
if (LOG.isDebugEnabled()) {
LOG.info(buildFullLogLine(logLine, parameters));
}
for (int i = 0; i < parameters.size(); i++) {
Object o = parameters.get(i);
assert o != null : "Null parameter in position " + i;
}
try {
return new XmlRpcClient(url).execute(fullMethodName, new Vector<>(parameters));
} catch (MalformedURLException e) {
LOG.info(buildFullLogLine(logLine, parameters) + ' ' + e.getLocalizedMessage());
} catch (IOException e) {
LOG.info(buildFullLogLine(logLine, parameters) + ' ' + e.getLocalizedMessage());
} catch (XmlRpcException e) {
LOG.info(buildFullLogLine(logLine, parameters) + ' ' + e.getLocalizedMessage());
}
return null;
}
use of org.apache.xmlrpc.XmlRpcClient in project intellij-community by JetBrains.
the class JiraRepository method createLegacyApi.
private JiraLegacyApi createLegacyApi() {
try {
XmlRpcClient client = new XmlRpcClient(getUrl());
Vector<String> parameters = new Vector<>(Collections.singletonList(""));
XmlRpcRequest request = new XmlRpcRequest("jira1.getServerInfo", parameters);
@SuppressWarnings("unchecked") Hashtable<String, Object> response = (Hashtable<String, Object>) client.execute(request, new CommonsXmlRpcTransport(new URL(getUrl()), getHttpClient()));
if (response != null) {
myJiraVersion = (String) response.get("version");
}
} catch (Exception e) {
LOG.error("Cannot find out JIRA version via XML-RPC", e);
}
return new JiraLegacyApi(this);
}
use of org.apache.xmlrpc.XmlRpcClient in project intellij-community by JetBrains.
the class JiraIntegrationTest method createIssueViaXmlRpc.
@SuppressWarnings("UseOfObsoleteCollectionType")
@NotNull
private String createIssueViaXmlRpc(@NotNull String project, @NotNull String summary) throws Exception {
final URL url = new URL(myRepository.getUrl() + "/rpc/xmlrpc");
final XmlRpcClient xmlRpcClient = new XmlRpcClient(url);
final Map<String, Object> issue = new Hashtable<>();
issue.put("summary", summary);
issue.put("project", project);
issue.put("assignee", myRepository.getUsername());
// Bug
issue.put("type", 1);
// Open
issue.put("state", 1);
// empty token because of HTTP basic auth
final Vector<Object> params = new Vector<>(Arrays.asList("", issue));
final Hashtable result = (Hashtable) xmlRpcClient.execute(new XmlRpcRequest("jira1.createIssue", params), new CommonsXmlRpcTransport(url, myRepository.getHttpClient()));
return (String) result.get("key");
}
use of org.apache.xmlrpc.XmlRpcClient in project blue by kunstmusik.
the class BlueShareTest method main.
public static void main(String[] args) {
try {
// XmlRpcClient xrpc = new
// XmlRpcClient("http://localhost/blueShare/blueShareServer.php");
XmlRpcClient xrpc = new XmlRpcClient("http://www.kunstmusik.com/blueShare/blueShareServer.php");
Vector v = new Vector();
v.addElement(new Integer(1));
String result = (String) xrpc.execute("blueShare.getInstrumentList", v);
System.out.println("result: " + result);
} catch (XmlRpcException | IOException e) {
System.err.println("error...");
}
}
Aggregations