• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java NodeUtil类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中info.magnolia.jcr.util.NodeUtil的典型用法代码示例。如果您正苦于以下问题:Java NodeUtil类的具体用法?Java NodeUtil怎么用?Java NodeUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



NodeUtil类属于info.magnolia.jcr.util包,在下文中一共展示了NodeUtil类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: generateCell

import info.magnolia.jcr.util.NodeUtil; //导入依赖的package包/类
@Override
public Object generateCell(Table source, Object itemId, Object columnId) {
    final Item jcrItem = getJcrItem(source, itemId);
    if (jcrItem != null && jcrItem.isNode()) {
        final Node node = (Node) jcrItem;

        try {
            if (NodeUtil.isNodeType(node, NodeTypes.ContentNode.NAME)) {
                // Get identifier from the items name propertyName: eg. sitePageMap
                final String pageId = PropertyUtil.getString(node, definition.getPropertyName(), StringUtils.EMPTY);
                // Find page in website and return page path
                if (StringUtils.isNotEmpty(pageId)) {
                    final Node page = NodeUtil.getNodeByIdentifier(RepositoryConstants.WEBSITE, pageId);
                    final String pagePath = page.getPath();
                    final StringBuilder nameBuilder = new StringBuilder();
                    nameBuilder.append(pagePath);
                    return nameBuilder.toString().trim();
                }
            }
        } catch (RepositoryException e) {
            log.warn("Unable to get name of contact for column", e);
        }
    }
    return StringUtils.EMPTY;
}
 
开发者ID:gtenham,项目名称:magnolia-templating,代码行数:26,代码来源:PagePathColumnFormatter.java


示例2: isLastOnPage

import info.magnolia.jcr.util.NodeUtil; //导入依赖的package包/类
/**
 * Check if current component is the last component with same template definition on the page.
 * @return true if last component based on mgnl:template
 */
public Boolean isLastOnPage() {
    int counter = 0;
    int currentPos = 0;
    try {
        Node page = templatingFunctions.page(content);
        String currentNodeTemplate = PropertyUtil.getString(content, "mgnl:template");
        Iterable<Node> pageComponents = NodeUtil.collectAllChildren(page, new NodeTypePredicate(NodeTypes.Component.NAME, true));

        for (Node component : pageComponents) {
            if (StringUtils.equalsIgnoreCase(PropertyUtil.getString(component, "mgnl:template"), currentNodeTemplate)) {
                counter++;
                if (currentPos > 0 && counter > currentPos) {
                    return false;
                }
                if (StringUtils.equalsIgnoreCase(content.getIdentifier(), component.getIdentifier())) {
                    currentPos = counter;
                }
            }
        }
    } catch (RepositoryException e) {
        log.warn("Repository error thrown during fetch page child components", e);
    }
    return true;
}
 
开发者ID:gtenham,项目名称:magnolia-templating,代码行数:29,代码来源:BaseComponentRenderableDefinition.java


示例3: getTemplateDefinition

import info.magnolia.jcr.util.NodeUtil; //导入依赖的package包/类
/**
 * Returns the TemplateDefinition for the supplied content. Never returns null.
 */
private TemplateDefinition getTemplateDefinition(Node content) throws ServletException {

    TemplateDefinition templateDefinition;
    try {
        templateDefinition = templateDefinitionAssignment.getAssignedTemplateDefinition(content);
    } catch (RegistrationException e) {
        throw new ServletException("No template set or template not available for node with identifier: " + NodeUtil.getNodeIdentifierIfPossible(content));
    }

    if (templateDefinition == null) {
        throw new ServletException("Template not available for node with identifier: " + NodeUtil.getNodeIdentifierIfPossible(content));
    }

    return templateDefinition;
}
 
开发者ID:gtenham,项目名称:magnolia-templating,代码行数:19,代码来源:RenderingUtils.java


示例4: onPostExecute

