use of org.brackit.xquery.xdm.DocumentException in project sirix by sirixdb.
the class IndexDef method toString.
@Override
public String toString() {
try {
ByteArrayOutputStream buf = new ByteArrayOutputStream();
SubtreePrinter.print(materialize(), new PrintStream(buf));
return buf.toString();
} catch (DocumentException e) {
return e.getMessage();
}
}
use of org.brackit.xquery.xdm.DocumentException in project sirix by sirixdb.
the class DBCollection method getDocument.
@Override
public DBNode getDocument(@Nonnegative final int revision) throws DocumentException {
final List<Path> resources = mDatabase.listResources();
if (resources.size() > 1) {
throw new DocumentException("More than one document stored in database/collection!");
}
try {
final ResourceManager session = mDatabase.getResourceManager(ResourceManagerConfiguration.newBuilder(resources.get(0).getFileName().toString()).build());
final int version = revision == -1 ? session.getMostRecentRevisionNumber() : revision;
final XdmNodeReadTrx rtx = session.beginNodeReadTrx(version);
return new DBNode(rtx, this);
} catch (final SirixException e) {
throw new DocumentException(e.getCause());
}
}
use of org.brackit.xquery.xdm.DocumentException in project sirix by sirixdb.
the class DBNode method insertBefore.
private DBNode insertBefore(XdmNodeWriteTrx wtx, SubtreeParser parser) throws DocumentException {
try {
final SubtreeBuilder builder = new SubtreeBuilder(mCollection, wtx, Insert.ASLEFTSIBLING, Collections.<SubtreeListener<? super AbstractTemporalNode<DBNode>>>emptyList());
parser.parse(builder);
return new DBNode(wtx.moveTo(builder.getStartNodeKey()).get(), mCollection);
} catch (final SirixException e) {
throw new DocumentException(e);
}
}
use of org.brackit.xquery.xdm.DocumentException in project sirix by sirixdb.
the class DBNode method insertAfter.
private DBNode insertAfter(XdmNodeWriteTrx wtx, Node<?> node) throws DocumentException {
try {
final SubtreeBuilder builder = new SubtreeBuilder(mCollection, wtx, Insert.ASRIGHTSIBLING, 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);
}
use of org.brackit.xquery.xdm.DocumentException in project sirix by sirixdb.
the class DBNode method delete.
@Override
public void delete() throws DocumentException {
if (mIsWtx) {
moveRtx();
final XdmNodeWriteTrx wtx = (XdmNodeWriteTrx) mRtx;
try {
wtx.remove();
} catch (final SirixException e) {
wtx.rollback();
wtx.close();
throw new DocumentException(e);
}
} else {
final XdmNodeWriteTrx wtx = getWtx();
try {
wtx.remove();
} catch (final SirixException e) {
wtx.rollback();
wtx.close();
throw new DocumentException(e);
}
}
}
Aggregations