/** {@inheritDoc} */ public RemoteNodeType getDefaultPrimaryType() throws RemoteException { NodeType nt = def.getDefaultPrimaryType(); if (nt == null) { return null; } else { return getFactory().getRemoteNodeType(def.getDefaultPrimaryType()); } }
NodeType defaultType = def.getDefaultPrimaryType(); String defaultTypeName = def.getDefaultPrimaryTypeName(); if (defaultType != null) {
private NodeDefinitionImpl(NodeDefinition definition) { super(definition); requiredPrimaryTypes = definition.getRequiredPrimaryTypes(); defaultPrimaryType = definition.getDefaultPrimaryType(); allowsSameNameSiblings = definition.allowsSameNameSiblings(); }
@Override public boolean canAddChildNode(String childNodeName) { // FIXME: properly calculate matching definition for (NodeDefinition definition : getChildNodeDefinitions()) { String name = definition.getName(); if (matches(childNodeName, name) || RESIDUAL_NAME.equals(name)) { return !definition.isProtected() && definition.getDefaultPrimaryType() != null; } } return false; }
@Override public boolean canAddChildNode(String childNodeName) { // FIXME: properly calculate matching definition for (NodeDefinition definition : getChildNodeDefinitions()) { String name = definition.getName(); if (matches(childNodeName, name) || RESIDUAL_NAME.equals(name)) { return !definition.isProtected() && definition.getDefaultPrimaryType() != null; } } return false; }
@Override public boolean canAddChildNode(String childNodeName) { // FIXME: properly calculate matching definition for (NodeDefinition definition : getChildNodeDefinitions()) { String name = definition.getName(); if (matches(childNodeName, name) || RESIDUAL_NAME.equals(name)) { return !definition.isProtected() && definition.getDefaultPrimaryType() != null; } } return false; }
if (node.getDefaultPrimaryType() != null) { writer.println(" DefaultPrimaryType " + node.getDefaultPrimaryType().getName()); } else { writer.println(" DefaultPrimaryType null");
dependencies.add(superType); for (NodeDefinition childDef : nt.getDeclaredChildNodeDefinitions()) { if (childDef.getDefaultPrimaryType() != null) dependencies.add(childDef.getDefaultPrimaryType()); for (NodeType childNodeType : childDef.getRequiredPrimaryTypes()) dependencies.add(childNodeType);
/** * Return a {@link NodeTypeDefinition} list where the metaData child node definition has been removed. */ @Override public List<NodeTypeDefinition> getNodeTypesToRegister(NodeTypeManager nodeTypeManager) { List<NodeTypeDefinition> list = new ArrayList<NodeTypeDefinition>(); try { NodeTypeIterator iterator = nodeTypeManager.getAllNodeTypes(); while (iterator.hasNext()) { NodeType nodeType = iterator.nextNodeType(); if (nodeType.getDeclaredChildNodeDefinitions() != null) { // check if this type define metaData as child List<NodeDefinition> childNodeDefinition = Arrays.asList(nodeType.getDeclaredChildNodeDefinitions()); for (NodeDefinition nodeDefinition : childNodeDefinition) { if (nodeDefinition.getDefaultPrimaryType() != null && NodeTypes.MetaData.NAME.equals(nodeDefinition.getDefaultPrimaryType().getName())) { NodeTypeTemplate newNodeType = createNodeTypeWithoutMetaData(nodeTypeManager, nodeType, nodeDefinition); log.info("Add the following NodeType '{}' that currently defined a metaData nodeType as child node to the list.", newNodeType.getName()); list.add(newNodeType); break; } } } } } catch (RepositoryException e) { log.error("Could not create a List of existing NodeTpe declaring metaData as childNodeDefinition", e); } return list; }
private void makeImage(Node node, InputStream istream, String mimeType) throws Exception { Node primaryChild; try { Item item = getPrimaryItem(node); if (!item.isNode()) { throw new Exception("Primary item is not a node"); } primaryChild = (Node) item; if (primaryChild.isNodeType("hippo:resource")) { setDefaultResourceProperties(primaryChild, mimeType, istream); } validateResource(primaryChild); for (NodeDefinition childDef : node.getPrimaryNodeType().getChildNodeDefinitions()) { if (childDef.getDefaultPrimaryType() != null && childDef.getDefaultPrimaryType().isNodeType("hippo:resource")) { makeRegularImage(node, childDef.getName(), primaryChild.getProperty(JcrConstants.JCR_DATA).getStream(), primaryChild.getProperty(JcrConstants.JCR_MIMETYPE).getString(), primaryChild.getProperty( JcrConstants.JCR_LASTMODIFIED).getDate()); } } makeThumbnailImage(primaryChild, primaryChild.getProperty(JcrConstants.JCR_DATA).getStream(), primaryChild .getProperty(JcrConstants.JCR_MIMETYPE).getString()); } catch (ItemNotFoundException ignore) { } }
private void visit(String namespacePrefix, NodeType nt, HashSet<String> visited, LinkedHashSet<QNodeTypeDefinition> result) { if (visited.contains(nt.getName())) { return; } visited.add(nt.getName()); for (NodeType superType : nt.getSupertypes()) { visit(namespacePrefix, superType, visited, result); } for (NodeDefinition nd : nt.getChildNodeDefinitions()) { for (NodeType childType : nd.getRequiredPrimaryTypes()) { visit(namespacePrefix, childType, visited, result); } NodeType defaultPriType = nd.getDefaultPrimaryType(); if (defaultPriType != null) { visit(namespacePrefix, defaultPriType, visited, result); } } if (nt.getName().startsWith(namespacePrefix + ":")) { result.add(((AbstractNodeType)nt).getDefinition()); } }
if (childDef.getDefaultPrimaryType() != null && childDef.getDefaultPrimaryType().isNodeType("hippo:resource")) { makeRegularImage(node, childDef.getName(), primaryChild.getProperty(JcrConstants.JCR_DATA).getStream(), primaryChild.getProperty(JcrConstants.JCR_MIMETYPE).getString(), primaryChild.getProperty(
private void writeNodeType(NodeType nt, CNDWriter w, Set<String> written) throws IOException, RepositoryException { if (nt != null && !written.contains(nt.getName())) { written.add(nt.getName()); w.write(nt); for (NodeType s: nt.getSupertypes()) { writeNodeType(s, w, written); } for (NodeDefinition n: nt.getChildNodeDefinitions()) { writeNodeType(n.getDefaultPrimaryType(), w, written); if (n.getRequiredPrimaryTypes() != null) { for (NodeType r: n.getRequiredPrimaryTypes()) { writeNodeType(r, w, written); } } } } }
private void loadChildNodeDefinitions(NodeType nodeType, EffectiveNodeTypeImpl ent) throws RepositoryException { for (NodeDefinition nd : nodeType.getChildNodeDefinitions()) { EffectiveNodeTypeChildImpl child = // ensure child definition declaring type is also loaded new EffectiveNodeTypeChildImpl(nd.getName(), loadEffectiveNodeType(nd.getDeclaringNodeType()).getName()); for (NodeType childType : nd.getRequiredPrimaryTypes()) { // ensure all possible child types are also loaded child.getRequiredPrimaryTypes().add(loadEffectiveNodeType(childType).getName()); } if (nd.getDefaultPrimaryType() != null) { // ensure possible primary type is also loaded child.setDefaultPrimaryType(loadEffectiveNodeType(nd.getDefaultPrimaryType()).getName()); } child.setMandatory(nd.isMandatory()); child.setAutoCreated(nd.isAutoCreated()); child.setMultiple(nd.allowsSameNameSiblings()); child.setProtected(nd.isProtected()); // each child definition is maintained in a list by name List<EffectiveNodeTypeChild> childList = ent.getChildren().get(child.getName()); if (childList == null) { childList = new ArrayList<EffectiveNodeTypeChild>(); ent.getChildren().put(child.getName(), childList); } childList.add(child); } }
/** * Creates a new node definition based on a JCR <code>NodeDefinition</code>. * * @param nodeDef the node definition. * @param resolver the name/path resolver of the session that provided the * node definition * @throws NameException if <code>nodeDef</code> contains an illegal * name. * @throws NamespaceException if <code>nodeDef</code> contains a name with * an namespace prefix that is unknown to * <code>resolver</code>. */ public QNodeDefinitionImpl(NodeDefinition nodeDef, NamePathResolver resolver) throws NameException, NamespaceException { this(nodeDef.getName().equals(NameConstants.ANY_NAME.getLocalName()) ? NameConstants.ANY_NAME : resolver.getQName(nodeDef.getName()), nodeDef.getDeclaringNodeType() != null ? resolver.getQName(nodeDef.getDeclaringNodeType().getName()) : null, nodeDef.isAutoCreated(), nodeDef.isMandatory(), nodeDef.getOnParentVersion(), nodeDef.isProtected(), nodeDef.getDefaultPrimaryType() != null ? resolver.getQName(nodeDef.getDefaultPrimaryType().getName()) : null, getNodeTypeNames(nodeDef.getRequiredPrimaryTypes(), resolver), nodeDef.allowsSameNameSiblings()); }
/** * Creates a new node definition based on a JCR <code>NodeDefinition</code>. * * @param nodeDef the node definition. * @param resolver the name/path resolver of the session that provided the * node definition * @throws NameException if <code>nodeDef</code> contains an illegal * name. * @throws NamespaceException if <code>nodeDef</code> contains a name with * an namespace prefix that is unknown to * <code>resolver</code>. */ public QNodeDefinitionImpl(NodeDefinition nodeDef, NamePathResolver resolver) throws NameException, NamespaceException { this(nodeDef.getName().equals(NameConstants.ANY_NAME.getLocalName()) ? NameConstants.ANY_NAME : resolver.getQName(nodeDef.getName()), nodeDef.getDeclaringNodeType() != null ? resolver.getQName(nodeDef.getDeclaringNodeType().getName()) : null, nodeDef.isAutoCreated(), nodeDef.isMandatory(), nodeDef.getOnParentVersion(), nodeDef.isProtected(), nodeDef.getDefaultPrimaryType() != null ? resolver.getQName(nodeDef.getDefaultPrimaryType().getName()) : null, getNodeTypeNames(nodeDef.getRequiredPrimaryTypes(), resolver), nodeDef.allowsSameNameSiblings()); }
if (nodeDefs != null) { for (NodeDefinition nodeDef: nodeDefs) { internalAddNodeType(nodeDef.getDefaultPrimaryType()); NodeType[] reqs = nodeDef.getRequiredPrimaryTypes(); if (reqs != null) {
public void testCreation() throws NotExecutableException, RepositoryException { Node n; try { n = testRootNode.addNode(nodeName1, testNodeType); } catch (RepositoryException e) { throw new NotExecutableException(); } try { testRootNode.save(); fail("Saving without having added the mandatory child items must fail."); } catch (ConstraintViolationException e) { // success } if (childNodeDef != null) { n.addNode(childNodeDef.getName(), childNodeDef.getDefaultPrimaryType().getName()); } if (childPropDef != null) { // TODO: check if definition defines default values n.setProperty(childPropDef.getName(), "any value"); } // now save must succeed. testRootNode.save(); }
@Test public void testGetDefinitionWithSNS() throws RepositoryException, IOException { Session session = getAdminSession(); Node node = session.getNode("/jcr:system/jcr:nodeTypes/nt:file"); // TODO: use getNode("jcr:childNodeDefinition[1]") once that works for (Node child : getChildNodes(node, "jcr:childNodeDefinition")) { NodeDefinition definition = child.getDefinition(); // OAK-829 definition.getDefaultPrimaryType(); // OAK-826 definition.getRequiredPrimaryTypes(); // OAK-826 } }
n = testRootNode.addNode(nodeName1, testNodeType); if (childNodeDef != null) { childN = n.addNode(childNodeDef.getName(), childNodeDef.getDefaultPrimaryType().getName()); childN = n.addNode(childNodeDef.getName(), childNodeDef.getDefaultPrimaryType().getName());