Package v7db.files.spi

Examples of v7db.files.spi.ContentStorage


      DecoderException {
    Mongo mongo = getMongo();

    DBCollection contents = mongo.getDB("test").getCollection(
        "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


public class ZipFileTest extends MockMongoTestCaseSupport {

  public void testPullOutFileFromZip() throws MongoException, IOException,
      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

  }

  public void testIndexZipFile() throws MongoException, IOException,
      ZipException, DecoderException {

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

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

    ZipFile.index(storage, zip);

    assertEquals("fc012bb0439382f709d3caebab958ff592811d17", DigestUtils
        .shaHex(storage.getContent(
            decodeHex("fc012bb0439382f709d3caebab958ff592811d17"
                .toCharArray())).getInputStream()));

  }
View Full Code Here

public class MongoContentStorageTest extends MockMongoTestCaseSupport {

  public void testRoundtrip() throws MongoException, IOException {

    Mongo mongo = getMongo();
    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());
    mongo.close();
View Full Code Here

    prepareMockData("test.v7files.content", new BasicBSONObject("_id", sha)
        .append("store", "gz").append("zin", compressed));

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

    Content check = storage.getContent(sha);

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

            Arrays.asList(new BasicBSONObject("sha", sha1).append(
                "length", data1.length), new BasicBSONObject(
                "sha", sha2).append("length", data2.length))));

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

    Content check = storage.getContent(sha);

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

          .println("Upload the contents of one or more files and print their SHA digests:");
      System.err.println("   upload <file> [file] [file] [...]");
      System.exit(1);
    }

    ContentStorage storage = new MongoContentStorage(Configuration
        .getMongo().getDB(Configuration.getProperty("mongo.db")));

    for (int i = 1; i < args.length; i++) {
      File f = new File(args[i]);
      if (f.isFile() && f.canRead()) {
        try {
          ContentSHA up = storage
              .storeContent(new FileInputStream(f));

          // TODO: display if chunked or not
          System.out.format("-      %10d %80s %40s\n", f.length(), f
              .getName(), up.getDigest());
View Full Code Here

TOP

Related Classes of v7db.files.spi.ContentStorage

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.