From b1c905d1a826b0fdd2947c58ace76d1347ede54a Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 22 Jan 2010 15:58:17 +0100 Subject: [PATCH] Factor out project validation, re-order warning and error messages. --- .../jsite/application/ProjectInserter.java | 193 +++++++++++++++++++++ src/de/todesbaum/jsite/i18n/jSite.properties | 24 +-- src/de/todesbaum/jsite/i18n/jSite_de.properties | 24 +-- src/de/todesbaum/jsite/main/Main.java | 61 ++----- 4 files changed, 231 insertions(+), 71 deletions(-) diff --git a/src/de/todesbaum/jsite/application/ProjectInserter.java b/src/de/todesbaum/jsite/application/ProjectInserter.java index 569e2fe..c8c5e93 100644 --- a/src/de/todesbaum/jsite/application/ProjectInserter.java +++ b/src/de/todesbaum/jsite/application/ProjectInserter.java @@ -27,14 +27,19 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Set; +import java.util.Map.Entry; import java.util.logging.Level; import java.util.logging.Logger; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; +import de.todesbaum.jsite.application.ProjectInserter.CheckReport.Issue; import de.todesbaum.jsite.gui.FileScanner; import de.todesbaum.jsite.gui.FileScannerListener; import de.todesbaum.util.freenet.fcp2.Client; @@ -380,6 +385,60 @@ public class ProjectInserter implements FileScannerListener, Runnable { } /** + * Validates the given project. The project will be checked for any invalid + * conditions, such as invalid insert or request keys, missing path names, + * missing default file, and so on. + * + * @param project + * The project to check + * @return The encountered warnings and errors + */ + public static CheckReport validateProject(Project project) { + CheckReport checkReport = new CheckReport(); + if ((project.getLocalPath() == null) || (project.getLocalPath().trim().length() == 0)) { + checkReport.addIssue("error.no-local-path", true); + } + if ((project.getPath() == null) || (project.getPath().trim().length() == 0)) { + checkReport.addIssue("error.no-path", true); + } + if ((project.getIndexFile() == null) || (project.getIndexFile().length() == 0)) { + checkReport.addIssue("warning.empty-index", false); + } else { + File indexFile = new File(project.getLocalPath(), project.getIndexFile()); + if (!indexFile.exists()) { + checkReport.addIssue("error.index-missing", true); + } + } + String indexFile = project.getIndexFile(); + boolean hasIndexFile = (indexFile != null); + if (hasIndexFile && !project.getFileOption(indexFile).getContainer().equals("")) { + checkReport.addIssue("warning.container-index", false); + } + List allowedIndexContentTypes = Arrays.asList("text/html", "application/xhtml+xml"); + if (hasIndexFile && !allowedIndexContentTypes.contains(project.getFileOption(indexFile).getMimeType())) { + checkReport.addIssue("warning.index-not-html", false); + } + Map fileOptions = project.getFileOptions(); + Set> fileOptionEntries = fileOptions.entrySet(); + boolean insert = false; + for (Entry fileOptionEntry : fileOptionEntries) { + String fileName = fileOptionEntry.getKey(); + FileOption fileOption = fileOptionEntry.getValue(); + insert |= fileOption.isInsert() || fileOption.isInsertRedirect(); + if (fileName.equals(project.getIndexFile()) && !fileOption.isInsert() && !fileOption.isInsertRedirect()) { + checkReport.addIssue("error.index-not-inserted", true); + } + if (!fileOption.isInsert() && fileOption.isInsertRedirect() && ((fileOption.getCustomKey().length() == 0) || "CHK@".equals(fileOption.getCustomKey()))) { + checkReport.addIssue("error.no-custom-key", true, fileName); + } + } + if (!insert) { + checkReport.addIssue("error.no-files-to-insert", true); + } + return checkReport; + } + + /** * {@inheritDoc} */ public void run() { @@ -499,4 +558,138 @@ public class ProjectInserter implements FileScannerListener, Runnable { fileScanner.removeFileScannerListener(this); } + /** + * Container class that collects all warnings and errors that occured during + * {@link ProjectInserter#validateProject(Project) project validation}. + * + * @author David ‘Bombe’ Roden + */ + public static class CheckReport implements Iterable { + + /** The issures that occured. */ + private final List issues = new ArrayList(); + + /** + * Adds an issue. + * + * @param issue + * The issue to add + */ + public void addIssue(Issue issue) { + issues.add(issue); + } + + /** + * Creates an {@link Issue} from the given error key and fatality flag + * and {@link #addIssue(Issue) adds} it. + * + * @param errorKey + * The error key + * @param fatal + * {@code true} if the error is fatal, {@code false} if only + * a warning should be generated + * @param parameters + * Any additional parameters + */ + public void addIssue(String errorKey, boolean fatal, String... parameters) { + addIssue(new Issue(errorKey, fatal, parameters)); + } + + /** + * {@inheritDoc} + */ + public Iterator iterator() { + return issues.iterator(); + } + + /** + * Returns whether this check report does not contain any errors. + * + * @return {@code true} if this check report does not contain any + * errors, {@code false} if this check report does contain + * errors + */ + public boolean isEmpty() { + return issues.isEmpty(); + } + + /** + * Returns the number of issues in this check report. + * + * @return The number of issues + */ + public int size() { + return issues.size(); + } + + /** + * Container class for a single issue. An issue contains an error key + * that describes the error, and a fatality flag that determines whether + * the insert has to be aborted (if the flag is {@code true}) or if it + * can still be performed and only a warning should be generated (if the + * flag is {@code false}). + * + * @author David ‘Bombe’ + * Roden + */ + public static class Issue { + + /** The error key. */ + private final String errorKey; + + /** The fatality flag. */ + private final boolean fatal; + + /** Additional parameters. */ + private String[] parameters; + + /** + * Creates a new issue. + * + * @param errorKey + * The error key + * @param fatal + * The fatality flag + * @param parameters + * Any additional parameters + */ + protected Issue(String errorKey, boolean fatal, String... parameters) { + this.errorKey = errorKey; + this.fatal = fatal; + this.parameters = parameters; + } + + /** + * Returns the key of the encountered error. + * + * @return The error key + */ + public String getErrorKey() { + return errorKey; + } + + /** + * Returns whether the issue is fatal and the insert has to be + * aborted. Otherwise only a warning should be shown. + * + * @return {@code true} if the insert needs to be aborted, {@code + * false} otherwise + */ + public boolean isFatal() { + return fatal; + } + + /** + * Returns any additional parameters. + * + * @return The additional parameters + */ + public String[] getParameters() { + return parameters; + } + + } + + } + } diff --git a/src/de/todesbaum/jsite/i18n/jSite.properties b/src/de/todesbaum/jsite/i18n/jSite.properties index cd6ac67..db78119 100644 --- a/src/de/todesbaum/jsite/i18n/jSite.properties +++ b/src/de/todesbaum/jsite/i18n/jSite.properties @@ -124,8 +124,6 @@ jsite.project.project.path=Freesite Path jsite.project.project.edition=Edition jsite.project.project.uri=URI jsite.project.keygen.io-error=Node communication failure

