Package com.xebialabs.overthere

Examples of com.xebialabs.overthere.RuntimeIOException


        if (dest instanceof CifsFile) {
            SmbFile targetSmbFile = ((CifsFile) dest).getSmbFile();
            try {
                smbFile.renameTo(targetSmbFile);
            } catch (SmbException exc) {
                throw new RuntimeIOException(format("Cannot move/rename %s to %s: %s", smbFile.getUncPath(), dest, exc.toString()), exc);
            }
        } else {
            throw new RuntimeIOException(format("Cannot move/rename cifs:%s: file/directory %s  to non-cifs:%s: file/directory %s",
                    connection.cifsConnectionType.toString().toLowerCase(), smbFile.getUncPath(), connection.cifsConnectionType.toString().toLowerCase(), dest));
        }
    }
View Full Code Here


                            }
                        } else {
                            logger.error("Cannot find errorlevel in Windows output: " + outputBuf);
                        }
                    } catch (IOException exc) {
                        throw new RuntimeIOException(format("Cannot start command [%s] on [%s]", obfuscatedCmd, CifsTelnetConnection.this), exc);
                    } finally {
                        closeQuietly(toCallersStdout);
                    }
                }
            };
            outputReaderThread.setDaemon(true);
            outputReaderThread.start();

            return new OverthereProcess() {
                @Override
                public synchronized OutputStream getStdin() {
                    return stdin;
                }

                @Override
                public synchronized InputStream getStdout() {
                    return callersStdout;
                }

                @Override
                public synchronized InputStream getStderr() {
                    return new ByteArrayInputStream(new byte[0]);
                }

                @Override
                public synchronized int waitFor() {
                    if (!tc.isConnected()) {
                        return exitValue[0];
                    }

                    try {
                        try {
                            outputReaderThread.join();
                        } finally {
                            disconnect();
                        }
                        return exitValue[0];
                    } catch (InterruptedException exc) {
                        throw new RuntimeIOException(format("Cannot start command [%s] on [%s]", obfuscatedCmd, CifsTelnetConnection.this), exc);
                    }
                }

                @Override
                public synchronized void destroy() {
                    if (!tc.isConnected()) {
                        return;
                    }

                    disconnect();
                }

                private synchronized void disconnect() {
                    try {
                        tc.disconnect();
                        logger.info("Disconnected from {}", CifsTelnetConnection.this);

                        closeQuietly(toCallersStdout);
                    } catch (IOException exc) {
                        throw new RuntimeIOException(format("Cannot disconnect from %s", CifsTelnetConnection.this), exc);
                    }
                }

                @Override
                public synchronized int exitValue() {
                    if (tc.isConnected()) {
                        throw new IllegalThreadStateException(format("Process for command [%s] on %s is still running", obfuscatedCmd, CifsTelnetConnection.this));
                    }

                    synchronized (exitValue) {
                        return exitValue[0];
                    }
                }
            };
        } catch (InvalidTelnetOptionException exc) {
            throw new RuntimeIOException("Cannot execute command " + cmd + " at telnet://" + username + "@" + address, exc);
        } catch (IOException exc) {
            throw new RuntimeIOException("Cannot execute command " + cmd + " at telnet://" + username + "@" + address, exc);
        }
    }
View Full Code Here

        try {
            if (smbFile.isDirectory()) {
                upgradeToDirectorySmbFile();
                if (smbFile.list().length > 0) {
                    throw new RuntimeIOException(format("Cannot delete non-empty directory %s", smbFile.getUncPath()));
                }
            }
            smbFile.delete();
            refreshSmbFile();
        } catch (MalformedURLException exc) {
            throw new RuntimeIOException(format("Cannot delete %s: %s", smbFile.getUncPath(), exc.toString()), exc);
        } catch (SmbException exc) {
            throw new RuntimeIOException(format("Cannot delete %s: %s", smbFile.getUncPath(), exc.toString()), exc);
        }
    }
View Full Code Here

                        handleReceivedLine(outputBuf, outputBufStr, toCallersStdout);
                    }
                    break;
                case '[':
                    if (lastCharWasEsc) {
                        throw new RuntimeIOException(
                                "VT100/ANSI escape sequence found in output stream. Please configure the Windows Telnet server to use stream mode (tlntadmn config mode=stream).");
                    }
            }
            lastCharWasCr = (c == '\r');
            lastCharWasEsc = (c == 27);
View Full Code Here

                upgradeToDirectorySmbFile();
            }
            smbFile.delete();
            refreshSmbFile();
        } catch (MalformedURLException exc) {
            throw new RuntimeIOException(format("Cannot delete %s recursively: %s", smbFile.getUncPath(), exc.toString()), exc);
        } catch (SmbException exc) {
            throw new RuntimeIOException(format("Cannot delete %s recursively: %s", smbFile.getUncPath(), exc.toString()), exc);
        }
    }
View Full Code Here

                    logger.debug("Closing CIFS input stream for {}", CifsFile.this.smbFile.getUncPath());
                    wrapped.close();
                }
            });
        } catch (IOException exc) {
            throw new RuntimeIOException(format("Cannot open %s for reading: %s", smbFile.getUncPath(), exc.toString()), exc);
        }
    }
View Full Code Here

                    logger.debug("Closing CIFS output stream for {}", CifsFile.this.smbFile.getUncPath());
                    wrapped.close();
                }
            });
        } catch (IOException exc) {
            throw new RuntimeIOException(format("Cannot open %s for writing: %s", smbFile.getUncPath(), exc.toString()), exc);
        }
    }
View Full Code Here

        if (path.length() >= 2 && path.charAt(1) == ':') {
            char driveLetter = toUpperCase(path.charAt(0));
            String pathInDrive = path.substring(2).replace('\\', '/');
            translatedPath = "/" + driveLetter + pathInDrive;
        } else {
            throw new RuntimeIOException(format("Cannot translate Windows path [%s] to a WinSSHD path because it is not a Windows path", path));
        }
        logger.trace("Translated Windows path [{}] to WinSSHD path [{}]", path, translatedPath);
        return translatedPath;
    }
View Full Code Here

    private static String urlEncode(String value) {
        try {
            return URLEncoder.encode(value, "UTF-8");
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeIOException("Unable to construct SMB URL", e);
        }
    }
View Full Code Here

    public OverthereFile getFile(String hostPath) throws RuntimeIOException {
        try {
            SmbFile smbFile = new SmbFile(encodeAsSmbUrl(hostPath), authentication);
            return new CifsFile(this, smbFile);
        } catch (IOException exc) {
            throw new RuntimeIOException(exc);
        }
    }
View Full Code Here

TOP

Related Classes of com.xebialabs.overthere.RuntimeIOException

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.