protected InputStream getInputStream() throws XmlRpcException { try { return method.getResponseBodyAsStream(); } catch (HttpException e) { throw new XmlRpcClientException("Error in HTTP transport: " + e.getMessage(), e); } catch (IOException e) { throw new XmlRpcClientException("I/O error in server communication: " + e.getMessage(), e); } }
@Override protected Map dispatch(String methodcall, Object[] methodparams) throws XmlRpcException, XenAPIException { if (methodcall.equals("session.local_logout") || methodcall.equals("session.slave_local_login_with_password") || methodcall.equals("session.logout") || methodcall.equals("session.login_with_password")) { return super.dispatch(methodcall, methodparams); } try { return super.dispatch(methodcall, methodparams); } catch (Types.SessionInvalid e) { s_logger.debug("Session is invalid for method: " + methodcall + " due to " + e.toString()); removeConnect(_poolUuid); throw e; } catch (XmlRpcClientException e) { s_logger.debug("XmlRpcClientException for method: " + methodcall + " due to " + e.toString()); removeConnect(_poolUuid); throw e; } catch (XmlRpcException e) { s_logger.debug("XmlRpcException for method: " + methodcall + " due to " + e.toString()); removeConnect(_poolUuid); throw e; } catch (Types.HostIsSlave e) { s_logger.debug("HostIsSlave Exception for method: " + methodcall + " due to " + e.toString()); removeConnect(_poolUuid); throw e; } } }
private Object call(String command, Object[] args) throws SwizzleException { for (int i = 0; i < args.length; i++) { Object arg = args[i]; if (arg instanceof MapObject) { MapObject map = (MapObject) arg; if (sendRawData) { args[i] = map.toRawMap(); } else { args[i] = map.toMap(); } } } Object[] vector; if (!command.equals("login")) { vector = new Object[args.length + 1]; vector[0] = token; System.arraycopy(args, 0, vector, 1, args.length); } else { vector = args; } try { return client.execute("confluence2." + command, vector); } catch (XmlRpcClientException e) { throw new SwizzleException(e.getMessage(), e.linkedException); } catch (XmlRpcException e) { throw new ConfluenceException(e.getMessage(), e.linkedException); } } }
throw new XmlRpcClientException("Failed to close connection: " + e.getMessage(), e);
throw new XmlRpcClientException("Failed to close connection: " + e.getMessage(), e);
protected InputStream getInputStream() throws XmlRpcException { try { checkStatus(method); return method.getResponseBodyAsStream(); } catch (HttpException e) { throw new XmlRpcClientException("Error in HTTP transport: " + e.getMessage(), e); } catch (IOException e) { throw new XmlRpcClientException("I/O error in server communication: " + e.getMessage(), e); } }
protected InputStream getInputStream() throws XmlRpcException { try { checkStatus(method); return method.getResponseBodyAsStream(); } catch (HttpException e) { throw new XmlRpcClientException("Error in HTTP transport: " + e.getMessage(), e); } catch (IOException e) { throw new XmlRpcClientException("I/O error in server communication: " + e.getMessage(), e); } }
throw new XmlRpcClientException("Failed to close connection: " + e.getMessage(), e);
@Override protected InputStream getInputStream() throws XmlRpcException { try { client = builder.setHeaders( headers ).build(); // Check the status of the return Response response = client.post( new ByteArrayBodyGenerator( byteOs.toByteArray() ) ).get(); return response.getResponseBodyAsStream(); } catch ( InterruptedException e ) { throw new XmlRpcClientException( "Interruption during communication: " + e.getMessage(), e ); } catch ( ExecutionException e ) { throw new XmlRpcClientException( "Execution error during communication: " + e.getMessage(), e ); } catch ( IOException e ) { throw new XmlRpcClientException( "I/O error in server communication: " + e.getMessage(), e ); } finally { byteOs.reset(); } }
throw new XmlRpcClientException("Failed to read server response: " + e.getMessage(), e);
code = Integer.parseInt(statusCode); } catch (NumberFormatException e) { throw new XmlRpcClientException("Server returned invalid status code: " + statusCode + " " + statusMsg, null); throw new XmlRpcClientException("Failed to read server response: " + e.getMessage(), e);
code = Integer.parseInt(statusCode); } catch (NumberFormatException e) { throw new XmlRpcClientException("Server returned invalid status code: " + statusCode + " " + statusMsg, null); throw new XmlRpcClientException("Failed to read server response: " + e.getMessage(), e);
throw new XmlRpcClientException("Failed to parse server's response: " + e.getMessage(), e); } catch (IOException e) { throw new XmlRpcClientException("Failed to read server's response: " + e.getMessage(), e);
protected Object readResponse(XmlRpcStreamRequestConfig pConfig, InputStream pStream) throws XmlRpcException { InputSource isource = new InputSource(pStream); XMLReader xr = newXMLReader(); XmlRpcResponseParser xp; try { xp = new XmlRpcResponseParser(pConfig, getClient().getTypeFactory()); xr.setContentHandler(xp); xr.parse(isource); } catch (SAXException e) { throw new XmlRpcClientException("Failed to parse servers response: " + e.getMessage(), e); } catch (IOException e) { throw new XmlRpcClientException("Failed to read servers response: " + e.getMessage(), e); } if (xp.isSuccess()) { return xp.getResult(); } else { throw new XmlRpcException(xp.getErrorCode(), xp.getErrorMessage()); } } }
@Override protected InputStream getInputStream() throws XmlRpcException { int responseCode = method.getStatusCode(); if (responseCode != HttpURLConnection.HTTP_OK) { XmlRpcHttpException e = new XmlRpcHttpException(responseCode); if (responseCode == HttpStatus.SC_UNAUTHORIZED) { e.setAuthScheme(method.getHostAuthState().getAuthScheme()); } throw e; } try { return method.getResponseBodyAsStream(); } catch (HttpException e) { throw new XmlRpcClientException("Error in HTTP transport: " + e.getMessage(), e); //$NON-NLS-1$ } catch (IOException e) { throw new XmlRpcClientException("I/O error in server communication: " + e.getMessage(), e); //$NON-NLS-1$ } }
protected Object readResponse(XmlRpcStreamRequestConfig pConfig, InputStream pStream) throws XmlRpcException { InputSource isource = new InputSource(pStream); XMLReader xr = newXMLReader(); XmlRpcResponseParser xp; try { xp = new XmlRpcResponseParser(pConfig, getClient().getTypeFactory()); xr.setContentHandler(xp); xr.parse(isource); } catch (SAXException e) { throw new XmlRpcClientException("Failed to parse server's response: " + e.getMessage(), e); } catch (IOException e) { throw new XmlRpcClientException("Failed to read server's response: " + e.getMessage(), e); } if (xp.isSuccess()) { return xp.getResult(); } Throwable t = xp.getErrorCause(); if (t == null) { throw new XmlRpcException(xp.getErrorCode(), xp.getErrorMessage()); } if (t instanceof XmlRpcException) { throw (XmlRpcException) t; } if (t instanceof RuntimeException) { throw (RuntimeException) t; } throw new XmlRpcException(xp.getErrorCode(), xp.getErrorMessage(), t); } }
protected Object readResponse(XmlRpcStreamRequestConfig pConfig, InputStream pStream) throws XmlRpcException { InputSource isource = new InputSource(pStream); XMLReader xr = newXMLReader(); XmlRpcResponseParser xp; try { xp = new XmlRpcResponseParser(pConfig, getClient().getTypeFactory()); xr.setContentHandler(xp); xr.parse(isource); } catch (SAXException e) { throw new XmlRpcClientException("Failed to parse server's response: " + e.getMessage(), e); } catch (IOException e) { throw new XmlRpcClientException("Failed to read server's response: " + e.getMessage(), e); } if (xp.isSuccess()) { return xp.getResult(); } Throwable t = xp.getErrorCause(); if (t == null) { throw new XmlRpcException(xp.getErrorCode(), xp.getErrorMessage()); } if (t instanceof XmlRpcException) { throw (XmlRpcException) t; } if (t instanceof RuntimeException) { throw (RuntimeException) t; } throw new XmlRpcException(xp.getErrorCode(), xp.getErrorMessage(), t); } }
protected Object readResponse(XmlRpcStreamRequestConfig pConfig, InputStream pStream) throws XmlRpcException { InputSource isource = new InputSource(pStream); isource.setEncoding(pConfig.getEncoding()); //jl XMLReader xr = newXMLReader(); XmlRpcResponseParser xp; try { xp = new XmlRpcResponseParser(pConfig, getClient().getTypeFactory()); xr.setContentHandler(xp); xr.parse(isource); } catch (SAXException e) { throw new XmlRpcClientException("Failed to parse server's response: " + e.getMessage(), e); } catch (IOException e) { throw new XmlRpcClientException("Failed to read server's response: " + e.getMessage(), e); } if (xp.isSuccess()) { return xp.getResult(); } Throwable t = xp.getErrorCause(); if (t == null) { throw new XmlRpcException(xp.getErrorCode(), xp.getErrorMessage()); } if (t instanceof XmlRpcException) { throw (XmlRpcException) t; } if (t instanceof RuntimeException) { throw (RuntimeException) t; } throw new XmlRpcException(xp.getErrorCode(), xp.getErrorMessage(), t); } }
protected Object readResponse(XmlRpcStreamRequestConfig pConfig, InputStream pStream) throws XmlRpcException { InputSource isource = new InputSource(pStream); XMLReader xr = newXMLReader(); XmlRpcResponseParser xp; try { xp = new XmlRpcResponseParser(pConfig, getClient().getTypeFactory()); xr.setContentHandler(xp); xr.parse(isource); } catch (SAXException e) { throw new XmlRpcClientException("Failed to parse server's response: " + e.getMessage(), e); } catch (IOException e) { throw new XmlRpcClientException("Failed to read server's response: " + e.getMessage(), e); } if (xp.isSuccess()) { return xp.getResult(); } Throwable t = xp.getErrorCause(); if (t == null) { throw new XmlRpcException(xp.getErrorCode(), xp.getErrorMessage()); } if (t instanceof XmlRpcException) { throw (XmlRpcException) t; } if (t instanceof RuntimeException) { throw (RuntimeException) t; } throw new XmlRpcException(xp.getErrorCode(), xp.getErrorMessage(), t); } }
protected void setCredentials(XmlRpcHttpClientConfig pConfig) throws XmlRpcClientException { String auth; try { auth = HttpUtil.encodeBasicAuthentication(pConfig.getBasicUserName(), pConfig.getBasicPassword(), pConfig.getBasicEncoding()); } catch (UnsupportedEncodingException e) { throw new XmlRpcClientException("Unsupported encoding: " + pConfig.getBasicEncoding(), e); } if (auth != null) { setRequestHeader("Authorization", "Basic " + auth); } }