Communication with the node failed
with the following error message:

{0}

Please make sure that you have entered
the correct host name and port number
on the "Node Settings" page. -jsite.project.warning.no-local-path=No local path

You did not specify a local path for the files to insert.
It is not possible to continue without one. -jsite.project.warning.no-path=No freesite path

You did not specify a freesite path.
It is not possible to continue without one. jsite.project.warning.generate-new-key=Generate new key?

If you generate a new key, your site will be published
under that new key. Any trust that other users put
in the old key of your site will be gone! jsite.project.warning.reset-edition=Reset edition?

Resetting the edition can lead to insert failures
and lots of confusion if you have not changed
the path or the keys of the project! jsite.project.warning.use-clipboard-now=URI copied

Please note that it is possible that quitting jSite
now will empty the clipboard. Please use the
copied URI immediately in another window! @@ -163,15 +161,6 @@ jsite.project-files.replacement.tooltip=Activates replacements in file jsite.project-files.replacement.edition-range=Range jsite.project-files.replacement.edition-range.tooltip=Also replace $[EDITION+1], $[EDITION+2]\u2026 jsite.project-files.scan-error=Error scanning files

Either the directory of the project does not exist
or some files/directories in it are not accessible.
Please go back and select the correct directory. -jsite.project-files.empty-index=No default file

