Package org.apache.jackrabbit.core.data

Examples of org.apache.jackrabbit.core.data.DataIdentifier


    @Override
    public boolean deleteChunks(List<String> chunkIds, long maxLastModifiedTime) throws Exception {
        if (delegate instanceof MultiDataStoreAware) {
            for (String chunkId : chunkIds) {
                DataIdentifier identifier = new DataIdentifier(chunkId);
                DataRecord dataRecord = delegate.getRecord(identifier);
                boolean success = (maxLastModifiedTime <= 0)
                        || dataRecord.getLastModified() <= maxLastModifiedTime;
                if (!success) {
                    return false;
View Full Code Here


    private DataRecord getDataRecord(String blobId) throws DataStoreException {
        DataRecord id;
        if(InMemoryDataRecord.isInstance(blobId)){
            id = InMemoryDataRecord.getInstance(blobId);
        }else{
            id = delegate.getRecord(new DataIdentifier(blobId));
        }
        checkNotNull(id, "No DataRecord found for blodId [%s]", blobId);
        return id;
    }
View Full Code Here

        int actualSize = maxInlineSize + 10;

        byte[] data = new byte[actualSize];
        new Random().nextBytes(data);

        DataIdentifier testDI = new DataIdentifier("test");
        DataRecord testDR = new ByteArrayDataRecord(data, testDI, "testReference");

        DataStore mockedDS = mock(DataStore.class);
        when(mockedDS.getMinRecordLength()).thenReturn(maxInlineSize);
        when(mockedDS.getRecord(testDI)).thenReturn(testDR);
        when(mockedDS.getRecordIfStored(testDI)).thenReturn(testDR);
        when(mockedDS.addRecord(any(InputStream.class))).thenReturn(testDR);
        DataStoreBlobStore ds = new DataStoreBlobStore(mockedDS);


        DataRecord dr = ds.addRecord(new ByteArrayInputStream(data));
        assertFalse(InMemoryDataRecord.isInstance(dr.getIdentifier().toString()));
        assertEquals(testDI, dr.getIdentifier());
        assertTrue(IOUtils.contentEquals(new ByteArrayInputStream(data), dr.getStream()));
        assertTrue(IOUtils.contentEquals(new ByteArrayInputStream(data),
                new BlobStoreInputStream(ds, dr.getIdentifier().toString(), 0)));

        assertEquals(dr, ds.getRecordIfStored(dr.getIdentifier()));
        assertEquals(dr, ds.getRecord(dr.getIdentifier()));

        assertEquals(actualSize, ds.getBlobLength(dr.getIdentifier().toString()));
        assertEquals(testDI.toString(), ds.writeBlob(new ByteArrayInputStream(data)));
    }
View Full Code Here

    @Test
    public void testReference() throws DataStoreException, IOException {
        String reference = "testReference";
        String blobId = "test";
        DataIdentifier testDI = new DataIdentifier(blobId);
        DataRecord testDR = new ByteArrayDataRecord("foo".getBytes(), testDI, reference);

        DataStore mockedDS = mock(DataStore.class);
        when(mockedDS.getRecordFromReference(reference)).thenReturn(testDR);
        when(mockedDS.getRecord(testDI)).thenReturn(testDR);
View Full Code Here

        assertNull(ds.getReference(inMemBlobId));
    }

    @Test
    public void testGetAllChunks() throws Exception{
        DataIdentifier d10 = new DataIdentifier("d-10");
        DataIdentifier d20 = new DataIdentifier("d-20");
        DataIdentifier d30 = new DataIdentifier("d-30");
        List<DataIdentifier> dis = ImmutableList.of(d10, d20, d30);

        DataStore mockedDS = mock(DataStore.class);
        when(mockedDS.getAllIdentifiers()).thenReturn(dis.iterator());
        when(mockedDS.getRecord(new DataIdentifier("d-10"))).thenReturn(new TimeDataRecord(d10));
        when(mockedDS.getRecord(new DataIdentifier("d-20"))).thenReturn(new TimeDataRecord(d20));
        when(mockedDS.getRecord(new DataIdentifier("d-30"))).thenReturn(new TimeDataRecord(d30));
        DataStoreBlobStore ds = new DataStoreBlobStore(mockedDS);

        Iterator<String> chunks = ds.getAllChunkIds(25);
        Set<String> expected = Sets.newHashSet("d-10","d-20");
        assertEquals(expected, Sets.newHashSet(chunks));
View Full Code Here

        byte[] data2 = new byte[Segment.MEDIUM_LIMIT + 1];
        new Random().nextBytes(data2);
        Blob b2 = testCreateAndRead(nodeStore.createBlob(new ByteArrayInputStream(data2)));
        assertTrue(b2 instanceof SegmentBlob);
        assertNotNull(b2.getReference());
        assertNotNull(dbs.getRecordIfStored(new DataIdentifier(((SegmentBlob) b2).getBlobId())));
    }
View Full Code Here

    }

    public Value createValue(Binary binary) {
        try {
            if (binary instanceof BLOBInDataStore) {
                DataIdentifier identifier = ((BLOBInDataStore) binary).getDataIdentifier();
                InternalValue value = InternalValue.getInternalValue(identifier, store);
                if (value != null) {
                    // if the value is already in this data store
                    return new BinaryValueImpl(value.getBLOBFileValue());
                }
View Full Code Here

            case PropertyType.BINARY:
                InternalValue result;
                BLOBFileValue blob = null;
                if (value instanceof BinaryValueImpl) {
                    BinaryValueImpl bin = (BinaryValueImpl) value;
                    DataIdentifier identifier = bin.getDataIdentifier();
                    if (identifier != null) {
                        // access the record to ensure it is not garbage collected
                        if (store.getRecordIfStored(identifier) != null) {
                            // it exists - so we don't need to stream it again
                            // but we need to create a new object because the original
View Full Code Here

        return PREFIX + identifier;
    }

    static BLOBInDataStore getInstance(DataStore store, String s) {
        String id = s.substring(PREFIX.length());
        DataIdentifier identifier = new DataIdentifier(id);
        return new BLOBInDataStore(store, identifier);
    }
View Full Code Here

        return new BLOBInDataStore(store, identifier);
    }

    static BLOBInDataStore getInstance(DataStore store, InputStream in) throws DataStoreException {
        DataRecord rec = store.addRecord(in);
        DataIdentifier identifier = rec.getIdentifier();
        if (auditLogger.isDebugEnabled()) {
            auditLogger.debug("Stored {} to DataStore ({})", identifier, rec.getLength());
        }
        return new BLOBInDataStore(store, identifier);
    }
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.core.data.DataIdentifier

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.