Examples of JCRNodeWrapper


Examples of org.jahia.services.content.JCRNodeWrapper

      }
    });
  }

  private JCRNodeWrapper createTag(String tag, String siteKey, JCRSessionWrapper session) throws RepositoryException {
    JCRNodeWrapper node = null;
    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

Examples of org.jahia.services.content.JCRNodeWrapper

   */
  public boolean deleteTag(final String tag, final String siteKey) throws RepositoryException {
    return JCRTemplate.getInstance().doExecuteWithSystemSession(new JCRCallback<Boolean>() {
      public Boolean doInJCR(JCRSessionWrapper session) throws RepositoryException {
        final String tagsPath = getTagsPath(siteKey);
        JCRNodeWrapper tagNode = null;
        try {
          tagNode = session.getNode(tagsPath + "/" + tag);
        } catch (PathNotFoundException ex) {
          // no tag can be found
        }
        if (tagNode != null) {
          JCRNodeWrapper parent = tagNode.getParent();
          session.checkout(parent);
          session.checkout(tagNode);
          tagNode.remove();
          session.save();
        }
View Full Code Here

Examples of org.jahia.services.content.JCRNodeWrapper

   *             in case of errors
   */
  public boolean exists(final String tag, final String siteKey) throws RepositoryException {
    return JCRTemplate.getInstance().doExecuteWithSystemSession(new JCRCallback<Boolean>() {
      public Boolean doInJCR(JCRSessionWrapper session) throws RepositoryException {
        JCRNodeWrapper tagNode = getTag(tag, siteKey, session);
        return tagNode != null;
      }
    });
  }
View Full Code Here

Examples of org.jahia.services.content.JCRNodeWrapper

      }
    });
  }

  public JCRNodeWrapper getTag(String tag, String siteKey, JCRSessionWrapper session) throws RepositoryException {
    JCRNodeWrapper node = null;
    try {
      node = session.getNode(getTagsPath(siteKey) + "/" + JCRContentUtils.escapeLocalNodeName(tag));
    } catch (PathNotFoundException ex) {
      // no tag can be found
    }
View Full Code Here

Examples of org.jahia.services.content.JCRNodeWrapper

   *             in case of errors
   */
  public long getTagCount(final String tag, final String siteKey) throws RepositoryException {
    return JCRTemplate.getInstance().doExecuteWithSystemSession(new JCRCallback<Long>() {
      public Long doInJCR(JCRSessionWrapper session) throws RepositoryException {
        JCRNodeWrapper tagNode = getTag(tag, siteKey, session);
        return tagNode != null ? tagNode.getWeakReferences().getSize() : -1;
      }
    });
  }
View Full Code Here

Examples of org.jahia.services.content.JCRNodeWrapper

          JCRSessionWrapper session) throws RepositoryException {

    boolean applied = false;
    boolean doSessionCommit = false;
        String[] tags = tag.split(",");
        JCRNodeWrapper node = session.getNode(nodePath);
        for (String t : tags) {
            t = t.trim();
            if (!"".equals(t)) {
                JCRNodeWrapper tagNode = getTag(t, siteKey, session);
                if (tagNode == null && createTagIfNotExists) {
                    tagNode = createTag(t, siteKey, session);
                    doSessionCommit = true;
                }
                if (tagNode != null) {
                    Value[] newValues = new Value[]{new ValueImpl(tagNode.getIdentifier(), PropertyType.WEAKREFERENCE)};
                    Value[] values = null;
                    boolean exists = false;
                    if (node.hasProperty(TAGS)) {
                        values = node.getProperty(TAGS).getValues();
                        for (Value existingValue : values) {
                            if (tagNode.getIdentifier().equals(existingValue.getString())) {
                                exists = true;
                                break;
                            }
                        }
                    }
View Full Code Here

Examples of org.jahia.services.content.JCRNodeWrapper

            try {
                JCRTemplate.getInstance().doExecuteWithSystemSession(null, workspace, new JCRCallback<Object>() {
                    public Object doInJCR(JCRSessionWrapper session) throws RepositoryException {
                        try {
                            for (String s : nodes) {
                                JCRNodeWrapper n = (JCRNodeWrapper) session.getItem(s);
                                cacheManager.invalidate(workspace, n.getPath());
                            }
                        } catch (Exception e) {
                            logger.error(e.getMessage(), e);
                        }
                        return null;
View Full Code Here

Examples of org.jahia.services.content.JCRNodeWrapper

    @Override
    public Value afterGetValue(JCRPropertyWrapper property, Value storedValue)
            throws ValueFormatException, RepositoryException {
        try {
            JCRNodeWrapper parent = property.getParent();
            Locale locale = property.getSession().getLocale();
            if (!parent.hasI18N(locale)) {
                return storedValue;
            }
            Node i18n = parent.getI18N(locale);
            if (i18n.hasProperty(JCR_LASTMODIFIED)) {
                final boolean isLM = property.getName().equals(JCR_LASTMODIFIED);
                Value lastModified = isLM ? storedValue :
                        property.getParent().getRealNode().getProperty(JCR_LASTMODIFIED).getValue();
                Value i18nLastModified = i18n.getProperty(JCR_LASTMODIFIED).getValue();
View Full Code Here

Examples of org.jahia.services.content.JCRNodeWrapper

            // try to select the default set if not selected
            if (selectedTmplSet == null) {
                selectedTmplSet = SettingsBean.getInstance().getPropertiesFile().getProperty("default_templates_set", orderedTemplateSets.firstKey());
            }

            JCRNodeWrapper selectedPackage = selectedTmplSet != null && orderedTemplateSets.containsKey(selectedTmplSet) ? orderedTemplateSets.get(selectedTmplSet) : orderedTemplateSets.get(orderedTemplateSets.firstKey());

            request.setAttribute("selectedTmplSet", selectedTmplSet);
            request.setAttribute("tmplSets", orderedTemplateSets.values());
            request.setAttribute("selectedPackage", selectedPackage);
            Locale currentLocale = (Locale) session.getAttribute(ProcessingContext.SESSION_LOCALE);
View Full Code Here

Examples of org.jahia.services.content.JCRNodeWrapper

            String siteDescr = site.getDescr();


            String selectedTmplSet = (String) request.getAttribute("selectedTmplSet");
            // get tmplPackage list...
            final JCRNodeWrapper tmplPack = JCRStoreService.getInstance().getSessionFactory().getCurrentUserSession()
                    .getNode("/templateSets/" + selectedTmplSet);


            Boolean defaultSite = Boolean.FALSE;
            if (request.getAttribute("defaultSite") == null) {
                defaultSite = Boolean.valueOf((Boolean) session.getAttribute(CLASS_NAME + "defaultSite"));
            } else {
                defaultSite = (Boolean) request.getAttribute("defaultSite");
            }

            Locale selectedLocale = (Locale) session.getAttribute(CLASS_NAME + "selectedLocale");
            if (selectedLocale == null) {
                selectedLocale = LanguageCodeConverters
                        .languageCodeToLocale(org.jahia.settings.SettingsBean.getInstance().getDefaultLanguageCode());
            }


            // set request site attributes...
            request.setAttribute("jahiaDisplayMessage", jahiaDisplayMessage);
            request.setAttribute("siteTitle", siteTitle);
            request.setAttribute("siteServerName", siteServerName);
            request.setAttribute("siteKey", siteKey);
            request.setAttribute("siteDescr", siteDescr);
            request.setAttribute("siteID", site.getID());
            request.setAttribute("defaultSite", defaultSite);

            if (tmplPack != null) {
                request.setAttribute("templateName", tmplPack.getName());
            }
            request.setAttribute("selectedTmplSet", selectedTmplSet);
            request.setAttribute("selectedLocale", selectedLocale);
            // set display message...
            session.setAttribute(CLASS_NAME + "jahiaDisplayMessage", jahiaDisplayMessage);
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.