Skip to content

Commit

Permalink
Added a save method for the test classes.
Browse files Browse the repository at this point in the history
Fixed a bug to use storage in the hashstore implementation.
  • Loading branch information
taojing2002 committed Jun 26, 2024
1 parent c2b27cb commit f1441b6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/main/java/org/dataone/indexer/storage/HashStorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,20 @@ public static HashStorage getInstance(String className) throws IOException {
public InputStream retrieveObject(String pid)
throws IllegalArgumentException, FileNotFoundException, IOException,
NoSuchAlgorithmException {
return hashStorage.retrieveObject(pid);
return hashStore.retrieveObject(pid);
}

@Override
public InputStream retrieveSystemMetadata(String pid)
throws IllegalArgumentException, FileNotFoundException, IOException,
NoSuchAlgorithmException {
return hashStorage.retrieveSystemMetadata(pid);
return hashStore.retrieveMetadata(pid);
}

@Override
public void storeObject(InputStream object, String pid) throws NoSuchAlgorithmException,
IOException,RuntimeException, InterruptedException {
hashStore.storeObject(object, pid, null, null, null, -1);
}

}
14 changes: 14 additions & 0 deletions src/main/java/org/dataone/indexer/storage/Storage.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import java.io.InputStream;
import java.security.NoSuchAlgorithmException;

import org.dataone.hashstore.exceptions.PidRefsFileExistsException;


/**
* The Storage represents the interface to access the objects and system metadata
Expand Down Expand Up @@ -38,4 +40,16 @@ public InputStream retrieveObject(String pid) throws IllegalArgumentException,
public InputStream retrieveSystemMetadata(String pid) throws IllegalArgumentException,
FileNotFoundException, IOException, NoSuchAlgorithmException;

/**
* Store the input stream object into hash store. This method is only for the test classes.
* @param object the input stream of the object
* @param pid the pid which will be stored
* @throws NoSuchAlgorithmException
* @throws IOException
* @throws RuntimeException
* @throws InterruptedException
*/
public void storeObject(InputStream object, String pid) throws NoSuchAlgorithmException,
IOException,RuntimeException, InterruptedException;

}

0 comments on commit f1441b6

Please sign in to comment.