Package org.locationtech.geogig.api

Examples of org.locationtech.geogig.api.RevObject


    protected DiffEntry computeNext() {
        if (source.hasNext()) {
            DiffEntry next = source.next();
            if (next.getNewObject() != null) {
                NodeRef newObject = next.getNewObject();
                RevObject object = sourceRepo.command(RevObjectParse.class)
                        .setObjectId(newObject.getNode().getObjectId()).call().get();

                RevObject metadata = null;
                if (newObject.getMetadataId() != ObjectId.NULL) {
                    metadata = sourceRepo.command(RevObjectParse.class)
                            .setObjectId(newObject.getMetadataId()).call().get();
                }

                if (!destinationRepo.blobExists(object.getId())) {
                    destinationRepo.objectDatabase().put(object);
                }
                if (metadata != null && !destinationRepo.blobExists(metadata.getId())) {
                    destinationRepo.objectDatabase().put(metadata);
                }
            }
            return next;
        }
View Full Code Here


    @Test
    public void testReadOnlyHint() {
        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);
View Full Code Here

    @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);
View Full Code Here

    @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);
View Full Code Here

    @Test
    public void testReadOnlyHint3() {
        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);
View Full Code Here

    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);
    }
View Full Code Here

    }

    private void moveObject(final ObjectId objectId, final ObjectDatabase from,
            final ObjectDatabase to) {

        RevObject object = from.get(objectId);

        if (object instanceof RevTree) {
            Set<ObjectId> metadataIds = new HashSet<ObjectId>();
            moveTree(object.getId(), from, to, metadataIds);
            for (ObjectId metadataId : metadataIds) {
                moveObject(metadataId, from, to);
            }
        } else {
            moveObject(object, from, to);
View Full Code Here

     * @return the type of the object specified by the object id.
     * @throws IllegalArgumentException if the object doesn't exist
     */
    @Override
    protected TYPE _call() throws IllegalArgumentException {
        RevObject o = stagingDatabase().get(oid);
        return o.getType();
    }
View Full Code Here

    }

    @Override
    protected CharSequence _call() {
        Preconditions.checkState(object != null);
        RevObject revObject = object.get();

        TextSerializationFactory factory = new TextSerializationFactory();
        ObjectWriter<RevObject> writer = factory.createObjectWriter(revObject.getType());
        ByteArrayOutputStream output = new ByteArrayOutputStream();
        String s = "id\t" + revObject.getId().toString() + "\n";
        OutputStreamWriter streamWriter = new OutputStreamWriter(output, Charsets.UTF_8);
        try {
            streamWriter.write(s);
            streamWriter.flush();
            writer.write(revObject, output);
        } catch (IOException e) {
            throw new IllegalStateException("Cannot print object: " + revObject.getId().toString(),
                    e);
        }
        return output.toString();
    }
View Full Code Here

        return new AbstractIterator<RevObject>() {
            final Iterator<ObjectId> iterator = ids.iterator();

            @Override
            protected RevObject computeNext() {
                RevObject found = null;
                ObjectId id;
                byte[] raw;
                while (iterator.hasNext() && found == null) {
                    id = iterator.next();
                    raw = objects.get(id);
                    if (raw != null) {
                        try {
                            found = serializationFactory.createObjectReader().read(id,
                                    new LZFInputStream(new ByteArrayInputStream(raw)));
                        } catch (IOException e) {
                            throw Throwables.propagate(e);
                        }
                        listener.found(found.getId(), raw.length);
                    } else {
                        listener.notFound(id);
                    }
                }
                return found == null ? endOfData() : found;
View Full Code Here

TOP

Related Classes of org.locationtech.geogig.api.RevObject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.