Package org.apache.xmlrpc

Examples of org.apache.xmlrpc.XmlRpcException


            }
            return results;
        } catch (Exception e) {
            String msg = "ERROR in BlooggerAPIHander.getRecentPosts";
            mLogger.error(msg,e);
            throw new XmlRpcException(UNKNOWN_EXCEPTION, msg);
        }
    }
View Full Code Here


        public Object sendRequest(XmlRpcRequest req) throws XmlRpcException {
            XmlRpcHttpClientConfig config = (XmlRpcHttpClientConfig) req.getConfig();
            URL serverUrl = config.getServerURL();
            if (serverUrl == null) {
                throw new XmlRpcException("Invalid server URL");
            }

            try {
                con = openConnection(serverUrl);
                con.setUseCaches(false);
                con.setDoInput(true);
                con.setDoOutput(true);
            } catch (IOException e) {
                throw new XmlRpcException("Failed to create URLConnection: " + e.getMessage(), e);
            }
            return super.sendRequest(req);
        }
View Full Code Here

        protected InputStream getInputStream() throws XmlRpcException {
            try {
                return con.getInputStream();
            } catch (IOException e) {
                throw new XmlRpcException("Failed to create input stream: " + e.getMessage(), e);
            }
        }
View Full Code Here

            ModelService model;
            try {
                model = dispatcher.getDispatchContext().getModelService(xmlRpcReq.getMethodName());
            } catch (GenericServiceException e) {
                throw new XmlRpcException(e.getMessage(), e);
            }

            if (model != null && model.auth) {
                String username = config.getBasicUserName();
                String password = config.getBasicPassword();

                // check the account
                Map<String, Object> context = FastMap.newInstance();
                context.put("login.username", username);
                context.put("login.password", password);

                Map<String, Object> resp;
                try {
                    resp = dispatcher.runSync("userLogin", context);
                } catch (GenericServiceException e) {
                    throw new XmlRpcException(e.getMessage(), e);
                }

                if (ServiceUtil.isError(resp)) {
                    return false;
                }
View Full Code Here

            String serviceName = xmlRpcReq.getMethodName();
            ModelService model = null;
            try {
                model = dctx.getModelService(serviceName);
            } catch (GenericServiceException e) {
                throw new XmlRpcException(e.getMessage(), e);
            }

            // check remote invocation security
            if (model == null || !model.export) {
                throw new XmlRpcException("Unknown method");
            }

            // prepare the context -- single parameter type struct (map)
            Map<String, Object> context = this.getContext(xmlRpcReq, serviceName);

            // add in auth parameters
            XmlRpcHttpRequestConfig config = (XmlRpcHttpRequestConfig) xmlRpcReq.getConfig();
            String username = config.getBasicUserName();
            String password = config.getBasicPassword();
            if (UtilValidate.isNotEmpty(username)) {
                context.put("login.username", username);
                context.put("login.password", password);
            }

            // add the locale to the context
            context.put("locale", Locale.getDefault());

            // invoke the service
            Map<String, Object> resp;
            try {
                resp = dispatcher.runSync(serviceName, context);
            } catch (GenericServiceException e) {
                throw new XmlRpcException(e.getMessage(), e);
            }
            if (ServiceUtil.isError(resp)) {
                Debug.logError(ServiceUtil.getErrorMessage(resp), module);
                throw new XmlRpcException(ServiceUtil.getErrorMessage(resp));
            }

            // return only definied parameters
            return model.makeValid(resp, ModelService.OUT_PARAM, false, null);
        }
View Full Code Here

        protected Map<String, Object> getContext(XmlRpcRequest xmlRpcReq, String serviceName) throws XmlRpcException {
            ModelService model;
            try {
                model = dispatcher.getDispatchContext().getModelService(serviceName);
            } catch (GenericServiceException e) {
                throw new XmlRpcException(e.getMessage(), e);
            }

            // context placeholder
            Map<String, Object> context = FastMap.newInstance();

            if (model != null) {
                int parameterCount = xmlRpcReq.getParameterCount();

                // more than one parameter; use list notation based on service def order
                if (parameterCount > 1) {
                    int x = 0;
                    for (String name: model.getParameterNames("IN", true, true)) {
                        context.put(name, xmlRpcReq.getParameter(x));
                        x++;

                        if (x == parameterCount) {
                            break;
                        }
                    }

                // only one parameter; if its a map use it as the context; otherwise make sure the service takes one param
                } else if (parameterCount == 1) {
                    Object param = xmlRpcReq.getParameter(0);
                    if (param instanceof Map) {
                        context = checkMap(param, String.class, Object.class);
                    } else {
                        if (model.getDefinedInCount() == 1) {
                            String paramName = (String) model.getInParamNames().iterator().next();
                            context.put(paramName, xmlRpcReq.getParameter(0));
                        } else {
                            throw new XmlRpcException("More than one parameter defined on service; cannot call via RPC with parameter list");
                        }
                    }
                }

                // do map value conversions
View Full Code Here

        Iterator iter =  mock(Iterator.class);
        doReturn(iter).when(vms).iterator();
        when(iter.hasNext()).thenReturn(true).thenReturn(false);
        doReturn(vm).when(iter).next();
        VM.Record vmr = mock(VM.Record.class);
        when(vm.getRecord(conn)).thenThrow(new XmlRpcException("XmlRpcException"));
        when(vm.getRecord(conn)).thenReturn(vmr);
        vmr.powerState = Types.VmPowerState.RUNNING;
        vmr.residentOn = mock(Host.class);
        XenAPIObject object = mock(XenAPIObject.class);
        doReturn(new String("OpaqueRef:NULL")).when(object).toWireString();
View Full Code Here

    try {
      return callback.waitForResponse();
    } catch (TimingOutCallback.TimeoutException to) {
      throw to;
    } catch (Throwable e) {
      throw new XmlRpcException(-2, e.getMessage());
    } finally {
      long endTime = System.currentTimeMillis();
      float during = (endTime - startTime) / 1000; // in secs
      s_logger.debug("Ovm call " + method + " finished in " + during + " secs");
    }
View Full Code Here

    /**
     * Handler for {@link JiraTest#testXMLRPC113()}
     */
    public static class XMLRPC113HandlerImpl implements XMLRPC113Handler {
        public Object throwCode(int pCode) throws XmlRpcException {
            throw new XmlRpcException(pCode, "Message: " + pCode);
        }
View Full Code Here

   */
  public static XMLReader newXMLReader() throws XmlRpcException {
    try {
      return spf.newSAXParser().getXMLReader();
    } catch (ParserConfigurationException e) {
      throw new XmlRpcException("Unable to create XML parser: " + e.getMessage(), e);
    } catch (SAXException e) {
      throw new XmlRpcException("Unable to create XML parser: " + e.getMessage(), e);
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.xmlrpc.XmlRpcException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.