Skip to content

Commit

Permalink
Merge branch 'feature-jcloud-store-7.4' into feature-jcloud-store-9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Buckingham committed Sep 5, 2024
2 parents d5b1cf3 + fc9a21c commit 8156c8d
Show file tree
Hide file tree
Showing 10 changed files with 883 additions and 18 deletions.
45 changes: 40 additions & 5 deletions dspace-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -632,11 +632,6 @@
<version>1.1.1</version>
</dependency>

<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>

<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
Expand Down Expand Up @@ -675,6 +670,12 @@
<dependency>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client</artifactId>
<exclusions>
<exclusion>
<groupId>com.google.guava</groupId>
<artifactId>guava-jdk5</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.http-client</groupId>
Expand Down Expand Up @@ -855,6 +856,40 @@
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.apache.jclouds</groupId>
<artifactId>jclouds-core</artifactId>
<version>2.5.0</version>
<exclusions>
<exclusion>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.apache.jclouds</groupId>
<artifactId>jclouds-blobstore</artifactId>
<version>2.5.0</version>
</dependency>

<dependency>
<groupId>org.apache.jclouds.api</groupId>
<artifactId>filesystem</artifactId>
<version>2.5.0</version>
</dependency>

<dependency>
<groupId>org.apache.jclouds.provider</groupId>
<artifactId>aws-s3</artifactId>
<version>2.5.0</version>
</dependency>
</dependencies>

<dependencyManagement>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ protected String getIntermediatePath(String internalId) {
* an attempt to make a path traversal attack, so ignore the path prefix. The
* internal-ID is supposed to be just a filename, so this will not affect normal
* operation.
*
*
* @param sInternalId
* @return Sanitized id
*/
Expand All @@ -88,7 +88,7 @@ protected String sanitizeIdentifier(String sInternalId) {

/**
* Append separator to target {@code StringBuilder}
*
*
* @param path
*/
protected void appendSeparator(StringBuilder path) {
Expand All @@ -99,7 +99,7 @@ protected void appendSeparator(StringBuilder path) {

/**
* Utility that checks string ending with separator
*
*
* @param bufFilename
* @return
*/
Expand All @@ -111,7 +111,7 @@ protected boolean endsWithSeparator(StringBuilder bufFilename) {
* Splits internalId into several subpaths using {@code digitsPerLevel} that
* indicates the folder name length, and {@code direcoryLevels} that indicates
* the maximum number of subfolders.
*
*
* @param internalId bitStream identifier
* @param path
*/
Expand All @@ -127,7 +127,7 @@ protected void populatePathSplittingId(String internalId, StringBuilder path) {

/**
* Extract substring if is in range, otherwise will truncate to length
*
*
* @param internalId
* @param startIndex
* @param endIndex
Expand All @@ -142,7 +142,7 @@ protected String extractSubstringFrom(String internalId, int startIndex, int end

/**
* Checks if the {@code String} is longer than {@code endIndex}
*
*
* @param internalId
* @param endIndex
* @return
Expand All @@ -153,7 +153,7 @@ protected boolean isLonger(String internalId, int endIndex) {

/**
* Retrieves a map of useful metadata about the File (size, checksum, modified)
*
*
* @param file The File to analyze
* @param attrs The list of requested metadata values
* @return Map of updated metadatas / attrs
Expand Down
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();
}


}
Loading

0 comments on commit 8156c8d

Please sign in to comment.