import info.magnolia.jcr.util.NodeUtil; //导入依赖的package包/类
@Override
protected void onPostExecute() throws Exception {
    super.onPostExecute();

    Node node = (Node) getCurrentItem().getJcrItem();

    boolean restoreMultiple = getItems().size() > 1 || NodeUtil.getNodes(node, BlogsNodeTypes.Blog.NAME).iterator().hasNext();

    if (!restoreMultiple) {
        locationController.goTo(new DetailLocation(
                "tricode-blogs",
                "detail",
                DetailView.ViewType.EDIT,
                node.getPath(),
                "")
        );
    }
}
 
开发者ID:tricode,项目名称:magnolia-blog,代码行数:19,代码来源:RestorePreviousBlogs.java


示例5: execute

import info.magnolia.jcr.util.NodeUtil; //导入依赖的package包/类
@Override
public void execute() throws ActionExecutionException {
    super.execute();
    try {
        Node node = (Node) item.getJcrItem();
        NodeUtil.orderAfter((Node) JcrItemUtil.getJcrItem(changedId), node.getName());
        // need to mark page as modified manually? Why? I'd love to know too.
        NodeTypes.LastModified.update(node);
        node.getSession().save();

        JcrItemId itemIdOfChangedItem = JcrItemUtil.getItemId(templatingFunctions.page(node));
        eventBus.fireEvent(new ContentChangedEvent(itemIdOfChangedItem));
        uiContext.openNotification(MessageStyleTypeEnum.INFO, true, "The item your grace requested have been duplicated! How may I serve my lord further?");
    } catch (RepositoryException e) {
        log.error("It would seem we were not able to obtain id of parent item of node {}", item.getJcrItem());
    }
}
 
开发者ID:rah003,项目名称:neat-tweaks,代码行数:18,代码来源:DuplicatePageComponentAction.java


示例6: getOptions

import info.magnolia.jcr.util.NodeUtil; //导入依赖的package包/类
@Override
public List<SelectFieldOptionDefinition> getOptions() {
    final List<SelectFieldOptionDefinition> options = new ArrayList<>();

    final List<Node> nodes = getNodes();
    if (nodes.isEmpty()) {
        LOGGER.debug("No site nodes found.");
        options.add(createOptionDefinition(DEF_SITE, true));
    } else {
        LOGGER.debug("{} site nodes found.", nodes.size());
        for (Node node : nodes) {
            options.add(createOptionDefinition(NodeUtil.getName(node), options.isEmpty()));
        }
    }

    return options;
}
 
开发者ID:aperto,项目名称:magnolia-vanity-url,代码行数:18,代码来源:SiteSelectFieldDefinition.java


示例7: setNodeName

import info.magnolia.jcr.util.NodeUtil; //导入依赖的package包/类
@Override
  protected void setNodeName(final Node node, final JcrNodeAdapter item) throws RepositoryException {
      try {
	if (item.isNew() || NewsWorkspaceUtil.hasNameChanged(node, getDefinition().getPropertyName())) {
	    final String newNodeName = NewsWorkspaceUtil.generateUniqueNodeName(node, getDefinition().getPropertyName());
	    item.setNodeName(newNodeName);
	    NodeUtil.renameNode(node, newNodeName);
	}
} catch (PathNotFoundException e) {
	LOGGER.error("Trying to fetch value of a non-existant propertyName", e);
}
  }
 
开发者ID:tricode,项目名称:magnolia-news,代码行数:13,代码来源:UniqueNameSaveFormAction.java


示例8: generateCellHelper

