use of org.locationtech.geogig.api.RevObject in project GeoGig by boundlessgeo.
the class JEObjectDatabaseTest method testReadOnlyHint2.
@Test
public void testReadOnlyHint2() {
hints.set(Hints.OBJECTS_READ_ONLY, Boolean.TRUE);
db = createDb();
RevObject obj = RevTree.EMPTY;
try {
db.put(obj);
fail("Expected UOE on read only hint");
} catch (UnsupportedOperationException e) {
assertTrue(true);
}
db.close();
hints.set(Hints.OBJECTS_READ_ONLY, Boolean.FALSE);
db = createDb();
Assert.assertTrue(db.put(obj));
}
use of org.locationtech.geogig.api.RevObject in project GeoGig by boundlessgeo.
the class JEObjectDatabaseTest method testMultipleInstances.
public void testMultipleInstances() {
ObjectDatabase db1 = createDb();
ObjectDatabase db2 = createDb();
RevObject obj = RevTree.EMPTY;
assertTrue(db1.put(obj));
db1.close();
assertFalse(db2.put(obj));
db2.close();
RevObject revObject = db.get(obj.getId());
assertEquals(obj, revObject);
}
use of org.locationtech.geogig.api.RevObject in project GeoGig by boundlessgeo.
the class JEObjectDatabaseTest method testReadOnlyHintPreservedOnReopen.
@Test
public void testReadOnlyHintPreservedOnReopen() {
hints.set(Hints.OBJECTS_READ_ONLY, Boolean.TRUE);
db = createDb();
RevObject obj = RevTree.EMPTY;
try {
db.put(obj);
fail("Expected UOE on read only hint");
} catch (UnsupportedOperationException e) {
assertTrue(true);
}
db.close();
db.open();
try {
db.put(obj);
fail("Expected UOE on read only hint");
} catch (UnsupportedOperationException e) {
assertTrue(true);
}
}
use of org.locationtech.geogig.api.RevObject in project GeoGig by boundlessgeo.
the class MongoObjectDatabase method getAll.
@Override
public Iterator<RevObject> getAll(final Iterable<ObjectId> ids, final BulkOpListener listener) {
return new AbstractIterator<RevObject>() {
final Iterator<ObjectId> queryIds = ids.iterator();
@Override
protected RevObject computeNext() {
RevObject obj = null;
while (obj == null) {
if (!queryIds.hasNext()) {
return endOfData();
}
ObjectId id = queryIds.next();
obj = getIfPresent(id);
if (obj == null) {
listener.notFound(id);
} else {
listener.found(obj.getId(), null);
}
}
return obj == null ? endOfData() : obj;
}
};
}
use of org.locationtech.geogig.api.RevObject in project GeoGig by boundlessgeo.
the class MongoObjectDatabase method toBytes.
private byte[] toBytes(RevObject object) {
ObjectWriter<RevObject> writer = serializers.createObjectWriter(object.getType());
ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
LZFOutputStream cOut = new LZFOutputStream(byteStream);
try {
writer.write(object, cOut);
} catch (IOException e) {
throw new RuntimeException(e);
}
try {
cOut.close();
} catch (IOException e) {
throw Throwables.propagate(e);
}
return byteStream.toByteArray();
}
Aggregations