Package com.jcraft.jsch

Examples of com.jcraft.jsch.SftpATTRS


    private SftpATTRS changeToRepositoryDirectory( ChannelSftp channel, String dir, String filename )
        throws ResourceDoesNotExistException, SftpException
    {
        // This must be called first to ensure that if the file doesn't exist it throws an exception
        SftpATTRS attrs;
        try
        {
            channel.cd( repository.getBasedir() );

            if ( dir.length() > 0 )
View Full Code Here


    @Override
    public Resource getResource(ResourceURI uri) {
        try {
            ChannelSftp channel = getOrCreateChannel(uri);
            SftpATTRS stat;

            try {
                stat = channel.stat(uri.getPath());
            } catch (SftpException e) {
                throw new ResourceNotFoundException(e);
View Full Code Here

    private void mkdir( String dir, int mode )
        throws TransferFailedException, SftpException
    {
        try
        {
            SftpATTRS attrs = channel.stat( dir );
            if ( ( attrs.getPermissions() & S_IFDIR ) == 0 )
            {
                throw new TransferFailedException( "Remote path is not a directory: " + dir );
            }
        }
        catch ( SftpException e )
View Full Code Here

    private SftpATTRS changeToRepositoryDirectory( String dir, String filename )
        throws ResourceDoesNotExistException, SftpException
    {
        // This must be called first to ensure that if the file doesn't exist it throws an exception
        SftpATTRS attrs;
        try
        {
            channel.cd( repository.getBasedir() );

            if ( dir.length() > 0 )
View Full Code Here

            dir = dir.substring( 1 );
        }

        try
        {
            SftpATTRS attrs = changeToRepositoryDirectory( dir, filename );
            if ( ( attrs.getPermissions() & S_IFDIR ) == 0 )
            {
                throw new TransferFailedException( "Remote path is not a directory:" + dir );
            }

            @SuppressWarnings( "unchecked" )
View Full Code Here

            dir = dir.substring( 1 );
        }

        try
        {
            SftpATTRS attrs = changeToRepositoryDirectory( dir, filename );

            long lastModified = attrs.getMTime() * MILLIS_PER_SEC;
            resource.setContentLength( attrs.getSize() );

            resource.setLastModified( lastModified );
           
            inputData.setInputStream( channel.get( filename ) );
        }
View Full Code Here

    }

    @Override
    FileStream open(final String path) throws IOException {
      try {
        final SftpATTRS a = ftp.lstat(path);
        return new FileStream(ftp.get(path), a.getSize());
      } catch (SftpException je) {
        if (je.id == ChannelSftp.SSH_FX_NO_SUCH_FILE)
          throw new FileNotFoundException(path);
        throw new TransportException("Can't get " + objectsPath + "/"
            + path + ": " + je.getMessage(), je);
View Full Code Here

            final ArrayList<String> toBeDeleted = new ArrayList<String>();
            LsEntrySelector selector = new LsEntrySelector() {
                @Override
                public int select(LsEntry entry) {
                    Matcher mtc = ARTIFACT_REGEXP.matcher(entry.getFilename());
                    SftpATTRS attr = entry.getAttrs();
                    if (mtc.find() && !attr.isDir() && !attr.isLink()) {
                        toBeDeleted.add(entry.getFilename());
                    }
                    return CONTINUE;
                }
            };
View Full Code Here

        }

        for (RemoteHost rh : m_hosts) {
            boolean existsOrIsDir = true;
            try {
                SftpATTRS stat = rh.channel.stat(rh.path);
                if (!stat.isDir()) {
                    existsOrIsDir = false;
                }
            } catch (SftpException e) {
                if (e.id == ChannelSftp.SSH_FX_NO_SUCH_FILE) {
                    existsOrIsDir = false;
View Full Code Here

    }

    public Resource getResource(ResourceURI uri) {
        try {
            ChannelSftp channel = getOrCreateChannel(uri);
            SftpATTRS stat;

            try {
                stat = channel.stat(uri.getPath());
            } catch (SftpException e) {
                throw new ResourceNotFoundException(e);
View Full Code Here

TOP

Related Classes of com.jcraft.jsch.SftpATTRS

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.