Class SpaceItemWriter

java.lang.Object
org.duracloud.snapshot.service.impl.StepExecutionSupport
org.duracloud.snapshot.service.impl.SpaceItemWriter
All Implemented Interfaces:
org.springframework.batch.core.ItemWriteListener<org.duracloud.common.model.ContentItem>, org.springframework.batch.core.StepExecutionListener, org.springframework.batch.core.StepListener, org.springframework.batch.item.ItemWriter<org.duracloud.common.model.ContentItem>

public class SpaceItemWriter extends StepExecutionSupport implements org.springframework.batch.item.ItemWriter<org.duracloud.common.model.ContentItem>, org.springframework.batch.core.ItemWriteListener<org.duracloud.common.model.ContentItem>
This class is responsible for reading the contents and properties of a duracloud content item, writing it to disk, appending its md5 and sha256 to separate text files, appending the item properties to a json file, and writing the item to the snapshot content repo.
Author:
Erik Paulsson Date: 2/7/14
  • Constructor Details

    • SpaceItemWriter

      public SpaceItemWriter(Snapshot snapshot, org.duracloud.retrieval.source.RetrievalSource retrievalSource, File contentDir, org.duracloud.retrieval.mgmt.OutputWriter outputWriter, File propsFile, File md5ManifestFile, File sha256ManifestFile, SnapshotManager snapshotManager, SpaceManifestSnapshotManifestVerifier spaceManifestSnapshotManifestVerifier)
      Parameters:
      snapshot -
      retrievalSource -
      contentDir -
      outputWriter -
      propsFile -
      md5ManifestFile -
      sha256ManifestFile -
      snapshotManager -
      spaceManifestSnapshotManifestVerifier -
  • Method Details

    • closeDatabase

      protected void closeDatabase()
    • deleteDatabase

      protected void deleteDatabase()
    • write

      public void write(List<? extends org.duracloud.common.model.ContentItem> items) throws IOException
      Specified by:
      write in interface org.springframework.batch.item.ItemWriter<org.duracloud.common.model.ContentItem>
      Throws:
      IOException
    • retrieveFile

      protected void retrieveFile(org.duracloud.common.model.ContentItem contentItem, File directory) throws IOException
      Throws:
      IOException
    • retrieveFile

      protected void retrieveFile(org.duracloud.common.model.ContentItem contentItem, File directory, boolean writeChecksums, boolean lastItem) throws IOException
      Throws:
      IOException
    • getTotalChecksumsPerformed

      protected int getTotalChecksumsPerformed()
    • writeMD5Checksum

      protected void writeMD5Checksum(String contentId, String md5Checksum) throws IOException
      Throws:
      IOException
    • writeSHA256Checksum

      protected void writeSHA256Checksum(String contentId, String sha256Checksum) throws IOException
      Throws:
      IOException
    • writeContentProperties

      protected void writeContentProperties(String contentId, Map<String,String> props, boolean lastItem) throws IOException
      Throws:
      IOException
    • retrieveSnapshotProperties

      protected void retrieveSnapshotProperties()
    • afterStep

      public org.springframework.batch.core.ExitStatus afterStep(org.springframework.batch.core.StepExecution stepExecution)
      Specified by:
      afterStep in interface org.springframework.batch.core.StepExecutionListener
      Overrides:
      afterStep in class StepExecutionSupport
    • beforeStep

      public void beforeStep(org.springframework.batch.core.StepExecution stepExecution)
      Specified by:
      beforeStep in interface org.springframework.batch.core.StepExecutionListener
      Overrides:
      beforeStep in class StepExecutionSupport
    • onWriteError

      public void onWriteError(Exception e, List<? extends org.duracloud.common.model.ContentItem> items)
      Specified by:
      onWriteError in interface org.springframework.batch.core.ItemWriteListener<org.duracloud.common.model.ContentItem>
    • beforeWrite

      public void beforeWrite(List<? extends org.duracloud.common.model.ContentItem> items)
      Specified by:
      beforeWrite in interface org.springframework.batch.core.ItemWriteListener<org.duracloud.common.model.ContentItem>
    • afterWrite

      public void afterWrite(List<? extends org.duracloud.common.model.ContentItem> items)
      Specified by:
      afterWrite in interface org.springframework.batch.core.ItemWriteListener<org.duracloud.common.model.ContentItem>