String[] dirblacklist;
String[] sitelist;
String[] siteblacklist;
String[] imaplist;
Localizer localizer = mMultiLocalizer.getLocalizer(request.getLocale());
int port;
if (interval == -1) {
// This is the first call -> Load the settings
DesktopConfig desktopConfig = DesktopToolkit.getDesktopConfig();
Document crawlerDoc = XmlToolkit.loadXmlDocument(CRAWLER_CONFIG_FILE);
interval = desktopConfig.getInterval();
dirlist = getStartlistEntries(crawlerDoc, FILE_PROTOCOL);
dirblacklist = getBlacklistEntries(crawlerDoc, FILE_PROTOCOL);
sitelist = getStartlistEntries(crawlerDoc, HTTP_PROTOCOL);
siteblacklist = getBlacklistEntries(crawlerDoc, HTTP_PROTOCOL);
imaplist = getCompleteStartlistEntries(crawlerDoc, IMAP_PROTOCOL);
port = desktopConfig.getPort();
} else {
// There were new settings sent -> Check the input
ArrayList<String> errorList = new ArrayList<String>();
// Get the input
dirlist = request.getParametersNotNull("dirlist");
dirblacklist = request.getParametersNotNull("dirblacklist");
sitelist = request.getParametersNotNull("sitelist");
siteblacklist = request.getParametersNotNull("siteblacklist");
imaplist = request.getParametersNotNull("imaplist");
port = request.getParameterAsInt("port", DEFAULT_PORT);
// Check the input
checkDirectoryList(errorList, dirlist, localizer);
checkDirectoryList(errorList, dirblacklist, localizer);
checkWebsiteList(errorList, sitelist, localizer);
checkWebsiteList(errorList, siteblacklist, localizer);
checkImapList(errorList, imaplist, localizer);
if (errorList.isEmpty()) {
// There were no errors -> Save the values
saveSettings(interval, dirlist, dirblacklist, sitelist, siteblacklist, imaplist, port);
DesktopToolkit.checkWebserver();
response.print(localizer.msg("settingsSaved", "Your settings where saved!"));
// response.print("Ihre Einstellungen wurden gespeichert!");
} else {
// There were errors -> Show them
response.print(localizer.msg("settingsContainsError", "The following errors where detected:<ul>"));
// response.print("Leider enthält Ihre Eingabe noch Fehler:<ul>");
for (int i = 0; i < errorList.size(); i++) {
response.print("<li>" + errorList.get(i) + "</li>");
}
response.print("</ul>");