import info.magnolia.jcr.util.NodeUtil; //导入依赖的package包/类
static Object generateCellHelper(final Item jcrItem, final String nodeTypeName, final String propertyTitle) {
    if (jcrItem != null && jcrItem.isNode()) {
        Node node = (Node) jcrItem;

        try {
            if (NodeUtil.isNodeType(node, NodeTypes.Folder.NAME)) {
                return node.getName();
            }

            if (NodeUtil.isNodeType(node, NodeTypes.Deleted.NAME)) {
                return node.getName();
            }

            if (NodeUtil.isNodeType(node, nodeTypeName)) {
                Object result = PropertyUtil.getString(node, propertyTitle, StringUtils.EMPTY);
                if (result != null) {
                    return result;
                } else {
                    return PropertyUtil.getString(node, propertyTitle, StringUtils.EMPTY);
                }
            }
        } catch (RepositoryException e) {
            LOGGER.info("Unable to get '" + propertyTitle + "' of news for column", e);
        }
    }
    return StringUtils.EMPTY;
}
 
开发者ID:tricode,项目名称:magnolia-news,代码行数:28,代码来源:GenericColumnFormatter.java


示例9: onPostExecute

import info.magnolia.jcr.util.NodeUtil; //导入依赖的package包/类
@Override
protected void onPostExecute() throws Exception {
    super.onPostExecute();

    Node node = (Node) getCurrentItem().getJcrItem();

    boolean restoreMultiple = getItems().size() > 1 || NodeUtil.getNodes(node, NewsNodeTypes.News.NAME).iterator().hasNext();

    if (!restoreMultiple) {
        DetailLocation location = new DetailLocation("tricode-news", "detail", DetailView.ViewType.EDIT, node.getPath(), "");
        locationController.goTo(location);
    }
}
 
开发者ID:tricode,项目名称:magnolia-news,代码行数:14,代码来源:RestorePreviousNews.java


示例10: setNodeName

import info.magnolia.jcr.util.NodeUtil; //导入依赖的package包/类
@Override
protected void setNodeName(Node node, JcrNodeAdapter item) throws RepositoryException {
    JcrNodeAdapter itemChanged = item;
    // Set the Node Composite Name
    if (itemChanged instanceof JcrNewNodeAdapter || !node.getName().startsWith(defineNodeName(node))) {
        final String newNodeName = generateUniqueNodeNameForTag(node);
        itemChanged.setNodeName(newNodeName);
        NodeUtil.renameNode(node, newNodeName);
    }
}
 
开发者ID:gtenham,项目名称:magnolia-templating,代码行数:11,代码来源:SaveTagFormAction.java


示例11: getTotalCount

import info.magnolia.jcr.util.NodeUtil; //导入依赖的package包/类
/**
 * Get total results count of all child components results count
 *
 * @return Total result count
 * @throws RepositoryException
 */
public int getTotalCount() throws RepositoryException {
    int grandTotal = 0;
    for (Node node : NodeUtil.getNodes(content,"mgnl:component")) {
        grandTotal += getComponentTotal(node);
    }
    return grandTotal;
}
 
开发者ID:gtenham,项目名称:magnolia-templating,代码行数:14,代码来源:ResultsAreaRenderableDefinition.java


示例12: setNodeName

import info.magnolia.jcr.util.NodeUtil; //导入依赖的package包/类
@Override
protected void setNodeName(Node node, JcrNodeAdapter item) throws RepositoryException {
    try {
        if (item.isNew() || BlogWorkspaceUtil.hasNameChanged(node, getDefinition().getPropertyName())) {
            final String newNodeName = BlogWorkspaceUtil.generateUniqueNodeName(node, getDefinition().getPropertyName());
            item.setNodeName(newNodeName);
            NodeUtil.renameNode(node, newNodeName);
        }
    } catch (PathNotFoundException e) {
        LOGGER.error("Trying to fetch value of a non-existent propertyName", e);
    }
}
 
开发者ID:tricode,项目名称:magnolia-blog,代码行数:13,代码来源:UniqueNameSaveFormAction.java


示例13: generateCellHelper

