Example usage for org.apache.commons.net.ftp FTPFile WORLD_ACCESS

List of usage examples for org.apache.commons.net.ftp FTPFile WORLD_ACCESS

Introduction

In this page you can find the example usage for org.apache.commons.net.ftp FTPFile WORLD_ACCESS.

Prototype

int WORLD_ACCESS

To view the source code for org.apache.commons.net.ftp FTPFile WORLD_ACCESS.

Click Source Link

Document

A constant indicating world access permissions.

Usage

From source file:ch.cyberduck.core.ftp.FTPPath.java

protected boolean parseListResponse(final AttributedList<Path> children, final FTPFileEntryParser parser,
        final List<String> replies) {
    if (null == replies) {
        // This is an empty directory
        return false;
    }/*from  www.jav  a  2s  .  c  om*/
    boolean success = false;
    for (String line : replies) {
        final FTPFile f = parser.parseFTPEntry(line);
        if (null == f) {
            continue;
        }
        final String name = f.getName();
        if (!success) {
            // Workaround for #2410. STAT only returns ls of directory itself
            // Workaround for #2434. STAT of symbolic link directory only lists the directory itself.
            if (this.getAbsolute().equals(name)) {
                log.warn(String.format("Skip %s", f.getName()));
                continue;
            }
            if (name.contains(String.valueOf(DELIMITER))) {
                if (!name.startsWith(this.getAbsolute() + Path.DELIMITER)) {
                    // Workaround for #2434.
                    log.warn("Skip listing entry with delimiter:" + name);
                    continue;
                }
            }
        }
        success = true;
        if (name.equals(".") || name.equals("..")) {
            if (log.isDebugEnabled()) {
                log.debug(String.format("Skip %s", f.getName()));
            }
            continue;
        }
        final Path parsed = new FTPPath(this.getSession(), this.getAbsolute(),
                StringUtils.removeStart(name, this.getAbsolute() + Path.DELIMITER),
                f.getType() == FTPFile.DIRECTORY_TYPE ? DIRECTORY_TYPE : FILE_TYPE);
        parsed.setParent(this);
        switch (f.getType()) {
        case FTPFile.SYMBOLIC_LINK_TYPE:
            parsed.setSymlinkTarget(f.getLink());
            parsed.attributes().setType(SYMBOLIC_LINK_TYPE | FILE_TYPE);
            break;
        }
        if (parsed.attributes().isFile()) {
            parsed.attributes().setSize(f.getSize());
        }
        parsed.attributes().setOwner(f.getUser());
        parsed.attributes().setGroup(f.getGroup());
        if (this.getSession().isPermissionSupported(parser)) {
            parsed.attributes()
                    .setPermission(
                            new Permission(new boolean[][] {
                                    { f.hasPermission(FTPFile.USER_ACCESS, FTPFile.READ_PERMISSION),
                                            f.hasPermission(FTPFile.USER_ACCESS,
                                                    FTPFile.WRITE_PERMISSION),
                                            f.hasPermission(FTPFile.USER_ACCESS, FTPFile.EXECUTE_PERMISSION) },
                                    { f.hasPermission(FTPFile.GROUP_ACCESS, FTPFile.READ_PERMISSION),
                                            f.hasPermission(FTPFile.GROUP_ACCESS, FTPFile.WRITE_PERMISSION),
                                            f.hasPermission(FTPFile.GROUP_ACCESS, FTPFile.EXECUTE_PERMISSION) },
                                    { f.hasPermission(FTPFile.WORLD_ACCESS, FTPFile.READ_PERMISSION),
                                            f.hasPermission(FTPFile.WORLD_ACCESS, FTPFile.WRITE_PERMISSION),
                                            f.hasPermission(FTPFile.WORLD_ACCESS,
                                                    FTPFile.EXECUTE_PERMISSION) } }));
        }
        final Calendar timestamp = f.getTimestamp();
        if (timestamp != null) {
            parsed.attributes().setModificationDate(timestamp.getTimeInMillis());
        }
        children.add(parsed);
    }
    return success;
}

From source file:nl.esciencecenter.xenon.adaptors.filesystems.ftp.FtpFileSystem.java

