forked from DSpace/DSpace
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature-jcloud-store-7.4' into feature-jcloud-store-9.0
- Loading branch information
Showing
10 changed files
with
883 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
dspace-api/src/main/java/org/dspace/storage/bitstore/BitstreamByteSource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/** | ||
* The contents of this file are subject to the license and copyright | ||
* detailed in the LICENSE and NOTICE files at the root of the source | ||
* tree and available online at | ||
* | ||
* http://www.dspace.org/license/ | ||
*/ | ||
package org.dspace.storage.bitstore; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.sql.SQLException; | ||
|
||
import com.google.common.io.ByteSource; | ||
import org.dspace.authorize.AuthorizeException; | ||
import org.dspace.content.Bitstream; | ||
import org.dspace.content.factory.ContentServiceFactory; | ||
import org.dspace.content.service.BitstreamService; | ||
import org.dspace.core.Context; | ||
|
||
public class BitstreamByteSource extends ByteSource { | ||
|
||
private static final BitstreamService bitstreamService = ContentServiceFactory.getInstance().getBitstreamService(); | ||
|
||
public Bitstream getBitstream() { | ||
return bitstream; | ||
} | ||
|
||
private final Bitstream bitstream; | ||
|
||
public BitstreamByteSource(Bitstream bitstream) { | ||
this.bitstream = bitstream; | ||
} | ||
|
||
@Override | ||
public InputStream openStream() throws IOException { | ||
try { | ||
return bitstreamService.retrieve(new Context(), bitstream); | ||
} catch (SQLException | AuthorizeException e) { | ||
throw new IOException(e.getMessage(), e); | ||
} | ||
} | ||
|
||
@Override | ||
public long size() throws IOException { | ||
return bitstream.getSizeBytes(); | ||
} | ||
|
||
|
||
} |
Oops, something went wrong.