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

## org.owasp.dependencycheck.data.update
Class AbstractUpdateTask

    java.lang.Object
      org.owasp.dependencycheck.data.update.AbstractUpdateTask

All Implemented Interfaces:
  UpdateTask

Direct Known Subclasses:
  BatchUpdateTask, StandardUpdateTask

    public abstract class AbstractUpdateTask

extends Object
implements UpdateTask

Class responsible for updating the CPE and NVDCVE data stores.

Author:
  Jeremy Long (jeremy.long@owasp.org)

Constructor Summary
`AbstractUpdateTask(DataStoreMetaInfo properties)` Initializes the AbstractUpdateTask.

Method Summary
`protected void` | `closeDataStores()` Closes the CVE and CPE data stores.
`protected void` | `deleteExistingData()` Deletes the existing data directories.
`protected CpeIndexWriter` | `getCpeIndex()` Returns the CpeIndex.
`protected CveDB` | `getCveDB()` Returns the CveDB.
`protected DataStoreMetaInfo` | `getProperties()` Returns the data store properties.
`protected Updateable` | `getUpdateable()` Gets the updateable NVD CVE Entries.
`protected void` | `importXML(File file, File oldVersion)` Imports the NVD CVE XML File into the Lucene Index.
`boolean` | `isUpdateNeeded()` Gets whether or not an update is needed.
`protected void` | `openDataStores()` Opens the CVE and CPE data stores.
`protected void` | `setDeleteAndRecreate(boolean deleteAndRecreate)` Set the value of deleteAndRecreate.
`boolean` | `shouldDeleteAndRecreate()` Get the value of deleteAndRecreate.
`abstract void` | `update()` Updates the data store to the latest version.
`protected abstract Updateable` | `updatesNeeded()` Determines if the index needs to be updated.
`protected boolean` | `withinRange(long date, long compareTo, int range)` Determines if the epoch date is within the range specified of the compareTo epoch time.

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

Constructor Detail

### AbstractUpdateTask

    public AbstractUpdateTask(DataStoreMetaInfo properties)
                       throws MalformedURLException,
                              DownloadFailedException,
                              UpdateException

  Initializes the AbstractUpdateTask.

  Parameters:
    `properties` - information about the data store
  Throws:
    `MalformedURLException` - thrown if the configuration contains a malformed url
    `DownloadFailedException` - thrown if the timestamp on a file cannot be checked
    `UpdateException` - thrown if the update fails

Method Detail

### getProperties

    protected DataStoreMetaInfo getProperties()

  Returns the data store properties.

  Returns:
    the data store properties

### getCveDB

    protected CveDB getCveDB()

  Returns the CveDB.

  Returns:
    the CveDB

### getCpeIndex

    protected CpeIndexWriter getCpeIndex()

  Returns the CpeIndex.

  Returns:
    the CpeIndex

### isUpdateNeeded

    public boolean isUpdateNeeded()

  Gets whether or not an update is needed.

  Specified by:
    `isUpdateNeeded` in interface `UpdateTask`
  Returns:
    true or false depending on whether an update is needed

### getUpdateable

    protected Updateable getUpdateable()

  Gets the updateable NVD CVE Entries.

  Returns:
    an Updateable object containing the NVD CVE entries

### updatesNeeded

    protected abstract Updateable updatesNeeded()
                                         throws MalformedURLException,
                                                DownloadFailedException,
                                                UpdateException

  Determines if the index needs to be updated.

  Returns:
    a collection of updateable resources.
  Throws:
    `MalformedURLException` - is thrown if the URL for the NVD CVE Meta data is incorrect.
    `DownloadFailedException` - is thrown if there is an error. downloading the NVD CVE download data file.
    `UpdateException` - Is thrown if there is an issue with the last updated properties file.

### update

    public abstract void update()
                         throws UpdateException

  Updates the data store to the latest version.

  Specified by:
    `update` in interface `UpdateTask`
  Throws:
    `UpdateException` - is thrown if there is an error updating the database

### shouldDeleteAndRecreate

    public boolean shouldDeleteAndRecreate()

  Get the value of deleteAndRecreate.

  Specified by:
    `shouldDeleteAndRecreate` in interface `UpdateTask`
  Returns:
    the value of deleteAndRecreate

### setDeleteAndRecreate

    protected void setDeleteAndRecreate(boolean deleteAndRecreate)

  Set the value of deleteAndRecreate.

  Parameters:
    `deleteAndRecreate` - new value of deleteAndRecreate

### deleteExistingData

    protected void deleteExistingData()
                               throws IOException

  Deletes the existing data directories.

  Throws:
    `IOException` - thrown if the directory cannot be deleted

### closeDataStores

    protected void closeDataStores()

  Closes the CVE and CPE data stores.

### openDataStores

    protected void openDataStores()
                           throws UpdateException

  Opens the CVE and CPE data stores.

  Throws:
    `UpdateException` - thrown if a data store cannot be opened

### withinRange

    protected boolean withinRange(long date,
                                  long compareTo,
                                  int range)

  Determines if the epoch date is within the range specified of the compareTo epoch time. This takes the (compareTo-date)/1000/60/60/24 to get the number of days. If the calculated days is less then the range the date is considered valid.

  Parameters:
    `date` - the date to be checked.
    `compareTo` - the date to compare to.
    `range` - the range in days to be considered valid.
  Returns:
    whether or not the date is within the range.

### importXML

    protected void importXML(File file,
                             File oldVersion)
                      throws ParserConfigurationException,
                             SAXException,
                             IOException,
                             SQLException,
                             DatabaseException,
                             ClassNotFoundException

  Imports the NVD CVE XML File into the Lucene Index.

  Parameters:
    `file` - the file containing the NVD CVE XML
    `oldVersion` - contains the file containing the NVD CVE XML 1.2
  Throws:
    `ParserConfigurationException` - is thrown if there is a parser configuration exception
    `SAXException` - is thrown if there is a SAXException
    `IOException` - is thrown if there is a IO Exception
    `SQLException` - is thrown if there is a SQL exception
    `DatabaseException` - is thrown if there is a database exception
    `ClassNotFoundException` - thrown if the h2 database driver cannot be loaded

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-2013 OWASP. All Rights Reserved.