@Override public void importXML(String parentAbsPath, InputStream in, int uuidBehavior) throws IOException, RepositoryException { try { ContentHandler handler = getImportContentHandler( checkNotNull(parentAbsPath), uuidBehavior); new ParsingContentHandler(handler).parse(in); } catch (SAXException e) { Throwable exception = e.getException(); if (exception instanceof RepositoryException) { throw (RepositoryException) exception; } else if (exception instanceof IOException) { throw (IOException) exception; } else { throw new InvalidSerializedDataException("XML parse error", e); } } finally { // JCR-2903 if (in != null) { try { in.close(); } catch (IOException ignore) { } } } }
/** * Parses the given input stream as an XML document and processes the * SAX events using the {@link ContentHandler} returned by * {@link Session#getImportContentHandler(String, int)}. * * @param parentAbsPath passed through * @param in input stream to be parsed as XML and imported * @param uuidBehavior passed through * @throws IOException if an I/O error occurs * @throws RepositoryException if another error occurs */ public void importXML( String parentAbsPath, InputStream in, int uuidBehavior) throws IOException, RepositoryException { ContentHandler handler = getImportContentHandler(parentAbsPath, uuidBehavior); new DefaultContentHandler(handler).parse(in); }
/** * Parses the given input stream as an XML document and processes the * SAX events using the {@link ContentHandler} returned by * {@link Workspace#getImportContentHandler(String, int)}. * * @param parentAbsPath passed through * @param in input stream to be parsed as XML and imported * @param uuidBehavior passed through * @throws IOException if an I/O error occurs * @throws RepositoryException if another error occurs */ public void importXML( String parentAbsPath, InputStream in, int uuidBehavior) throws IOException, RepositoryException { ContentHandler handler = getImportContentHandler(parentAbsPath, uuidBehavior); new DefaultContentHandler(handler).parse(in); }
@Override public void importXML(String parentAbsPath, InputStream in, int uuidBehavior) throws IOException, RepositoryException { try { ContentHandler handler = getImportContentHandler( checkNotNull(parentAbsPath), uuidBehavior); new ParsingContentHandler(handler).parse(in); } catch (SAXException e) { Throwable exception = e.getException(); if (exception instanceof RepositoryException) { throw (RepositoryException) exception; } else if (exception instanceof IOException) { throw (IOException) exception; } else { throw new InvalidSerializedDataException("XML parse error", e); } } finally { // JCR-2903 if (in != null) { try { in.close(); } catch (IOException ignore) { } } } }
@Override public void importXML(String parentAbsPath, InputStream in, int uuidBehavior) throws IOException, RepositoryException { try { ContentHandler handler = getImportContentHandler( checkNotNull(parentAbsPath), uuidBehavior); new ParsingContentHandler(handler).parse(in); } catch (SAXException e) { Throwable exception = e.getException(); if (exception instanceof RepositoryException) { throw (RepositoryException) exception; } else if (exception instanceof IOException) { throw (IOException) exception; } else { throw new InvalidSerializedDataException("XML parse error", e); } } finally { // JCR-2903 if (in != null) { try { in.close(); } catch (IOException ignore) { } } } }
ContentHandler handler = getImportContentHandler(parentAbsPath, uuidBehavior); new ParsingContentHandler(handler).parse(in); } catch (SAXException e) { Throwable exception = e.getException();
ContentHandler handler = getImportContentHandler(parentAbsPath, uuidBehavior); new ParsingContentHandler(handler).parse(in); } catch (SAXException e) { Throwable exception = e.getException();
ContentHandler handler = getImportContentHandler(parentAbsPath, uuidBehavior); new ParsingContentHandler(handler).parse(in); } catch (SAXException e) { Throwable exception = e.getException();
ContentHandler handler = getImportContentHandler(parentAbsPath, uuidBehavior); new ParsingContentHandler(handler).parse(in); } catch (SAXException e) { Throwable exception = e.getException();
ContentHandler handler = getImportContentHandler(parentAbsPath, uuidBehavior); new ParsingContentHandler(handler).parse(in); } catch (SAXException e) { Throwable exception = e.getException();
ContentHandler handler = getImportContentHandler(parentAbsPath, uuidBehavior); new ParsingContentHandler(handler).parse(in); } catch (SAXException e) { Throwable exception = e.getException();
@Override public void importXML(String parentAbsPath, InputStream in, int uuidBehavior) throws IOException, RepositoryException { ensureIsAlive(); try { ContentHandler handler = getImportContentHandler(parentAbsPath, uuidBehavior); new ParsingContentHandler(handler).parse(in); } catch (SAXException e) { Throwable exception = e.getException(); if (exception instanceof RepositoryException) { throw (RepositoryException) exception; } else if (exception instanceof IOException) { throw (IOException) exception; } else if (exception instanceof CommitFailedException) { throw ((CommitFailedException) exception).asRepositoryException(); } else { throw new InvalidSerializedDataException("XML parse error", e); } } finally { // JCR-2903 if (in != null) { try { in.close(); } catch (IOException ignore) { } } } }
@Override public void importXML(String parentAbsPath, InputStream in, int uuidBehavior) throws IOException, RepositoryException { ensureIsAlive(); try { ContentHandler handler = getImportContentHandler(parentAbsPath, uuidBehavior); new ParsingContentHandler(handler).parse(in); } catch (SAXException e) { Throwable exception = e.getException(); if (exception instanceof RepositoryException) { throw (RepositoryException) exception; } else if (exception instanceof IOException) { throw (IOException) exception; } else if (exception instanceof CommitFailedException) { throw ((CommitFailedException) exception).asRepositoryException(); } else { throw new InvalidSerializedDataException("XML parse error", e); } } finally { // JCR-2903 if (in != null) { try { in.close(); } catch (IOException ignore) { } } } }
@Override public void importXML(String parentAbsPath, InputStream in, int uuidBehavior) throws IOException, RepositoryException { ensureIsAlive(); try { ContentHandler handler = getImportContentHandler(parentAbsPath, uuidBehavior); new ParsingContentHandler(handler).parse(in); } catch (SAXException e) { Throwable exception = e.getException(); if (exception instanceof RepositoryException) { throw (RepositoryException) exception; } else if (exception instanceof IOException) { throw (IOException) exception; } else if (exception instanceof CommitFailedException) { throw ((CommitFailedException) exception).asRepositoryException(); } else { throw new InvalidSerializedDataException("XML parse error", e); } } finally { // JCR-2903 if (in != null) { try { in.close(); } catch (IOException ignore) { } } } }
private void doImport(NodeImpl target, String xml) throws IOException, SAXException, RepositoryException { InputStream in = new ByteArrayInputStream(xml.getBytes("UTF-8")); SessionImporter importer = new SessionImporter(target, sImpl, ImportUUIDBehavior.IMPORT_UUID_COLLISION_THROW, new PseudoConfig()); ImportHandler ih = new ImportHandler(importer, sImpl); new ParsingContentHandler(ih).parse(in); }
private void doImport(NodeImpl target, String xml, int uuidBehavior, int importBehavior) throws IOException, SAXException, RepositoryException { InputStream in = new ByteArrayInputStream(xml.getBytes("UTF-8")); SessionImporter importer = new SessionImporter(target, sImpl, uuidBehavior, new PseudoConfig(importBehavior)); ImportHandler ih = new ImportHandler(importer, sImpl); new ParsingContentHandler(ih).parse(in); }
private NodeImpl createPolicyNode(NodeImpl target) throws Exception { try { InputStream in = new ByteArrayInputStream(XML_POLICY_ONLY.getBytes("UTF-8")); SessionImporter importer = new SessionImporter(target, sImpl, ImportUUIDBehavior.IMPORT_UUID_COLLISION_THROW); ImportHandler ih = new ImportHandler(importer, sImpl); new ParsingContentHandler(ih).parse(in); return (NodeImpl) target.getNode("test/rep:policy"); } catch (Exception e) { e.printStackTrace(); throw e; } finally { superuser.refresh(false); if (superuser.nodeExists("/test")) { NodeIterator it = superuser.getRootNode().getNodes("test"); while (it.hasNext()) { it.nextNode().remove(); } } superuser.save(); } }
/** * Imports a resource-based ACL containing a single entry. * * @throws Exception */ public void testImportACLUnknownFail() throws Exception { try { NodeImpl target = (NodeImpl) testRootNode.addNode(nodeName1); target.addMixin("rep:AccessControllable"); InputStream in = new ByteArrayInputStream(XML_POLICY_TREE_4.getBytes("UTF-8")); PseudoConfig config = new PseudoConfig(); ((AccessControlImporter) config.getProtectedItemImporters().get(0)).setImportBehavior("default"); SessionImporter importer = new SessionImporter(target, sImpl, ImportUUIDBehavior.IMPORT_UUID_COLLISION_THROW, config); ImportHandler ih = new ImportHandler(importer, sImpl); try { new ParsingContentHandler(ih).parse(in); fail("importing unknown principal should fail based on configuration."); } catch (Exception e) { // ok } } finally { superuser.refresh(false); } }
/** * With the default importer that isn't able to deal with ACEs the * policy will be created but any ACEs will be ignored. * * @throws Exception */ public void testImportWithDefaultImporter() throws Exception { NodeImpl target = (NodeImpl) testRootNode; try { InputStream in = new ByteArrayInputStream(XML_POLICY_TREE.getBytes("UTF-8")); SessionImporter importer = new SessionImporter(target, sImpl, ImportUUIDBehavior.IMPORT_UUID_COLLISION_THROW, null); ImportHandler ih = new ImportHandler(importer, sImpl); new ParsingContentHandler(ih).parse(in); assertTrue(target.hasNode("test")); String path = target.getNode("test").getPath(); AccessControlManager acMgr = sImpl.getAccessControlManager(); AccessControlPolicy[] policies = acMgr.getPolicies(path); assertEquals(1, policies.length); assertTrue(policies[0] instanceof JackrabbitAccessControlList); AccessControlEntry[] entries = ((JackrabbitAccessControlList) policies[0]).getAccessControlEntries(); assertEquals(0, entries.length); } finally { superuser.refresh(false); } }
ImportUUIDBehavior.IMPORT_UUID_COLLISION_THROW, new PseudoConfig()); ImportHandler ih = new ImportHandler(importer, sImpl); new ParsingContentHandler(ih).parse(in); ImportUUIDBehavior.IMPORT_UUID_COLLISION_THROW, new PseudoConfig()); ih = new ImportHandler(importer, sImpl); new ParsingContentHandler(ih).parse(in);