Skip to content

Commit

Permalink
[JENKINS-18427] log formatter error
Browse files Browse the repository at this point in the history
use more explicit method name
use formattedDescription for all parameter types
  • Loading branch information
ndeloof committed Jun 21, 2013
1 parent 21ac88c commit 20391ab
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 15 deletions.
12 changes: 10 additions & 2 deletions core/src/main/java/hudson/model/ParameterDefinition.java
Expand Up @@ -32,6 +32,7 @@

import java.io.Serializable;
import java.io.IOException;
import java.util.logging.Logger;

import jenkins.model.Jenkins;
import net.sf.json.JSONObject;
Expand Down Expand Up @@ -137,11 +138,16 @@ public String getDescription() {
return description;
}

public String getSafeDescription() {
/**
* return parameter description, applying the configured MarkupFormatter for jenkins instance.
* @since 1.521
*/
public String getFormattedDescription() {
try {
return Jenkins.getInstance().getMarkupFormatter().translate(description);
} catch (IOException e) {
return "failed to translate description using configured markup formatter";
LOGGER.warning("failed to translate description using configured markup formatter");
return "";
}
}

Expand Down Expand Up @@ -249,4 +255,6 @@ public String getDisplayName() {
return "Parameter";
}
}

private static final Logger LOGGER = Logger.getLogger(ParameterDefinition.class.getName());
}
Expand Up @@ -26,8 +26,8 @@ THE SOFTWARE.
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define"
xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form"
xmlns:i="jelly:fmt" xmlns:p="/lib/hudson/project">
<f:entry title="${it.name}" description="${it.description}">
<div name="parameter" description="${it.description}">
<f:entry title="${it.name}" description="${it.formattedDescription}">
<div name="parameter">
<input type="hidden" name="name" value="${it.name}" />
<f:checkbox name="value" checked="${it.defaultValue}" />
</div>
Expand Down
Expand Up @@ -26,8 +26,8 @@ THE SOFTWARE.
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define"
xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form"
xmlns:i="jelly:fmt" xmlns:p="/lib/hudson/project">
<f:entry title="${it.name}" description="${it.description}">
<div name="parameter" description="${it.description}">
<f:entry title="${it.name}" description="${it.formattedDescription}">
<div name="parameter">
<input type="hidden" name="name" value="${it.name}" />
<select name="value">
<j:forEach var="value" items="${it.choices}">
Expand Down
Expand Up @@ -26,7 +26,7 @@ THE SOFTWARE.
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define"
xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form"
xmlns:i="jelly:fmt" xmlns:p="/lib/hudson/project">
<f:entry title="${it.name}" description="${it.description}">
<f:entry title="${it.name}" description="${it.formattedDescription}">
<div name="parameter">
<input type="hidden" name="name" value="${it.name}" />
<input name="file" type="file" jsonAware="true" />
Expand Down
Expand Up @@ -26,8 +26,8 @@ THE SOFTWARE.
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define"
xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form"
xmlns:i="jelly:fmt" xmlns:p="/lib/hudson/project">
<f:entry title="${it.name}" description="${it.description}">
<div name="parameter" description="${it.description}">
<f:entry title="${it.name}" description="${it.formattedDescription}">
<div name="parameter">
<input type="hidden" name="name" value="${it.name}" />
<f:password name="value" value="${it.defaultValue}" />
</div>
Expand Down
Expand Up @@ -26,8 +26,8 @@ THE SOFTWARE.
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define"
xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form"
xmlns:i="jelly:fmt" xmlns:p="/lib/hudson/project">
<f:entry title="${it.name}" description="${it.description}">
<div name="parameter" description="${it.description}">
<f:entry title="${it.name}" description="${it.formattedDescription}">
<div name="parameter">
<input type="hidden" name="name" value="${it.name}" />
<select name="runId">
<j:forEach var="run" items="${it.builds}">
Expand Down
Expand Up @@ -26,7 +26,7 @@ THE SOFTWARE.
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define"
xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form"
xmlns:i="jelly:fmt" xmlns:p="/lib/hudson/project">
<f:entry title="${it.name}" description="${it.safeDescription}">
<f:entry title="${it.name}" description="${it.formattedDescription}">
<div name="parameter">
<input type="hidden" name="name" value="${it.name}" />
<f:textbox name="value" value="${it.defaultValue}" />
Expand Down
Expand Up @@ -24,8 +24,8 @@ THE SOFTWARE.
-->
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:i="jelly:fmt" xmlns:p="/lib/hudson/project">
<f:entry title="${it.name}" description="${it.description}">
<div name="parameter" description="${it.description}">
<f:entry title="${it.name}" description="${it.formattedDescription}">
<div name="parameter">
<input type="hidden" name="name" value="${it.name}"/>
<f:textarea name="value" value="${it.defaultValue}"/>
</div>
Expand Down
2 changes: 1 addition & 1 deletion test/src/test/java/hudson/model/ParametersTest.java
Expand Up @@ -89,7 +89,7 @@ public void testChoiceWithLTGT() throws Exception {

HtmlElement element = (HtmlElement) form.selectSingleNode(".//tr[td/div/input/@value='choice']");
assertNotNull(element);
assertEquals("choice description", ((HtmlElement) element.selectSingleNode("td/div")).getAttribute("description"));
assertEquals("choice description", ((HtmlElement) element.getNextSibling().getNextSibling().selectSingleNode("td[@class='setting-description']")).getTextContent());
assertEquals("choice", ((HtmlElement) element.selectSingleNode("td[@class='setting-name']")).getTextContent());
HtmlOption opt = (HtmlOption)element.selectSingleNode("td/div/select/option[@value='Choice <2>']");
assertNotNull(opt);
Expand Down

0 comments on commit 20391ab

Please sign in to comment.