Package com.jcraft.jsch

Examples of com.jcraft.jsch.ChannelSftp$Header


        /*
        final ChannelSftp channel = fileSystem.getChannel();
        return new SftpOutputStream(channel);
        */

        final ChannelSftp channel = fileSystem.getChannel();
        return new SftpOutputStream(channel, channel.put(relPath));
    }
View Full Code Here


        }

        try
        {
            // Use the pooled channel, or create a new one
            final ChannelSftp channel;
            if (idleChannel != null)
            {
                channel = idleChannel;
                idleChannel = null;
            }
            else
            {
                channel = (ChannelSftp) session.openChannel("sftp");
                channel.connect();

                Boolean userDirIsRoot =
                    SftpFileSystemConfigBuilder.getInstance().getUserDirIsRoot(getFileSystemOptions());
                String workingDirectory = getRootName().getPath();
                if (workingDirectory != null && (userDirIsRoot == null || !userDirIsRoot.booleanValue()))
                {
                    try
                    {
                        channel.cd(workingDirectory);
                    }
                    catch (SftpException e)
                    {
                        throw new FileSystemException("vfs.provider.sftp/change-work-directory.error",
                            workingDirectory);
View Full Code Here

    protected void remoteChmod(MuleClient muleClient,
                               SftpClient sftpClient,
                               String endpointName,
                               int permissions) throws SftpException
    {
        ChannelSftp channelSftp = sftpClient.getChannelSftp();

        ImmutableEndpoint endpoint = (ImmutableEndpoint) muleClient.getProperty(endpointName);
        EndpointURI endpointURI = endpoint.getEndpointURI();

        // RW - so that we can do initial cleanup
        channelSftp.chmod(permissions, sftpClient.getAbsolutePath(endpointURI.getPath()));
    }
View Full Code Here

    {
        MuleClient muleClient = new MuleClient(muleContext);
        SftpClient sftpClient = getSftpClient(muleClient, endpointName);
        try
        {
            ChannelSftp channelSftp = sftpClient.getChannelSftp();
            try
            {
                recursiveDelete(muleClient, sftpClient, endpointName, "");
            }
            catch (IOException e)
            {
                if (logger.isErrorEnabled())
                    logger.error("Failed to recursivly delete endpoint " + endpointName, e);
            }

            String path = getPathByEndpoint(muleClient, sftpClient, endpointName);
            channelSftp.mkdir(path);
        }
        finally
        {
            sftpClient.disconnect();
            if (logger.isDebugEnabled()) logger.debug("Done init endpoint directory: " + endpointName);
View Full Code Here

     * @return a fully initialised resource, able to answer to all its methods without needing any
     *         further connection
     */
    public Resource resolveResource(String path) {
        try {
            ChannelSftp c = getSftpChannel(path);
            Collection r = c.ls(path);
            if (r != null) {
                for (Iterator iter = r.iterator(); iter.hasNext();) {
                    Object obj = iter.next();
                    if (obj instanceof LsEntry) {
                        LsEntry entry = (LsEntry) obj;
View Full Code Here

        }
        return new BasicResource(path, false, 0, 0, false);
    }

    public InputStream openStream(SFTPResource resource) throws IOException {
        ChannelSftp c = getSftpChannel(resource.getName());
        try {
            return c.get(resource.getName());
        } catch (SftpException e) {
            e.printStackTrace();
            IOException ex = new IOException("impossible to open stream for " + resource + " on "
                    + getHost() + (e.getMessage() != null ? ": " + e.getMessage() : ""));
            ex.initCause(e);
View Full Code Here

        }
    }

    public void get(String source, File destination) throws IOException {
        fireTransferInitiated(getResource(source), TransferEvent.REQUEST_GET);
        ChannelSftp c = getSftpChannel(source);
        try {
            c.get(source, destination.getAbsolutePath(), new MyProgressMonitor());
        } catch (SftpException e) {
            e.printStackTrace();
            IOException ex = new IOException("impossible to get " + source + " on " + getHost()
                    + (e.getMessage() != null ? ": " + e.getMessage() : ""));
            ex.initCause(e);
View Full Code Here

        }
    }

    public void put(File source, String destination, boolean overwrite) throws IOException {
        fireTransferInitiated(getResource(destination), TransferEvent.REQUEST_PUT);
        ChannelSftp c = getSftpChannel(destination);
        try {
            if (!overwrite && checkExistence(destination, c))
                throw new IOException("destination file exists and overwrite == true");
            if (destination.indexOf('/') != -1) {
                mkdirs(destination.substring(0, destination.lastIndexOf('/')), c);
            }
            c.put(source.getAbsolutePath(), destination, new MyProgressMonitor());
        } catch (SftpException e) {
            IOException ex = new IOException(e.getMessage());
            ex.initCause(e);
            throw ex;
        }
View Full Code Here

        }
    }

    public List list(String parent) throws IOException {
        try {
            ChannelSftp c = getSftpChannel(parent);
            Collection r = c.ls(parent);
            if (r != null) {
                if (!parent.endsWith("/")) {
                    parent = parent + "/";
                }
                List result = new ArrayList();
View Full Code Here

     *             if any connection problem occurs
     */
    private ChannelSftp getSftpChannel(String pathOrUri) throws IOException {
        Session session = getSession(pathOrUri);
        String host = session.getHost();
        ChannelSftp channel = SshCache.getInstance().getChannelSftp(session);
        if (channel == null) {
            try {
                channel = (ChannelSftp) session.openChannel("sftp");
                channel.connect();
                Message.verbose(":: SFTP :: connected to " + host + "!");
                SshCache.getInstance().attachChannelSftp(session, channel);
            } catch (JSchException e) {
                IOException ex = new IOException(e.getMessage());
                ex.initCause(e);
View Full Code Here

TOP

Related Classes of com.jcraft.jsch.ChannelSftp$Header

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.