Search in sources :

Example 1 with XmlRpcClient

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);
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) XmlRpcClient(org.apache.xmlrpc.XmlRpcClient) Hashtable(java.util.Hashtable) AsyncCallback(org.apache.xmlrpc.AsyncCallback) MalformedURLException(java.net.MalformedURLException) URL(java.net.URL) WikiEngine(org.apache.wiki.WikiEngine) Vector(java.util.Vector)

Example 2 with XmlRpcClient

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;
}
Also used : XmlRpcClient(org.apache.xmlrpc.XmlRpcClient) IOException(java.io.IOException) XmlRpcException(org.apache.xmlrpc.XmlRpcException)

Example 3 with XmlRpcClient

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);
}
Also used : JiraLegacyApi(com.intellij.tasks.jira.soap.JiraLegacyApi) XmlRpcClient(org.apache.xmlrpc.XmlRpcClient) CommonsXmlRpcTransport(org.apache.xmlrpc.CommonsXmlRpcTransport) URL(java.net.URL) MalformedURLException(java.net.MalformedURLException) XmlRpcRequest(org.apache.xmlrpc.XmlRpcRequest) JsonObject(com.google.gson.JsonObject)

Example 4 with XmlRpcClient

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");
}
Also used : XmlRpcClient(org.apache.xmlrpc.XmlRpcClient) JsonObject(com.google.gson.JsonObject) XmlRpcRequest(org.apache.xmlrpc.XmlRpcRequest) CommonsXmlRpcTransport(org.apache.xmlrpc.CommonsXmlRpcTransport) URL(java.net.URL) NotNull(org.jetbrains.annotations.NotNull)

Example 5 with XmlRpcClient

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...");
    }
}
Also used : XmlRpcClient(org.apache.xmlrpc.XmlRpcClient) IOException(java.io.IOException) Vector(java.util.Vector) XmlRpcException(org.apache.xmlrpc.XmlRpcException)

Aggregations

XmlRpcClient (org.apache.xmlrpc.XmlRpcClient)5 URL (java.net.URL)3 JsonObject (com.google.gson.JsonObject)2 IOException (java.io.IOException)2 MalformedURLException (java.net.MalformedURLException)2 Vector (java.util.Vector)2 CommonsXmlRpcTransport (org.apache.xmlrpc.CommonsXmlRpcTransport)2 XmlRpcException (org.apache.xmlrpc.XmlRpcException)2 XmlRpcRequest (org.apache.xmlrpc.XmlRpcRequest)2 JiraLegacyApi (com.intellij.tasks.jira.soap.JiraLegacyApi)1 Hashtable (java.util.Hashtable)1 WikiEngine (org.apache.wiki.WikiEngine)1 AsyncCallback (org.apache.xmlrpc.AsyncCallback)1 NotNull (org.jetbrains.annotations.NotNull)1