Package org.lilyproject.repository.api

Examples of org.lilyproject.repository.api.Blob


            log.debug("Begin test V302");

            Record record = defaultTable.newRecord();
            record.setRecordType(rt.getName());

            Blob blob1 = createBlob("blob2.pdf", "application/pdf", "blob2.pdf");
            Blob blob2 = createBlob("blob2.pdf", "application/pdf", "blob2.pdf");

            record.setField(field13.getName(), blob1);
            record.setField(field14.getName(), blob2);

            expectEvent(CREATE, Table.RECORD.name, record.getId(), 1L, null, field13.getId(), field14.getId());
            record = defaultTable.create(record);

            commitIndex();

            // extractContent is not enabled for field13, search on content should not find anything
            verifyResultCount("field13_string:tired", 0);

            // extractContent is enabled for field14
            verifyResultCount("field14_string:tired", 1);
        }

        //
        // Attention: we change the indexerconf here
        //
        changeIndexUpdater("indexerconf_dynfields_continue.xml");

        //
        // Test the fall-through behavior (continue="true") of dynamic fields
        //
        {
            log.debug("Begin test V303");

            Record record = defaultTable.newRecord();
            record.setRecordType(rt.getName());

            record.setField(field1.getName(), "mega");
            record.setField(field2.getName(), "giga");

            expectEvent(CREATE, Table.RECORD.name, record.getId(), 1L, null, field1.getId(), field2.getId());
            record = defaultTable.create(record);

            commitIndex();

            verifyResultCount("dyncont_field1_first_string:mega", 1);
            verifyResultCount("dyncont_field2_first_string:giga", 1);

            verifyResultCount("dyncont_field1_second_string:mega", 1);
            verifyResultCount("dyncont_field2_second_string:giga", 1);

            verifyResultCount("dyncont_field1_third_string:mega", 0);
            verifyResultCount("dyncont_field2_third_string:giga", 0);
        }

        //
        // Attention: we change the indexerconf here
        //
        changeIndexUpdater("indexerconf_fulldynamic.xml");

        //
        // Test a 'fully dynamic' mapping
        //
        {
            log.debug("Begin test V304");

            Record record = defaultTable.newRecord();
            record.setRecordType(rt.getName());

            Blob blob = createBlob("blob2.pdf", "application/pdf", "blob2.pdf");

            record.setField(field1.getName(), "gauss");
            record.setField(field2.getName(), "hilbert");
            record.setField(field4.getName(), new Long(1024));
            record.setField(field14.getName(), blob);
View Full Code Here


        String description = "<html><body>This book gives thorough insight into Lily, ...</body></html>";
        byte[] descriptionData = description.getBytes("UTF-8");

        // (1)
        Blob blob = new Blob("text/html", (long) descriptionData.length, "description.xml");
        OutputStream os = table.getOutputStream(blob);
        try {
            os.write(descriptionData);
        } finally {
            os.close();
View Full Code Here

    }

    private Blob createBlob(String resource, String mediaType, String fileName) throws Exception {
        byte[] mswordblob = readResource(resource);

        Blob blob = new Blob(mediaType, (long) mswordblob.length, fileName);
        OutputStream os = defaultTable.getOutputStream(blob);
        try {
            os.write(mswordblob);
        } finally {
            os.close();
View Full Code Here

        return blob;
    }

    private Blob createBlob(byte[] content, String mediaType, String fileName) throws Exception {
        Blob blob = new Blob(mediaType, (long) content.length, fileName);
        OutputStream os = defaultTable.getOutputStream(blob);
        try {
            os.write(content);
        } finally {
            os.close();
View Full Code Here

    }

    private void extractContent(String table, Object value, Record record, FieldType fieldType, int[] indexes, List<String> result,
            LRepository repository) {

        Blob blob = (Blob) value;
        InputStream is = null;

        // TODO make write limit configurable
        WriteOutContentHandler woh = new WriteOutContentHandler(500 * 1000); // 500K limit (Tika default: 100K)
        BodyContentHandler ch = new BodyContentHandler(woh);

        try {
            is = repository.getTable(table).getInputStream(record, fieldType.getName(), indexes);

            Metadata metadata = new Metadata();
            metadata.add(Metadata.CONTENT_TYPE, blob.getMediaType());
            if (blob.getName() != null) {
                metadata.add(Metadata.RESOURCE_NAME_KEY, blob.getName());
            }

            ParseContext parseContext = new ParseContext();

            tikaParser.parse(is, ch, metadata, parseContext);
View Full Code Here

      BigDecimal decimalValue = BigDecimal.valueOf(Double.MIN_EXPONENT);
      Boolean booleanValue = true;
      LocalDate dateValue = new LocalDate(2900, 10, 14);
      DateTime dateTimeValue = new DateTime(Long.MAX_VALUE);
      Link linkValue = new Link(idGenerator.newRecordId());
      Blob blobValue = new Blob(Bytes.toBytes("anotherKey"), "image/jpeg", Long.MIN_VALUE, "images/image.jpg");
      URI uriValue = URI.create("http://foo.com/bar");
      List<String> listValue = new ArrayList<String>();
      listValue.add("abc");
      HierarchyPath pathValue = new HierarchyPath("abc");
      Record recordValue = repository.recordBuilder().field(stringFieldName, "foo").build();

      Record record = repository.recordBuilder()
          .field(stringFieldName, stringValue)
          .field(integerFieldName, integerValue)
          .field(longFieldName, longValue)
          .field(doubleFieldName, doubleValue)
          .field(decimalFieldName, decimalValue)
          .field(booleanFieldName, booleanValue)
          .field(dateFieldName, dateValue)
          .field(dateTimeFieldName, dateTimeValue)
          .field(linkFieldName, linkValue)
          .field(blobFieldName, blobValue)
          .field(uriFieldName, uriValue)
          .field(listFieldName, listValue)
          .field(pathFieldName, pathValue)
          .field(recordFieldName, recordValue)
          .build();

      // Clone record
        record = record.cloneRecord();

      // Change mutable values
      listValue.add("def");
      pathValue.getElements()[0] = "def";
      blobValue.setSize(0L);
      recordValue.setField(integerFieldName, 777);

      // Validate cloned record does not contain mutations
      List<String> list = record.getField(listFieldName);
      assertTrue(list.size() == 1);
      assertEquals("abc", list.get(0));

      HierarchyPath path = record.getField(pathFieldName);
      assertEquals("abc", path.getElements()[0]);

      Blob blob = record.getField(blobFieldName);
      assertTrue(Long.MIN_VALUE == blob.getSize());

      Record recordField = record.getField(recordFieldName);
      assertFalse(recordField.hasField(integerFieldName));

      // Put a record in itself
View Full Code Here

            int hierarchyIndex = randomIndex(hierarchyValues.length);
            Object subValue = hierarchyValues[hierarchyIndex];
            indexes = ArrayUtils.add(indexes, hierarchyIndex);
            readBlobs(readRecord, fieldName, subValue, valueType.getNestedValueType(), indexes);
        } else {
            Blob blob = (Blob) value;
            InputStream inputStream = testActionContext.table.getInputStream(readRecord, fieldName, indexes);
            readBlobBytes(blob, inputStream);
        }
    }
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.