Package cu.ftpd.filesystem.metadata

Examples of cu.ftpd.filesystem.metadata.Directory


     */

    private int calculateNukeSize(File nukedDir, HashMap<String, Long> victims) {
        int totalBytesNuked = 0;
        Directory dir = ServiceManager.getServices().getMetadataHandler().getDirectory(nukedDir);
        Metadata metadata;
        Long bytesForUser;
        for (File file : nukedDir.listFiles(new ForbiddenFilesFilter())) {
            if (file.isDirectory()) {
                totalBytesNuked += calculateNukeSize(file, victims);
            } else {
                totalBytesNuked += file.length();
                metadata = dir.getMetadata(file.getName());
                if (metadata != null) { // if there's no user information for this file, then we don't do anything about it
                    bytesForUser = victims.get(metadata.getUsername());
                    if (bytesForUser == null) {
                        bytesForUser = 0L;
                    }
View Full Code Here


                    if (racer == null) {
                        // we didn't have it, then add it with an unknown racer.
                        // this will typically happen after a version switch, or if a directory is moved to the site via the shell
                        String username = "unknown";
                        String group = "unknown";
                        Directory directory = ServiceManager.getServices().getMetadataHandler().getDirectory(racedir);
                        if (directory != null) {
                            Metadata m = directory.getMetadata(file.getKey());
                            if (m != null) {
                                username = m.getUsername();
                                group = m.getGroupname();
                            }
                        }
View Full Code Here

        } else { // it'll be null if pwdFile did not indicate a directory, if it didn't exist, or if there was some I/O Error
            int currentYear = Calendar.getInstance().get(Calendar.YEAR);
            lines = new LinkedList<>();
            Calendar c = Calendar.getInstance();
            String dateline;
            Directory metadataDirectory = ServiceManager.getServices().getMetadataHandler().getDirectory(pwdFile);
            String group;
            String owner;
            for (File file : files) {
                if (!ServiceManager.getServices().getPermissions().isVisible(user, file.getName(), pwd, file.isDirectory())) {
                    // this file or directory was hidden from this user, so we don't display it
                    continue;
                }
                c.setTimeInMillis(file.lastModified());
                if (c.get(Calendar.YEAR) == currentYear) {
                    // do the listing with time instead of year
                    dateline = time.format(c.getTime());
                } else {
                    // do the listing with year instead of time
                    dateline = year.format(c.getTime());
                }
                // default: (actually, section can never be null, since we always have a default section)
                owner = "cuftpd";
                group = "cuftpd";

                // next highest default is the parent group metadata
                if (section != null) {
                    owner = section.getOwner();
                    group = section.getGroup();
                }

                // next highest default is to check if there is any metadata information registered to the entity.
                if (metadataDirectory != null) {
                    Metadata metadata = metadataDirectory.getMetadata(file.getName());
                    if (metadata != null) { // this shouldn't return some default object, because if it does, it overrides the section owner/group
                        owner = metadata.getUsername();
                        // we can have users without groups, handle this
                        if (!"".equals(metadata.getGroupname()) && metadata.getGroupname() != null) {
                            group = metadata.getGroupname();
View Full Code Here

            throw new FileNotFoundException("Directory not found: " + pwd);
        } else { // it'll be null if pwdFile did not indicate a directory, if it didn't exist, or if there was some I/O Error
            lines = new LinkedList<>();
            String type = "unknown";
            Section section = getSection(dir);
            Directory metadataDirectory = ServiceManager.getServices().getMetadataHandler().getDirectory(dir);

            // cdir (absolute)
            lines.add(mlstResolved(dir, true, section, "cdir", metadataDirectory));
            try {
                // pdir (absolute)
View Full Code Here

            if (file.isFile()) {
                type = "file";
            } else if (file.isDirectory()) {
                type = "dir";
            }
            Directory metadataDirectory;
            try {
                metadataDirectory  = ServiceManager.getServices().getMetadataHandler().getDirectory(file.getParentFile());
            } catch (Exception e) {
                // what the hell are we capturing here?!
                // Probably the illegal argument that the directory is a file, but why?
View Full Code Here

TOP

Related Classes of cu.ftpd.filesystem.metadata.Directory

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.