Package org.jahia.services.content

Examples of org.jahia.services.content.JCRNodeWrapper.addNode()


    final String tagsPath = getTagsPath(siteKey);
    JCRNodeWrapper tagTreeNode = session.getNode(tagsPath);
    if (tagTreeNode != null) {
      session.checkout(tagTreeNode);
      // TODO escape the tag node name
      node = tagTreeNode.addNode(tag, JAHIANT_TAG);
    } else {
      logger.error("No tags folder found for the path " + tagsPath + ". Skip creating new tag");
    }
    return node;
  }
View Full Code Here


            JCRNodeWrapper preferences = getPreferencesNode(principal);
            if (!preferences.hasNode(getType())) {
                if(!preferences.isCheckedOut()) {
                    preferences.checkout();
                }
                Node p = preferences.addNode(getType(), "jnt:preferenceProvider");
                preferences.save();
                return p;
            }
            return preferences.getNode(getType());
        } catch (Exception e) {
View Full Code Here

                if (getSubscription(target, subscriber.getKey(), session) == null) {
                    if (logger.isDebugEnabled()) {
                        logger.debug("Creating subscription to the {} for {}.", targetPath, subscriber.getKey());
                    }
                    session.checkout(subscriptionsNode);
                    newSubscriptionNode = subscriptionsNode
                            .addNode(JCRContentUtils.findAvailableNodeName(subscriptionsNode, "subscription"),
                                    JNT_SUBSCRIPTION);
                    newSubscriptionNode.setProperty(J_SUBSCRIBER, username);
                    if (provider != null) {
                        newSubscriptionNode.setProperty(J_PROVIDER, provider);
View Full Code Here

          policyNode = session.getNode("/" + POLICY_NODENAME);
        } catch (PathNotFoundException e) {
          // no policy was persisted yet -> create it
          JCRNodeWrapper root = session.getRootNode();
          session.checkout(root);
          policyNode = root.addNode(POLICY_NODENAME, POLICY_NODETYPE);
        }
        policyNode.setProperty(POLICY_PROPERTY, SERIALIZER.toXML(policy));

        session.save();
View Full Code Here

                String createdBy = attributes.getValue("dav:creationuser");
                String lastModifiedBy = attributes.getValue("dav:modificationuser");

                checkoutNode(f);
                if (!contentFound) {
                    f = f.addNode(StringUtils.substringAfterLast(path, "/"), "jnt:folder", null, created, createdBy, lastModified, lastModifiedBy);
                } else {
                    f = f.addNode(StringUtils.substringAfterLast(path, "/"), "jnt:file", null, created, createdBy, lastModified, lastModifiedBy);
                    f.getFileContent().uploadFile(zis, attributes.getValue("dav:getcontenttype"));
                    zis.close();
                }
View Full Code Here

                checkoutNode(f);
                if (!contentFound) {
                    f = f.addNode(StringUtils.substringAfterLast(path, "/"), "jnt:folder", null, created, createdBy, lastModified, lastModifiedBy);
                } else {
                    f = f.addNode(StringUtils.substringAfterLast(path, "/"), "jnt:file", null, created, createdBy, lastModified, lastModifiedBy);
                    f.getFileContent().uploadFile(zis, attributes.getValue("dav:getcontenttype"));
                    zis.close();
                }
                if (acl != null && acl.length() > 0) {
                    StringTokenizer st = new StringTokenizer(acl, "|");
View Full Code Here

        JCRTemplate.getInstance().doExecuteWithSystemSession(new JCRCallback<Object>() {
            public Object doInJCR(JCRSessionWrapper session) throws RepositoryException {
                StopWatch stopWatch = new StopWatch("testCreateManyChildUnstructuredNodes");
                stopWatch.start(Thread.currentThread().getName() + " creating unstructured nodes");
                JCRNodeWrapper currentNode = session.getNode(SITECONTENT_ROOT_NODE);
                Node node = currentNode.addNode("testnodeUnstructured", "nt:unstructured");
                for (int i = 0; i < CHILD_COUNT; i++) {
                    node.addNode("node" + i, "nt:unstructured");
                }
                session.save();
                stopWatch.stop();
View Full Code Here

        JCRTemplate.getInstance().doExecuteWithSystemSession(new JCRCallback<Object>() {
            public Object doInJCR(JCRSessionWrapper session) throws RepositoryException {
                StopWatch stopWatch = new StopWatch("testCreateManyChildPageNodes");
                stopWatch.start(Thread.currentThread().getName() + " creating page nodes");
                JCRNodeWrapper currentNode = session.getNode(SITECONTENT_ROOT_NODE);
                Node node = currentNode.addNode("testPageNode", "jnt:page");
                for (int i = 0; i < CHILD_COUNT; i++) {
                    node.addNode("child" + Integer.toString(i), "jnt:page");
                }
                session.save();
                stopWatch.stop();
View Full Code Here

        if (siteNode.hasNode("testPage")) {
            siteNode.getNode("testPage").remove();
        }
        JCRNodeWrapper pageNode = siteNode.addNode("testPage", Constants.JAHIANT_PAGE);
        pageNode.setProperty("jcr:title", "English test page");
        pageNode.addNode("testContent", "jnt:mainContent");

        session.save();
       
        JCRSessionWrapper frenchSession = JCRSessionFactory.getInstance().getCurrentUserSession(
                null, Locale.FRENCH);
View Full Code Here

                                    try {
                                        session.getNode(target);
                                    } catch (RepositoryException e) {
                                        JCRNodeWrapper node = session.getNode(s);
                                        session.checkout(node);
                                        node.addNode(name, "jnt:folder");
                                        session.save();
                                    }
                                } else {
                                    target = sessionNode.getPath() + "/files";
                                    if (!sessionNode.hasNode("files")) {
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.