@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); } }
@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); } }
@Override public NodeTypeIterator registerNodeTypes( File file, boolean allowUpdate ) throws IOException, RepositoryException { String content = IoUtil.read(file); if (content.startsWith("<?xml")) { // This is Jackrabbit XML format ... return registerNodeTypes(importFromXml(new InputSource(new FileInputStream(file))), allowUpdate); } // Assume this is CND format ... CndImporter importer = new CndImporter(context()); Problems problems = new SimpleProblems(); importer.importFrom(content, problems, file.getAbsolutePath()); // 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(file.getAbsolutePath(), summary); throw new RepositoryException(msg); } // Otherwise, there are warnings, so log them ... I18n msg = JcrI18n.warningsParsingNodeTypeDefinitions; Logger.getLogger(getClass()).warn(msg, file.getAbsolutePath(), summary); } // Register the node types ... return registerNodeTypes(importer.getNodeTypeDefinitions(), allowUpdate); }
@Override public NodeTypeIterator registerNodeTypes( File file, boolean allowUpdate ) throws IOException, RepositoryException { String content = IoUtil.read(file); if (content.startsWith("<?xml")) { // This is Jackrabbit XML format ... return registerNodeTypes(importFromXml(new InputSource(new FileInputStream(file))), allowUpdate); } // Assume this is CND format ... CndImporter importer = new CndImporter(context()); Problems problems = new SimpleProblems(); importer.importFrom(content, problems, file.getAbsolutePath()); // 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(file.getAbsolutePath(), summary); throw new RepositoryException(msg); } // Otherwise, there are warnings, so log them ... I18n msg = JcrI18n.warningsParsingNodeTypeDefinitions; Logger.getLogger(getClass()).warn(msg, file.getAbsolutePath(), summary); } // Register the node types ... return registerNodeTypes(importer.getNodeTypeDefinitions(), allowUpdate); }
@Override public NodeTypeIterator registerNodeTypes( InputStream stream, boolean allowUpdate ) throws IOException, javax.jcr.nodetype.InvalidNodeTypeDefinitionException, javax.jcr.nodetype.NodeTypeExistsException, UnsupportedRepositoryOperationException, RepositoryException { String content = IoUtil.read(stream); 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, "stream"); // 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.errorsParsingStreamOfNodeTypeDefinitions.text(summary); throw new RepositoryException(msg); } // Otherwise, there are warnings, so log them ... I18n msg = JcrI18n.warningsParsingStreamOfNodeTypeDefinitions; Logger.getLogger(getClass()).warn(msg, summary); } // Register the node types ... return registerNodeTypes(importer.getNodeTypeDefinitions(), allowUpdate); }
@Override public NodeTypeIterator registerNodeTypes( InputStream stream, boolean allowUpdate ) throws IOException, javax.jcr.nodetype.InvalidNodeTypeDefinitionException, javax.jcr.nodetype.NodeTypeExistsException, UnsupportedRepositoryOperationException, RepositoryException { String content = IoUtil.read(stream); 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, "stream"); // 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.errorsParsingStreamOfNodeTypeDefinitions.text(summary); throw new RepositoryException(msg); } // Otherwise, there are warnings, so log them ... I18n msg = JcrI18n.warningsParsingStreamOfNodeTypeDefinitions; Logger.getLogger(getClass()).warn(msg, summary); } // Register the node types ... return registerNodeTypes(importer.getNodeTypeDefinitions(), allowUpdate); }