Skip to content

Commit

Permalink
[JENKINS-27208] Removed obsolete way to work
Browse files Browse the repository at this point in the history
  • Loading branch information
recena committed Sep 29, 2015
1 parent 2124750 commit e59455c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 50 deletions.
57 changes: 9 additions & 48 deletions src/main/java/hudson/plugins/logparser/LogParserPublisher.java
Expand Up @@ -68,8 +68,16 @@ private LogParserPublisher(final boolean unstableOnWarning,
}

@DataBoundConstructor
public LogParserPublisher() {
public LogParserPublisher(final boolean useProjectRule, final String parsingRulesPath, final String projectRulePath) {
super();
if (useProjectRule) {
this.projectRulePath = projectRulePath;
this.parsingRulesPath = null;
} else {
this.projectRulePath = null;
this.parsingRulesPath = parsingRulesPath;
}
this.useProjectRule = useProjectRule;
}

@DataBoundSetter
Expand All @@ -87,21 +95,6 @@ public void setShowGraphs(boolean showGraphs) {
this.showGraphs = showGraphs;
}

@DataBoundSetter
public void setUseProjectRule(final boolean useProjectRule) {
this.useProjectRule = useProjectRule;
}

@DataBoundSetter
public void setParsingRulesPath(final String parsingRulesPath) {
this.parsingRulesPath = parsingRulesPath;
}

@DataBoundSetter
public void setProjectRulePath(final String projectRulePath) {
this.projectRulePath = projectRulePath;
}

@Override
public boolean prebuild(final AbstractBuild<?, ?> build,
final BuildListener listener) {
Expand Down Expand Up @@ -215,38 +208,6 @@ public boolean configure(final StaplerRequest req, final JSONObject json)
save();
return true;
}

/**
* Cannot use simple DataBoundConstructor due to radioBlock usage where
* a JSON object is returned holding the selected value of the block.
*
* {@inheritDoc}
*/
@Override
public LogParserPublisher newInstance(StaplerRequest req,
JSONObject json) throws FormException {

String configuredParsingRulesPath = null;
String configuredProjectRulePath = null;
boolean configuredUseProjectRule = false;
final JSONObject useProjectRuleJSON = json.getJSONObject("useProjectRule");

if (useProjectRuleJSON != null) {
configuredUseProjectRule = useProjectRuleJSON.getBoolean("value");

if (!configuredUseProjectRule && useProjectRuleJSON.containsKey("parsingRulesPath")) {
configuredParsingRulesPath = useProjectRuleJSON.getString("parsingRulesPath");
} else if (configuredUseProjectRule && useProjectRuleJSON.containsKey("projectRulePath")) {
configuredProjectRulePath = useProjectRuleJSON.getString("projectRulePath");
}
}
return new LogParserPublisher(json.getBoolean("unstableOnWarning"),
json.getBoolean("failBuildOnError"),
json.getBoolean("showGraphs"),
configuredParsingRulesPath,
configuredUseProjectRule,
configuredProjectRulePath);
}
}

public BuildStepMonitor getRequiredMonitorService() {
Expand Down
Expand Up @@ -9,7 +9,7 @@
<f:entry title="Show log parser graphs" help="/plugin/log-parser/parser_graphs.html">
<f:checkbox name="log-parser.showGraphs" checked="${instance.showGraphs}"/>
</f:entry>
<f:radioBlock title="Use global rule" name="log-parser.useProjectRule" value="false" checked="${instance.useProjectRule!=true}">
<f:radioBlock title="Use global rule" name="log-parser.useProjectRule" value="false" checked="${instance.useProjectRule!=true}" inline="true">
<f:entry title="Select Parsing Rules" field="currentRulePath" help="/plugin/log-parser/parse_rule_choice.html">
<select name="log-parser.parsingRulesPath">
<j:forEach var="i" items="${descriptor.parsingRulesGlobal}">
Expand All @@ -18,7 +18,7 @@
</select>
</f:entry>
</f:radioBlock>
<f:radioBlock title="Use project rule" name="log-parser.useProjectRule" value="true" checked="${instance.useProjectRule==true}">
<f:radioBlock title="Use project rule" name="log-parser.useProjectRule" value="true" checked="${instance.useProjectRule==true}" inline="true">
<f:entry title="Path to rule file in workspace" field="projectRulePath">
<f:textbox/>
</f:entry>
Expand Down

1 comment on commit e59455c

@orrc
Copy link
Member

@orrc orrc commented on e59455c Oct 14, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of interest, why is using @DataBoundSetter obsolete?

I understand removing newInstance(), but @DataBoundSetter was explicitly added so that developers no longer need to stuff loads of data-bound parameters into the constructor.

Please sign in to comment.