You did not specify a default file for this project.
While it is possible to insert a project without a default
file you should specify one to ease browsing. -jsite.project-files.index-missing=Your default file is missing

A default file was previously specified but it
does not exist anymore! Please select
a new default file in the list of files. -jsite.project-files.container-index=Default file in container

Your default file was placed in a container!
This might make other people shun your page. -jsite.project-files.index-not-html=Default file is not HTML

Your default file does not have the MIME type "text/html"!
Loading your Freesite in a browser may give unexpected results. -jsite.project-files.no-node-running=Node is not running

You can not insert a project if your node is not running.
Please start your node and try again. -jsite.project-files.no-custom-key=No custom key for file

You specified not to insert {0}
but failed to enter a key to redirect to! -jsite.project-files.no-node-selected=No node selected

Please select a node from the menu! -jsite.project-files.no-files-to-insert=No files to insert

You do not have any files selected for insertion!
Please select at least one file to insert. -jsite.project-files.index-not-inserted=Default file not inserted

You have chosen not to insert the default file!
You need to either choose to insert it or select
a different default file! jsite.project-files.insert-now=Insert now jsite.update-checker.found-version.title=Found New Version @@ -190,3 +179,16 @@ jsite.key-dialog.label.keys=Keys jsite.key-dialog.label.private-key=Private Key jsite.key-dialog.label.public-key=Public Key jsite.key-dialog.label.actions=Actions + +jsite.warning.empty-index=No default file

You did not specify a default file for this project.
While it is possible to insert a project without a default
file you should specify one to ease browsing. +jsite.warning.container-index=Default file in container

Your default file was placed in a container!
This might make other people shun your page. +jsite.warning.index-not-html=Default file is not HTML

Your default file does not have the MIME type "text/html"!
Loading your Freesite in a browser may give unexpected results. + +jsite.error.no-node-selected=No node selected

Please select a node from the menu! +jsite.error.no-node-running=Node is not running

You can not insert a project if your node is not running.
Please start your node and try again. +jsite.error.no-local-path=No local path

You did not specify a local path for the files to insert.
It is not possible to continue without one. +jsite.error.no-path=No freesite path

You did not specify a freesite path.
It is not possible to continue without one. +jsite.error.index-missing=Your default file is missing

A default file was previously specified but it
does not exist anymore! Please select
a new default file in the list of files. +jsite.error.index-not-inserted=Default file not inserted

You have chosen not to insert the default file!
You need to either choose to insert it or select
a different default file! +jsite.error.no-custom-key=No custom key for file

You specified not to insert {0}
but failed to enter a key to redirect to! +jsite.error.no-files-to-insert=No files to insert

You do not have any files selected for insertion!
Please select at least one file to insert. diff --git a/src/de/todesbaum/jsite/i18n/jSite_de.properties b/src/de/todesbaum/jsite/i18n/jSite_de.properties index efa121e..6c303ff 100644 --- a/src/de/todesbaum/jsite/i18n/jSite_de.properties +++ b/src/de/todesbaum/jsite/i18n/jSite_de.properties @@ -124,8 +124,6 @@ jsite.project.project.path=Seitenpfad jsite.project.project.edition=Edition jsite.project.project.uri=Anfrage-URI jsite.project.keygen.io-error=Kommunikation fehlgeschlagen

