当前位置: 首页>>代码示例>>Java>>正文


Java NodeTypes类代码示例

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


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

示例1: generateCell

import info.magnolia.jcr.util.NodeTypes; //导入依赖的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.NodeTypes; //导入依赖的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: generateCellWithoutBlogNode

import info.magnolia.jcr.util.NodeTypes; //导入依赖的package包/类
@Test
public void generateCellWithoutBlogNode() throws Exception {
    Object itemId = "1";

    JcrItemAdapter mockItem = mock(JcrItemAdapter.class);
    Node mockNode = mock(Node.class);

    doReturn(mockItem).when(mockTable).getItem(itemId);
    doReturn(mockNode).when(mockItem).getJcrItem();
    doReturn(true).when(mockItem).isNode();
    doReturn(true).when(mockNode).isNode();
    doReturnIsNodeType(mockNode, NodeTypes.Page.NAME);

    Object result = formatter.generateCell(mockTable, itemId, null);
    assertEquals(StringUtils.EMPTY, result);
}
 
开发者ID:tricode,项目名称:magnolia-blog,代码行数:17,代码来源:AuthorNameColumnFormatterTest.java

示例4: testGenerateCellWithoutBlogOrFolderNode

import info.magnolia.jcr.util.NodeTypes; //导入依赖的package包/类
@Test
public void testGenerateCellWithoutBlogOrFolderNode() throws Exception {
    Object itemId = "1";

    JcrItemAdapter mockItem = mock(JcrItemAdapter.class);
    Node mockNode = mock(Node.class);

    doReturn(mockItem).when(mockTable).getItem(itemId);
    doReturn(mockNode).when(mockItem).getJcrItem();
  doReturn(true).when(mockItem).isNode();
    doReturn(true).when(mockNode).isNode();
    doReturnIsNodeType(mockNode, NodeTypes.Page.NAME);

    Object result = formatter.generateCell(mockTable, itemId, null);
    Assert.assertEquals(StringUtils.EMPTY, result);
}
 
开发者ID:tricode,项目名称:magnolia-blog,代码行数:17,代码来源:BlogNameColumnFormatterTest.java

示例5: testGenerateCellWithFolderNode

import info.magnolia.jcr.util.NodeTypes; //导入依赖的package包/类
@Test
public void testGenerateCellWithFolderNode() throws Exception {
    Object itemId = "1";
    String folderName = "folder1";

    JcrItemAdapter mockItem = mock(JcrItemAdapter.class);
    Node mockNode = mock(Node.class);

    doReturn(mockItem).when(mockTable).getItem(itemId);
    doReturn(mockNode).when(mockItem).getJcrItem();
  doReturn(true).when(mockItem).isNode();
    doReturn(true).when(mockNode).isNode();
    doReturnIsNodeType(mockNode, NodeTypes.Folder.NAME);
    doReturn(folderName).when(mockNode).getName();

    Object result = formatter.generateCell(mockTable, itemId, null);
    Assert.assertEquals(folderName, result);
}
 
开发者ID:tricode,项目名称:magnolia-blog,代码行数:19,代码来源:BlogNameColumnFormatterTest.java

示例6: execute

import info.magnolia.jcr.util.NodeTypes; //导入依赖的package包/类
@Override
public void execute() throws ActionExecutionException {
    super.execute();
    try {
        Node node = (Node) ((JcrItemAdapter) item).getJcrItem();
        // 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, "It would seem you decided to change type of the component! In case you realize that being bad idea, you can always change it back.");
    } catch (RepositoryException e) {
        log.error("It would seem we were not able to obtain id of parent item of node {}", ((JcrItemAdapter) item).getJcrItem());
    }
}
 
开发者ID:rah003,项目名称:neat-tweaks,代码行数:17,代码来源:SaveAndRefreshGenericCommitDialogAction.java

示例7: getExtraInstallTasks

