Package org.lilyproject.repository.api

Examples of org.lilyproject.repository.api.Blob


        // TODO do we want the mediatype to include the parameters?
        String mediaType = headers.getMediaType().getType() + "/" + headers.getMediaType().getSubtype();

        long length = Long.parseLong(lengthHeader);
        Blob blob = new Blob(mediaType, length, null);

        if (length == 0 && is == null) {
            // Apparently when the length is 0, no InputStream is provided, therefore the following
            is = new NullInputStream(0);
        }
View Full Code Here


        int min = 1;
        int max = sizes[0 + (int)(Math.random() * ((2 - 0) + 1))];
        int size = min + (int)(Math.random() * ((max - min) + 1));
        byte[] bytes = new byte[size];
        random.nextBytes(bytes);
        Blob blob = new Blob("tester", (long)bytes.length, "test"+size);
        try {
            OutputStream outputStream = table.getOutputStream(blob);
            outputStream.write(bytes);
            outputStream.close();
//            System.out.println("created blob of size "+size+" in "+ (System.currentTimeMillis()-start) +" ms");
View Full Code Here

        String mediaType = JsonUtil.getString(node, "mediaType", null);
        long size = JsonUtil.getLong(node, "size");
        String name = JsonUtil.getString(node, "name", null);
        byte[] value = valueFromString(JsonUtil.getString(node, "value"));

        Blob blob = new Blob(mediaType, size, name);
        blob.setValue(value);

        return blob;
    }
View Full Code Here

        for (int i = 0; i < types.length; i++) {
            FieldType blobField = typeManager
                    .createFieldType("BLOB", new QName("metadata-blob", "blob" + i), Scope.NON_VERSIONED);

            Blob blob = new Blob("text/plain", 5L, "foo");
            OutputStream os = repository.getOutputStream(blob);
            os.write("12345".getBytes());
            os.close();

            Record record = repository.newRecord();
View Full Code Here

        } else if (name.equals("URI") || name.equals("DATETIME") || name.equals("DATE") || name.equals("LINK")) {
            result = factory.textNode(value.toString());
        } else if (name.equals("DECIMAL")) {
            result = factory.numberNode((BigDecimal)value);
        } else if (name.equals("BLOB")) {
            Blob blob = (Blob)value;
            result = BlobConverter.toJson(blob);
        } else if (name.equals("RECORD")){
            result = toJson((Record)value, options, namespaces, repository);
        } else if (name.equals("BYTEARRAY")) {
            result = factory.binaryNode(((ByteArray) value).getBytes());
View Full Code Here

            throws BlobException {
        if (!(fieldType.getValueType().getDeepestValueType() instanceof BlobValueType)) {
            throw new BlobException("Cannot read a blob from a non-blob field type: " + fieldType.getName());
        }

        Blob blob = getBlobFromRecord(record, fieldName, fieldType, indexes);
        return registry.getBlobAccess(blob);
    }
View Full Code Here

                    byte[] data = IOUtils.toByteArray(bodyDataStream);

                    // TODO could fill in filename
                    long startTime = System.nanoTime();
                    Blob blob = new Blob(mediaType, (long)data.length, null);
                    OutputStream os = table.getOutputStream(blob);
                    try {
                        IOUtils.write(data, os);
                    } finally {
                        os.close();
View Full Code Here

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

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

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

        byte[] bytes3 = new byte[size];
        random.nextBytes(bytes3);
        Blob blob3 = writeBlob(bytes3, "aMediaType", "testUpdateMutableMultivalueBlob3");

        byte[] bytes4 = new byte[size];
        random.nextBytes(bytes4);
        Blob blob4 = writeBlob(bytes4, "aMediaType", "testUpdateMutableMultivalueBlob4");

        Record record = repository.newRecord();
        record.setRecordType(recordType.getName(), null);
        record.setField(fieldName, Arrays.asList(blob, blob2));
        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", "testUpdateMutableHierarchyBlob");

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

        byte[] bytes3 = new byte[size];
        random.nextBytes(bytes3);
        Blob blob3 = writeBlob(bytes3, "aMediaType", "testUpdateMutableHierarchyBlob3");

        byte[] bytes4 = new byte[size];
        random.nextBytes(bytes4);
        Blob blob4 = writeBlob(bytes4, "aMediaType", "testUpdateMutableHierarchyBlob4");

        Record record = repository.newRecord();
        record.setRecordType(recordType.getName(), null);
        record.setField(fieldName, new HierarchyPath(blob, blob2));
        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", "testUpdateMutableMultivalueHierarchyBlob");

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

        byte[] bytes3 = new byte[size];
        random.nextBytes(bytes3);
        Blob blob3 = writeBlob(bytes3, "aMediaType", "testUpdateMutableMultivalueHierarchyBlob3");

        byte[] bytes4 = new byte[size];
        random.nextBytes(bytes4);
        Blob blob4 = writeBlob(bytes4, "aMediaType", "testUpdateMutableMultivalueHierarchyBlob4");

        Record record = repository.newRecord();
        record.setRecordType(recordType.getName(), null);
        record.setField(fieldName, Arrays.asList(new HierarchyPath(blob, blob2), new HierarchyPath(blob3)));
        record = repository.create(record);
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.