Search in sources :

Example 26 with SirixException

use of org.sirix.exception.SirixException in project sirix by sirixdb.

the class DBNode method setAttribute.

private DBNode setAttribute(XdmNodeWriteTrx wtx, Node<?> attribute) throws DocumentException {
    if (wtx.isElement()) {
        final String value = attribute.getValue().asStr().stringValue();
        final QNm name = attribute.getName();
        try {
            wtx.insertAttribute(name, value);
        } catch (final SirixException e) {
            throw new DocumentException(e);
        }
        return new DBNode(mRtx, mCollection);
    }
    throw new DocumentException("No element node selected!");
}
Also used : QNm(org.brackit.xquery.atomic.QNm) DocumentException(org.brackit.xquery.xdm.DocumentException) SirixException(org.sirix.exception.SirixException)

Example 27 with SirixException

use of org.sirix.exception.SirixException in project sirix by sirixdb.

the class DBNode method insertBefore.

private DBNode insertBefore(XdmNodeWriteTrx wtx, Node<?> node) throws DocumentException {
    try {
        final SubtreeBuilder builder = new SubtreeBuilder(mCollection, wtx, Insert.ASLEFTSIBLING, Collections.<SubtreeListener<? super AbstractTemporalNode<DBNode>>>emptyList());
        node.parse(builder);
        wtx.moveTo(builder.getStartNodeKey());
    } catch (final SirixException e) {
        throw new DocumentException(e);
    }
    return new DBNode(wtx, mCollection);
}
Also used : DocumentException(org.brackit.xquery.xdm.DocumentException) SirixException(org.sirix.exception.SirixException)

Example 28 with SirixException

use of org.sirix.exception.SirixException in project sirix by sirixdb.

the class DBNode method replaceWith.

private DBNode replaceWith(XdmNodeWriteTrx wtx, Node<?> node) throws DocumentException {
    if (node instanceof DBNode) {
        final DBNode other = (DBNode) node;
        try {
            final XdmNodeReadTrx rtx = other.getTrx();
            rtx.moveTo(other.getNodeKey());
            wtx.replaceNode(rtx);
        } catch (final SirixException e) {
            throw new DocumentException(e.getCause());
        }
        return new DBNode(wtx, mCollection);
    } else {
        final SubtreeBuilder builder = createBuilder(wtx);
        node.parse(builder);
        try {
            return replace(builder.getStartNodeKey(), wtx);
        } catch (final SirixException e) {
            throw new DocumentException(e.getCause());
        }
    }
}
Also used : XdmNodeReadTrx(org.sirix.api.XdmNodeReadTrx) DocumentException(org.brackit.xquery.xdm.DocumentException) SirixException(org.sirix.exception.SirixException)

Example 29 with SirixException

use of org.sirix.exception.SirixException in project sirix by sirixdb.

the class DBNode method prepend.

private DBNode prepend(XdmNodeWriteTrx wtx, SubtreeParser parser) throws DocumentException {
    try {
        parser.parse(new SubtreeBuilder(mCollection, wtx, Insert.ASFIRSTCHILD, Collections.<SubtreeListener<? super AbstractTemporalNode<DBNode>>>emptyList()));
        moveRtx();
        wtx.moveToFirstChild();
    } catch (final SirixException e) {
        throw new DocumentException(e);
    }
    return new DBNode(wtx, mCollection);
}
Also used : SubtreeListener(org.brackit.xquery.node.parser.SubtreeListener) DocumentException(org.brackit.xquery.xdm.DocumentException) AbstractTemporalNode(org.brackit.xquery.xdm.AbstractTemporalNode) SirixException(org.sirix.exception.SirixException)

Example 30 with SirixException

use of org.sirix.exception.SirixException in project sirix by sirixdb.

the class DBNode method createBuilder.

private SubtreeBuilder createBuilder(final XdmNodeWriteTrx wtx) throws DocumentException {
    SubtreeBuilder builder = null;
    try {
        if (wtx.hasLeftSibling()) {
            wtx.moveToLeftSibling();
            builder = new SubtreeBuilder(mCollection, wtx, Insert.ASRIGHTSIBLING, Collections.<SubtreeListener<? super AbstractTemporalNode<DBNode>>>emptyList());
        } else {
            wtx.moveToParent();
            builder = new SubtreeBuilder(mCollection, wtx, Insert.ASFIRSTCHILD, Collections.<SubtreeListener<? super AbstractTemporalNode<DBNode>>>emptyList());
        }
    } catch (final SirixException e) {
        throw new DocumentException(e);
    }
    return builder;
}
Also used : SubtreeListener(org.brackit.xquery.node.parser.SubtreeListener) DocumentException(org.brackit.xquery.xdm.DocumentException) AbstractTemporalNode(org.brackit.xquery.xdm.AbstractTemporalNode) SirixException(org.sirix.exception.SirixException)

Aggregations

SirixException (org.sirix.exception.SirixException)74 DocumentException (org.brackit.xquery.xdm.DocumentException)25 IOException (java.io.IOException)18 Database (org.sirix.api.Database)17 JaxRxException (org.jaxrx.core.JaxRxException)14 NodeReadTrx (org.sirix.api.NodeReadTrx)13 XdmNodeWriteTrx (org.sirix.api.XdmNodeWriteTrx)13 SessionConfiguration (org.sirix.access.conf.SessionConfiguration)12 Session (org.sirix.api.Session)12 ResourceManager (org.sirix.api.ResourceManager)10 WebApplicationException (javax.ws.rs.WebApplicationException)8 Path (java.nio.file.Path)7 XMLStreamException (javax.xml.stream.XMLStreamException)7 QNm (org.brackit.xquery.atomic.QNm)7 XdmNodeReadTrx (org.sirix.api.XdmNodeReadTrx)6 OutputStream (java.io.OutputStream)5 SubtreeListener (org.brackit.xquery.node.parser.SubtreeListener)5 AbstractTemporalNode (org.brackit.xquery.xdm.AbstractTemporalNode)5 StreamingOutput (javax.ws.rs.core.StreamingOutput)4 DatabaseConfiguration (org.sirix.access.conf.DatabaseConfiguration)4