- 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
-
-
Field Summary
-
Fields inherited from class org.duracloud.snapshot.service.impl.StepExecutionSupport
ERRORS_KEY, ITEMS_READ_KEY
-
-
Constructor Summary
Constructors Constructor Description SpaceItemWriter(org.duracloud.snapshot.db.model.Snapshot snapshot, org.duracloud.retrieval.source.RetrievalSource retrievalSource, File contentDir, org.duracloud.retrieval.mgmt.OutputWriter outputWriter, File propsFile, File md5ManifestFile, File sha256ManifestFile, org.duracloud.snapshot.service.SnapshotManager snapshotManager, SpaceManifestSnapshotManifestVerifier spaceManifestSnapshotManifestVerifier)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.springframework.batch.core.ExitStatusafterStep(org.springframework.batch.core.StepExecution stepExecution)voidafterWrite(List<? extends org.duracloud.common.model.ContentItem> items)voidbeforeStep(org.springframework.batch.core.StepExecution stepExecution)voidbeforeWrite(List<? extends org.duracloud.common.model.ContentItem> items)protected voidcloseDatabase()protected voiddeleteDatabase()protected intgetTotalChecksumsPerformed()voidonWriteError(Exception e, List<? extends org.duracloud.common.model.ContentItem> items)protected voidretrieveFile(org.duracloud.common.model.ContentItem contentItem, File directory)protected voidretrieveFile(org.duracloud.common.model.ContentItem contentItem, File directory, boolean writeChecksums, boolean lastItem)protected voidretrieveSnapshotProperties()voidwrite(List<? extends org.duracloud.common.model.ContentItem> items)protected voidwriteContentProperties(String contentId, Map<String,String> props, boolean lastItem)protected voidwriteMD5Checksum(String contentId, String md5Checksum)protected voidwriteSHA256Checksum(String contentId, String sha256Checksum)-
Methods inherited from class org.duracloud.snapshot.service.impl.StepExecutionSupport
addError, addToItemsRead, addToLong, clearErrors, failExecution, getErrors, getExecutionContext, getItemsRead, getLongValue, getStepExecution, resetContextState, setIsTest, skipLinesAlreadyRead, verifySpace
-
-
-
-
Constructor Detail
-
SpaceItemWriter
public SpaceItemWriter(org.duracloud.snapshot.db.model.Snapshot snapshot, org.duracloud.retrieval.source.RetrievalSource retrievalSource, File contentDir, org.duracloud.retrieval.mgmt.OutputWriter outputWriter, File propsFile, File md5ManifestFile, File sha256ManifestFile, org.duracloud.snapshot.service.SnapshotManager snapshotManager, SpaceManifestSnapshotManifestVerifier spaceManifestSnapshotManifestVerifier)- Parameters:
snapshot-retrievalSource-contentDir-outputWriter-propsFile-md5ManifestFile-sha256ManifestFile-snapshotManager-spaceManifestSnapshotManifestVerifier-
-
-
Method Detail
-
closeDatabase
protected void closeDatabase()
-
deleteDatabase
protected void deleteDatabase()
-
write
public void write(List<? extends org.duracloud.common.model.ContentItem> items) throws IOException
- Specified by:
writein interfaceorg.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:
afterStepin interfaceorg.springframework.batch.core.StepExecutionListener- Overrides:
afterStepin classStepExecutionSupport
-
beforeStep
public void beforeStep(org.springframework.batch.core.StepExecution stepExecution)
- Specified by:
beforeStepin interfaceorg.springframework.batch.core.StepExecutionListener- Overrides:
beforeStepin classStepExecutionSupport
-
onWriteError
public void onWriteError(Exception e, List<? extends org.duracloud.common.model.ContentItem> items)
- Specified by:
onWriteErrorin interfaceorg.springframework.batch.core.ItemWriteListener<org.duracloud.common.model.ContentItem>
-
beforeWrite
public void beforeWrite(List<? extends org.duracloud.common.model.ContentItem> items)
- Specified by:
beforeWritein interfaceorg.springframework.batch.core.ItemWriteListener<org.duracloud.common.model.ContentItem>
-
afterWrite
public void afterWrite(List<? extends org.duracloud.common.model.ContentItem> items)
- Specified by:
afterWritein interfaceorg.springframework.batch.core.ItemWriteListener<org.duracloud.common.model.ContentItem>
-
-