Class CronJobDumpHandler
- java.lang.Object
-
- de.hybris.platform.impex.jalo.imp.AbstractDumpHandler
-
- de.hybris.platform.impex.jalo.cronjob.CronJobDumpHandler
-
- All Implemented Interfaces:
DumpHandler
public class CronJobDumpHandler extends AbstractDumpHandler
Implementation of aDumpHandlerfor usage inImpExImportCronJobs. The current dump storage is hold by a temporary file which will be saved to the persistent unresolved media attribute of the cronjob at eachswitchDumpcall or when calling thesavepointmethod. The last dump storage is located at the persistent work media attribute of the cronjob (used for input).
-
-
Constructor Summary
Constructors Constructor Description CronJobDumpHandler(ImpExImportCronJob cronjob)Instantiates a new handler using the given cronjob for storing dump storages.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected CSVReadercreateReader()Creates a new reader using last dump media as input.protected CSVWritercreateWriter()Creates a new writer using a new created temp file as temporary dump.protected voiddeleteTempDump()Deletes the temporary dump file.voidfinish(boolean saveCurrentDump)Deletes last dump storage definitely and current one if given flag is set.ImpExMediagetDumpAsMedia()Gets the current dump as media object.protected java.io.FilegetTempDump()Gets the temporary dump file.voidinit()Initializes the handler by creating the first dump storage and providing a writer object to that storage when callingDumpHandler.getWriterOfCurrentDump().protected voidsaveAndDeleteTempDump()Saves the temporary dump to the unresolved data media of the cronjob.protected voidsetTempDump(java.io.File tempFile)Remembers given temporary dump.protected voidswitchCurrentToLastDump()Switches the reference of current dump media to last dump media and prepares unresolved media attribute.voidswitchDump()References the 'current' dump storage as 'last' dump storage (DumpHandler.getReaderOfLastDump()now provides a reader object to that storage) and creates a new 'current' dump storage (DumpHandler.getWriterOfCurrentDump()now provides a writer object to that storage).-
Methods inherited from class de.hybris.platform.impex.jalo.imp.AbstractDumpHandler
getDumpAsFile, getDumpAsString, getReaderOfLastDump, getWriterOfCurrentDump, setReaderOfLastDump, setWriterOfCurrentDump
-
-
-
-
Constructor Detail
-
CronJobDumpHandler
public CronJobDumpHandler(ImpExImportCronJob cronjob)
Instantiates a new handler using the given cronjob for storing dump storages.- Parameters:
cronjob- used cronjob instance
-
-
Method Detail
-
init
public void init() throws java.io.IOExceptionDescription copied from interface:DumpHandlerInitializes the handler by creating the first dump storage and providing a writer object to that storage when callingDumpHandler.getWriterOfCurrentDump().- Throws:
java.io.IOException- error while storage creation
-
finish
public void finish(boolean saveCurrentDump)
Description copied from interface:DumpHandlerDeletes last dump storage definitely and current one if given flag is set.- Parameters:
saveCurrentDump- should the current storage be deleted
-
switchDump
public void switchDump() throws ImpExExceptionDescription copied from interface:DumpHandlerReferences the 'current' dump storage as 'last' dump storage (DumpHandler.getReaderOfLastDump()now provides a reader object to that storage) and creates a new 'current' dump storage (DumpHandler.getWriterOfCurrentDump()now provides a writer object to that storage). If there was a storage referenced by 'last' it will be deleted.- Throws:
ImpExException- error while storage handling
-
getDumpAsMedia
public ImpExMedia getDumpAsMedia()
Description copied from interface:DumpHandlerGets the current dump as media object.- Specified by:
getDumpAsMediain interfaceDumpHandler- Overrides:
getDumpAsMediain classAbstractDumpHandler- Returns:
- current dump as media
-
createWriter
protected CSVWriter createWriter() throws java.io.IOException
Creates a new writer using a new created temp file as temporary dump.- Returns:
- writer object to new temporary dump
- Throws:
java.io.IOException- error while accessing file
-
createReader
protected CSVReader createReader() throws java.io.IOException
Creates a new reader using last dump media as input.- Returns:
- reader object to last dump media
- Throws:
java.io.IOException- error while accessing media
-
switchCurrentToLastDump
protected void switchCurrentToLastDump() throws JaloBusinessExceptionSwitches the reference of current dump media to last dump media and prepares unresolved media attribute.- Throws:
JaloBusinessException- error while accessing data of medias
-
deleteTempDump
protected void deleteTempDump()
Deletes the temporary dump file.
-
getTempDump
protected java.io.File getTempDump()
Gets the temporary dump file.- Returns:
- temporary dump file
-
setTempDump
protected void setTempDump(java.io.File tempFile)
Remembers given temporary dump.- Parameters:
tempFile- file to store
-
saveAndDeleteTempDump
protected void saveAndDeleteTempDump()
Saves the temporary dump to the unresolved data media of the cronjob.
-
-