Package v7db.files.spi

Examples of v7db.files.spi.ContentPointer


        "v7files.content");
    ContentStorage storage = new MongoContentStorage(contents);

    byte[] data = "abcdefghijklmnopqrstuvwxyz".getBytes();

    ContentPointer pointer = storage.storeContent(new ByteArrayInputStream(
        data));

    DBCollection references = mongo.getDB("test").getCollection(
        "v7files.refs");
    ReferenceTracking refs = new MongoReferenceTracking(references);
View Full Code Here


      ZipException, DecoderException {

    ContentStorage storage = new MongoContentStorage(getMongo().getDB(
        "test"));

    ContentPointer zip = storage.storeContent(getClass()
        .getResourceAsStream("mongodb.epub"));

    ContentPointer png = ZipFile.extractFile(storage, zip,
        "images/img0.png");

    assertEquals("fc012bb0439382f709d3caebab958ff592811d17", DigestUtils
        .shaHex(storage.getContent(png).getInputStream()));
View Full Code Here

      ZipException, DecoderException {

    ContentStorage storage = new MongoContentStorage(getMongo().getDB(
        "test"));

    ContentPointer zip = storage.storeContent(getClass()
        .getResourceAsStream("mongodb.epub"));

    ZipFile.index(storage, zip);

    assertEquals("fc012bb0439382f709d3caebab958ff592811d17", DigestUtils
View Full Code Here

    ContentStorage storage = new MongoContentStorage(mongo.getDB("test")
        .getCollection("v7files.content"));

    byte[] data = "abcdefghijklmnopqrstuvwxyz".getBytes();

    ContentPointer pointer = storage.storeContent(new ByteArrayInputStream(
        data));
    Content check = storage.getContent(pointer);

    assertEquals(new String(data), IOUtils.toString(check.getInputStream()));
    assertEquals(data.length, check.getLength());
View Full Code Here

    Mongo mongo = getMongo();
    MongoContentStorage storage = new MongoContentStorage(mongo
        .getDB("test"));

    ContentPointer pointer = storage.storeContent(new ByteArrayInputStream(
        data));

    BSONObject doc = assertMockMongoContainsDocument(
        "test.v7files.content", sha);
    assertEquals("cat", doc.get("store"));
View Full Code Here

      refTracking.updateReferences(fileId);
      return makeMetaData(filename, contentType, null);

    }

    ContentPointer p = storage.storeContent(new ByteArrayInputStream(data,
        offset, len));

    refTracking.updateReferences(fileId, p);

    return makeMetaData(filename, contentType, p);
View Full Code Here

    if (data == null)
      return insertContentsAndBackRefs(null, 0, 0, fileId, filename,
          contentType);

    ContentPointer p = storage.storeContent(data);

    refTracking.updateReferences(fileId, p);

    return makeMetaData(filename, contentType, p);
View Full Code Here

        : contents.length);
  }

  void updateContents(DBObject metaData, ContentPointer newContents)
      throws IOException {
    ContentPointer oldContents = getContentPointer(metaData);

    if (newContents.contentEquals(oldContents))
      return;

    String filename = (String) metaData.get("filename");
View Full Code Here

  private void updateContents(DBObject metaData, InputStream contents)
      throws IOException {

    Object fileId = metaData.get("_id");
    ContentPointer oldContents = getContentPointer(metaData);
    String filename = (String) metaData.get("filename");
    String contentType = (String) metaData.get("contentType");

    BSONObject newContent = storage.insertContentsAndBackRefs(contents,
        fileId, filename, contentType);

    // check if it has changed
    ContentPointer newContents = getContentPointer(newContent);
    if (newContents.contentEquals(oldContents))
      return;

    metaData.removeField("sha");
    metaData.removeField("length");
    metaData.removeField("in");
View Full Code Here

  private void updateContents(DBObject metaData, byte[] contents, int offset,
      int len) throws IOException {

    Object fileId = metaData.get("_id");
    ContentPointer oldContents = getContentPointer(metaData);
    String filename = (String) metaData.get("filename");
    String contentType = (String) metaData.get("contentType");

    // for up to 55 bytes, storing the complete file inline
    // takes less space than just storing the SHA-1 and length
    // 20 (SHA-1) + 1 (sha - in) + 6 (length) + 4 (int32) + 2*12
    // (ObjectId back-references)
    BSONObject newContent = storage.inlineOrInsertContentsAndBackRefs(55,
        contents, offset, len, fileId, filename, contentType);

    // check if it has changed
    ContentPointer newContents = getContentPointer(newContent);
    if (newContents.contentEquals(oldContents))
      return;

    metaData.removeField("sha");
    metaData.removeField("length");
    metaData.removeField("in");
View Full Code Here

TOP

Related Classes of v7db.files.spi.ContentPointer

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.