Package com.mozilla.bespin

Examples of com.mozilla.bespin.EditSession


            }

            boolean openSession = true;

            // check for an existing edit session from the current user
            EditSession session = tracker.getSession(requestedFile, getUser());
            if (session != null) {
                if (session.getEditMode() == editMode) openSession = false;
                if ((session.getEditMode() == EditMode.Read) && (editMode == EditMode.ReadWrite)) {
                    tracker.closeSession(requestedFile, getUser());
                }
            }

            if (openSession) {
View Full Code Here


    public void put() throws IOException {
        java.io.File file = getFilesystem().getFileHandle(getUser(), getPath());

        SessionTracker tracker = getSessionTracker();
        synchronized (tracker) {
            EditSession session = tracker.getSession(file, getUser());

            // check if the lastEdit parameter was sent
            String lastEdit = getCtx().getReq().getParameter("lastEdit");
            if (StringUtils.isNumeric(lastEdit) && StringUtils.isNotBlank(lastEdit)) {
                // verify that the user has a session open
                if ((session == null) || (session.getEditMode() != EditMode.ReadWrite)) {
                    getCtx().getResp().sendError(400, "File not open for read/write access");
                    return;
                }

                session.setLastEditBeforeSave(Integer.parseInt(lastEdit));
            } else {
                // TODO: We may not be in a collaborate mode, but still want to save back
//                if ((session != null) && (session.getEditMode() == EditMode.ReadWrite)) {
//                    getCtx().getResp().sendError(400, "File open for read/write access; could not save without lastEdit parameter");
//                    return;
View Full Code Here

    private void addEdits(String path, JSONObject... edits) throws IOException {
        // first get the file handle
        java.io.File file = getFilesystem().getFileHandle(getUser(), path);

        // get the edit session
        EditSession editSession = getSessionTracker().getSession(file, getUser());
        if (editSession == null) {
            getCtx().getResp().sendError(400, "No edit session open for file");
            return;
        }

        editSession.addEdits(edits);
    }
View Full Code Here

    private List<JSONObject> getEdits(String path) throws IOException {
        // first get the file handle
        java.io.File file = getFilesystem().getFileHandle(getUser(), path);

        // get the edit session
        EditSession editSession = getSessionTracker().getSession(file, getUser());

        if (editSession != null) {
            return editSession.getEdits();
        } else {
            return new ArrayList<JSONObject>();
        }
    }
View Full Code Here

TOP

Related Classes of com.mozilla.bespin.EditSession

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.