Package org.apache.jackrabbit.mk.model

Examples of org.apache.jackrabbit.mk.model.Id


            byte[] rawId = null;
            if (rs.next()) {
                rawId = rs.getBytes(1);
            }
            stmt.close();
            return rawId == null ? null : new Id(rawId);
        } finally {
            con.close();
        }
    }
View Full Code Here


            con.close();
        }
    }

    public void readNode(StoredNode node) throws NotFoundException, Exception {
        Id id = node.getId();
        Connection con = cp.getConnection();
        try {
            PreparedStatement stmt = con.prepareStatement("select DATA from REVS where ID = ?");
            try {
                stmt.setBytes(1, id.getBytes());
                ResultSet rs = stmt.executeQuery();
                if (rs.next()) {
                    ByteArrayInputStream in = new ByteArrayInputStream(rs.getBytes(1));
                    node.deserialize(new BinaryBinding(in));
                } else {
                    throw new NotFoundException(id.toString());
                }
            } finally {
                stmt.close();
            }
        } finally {
View Full Code Here

                stmt.close();
            }
        } finally {
            con.close();
        }
        return new Id(rawId);
    }
View Full Code Here

                stmt.close();
            }
        } finally {
            con.close();
        }
        return new Id(rawId);
    }
View Full Code Here

    public Id readHead() throws Exception {
        DBObject entry = db.getCollection(HEAD_COLLECTION).findOne();
        if (entry == null) {
            return null;
        }
        return new Id((byte[]) entry.get(ID_FIELD));
    }
View Full Code Here

        // capped collection of size 1
        db.getCollection(HEAD_COLLECTION).insert(new BasicDBObject(ID_FIELD, id.getBytes()));
    }

    public void readNode(StoredNode node) throws NotFoundException, Exception {
        Id id = node.getId();
        BasicDBObject key = new BasicDBObject();
        if (BINARY_FORMAT) {
            key.put(ID_FIELD, id.getBytes());
        } else {
            key.put(ID_FIELD, id.toString());
        }
        final BasicDBObject nodeObject = (BasicDBObject) nodes.findOne(key);
        if (nodeObject != null) {
            Binding binding;
            if (BINARY_FORMAT) {
                byte[] bytes = (byte[]) nodeObject.get(DATA_FIELD);
                binding = new BinaryBinding(new ByteArrayInputStream(bytes));
            } else {
                binding = new DBObjectBinding(nodeObject);
            }
            node.deserialize(binding);
        } else {
            throw new NotFoundException(id.toString());
        }
    }
View Full Code Here

   
    public Id writeNode(Node node) throws Exception {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        node.serialize(new BinaryBinding(out));
        byte[] bytes = out.toByteArray();
        Id id = new Id(idFactory.createContentId(bytes));

        BasicDBObject nodeObject;
        if (BINARY_FORMAT) {
            nodeObject = new BasicDBObject(ID_FIELD, id.getBytes()).append(DATA_FIELD, bytes);
        } else {
            nodeObject = new BasicDBObject(ID_FIELD, id.toString());
            node.serialize(new DBObjectBinding(nodeObject));
        }
        try {
            nodes.insert(nodeObject);
        } catch (MongoException.DuplicateKey ignore) {
View Full Code Here

    public Id writeCNEMap(ChildNodeEntriesMap map) throws Exception {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        map.serialize(new BinaryBinding(out));
        byte[] bytes = out.toByteArray();
        Id id = new Id(idFactory.createContentId(bytes));

        BasicDBObject mapObject;
        if (BINARY_FORMAT) {
            mapObject = new BasicDBObject(ID_FIELD, id.getBytes()).append(DATA_FIELD, bytes);
        } else {
            mapObject = new BasicDBObject(ID_FIELD, id.toString());
            map.serialize(new DBObjectBinding(mapObject));
        }
        try {
            cneMaps.insert(mapObject);
        } catch (MongoException.DuplicateKey ignore) {
View Full Code Here

    }

    @Test
    public void testOldNodeIsSwept() throws Exception {
        MutableNode node = new MutableNode(null, "/");
        Id id = pm.writeNode(node);

        Thread.sleep(1);
        pm.start();
        pm.sweep();
       
View Full Code Here

    }

    @Test
    public void testMarkedNodeIsNotSwept() throws Exception {
        MutableNode node = new MutableNode(null, "/");
        Id id = pm.writeNode(node);

        // small delay needed
        Thread.sleep(100);
       
        pm.start();
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.mk.model.Id

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.