Search in sources :

Example 1 with SessionImporter

use of org.apache.jackrabbit.core.xml.SessionImporter in project jackrabbit by apache.

the class SessionImpl method getImportContentHandler.

/**
 * {@inheritDoc}
 */
public ContentHandler getImportContentHandler(String parentAbsPath, int uuidBehavior) throws PathNotFoundException, ConstraintViolationException, VersionException, LockException, RepositoryException {
    // check sanity of this session
    sanityCheck();
    NodeImpl parent;
    try {
        Path p = getQPath(parentAbsPath).getNormalizedPath();
        if (!p.isAbsolute()) {
            throw new RepositoryException("not an absolute path: " + parentAbsPath);
        }
        parent = getItemManager().getNode(p);
    } catch (NameException e) {
        String msg = parentAbsPath + ": invalid path";
        log.debug(msg);
        throw new RepositoryException(msg, e);
    } catch (AccessDeniedException ade) {
        throw new PathNotFoundException(parentAbsPath);
    }
    // verify that parent node is checked-out, not locked and not protected
    // by either node type constraints nor by some retention or hold.
    int options = ItemValidator.CHECK_LOCK | ItemValidator.CHECK_CHECKED_OUT | ItemValidator.CHECK_CONSTRAINTS | ItemValidator.CHECK_HOLD | ItemValidator.CHECK_RETENTION;
    context.getItemValidator().checkModify(parent, options, Permission.NONE);
    SessionImporter importer = new SessionImporter(parent, this, uuidBehavior, context.getWorkspace().getConfig().getImportConfig());
    return new ImportHandler(importer, this);
}
Also used : Path(org.apache.jackrabbit.spi.Path) AccessDeniedException(javax.jcr.AccessDeniedException) NameException(org.apache.jackrabbit.spi.commons.conversion.NameException) IllegalNameException(org.apache.jackrabbit.spi.commons.conversion.IllegalNameException) ImportHandler(org.apache.jackrabbit.core.xml.ImportHandler) RepositoryException(javax.jcr.RepositoryException) PathNotFoundException(javax.jcr.PathNotFoundException) SessionImporter(org.apache.jackrabbit.core.xml.SessionImporter)

Example 2 with SessionImporter

use of org.apache.jackrabbit.core.xml.SessionImporter in project jackrabbit by apache.

the class UserImporterTest method doImport.

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);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) ParsingContentHandler(org.apache.jackrabbit.commons.xml.ParsingContentHandler) ImportHandler(org.apache.jackrabbit.core.xml.ImportHandler) SessionImporter(org.apache.jackrabbit.core.xml.SessionImporter)

Example 3 with SessionImporter

use of org.apache.jackrabbit.core.xml.SessionImporter in project jackrabbit by apache.

the class UserImporterTest method doImport.

// --------------------------------------------------------------------------
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);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) ParsingContentHandler(org.apache.jackrabbit.commons.xml.ParsingContentHandler) ImportHandler(org.apache.jackrabbit.core.xml.ImportHandler) SessionImporter(org.apache.jackrabbit.core.xml.SessionImporter)

Aggregations

ImportHandler (org.apache.jackrabbit.core.xml.ImportHandler)3 SessionImporter (org.apache.jackrabbit.core.xml.SessionImporter)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 InputStream (java.io.InputStream)2 ParsingContentHandler (org.apache.jackrabbit.commons.xml.ParsingContentHandler)2 AccessDeniedException (javax.jcr.AccessDeniedException)1 PathNotFoundException (javax.jcr.PathNotFoundException)1 RepositoryException (javax.jcr.RepositoryException)1 Path (org.apache.jackrabbit.spi.Path)1 IllegalNameException (org.apache.jackrabbit.spi.commons.conversion.IllegalNameException)1 NameException (org.apache.jackrabbit.spi.commons.conversion.NameException)1