/** * Returns an empty {@code PropertyDefinitionTemplate} which can then be used to create a property definition and attached to * a {@code NodeTypeTemplate}. * * @return an empty {@code PropertyDefinitionTemplate} which can then be used to create a property definition and attached to * a {@code NodeTypeTemplate}. * @throws RepositoryException if another error occurs */ @Override public NodeDefinitionTemplate createNodeDefinitionTemplate() throws RepositoryException { return new JcrNodeDefinitionTemplate(context()); }
/** * Returns an empty {@code NodeTypeTemplate} which can then be used to define a node type and passed to * {@link JcrNodeTypeManager#registerNodeType(NodeTypeDefinition, boolean)} * * @return an empty {@code NodeTypeTemplate} which can then be used to define a node type and passed to * {@link JcrNodeTypeManager#registerNodeType(NodeTypeDefinition, boolean)}. * @throws RepositoryException if another error occurs */ @Override public NodeTypeTemplate createNodeTypeTemplate() throws RepositoryException { return new JcrNodeTypeTemplate(context()); }
/** * Returns an empty {@code PropertyDefinitionTemplate} which can then be used to create a property definition and attached to * a {@code NodeTypeTemplate}. * * @return an empty {@code PropertyDefinitionTemplate} which can then be used to create a property definition and attached to * a {@code NodeTypeTemplate}. * @throws RepositoryException if another error occurs */ @Override public PropertyDefinitionTemplate createPropertyDefinitionTemplate() throws RepositoryException { return new JcrPropertyDefinitionTemplate(context()); }
/** * Returns an empty {@code NodeTypeTemplate} which can then be used to define a node type and passed to * {@link JcrNodeTypeManager#registerNodeType(NodeTypeDefinition, boolean)} * * @return an empty {@code NodeTypeTemplate} which can then be used to define a node type and passed to * {@link JcrNodeTypeManager#registerNodeType(NodeTypeDefinition, boolean)}. * @throws RepositoryException if another error occurs */ @Override public NodeTypeTemplate createNodeTypeTemplate() throws RepositoryException { return new JcrNodeTypeTemplate(context()); }
/** * Returns an empty {@code PropertyDefinitionTemplate} which can then be used to create a property definition and attached to * a {@code NodeTypeTemplate}. * * @return an empty {@code PropertyDefinitionTemplate} which can then be used to create a property definition and attached to * a {@code NodeTypeTemplate}. * @throws RepositoryException if another error occurs */ @Override public NodeDefinitionTemplate createNodeDefinitionTemplate() throws RepositoryException { return new JcrNodeDefinitionTemplate(context()); }
/** * Returns an empty {@code PropertyDefinitionTemplate} which can then be used to create a property definition and attached to * a {@code NodeTypeTemplate}. * * @return an empty {@code PropertyDefinitionTemplate} which can then be used to create a property definition and attached to * a {@code NodeTypeTemplate}. * @throws RepositoryException if another error occurs */ @Override public PropertyDefinitionTemplate createPropertyDefinitionTemplate() throws RepositoryException { return new JcrPropertyDefinitionTemplate(context()); }
@Override public NodeTypeIterator getMixinNodeTypes() throws RepositoryException { session.checkLive(); Collection<JcrNodeType> rawTypes = nodeTypes().getMixinNodeTypes(); List<JcrNodeType> types = new ArrayList<JcrNodeType>(rawTypes.size()); // Need to return a version of the node type with the current context for (JcrNodeType type : rawTypes) { types.add(type.with(context(), session)); } return new JcrNodeTypeIterator(types); }
@Override public NodeTypeIterator getMixinNodeTypes() throws RepositoryException { session.checkLive(); Collection<JcrNodeType> rawTypes = nodeTypes().getMixinNodeTypes(); List<JcrNodeType> types = new ArrayList<JcrNodeType>(rawTypes.size()); // Need to return a version of the node type with the current context for (JcrNodeType type : rawTypes) { types.add(type.with(context(), session)); } return new JcrNodeTypeIterator(types); }
@Override public NodeTypeIterator getPrimaryNodeTypes() throws RepositoryException { session.checkLive(); Collection<JcrNodeType> rawTypes = nodeTypes().getPrimaryNodeTypes(); List<JcrNodeType> types = new ArrayList<JcrNodeType>(rawTypes.size()); // Need to return a version of the node type with the current context for (JcrNodeType type : rawTypes) { types.add(type.with(context(), session)); } return new JcrNodeTypeIterator(types); }
@Override public NodeTypeIterator getPrimaryNodeTypes() throws RepositoryException { session.checkLive(); Collection<JcrNodeType> rawTypes = nodeTypes().getPrimaryNodeTypes(); List<JcrNodeType> types = new ArrayList<JcrNodeType>(rawTypes.size()); // Need to return a version of the node type with the current context for (JcrNodeType type : rawTypes) { types.add(type.with(context(), session)); } return new JcrNodeTypeIterator(types); }
/** * Returns the node type with the given name (if one exists) * * @param nodeTypeName the name of the node type to be returned * @return the node type with the given name (if one exists) * @see NodeTypes#getNodeType(Name) */ JcrNodeType getNodeType( Name nodeTypeName ) { JcrNodeType nodeType = nodeTypes().getNodeType(nodeTypeName); if (nodeType != null) { nodeType = nodeType.with(context(), session); } return nodeType; }
/** * Returns the node type with the given name (if one exists) * * @param nodeTypeName the name of the node type to be returned * @return the node type with the given name (if one exists) * @see NodeTypes#getNodeType(Name) */ JcrNodeType getNodeType( Name nodeTypeName ) { JcrNodeType nodeType = nodeTypes().getNodeType(nodeTypeName); if (nodeType != null) { nodeType = nodeType.with(context(), session); } return nodeType; }
@Override public JcrNodeType getNodeType( String nodeTypeName ) throws NoSuchNodeTypeException, RepositoryException { session.checkLive(); Name ntName = context().getValueFactories().getNameFactory().create(nodeTypeName); JcrNodeType type = nodeTypes().getNodeType(ntName); if (type != null) { type = type.with(context(), session); return type; } throw new NoSuchNodeTypeException(JcrI18n.typeNotFound.text(nodeTypeName)); }
@Override public JcrNodeType getNodeType( String nodeTypeName ) throws NoSuchNodeTypeException, RepositoryException { session.checkLive(); Name ntName = context().getValueFactories().getNameFactory().create(nodeTypeName); JcrNodeType type = nodeTypes().getNodeType(ntName); if (type != null) { type = type.with(context(), session); return type; } throw new NoSuchNodeTypeException(JcrI18n.typeNotFound.text(nodeTypeName)); }
NameFactory nameFactory = context().getValueFactories().getNameFactory();
@Override public NodeTypeIterator registerNodeTypes( URL url, boolean allowUpdate ) throws IOException, RepositoryException { String content = IoUtil.read(url.openStream()); if (content.startsWith("<?xml")) { // This is Jackrabbit XML format ... return registerNodeTypes(importFromXml(new InputSource(new StringReader(content))), allowUpdate); } // Assume this is CND format ... CndImporter importer = new CndImporter(context()); Problems problems = new SimpleProblems(); importer.importFrom(content, problems, url.toExternalForm()); // Check for (and report) any problems ... if (problems.hasProblems()) { // There are errors and/or warnings, so report them ... String summary = messageFrom(problems); if (problems.hasErrors()) { String msg = JcrI18n.errorsParsingNodeTypeDefinitions.text(url.toExternalForm(), summary); throw new RepositoryException(msg); } // Otherwise, there are warnings, so log them ... I18n msg = JcrI18n.warningsParsingNodeTypeDefinitions; Logger.getLogger(getClass()).warn(msg, url.toExternalForm(), summary); } // Register the node types ... return registerNodeTypes(importer.getNodeTypeDefinitions(), allowUpdate); } }
NameFactory nameFactory = context().getValueFactories().getNameFactory();
@Override public NodeTypeIterator registerNodeTypes( URL url, boolean allowUpdate ) throws IOException, RepositoryException { String content = IoUtil.read(url.openStream()); if (content.startsWith("<?xml")) { // This is Jackrabbit XML format ... return registerNodeTypes(importFromXml(new InputSource(new StringReader(content))), allowUpdate); } // Assume this is CND format ... CndImporter importer = new CndImporter(context()); Problems problems = new SimpleProblems(); importer.importFrom(content, problems, url.toExternalForm()); // Check for (and report) any problems ... if (problems.hasProblems()) { // There are errors and/or warnings, so report them ... String summary = messageFrom(problems); if (problems.hasErrors()) { String msg = JcrI18n.errorsParsingNodeTypeDefinitions.text(url.toExternalForm(), summary); throw new RepositoryException(msg); } // Otherwise, there are warnings, so log them ... I18n msg = JcrI18n.warningsParsingNodeTypeDefinitions; Logger.getLogger(getClass()).warn(msg, url.toExternalForm(), summary); } // Register the node types ... return registerNodeTypes(importer.getNodeTypeDefinitions(), allowUpdate); } }
/** * Returns true if and only if the node type with the given name exists. * <p> * This is equivalent to the following code: * * <pre> * try { * getNodeType(nodeTypeName); * return true; * } catch (NoSuchNodeTypeException nsnte) { * return false; * } * </pre> * * However, the implementation is more efficient that the approach listed above and does not rely upon exceptions. * </p> * * @param nodeTypeName the name of the node type * @return true if the named node type does exist, or false otherwise * @see NodeTypes#hasNodeType(Name) */ @Override public boolean hasNodeType( String nodeTypeName ) { Name ntName = context().getValueFactories().getNameFactory().create(nodeTypeName); return nodeTypes().hasNodeType(ntName); }
/** * Returns true if and only if the node type with the given name exists. * <p> * This is equivalent to the following code: * * <pre> * try { * getNodeType(nodeTypeName); * return true; * } catch (NoSuchNodeTypeException nsnte) { * return false; * } * </pre> * * However, the implementation is more efficient that the approach listed above and does not rely upon exceptions. * </p> * * @param nodeTypeName the name of the node type * @return true if the named node type does exist, or false otherwise * @see NodeTypes#hasNodeType(Name) */ @Override public boolean hasNodeType( String nodeTypeName ) { Name ntName = context().getValueFactories().getNameFactory().create(nodeTypeName); return nodeTypes().hasNodeType(ntName); }