Using the CommonIntegrator getAlerts Method to Validate Field Values

After someone has configured a component using your custom source configuration type and saved the component, you can use the CommonIntegrator method getAlerts()to validate the provided values.

If the values are invalid, you can return a collection of alert messages to the UI. The default implementation of this method returns nothing. This method can be treated as a way to prevent integration failures by pre-checking all the required values.

An example implementation is as follows:

Private File location = null;

public Collection<String> getAlerts(Locale locale) throws Exception {
    if(location == null)
        return Arrays.asList("The Base Directory cannot be empty");

    File toCheck = new File(location);
    if(toCheck.exists())
        return null;

    return Arrays.asList("The Base Directory does not exist");
}

See the Javadoc and the example for more details.