Search in sources :

Example 31 with SirixException

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

the class DBStore method create.

public TemporalCollection<?> create(final String collName, final Optional<String> optResName, final SubtreeParser parser) throws DocumentException {
    final DatabaseConfiguration dbConf = new DatabaseConfiguration(mLocation.resolve(collName));
    try {
        Databases.truncateDatabase(dbConf);
        Databases.createDatabase(dbConf);
        try (final Database database = Databases.openDatabase(dbConf.getFile())) {
            mDatabases.add(database);
            final String resName = optResName.isPresent() ? optResName.get() : new StringBuilder(3).append("resource").append(database.listResources().size() + 1).toString();
            database.createResource(ResourceConfiguration.newBuilder(resName, dbConf).useDeweyIDs(true).useTextCompression(true).buildPathSummary(true).storageType(mStorageType).build());
            final DBCollection collection = new DBCollection(collName, database);
            mCollections.put(database, collection);
            try (final ResourceManager resource = database.getResourceManager(new ResourceManagerConfiguration.Builder(resName).build());
                final XdmNodeWriteTrx wtx = resource.beginNodeWriteTrx()) {
                parser.parse(new SubtreeBuilder(collection, wtx, Insert.ASFIRSTCHILD, Collections.<SubtreeListener<? super AbstractTemporalNode<DBNode>>>emptyList()));
                wtx.commit();
            }
            return collection;
        }
    } catch (final SirixException e) {
        throw new DocumentException(e.getCause());
    }
}
Also used : XdmNodeWriteTrx(org.sirix.api.XdmNodeWriteTrx) SubtreeListener(org.brackit.xquery.node.parser.SubtreeListener) DatabaseConfiguration(org.sirix.access.conf.DatabaseConfiguration) AbstractTemporalNode(org.brackit.xquery.xdm.AbstractTemporalNode) ResourceManager(org.sirix.api.ResourceManager) DocumentException(org.brackit.xquery.xdm.DocumentException) Database(org.sirix.api.Database) SirixException(org.sirix.exception.SirixException)

Example 32 with SirixException

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

the class SubtreeBuilder method attribute.

@Override
public void attribute(final QNm name, final Atomic value) throws DocumentException {
    try {
        mWtx.insertAttribute(name, value.stringValue());
        mWtx.moveToParent();
        mSubtreeProcessor.notifyAttribute(new DBNode(mWtx, mCollection));
    } catch (final SirixException e) {
        throw new DocumentException(e.getCause());
    }
}
Also used : DocumentException(org.brackit.xquery.xdm.DocumentException) SirixException(org.sirix.exception.SirixException)

Example 33 with SirixException

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

the class SubtreeBuilder method startElement.

@Override
public void startElement(final QNm name) throws DocumentException {
    try {
        processStartTag(name);
        if (mFirst) {
            mFirst = false;
            mStartNodeKey = mWtx.getNodeKey();
        }
        final DBNode node = new DBNode(mWtx, mCollection);
        mParents.push(node);
        mSubtreeProcessor.notifyStartElement(node);
    } catch (final SirixException e) {
        throw new DocumentException(e.getCause());
    }
}
Also used : DocumentException(org.brackit.xquery.xdm.DocumentException) SirixException(org.sirix.exception.SirixException)

Example 34 with SirixException

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

the class SubtreeBuilder method processingInstruction.

@Override
public void processingInstruction(final QNm target, final Atomic content) throws DocumentException {
    try {
        processPI(content.asStr().stringValue(), target.getLocalName());
        mSubtreeProcessor.notifyProcessingInstruction(new DBNode(mWtx, mCollection));
    } catch (final SirixException e) {
        throw new DocumentException(e.getCause());
    }
}
Also used : DocumentException(org.brackit.xquery.xdm.DocumentException) SirixException(org.sirix.exception.SirixException)

Example 35 with SirixException

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

the class SubtreeBuilder method comment.

@Override
public void comment(final Atomic content) throws DocumentException {
    try {
        processComment(content.asStr().stringValue());
        if (mFirst) {
            mFirst = false;
            mStartNodeKey = mWtx.getNodeKey();
        }
        mSubtreeProcessor.notifyComment(new DBNode(mWtx, mCollection));
    } catch (final SirixException e) {
        throw new DocumentException(e.getCause());
    }
}
Also used : DocumentException(org.brackit.xquery.xdm.DocumentException) 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