Example usage for java.lang RuntimeException toString

List of usage examples for java.lang RuntimeException toString

Introduction

In this page you can find the example usage for java.lang RuntimeException toString.

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

Usage

From source file:com.bonsai.wallet32.SendBitcoinActivity.java

public void onSendBitcoin(int acctId, String addrString, long amount, long fee) {

    try {/*from   ww  w  .  j  a  v  a 2s  .c om*/
        mLogger.info(String.format("send from %d, to %s, amount %s, fee %s starting", acctId, addrString,
                mBTCFmt.format(amount), mBTCFmt.format(fee)));

        mWalletService.sendCoinsFromAccount(acctId, addrString, amount, fee, spendUnconfirmed());

        mLogger.info("send finished");

        // Head to the transaction view for this account ...
        Intent intent = new Intent(this, ViewTransactionsActivity.class);
        Bundle bundle = new Bundle();
        bundle.putInt("accountId", mCheckedFromId);
        intent.putExtras(bundle);
        startActivity(intent);

        // We're done here ...
        finish();

    } catch (RuntimeException ex) {
        mLogger.error(ex.toString());
        showErrorDialog(ex.getMessage());
        return;
    }
}

From source file:org.alfresco.repo.transfer.HttpClientTransmitterImpl.java

public void verifyTarget(TransferTarget target) throws TransferException {
    HttpMethod verifyRequest = getPostMethod();
    try {//from   w  ww.  java  2 s .com
        HostConfiguration hostConfig = getHostConfig(target);
        HttpState httpState = getHttpState(target);

        verifyRequest.setPath(target.getEndpointPath() + "/test");
        try {
            int response = httpClient.executeMethod(hostConfig, verifyRequest, httpState);
            checkResponseStatus("verifyTarget", response, verifyRequest);
        } catch (RuntimeException e) {
            throw e;
        } catch (Exception e) {
            String error = "Failed to execute HTTP request to target";
            log.debug(error, e);
            throw new TransferException(MSG_HTTP_REQUEST_FAILED,
                    new Object[] { "verifyTraget", target.toString(), e.toString() }, e);
        }
    } finally {
        verifyRequest.releaseConnection();
    }
}

From source file:org.alfresco.repo.transfer.HttpClientTransmitterImpl.java

public void abort(Transfer transfer) throws TransferException {
    TransferTarget target = transfer.getTransferTarget();
    HttpMethod abortRequest = getPostMethod();
    try {//from w  ww  . j  ava  2 s.c o m
        HostConfiguration hostConfig = getHostConfig(target);
        HttpState httpState = getHttpState(target);

        abortRequest.setPath(target.getEndpointPath() + "/abort");
        //Put the transferId on the query string
        abortRequest.setQueryString(
                new NameValuePair[] { new NameValuePair("transferId", transfer.getTransferId()) });

        try {
            int responseStatus = httpClient.executeMethod(hostConfig, abortRequest, httpState);
            checkResponseStatus("abort", responseStatus, abortRequest);
            //If we get here then we've received a 200 response
            //We're expecting the transfer id encoded in a JSON object...
        } catch (RuntimeException e) {
            throw e;
        } catch (Exception e) {
            String error = "Failed to execute HTTP request to target";
            log.debug(error, e);
            throw new TransferException(MSG_HTTP_REQUEST_FAILED,
                    new Object[] { "abort", target.toString(), e.toString() }, e);
        }
    } finally {
        abortRequest.releaseConnection();
    }
}

From source file:org.alfresco.repo.transfer.HttpClientTransmitterImpl.java

public void commit(Transfer transfer) throws TransferException {
    TransferTarget target = transfer.getTransferTarget();
    HttpMethod commitRequest = getPostMethod();
    try {//from ww w. ja va  2  s.  co  m
        HostConfiguration hostConfig = getHostConfig(target);
        HttpState httpState = getHttpState(target);

        commitRequest.setPath(target.getEndpointPath() + "/commit");
        //Put the transferId on the query string
        commitRequest.setQueryString(
                new NameValuePair[] { new NameValuePair("transferId", transfer.getTransferId()) });
        try {
            int responseStatus = httpClient.executeMethod(hostConfig, commitRequest, httpState);
            checkResponseStatus("commit", responseStatus, commitRequest);
            //If we get here then we've received a 200 response
            //We're expecting the transfer id encoded in a JSON object...
        } catch (RuntimeException e) {
            throw e;
        } catch (Exception e) {
            String error = "Failed to execute HTTP request to target";
            log.error(error, e);
            throw new TransferException(MSG_HTTP_REQUEST_FAILED,
                    new Object[] { "commit", target.toString(), e.toString() }, e);
        }
    } finally {
        commitRequest.releaseConnection();
    }
}

From source file:org.alfresco.repo.transfer.HttpClientTransmitterImpl.java

