Mercurial > dive4elements > framework
diff artifact-database/src/main/java/de/intevation/artifactdatabase/state/AbstractState.java @ 468:402cd5464723 3.0.0
${help.url} in states helpText attributes now evaluates to /artifact-database/help-url/text() from configuration.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Mon, 15 Apr 2013 12:30:38 +0200 |
parents | ad74e1ba88ba |
children |
line wrap: on
line diff
--- 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); }