16. Harvesting

16.1 Structure

The harvesting capability is built around 3 areas: Javascript code, Java code and XSL stylesheets (on both the server and client side).

Javascript code

This refers to the web interface. The code is located in the web/geonetwork/scripts/harvesting folder. Here, there is a subfolder for each harvesting type plus some classes for the main page. These are:

  1. harvester.js : This is an abstract class that must be implemented by harvesting types. It defines some information retrieval methods (getType, getLabel, etc...) used to handle the harvesting type, plus one getUpdateRequest method used to build the XML request to insert or update entries.

  2. harvester-model.js : Another abstract class that must be implemented by harvesting types. When creating the XML request, the only method substituteCommon takes care of adding common information like privileges and categories taken from the user interface.

  3. harvester-view.js : This is an important abstract class that must be implemented by harvesting types. It takes care of many common aspects of the user interface. It provides methods to add group’s privileges, to select categories, to check data for validity and to set and get common data from the user interface.

  4. harvesting.js : This is the main Javascript file that takes care of everything. It starts all the submodules, loads XML strings from the server and displays the main page that lists all harvesting nodes.

  5. model.js : Performs all XML requests to the server, handles errors and decode responses.

  6. view.js : Handles all updates and changes on the main page.

  7. util.js : just a couple of utility methods.

Java code

The harvesting package is located in src/org/fao/geonet/kernel/harvest. Here too, there is one subfolder for each harvesting type. The most important classes for the implementor are:

  1. AbstractHarvester : This is the main class that a new harvesting type must extends. It takes care of all aspects like adding, updating, removing, starting, stopping of harvesting nodes. Some abstract methods must be implemented to properly tune the behaviour of a particular harvesting type.

  2. AbstractParams : All harvesting parameters must be enclosed in a class that extends this abstract one. Doing so, all common parameters can be transparently handled by this abstract class.

All others are small utility classes used by harvesting types.

XSL stylesheets

Stylesheets are spread in some foders and are used by both the Javascript code and the server. The main folder is located at web/geonetwork/xsl/harvesting. Here there are some general stylesheets, plus one subfolder for each harvesting type. The general stylesheets are:

  1. buttons.xsl : Defines all button present in the main page (activate, deactivate, run, remove, back, add, refresh), buttons present in the "add new harvesting" page (back and add) and at the bottom of the edit page (back and save).

  2. client-error-tip.xsl : This stylesheet is used by the browser to build tooltips when an harvesting error occured. It will show the error class, the message and the stacktrace.

  3. client-node-row.xsl : This is also used by the browser to add one row to the list of harvesting nodes in the main page.

  4. harvesting.xsl : This is the main stylesheet. It generates the html page of the main page and includes all panels from all the harvesting nodes.

In each subfolder, there are usually 4 files:

  1. xxx.xsl : This is the server stylesheets who builds all panels for editing the parameters. XXX is the harvesting type. Usually, it has the following panels: site information, search criteria, options, privileges and categories.

  2. client-privil-row.xsl : This is used by the Javascript code to add rows in the group’s privileges panel.

  3. client-result-tip.xsl : This is used by the Javascript code (which inherits from harvester-view.js) to show the tooltip when the harvesting has been successfull.

  4. client-search-row.xsl : Used in some harvesting types to generate the html for the search criteria panel.

As you may have guessed, all client side stylesheets (those used by Javascript code) start with the prefix client-.

Another set of stylesheets are located in web/geonetwork/xsl/xml/harvesting and are used by the xml.harvesting.get service. This service is used by the Javascript code to retrieve all the nodes the system is currently harvesting from. This implies that a stylesheet (one for each harvesting type) must be provided to convert from the internal setting structure to an XML structure suitable to clients.

The last file to take into consideration contains all localized strings and is located at web/geonetwork/loc/XX/xml/harvesting.xml (where XX refers to a language code). This file is used by both Javascript code and the server.

Other documents: The complete manual in pdf format | License | Readme | Changes