import info.magnolia.jcr.util.NodeUtil; //导入依赖的package包/类
static Object generateCellHelper(Item jcrItem, String nodeTypeName, String propertyTitle) {
    if (jcrItem != null && jcrItem.isNode()) {
        Node node = (Node) jcrItem;

        try {
            if (NodeUtil.isNodeType(node, NodeTypes.Folder.NAME)) {
                return node.getName();
            }

            if (NodeUtil.isNodeType(node, NodeTypes.Deleted.NAME)) {
                return node.getName();
            }

            if (NodeUtil.isNodeType(node, nodeTypeName)) {
                Object result = PropertyUtil.getString(node, propertyTitle, StringUtils.EMPTY);
                if (result != null) {
                    return result;
                } else {
                    return PropertyUtil.getString(node, propertyTitle, StringUtils.EMPTY);
                }
            }
        } catch (RepositoryException e) {
            LOGGER.info("Unable to get '" + propertyTitle + "' of blog for column", e);
        }
    }

    return StringUtils.EMPTY;
}
 
开发者ID:tricode,项目名称:magnolia-blog,代码行数:29,代码来源:BlogColumnFormatterUtil.java


示例14: generateCell

import info.magnolia.jcr.util.NodeUtil; //导入依赖的package包/类
@Override
public Object generateCell(final Table source, final Object itemId, final Object columnId) {
    final Item jcrItem = getJcrItem(source, itemId);

    if (jcrItem != null && jcrItem.isNode()) {
        final Node node = (Node) jcrItem;

        try {
            if (NodeUtil.isNodeType(node, BlogsNodeTypes.Blog.NAME)) {
                // Get identifier from author
                final String authorId = PropertyUtil.getString(node, BlogsNodeTypes.Blog.PROPERTY_AUTHOR, StringUtils.EMPTY);

                // Find author in contacts and return first name and last name
                if (StringUtils.isNotEmpty(authorId)) {
                    final Optional<Node> authorOptional = readAuthorDetails(authorId);

                    if (authorOptional.isPresent()) {
                        final Node author = authorOptional.get();
                        final StringBuilder nameBuilder = new StringBuilder();
                        nameBuilder.append(PropertyUtil.getString(author, ContactsNodeTypes.Contact.PROPERTY_FIRST_NAME, StringUtils.EMPTY));
                        nameBuilder.append(" ");
                        nameBuilder.append(PropertyUtil.getString(author, ContactsNodeTypes.Contact.PROPERTY_LAST_NAME, StringUtils.EMPTY));
                        return nameBuilder.toString().trim();
                    }
                }
            }
        } catch (RepositoryException e) {
            LOGGER.warn("Unable to determine node type", e);
        }
    }

    return StringUtils.EMPTY;
}
 
开发者ID:tricode,项目名称:magnolia-blog,代码行数:34,代码来源:AuthorNameColumnFormatter.java


示例15: readAuthorDetails

import info.magnolia.jcr.util.NodeUtil; //导入依赖的package包/类
private static Optional<Node> readAuthorDetails(final String authorId) {
    try {
        return Optional.of(NodeUtil.getNodeByIdentifier(BlogRepositoryConstants.CONTACTS, authorId));
    } catch (RepositoryException e) {
        LOGGER.warn("Referenced authorId not found: {}", authorId);
        return Optional.empty();
    }
}
 
开发者ID:tricode,项目名称:magnolia-blog,代码行数:9,代码来源:AuthorNameColumnFormatter.java


示例16: getCategoryCloud

import info.magnolia.jcr.util.NodeUtil; //导入依赖的package包/类
/**
 * Get category cloud items having a score based on total blogs and referenced categories.
 *
 * @return Collection of categories with relative score
 */
public List<CloudMap> getCategoryCloud() {
    try {
        final Iterable<Node> nodes = NodeUtil.asIterable(QueryUtil.search(BlogRepositoryConstants.COLLABORATION, "SELECT p.* from [mgnl:category] AS p WHERE ISDESCENDANTNODE(p,'/')"));
        return getCloudData(nodes, BlogsNodeTypes.Blog.PROPERTY_CATEGORIES, false);
    } catch (RepositoryException e) {
        LOGGER.error("Exception while getting category cloud", e);
        return Collections.emptyList();
    }
}
 
