Package org.akubraproject

Examples of org.akubraproject.Blob


  @Override
  public RepeatStatus execute(StepContribution contribution,
      ChunkContext chunkContext) throws Exception {
    String guid = FedoraURI.getGuidFromPid(pid);
    BasicDownloadRequest request = new BasicDownloadRequest();
    Blob blob = lowLevelStorage.getBlob(FedoraURI.getPidFromGuid(guid),
        "FULL_PDF");
    request.setBlob(blob);
    request.setContentType(ContentType.PDF);
    request.setResolution(new Resolution("medium"));
    String[] pageUris = PID_EXTRACTOR.getPageURIs(guid, "");
View Full Code Here


    }, false);

    // one operation, close then commit
    runTests(new ConAction() {
        public void run(BlobStoreConnection con) throws Exception {
          Blob b = getBlob(con, id, null);
          createBlob(con, b, null);
        }
    }, true);

    // one operation, close then roll back
    runTests(new ConAction() {
        public void run(BlobStoreConnection con) throws Exception {
          Blob b = getBlob(con, id, "");
          deleteBlob(con, b);
        }
    }, false);

    // clean up
    if (isTransactional)
      deleteBlob(id, "", true);
    else
      getBlob(id, null, true);

    // special transactional tests
    if (!isTransactional)
      return;

    // no operations, commit then close
    tm.begin();
    BlobStoreConnection con = store.openConnection(tm.getTransaction(), null);
    tm.commit();
    con.close();
    assertTrue(con.isClosed());

    // no operations, roll back then close
    tm.begin();
    con = store.openConnection(tm.getTransaction(), null);
    tm.rollback();
    con.close();
    assertTrue(con.isClosed());

    // one operation, commit then close
    tm.begin();
    con = store.openConnection(tm.getTransaction(), null);
    Blob b = getBlob(con, id, null);
    createBlob(con, b, null);
    tm.commit();
    con.close();
    assertTrue(con.isClosed());
