mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-17 14:02:22 +00:00
don't use the deprecated newInstance Method in LRDescriptor.
git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@10227 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
1 parent
e314dda2f7
commit
2f27ef4306
2 files changed
+23
-22
No files matched your search
@@ -800,11 +800,6 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
|
||||
|
||||
description = req.getParameter("description");
|
||||
|
||||
if (req.getParameter("logrotate") != null)
|
||||
logRotator = LogRotator.DESCRIPTOR.newInstance(req);
|
||||
else
|
||||
logRotator = null;
|
||||
|
||||
keepDependencies = req.getParameter("keepDependencies") != null;
|
||||
|
||||
try {
|
||||
@@ -812,6 +807,11 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
|
||||
|
||||
JSONObject json = StructuredForm.get(req);
|
||||
|
||||
if (req.getParameter("logrotate") != null)
|
||||
logRotator = LogRotator.DESCRIPTOR.newInstance(req,json.getJSONObject("logrotate"));
|
||||
else
|
||||
logRotator = null;
|
||||
|
||||
int i = 0;
|
||||
for (JobPropertyDescriptor d : JobPropertyDescriptor
|
||||
.getPropertyDescriptors(Job.this.getClass())) {
|
||||
|
||||
@@ -5,6 +5,8 @@ import hudson.model.Descriptor;
|
||||
import hudson.model.Job;
|
||||
import hudson.model.Run;
|
||||
import hudson.scm.SCM;
|
||||
|
||||
import org.kohsuke.stapler.DataBoundConstructor;
|
||||
import org.kohsuke.stapler.StaplerRequest;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@@ -33,7 +35,22 @@ public class LogRotator implements Describable<LogRotator> {
|
||||
* If not -1, only this number of build logs are kept.
|
||||
*/
|
||||
private final int numToKeep;
|
||||
|
||||
@DataBoundConstructor
|
||||
public LogRotator (String logrotate_days, String logrotate_nums) {
|
||||
this (parse(logrotate_days),parse(logrotate_nums));
|
||||
}
|
||||
|
||||
public static int parse(String p) {
|
||||
if(p==null) return -1;
|
||||
try {
|
||||
return Integer.parseInt(p);
|
||||
} catch (NumberFormatException e) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public LogRotator(int daysToKeep, int numToKeep) {
|
||||
this.daysToKeep = daysToKeep;
|
||||
this.numToKeep = numToKeep;
|
||||
@@ -93,22 +110,6 @@ public class LogRotator implements Describable<LogRotator> {
|
||||
|
||||
public String getDisplayName() {
|
||||
return "Log Rotation";
|
||||
}
|
||||
|
||||
public LogRotator newInstance(StaplerRequest req) {
|
||||
return new LogRotator(
|
||||
parse(req,"logrotate_days"),
|
||||
parse(req,"logrotate_nums") );
|
||||
}
|
||||
|
||||
private int parse(HttpServletRequest req, String name) {
|
||||
String p = req.getParameter(name);
|
||||
if(p==null) return -1;
|
||||
try {
|
||||
return Integer.parseInt(p);
|
||||
} catch (NumberFormatException e) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user