import info.magnolia.jcr.util.NodeTypes; //导入依赖的package包/类
@Override
protected List<Task> getExtraInstallTasks(InstallContext installContext) {
    List<Task> tasks = new ArrayList<Task>(super.getExtraInstallTasks(installContext));
    tasks.add(new NodeExistsDelegateTask("", "/modules/ui-admincentral/config/appLauncherLayout/groups/manage/apps/neatconfiguration", null,
            new CreateNodeTask("", "/modules/ui-admincentral/config/appLauncherLayout/groups/manage/apps", "neatconfiguration", NodeTypes.ContentNode.NAME)));
    tasks.add(new MoveNodeTask("", "/modules/ui-admincentral/config/appLauncherLayout/groups/manage/apps/configuration", "/modules/ui-admincentral/config/appLauncherLayout/groups/tools/apps/configuration", false));
    tasks.add(new NodeExistsDelegateTask("", "/modules/ui-admincentral/apps/stkSiteApp/subApps",
            new SetPropertyTask("config", "/modules/ui-admincentral/apps/stkSiteApp/subApps", "extends", "/modules/neat-tweaks-developers/apps/neatconfiguration/subApps")));
    tasks.add(new NodeExistsDelegateTask("", "/modules/ui-admincentral/apps/stkThemesApp/subApps",
            new SetPropertyTask("config", "/modules/ui-admincentral/apps/stkThemesApp/subApps", "extends", "/modules/neat-tweaks-developers/apps/neatconfiguration/subApps")));
    tasks.add(new NodeExistsDelegateTask("", "/modules/ui-admincentral/apps/stkChannelsApp/subApps",
            new SetPropertyTask("config", "/modules/ui-admincentral/apps/stkChannelsApp/subApps", "extends", "/modules/neat-tweaks-developers/apps/neatconfiguration/subApps")));
    tasks.add(new NodeExistsDelegateTask("", "/modules/ui-admincentral/apps/stkDialogsApp/subApps",
            new SetPropertyTask("config", "/modules/ui-admincentral/apps/stkDialogsApp/subApps", "extends", "/modules/neat-tweaks-developers/apps/neatconfiguration/subApps")));
    tasks.add(new NodeExistsDelegateTask("", "/modules/ui-admincentral/apps/stkTemplateDefsApp/subApps",
            new SetPropertyTask("config", "/modules/ui-admincentral/apps/stkTemplateDefsApp/subApps", "extends", "/modules/neat-tweaks-developers/apps/neatconfiguration/subApps")));
    tasks.add(new IsModuleInstalledOrRegistered("STK JPG Image generator", "standard-templating-kit",
            new BootstrapSingleResource("", "", "/mgnl-bootstrap/standard-templating-kit/config.modules.imaging.config.generators.stk-jpg.xml")));
    return tasks;
}
 
开发者ID:rah003,项目名称:neat-tweaks,代码行数:21,代码来源:NeatTweaks4DevelopersVersionHandler.java

示例8: execute

import info.magnolia.jcr.util.NodeTypes; //导入依赖的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

示例9: execute

import info.magnolia.jcr.util.NodeTypes; //导入依赖的package包/类
@Override
public void execute() throws ActionExecutionException {
    super.execute();
    // First Validate
    validator.showValidation(true);
    if (validator.isValid()) {
        try {
            Node node = (Node) item.getJcrItem();
            // 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, "In case you didn't manage to set component type right, you can always try again ... and again");
        } catch (RepositoryException e) {
            log.error("It would seem we were not able to obtain id of parent item of node {}", item.getJcrItem());
        }

    } else {
        log.debug("Validation error(s) occurred. No save performed.");
    }
}
 
开发者ID:rah003,项目名称:neat-tweaks,代码行数:24,代码来源:SaveAndRefreshPageAction.java

示例10: generateCellHelper

import info.magnolia.jcr.util.NodeTypes; //导入依赖的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

示例11: generateCellHelper

import info.magnolia.jcr.util.NodeTypes; //导入依赖的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

示例12: getExtraInstallTasks