public void prepare(Transfer transfer) throws TransferException {
    TransferTarget target = transfer.getTransferTarget();
    HttpMethod prepareRequest = getPostMethod();
    try {/* ww w.j a v  a2 s. c  o  m*/
        HostConfiguration hostConfig = getHostConfig(target);
        HttpState httpState = getHttpState(target);

        prepareRequest.setPath(target.getEndpointPath() + "/prepare");
        //Put the transferId on the query string
        prepareRequest.setQueryString(
                new NameValuePair[] { new NameValuePair("transferId", transfer.getTransferId()) });
        try {
            int responseStatus = httpClient.executeMethod(hostConfig, prepareRequest, httpState);
            checkResponseStatus("prepare", responseStatus, prepareRequest);
            //If we get here then we've received a 200 response
            //We're expecting the transfer id encoded in a JSON object...
        } catch (RuntimeException e) {
            throw e;
        } catch (Exception e) {
            String error = "Failed to execute HTTP request to target";
            log.debug(error, e);
            throw new TransferException(MSG_HTTP_REQUEST_FAILED,
                    new Object[] { "prepare", target.toString(), e.toString() }, e);
        }
    } finally {
        prepareRequest.releaseConnection();
    }
}

From source file:com.streamsets.pipeline.lib.jdbc.JdbcUtil.java

public HikariDataSource createDataSourceForRead(HikariPoolConfigBean hikariConfigBean) throws StageException {
    HikariDataSource dataSource;/*from  www  . ja v a 2  s.  com*/
    try {
        dataSource = new HikariDataSource(createDataSourceConfig(hikariConfigBean, hikariConfigBean.autoCommit,
                hikariConfigBean.readOnly));
    } catch (RuntimeException e) {
        LOG.error(JdbcErrors.JDBC_06.getMessage(), e);
        throw new StageException(JdbcErrors.JDBC_06, e.toString(), e);
    }

    return dataSource;
}

From source file:org.alfresco.repo.transfer.HttpClientTransmitterImpl.java

/**
 *
 *///from   www . java  2  s.co  m
public TransferProgress getStatus(Transfer transfer) throws TransferException {
    TransferTarget target = transfer.getTransferTarget();
    HttpMethod statusRequest = getPostMethod();
    try {
        HostConfiguration hostConfig = getHostConfig(target);
        HttpState httpState = getHttpState(target);

        statusRequest.setPath(target.getEndpointPath() + "/status");
        //Put the transferId on the query string
        statusRequest.setQueryString(
                new NameValuePair[] { new NameValuePair("transferId", transfer.getTransferId()) });

        try {
            int responseStatus = httpClient.executeMethod(hostConfig, statusRequest, httpState);
            checkResponseStatus("status", responseStatus, statusRequest);
            //If we get here then we've received a 200 response
            String statusPayload = statusRequest.getResponseBodyAsString();
            JSONObject statusObj = new JSONObject(statusPayload);
            //We're expecting the transfer progress encoded in a JSON object...
            int currentPosition = statusObj.getInt("currentPosition");
            int endPosition = statusObj.getInt("endPosition");
            String statusStr = statusObj.getString("status");

            TransferProgress p = new TransferProgress();

            if (statusObj.has("error")) {
                JSONObject errorJSON = statusObj.getJSONObject("error");
                Throwable throwable = rehydrateError(errorJSON);
                p.setError(throwable);
            }

            p.setStatus(TransferProgress.Status.valueOf(statusStr));
            p.setCurrentPosition(currentPosition);
            p.setEndPosition(endPosition);

            return p;
        } catch (RuntimeException e) {
            throw e;
        } catch (Exception e) {
            String error = "Failed to execute HTTP request to target";
            log.debug(error, e);
            throw new TransferException(MSG_HTTP_REQUEST_FAILED,
                    new Object[] { "status", target.toString(), e.toString() }, e);
        }
    } finally {
        statusRequest.releaseConnection();
    }
}

From source file:org.alfresco.repo.transfer.HttpClientTransmitterImpl.java

/**
 *
 *//*from   w  w w .  j a  va  2s  . c o  m*/
public void getTransferReport(Transfer transfer, OutputStream result) {
    TransferTarget target = transfer.getTransferTarget();
    PostMethod getReportRequest = getPostMethod();
    try {
        HostConfiguration hostConfig = getHostConfig(target);
        HttpState httpState = getHttpState(target);

        try {
            getReportRequest.setPath(target.getEndpointPath() + "/report");

            //Put the transferId on the query string
            getReportRequest.setQueryString(
                    new NameValuePair[] { new NameValuePair("transferId", transfer.getTransferId()) });

            int responseStatus = httpClient.executeMethod(hostConfig, getReportRequest, httpState);
            checkResponseStatus("getReport", responseStatus, getReportRequest);

            InputStream is = getReportRequest.getResponseBodyAsStream();

            // Now copy the response input stream to result.
            final ReadableByteChannel inputChannel = Channels.newChannel(is);
            final WritableByteChannel outputChannel = Channels.newChannel(result);
            try {
                // copy the channels
                channelCopy(inputChannel, outputChannel);
            } finally {
                // closing the channels
                inputChannel.close();
                outputChannel.close();
            }

            return;
        } catch (RuntimeException e) {
            throw e;
        } catch (Exception e) {
            String error = "Failed to execute HTTP request to target";
            log.debug(error, e);
            throw new TransferException(MSG_HTTP_REQUEST_FAILED,
                    new Object[] { "getTransferReport", target.toString(), e.toString() }, e);
        }
    } finally {
        getReportRequest.releaseConnection();
    }
}

