Class FileMetadataExtractor

java.lang.Object
gov.nasa.pds.registry.common.meta.FileMetadataExtractor

public class FileMetadataExtractor extends Object
Extracts file metadata, such as file name, size, checksum.
Author:
karpenko
  • Constructor Details

    • FileMetadataExtractor

      public FileMetadataExtractor() throws Exception
      Constructor
      Throws:
      Exception - and exception
  • Method Details

    • setStoreLabels

      public void setStoreLabels(boolean storeXml, boolean storeJson)
      Set flags to store PDS labels in XML and JSON format. Default values are true.
      Parameters:
      storeXml - store PDS labels in XML format
      storeJson - store PDS labels in JSON format
    • setProcessDataFiles

      public void setProcessDataFiles(boolean process)
      Set a flag to process data files. Default value is true.
      Parameters:
      process - a flag to process data files.
    • extract

      public void extract(File file, Metadata meta, List<FileRefRule> refRules) throws Exception
      Extract file metadata
      Parameters:
      file - a file
      meta - extracted metadata is added to this object
      refRules - rules to create external file references
      Throws:
      Exception - an exception
    • getMd5

      public String getMd5(File file) throws Exception
      Calculate MD5 hash of a file
      Parameters:
      file - a file
      Returns:
      HEX encoded MD5 hash
      Throws:
      Exception - an exception
    • getBlob

      public String getBlob(File file) throws Exception
      Deflate (zip) PDS XML label and then Base64 encode.
      Parameters:
      file - PDS XML label
      Returns:
      Base64 encoded string
      Throws:
      Exception - an exception
    • getJsonBlob

      public static String getJsonBlob(File file) throws Exception
      Convert PDS XML label into JSON, deflate (zip) and then Base64 encode.
      Parameters:
      file - PDS XML label
      Returns:
      Base64 encoded string
      Throws:
      Exception - an exception