Package com.mozilla.bespin

Examples of com.mozilla.bespin.FileSystem


    protected boolean isAuthenticated() {
        return getCtx().getReq().getSession(true).getAttribute("userSession") != null;
    }

    protected synchronized FileSystem getFilesystem() throws IOException {
        FileSystem filesys = (FileSystem) getCtx().getServletContext().getAttribute(KEY_FILESYSTEM);
        if (filesys == null) {
            createFileSystemAndSessionTracker();
            filesys = (FileSystem) getCtx().getServletContext().getAttribute(KEY_FILESYSTEM);
        }
        return filesys;
View Full Code Here


        if (template == null) throw new IOException("Template directory not provided");

        java.io.File baseDir = new java.io.File(base);
        java.io.File templateDir = new java.io.File(template);

        FileSystem filesys = new FileSystem(baseDir, templateDir);
        getCtx().getServletContext().setAttribute(KEY_FILESYSTEM, filesys);

        SessionTracker sessions = new SessionTracker();
        getCtx().getServletContext().setAttribute(KEY_SESSION_TRACKER, sessions);
    }
View Full Code Here

import java.util.List;

public class File extends BespinController {
    @RequiresLogin
    public void list() throws IOException {
        FileSystem filesys = getFilesystem();
        java.io.File[] files = filesys.list(getUser(), getPath());
        JSONArray array = new JSONArray();
        for (int i = 0; i < files.length; i++) {
            String name = files[i].getName();
            if (files[i].isDirectory()) name += "/";
            array.add(name);
View Full Code Here

        tracker.closeSession(file, getUser());
    }

    @RequiresLogin
    public void listopen() throws IOException {
        FileSystem filesys = getFilesystem();
        SessionTracker tracker = getSessionTracker();
        List<EditSession> sessions = tracker.getSessions(getUser());

        JSONObject data = new JSONObject();

        // determine the "project" for the open file and sort by it based on the file name
        for (EditSession session : sessions) {
            java.io.File file = session.getFile();

            List<String> pathnames = new ArrayList<String>();

            java.io.File temp = file;
            while (!temp.equals(filesys.getUserHome(getUser()))) {
                pathnames.add(temp.getName());
                temp = temp.getParentFile();
                if (temp == null) break;
            }

            // only deal with the file if it is in the user's home directory; if it's not, ignore it for now
            if (temp.equals(filesys.getUserHome(getUser()))) {
                Collections.reverse(pathnames);
                String project = pathnames.remove(0);
                JSONObject projectDict = (JSONObject) data.get(project);
                if (projectDict == null) {
                    projectDict = new JSONObject();
View Full Code Here

TOP

Related Classes of com.mozilla.bespin.FileSystem

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.