提交 82f0feb9 编写于 作者: M mindless

Updates to use non-deprecated APIs, and add some @Override annotations


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@21661 71c3de6d-444a-0410-be80-ed276b4c234a
上级 2a674201
......@@ -68,8 +68,6 @@ import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.HttpResponse;
import org.kohsuke.stapler.HttpRedirect;
import org.kohsuke.stapler.ForwardToView;
import org.kohsuke.args4j.Argument;
import javax.servlet.ServletException;
import java.io.File;
......@@ -225,6 +223,7 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
updateTransientActions();
}
@Override
protected void performDelete() throws IOException, InterruptedException {
// prevent a new build while a delete operation is in progress
makeDisabled(true);
......@@ -293,7 +292,7 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
*
* @return the root project value.
*/
public AbstractProject getRootProject() {
public AbstractProject getRootProject() {
if (this.getParent() instanceof Hudson) {
return this;
} else {
......@@ -405,7 +404,7 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
}
public boolean hasCustomScmCheckoutRetryCount(){
return scmCheckoutRetryCount != null;
return scmCheckoutRetryCount != null;
}
public final boolean isBuildable() {
......@@ -421,12 +420,12 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
}
public boolean blockBuildWhenUpstreamBuilding() {
return blockBuildWhenUpstreamBuilding;
return blockBuildWhenUpstreamBuilding;
}
public void setBlockBuildWhenUpstreamBuilding(boolean b) throws IOException {
blockBuildWhenUpstreamBuilding = b;
save();
blockBuildWhenUpstreamBuilding = b;
save();
}
public boolean isDisabled() {
......@@ -437,13 +436,13 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
* Validates the retry count Regex
*/
public FormValidation doCheckRetryCount(@QueryParameter String value)throws IOException,ServletException{
// retry count is optional so this is ok
if(value == null || value.trim().equals(""))
return FormValidation.ok();
if (!value.matches("[0-9]*")) {
return FormValidation.error("Invalid retry count");
}
return FormValidation.ok();
// retry count is optional so this is ok
if(value == null || value.trim().equals(""))
return FormValidation.ok();
if (!value.matches("[0-9]*")) {
return FormValidation.error("Invalid retry count");
}
return FormValidation.ok();
}
/**
......@@ -676,16 +675,16 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
return defValues;
}
/**
/**
* Schedules a build, and returns a {@link Future} object
* to wait for the completion of the build.
*
* <p>
* Production code shouldn't be using this, but for tests, this is very convenience, so this isn't marked
* Production code shouldn't be using this, but for tests this is very convenient, so this isn't marked
* as deprecated.
*/
*/
public Future<R> scheduleBuild2(int quietPeriod) {
return scheduleBuild2(quietPeriod, new LegacyCodeCause());
return scheduleBuild2(quietPeriod, new LegacyCodeCause());
}
/**
......@@ -817,6 +816,7 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
* {@link BuildStep}s and others who want to add a project action
* should do so by implementing {@link BuildStep#getProjectAction(AbstractProject)}.
*/
@Override
public synchronized List<Action> getActions() {
// add all the transient actions, too
List<Action> actions = new Vector<Action>(super.getActions());
......@@ -1229,9 +1229,10 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
*/
protected abstract void buildDependencyGraph(DependencyGraph graph);
@Override
protected SearchIndexBuilder makeSearchIndex() {
SearchIndexBuilder sib = super.makeSearchIndex();
if(isBuildable() && Hudson.isAdmin())
if(isBuildable() && hasPermission(Hudson.ADMINISTER))
sib.add("build","build");
return sib;
}
......
......@@ -192,10 +192,10 @@ public interface Item extends PersistenceRoot, SearchableModelObject, AccessCont
public void delete() throws IOException, InterruptedException;
public static final PermissionGroup PERMISSIONS = new PermissionGroup(Item.class,Messages._Item_Permissions_Title());
public static final Permission CREATE = new Permission(PERMISSIONS,"Create", Permission.CREATE);
public static final Permission DELETE = new Permission(PERMISSIONS,"Delete", Permission.DELETE);
public static final Permission CONFIGURE = new Permission(PERMISSIONS,"Configure", Permission.CONFIGURE);
public static final Permission READ = new Permission(PERMISSIONS,"Read", Permission.READ);
public static final Permission CREATE = new Permission(PERMISSIONS, "Create", null, Permission.CREATE);
public static final Permission DELETE = new Permission(PERMISSIONS, "Delete", null, Permission.DELETE);
public static final Permission CONFIGURE = new Permission(PERMISSIONS, "Configure", null, Permission.CONFIGURE);
public static final Permission READ = new Permission(PERMISSIONS, "Read", null, Permission.READ);
public static final Permission EXTENDED_READ = new Permission(PERMISSIONS,"ExtendedRead", Messages._AbstractProject_ExtendedReadPermission_Description(), CONFIGURE, Boolean.getBoolean("hudson.security.ExtendedReadPermission"));
public static final Permission BUILD = new Permission(PERMISSIONS, "Build", Messages._AbstractProject_BuildPermission_Description(), Permission.UPDATE);
public static final Permission WORKSPACE = new Permission(PERMISSIONS, "Workspace", Messages._AbstractProject_WorkspacePermission_Description(), Permission.READ);
......
......@@ -145,6 +145,7 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
super(parent, name);
}
@Override
public void onLoad(ItemGroup<? extends Item> parent, String name)
throws IOException {
super.onLoad(parent, name);
......@@ -178,6 +179,7 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
this.nextBuildNumber = 1; // reset the next build number
}
@Override
protected void performDelete() throws IOException, InterruptedException {
// if a build is in progress. Cancel it.
RunT lb = getLastBuild();
......@@ -307,6 +309,7 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
return true;
}
@Override
protected SearchIndexBuilder makeSearchIndex() {
return super.makeSearchIndex().add(new SearchIndex() {
public void find(String token, List<SearchItem> result) {
......@@ -537,7 +540,7 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
parent.onRenamed((TopLevelItem) this, oldName, newName);
for (ItemListener l : Hudson.getInstance().getJobListeners())
for (ItemListener l : ItemListener.all())
l.onRenamed(this, oldName, newName);
}
}
......@@ -609,13 +612,8 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
* be already gone (deleted, rotated, etc.)
*/
public final RunT getNearestBuild(int n) {
SortedMap<Integer, ? extends RunT> m = _getRuns().headMap(n - 1); // the
// map
// should
// include
// n,
// so
// n-1
SortedMap<Integer, ? extends RunT> m = _getRuns().headMap(n - 1); // the map should
// include n, so n-1
if (m.isEmpty())
return null;
return m.get(m.lastKey());
......@@ -634,6 +632,7 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
return m.get(m.firstKey());
}
@Override
public Object getDynamic(String token, StaplerRequest req,
StaplerResponse rsp) {
try {
......@@ -1052,6 +1051,7 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
return this.run.number - that.run.number;
}
@Override
public boolean equals(Object o) {
// HUDSON-2682 workaround for Eclipse compilation bug
// on (c instanceof ChartLabel)
......@@ -1076,10 +1076,12 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
return ColorPalette.BLUE;
}
@Override
public int hashCode() {
return run.hashCode();
}
@Override
public String toString() {
String l = run.getDisplayName();
if (run instanceof Build) {
......@@ -1223,6 +1225,7 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
* We need to override the identical method in AbstractItem because we won't
* call getACL(Job) otherwise (single dispatch)
*/
@Override
public ACL getACL() {
return Hudson.getInstance().getAuthorizationStrategy().getACL(this);
}
......
......@@ -70,8 +70,8 @@ public class WorkspaceCleanupThread extends AsyncPeriodicWork {
this.listener = listener;
Hudson h = Hudson.getInstance();
for (Slave s : h.getSlaves())
process(s);
for (Node n : h.getNodes())
if (n instanceof Slave) process((Slave)n);
process(h);
} finally {
......
......@@ -111,7 +111,7 @@ public abstract class NodeMonitor implements ExtensionPoint, Describable<NodeMon
* @since 1.187
*/
public static List<NodeMonitor> getAll() {
return ComputerSet.get_monitors();
return ComputerSet.getMonitors().toList();
}
/**
......
......@@ -184,6 +184,7 @@ public final class Permission {
}
}
@Override
public String toString() {
return "Permission["+owner+','+name+']';
}
......@@ -258,30 +259,30 @@ public final class Permission {
/**
* Generic read access.
*/
public static final Permission READ = new Permission(GROUP,"GenericRead",HUDSON_ADMINISTER);
public static final Permission READ = new Permission(GROUP,"GenericRead",null,HUDSON_ADMINISTER);
/**
* Generic write access.
*/
public static final Permission WRITE = new Permission(GROUP,"GenericWrite",HUDSON_ADMINISTER);
public static final Permission WRITE = new Permission(GROUP,"GenericWrite",null,HUDSON_ADMINISTER);
/**
* Generic create access.
*/
public static final Permission CREATE = new Permission(GROUP,"GenericCreate",WRITE);
public static final Permission CREATE = new Permission(GROUP,"GenericCreate",null,WRITE);
/**
* Generic update access.
*/
public static final Permission UPDATE = new Permission(GROUP,"GenericUpdate",WRITE);
public static final Permission UPDATE = new Permission(GROUP,"GenericUpdate",null,WRITE);
/**
* Generic delete access.
*/
public static final Permission DELETE = new Permission(GROUP,"GenericDelete",WRITE);
public static final Permission DELETE = new Permission(GROUP,"GenericDelete",null,WRITE);
/**
* Generic configuration access.
*/
public static final Permission CONFIGURE = new Permission(GROUP,"GenericConfigure",UPDATE);
public static final Permission CONFIGURE = new Permission(GROUP,"GenericConfigure",null,UPDATE);
}
......@@ -33,6 +33,7 @@ import static hudson.model.LoadStatistics.DECAY;
import hudson.model.MultiStageTimeSeries.TimeScale;
import hudson.Extension;
import java.awt.Color;
import java.util.concurrent.Future;
import java.util.concurrent.ExecutionException;
import java.util.List;
......@@ -87,7 +88,8 @@ public class NodeProvisioner {
* This is used to filter out high-frequency components from the planned capacity, so that
* the comparison with other low-frequency only variables won't leave spikes.
*/
private final MultiStageTimeSeries plannedCapacitiesEMA = new MultiStageTimeSeries(0,DECAY);
private final MultiStageTimeSeries plannedCapacitiesEMA =
new MultiStageTimeSeries(Messages._NodeProvisioner_EmptyString(),Color.WHITE,0,DECAY);
public NodeProvisioner(Label label, LoadStatistics loadStatistics) {
this.label = label;
......
......@@ -113,6 +113,7 @@ public abstract class RetentionStrategy<T extends Computer> implements Describab
c.connect(false);
}
@Override
public Descriptor<RetentionStrategy<?>> getDescriptor() {
return DESCRIPTOR;
}
......@@ -213,7 +214,7 @@ public abstract class RetentionStrategy<T extends Computer> implements Describab
// we've been idle for long enough
logger.log(Level.INFO, "Disconnecting computer {0} as it has been idle for {1}",
new Object[]{c.getName(), Util.getTimeSpanString(idleMilliseconds)});
c.disconnect();
c.disconnect(OfflineCause.create(Messages._RetentionStrategy_Demand_OfflineIdle()));
}
}
return 1;
......
......@@ -67,7 +67,7 @@ public abstract class BuildStepDescriptor<T extends BuildStep & Describable<T>>
/**
* Fiters a descriptor for {@link BuildStep}s by using {@link BuildStepDescriptor#isApplicable(Class)}.
* Filters a descriptor for {@link BuildStep}s by using {@link BuildStepDescriptor#isApplicable(Class)}.
*/
public static <T extends BuildStep&Describable<T>>
List<Descriptor<T>> filter(List<Descriptor<T>> base, Class<? extends AbstractProject> type) {
......
......@@ -22,12 +22,14 @@
RetentionStrategy.Always.displayName=Keep this slave on-line as much as possible
RetentionStrategy.Demand.displayName=Take this slave on-line when in demand and off-line when idle
RetentionStrategy.Demand.OfflineIdle=Computer was idle
CommandLauncher.displayName=Launch slave via execution of command on the Master
JNLPLauncher.displayName=Launch slave agents via JNLP
ComputerLauncher.unexpectedError=Unexpected error in launching a slave. This is probably a bug in Hudson
ComputerLauncher.abortedLaunch=Launching slave process aborted.
CommandLauncher.NoLaunchCommand=No launch command specified
DumbSlave.displayName=Dumb Slave
NodeProvisioner.EmptyString=
SimpleScheduledRetentionStrategy.FinishedUpTime=Computer has finished its scheduled uptime
SimpleScheduledRetentionStrategy.displayName=Take this slave on-line according to a schedule
EnvironmentVariablesNodeProperty.displayName=Environment variables
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册