@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) { } } } }
@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();
@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);
/** * Make sure repo-level acl is not imported below any other node than the * root node. * * @throws Exception */ public void testImportRepoACLAtTestNode() throws Exception { NodeImpl target = (NodeImpl) testRootNode.addNode("test"); target.addMixin("rep:RepoAccessControllable"); AccessControlManager acMgr = sImpl.getAccessControlManager(); try { InputStream in = new ByteArrayInputStream(XML_REPO_POLICY_TREE.getBytes("UTF-8")); SessionImporter importer = new SessionImporter(target, sImpl, ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW, new PseudoConfig()); ImportHandler ih = new ImportHandler(importer, sImpl); new ParsingContentHandler(ih).parse(in); AccessControlPolicy[] policies = acMgr.getPolicies(null); assertEquals(0, policies.length); assertTrue(target.hasNode("rep:repoPolicy")); assertFalse(target.hasNode("rep:repoPolicy/allow0")); Node n = target.getNode("rep:repoPolicy"); assertEquals("rep:RepoAccessControllable", n.getDefinition().getDeclaringNodeType().getName()); } 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()); ImportHandler ih = new ImportHandler(importer, sImpl); new ParsingContentHandler(ih).parse(in);
ImportUUIDBehavior.IMPORT_UUID_COLLISION_THROW, new PseudoConfig()); ImportHandler ih = new ImportHandler(importer, sImpl); new ParsingContentHandler(ih).parse(in);
/** * Imports an empty resource-based ACL for a policy that already exists. * * @throws Exception */ public void testImportEmptyExistingPolicy() throws Exception { NodeImpl target = (NodeImpl) testRootNode; target = (NodeImpl) target.addNode("test", "test:sameNameSibsFalseChildNodeDefinition"); AccessControlManager acMgr = sImpl.getAccessControlManager(); for (AccessControlPolicyIterator it = acMgr.getApplicablePolicies(target.getPath()); it.hasNext();) { AccessControlPolicy policy = it.nextAccessControlPolicy(); if (policy instanceof AccessControlList) { acMgr.setPolicy(target.getPath(), policy); } } try { InputStream in = new ByteArrayInputStream(XML_POLICY_ONLY.getBytes("UTF-8")); SessionImporter importer = new SessionImporter(target, sImpl, ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW, new PseudoConfig()); ImportHandler ih = new ImportHandler(importer, sImpl); new ParsingContentHandler(ih).parse(in); AccessControlPolicy[] policies = acMgr.getPolicies(target.getPath()); assertEquals(1, policies.length); assertTrue(policies[0] instanceof JackrabbitAccessControlList); AccessControlEntry[] entries = ((JackrabbitAccessControlList) policies[0]).getAccessControlEntries(); assertEquals(0, entries.length); } finally { superuser.refresh(false); } }