[Dive4elements-commits] [PATCH] ${help.url} in states helpText attributes now evaluates to /artifact-database/help-url/text() from configuration
Wald Commits
scm-commit at wald.intevation.org
Mon Apr 15 12:30:41 CEST 2013
# HG changeset patch
# User Sascha L. Teichmann <teichmann at intevation.de>
# Date 1366021838 -7200
# Node ID 402cd5464723ccf9b33df52b253e0af0e6250a61
# Parent 2d828a605669b328e766af34002aefae59941f00
${help.url} in states helpText attributes now evaluates to /artifact-database/help-url/text() from configuration.
diff -r 2d828a605669 -r 402cd5464723 artifact-database/src/main/java/de/intevation/artifactdatabase/state/AbstractState.java
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/state/AbstractState.java Fri Apr 12 19:17:56 2013 +0200
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/state/AbstractState.java Mon Apr 15 12:30:38 2013 +0200
@@ -26,6 +26,7 @@
import de.intevation.artifacts.CallContext;
import de.intevation.artifacts.CallMeta;
+import de.intevation.artifacts.common.utils.Config;
import de.intevation.artifacts.common.utils.XMLUtils;
import de.intevation.artifactdatabase.data.StateData;
@@ -57,6 +58,10 @@
* to. */
public static final String XPATH_FACETS = "facets/facet";
+ public static final String XPATH_HELP_URL = "/artifact-database/help-url/text()";
+
+ public static final String HELP_URL = "${help.url}";
+
/** The logger that is used in this class. */
private static Logger logger = Logger.getLogger(AbstractState.class);
@@ -77,11 +82,24 @@
/** A list of output modes which are available for this state. */
protected List<Output> outputs;
+ private static String helpUrl;
+
public AbstractState() {
outputs = new ArrayList<Output>();
}
+ public static synchronized final String getHelpUrl() {
+ if (helpUrl == null) {
+ helpUrl = Config.getStringXPath(XPATH_HELP_URL, HELP_URL);
+ }
+ return helpUrl;
+ }
+
+ public static String replaceHelpUrl(String string) {
+ return string.replace(HELP_URL, getHelpUrl());
+ }
+
/**
* The default constructor.
@@ -99,7 +117,7 @@
public AbstractState(String id, String description, String helpText) {
this(id, description);
- this.helpText = helpText;
+ this.helpText = replaceHelpUrl(helpText);
}
@@ -159,7 +177,7 @@
* @param helpText The help text.
*/
public void setHelpText(String helpText) {
- this.helpText = helpText;
+ this.helpText = replaceHelpUrl(helpText);
}
@@ -232,6 +250,10 @@
helpText = (String) XMLUtils.xpath(
config, XPATH_HELP_TEXT, XPathConstants.STRING);
+ if (helpUrl != null) {
+ helpUrl = replaceHelpUrl(helpUrl);
+ }
+
setupOutputs(config);
}
More information about the Dive4elements-commits
mailing list