@@ -624,26 +624,9 @@ public void submitReportRequest(MultipartCNode cnNode, MultipartMNode mnNode, Bo
624624
625625 Identifier pid = new Identifier ();
626626 pid .setValue (pidStr );
627-
628- // Get hashstore props from a config file to directly retrieve sysmeta and eml metadata
629- Map <String , Object > storeConfig = getHashStorePropsFromMetadigProps ();
627+ HashStore hashStore = getHashStoreFromMetadigProps ();
630628
631629 // TODO: Junit tests
632- String storePath = (String ) storeConfig .get ("store_path" );
633- String storeDepth = (String ) storeConfig .get ("store_depth" );
634- String storeWidth = (String ) storeConfig .get ("store_width" );
635- String storeAlgo = (String ) storeConfig .get ("store_algorithm" );
636- String sysmetaNamespace = (String ) storeConfig .get ("store_metadata_namespace" );
637- String hashstoreClassName = "org.dataone.hashstore.filehashstore.FileHashStore" ;
638- Properties storeProperties = new Properties ();
639- storeProperties .setProperty ("storePath" , storePath );
640- storeProperties .setProperty ("storeDepth" , storeDepth );
641- storeProperties .setProperty ("storeWidth" , storeWidth );
642- storeProperties .setProperty ("storeAlgorithm" , storeAlgo );
643- storeProperties .setProperty ("storeMetadataNamespace" , sysmetaNamespace );
644- // Get a HashStore
645- HashStore hashStore = HashStoreFactory .getHashStore (hashstoreClassName , storeProperties );
646-
647630 // Retrieve the system metadata
648631 sysmeta = getSystemMetadataFromHashStoreOrNode (pid , hashStore , cnNode , mnNode , isCN , session );
649632
@@ -679,6 +662,36 @@ public void submitReportRequest(MultipartCNode cnNode, MultipartMNode mnNode, Bo
679662 }
680663 }
681664
665+ /**
666+ * Retrieve a hashstore by loading the metadig.properties file and parsing it for keys with
667+ * the 'store.' prefix. These keys are then used to form properties to instantiate a
668+ * hashstore which can be used to retrieve system metadata or data objects.
669+ *
670+ * @return A hashstore based on metadig properties
671+ * @throws IOException When there is an issue with using metadig properties to retrieve store
672+ * keys to retrieve a hashstore
673+ */
674+ private static HashStore getHashStoreFromMetadigProps () throws IOException {
675+ // Get hashstore with props from a config file to directly access sysmeta and eml metadata
676+ Map <String , Object > storeConfig = getHashStorePropsFromMetadigProps ();
677+ String storePath = (String ) storeConfig .get ("store_path" );
678+ String storeDepth = (String ) storeConfig .get ("store_depth" );
679+ String storeWidth = (String ) storeConfig .get ("store_width" );
680+ String storeAlgo = (String ) storeConfig .get ("store_algorithm" );
681+ String sysmetaNamespace = (String ) storeConfig .get ("store_metadata_namespace" );
682+ String hashstoreClassName = "org.dataone.hashstore.filehashstore.FileHashStore" ;
683+ Properties storeProperties = new Properties ();
684+ storeProperties .setProperty ("storePath" , storePath );
685+ storeProperties .setProperty ("storeDepth" , storeDepth );
686+ storeProperties .setProperty ("storeWidth" , storeWidth );
687+ storeProperties .setProperty ("storeAlgorithm" , storeAlgo );
688+ storeProperties .setProperty ("storeMetadataNamespace" , sysmetaNamespace );
689+
690+ // Get a HashStore
691+ HashStore hashStore = HashStoreFactory .getHashStore (hashstoreClassName , storeProperties );
692+ return hashStore ;
693+ }
694+
682695 /**
683696 * Returns an input stream to an eml metadata document for a given pid. First, we try to open
684697 * a stream to the eml metadata doc directly through the given hashstore (quickest). If we
0 commit comments