Search in sources :

Example 1 with ImportHandler

use of org.apache.jackrabbit.jcr2spi.xml.ImportHandler in project jackrabbit by apache.

the class SessionImpl method getImportContentHandler.

/**
     * @see Session#getImportContentHandler(String, int)
     */
public ContentHandler getImportContentHandler(String parentAbsPath, int uuidBehavior) throws PathNotFoundException, ConstraintViolationException, VersionException, LockException, RepositoryException {
    checkSupportedOption(Repository.LEVEL_2_SUPPORTED);
    checkIsAlive();
    Path parentPath = getQPath(parentAbsPath);
    // NOTE: check if path corresponds to Node and is writable is performed
    // within the SessionImporter.
    Importer importer = new SessionImporter(parentPath, this, itemStateManager, uuidBehavior);
    return new ImportHandler(importer, getNamespaceResolver(), workspace.getNamespaceRegistry(), getNameFactory(), getPathFactory());
}
Also used : Path(org.apache.jackrabbit.spi.Path) ImportHandler(org.apache.jackrabbit.jcr2spi.xml.ImportHandler) Importer(org.apache.jackrabbit.jcr2spi.xml.Importer) SessionImporter(org.apache.jackrabbit.jcr2spi.xml.SessionImporter) SessionImporter(org.apache.jackrabbit.jcr2spi.xml.SessionImporter)

Example 2 with ImportHandler

use of org.apache.jackrabbit.jcr2spi.xml.ImportHandler in project jackrabbit by apache.

the class SessionImpl method importXML.

/**
     * @see javax.jcr.Session#importXML(String, java.io.InputStream, int)
     */
@Override
public void importXML(String parentAbsPath, InputStream in, int uuidBehavior) throws IOException, PathNotFoundException, ItemExistsException, ConstraintViolationException, VersionException, InvalidSerializedDataException, LockException, RepositoryException {
    // NOTE: checks are performed by 'getImportContentHandler'
    ImportHandler handler = (ImportHandler) getImportContentHandler(parentAbsPath, uuidBehavior);
    try {
        SAXParserFactory factory = SAXParserFactory.newInstance();
        factory.setNamespaceAware(true);
        factory.setFeature("http://xml.org/sax/features/namespace-prefixes", false);
        SAXParser parser = factory.newSAXParser();
        parser.parse(new InputSource(in), handler);
    } catch (SAXException se) {
        // check for wrapped repository exception
        Exception e = se.getException();
        if (e != null && e instanceof RepositoryException) {
            throw (RepositoryException) e;
        } else {
            String msg = "failed to parse XML stream";
            log.debug(msg);
            throw new InvalidSerializedDataException(msg, se);
        }
    } catch (ParserConfigurationException e) {
        throw new RepositoryException("SAX parser configuration error", e);
    } finally {
        // JCR-2903
        in.close();
    }
}
Also used : InputSource(org.xml.sax.InputSource) ImportHandler(org.apache.jackrabbit.jcr2spi.xml.ImportHandler) SAXParser(javax.xml.parsers.SAXParser) InvalidSerializedDataException(javax.jcr.InvalidSerializedDataException) RepositoryException(javax.jcr.RepositoryException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) ItemExistsException(javax.jcr.ItemExistsException) NameException(org.apache.jackrabbit.spi.commons.conversion.NameException) ConstraintViolationException(javax.jcr.nodetype.ConstraintViolationException) NoSuchWorkspaceException(javax.jcr.NoSuchWorkspaceException) VersionException(javax.jcr.version.VersionException) InvalidSerializedDataException(javax.jcr.InvalidSerializedDataException) InvalidItemStateException(javax.jcr.InvalidItemStateException) ItemNotFoundException(javax.jcr.ItemNotFoundException) LoginException(javax.jcr.LoginException) SAXException(org.xml.sax.SAXException) AccessControlException(java.security.AccessControlException) AccessDeniedException(javax.jcr.AccessDeniedException) PathNotFoundException(javax.jcr.PathNotFoundException) RepositoryException(javax.jcr.RepositoryException) LockException(javax.jcr.lock.LockException) NamespaceException(javax.jcr.NamespaceException) IOException(java.io.IOException) UnsupportedRepositoryOperationException(javax.jcr.UnsupportedRepositoryOperationException) MalformedPathException(org.apache.jackrabbit.spi.commons.conversion.MalformedPathException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) SAXParserFactory(javax.xml.parsers.SAXParserFactory) SAXException(org.xml.sax.SAXException)

Aggregations

ImportHandler (org.apache.jackrabbit.jcr2spi.xml.ImportHandler)2 IOException (java.io.IOException)1 AccessControlException (java.security.AccessControlException)1 AccessDeniedException (javax.jcr.AccessDeniedException)1 InvalidItemStateException (javax.jcr.InvalidItemStateException)1 InvalidSerializedDataException (javax.jcr.InvalidSerializedDataException)1 ItemExistsException (javax.jcr.ItemExistsException)1 ItemNotFoundException (javax.jcr.ItemNotFoundException)1 LoginException (javax.jcr.LoginException)1 NamespaceException (javax.jcr.NamespaceException)1 NoSuchWorkspaceException (javax.jcr.NoSuchWorkspaceException)1 PathNotFoundException (javax.jcr.PathNotFoundException)1 RepositoryException (javax.jcr.RepositoryException)1 UnsupportedRepositoryOperationException (javax.jcr.UnsupportedRepositoryOperationException)1 LockException (javax.jcr.lock.LockException)1 ConstraintViolationException (javax.jcr.nodetype.ConstraintViolationException)1 VersionException (javax.jcr.version.VersionException)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 SAXParser (javax.xml.parsers.SAXParser)1 SAXParserFactory (javax.xml.parsers.SAXParserFactory)1