View Full Code Here

    // test non-existent blob operations on a closed connection
    runTests(new Action() {
      public void run(Transaction txn) throws Exception {
        final BlobStoreConnection con = store.openConnection(txn, null);
        final Blob b = getBlob(con, id1, false);

        for (int idx = 0; idx < 3; idx++) {
          con.close();
          assertTrue(con.isClosed());

          assertEquals(b.getConnection(), con);
          assertEquals(b.getId(), id1);

          if (isOutputSupp) {
            shouldFail(new ERunnable() {
              @Override
              public void erun() throws Exception {
                b.openOutputStream(-1, true);
              }
            }, IllegalStateException.class, null);
          }

          shouldFail(new ERunnable() {
            @Override
            public void erun() throws Exception {
              b.exists();
            }
          }, IllegalStateException.class, null);
        }
      }
    });

    // test existing blob operations on a closed connection
    runTests(new Action() {
      public void run(Transaction txn) throws Exception {
        final BlobStoreConnection con = store.openConnection(txn, null);
        final Blob b  = getBlob(con, id1, false);
        final Blob b2 = getBlob(con, id2, false);
        createBlob(con, b, "foo");

        for (int idx = 0; idx < 3; idx++) {
          con.close();
          assertTrue(con.isClosed());

          assertEquals(b.getConnection(), con);
          assertEquals(b.getId(), id1);

          shouldFail(new ERunnable() {
            @Override
            public void erun() throws Exception {
              b.openInputStream();
            }
          }, IllegalStateException.class, null);

          if (isOutputSupp) {
            shouldFail(new ERunnable() {
              @Override
              public void erun() throws Exception {
                b.openOutputStream(-1, true);
              }
            }, IllegalStateException.class, null);
          }

          shouldFail(new ERunnable() {
            @Override
            public void erun() throws Exception {
              b.getSize();
            }
          }, IllegalStateException.class, null);

          shouldFail(new ERunnable() {
            @Override
            public void erun() throws Exception {
              b.exists();
            }
          }, IllegalStateException.class, null);

          if (isDeleteSupp) {
            shouldFail(new ERunnable() {
              @Override
              public void erun() throws Exception {
                b.delete();
              }
            }, IllegalStateException.class, null);
          }

          if (isMoveToSupp) {
            shouldFail(new ERunnable() {
              @Override
              public void erun() throws Exception {
                b.moveTo(b2.getId(), null);
              }
            }, IllegalStateException.class, null);
          }
        }
      }
View Full Code Here

    listBlobs(getPrefixFor("blobBasicList2"), new URI[] { });

    // test that blobs created/deleted as part of the current txn are properly shown
    runTests(new ConAction() {
        public void run(BlobStoreConnection con) throws Exception {
          Blob b1 = getBlob(con, id1, null);
          Blob b2 = getBlob(con, id2, null);

          listBlobs(con, getPrefixFor("blobBasicList"), new URI[] { });
          listBlobs(con, getPrefixFor("blobBasicLisT"), new URI[] { });
          listBlobs(con, getPrefixFor("blobBasicList2"), new URI[] { });
View Full Code Here

        }
    });

    runTests(new ConAction() {
        public void run(BlobStoreConnection con) throws Exception {
          Blob b = getBlob(con, id1, null);
          createBlob(con, b, "foos");
          con.sync();
          deleteBlob(con, b);
        }
    });

    runTests(new ConAction() {
        public void run(BlobStoreConnection con) throws Exception {
          Blob b = getBlob(con, id1, null);
          createBlob(con, b, "foos");
          deleteBlob(con, b);
          con.sync();
        }
    });

    runTests(new ConAction() {
        public void run(BlobStoreConnection con) throws Exception {
          Blob b = getBlob(con, id1, null);
          createBlob(con, b, "foos");
          b = moveBlob(con, b, id2, "foos");
          con.sync();
          deleteBlob(con, b);
        }
View Full Code Here

    }

    // null id should work
    runTests(new ConAction() {
        public void run(BlobStoreConnection con) throws Exception {
          Blob b = getBlob(con, null, false);
          if (b.exists())
            deleteBlob(con, b);
        }
    }, false);
  }
View Full Code Here

    // test
    runTests(new ConAction() {
      public void run(BlobStoreConnection con) throws Exception {
        if (aliases == null) {
          Blob b = getBlob(con, id, false);
          assertNull(b.getCanonicalId());
        } else {
          for (URI alias : aliases) {
            Blob b = getBlob(con, alias, false);
            assertEquals(b.getCanonicalId(), id);
          }
        }
      }
    });
  }
View Full Code Here

  public void testNonExistentBlob() throws Exception {
    final URI id = createId("blobNonExistent1");

    runTests(new ConAction() {
      public void run(BlobStoreConnection con) throws Exception {
        Blob b = getBlob(con, id, false);
        assertEquals(b.getConnection(), con);
        assertEquals(b.getId(), id);
      }
    });

    shouldFail(new ConAction() {
      public void run(BlobStoreConnection con) throws Exception {
View Full Code Here

  }

  protected void testBlobFromStream(final String body, final long estSize) throws Exception {
    runTests(new ConAction() {
        public void run(BlobStoreConnection con) throws Exception {
          Blob b = con.getBlob(new ByteArrayInputStream(body.getBytes("UTF-8")), estSize, null);
          assertTrue(b.exists());
          assertTrue(con.getBlob(b.getId(), null).exists());

          assertEquals(getBody(b), body);
          assertEquals(getBody(con.getBlob(b.getId(), null)), body);

          deleteBlob(con, b);
        }
    });
  }
View Full Code Here

    // check if delete is supported
    if (!isDeleteSupp) {
      shouldFail(new ConAction() {
        public void run(BlobStoreConnection con) throws Exception {
          Blob b = getBlob(con, id1, "");
          b.delete();
        }
      }, UnsupportedOperationException.class, null);

      getBlob(id1, "", true);   // make sure it's still exists
View Full Code Here

TOP

Related Classes of org.akubraproject.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.