Package org.apache.jackrabbit.core.data

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


   
    /**
     * {@inheritDoc}
     */
    public DataRecord getRecord(DataIdentifier identifier) throws DataStoreException {
        DataRecord record = getRecordIfStored(identifier);
        if (record == null) {
            throw new DataStoreException("Record not found: " + identifier);
        }
        return record;
    }
View Full Code Here


    @Override
    public String writeBlob(InputStream stream) throws IOException {
        boolean threw = true;
        try {
            checkNotNull(stream);
            DataRecord dr = writeStream(stream);
            String id = getBlobId(dr);
            threw = false;
            return id;
        } catch (DataStoreException e) {
            throw new IOException(e);
View Full Code Here

    }

    @Override
    public String getBlobId(String reference) {
        checkNotNull(reference);
        DataRecord record;
        try {
            record = delegate.getRecordFromReference(reference);
            if (record != null) {
                return getBlobId(record);
            }
View Full Code Here

        //Reference are not created for in memory record
        if(InMemoryDataRecord.isInstance(blobId)){
            return null;
        }

        DataRecord record;
        try {
            record = delegate.getRecord(new DataIdentifier(blobId));
            if(record != null){
                return record.getReference();
            }else{
                log.debug("No blob found for id [{}]", blobId);
            }
        } catch (DataStoreException e) {
            log.warn("Unable to access the blobId for  [{}]", blobId, e);
View Full Code Here

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

            throw new IOException(e);
        }
    }

    private DataRecord getDataRecord(String blobId) throws DataStoreException {
        DataRecord id;
        if(InMemoryDataRecord.isInstance(blobId)){
            id = InMemoryDataRecord.getInstance(blobId);
        }else{
            id = delegate.getRecord(new DataIdentifier(blobId));
        }
View Full Code Here

                break;
            }
            pos += l;
            len -= l;
        }
        DataRecord record;
        if (pos < maxMemorySize) {
            // shrink the buffer
            byte[] data = new byte[pos];
            System.arraycopy(buffer, 0, data, 0, pos);
            record = InMemoryDataRecord.getInstance(data);
View Full Code Here

    public void testGetInstance() throws Exception {
        int length = 400;
        byte[] data = new byte[length];
        new Random().nextBytes(data);

        DataRecord dr = InMemoryDataRecord.getInstance(data);
        assertTrue(InMemoryDataRecord.isInstance(dr.getIdentifier().toString()));

        DataRecord dr2 = InMemoryDataRecord.getInstance(dr.getIdentifier().toString());

        assertTrue(IOUtils.contentEquals(dr.getStream(), dr2.getStream()));
        assertTrue(IOUtils.contentEquals(dr.getStream(), new ByteArrayInputStream(data)));

        assertEquals(length, dr.getLength());
        assertEquals(dr2.getLength(), dr.getLength());

        assertEquals(dr, dr2);
    }
View Full Code Here

        DataStoreBlobStore ds = new DataStoreBlobStore(mockedDS);

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

        DataRecord dr = ds.addRecord(new ByteArrayInputStream(data));
        assertTrue(InMemoryDataRecord.isInstance(dr.getIdentifier().toString()));
        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()));

        //Check for BlobStore methods
        assertEquals(maxInlineSize, ds.getBlobLength(dr.getIdentifier().toString()));
        assertEquals(dr.getIdentifier().toString(), ds.writeBlob(new ByteArrayInputStream(data)));
    }
View Full Code Here

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

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

        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

TOP

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

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.