javax.jcr.Node.isNodeType()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(7.2k)|赞(0)|评价(0)|浏览(242)

本文整理了Java中javax.jcr.Node.isNodeType()方法的一些代码示例,展示了Node.isNodeType()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.isNodeType()方法的具体详情如下:
包路径:javax.jcr.Node
类名称:Node
方法名:isNodeType

Node.isNodeType介绍

[英]Returns true if this node is of the specified primary node type or mixin type, or a subtype thereof. Returns false otherwise.

This method respects the effective node type of the node.
[中]如果此节点属于指定的主节点类型或mixin类型或其子类型,则返回true。否则返回false
此方法考虑节点的有效节点类型。

代码示例

代码示例来源:origin: info.magnolia/magnolia-core

  1. private boolean isNodeType(Node node, String[] nodeType) throws RepositoryException {
  2. for (String nt : nodeType) {
  3. if (node.isNodeType(nt)) {
  4. return true;
  5. }
  6. }
  7. return false;
  8. }
  9. }

代码示例来源:origin: info.magnolia/magnolia-core

  1. private boolean isAllowedNodeType(Node node) throws RepositoryException {
  2. if (allowedNodeTypes.isEmpty()) {
  3. return true; //allowed node types aren't specified, behave like DefaultACLBasedPermissions
  4. }
  5. for (String nodeType : allowedNodeTypes) {
  6. if (node.isNodeType(nodeType)) {
  7. return true;
  8. }
  9. }
  10. return false;
  11. }
  12. }

代码示例来源:origin: info.magnolia/magnolia-core

  1. @Override
  2. public boolean evaluateTyped(Node t) {
  3. try {
  4. return !(t.getName().startsWith(NodeTypes.JCR_PREFIX) || t.isNodeType(NodeTypes.MetaData.NAME));
  5. } catch (RepositoryException e) {
  6. return false;
  7. }
  8. }
  9. });

代码示例来源:origin: info.magnolia/magnolia-core

  1. protected boolean hasBinaryNode(String name) throws RepositoryException {
  2. return this.node.hasNode(name) && (this.node.getNode(name).isNodeType(ItemType.NT_RESOURCE) ||
  3. (this.node.hasProperty("jcr:frozenPrimaryType") && this.node.getNode(name).getProperty("jcr:frozenPrimaryType").getValue().getString().equals(ItemType.NT_RESOURCE)));
  4. }
  5. }

代码示例来源:origin: info.magnolia/magnolia-core

  1. /**
  2. * Verifies the existence of the mix:versionable and adds it if not.
  3. */
  4. protected void checkAndAddMixin(Node node) throws RepositoryException {
  5. if (!node.isNodeType("mix:versionable")) {
  6. log.debug("Add mix:versionable");
  7. node.addMixin("mix:versionable");
  8. }
  9. }

代码示例来源:origin: info.magnolia/magnolia-core

  1. public static void checkNodeType(Node node, String nodeType, String... propertyNames) throws RepositoryException {
  2. if (!node.isNodeType(nodeType)) {
  3. log.warn("Trying to set property/ies '{}' although the node '{}' with PrimaryType '{}' is not of type '{}'!", propertyNames, node.getPath(), node.getPrimaryNodeType().getName(), nodeType);
  4. }
  5. }
  6. }

代码示例来源:origin: pentaho/pentaho-platform

  1. public static boolean isSupportedNodeType( final PentahoJcrConstants pentahoJcrConstants, final Node node )
  2. throws RepositoryException {
  3. Assert.notNull( node );
  4. if ( node.isNodeType( pentahoJcrConstants.getNT_FROZENNODE() ) ) {
  5. String nodeTypeName = node.getProperty( pentahoJcrConstants.getJCR_FROZENPRIMARYTYPE() ).getString();
  6. return pentahoJcrConstants.getPHO_NT_PENTAHOFILE().equals( nodeTypeName ) || pentahoJcrConstants
  7. .getPHO_NT_PENTAHOFOLDER().equals( nodeTypeName );
  8. }
  9. return node.isNodeType( pentahoJcrConstants.getPHO_NT_PENTAHOFILE() ) || node.isNodeType( pentahoJcrConstants
  10. .getPHO_NT_PENTAHOFOLDER() );
  11. }

代码示例来源:origin: info.magnolia/magnolia-core

  1. public boolean isEditorBinaryLink() {
  2. try {
  3. return getJCRNode().isNodeType(NodeTypes.Resource.NAME);
  4. } catch (RepositoryException e) {
  5. throw new RuntimeRepositoryException(e);
  6. }
  7. }

代码示例来源:origin: Adobe-Consulting-Services/acs-aem-commons

  1. /**
  2. * Determine if a component has a Classic UI dialog for shared or global configs.
  3. */
  4. private boolean componentHasClassicDialog(Component component, String dialogName) throws RepositoryException {
  5. Resource dialog = component.getLocalResource(dialogName);
  6. return dialog != null && dialog.adaptTo(Node.class).isNodeType("cq:Dialog");
  7. }

代码示例来源:origin: pentaho/pentaho-platform

  1. public static Serializable getNodeId( final Session session, final PentahoJcrConstants pentahoJcrConstants,
  2. final Node node ) throws RepositoryException {
  3. if ( node.isNodeType( pentahoJcrConstants.getNT_FROZENNODE() ) ) {
  4. return node.getProperty( pentahoJcrConstants.getJCR_FROZENUUID() ).getString();
  5. }
  6. return node.getIdentifier();
  7. }

