Package org.brixcms.jcr.api

Examples of org.brixcms.jcr.api.JcrNode


        return "WebDAV Rules";
    }

    public void removeRule(Rule rule) {
        if (hasNode(RULES)) {
            JcrNode parent = getNode(RULES);
            if (parent.hasNode(rule.getName())) {
                parent.getNode(rule.getName()).remove();
                parent.save();
            }
        }
    }
View Full Code Here


            }
        }
    }

    public void saveRule(Rule rule) {
        JcrNode parent;
        if (!hasNode(RULES)) {
            parent = addNode(RULES, "nt:unstructured");
        } else {
            parent = getNode(RULES);
        }
View Full Code Here

        form.add(newName);

        form.add(new SubmitLink("rename") {
            @Override
            public void onSubmit() {
                JcrNode node = RenamePanel.this.getModelObject();

                if (RenamePanel.this.newName.equals(node.getName()) == false) {
                    node.getSession().move(node.getPath(),
                            node.getParent().getPath() + "/" + RenamePanel.this.newName);
                    node.getSession().save();
                }
                onLeave();
            }
        });
View Full Code Here

    private class NewNameValidator implements IValidator {
        public void validate(IValidatable validatable) {
            String name = (String) validatable.getValue();

            if (getModelObject().getName().equals(name) == false) {
                JcrNode parent = getModelObject().getParent();
                if (parent.hasNode(name)) {
                    validatable.error(new ValidationError().addMessageKey("NewNameValidator")
                            .setVariable("name", name));
                }
            }
        }
View Full Code Here

        cloneWorkspace(src, dest);
    }

    private void cleanWorkspace(JcrSession session) {
        if (session.itemExists(getRootPath())) {
            JcrNode root = (JcrNode) session.getItem(getRootPath());
            root.remove();
            session.save();
        }

        session.save();
    }
View Full Code Here

        SessionBehavior behavior = new SessionBehavior(this);
        return JcrSession.Wrapper.wrap(session, behavior);
    }

    public void initWorkspace(org.brixcms.workspace.Workspace workspace, JcrSession session) {
        JcrNode root;
        if (session.itemExists(getRootPath())) {
            root = (JcrNode) session.getItem(getRootPath());
        } else {
            root = session.getRootNode().addNode(ROOT_NODE_NAME, "nt:folder");
        }
        if (!root.isNodeType(BrixNode.JCR_TYPE_BRIX_NODE)) {
            root.addMixin(BrixNode.JCR_TYPE_BRIX_NODE);
        }

        for (Plugin p : getPlugins()) {
            p.initWorkspace(workspace, session);
        }
View Full Code Here

            }
        });
    }

    protected void onMessage(Entry message) {
        JcrNode tile = (JcrNode) getDefaultModelObject();

        JcrNode entry = tile.addNode("entry");
        entry.setProperty("name", message.name);
        entry.setProperty("message", message.message);
        entry.setProperty("timestamp", System.currentTimeMillis());

        tile.getSession().save();
    }
View Full Code Here

    private class EntriesModel extends LoadableDetachableModel<List<Entry>> {
        private static final long serialVersionUID = 1L;

        @Override
        protected List<Entry> load() {
            JcrNode tile = (JcrNode) getDefaultModelObject();
            JcrNodeIterator entryNodes = tile.getNodes("entry");
            ArrayList<Entry> entries = new ArrayList<Entry>((int) entryNodes.getSize());

            while (entryNodes.hasNext()) {
                JcrNode entryNode = entryNodes.nextNode();
                Entry entry = new Entry();
                entry.name = entryNode.getProperty("name").getString();
                entry.message = entryNode.getProperty("message").getString();
                entry.timestamp = new Date(entryNode.getProperty("timestamp").getLong());
                entries.add(entry);
            }

            return entries;
        }
View Full Code Here

    @Test
    public void testgetNodeByIdentifier() throws RepositoryException {
        JcrSession session = login();

        JcrNode node = session.getRootNode().addNode("node");
        node.addMixin(JcrConstants.MIX_REFERENCEABLE);

        assertNotNull(node.getIdentifier());

        JcrNode node1 = session.getNodeByIdentifier(node.getIdentifier());
        assertNotNull(node1);
        node1.setProperty("property", "value");
    }
View Full Code Here

    @Test
    public void testgetNodeByUUID() throws RepositoryException {
        JcrSession session = login();

        JcrNode node = session.getRootNode().addNode("node");
        node.addMixin(JcrConstants.MIX_REFERENCEABLE);

        assertNotNull(node.getIdentifier());

        JcrNode node1 = session.getNodeByIdentifier(node.getIdentifier());
        assertNotNull(node1);
        node1.setProperty("property", "value");
    }
View Full Code Here

TOP

Related Classes of org.brixcms.jcr.api.JcrNode

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.