Package org.akubraproject

Examples of org.akubraproject.Blob


  @Test
  public void testIdMapperStore() throws UnsupportedOperationException,
      IOException {
    BlobStoreConnection connnection = blobStore.openConnection(null, null);
    Blob blob = null;
    try {
      blob = connnection.getBlob(new URI(
          "info:fedora/bhle:10706-a000test/OLEF"), null);
    } catch (UnsupportedIdException e) {
      e.printStackTrace();
    } catch (UnsupportedOperationException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    } catch (URISyntaxException e) {
      e.printStackTrace();
    }
    OutputStream out = null;
    try {
      out = blob.openOutputStream(-1, true);
    } catch (DuplicateBlobException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }
    try {
      out.write("SOMETHING ID!".getBytes());
      out.close();
    } catch (IOException e) {
      e.printStackTrace();
    }

    try {
      blob = connnection.getBlob(new URI(
          "info:fedora/bhle:10706-a000test/OLEF"), null);
      Assert.assertTrue(blob.exists());
      blob.delete();
      Assert.assertFalse(blob.exists());
      connnection.close();
    } catch (URISyntaxException e) {
      e.printStackTrace();
    }
  }
View Full Code Here


  @ExpectedException(UnsupportedOperationException.class)
  public void testGettingBlobWithoutProperConvertor()
      throws UnsupportedOperationException, IOException {
    BlobStoreConnection connnection = blobStore.openConnection(null, null);
    try {
      Blob blob = connnection.getBlob(new URI(
          "info:fedora/bhle:10706-a000test/JPG"), null);
      blob.openOutputStream(-1, true);
    } catch (URISyntaxException e) {
      e.printStackTrace();
    }
  }
View Full Code Here

    this.blobStore = blobStore;
  }

  public void add(String pid, String dsId, InputStream in) throws IOException {
    BlobStoreConnection connection = openConnection(blobStore);
    Blob blob = getBlob(connection, pid, dsId);
    OutputStream out = openOutputStream(blob);
    IOUtils.copy(in, out);
    connection.close();
  }
View Full Code Here

    }
  }

  public void remove(String pid, String dsId) throws IOException {
    BlobStoreConnection connection = openConnection(blobStore);
    Blob blob = getBlob(connection, pid, dsId);
    if (blob.exists()) {
      blob.delete();
    }
    connection.close();
  }
View Full Code Here

  }

  public void replace(String pid, String dsId, InputStream in)
      throws IOException {
    BlobStoreConnection connection = openConnection(blobStore);
    Blob blob = getBlob(connection, pid, dsId);
    OutputStream out = openOutputStream(blob);
    IOUtils.copy(in, out);
    out.close();
    in.close();
    connection.close();
View Full Code Here

    connection.close();
  }

  public InputStream get(String pid, String dsId) throws IOException {
    BlobStoreConnection connection = openConnection(blobStore);
    Blob blob = getBlob(connection, pid, dsId);
    return blob.openInputStream();
  }
View Full Code Here

  private FileStorage storage;

  public OfflineDownloadResponse fetch(String email, String filename)
      throws IOException {
    OfflineDownloadResponse response = new OfflineDownloadResponse();
    Blob blob = storage.fetchBlob(email, filename);
    if (blob.exists()) {
      response.setBlob(storage.fetchBlob(email, filename));
    } else {
      throw new IOException("Content not found");
    }
    return response;
View Full Code Here

  private DownloadResponseBuilderFactory responseBuilderFactory;

  @ServiceActivator
  public DownloadResponse process(DownloadRequest request) {

    Blob blob = request.getBlob();
    if (blob == null && request.isOffline()) {
      blob = storage.fetchBlob((OfflineDownloadRequest) request);
    }
    OutputStream out = null;
    try {
      out = blob.openOutputStream(-1, true);
    } catch (DuplicateBlobException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }
View Full Code Here

  /*
   * simple helpers that do an operation on an open connection and assert things went fine
   */

  protected Blob getBlob(BlobStoreConnection con, URI id, boolean exists) throws Exception {
    Blob b = con.getBlob(id, null);
    if (id != null)
      assertEquals(b.getId(), id);
    assertEquals(b.exists(), exists);
    return b;
  }
View Full Code Here

    assertEquals(b.exists(), exists);
    return b;
  }

  protected Blob getBlob(BlobStoreConnection con, URI id, String body) throws Exception {
    Blob b = getBlob(con, id, body != null);

    if (body != null)
      assertEquals(getBody(b), body);

    return b;
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.