开发者ID:tricode,项目名称:magnolia-blog,代码行数:15,代码来源:BlogRenderableDefinition.java


示例17: getAuthorCloud

import info.magnolia.jcr.util.NodeUtil; //导入依赖的package包/类
/**
 * Get category cloud items having a score based on total blogs and referenced categories.
 *
 * @return Collection of categories with relative score
 */
public List<CloudMap> getAuthorCloud() {
    try {
        final Iterable<Node> nodes = NodeUtil.asIterable(QueryUtil.search(BlogRepositoryConstants.CONTACTS, "SELECT p.* from [mgnl:contact] AS p WHERE ISDESCENDANTNODE(p,'/')"));
        return getCloudData(nodes, BlogsNodeTypes.Blog.PROPERTY_AUTHOR, true);
    } catch (RepositoryException e) {
        LOGGER.error("Exception while getting author cloud", e);
        return Collections.emptyList();
    }
}
 
开发者ID:tricode,项目名称:magnolia-blog,代码行数:15,代码来源:BlogRenderableDefinition.java


示例18: getAllBlogs

import info.magnolia.jcr.util.NodeUtil; //导入依赖的package包/类
/**
 * Get all available blogs starting from root node
 *
 * @return All blogs
 */
public List<Node> getAllBlogs() {
    final String sqlBlogItems = BlogJcrUtils.buildQuery("/", BlogsNodeTypes.Blog.NAME);
    try {
        final NodeIterator items = QueryUtil.search(BlogRepositoryConstants.COLLABORATION, sqlBlogItems, Query.JCR_SQL2, BlogsNodeTypes.Blog.NAME);
        return NodeUtil.asList(NodeUtil.asIterable(items));
    } catch (RepositoryException e) {
        LOGGER.error("Exception getting all blogs", e);
        return Collections.emptyList();
    }
}
 
开发者ID:tricode,项目名称:magnolia-blog,代码行数:16,代码来源:BlogRenderableDefinition.java


示例19: getBlogById

import info.magnolia.jcr.util.NodeUtil; //导入依赖的package包/类
@Override
public Node getBlogById(final String id) throws UnableToGetBlogException {
    if (StringUtils.isBlank(id)) {
        return null;
    }

    try {
        return NodeUtil.getNodeByIdentifier(BlogRepositoryConstants.COLLABORATION, id);
    } catch (RepositoryException e) {
        LOGGER.error("Exception during fetch of blog by id.", e);
        throw new UnableToGetBlogException("Unable to retrieve blog for given id.", e);
    }
}
 
开发者ID:tricode,项目名称:magnolia-blog,代码行数:14,代码来源:BlogServiceImpl.java


示例20: setNodeName

import info.magnolia.jcr.util.NodeUtil; //导入依赖的package包/类
/**
 * Set the node Name. Node name is set to: <br>
 * the value of the property 'name' if it is present.
 */
protected void setNodeName(Node node, JcrNodeAdapter item) throws RepositoryException {
    String propertyName = "name";
    if (node.hasProperty(propertyName) && !node.hasProperty(ModelConstants.JCR_NAME)) {
        Property property = node.getProperty(propertyName);
        String newNodeName = property.getString();
        if (!node.getName().equals(Path.getValidatedLabel(newNodeName))) {
            newNodeName = Path.getUniqueLabel(node.getSession(), node.getParent().getPath(), Path.getValidatedLabel(newNodeName));
            item.setNodeName(newNodeName);
            NodeUtil.renameNode(node, newNodeName);
        }
    }

}
 
开发者ID:rah003,项目名称:neat-tweaks,代码行数:18,代码来源:SaveFieldFormAction.java



注:本文中的info.magnolia.jcr.util.NodeUtil类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java BsonBinaryReader类代码示例发布时间:2022-05-22
下一篇:
Java PersistenceProviderImpl类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap