/** * Registers the node types defined in the given input stream depending * on the content type specified for the stream. This will also register * any namespaces identified in the input stream if they have not already * been registered. * * {@inheritDoc} */ public NodeType[] registerNodeTypes(InputStream in, String contentType) throws IOException, RepositoryException { return registerNodeTypes(in, contentType, false); }
/** * Registers the node types defined in the given input stream depending * on the content type specified for the stream. This will also register * any namespaces identified in the input stream if they have not already * been registered. * * {@inheritDoc} */ public NodeType[] registerNodeTypes(InputStream in, String contentType) throws IOException, RepositoryException { return registerNodeTypes(in, contentType, false); }
/** * Registers the node types defined in the given XML stream. This * is a trivial implementation that just invokes the existing * {@link NodeTypeReader} and {@link NodeTypeRegistry} methods and * heuristically creates the returned node type array. It will also * register any namespaces defined in the input source that have not * already been registered. * * {@inheritDoc} */ public NodeType[] registerNodeTypes(InputSource in) throws SAXException, RepositoryException { try { return registerNodeTypes(in.getByteStream(), TEXT_XML); } catch (IOException e) { throw new SAXException("Error reading node type stream", e); } }
/** * Registers the node types defined in the given XML stream. This * is a trivial implementation that just invokes the existing * {@link NodeTypeReader} and {@link NodeTypeRegistry} methods and * heuristically creates the returned node type array. It will also * register any namespaces defined in the input source that have not * already been registered. * * {@inheritDoc} */ public NodeType[] registerNodeTypes(InputSource in) throws SAXException, RepositoryException { try { return registerNodeTypes(in.getByteStream(), TEXT_XML); } catch (IOException e) { throw new SAXException("Error reading node type stream", e); } }
/** * {@inheritDoc} */ @Override protected void initNodeTypes(NodeTypeManager ntm) throws RepositoryException { NodeTypeManagerImpl ntmi = (NodeTypeManagerImpl) ntm; try { InputStream is = null; try { is = this.getClass().getResourceAsStream(DEFAULT_NODETYPE_FILE); ntmi.registerNodeTypes(is, JackrabbitNodeTypeManager.TEXT_XML, true); } finally { if (is != null) { is.close(); } } } catch (IOException e) { throw new RepositoryException("Failed to init NodeTypes: " + e.getMessage(), e); } }
/** * {@inheritDoc} */ @Override protected void initNodeTypes(NodeTypeManager ntm) throws RepositoryException { NodeTypeManagerImpl ntmi = (NodeTypeManagerImpl) ntm; try { InputStream is = null; try { is = this.getClass().getResourceAsStream(DEFAULT_NODETYPE_FILE); ntmi.registerNodeTypes(is, JackrabbitNodeTypeManager.TEXT_XML, true); } finally { if (is != null) { is.close(); } } } catch (IOException e) { throw new RepositoryException("Failed to init NodeTypes: " + e.getMessage(), e); } }
@Override protected void doExecute(InstallContext installContext) throws RepositoryException, TaskExecutionException { final InputStream xmlStreamNew = getClass().getResourceAsStream("/mgnl-nodetypes/magnolia-forum-nodetypes.xml"); final Repository repository = ContentRepository.getRepository("forum"); final SimpleCredentials credentials = new SimpleCredentials(ContentRepository.REPOSITORY_USER, ContentRepository.REPOSITORY_PSWD.toCharArray()); final Session jcrSession = repository.login(credentials); try { try { final Workspace workspace = jcrSession.getWorkspace(); final NodeTypeManager ntMgr = workspace.getNodeTypeManager(); ((NodeTypeManagerImpl) ntMgr).registerNodeTypes(xmlStreamNew, NodeTypeManagerImpl.TEXT_XML, true); } catch (Exception e) { throw new RepositoryException(e.getMessage(), e); } } finally { IOUtils.closeQuietly(xmlStreamNew); jcrSession.logout(); } } }
nodeTypes.addAll(registerNodeTypes(newNodeTypeDefs)); Collection<NodeType> types = registerNodeTypes(nodeTypeDefs); return types.toArray(new NodeType[types.size()]);
nodeTypes.addAll(registerNodeTypes(newNodeTypeDefs)); Collection<NodeType> types = registerNodeTypes(nodeTypeDefs); return types.toArray(new NodeType[types.size()]);
result.addAll(registerNodeTypes(addedDefs));
result.addAll(registerNodeTypes(addedDefs));