Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.gisgraphy.importer
Class AbstractFileRetriever

    java.lang.Object
      com.gisgraphy.importer.AbstractFileRetriever

All Implemented Interfaces:
  IImporterProcessor

Direct Known Subclasses:
  GeonamesFileRetriever, GeonamesZipCodeFileRetriever, OpenStreetMapFileRetriever

    public abstract class AbstractFileRetriever

extends Object
implements IImporterProcessor

Base class to download files from a server

Author:
  David Masclet

Field Summary
`protected String` | `currentFileName`
`protected int` | `fileIndex`
`protected ImporterConfig` | `importerConfig`
`protected static org.slf4j.Logger` | `logger` The logger
`protected int` | `numberOfFileToDownload`
`protected ImporterStatus` | `status`
`protected String` | `statusMessage`

Constructor Summary
`AbstractFileRetriever()`

Method Summary
`abstract void` | `decompressFiles()` Method to call if files must be decompress (untar or unzip)
`protected void` | `downloadFile(String file)`
`protected void` | `downloadFiles()`
`String` | `getCurrentFileName()`
`abstract String` | `getDownloadBaseUrl()`
`abstract String` | `getDownloadDirectory()`
`abstract File[]` | `getFilesToDecompress()` return an array of file that are to be decompressed
`long` | `getNumberOfLinesToProcess()`
`long` | `getReadFileLine()` The number of read line for the current processed file
`ImporterStatus` | `getStatus()`
`String` | `getStatusMessage()`
`long` | `getTotalReadLine()` The number of read line for all the processed file
`abstract boolean` | `isFileNotFoundTolerant()`
`void` | `process()` Do the stuff...
`void` | `resetStatus()` Reset status fields, it should be done when the import has been canceled
`List<NameValueDTO<Integer>>` | `rollback()` /!
`void` | `setImporterConfig(ImporterConfig importerConfig)`
`void` | `setInternationalisationService(IInternationalisationService internationalisationService)`
`boolean` | `shouldBeSkipped()`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### importerConfig

    protected ImporterConfig importerConfig

### currentFileName

    protected String currentFileName

### status

    protected ImporterStatus status

### fileIndex

    protected int fileIndex

### numberOfFileToDownload

    protected int numberOfFileToDownload

### statusMessage

    protected String statusMessage

### logger

    protected static final org.slf4j.Logger logger

  The logger

Constructor Detail

### AbstractFileRetriever

    public AbstractFileRetriever()

Method Detail

### process

    public void process()
                 throws ImporterException

  Description copied from interface: `IImporterProcessor`
  Do the stuff...

  Specified by:
    `process` in interface `IImporterProcessor`
  Throws:
    `ImporterException`

### downloadFiles

    protected void downloadFiles()

### downloadFile

    protected void downloadFile(String file)
                         throws FileNotFoundException

  Throws:
    `FileNotFoundException`

### isFileNotFoundTolerant

    public abstract boolean isFileNotFoundTolerant()

  Returns:
    false if download files that doesn't exists on the remote server should throw

### shouldBeSkipped

    public boolean shouldBeSkipped()

  Specified by:
    `shouldBeSkipped` in interface `IImporterProcessor`
  Returns:
    true if the processor should Not be executed

### decompressFiles

    public abstract void decompressFiles()
                                  throws IOException

  Method to call if files must be decompress (untar or unzip)

  Throws:
    `IOException`

### getFilesToDecompress

    public abstract File[] getFilesToDecompress()
                                         throws IOException

  return an array of file that are to be decompressed

  Throws:
    `IOException`

### getDownloadDirectory

    public abstract String getDownloadDirectory()

  Returns:
    The directory where the file should be downloaded

### getDownloadBaseUrl

    public abstract String getDownloadBaseUrl()

  Returns:
    the base URL from wich the file should be downloaded

### getReadFileLine

    public long getReadFileLine()

  Description copied from interface: `IImporterProcessor`
  The number of read line for the current processed file

  Specified by:
    `getReadFileLine` in interface `IImporterProcessor`
  See Also:
    `IImporterProcessor.getTotalReadLine()`

### getTotalReadLine

    public long getTotalReadLine()

  Description copied from interface: `IImporterProcessor`
  The number of read line for all the processed file

  Specified by:
    `getTotalReadLine` in interface `IImporterProcessor`
  See Also:
    `IImporterProcessor.getReadFileLine()`

### getCurrentFileName

    public String getCurrentFileName()

  Specified by:
    `getCurrentFileName` in interface `IImporterProcessor`
  Returns:
    The name of the file currently processed or null if no file is processed

### getNumberOfLinesToProcess

    public long getNumberOfLinesToProcess()

  Specified by:
    `getNumberOfLinesToProcess` in interface `IImporterProcessor`
  Returns:
    The number of line the processor will process. (it is not the number of lines left!)

### getStatus

    public ImporterStatus getStatus()

  Specified by:
    `getStatus` in interface `IImporterProcessor`
  Returns:
    The current status of the importer

### getStatusMessage

    public String getStatusMessage()

  Specified by:
    `getStatusMessage` in interface `IImporterProcessor`
  Returns:
    A text Message for the importer

### rollback

    public List<NameValueDTO<Integer>> rollback()

  Description copied from interface: `IImporterProcessor`
  /!\ USE THIS METHOD VERY CAREFULLY /!\ : If you call this function, all the imported data for the specified importer will be deleted

  Specified by:
    `rollback` in interface `IImporterProcessor`
  Returns:
    a NameValueDTO with the name of the deleted object and the number of deleted Object. No entry will be return for Object that were 0 object will be deleted except if an error occurred during the deletion.

### resetStatus

    public void resetStatus()

  Description copied from interface: `IImporterProcessor`
  Reset status fields, it should be done when the import has been canceled

  Specified by:
    `resetStatus` in interface `IImporterProcessor`

### setImporterConfig

    public void setImporterConfig(ImporterConfig importerConfig)

  Parameters:
    `importerConfig` - The importerConfig to set

### setInternationalisationService

    public void setInternationalisationService(IInternationalisationService internationalisationService)

  Parameters:
    `internationalisationService` - the internationalisationService to set

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2012. All Rights Reserved.