代码示例来源:origin: info.magnolia/magnolia-core

  1. protected void markAsDeleted(Node node) throws RepositoryException {
  2. // add mixin
  3. node.addMixin(NodeTypes.Deleted.NAME);
  4. // change template
  5. if (node.isNodeType(NodeTypes.Renderable.NAME)) {
  6. NodeTypes.Renderable.set(node, DELETED_NODE_TEMPLATE);
  7. }
  8. }

代码示例来源:origin: info.magnolia/magnolia-core

  1. public String getFileName() {
  2. try {
  3. if (StringUtils.isEmpty(this.fileName) && this.getJCRNode() != null && this.getJCRNode().isNodeType(NodeTypes.Resource.NAME)) {
  4. File binary = new File(jcrNode);
  5. fileName = new URI(null, null, binary.getFileName(), null).toASCIIString();
  6. }
  7. } catch (RepositoryException e) {
  8. //Just return fileName.
  9. } catch (URISyntaxException e) {
  10. }
  11. return fileName;
  12. }

代码示例来源:origin: info.magnolia/magnolia-core

  1. public Link(Node node) {
  2. try {
  3. setJCRNode(node);
  4. setWorkspace(node.getSession().getWorkspace().getName());
  5. if (node.isNodeType(JcrConstants.MIX_REFERENCEABLE)) {
  6. setUUID(node.getIdentifier());
  7. }
  8. } catch (RepositoryException e) {
  9. throw new RuntimeRepositoryException(e);
  10. }
  11. }

代码示例来源:origin: info.magnolia/magnolia-core

  1. @Test
  2. public void restoredFirstVersionHasVersionMixin() throws Exception {
  3. //GIVEN
  4. Node node = websiteSession.getRootNode().addNode("page", NodeTypes.Page.NAME);
  5. //WHEN
  6. versionManager.addVersion(node);
  7. //THEN
  8. Node restored = versionManager.getVersionedNode(node);
  9. assertTrue("Node must have hasVersion mixin", node.isNodeType(NodeTypes.HasVersion.NAME));
  10. assertTrue("Node in mgnlVersion workspace must have hasVersion mixin", restored.isNodeType(NodeTypes.HasVersion.NAME));
  11. }
  12. }

代码示例来源:origin: info.magnolia/magnolia-core

  1. public String getExtension() {
  2. try {
  3. if (StringUtils.isEmpty(this.extension) && this.getJCRNode() != null && this.getJCRNode().isNodeType(NodeTypes.Resource.NAME)) {
  4. File binary = new File(jcrNode);
  5. extension = binary.getExtension();
  6. }
  7. } catch (RepositoryException e) {
  8. //Just return extension if already set, default if not.
  9. }
  10. return StringUtils.defaultIfEmpty(this.extension, Components.getComponent(ServerConfiguration.class).getDefaultExtension());
  11. }

代码示例来源:origin: info.magnolia/magnolia-core

  1. @Test
  2. public void testIsNodeType() throws Exception {
  3. // GIVEN
  4. final String nodeType = NodeTypes.ContentNode.NAME;
  5. final Node newNode = new MockNode("test", nodeType);
  6. // WHEN
  7. final boolean result = newNode.isNodeType(nodeType);
  8. // THEN
  9. assertTrue(result);
  10. }

代码示例来源:origin: info.magnolia/magnolia-core

  1. @Test
  2. public void testIsNodeTypeWithSupertype() throws Exception {
  3. // GIVEN
  4. final Node newNode = new MockNode("test");
  5. // WHEN
  6. final boolean result = newNode.isNodeType(JcrConstants.NT_BASE);
  7. // THEN
  8. assertTrue(result);
  9. }

代码示例来源:origin: info.magnolia/magnolia-core

  1. @Test
  2. public void testIsNodeTypeWithUnsetMixin() throws Exception {
  3. // GIVEN
  4. Node newNode = new MockNode();
  5. // WHEN
  6. final boolean result = newNode.isNodeType(NodeTypes.Activatable.NAME);
  7. // THEN
  8. assertFalse(result);
  9. }

代码示例来源:origin: info.magnolia/magnolia-core

  1. @Test
  2. public void testIsNodeTypeWithSetMixin() throws Exception {
  3. // GIVEN
  4. final Node newNode = new MockNode();
  5. final String mixin = NodeTypes.Activatable.NAME;
  6. newNode.addMixin(mixin);
  7. // WHEN
  8. final boolean result = newNode.isNodeType(mixin);
  9. // THEN
  10. assertTrue(result);
  11. }

代码示例来源:origin: info.magnolia/magnolia-core

  1. @Test
  2. public void testNewlyCreatedUserNodeHasMixinLockable() throws PathNotFoundException, RepositoryException {
  3. // WHEN
  4. um.createUser("peter", "peter");
  5. // THEN
  6. Node userNode = MgnlContext.getJCRSession(RepositoryConstants.USERS).getNode("/admin/peter");
  7. assertNotNull(userNode);
  8. assertTrue(userNode.isNodeType(JcrConstants.MIX_LOCKABLE));
  9. }

相关文章