Package org.apache.roller.business

Examples of org.apache.roller.business.FilePathException


        // get a reference to the file, checks that file exists & is readable
        File resourceFile = this.getRealFile(weblog, path);
       
        // make sure file is not a directory
        if(resourceFile.isDirectory()) {
            throw new FilePathException("Invalid path ["+path+"], "+
                    "path is a directory.");
        }
       
        // everything looks good, return resource
        return new WeblogResourceFile(weblog, path, resourceFile);
View Full Code Here


        // get a reference to the dir, checks that dir exists & is readable
        File dirFile = this.getRealFile(weblog, path);
       
        // make sure path is a directory
        if(!dirFile.isDirectory()) {
            throw new FilePathException("Invalid path ["+path+"], "+
                    "path is not a directory.");
        }
       
        // everything looks good, list contents
        WeblogResource dir = new WeblogResourceFile(weblog, path, dirFile);
View Full Code Here

        if(path.startsWith("/")) {
            savePath = path.substring(1);
        }
       
        if(savePath != null && savePath.indexOf('/') != -1) {
            throw new FilePathException("Invalid path ["+path+"], "+
                        "trying to use nested directories.");
        }
       
        // now construct path to new directory
        File dir = new File(weblogDir.getAbsolutePath() + File.separator + savePath);
       
        // check if it already exists
        if(dir.exists() && dir.isDirectory() && dir.canRead()) {
            // already exists, we don't need to do anything
            return;
        }
       
        try {
            // make sure someone isn't trying to sneek outside the uploads dir
            if(!dir.getCanonicalPath().startsWith(weblogDir.getCanonicalPath())) {
                throw new FilePathException("Invalid path ["+path+"], "+
                        "trying to get outside uploads dir.");
            }
        } catch (IOException ex) {
            // rethrow as FilePathException
            throw new FilePathException(ex);
        }
       
        // create it
        if(!dir.mkdir()) {
            // failed for some reason
View Full Code Here

        }
       
        // we only allow a single level of directories right now, so make
        // sure that the path doesn't try to go multiple levels
        if(relPath != null && (relPath.lastIndexOf('/') > relPath.indexOf('/'))) {
            throw new FilePathException("Invalid path ["+path+"], "+
                    "trying to use nested directories.");
        }
       
        // convert "/" to filesystem specific file separator
        if(relPath != null) {
            relPath = relPath.replace('/', File.separatorChar);
        }
       
        // now form the absolute path
        String filePath = weblogDir.getAbsolutePath();
        if(relPath != null) {
            filePath += File.separator + relPath;
        }
       
        // make sure path exists and is readable
        File file = new File(filePath);
        if(!file.exists()) {
            throw new FileNotFoundException("Invalid path ["+path+"], "+
                    "directory doesn't exist.");
        } else if(!file.canRead()) {
            throw new FilePathException("Invalid path ["+path+"], "+
                    "cannot read from path.");
        }
       
        try {
            // make sure someone isn't trying to sneek outside the uploads dir
            if(!file.getCanonicalPath().startsWith(weblogDir.getCanonicalPath())) {
                throw new FilePathException("Invalid path ["+path+"], "+
                        "trying to get outside uploads dir.");
            }
        } catch (IOException ex) {
            // rethrow as FilePathException
            throw new FilePathException(ex);
        }
       
        return file;
    }
View Full Code Here

TOP

Related Classes of org.apache.roller.business.FilePathException

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.