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
-
Field Summary
Fields inherited from class org.duracloud.snapshot.service.impl.StepExecutionSupport
ERRORS_KEY, ITEMS_READ_KEY -
Constructor Summary
ConstructorsConstructorDescriptionSpaceItemWriter(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) -
Method Summary
Modifier and TypeMethodDescriptionorg.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 voidprotected voidprotected intvoidonWriteError(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 voidvoidprotected 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 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
- 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
- Throws:
IOException
-
writeSHA256Checksum
- 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
- Specified by:
onWriteErrorin interfaceorg.springframework.batch.core.ItemWriteListener<org.duracloud.common.model.ContentItem>
-
beforeWrite
- Specified by:
beforeWritein interfaceorg.springframework.batch.core.ItemWriteListener<org.duracloud.common.model.ContentItem>
-
afterWrite
- Specified by:
afterWritein interfaceorg.springframework.batch.core.ItemWriteListener<org.duracloud.common.model.ContentItem>
-