From source file:org.alfresco.repo.transfer.HttpClientTransmitterImpl.java

public void sendManifest(Transfer transfer, File manifest, OutputStream result) throws TransferException {
    TransferTarget target = transfer.getTransferTarget();
    PostMethod postSnapshotRequest = getPostMethod();
    MultipartRequestEntity requestEntity;

    if (log.isDebugEnabled()) {
        log.debug("does manifest exist? " + manifest.exists());
        log.debug("sendManifest file : " + manifest.getAbsoluteFile());
    }/* w w  w  .  j a  v  a  2s  . co  m*/

    try {
        HostConfiguration hostConfig = getHostConfig(target);
        HttpState httpState = getHttpState(target);

        try {
            postSnapshotRequest.setPath(target.getEndpointPath() + "/post-snapshot");

            //Put the transferId on the query string
            postSnapshotRequest.setQueryString(
                    new NameValuePair[] { new NameValuePair("transferId", transfer.getTransferId()) });

            //TODO encapsulate the name of the manifest part
            //And add the manifest file as a "part"
            Part file = new FilePart(TransferCommons.PART_NAME_MANIFEST, manifest);
            requestEntity = new MultipartRequestEntity(new Part[] { file }, postSnapshotRequest.getParams());
            postSnapshotRequest.setRequestEntity(requestEntity);

            int responseStatus = httpClient.executeMethod(hostConfig, postSnapshotRequest, httpState);
            checkResponseStatus("sendManifest", responseStatus, postSnapshotRequest);

            InputStream is = postSnapshotRequest.getResponseBodyAsStream();

            final ReadableByteChannel inputChannel = Channels.newChannel(is);
            final WritableByteChannel outputChannel = Channels.newChannel(result);
            try {
                // copy the channels
                channelCopy(inputChannel, outputChannel);
            } finally {
                inputChannel.close();
                outputChannel.close();
            }

            return;
        } catch (RuntimeException e) {
            throw e;
        } catch (Exception e) {
            String error = "Failed to execute HTTP request to target";
            log.debug(error, e);
            throw new TransferException(MSG_HTTP_REQUEST_FAILED,
                    new Object[] { "sendManifest", target.toString(), e.toString() }, e);
        }
    } finally {
        postSnapshotRequest.releaseConnection();
    }
}

From source file:org.alfresco.repo.transfer.HttpClientTransmitterImpl.java

/**
 *
 *//* w w w . j a  v  a 2  s . c  o m*/
public void sendContent(Transfer transfer, Set<ContentData> data) throws TransferException {
    if (log.isDebugEnabled()) {
        log.debug("send content to transfer:" + transfer);
    }

    TransferTarget target = transfer.getTransferTarget();
    PostMethod postContentRequest = getPostMethod();

    try {
        HostConfiguration hostConfig = getHostConfig(target);
        HttpState httpState = getHttpState(target);

        try {
            postContentRequest.setPath(target.getEndpointPath() + "/post-content");
            //Put the transferId on the query string
            postContentRequest.setQueryString(
                    new NameValuePair[] { new NameValuePair("transferId", transfer.getTransferId()) });

            //Put the transferId on the query string
            postContentRequest.setQueryString(
                    new NameValuePair[] { new NameValuePair("transferId", transfer.getTransferId()) });

            Part[] parts = new Part[data.size()];

            int index = 0;
            for (ContentData content : data) {
                String contentUrl = content.getContentUrl();
                String fileName = TransferCommons.URLToPartName(contentUrl);
                log.debug("content partName: " + fileName);

                parts[index++] = new ContentDataPart(getContentService(), fileName, content);
            }

            MultipartRequestEntity requestEntity = new MultipartRequestEntity(parts,
                    postContentRequest.getParams());
            postContentRequest.setRequestEntity(requestEntity);

            int responseStatus = httpClient.executeMethod(hostConfig, postContentRequest, httpState);
            checkResponseStatus("sendContent", responseStatus, postContentRequest);

            if (log.isDebugEnabled()) {
                log.debug("sent content");
            }

        } catch (RuntimeException e) {
            throw e;
        } catch (Exception e) {
            String error = "Failed to execute HTTP request to target";
            log.debug(error, e);
            throw new TransferException(MSG_HTTP_REQUEST_FAILED,
                    new Object[] { "sendContent", target.toString(), e.toString() }, e);
        }
    } finally {
        postContentRequest.releaseConnection();
    }
}