Package org.lilyproject.repository.api

Examples of org.lilyproject.repository.api.Blob


        FieldTypeEntry fieldTypeEntry = typeManager.newFieldTypeEntry(fieldType.getId(), true);
        recordType.addFieldTypeEntry(fieldTypeEntry);
        recordType = typeManager.createRecordType(recordType);

        byte[] bytes = Bytes.toBytes("someBytes");
        Blob blob = writeBlob(bytes, "aMediaType", "testCreate");

        Record record = repository.newRecord();
        record.setRecordType(recordType.getName(), null);
        record.setField(fieldName, blob);
        record = repository.create(record);

        Record record2 = repository.newRecord();
        record2.setRecordType(recordType.getName(), null);
        record2.setField(fieldName, blob);
        record2 = repository.create(record2); // For an inline record this succeeds

        byte[] bytesLarge = new byte[3000];
        random.nextBytes(bytesLarge);
        Blob largeBlob = writeBlob(bytesLarge, "largeBlob", "testCreate");

        Record record3 = repository.newRecord();
        record3.setRecordType(recordType.getName(), null);
        record3.setField(fieldName, largeBlob);
        record3 = repository.create(record3);
View Full Code Here


        recordType.addFieldTypeEntry(fieldTypeEntry);
        recordType = typeManager.createRecordType(recordType);

        byte[] bytes = new byte[size];
        random.nextBytes(bytes);
        Blob blob = writeBlob(bytes, "aMediaType", "testUpdateNonVersionedBlob");

        byte[] bytes2 = new byte[size];
        random.nextBytes(bytes2);
        Blob blob2 = writeBlob(bytes2, "aMediaType", "testUpdateNonVersionedBlob2");

        Record record = repository.newRecord();
        record.setRecordType(recordType.getName(), null);
        record.setField(fieldName, blob);
        record = repository.create(record);
View Full Code Here

        recordType.addFieldTypeEntry(fieldTypeEntry);
        recordType = typeManager.createRecordType(recordType);

        byte[] bytes = new byte[size];
        random.nextBytes(bytes);
        Blob blob = writeBlob(bytes, "aMediaType", "testDeleteNonVersionedBlob");

        Record record = repository.newRecord();
        record.setRecordType(recordType.getName(), null);
        record.setField(fieldName, blob);
        record = repository.create(record);
View Full Code Here

        recordType.addFieldTypeEntry(fieldTypeEntry);
        recordType = typeManager.createRecordType(recordType);

        byte[] bytes = new byte[size];
        random.nextBytes(bytes);
        Blob blob = writeBlob(bytes, "aMediaType", "testUpdateMutableBlob");

        byte[] bytes2 = new byte[size];
        random.nextBytes(bytes2);
        Blob blob2 = writeBlob(bytes2, "aMediaType", "testUpdateMutableBlob2");

        Record record = repository.newRecord();
        record.setRecordType(recordType.getName(), null);
        record.setField(fieldName, blob);
        record = repository.create(record);
View Full Code Here

        recordType.addFieldTypeEntry(fieldTypeEntry);
        recordType = typeManager.createRecordType(recordType);

        byte[] bytes = new byte[size];
        random.nextBytes(bytes);
        Blob blob = writeBlob(bytes, "aMediaType", "testDeleteMutableBlob");

        byte[] bytes2 = new byte[size];
        random.nextBytes(bytes2);
        Blob blob2 = writeBlob(bytes2, "aMediaType", "testDeleteMutableBlob2");

        Record record = repository.newRecord();
        record.setRecordType(recordType.getName(), null);
        record.setField(fieldName, blob);
        record = repository.create(record);
View Full Code Here


        // Upload a blob that, based upon the current default config, should end up in HBase
        //  (> 5000 bytes and < 200000 bytes)
        byte[] data = makeBlobData(10000);
        Blob blob = new Blob("application/octet-stream", (long) data.length, null);
        OutputStream blobStream = repository.getOutputStream(blob);
        IOUtils.copy(new ByteArrayInputStream(data), blobStream);
        blobStream.close();
        assertTrue(blob.getValue() != null);

        // Create a record with this blob
        Record record = repository.newRecord();
        record.setRecordType(new QName(NS, "file"));
        record.setField(new QName(NS, "data"), blob);
View Full Code Here

                Bytes.toBytes("bytes2")), new ByteArray(Bytes.toBytes("bbb")));
    }

    @Test
    public void testBlobType() throws Exception {
        Blob blob1 = new Blob("text/html", Long.MAX_VALUE, null);
        writeBlob(blob1, Bytes.toBytes("aKey"));
        Blob blob2 = new Blob("image/jpeg", Long.MIN_VALUE, "images/image.jpg");
        writeBlob(blob2, Bytes.toBytes("anotherKey"));
        Blob blob3 = new Blob("text/plain", Long.valueOf(0), null);
        writeBlob(blob3, Bytes.toBytes("thirdKey"));

        runValueTypeTests("blobTypeId", "BLOB", blob1, blob2, blob3);
    }
View Full Code Here

        Long size = dataInput.readLong();
        if (size == -1) {
            size = null;
        }
        String filename = dataInput.readUTF();
        return new Blob(key, mediaType, size, filename);
    }
View Full Code Here

     * <p> IMPORTANT: Any changes on this format has an impact on the {@link ContainsValueComparator}
     */
    @Override
    public void write(Object value, DataOutput dataOutput, IdentityRecordStack parentRecords) {
        dataOutput.writeByte((byte)1); // Encoding version 1
        Blob blob = (Blob)value;
        byte[] key = blob.getValue();
        if (key == null) {
            dataOutput.writeVInt(0);
        } else {
            dataOutput.writeVInt(key.length);
            dataOutput.writeBytes(key);
        }
        dataOutput.writeUTF(blob.getMediaType());
        Long size = blob.getSize();
        if (size == null) {
            size = Long.valueOf(-1);
        }
        dataOutput.writeLong(size);
        dataOutput.writeUTF(blob.getName());
    }
View Full Code Here

        //
        // Blob tests
        //
        {
            log.debug("Begin test V70");
            Blob blob1 = createBlob("blob1_msword.doc", "application/msword", "blob1_msword.doc");
            Blob blob1dup = createBlob("blob1_msword.doc", "application/msword", "blob1_msword.doc");
            Blob blob2 = createBlob("blob2.pdf", "application/pdf", "blob2.pdf");
            Blob blob3 =
                    createBlob("blob3_oowriter.odt", "application/vnd.oasis.opendocument.text", "blob3_oowriter.odt");
            Blob blob4 = createBlob("blob4_excel.xls", "application/excel", "blob4_excel.xls");

            // Single-valued blob field
            Record record1 = defaultTable.newRecord();
            record1.setRecordType(vRecordType1.getName());
            record1.setField(vBlobField.getName(), blob1);
View Full Code Here

TOP

Related Classes of org.lilyproject.repository.api.Blob

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.