Die Kommunikation mit dem Freenet Node
ergab folgende Fehlermeldung:

{0}

Bitte vergewissern Sie sich, dass der Node l\u00e4uft und dass Sie
den korrekten Hostnamen und die korrekte Portnummer auf der
\u201eNode Einstellungen\u201c Seite eingegeben haben. -jsite.project.warning.no-local-path=Kein lokaler Pfad

Sie haben keinen lokalen Pfad f\u00fcr die einzuf\u00fcgenden Dateien angegeben.
Es ist nicht m\u00f6glich, ohne lokalen Pfad weiter zu machen. -jsite.project.warning.no-path=Kein Freesite-Pfad

Sie haben keinen Pfad f\u00fcr die Freesite angegeben.
Es ist nicht m\u00f6glich, ohne einen Freesite-Pfad weiter zu machen. jsite.project.warning.generate-new-key=Neues Schl\u00fcsselpaar generieren?

Wenn Sie das Schl\u00fcsselpaar f\u00fcr das Projekt \u00e4ndern,
wird sich die URI f\u00fcr Ihr Projekt ebenfalls
\u00e4ndern, und jegliches Vertrauen, dass andere
Benutzer in das alte Schl\u00fcsselpaar hatten, wird
verloren gehen! jsite.project.warning.reset-edition=Edition zur\u00fccksetzen?

Das Zur\u00fccksetzen der Editionsnummer kann zum
Fehlschlagen des Einf\u00fcgens f\u00fchren, wenn sich nicht
auch die URI oder der Pfad des Projekts ge\u00e4ndert haben! jsite.project.warning.use-clipboard-now=Anfrage-URI kopiert

Bitte beachten Sie, dass die Zwischenablage nach dem
Beenden von jSite eventuell nicht mehr die kopierte
URI enth\u00e4lt. Bitte f\u00fcgen Sie sie daher schleunigst in
ein anderes Programm ein! @@ -163,15 +161,6 @@ jsite.project-files.replacement.tooltip=Aktiviert Ersetzungen in Datei jsite.project-files.replacement.edition-range=Reichweite jsite.project-files.replacement.edition-range.tooltip=Ersetzt auch $[EDITION+1], $[EDITION+2], usw. jsite.project-files.scan-error=Fehler beim Einlesen der Dateien

Entweder existiert das Projektverzeichnis nicht,
oder einige Dateien und/oder Verzeichnisse sind nicht lesbar!
Bitte gehen Sie zur\u00fcck und beheben Sie den Fehler! -jsite.project-files.empty-index=Keine Index-Datei gew\u00e4hlt

Sie haben keine Index-Datei f\u00fcr das Projekt angegeben.
Obwohl es m\u00f6glich ist, das zu machen, sollten Sie doch
eine Index-Datei angeben, um das Browsen zu erleichtern. -jsite.project-files.index-missing=Index-Datei fehlt!

Sie haben eine Index-Datei f\u00fcr das Project gew\u00e4hlt,
aber diese Index-Datei existiert nicht mehr!
Bitte w\u00e4hlen Sie eine neue Index-Datei. -jsite.project-files.container-index=Index-Datei in Container

Ihre Index-Datei befindet sich in einem Container! Das kann
dazu f\u00fchren, dass Ihre Freesite von anderen Leuten gemieden wird. -jsite.project-files.index-not-html=Index-Datei ist kein HTML

Ihre Index-Datei hat nicht den MIME-Typ "text/html"!
Das kann beim Besuch Ihrer Freesite zu
unerwarteten Ergebnissen f\u00fchren. -jsite.project-files.no-node-running=Der Node l\u00e4uft nicht

Sie k\u00f6nnen das Projekt nicht einf\u00fcgen, wenn
Ihr Node nicht l\u00e4uft. Bitte starten Sie Ihren Node
und probieren Sie es erneut. -jsite.project-files.no-custom-key=Kein externer Schl\u00fcssel