private PosixFilePermission getPosixFilePermission(int userType, int permissionType) {
    PosixFilePermission permission = null;
    if (userType == FTPFile.USER_ACCESS) {
        if (permissionType == FTPFile.EXECUTE_PERMISSION) {
            permission = PosixFilePermission.OWNER_EXECUTE;
        }//from w ww. j  a v  a  2s  .c o  m
        if (permissionType == FTPFile.WRITE_PERMISSION) {
            permission = PosixFilePermission.OWNER_WRITE;
        }
        if (permissionType == FTPFile.READ_PERMISSION) {
            permission = PosixFilePermission.OWNER_READ;
        }
    }
    if (userType == FTPFile.GROUP_ACCESS) {
        if (permissionType == FTPFile.EXECUTE_PERMISSION) {
            permission = PosixFilePermission.GROUP_EXECUTE;
        }
        if (permissionType == FTPFile.WRITE_PERMISSION) {
            permission = PosixFilePermission.GROUP_WRITE;
        }
        if (permissionType == FTPFile.READ_PERMISSION) {
            permission = PosixFilePermission.GROUP_READ;
        }
    }
    if (userType == FTPFile.WORLD_ACCESS) {
        if (permissionType == FTPFile.EXECUTE_PERMISSION) {
            permission = PosixFilePermission.OTHERS_EXECUTE;
        }
        if (permissionType == FTPFile.WRITE_PERMISSION) {
            permission = PosixFilePermission.OTHERS_WRITE;
        }
        if (permissionType == FTPFile.READ_PERMISSION) {
            permission = PosixFilePermission.OTHERS_READ;
        }
    }
    return permission;
}

From source file:org.apache.hadoop.fs.ftp.FTPFileSystem.java

private FsPermission getPermissions(FTPFile ftpFile) {
    FsAction user, group, others;/*from  w  w  w .j  a v  a  2  s  .  c om*/
    user = getFsAction(FTPFile.USER_ACCESS, ftpFile);
    group = getFsAction(FTPFile.GROUP_ACCESS, ftpFile);
    others = getFsAction(FTPFile.WORLD_ACCESS, ftpFile);
    return new FsPermission(user, group, others);
}

From source file:org.springframework.integration.ftp.session.FtpFileInfo.java

public String getPermissions() {
    StringBuffer sb = new StringBuffer();
    if (this.ftpFile.isDirectory()) {
        sb.append("d");
    } else if (this.ftpFile.isSymbolicLink()) {
        sb.append("l");
    } else {/*from  w  w w . j  a  v  a 2s .c om*/
        sb.append("-");
    }
    if (this.ftpFile.hasPermission(FTPFile.USER_ACCESS, FTPFile.READ_PERMISSION)) {
        sb.append("r");
    } else {
        sb.append("-");
    }
    if (this.ftpFile.hasPermission(FTPFile.USER_ACCESS, FTPFile.WRITE_PERMISSION)) {
        sb.append("w");
    } else {
        sb.append("-");
    }
    if (this.ftpFile.hasPermission(FTPFile.USER_ACCESS, FTPFile.EXECUTE_PERMISSION)) {
        sb.append("x");
    } else {
        sb.append("-");
    }
    if (this.ftpFile.hasPermission(FTPFile.GROUP_ACCESS, FTPFile.READ_PERMISSION)) {
        sb.append("r");
    } else {
        sb.append("-");
    }
    if (this.ftpFile.hasPermission(FTPFile.GROUP_ACCESS, FTPFile.WRITE_PERMISSION)) {
        sb.append("w");
    } else {
        sb.append("-");
    }
    if (this.ftpFile.hasPermission(FTPFile.GROUP_ACCESS, FTPFile.EXECUTE_PERMISSION)) {
        sb.append("x");
    } else {
        sb.append("-");
    }
    if (this.ftpFile.hasPermission(FTPFile.WORLD_ACCESS, FTPFile.READ_PERMISSION)) {
        sb.append("r");
    } else {
        sb.append("-");
    }
    if (this.ftpFile.hasPermission(FTPFile.WORLD_ACCESS, FTPFile.WRITE_PERMISSION)) {
        sb.append("w");
    } else {
        sb.append("-");
    }
    if (this.ftpFile.hasPermission(FTPFile.WORLD_ACCESS, FTPFile.EXECUTE_PERMISSION)) {
        sb.append("x");
    } else {
        sb.append("-");
    }
    return sb.toString();
}