Examples of CausedIOException


Examples of de.fu_berlin.inf.dpp.util.CausedIOException

                    confirmation = remoteTransfers.get(objectid).poll(500,
                        TimeUnit.MILLISECONDS);
                }
            } catch (InterruptedException e) {
                log.error("Code not designed to be interrupted", e);
                throw new CausedIOException(
                    "Binary Channel received unexpected exception while waiting for confirmation package",
                    e);
            }
            if (confirmation == null)
                throw new IOException(
View Full Code Here

Examples of de.fu_berlin.inf.dpp.util.CausedIOException

        try {
            os = new ObjectInputStream(is);
            try {
                return (TransferDescription) os.readObject();
            } catch (ClassNotFoundException e) {
                throw new CausedIOException("Invalid Object sent", e);
            }
        } finally {
            IOUtils.closeQuietly(os);
            IOUtils.closeQuietly(is);
        }
View Full Code Here

Examples of de.fu_berlin.inf.dpp.util.CausedIOException

     */
    public static void uploadFile(File file, String server, SubMonitor monitor)
        throws IOException {
        try {
            if (file == null || !file.exists()) {
                throw new CausedIOException("Upload not possible",
                    new IllegalArgumentException(
                        "The file that should be uploaded was"
                            + " either null or nonexistent"));
            }

            monitor.beginTask("Uploading file " + file.getName(), 100);

            PostMethod post = new PostMethod(server);
            // holds the status response after the method was executed
            int status = 0;

            post.getParams().setBooleanParameter(
                HttpMethodParams.USE_EXPECT_CONTINUE, true);

            /*
             * retry the method 3 times, but not if the request was send
             * successfully
             */
            post.getParams().setParameter(HttpMethodParams.RETRY_HANDLER,
                new DefaultHttpMethodRetryHandler(3, false));

            monitor.worked(20);
            if (monitor.isCanceled())
                throw new CancellationException();

            try {
                // create a multipart request for the file
                Part[] parts = { new FilePart(file.getName(), file) };
                post.setRequestEntity(new MultipartRequestEntity(parts, post
                    .getParams()));

                HttpClient client = new HttpClient();

                /*
                 * connection has to be established within the timeout,
                 * otherwise a ConnectTimeoutException is thrown
                 */
                client.getHttpConnectionManager().getParams()
                    .setConnectionTimeout(TIMEOUT);

                log.info("Trying to upload file " + file.getName() + " to "
                    + server + " ...");

                monitor.worked(20);
                if (monitor.isCanceled())
                    throw new CancellationException();

                // try to upload the file
                status = client.executeMethod(post);

                monitor.worked(50);

                // examine status response
                if (status == HttpStatus.SC_OK) {
                    log.info("Upload successfull for " + file.getName()
                        + ".\nServer response: "
                        + IOUtils.toString(post.getResponseBodyAsStream()));
                    return;
                }

            } catch (ConnectTimeoutException e) {
                // couldn't connect within the timeout
                throw new CausedIOException("Couldn't connect to host "
                    + server, e);
            } catch (Exception e) {
                throw new CausedIOException(
                    "An internal error occurred while trying to upload file "
                        + file.getName(), e);
            } finally {
                post.releaseConnection();
            }
            // upload failed
            throw new CausedIOException("Upload failed", new RuntimeException(
                "Server response: " + status + " "
                    + HttpStatus.getStatusText(status)));
        } finally {
            monitor.done();
        }
View Full Code Here

Examples of de.fu_berlin.inf.dpp.util.CausedIOException

            } catch (TimeoutException e) {
                Utils.closeQuietly(outSession);
                String msg = "waiting for a response session timed out ("
                    + WAIT_FOR_RESPONSE_CONNECTION + "ms)";
                if (exception != null)
                    throw new CausedIOException(
                        prefix()
                            + msg
                            + " and could not establish a connection from this side, too:",
                        exception);
                else
View Full Code Here

Examples of de.fu_berlin.inf.dpp.util.CausedIOException

    public T parseString(String string) throws IOException {
        try {
            return ((XStreamPacketExtension<T>) xstream.fromXML(string))
                .getPayload();
        } catch (Exception e) {
            throw new CausedIOException(e);
        }
    }
View Full Code Here

Examples of de.fu_berlin.inf.dpp.util.CausedIOException

            channel = establishBinaryChannel(peer.toString(), progress);
            return new BinaryChannelConnection(peer, channel,
                connectionListener);

        } catch (XMPPException e) {
            throw new CausedIOException(e);
        }
    }
View Full Code Here

Examples of de.fu_berlin.inf.dpp.util.CausedIOException

        try {
            Chat chat = getChat(jid);
            chat.sendMessage(message);
        } catch (XMPPException e) {
            throw new CausedIOException("Failed to send message", e);
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.