Sie haben angegeben, dass die Datei {0}
nicht eingef\u00fcgt werden soll. Allerdings haben Sie
keinen extern erstellten Schl\u00fcssel angegeben. -jsite.project-files.no-node-selected=Kein Node ausgew\u00e4hlt

Bitte w\u00e4hlen Sie einen Node aus dem Men\u00fc! -jsite.project-files.no-files-to-insert=Keine Dateien einzuf\u00fcgen

Es sind keine Dateien zum Einf\u00fcgen ausgew\u00e4hlt! Bitte
w\u00e4hlen Sie mindestens eine Datei zum Einf\u00fcgen aus! -jsite.project-files.index-not-inserted=Index-Datei nicht eingef\u00fcgt

Die index-Datei ist nicht zum Einf\u00fcgen ausgew\u00e4hlt!
Sie m\u00fcssen entweder w\u00e4hlen, die Index-Datei einzuf\u00fcgen,
oder Sie m\u00fcssen eine andere Index-Datei ausw\u00e4hlen! jsite.project-files.insert-now=Jetzt einf\u00fcgen jsite.update-checker.found-version.title=Neue Version gefunden @@ -190,3 +179,16 @@ jsite.key-dialog.label.keys=Schl\u00fcssel jsite.key-dialog.label.private-key=Privater Schl\u00fcssel jsite.key-dialog.label.public-key=\u00d6ffentlicher Schl\u00fcssel jsite.key-dialog.label.actions=Aktionen + +jsite.warning.empty-index=Keine Index-Datei gew\u00e4hlt

Sie haben keine Index-Datei f\u00fcr das Projekt angegeben.
Obwohl es m\u00f6glich ist, das zu machen, sollten Sie doch
eine Index-Datei angeben, um das Browsen zu erleichtern. +jsite.warning.container-index=Index-Datei in Container

Ihre Index-Datei befindet sich in einem Container! Das kann
dazu f\u00fchren, dass Ihre Freesite von anderen Leuten gemieden wird. +jsite.warning.index-not-html=Index-Datei ist kein HTML

Ihre Index-Datei hat nicht den MIME-Typ "text/html"!
Das kann beim Besuch Ihrer Freesite zu
unerwarteten Ergebnissen f\u00fchren. + +jsite.error.no-node-selected=Kein Node ausgew\u00e4hlt

Bitte w\u00e4hlen Sie einen Node aus dem Men\u00fc! +jsite.error.no-node-running=Der Node l\u00e4uft nicht

Sie k\u00f6nnen das Projekt nicht einf\u00fcgen, wenn
Ihr Node nicht l\u00e4uft. Bitte starten Sie Ihren Node
und probieren Sie es erneut. +jsite.error.no-local-path=Kein lokaler Pfad

Sie haben keinen lokalen Pfad f\u00fcr die einzuf\u00fcgenden Dateien angegeben.
Es ist nicht m\u00f6glich, ohne lokalen Pfad weiter zu machen. +jsite.error.no-path=Kein Freesite-Pfad

Sie haben keinen Pfad f\u00fcr die Freesite angegeben.
Es ist nicht m\u00f6glich, ohne einen Freesite-Pfad weiter zu machen. +jsite.error.index-missing=Index-Datei fehlt!

Sie haben eine Index-Datei f\u00fcr das Project gew\u00e4hlt,
aber diese Index-Datei existiert nicht mehr!
Bitte w\u00e4hlen Sie eine neue Index-Datei. +jsite.error.index-not-inserted=Index-Datei nicht eingef\u00fcgt

Die index-Datei ist nicht zum Einf\u00fcgen ausgew\u00e4hlt!
Sie m\u00fcssen entweder w\u00e4hlen, die Index-Datei einzuf\u00fcgen,
oder Sie m\u00fcssen eine andere Index-Datei ausw\u00e4hlen! +jsite.error.no-custom-key=Kein externer Schl\u00fcssel

