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 a DumpHandler for usage in ImpExImportCronJobs. The current dump storage is hold by a temporary file which will be saved to the persistent unresolved media attribute of the cronjob at each switchDump call or when calling the savepoint method. The last dump storage is located at the persistent work media attribute of the cronjob (used for input).
  • Constructor Details

    • CronJobDumpHandler

      public CronJobDumpHandler(ImpExImportCronJob cronjob)
      Instantiates a new handler using the given cronjob for storing dump storages.
      Parameters:
      cronjob - used cronjob instance
  • Method Details

    • init

      public void init() throws IOException
      Description copied from interface: DumpHandler
      Initializes the handler by creating the first dump storage and providing a writer object to that storage when calling DumpHandler.getWriterOfCurrentDump().
      Throws:
      IOException - error while storage creation
    • finish

      public void finish(boolean saveCurrentDump)
      Description copied from interface: DumpHandler
      Deletes 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 ImpExException
      Description copied from interface: DumpHandler
      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). 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: DumpHandler
      Gets the current dump as media object.
      Specified by:
      getDumpAsMedia in interface DumpHandler
      Overrides:
      getDumpAsMedia in class AbstractDumpHandler
      Returns:
      current dump as media
    • createWriter

      protected CSVWriter createWriter() throws IOException
      Creates a new writer using a new created temp file as temporary dump.
      Returns:
      writer object to new temporary dump
      Throws:
      IOException - error while accessing file
    • createReader

      protected CSVReader createReader() throws IOException
      Creates a new reader using last dump media as input.
      Returns:
      reader object to last dump media
      Throws:
      IOException - error while accessing media
    • switchCurrentToLastDump

      protected void switchCurrentToLastDump() throws JaloBusinessException
      Switches 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 File getTempDump()
      Gets the temporary dump file.
      Returns:
      temporary dump file
    • setTempDump

      protected void setTempDump(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.