Search in sources :

Example 46 with XmlRpcException

use of org.apache.xmlrpc.XmlRpcException 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 47 with XmlRpcException

use of org.apache.xmlrpc.XmlRpcException in project intellij-community by JetBrains.

the class GitAskPassXmlRpcClient method askPassword.

// Obsolete collection usage because of the XmlRpcClientLite API
@SuppressWarnings({ "UseOfObsoleteCollectionType", "unchecked" })
String askPassword(String token, @NotNull String url) {
    Vector parameters = new Vector();
    parameters.add(token);
    parameters.add(url);
    try {
        return (String) myClient.execute(methodName("askPassword"), parameters);
    } catch (XmlRpcException | IOException e) {
        throw new RuntimeException("Invocation failed " + e.getMessage(), e);
    }
}
Also used : IOException(java.io.IOException) Vector(java.util.Vector) XmlRpcException(org.apache.xmlrpc.XmlRpcException)

Example 48 with XmlRpcException

use of org.apache.xmlrpc.XmlRpcException in project intellij-community by JetBrains.

the class GitAskPassXmlRpcClient method askUsername.

// Obsolete collection usage because of the XmlRpcClientLite API
@SuppressWarnings({ "UseOfObsoleteCollectionType", "unchecked" })
String askUsername(String token, @NotNull String url) {
    Vector parameters = new Vector();
    parameters.add(token);
    parameters.add(url);
    try {
        return (String) myClient.execute(methodName("askUsername"), parameters);
    } catch (XmlRpcException | IOException e) {
        throw new RuntimeException("Invocation failed " + e.getMessage(), e);
    }
}
Also used : IOException(java.io.IOException) Vector(java.util.Vector) XmlRpcException(org.apache.xmlrpc.XmlRpcException)

Example 49 with XmlRpcException

use of org.apache.xmlrpc.XmlRpcException in project intellij-community by JetBrains.

the class GitSSHXmlRpcClient method verifyServerHostKey.

/**
   * {@inheritDoc}
   */
@SuppressWarnings("unchecked")
public boolean verifyServerHostKey(String token, final String hostname, final int port, final String serverHostKeyAlgorithm, final String serverHostKey, final boolean isNew) {
    if (myClient == null) {
        return false;
    }
    Vector parameters = new Vector();
    parameters.add(token);
    parameters.add(hostname);
    parameters.add(port);
    parameters.add(serverHostKeyAlgorithm);
    parameters.add(serverHostKey);
    parameters.add(isNew);
    try {
        return ((Boolean) myClient.execute(methodName("verifyServerHostKey"), parameters)).booleanValue();
    } catch (XmlRpcException | IOException e) {
        throw new RuntimeException("Invocation failed " + e.getMessage(), e);
    }
}
Also used : IOException(java.io.IOException) Vector(java.util.Vector) XmlRpcException(org.apache.xmlrpc.XmlRpcException)

Example 50 with XmlRpcException

use of org.apache.xmlrpc.XmlRpcException in project intellij-community by JetBrains.

the class GitSSHXmlRpcClient method askPassword.

/**
   * {@inheritDoc}
   */
@Nullable
@SuppressWarnings("unchecked")
public String askPassword(String token, final String username, final boolean resetPassword, final String lastError) {
    if (myClient == null) {
        return null;
    }
    Vector parameters = new Vector();
    parameters.add(token);
    parameters.add(username);
    parameters.add(resetPassword);
    parameters.add(lastError);
    try {
        return adjustNull(((String) myClient.execute(methodName("askPassword"), parameters)));
    } catch (XmlRpcException | IOException e) {
        throw new RuntimeException("Invocation failed " + e.getMessage(), e);
    }
}
Also used : IOException(java.io.IOException) Vector(java.util.Vector) XmlRpcException(org.apache.xmlrpc.XmlRpcException) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

XmlRpcException (org.apache.xmlrpc.XmlRpcException)100 XenAPIException (com.xensource.xenapi.Types.XenAPIException)75 Connection (com.xensource.xenapi.Connection)49 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)35 Answer (com.cloud.agent.api.Answer)33 IOException (java.io.IOException)27 BadServerResponse (com.xensource.xenapi.Types.BadServerResponse)26 Network (com.xensource.xenapi.Network)25 Test (org.junit.Test)25 AttachAnswer (org.apache.cloudstack.storage.command.AttachAnswer)22 XsLocalNetwork (com.cloud.hypervisor.xenserver.resource.XsLocalNetwork)21 Host (com.xensource.xenapi.Host)21 RebootAnswer (com.cloud.agent.api.RebootAnswer)20 CreateAnswer (com.cloud.agent.api.storage.CreateAnswer)20 HashMap (java.util.HashMap)20 VM (com.xensource.xenapi.VM)17 VDI (com.xensource.xenapi.VDI)16 ConfigurationException (javax.naming.ConfigurationException)16 SR (com.xensource.xenapi.SR)15 InternalErrorException (com.cloud.exception.InternalErrorException)13