import info.magnolia.jcr.util.NodeTypes; //导入依赖的package包/类
@Override
protected List<Task> getExtraInstallTasks(InstallContext installContext) {
    List<Task> tasks = new ArrayList<Task>(super.getExtraInstallTasks(installContext));
    if (!LicenseFileExtractor.getInstance().get(LicenseFileExtractor.VERSION_NUMBER).startsWith("5.4")) {
        tasks.add(new InstallTextResourceTask("/ui-admincentral/neat_theme.css"));
    } else {
        tasks.add(new CreateNodePathTask("admincentral", "/", NodeTypes.Folder.NAME));
    }
    return tasks;
}
 
开发者ID:rah003,项目名称:neat-tweaks,代码行数:11,代码来源:DefaultNeatVersionHandler.java

示例13: execute

import info.magnolia.jcr.util.NodeTypes; //导入依赖的package包/类
@Override
public void execute() throws ActionExecutionException {
    // First Validate
    validator.showValidation(true);
    if (validator.isValid()) {
        try {
            final Node node = item.applyChanges();
            // Set the Node name.
            setNodeName(node, item);
            // WTF was whomever at JR dev team thinking?
            for (Property prop : in((Iterator<Property>) node.getProperties())) {
                if (prop.getType() == PropertyType.STRING && StringUtils.isEmpty(prop.getValue().getString())) {
                    prop.remove();
                }
            }
            Node actions = node.addNode("actions", NodeTypes.ContentNode.NAME);
            setAction(node, actions, "commit", "info.magnolia.ui.form.action.SaveFormActionDefinition");
            setAction(node, actions, "cancel", "info.magnolia.ui.form.action.CancelFormActionDefinition");

            Node tabs = node.addNode("form", NodeTypes.ContentNode.NAME).addNode("tabs", NodeTypes.ContentNode.NAME);
            for (Node n : in((Iterator<Node>) node.getNodes("tabs*"))) {
                if (n.hasProperty("field")) {
                    String name = n.getProperty("field").getString();

                    Node tab = tabs.addNode(Path.getUniqueLabel(tabs, Path.getValidatedLabel(name)), NodeTypes.ContentNode.NAME);
                    tab.setProperty("label", StringUtils.capitalize(name));
                    tab.addNode("fields", NodeTypes.ContentNode.NAME);
                }
                n.remove();
            }
            node.getSession().save();
        } catch (final RepositoryException e) {
            throw new ActionExecutionException(e);
        }
        callback.onSuccess(getDefinition().getName());
    } else {
        log.info("Validation error(s) occurred. No save performed.");
    }
}
 
开发者ID:rah003,项目名称:neat-tweaks,代码行数:40,代码来源:SaveDialogFormAction.java

示例14: setAction

import info.magnolia.jcr.util.NodeTypes; //导入依赖的package包/类
private void setAction(final Node node, Node actions, String actionName, String implClass) throws RepositoryException, PathNotFoundException, ValueFormatException, VersionException, LockException, ConstraintViolationException, ItemExistsException, AccessDeniedException {
    String propName = "default" + StringUtils.capitalize(actionName);
    if (node.hasProperty(propName)) {
        Property defaultAction = node.getProperty(propName);
        if (defaultAction.getBoolean()) {
            actions.addNode(actionName, NodeTypes.ContentNode.NAME).setProperty("class", implClass);
        }
        defaultAction.remove();
    }
}
 
开发者ID:rah003,项目名称:neat-tweaks,代码行数:11,代码来源:SaveDialogFormAction.java

示例15: isNotDeleted

import info.magnolia.jcr.util.NodeTypes; //导入依赖的package包/类
private boolean isNotDeleted(Node node) {
    try {
        boolean isDeleted = NodeUtil.hasMixin(node, NodeTypes.Deleted.NAME);
        return !isDeleted;
    } catch (RepositoryException e) {
        log.debug("Failed to check for deleted nodes. with {}", e.getMessage(), e );
    }
    return false;
}
 
开发者ID:rah003,项目名称:neat-jsonfn,代码行数:10,代码来源:JsonBuilder.java


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