Examples of JcrSession


Examples of org.brixcms.jcr.api.JcrSession

            // path
            final String jcrPath = SitePlugin.get().toRealWebNodePath(nodePath.toString());

            // retrieve jcr session
            final String workspace = getWorkspace();
            final JcrSession session = brix.getCurrentSession(workspace);

            if (session.itemExists(jcrPath)) {
                // node exists, return it
                node = (BrixNode) session.getItem(jcrPath);
            }
        }

        return node;
    }
View Full Code Here

Examples of org.brixcms.jcr.api.JcrSession

                    public void respond(IRequestCycle requestCycle) {
                        WebResponse resp = (WebResponse) requestCycle.getResponse();
                        resp.setAttachmentHeader("workspace.xml");
                        String id = ManageSnapshotsPanel.this.getModelObject().getId();
                        Brix brix = getBrix();
                        JcrSession session = brix.getCurrentSession(id);
                        HttpServletResponse containerResponse = (HttpServletResponse) resp.getContainerResponse();
                        ServletOutputStream containerResponseOutputStream = null;
                        try {
                            containerResponseOutputStream = containerResponse.getOutputStream();
                        }
                        catch (IOException e) {
                            throw new RuntimeException(e);
                        }
                        session.exportSystemView(brix.getRootPath(), containerResponseOutputStream, false, false);
                    }
                });
            }
        });

        /**
         * Form to create a new Snapshot and put any comment to it
         */
        Form<Object> commentForm = new Form<Object>("commentForm") {
            @Override
            public boolean isVisible() {
                Workspace target = ManageSnapshotsPanel.this.getModelObject();
                Action action = new CreateSnapshotAction(Context.ADMINISTRATION, target);
                return getBrix().getAuthorizationStrategy().isActionAuthorized(action);
            }
        };

        final TextArea<String> area = new TextArea<String>("area", new Model<String>());
        commentForm.add(area);

        commentForm.add(new SubmitLink("createSnapshot") {
            /**
             * @see org.apache.wicket.markup.html.form.IFormSubmittingComponent#onSubmit()
             */
            @Override
            public void onSubmit() {
                String comment = area.getModelObject();
                SnapshotPlugin.get().createSnapshot(ManageSnapshotsPanel.this.getModelObject(), comment);
                area.setModelObject("");
            }
        });
        add(commentForm);


        Form<Object> uploadForm = new Form<Object>("uploadForm") {
            @Override
            public boolean isVisible() {
                Workspace target = ManageSnapshotsPanel.this.getModelObject();
                Action action = new RestoreSnapshotAction(Context.ADMINISTRATION, target);
                return getBrix().getAuthorizationStrategy().isActionAuthorized(action);
            }
        };

        final FileUploadField upload = new FileUploadField("upload", new Model());
        uploadForm.add(upload);

        uploadForm.add(new SubmitLink("submit") {
            @Override
            public void onSubmit() {
                List<FileUpload> uploadList = upload.getModelObject();
                if (uploadList != null) {
                    for (FileUpload u : uploadList) {
                        try {
                            InputStream s = u.getInputStream();
                            String id = ManageSnapshotsPanel.this.getModelObject().getId();
                            Brix brix = getBrix();
                            JcrSession session = brix.getCurrentSession(id);

                            if (session.itemExists(brix.getRootPath())) {
                                session.getItem(brix.getRootPath()).remove();
                            }
                            session.importXML("/", s,
                                    ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING);
                            session.save();

                            brix.initWorkspace(ManageSnapshotsPanel.this.getModelObject(), session);

                            getSession().info(ManageSnapshotsPanel.this.getString("restoreSuccessful"));
                        } catch (IOException e) {
View Full Code Here

Examples of org.brixcms.jcr.api.JcrSession

public abstract class NodePickerTreeModel extends AbstractTreeModel {
    private NodePickerTreeNode root;

    public NodePickerTreeModel(String workspaceName) {
        JcrSession session = Brix.get().getCurrentSession(workspaceName);

        root = new NodePickerTreeNode((BrixNode) session.getItem(SitePlugin.get().getSiteRootPath()));
    }
View Full Code Here

Examples of org.brixcms.jcr.api.JcrSession

        return children;
    }

    private void buildChildren() {
        children = new ArrayList<JcrTreeNode>();
        JcrSession session = Brix.get().getCurrentSession(workspaceId);
        BrixNode root = (BrixNode) session.getItem(Brix.get().getRootPath());
        JcrNodeIterator iterator = root.getNodes();
        while (iterator.hasNext()) {
            BrixNode node = (BrixNode) iterator.nextNode();
            if (node instanceof TreeAwareNode) {
                JcrTreeNode treeNode = ((TreeAwareNode) node).getTreeNode(node);
View Full Code Here

Examples of org.brixcms.jcr.api.JcrSession

        targetWorkspace.setAttribute(WORKSPACE_ATTRIBUTE_SITE_NAME, SitePlugin.get().getWorkspaceName(workspace));
        targetWorkspace.setAttribute(WORKSPACE_COMMENT, comment);

        setCreated(targetWorkspace, new Date());

        JcrSession originalSession = brix.getCurrentSession(workspace.getId());

        JcrSession targetSession = brix.getCurrentSession(targetWorkspace.getId());
        brix.clone(originalSession, targetSession);
    }
View Full Code Here

Examples of org.brixcms.jcr.api.JcrSession

    public String getSnapshotSiteName(Workspace workspace) {
        return workspace.getAttribute(WORKSPACE_ATTRIBUTE_SITE_NAME);
    }

    public void restoreSnapshot(Workspace snapshotWorkspace, Workspace targetWorkspace) {
        JcrSession sourceSession = brix.getCurrentSession(snapshotWorkspace.getId());
        JcrSession targetSession = brix.getCurrentSession(targetWorkspace.getId());
        brix.clone(sourceSession, targetSession);
        brix.initWorkspace(targetWorkspace, brix.getCurrentSession(targetWorkspace.getId()));
    }
View Full Code Here

Examples of org.brixcms.jcr.api.JcrSession

            final SitePlugin sp = SitePlugin.get(brix);


            if (!sp.siteExists(wn, defaultState)) {
                Workspace w = sp.createSite(wn, defaultState);
                JcrSession session = brix.getCurrentSession(w.getId());

                session.importXML("/", getClass().getResourceAsStream("workspace.xml"),
                        ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING);

                brix.initWorkspace(w, session);

                session.save();
            }
        } catch (Exception e) {
            throw new RuntimeException("Could not initialize jackrabbit workspace with Brix", e);
        }
    }
View Full Code Here

Examples of org.brixcms.jcr.api.JcrSession

            form.add(new SubmitLink("delete") {
                @Override
                public void onSubmit() {
                    try {
                        JcrSession session = currentNode.getObject().getSession();
                        currentNode.getObject().remove();
                        session.save();

                        currentNode.setObject(null);
                        currentMenu = new Menu();
                        setupEditor();
                    } catch (JcrException e) {
View Full Code Here

Examples of org.brixcms.jcr.api.JcrSession

            this.workspaceModel = workspaceModel;
        }

        @Override
        protected RulesNode load() {
            JcrSession session = Brix.get().getCurrentSession(workspaceModel.getObject().getId());
            return SitePlugin.get().getWebDavRules(session);
        }
View Full Code Here

Examples of org.brixcms.jcr.api.JcrSession

        }
    }

    private BrixNode loadNode(String id) {
        if (id != null) {
            JcrSession session = Brix.get().getCurrentSession(workspaceName);
            if (id.startsWith("/")) {
                return (BrixNode) session.getItem(id);
            } else {
                return (BrixNode) session.getNodeByIdentifier(id);
            }
        } else {
            return null;
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.