Sie haben angegeben, dass die Datei {0}
nicht eingef\u00fcgt werden soll. Allerdings haben Sie
keinen extern erstellten Schl\u00fcssel angegeben. +jsite.error.no-files-to-insert=Keine Dateien einzuf\u00fcgen

Es sind keine Dateien zum Einf\u00fcgen ausgew\u00e4hlt! Bitte
w\u00e4hlen Sie mindestens eine Datei zum Einf\u00fcgen aus! diff --git a/src/de/todesbaum/jsite/main/Main.java b/src/de/todesbaum/jsite/main/Main.java index 517f48a..cc540ea 100644 --- a/src/de/todesbaum/jsite/main/Main.java +++ b/src/de/todesbaum/jsite/main/Main.java @@ -21,17 +21,12 @@ package de.todesbaum.jsite.main; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.io.File; import java.io.IOException; import java.text.MessageFormat; -import java.util.Arrays; import java.util.Date; import java.util.HashMap; -import java.util.List; import java.util.Locale; import java.util.Map; -import java.util.Set; -import java.util.Map.Entry; import java.util.logging.ConsoleHandler; import java.util.logging.Handler; import java.util.logging.Level; @@ -50,12 +45,14 @@ import javax.swing.JRadioButtonMenuItem; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; -import de.todesbaum.jsite.application.FileOption; import de.todesbaum.jsite.application.Freenet7Interface; import de.todesbaum.jsite.application.Node; import de.todesbaum.jsite.application.Project; +import de.todesbaum.jsite.application.ProjectInserter; import de.todesbaum.jsite.application.UpdateChecker; import de.todesbaum.jsite.application.UpdateListener; +import de.todesbaum.jsite.application.ProjectInserter.CheckReport; +import de.todesbaum.jsite.application.ProjectInserter.CheckReport.Issue; import de.todesbaum.jsite.gui.NodeManagerListener; import de.todesbaum.jsite.gui.NodeManagerPage; import de.todesbaum.jsite.gui.PreferencesPage; @@ -496,11 +493,11 @@ public class Main implements ActionListener, ListSelectionListener, WizardListen ProjectPage projectPage = (ProjectPage) wizard.getPage(); Project project = projectPage.getSelectedProject(); if ((project.getLocalPath() == null) || (project.getLocalPath().trim().length() == 0)) { - JOptionPane.showMessageDialog(wizard, I18n.getMessage("jsite.project.warning.no-local-path"), null, JOptionPane.ERROR_MESSAGE); + JOptionPane.showMessageDialog(wizard, I18n.getMessage("jsite.warning.no-local-path"), null, JOptionPane.ERROR_MESSAGE); return; } if ((project.getPath() == null) || (project.getPath().trim().length() == 0)) { - JOptionPane.showMessageDialog(wizard, I18n.getMessage("jsite.project.warning.no-path"), null, JOptionPane.ERROR_MESSAGE); + JOptionPane.showMessageDialog(wizard, I18n.getMessage("jsite.warning.no-path"), null, JOptionPane.ERROR_MESSAGE); return; } ((ProjectFilesPage) pages.get(PageType.PAGE_PROJECT_FILES)).setProject(project); @@ -510,53 +507,19 @@ public class Main implements ActionListener, ListSelectionListener, WizardListen ProjectPage projectPage = (ProjectPage) pages.get(PageType.PAGE_PROJECTS); Project project = projectPage.getSelectedProject(); if (selectedNode == null) { - JOptionPane.showMessageDialog(wizard, I18n.getMessage("jsite.project-files.no-node-selected"), null, JOptionPane.ERROR_MESSAGE); + JOptionPane.showMessageDialog(wizard, I18n.getMessage("jsite.error.no-node-selected"), null, JOptionPane.ERROR_MESSAGE); return; } - if ((project.getIndexFile() == null) || (project.getIndexFile().length() == 0)) { - if (JOptionPane.showConfirmDialog(wizard, I18n.getMessage("jsite.project-files.empty-index"), null, JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE) != JOptionPane.OK_OPTION) { + CheckReport checkReport = ProjectInserter.validateProject(project); + for (Issue issue : checkReport) { + if (issue.isFatal()) { + JOptionPane.showMessageDialog(wizard, MessageFormat.format(I18n.getMessage("jsite." + issue.getErrorKey()), (Object[]) issue.getParameters()), null, JOptionPane.ERROR_MESSAGE); return; } - } else { - File indexFile = new File(project.getLocalPath(), project.getIndexFile()); - if (!indexFile.exists()) { - JOptionPane.showMessageDialog(wizard, I18n.getMessage("jsite.project-files.index-missing"), null, JOptionPane.ERROR_MESSAGE); + if (JOptionPane.showConfirmDialog(wizard, MessageFormat.format(I18n.getMessage("jsite." + issue.getErrorKey()), (Object[]) issue.getParameters()), null, JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE) != JOptionPane.OK_OPTION) { return; } } - String indexFile = project.getIndexFile(); - boolean hasIndexFile = (indexFile != null); - if (hasIndexFile && !project.getFileOption(indexFile).getContainer().equals("")) { - if (JOptionPane.showConfirmDialog(wizard, I18n.getMessage("jsite.project-files.container-index"), null, JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE) != JOptionPane.OK_OPTION) { - return; - } - } - List allowedIndexContentTypes = Arrays.asList("text/html", "application/xhtml+xml"); - if (hasIndexFile && !allowedIndexContentTypes.contains(project.getFileOption(indexFile).getMimeType())) { - if (JOptionPane.showConfirmDialog(wizard, I18n.getMessage("jsite.project-files.index-not-html"), null, JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE) != JOptionPane.OK_OPTION) { - return; - } - } - Map fileOptions = project.getFileOptions(); - Set> fileOptionEntries = fileOptions.entrySet(); - boolean insert = false; - for (Entry fileOptionEntry : fileOptionEntries) { - String fileName = fileOptionEntry.getKey(); - FileOption fileOption = fileOptionEntry.getValue(); - insert |= fileOption.isInsert() || fileOption.isInsertRedirect(); - if (fileName.equals(project.getIndexFile()) && !fileOption.isInsert() && !fileOption.isInsertRedirect()) { - JOptionPane.showMessageDialog(wizard, I18n.getMessage("jsite.project-files.index-not-inserted"), null, JOptionPane.ERROR_MESSAGE); - return; - } - if (!fileOption.isInsert() && fileOption.isInsertRedirect() && ((fileOption.getCustomKey().length() == 0) || "CHK@".equals(fileOption.getCustomKey()))) { - JOptionPane.showMessageDialog(wizard, MessageFormat.format(I18n.getMessage("jsite.project-files.no-custom-key"), fileOptionEntry.getKey()), null, JOptionPane.ERROR_MESSAGE); - return; - } - } - if (!insert) { - JOptionPane.showMessageDialog(wizard, I18n.getMessage("jsite.project-files.no-files-to-insert"), null, JOptionPane.ERROR_MESSAGE); - return; - } boolean nodeRunning = false; try { nodeRunning = freenetInterface.isNodePresent(); @@ -564,7 +527,7 @@ public class Main implements ActionListener, ListSelectionListener, WizardListen /* ignore. */ } if (!nodeRunning) { - JOptionPane.showMessageDialog(wizard, I18n.getMessage("jsite.project-files.no-node-running"), null, JOptionPane.ERROR_MESSAGE); + JOptionPane.showMessageDialog(wizard, I18n.getMessage("jsite.error.no-node-running"), null, JOptionPane.ERROR_MESSAGE); return; } configuration.save(); -- 2.7.4