private static boolean isNodeType(final NodeType nodeType, final String superType) { if (nodeType == null) { log.debug("Unable to check node type for empty node type"); return false; } if (StringUtils.isEmpty(superType)) { log.debug("Unable to check node type for empty super type"); return false; } return nodeType.isNodeType(superType); }
private static boolean isNodeType(final NodeType nodeType, final String superType) { if (nodeType == null) { log.debug("Unable to check node type for empty node type"); return false; } if (StringUtils.isEmpty(superType)) { log.debug("Unable to check node type for empty super type"); return false; } return nodeType.isNodeType(superType); }
private boolean hasRequiredPrimaryNodeType(final NodeDefinition definition) { for (String primaryNodeTypeName : definition.getRequiredPrimaryTypeNames()) { if (!nodeType.isNodeType(primaryNodeTypeName)) { return false; } } return true; }
@Override public boolean isType(String typeName) { load(); if (nt != null) { return nt.isNodeType(typeName); } else if (type.equals(typeName)) { return true; } return false; }
private boolean hasMixin(Node node) { try { NodeType[] nodeTypes = node.getMixinNodeTypes(); for (NodeType nodeType : nodeTypes) { if (nodeType.isNodeType("mix:shareable")) { return true; } } } catch (RepositoryException e) { } return false; }
private boolean hasMixin(Node node) { try { NodeType[] nodeTypes = node.getMixinNodeTypes(); for (NodeType nodeType : nodeTypes) { if (nodeType.isNodeType("mix:shareable")) { return true; } } } catch (RepositoryException e) { } return false; }
@Override public boolean isNodeType(String nodeTypeName) throws RepositoryException { return getPrimaryNodeType().isNodeType(nodeTypeName); }
@Override public void init(JcrNodeModel model) throws RepositoryException { for (NodeIterator it = model.getNode().getNodes(); it.hasNext();) { Node child = it.nextNode(); if (child.getPrimaryNodeType().isNodeType(HST_SITE)) { this.model = new JcrNodeModel(child); break; } } }
private Set<String> getSelfPlusSubTypes(final String nodeType, final NodeTypeIterator allTypes) throws RepositoryException { Set<String> subTypes = new LinkedHashSet<>(); while (allTypes.hasNext()) { NodeType nt = allTypes.nextNodeType(); if (nt.isNodeType(nodeType)) { subTypes.add(nt.getName()); } } return subTypes; }
public boolean isNodeType(String nodeTypeName) throws RepositoryException { substantiate(); try { for (NodeType type : getNodeTypes()) { if (type.isNodeType(nodeTypeName)) return true; } } catch (PathNotFoundException ex) { // deliberate ignore, in case of virtual nodes without primary type (bad idea, but be leniant at this time } return false; }
public void testConfigurationsPath() throws Exception { Node config = vm.createConfiguration(versionableNode.getPath()); assertNotNull(config); NodeType nt = config.getPrimaryNodeType(); assertTrue("created node must be subtype of nt:configuration", nt.isNodeType(ntConfiguration)); assertTrue("path for configuration must be below " + PREFIX + ", but was " + config.getPath(), config.getPath().startsWith(PREFIX)); }
public boolean isNodeType(String s) throws RepositoryException { boolean isNodeType = false; if(getNodetype().isNodeType(s)){ return true; } if ((resource.getPropertyValues("jcr:mixinTypes") != null) && (resource.getPropertyValues("jcr:mixinTypes").contains(s))) { return true; } return false; }
/** * Checks whether the node already has the specified mixin node type */ protected boolean needsMixin(Node node, String mixin) throws RepositoryException { return ! node.getSession().getWorkspace().getNodeTypeManager().getNodeType(node.getPrimaryNodeType().getName()).isNodeType(mixin); }
private Set<String> getSelfPlusSubTypes(final String primaryNodeType) throws RepositoryException { Set<String> subTypes = new LinkedHashSet<>(); NodeTypeManager ntMgr = session.getWorkspace().getNodeTypeManager(); NodeTypeIterator allTypes = ntMgr.getAllNodeTypes(); while (allTypes.hasNext()) { NodeType nt = allTypes.nextNodeType(); if (nt.isNodeType(primaryNodeType)) { subTypes.add(nt.getName()); } } return subTypes; }
public static boolean isNodeType(Node node, String typeName) { try { return node.getPrimaryNodeType().isNodeType(typeName); } catch (AccessDeniedException e) { log.debug("Access denied", e); throw new AccessControlException(e.getMessage()); } catch (RepositoryException e) { throw new MetadataRepositoryException("Failed to retrieve the type of node: " + node, e); } }
boolean isPrimaryNodeType() { JcrNodeModel nodeModel = (JcrNodeModel) MixinPlugin.this.getDefaultModel(); try { Node node = nodeModel.getNode(); if (node.getPrimaryNodeType().isNodeType(realType)) { return true; } } catch (RepositoryException ex) { log.error(ex.getMessage()); } return false; }
public void testCreateConfiguration() throws Exception { Node config = vm.createConfiguration(versionableNode.getPath()); assertNotNull(config); NodeType nt = config.getPrimaryNodeType(); assertTrue("created node must be subtype of nt:configuration", nt.isNodeType(ntConfiguration)); // check if the configuration points to the versionable assertTrue("jcr:root property of the configuration must reference the versionable node", config.getProperty("jcr:root").getNode().isSame(versionableNode)); // check if the versionable points to the configuration assertTrue("jcr:configuration property of the versionable node must reference the configuration", versionableNode.getProperty("jcr:configuration").getNode().isSame(config)); }
private boolean isAHippoResource(final IFieldValidator type) throws ValidationException { String jcrTypeName = type.getFieldType().getType(); try { Session jcrSession = UserSession.get().getJcrSession(); NodeTypeManager typeManager = jcrSession.getWorkspace().getNodeTypeManager(); NodeType nodeType = typeManager.getNodeType(jcrTypeName); return nodeType.isNodeType(HippoNodeType.NT_RESOURCE); } catch (RepositoryException e) { throw new ValidationException(e); } }
@Test public void verifyReplacedBuiltinNodeTypes() throws Exception { Session session = createAdminSession(); try { NodeTypeManager manager = session.getWorkspace().getNodeTypeManager(); NodeType nt = manager.getNodeType(UserConstants.NT_REP_GROUP); assertTrue("Migrated repository must have new nodetype definitions", nt.isNodeType(UserConstants.NT_REP_MEMBER_REFERENCES)); } finally { session.logout(); } }
@Test public void verifyReplacedBuiltinNodeTypes() throws Exception { Session session = createAdminSession(); try { NodeTypeManager manager = session.getWorkspace().getNodeTypeManager(); NodeType nt = manager.getNodeType(UserConstants.NT_REP_GROUP); assertTrue("Migrated repository must have new nodetype definitions", nt.isNodeType(UserConstants.NT_REP_MEMBER_REFERENCES)); } finally { session.logout(); } }