aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Lynggaard Hansen2012-07-18 15:22:25 (EDT)
committerHenrik Lynggaard Hansen2012-07-18 15:22:25 (EDT)
commitf0e2467e27544ab6e9d699a258b97597ebce1d2a (patch)
treec56f3aa8f6a74b6bba92a936a2b4eea10a70f6a3
parentc4159e1ea623b6da52af7b1dc272dea8408eadb7 (diff)
downloadorg.eclipse.hudson.core-f0e2467e27544ab6e9d699a258b97597ebce1d2a.zip
org.eclipse.hudson.core-f0e2467e27544ab6e9d699a258b97597ebce1d2a.tar.gz
org.eclipse.hudson.core-f0e2467e27544ab6e9d699a258b97597ebce1d2a.tar.bz2
Reformat hudson.modelrefs/changes/52/6852/1
Change-Id: I493137edef8c8721e981a9913bd791cc4bf39cb0 Signed-off-by: Henrik Lynggaard Hansen <henrik@hlyh.dk>
-rw-r--r--hudson-core/src/main/java/hudson/model/AbstractBuild.java568
-rw-r--r--hudson-core/src/main/java/hudson/model/AbstractDescribableImpl.java5
-rw-r--r--hudson-core/src/main/java/hudson/model/AbstractItem.java138
-rw-r--r--hudson-core/src/main/java/hudson/model/AbstractModelObject.java58
-rw-r--r--hudson-core/src/main/java/hudson/model/AbstractProject.java98
-rw-r--r--hudson-core/src/main/java/hudson/model/AbstractStatusIcon.java5
-rw-r--r--hudson-core/src/main/java/hudson/model/Action.java106
-rw-r--r--hudson-core/src/main/java/hudson/model/Actionable.java56
-rw-r--r--hudson-core/src/main/java/hudson/model/AdministrativeMonitor.java86
-rw-r--r--hudson-core/src/main/java/hudson/model/AllView.java20
-rw-r--r--hudson-core/src/main/java/hudson/model/Api.java51
-rw-r--r--hudson-core/src/main/java/hudson/model/AppointedNode.java30
-rw-r--r--hudson-core/src/main/java/hudson/model/AsyncPeriodicWork.java45
-rw-r--r--hudson-core/src/main/java/hudson/model/AutoCompletionCandidates.java14
-rw-r--r--hudson-core/src/main/java/hudson/model/BallColor.java84
-rw-r--r--hudson-core/src/main/java/hudson/model/BaseBuildableProject.java79
-rw-r--r--hudson-core/src/main/java/hudson/model/BooleanParameterDefinition.java20
-rw-r--r--hudson-core/src/main/java/hudson/model/BooleanParameterValue.java35
-rw-r--r--hudson-core/src/main/java/hudson/model/Build.java114
-rw-r--r--hudson-core/src/main/java/hudson/model/BuildAuthorizationToken.java35
-rw-r--r--hudson-core/src/main/java/hudson/model/BuildBadgeAction.java24
-rw-r--r--hudson-core/src/main/java/hudson/model/BuildListener.java11
-rw-r--r--hudson-core/src/main/java/hudson/model/BuildTimelineWidget.java53
-rw-r--r--hudson-core/src/main/java/hudson/model/BuildableItem.java38
-rw-r--r--hudson-core/src/main/java/hudson/model/BuildableItemWithBuildWrappers.java19
-rw-r--r--hudson-core/src/main/java/hudson/model/Cause.java100
-rw-r--r--hudson-core/src/main/java/hudson/model/CauseAction.java83
-rw-r--r--hudson-core/src/main/java/hudson/model/CheckPoint.java126
-rw-r--r--hudson-core/src/main/java/hudson/model/ChoiceParameterDefinition.java23
-rw-r--r--hudson-core/src/main/java/hudson/model/Computer.java530
-rw-r--r--hudson-core/src/main/java/hudson/model/ComputerPinger.java15
-rw-r--r--hudson-core/src/main/java/hudson/model/ComputerSet.java168
-rw-r--r--hudson-core/src/main/java/hudson/model/DependecyDeclarer.java35
-rw-r--r--hudson-core/src/main/java/hudson/model/DependencyGraph.java192
-rw-r--r--hudson-core/src/main/java/hudson/model/Describable.java15
-rw-r--r--hudson-core/src/main/java/hudson/model/Descriptor.java560
-rw-r--r--hudson-core/src/main/java/hudson/model/DescriptorByNameOwner.java24
-rw-r--r--hudson-core/src/main/java/hudson/model/DescriptorVisibilityFilter.java27
-rw-r--r--hudson-core/src/main/java/hudson/model/DirectoryBrowserSupport.java245
-rw-r--r--hudson-core/src/main/java/hudson/model/DownloadService.java138
-rw-r--r--hudson-core/src/main/java/hudson/model/Environment.java125
-rw-r--r--hudson-core/src/main/java/hudson/model/EnvironmentContributingAction.java29
-rw-r--r--hudson-core/src/main/java/hudson/model/EnvironmentContributor.java37
-rw-r--r--hudson-core/src/main/java/hudson/model/EnvironmentSpecific.java22
-rw-r--r--hudson-core/src/main/java/hudson/model/Executor.java198
-rw-r--r--hudson-core/src/main/java/hudson/model/ExecutorListener.java23
-rw-r--r--hudson-core/src/main/java/hudson/model/ExternalJob.java39
-rw-r--r--hudson-core/src/main/java/hudson/model/ExternalRun.java97
-rw-r--r--hudson-core/src/main/java/hudson/model/Failure.java33
-rw-r--r--hudson-core/src/main/java/hudson/model/FileParameterDefinition.java26
-rw-r--r--hudson-core/src/main/java/hudson/model/FileParameterValue.java98
-rw-r--r--hudson-core/src/main/java/hudson/model/Fingerprint.java379
-rw-r--r--hudson-core/src/main/java/hudson/model/FingerprintCleanupThread.java45
-rw-r--r--hudson-core/src/main/java/hudson/model/FingerprintMap.java57
-rw-r--r--hudson-core/src/main/java/hudson/model/FreeStyleBuild.java21
-rw-r--r--hudson-core/src/main/java/hudson/model/FreeStyleProject.java30
-rw-r--r--hudson-core/src/main/java/hudson/model/FullDuplexHttpChannel.java34
-rw-r--r--hudson-core/src/main/java/hudson/model/HealthReport.java128
-rw-r--r--hudson-core/src/main/java/hudson/model/HealthReportingAction.java30
-rw-r--r--hudson-core/src/main/java/hudson/model/Hudson.java642
-rw-r--r--hudson-core/src/main/java/hudson/model/InvisibleAction.java12
-rw-r--r--hudson-core/src/main/java/hudson/model/Item.java147
-rw-r--r--hudson-core/src/main/java/hudson/model/ItemGroup.java21
-rw-r--r--hudson-core/src/main/java/hudson/model/ItemGroupMixIn.java115
-rw-r--r--hudson-core/src/main/java/hudson/model/Items.java56
-rw-r--r--hudson-core/src/main/java/hudson/model/JDK.java52
-rw-r--r--hudson-core/src/main/java/hudson/model/Job.java227
-rw-r--r--hudson-core/src/main/java/hudson/model/JobParameterDefinition.java12
-rw-r--r--hudson-core/src/main/java/hudson/model/JobParameterValue.java15
-rw-r--r--hudson-core/src/main/java/hudson/model/JobProperty.java99
-rw-r--r--hudson-core/src/main/java/hudson/model/JobPropertyDescriptor.java53
-rw-r--r--hudson-core/src/main/java/hudson/model/Jobs.java22
-rw-r--r--hudson-core/src/main/java/hudson/model/Label.java188
-rw-r--r--hudson-core/src/main/java/hudson/model/LabelFinder.java20
-rw-r--r--hudson-core/src/main/java/hudson/model/LargeText.java149
-rw-r--r--hudson-core/src/main/java/hudson/model/ListView.java83
-rw-r--r--hudson-core/src/main/java/hudson/model/LoadBalancer.java75
-rw-r--r--hudson-core/src/main/java/hudson/model/LoadStatistics.java62
-rw-r--r--hudson-core/src/main/java/hudson/model/ManagementLink.java50
-rw-r--r--hudson-core/src/main/java/hudson/model/ModelObject.java11
-rw-r--r--hudson-core/src/main/java/hudson/model/MyView.java13
-rw-r--r--hudson-core/src/main/java/hudson/model/MyViewsProperty.java92
-rw-r--r--hudson-core/src/main/java/hudson/model/NoFingerprintMatch.java9
-rw-r--r--hudson-core/src/main/java/hudson/model/Node.java140
-rw-r--r--hudson-core/src/main/java/hudson/model/OneOffExecutor.java18
-rw-r--r--hudson-core/src/main/java/hudson/model/OverallLoadStatistics.java29
-rw-r--r--hudson-core/src/main/java/hudson/model/PageDecorator.java70
-rw-r--r--hudson-core/src/main/java/hudson/model/ParameterDefinition.java170
-rw-r--r--hudson-core/src/main/java/hudson/model/ParameterValue.java199
-rw-r--r--hudson-core/src/main/java/hudson/model/ParametersAction.java63
-rw-r--r--hudson-core/src/main/java/hudson/model/ParametersDefinitionProperty.java61
-rw-r--r--hudson-core/src/main/java/hudson/model/PasswordParameterDefinition.java21
-rw-r--r--hudson-core/src/main/java/hudson/model/PasswordParameterValue.java10
-rw-r--r--hudson-core/src/main/java/hudson/model/PeriodicWork.java49
-rw-r--r--hudson-core/src/main/java/hudson/model/PermalinkProjectAction.java58
-rw-r--r--hudson-core/src/main/java/hudson/model/PersistenceRoot.java20
-rw-r--r--hudson-core/src/main/java/hudson/model/Project.java28
-rw-r--r--hudson-core/src/main/java/hudson/model/ProminentProjectAction.java16
-rw-r--r--hudson-core/src/main/java/hudson/model/ProxyView.java29
-rw-r--r--hudson-core/src/main/java/hudson/model/RSS.java37
-rw-r--r--hudson-core/src/main/java/hudson/model/Resource.java84
-rw-r--r--hudson-core/src/main/java/hudson/model/ResourceActivity.java27
-rw-r--r--hudson-core/src/main/java/hudson/model/ResourceController.java63
-rw-r--r--hudson-core/src/main/java/hudson/model/ResourceList.java96
-rw-r--r--hudson-core/src/main/java/hudson/model/RestartListener.java10
-rw-r--r--hudson-core/src/main/java/hudson/model/Result.java71
-rw-r--r--hudson-core/src/main/java/hudson/model/RootAction.java13
-rw-r--r--hudson-core/src/main/java/hudson/model/RunAction.java11
-rw-r--r--hudson-core/src/main/java/hudson/model/RunMap.java97
-rw-r--r--hudson-core/src/main/java/hudson/model/RunParameterDefinition.java25
-rw-r--r--hudson-core/src/main/java/hudson/model/RunParameterValue.java26
-rw-r--r--hudson-core/src/main/java/hudson/model/RunnerStack.java25
-rw-r--r--hudson-core/src/main/java/hudson/model/SCMedItem.java35
-rw-r--r--hudson-core/src/main/java/hudson/model/Saveable.java22
-rw-r--r--hudson-core/src/main/java/hudson/model/SimpleParameterDefinition.java6
-rw-r--r--hudson-core/src/main/java/hudson/model/Slave.java156
-rw-r--r--hudson-core/src/main/java/hudson/model/StatusIcon.java33
-rw-r--r--hudson-core/src/main/java/hudson/model/StockStatusIcon.java12
-rw-r--r--hudson-core/src/main/java/hudson/model/StreamBuildListener.java31
-rw-r--r--hudson-core/src/main/java/hudson/model/StringParameterDefinition.java21
-rw-r--r--hudson-core/src/main/java/hudson/model/StringParameterValue.java71
-rw-r--r--hudson-core/src/main/java/hudson/model/TaskAction.java54
-rw-r--r--hudson-core/src/main/java/hudson/model/TaskListener.java63
-rw-r--r--hudson-core/src/main/java/hudson/model/TaskThread.java69
-rw-r--r--hudson-core/src/main/java/hudson/model/TimeSeries.java41
-rw-r--r--hudson-core/src/main/java/hudson/model/TopLevelItem.java21
-rw-r--r--hudson-core/src/main/java/hudson/model/TopLevelItemDescriptor.java41
-rw-r--r--hudson-core/src/main/java/hudson/model/TransientProjectActionFactory.java37
-rw-r--r--hudson-core/src/main/java/hudson/model/TransientViewActionFactory.java41
-rw-r--r--hudson-core/src/main/java/hudson/model/TreeView.java57
-rw-r--r--hudson-core/src/main/java/hudson/model/UpdateCenter.java426
-rw-r--r--hudson-core/src/main/java/hudson/model/UpdateSite.java278
-rw-r--r--hudson-core/src/main/java/hudson/model/UsageStatistics.java19
-rw-r--r--hudson-core/src/main/java/hudson/model/User.java206
-rw-r--r--hudson-core/src/main/java/hudson/model/UserProperties.java16
-rw-r--r--hudson-core/src/main/java/hudson/model/UserProperty.java38
-rw-r--r--hudson-core/src/main/java/hudson/model/UserPropertyDescriptor.java43
-rw-r--r--hudson-core/src/main/java/hudson/model/View.java391
-rw-r--r--hudson-core/src/main/java/hudson/model/ViewDescriptor.java20
-rw-r--r--hudson-core/src/main/java/hudson/model/ViewGroup.java32
-rw-r--r--hudson-core/src/main/java/hudson/model/ViewJob.java97
-rw-r--r--hudson-core/src/main/java/hudson/model/WorkspaceCleanupThread.java80
-rw-r--r--hudson-core/src/main/java/hudson/model/package.html4
143 files changed, 6103 insertions, 5673 deletions
diff --git a/hudson-core/src/main/java/hudson/model/AbstractBuild.java b/hudson-core/src/main/java/hudson/model/AbstractBuild.java
index 20121bf..16f8a7c 100644
--- a/hudson-core/src/main/java/hudson/model/AbstractBuild.java
+++ b/hudson-core/src/main/java/hudson/model/AbstractBuild.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
*
* Kohsuke Kawaguchi, Yahoo! Inc., CloudBees, Inc.
- *
+ *
*
*******************************************************************************/
@@ -80,59 +80,56 @@ import java.util.logging.Logger;
* @author Kohsuke Kawaguchi
* @see AbstractProject
*/
-public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends AbstractBuild<P,R>> extends Run<P,R> implements Queue.Executable {
+public abstract class AbstractBuild<P extends AbstractProject<P, R>, R extends AbstractBuild<P, R>> extends Run<P, R> implements Queue.Executable {
/**
- * Set if we want the blame information to flow from upstream to downstream build.
+ * Set if we want the blame information to flow from upstream to downstream
+ * build.
*/
private static final boolean upstreamCulprits = Boolean.getBoolean("hudson.upstreamCulprits");
-
/**
- * Name of the slave this project was built on.
- * Null or "" if built by the master. (null happens when we read old record that didn't have this information.)
+ * Name of the slave this project was built on. Null or "" if built by the
+ * master. (null happens when we read old record that didn't have this
+ * information.)
*/
private String builtOn;
-
/**
- * The file path on the node that performed a build. Kept as a string since {@link FilePath} is not serializable into XML.
+ * The file path on the node that performed a build. Kept as a string since
+ * {@link FilePath} is not serializable into XML.
+ *
* @since 1.319
*/
private String workspace;
-
/**
* Version of Hudson that built this.
*/
private String hudsonVersion;
-
/**
- * SCM used for this build.
- * Maybe null, for historical reason, in which case CVS is assumed.
+ * SCM used for this build. Maybe null, for historical reason, in which case
+ * CVS is assumed.
*/
private ChangeLogParser scm;
-
/**
* Changes in this build.
*/
private volatile transient ChangeLogSet<? extends Entry> changeSet;
-
/**
* Cumulative list of people who contributed to the build problem.
*
- * <p>
- * This is a list of {@link User#getId() user ids} who made a change
- * since the last non-broken build. Can be null (which should be
- * treated like empty set), because of the compatibility.
+ * <p> This is a list of {@link User#getId() user ids} who made a change
+ * since the last non-broken build. Can be null (which should be treated
+ * like empty set), because of the compatibility.
*
- * <p>
- * This field is semi-final --- once set the value will never be modified.
+ * <p> This field is semi-final --- once set the value will never be
+ * modified.
*
* @since 1.137
*/
private volatile Set<String> culprits;
-
/**
- * During the build this field remembers {@link BuildWrapper.Environment}s created by
- * {@link BuildWrapper}. This design is bit ugly but forced due to compatibility.
+ * During the build this field remembers {@link BuildWrapper.Environment}s
+ * created by {@link BuildWrapper}. This design is bit ugly but forced due
+ * to compatibility.
*/
protected transient List<Environment> buildEnvironments;
@@ -155,21 +152,23 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
/**
* Returns a {@link Slave} on which this build was done.
*
- * @return
- * null, for example if the slave that this build run no longer exists.
+ * @return null, for example if the slave that this build run no longer
+ * exists.
*/
public Node getBuiltOn() {
- if (builtOn==null || builtOn.equals(""))
+ if (builtOn == null || builtOn.equals("")) {
return Hudson.getInstance();
- else
+ } else {
return Hudson.getInstance().getNode(builtOn);
+ }
}
/**
- * Returns the name of the slave it was built on; null or "" if built by the master.
- * (null happens when we read old record that didn't have this information.)
+ * Returns the name of the slave it was built on; null or "" if built by the
+ * master. (null happens when we read old record that didn't have this
+ * information.)
*/
- @Exported(name="builtOn")
+ @Exported(name = "builtOn")
public String getBuiltOnStr() {
return builtOn;
}
@@ -177,91 +176,96 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
/**
* Used to render the side panel "Back to project" link.
*
- * <p>
- * In a rare situation where a build can be reached from multiple paths,
- * returning different URLs from this method based on situations might
- * be desirable.
+ * <p> In a rare situation where a build can be reached from multiple paths,
+ * returning different URLs from this method based on situations might be
+ * desirable.
*
- * <p>
- * If you override this method, you'll most likely also want to override
+ * <p> If you override this method, you'll most likely also want to override
* {@link #getDisplayName()}.
*/
public String getUpUrl() {
- return Functions.getNearestAncestorUrl(Stapler.getCurrentRequest(),getParent())+'/';
+ return Functions.getNearestAncestorUrl(Stapler.getCurrentRequest(), getParent()) + '/';
}
/**
* Gets the directory where this build is being built.
*
- * <p>
- * Note to implementors: to control where the workspace is created, override
- * {@link AbstractRunner#decideWorkspace(Node,WorkspaceList)}.
+ * <p> Note to implementors: to control where the workspace is created,
+ * override {@link AbstractRunner#decideWorkspace(Node,WorkspaceList)}.
*
- * @return
- * null if the workspace is on a slave that's not connected. Note that once the build is completed,
- * the workspace may be used to build something else, so the value returned from this method may
- * no longer show a workspace as it was used for this build.
+ * @return null if the workspace is on a slave that's not connected. Note
+ * that once the build is completed, the workspace may be used to build
+ * something else, so the value returned from this method may no longer show
+ * a workspace as it was used for this build.
* @since 1.319
*/
public final FilePath getWorkspace() {
- if (workspace==null) return null;
+ if (workspace == null) {
+ return null;
+ }
Node n = getBuiltOn();
- if (n==null) return null;
+ if (n == null) {
+ return null;
+ }
return n.createPath(workspace);
}
/**
- * Normally, a workspace is assigned by {@link Runner}, but this lets you set the workspace in case
- * {@link AbstractBuild} is created without a build.
+ * Normally, a workspace is assigned by {@link Runner}, but this lets you
+ * set the workspace in case {@link AbstractBuild} is created without a
+ * build.
*/
protected void setWorkspace(FilePath ws) {
this.workspace = ws.getRemote();
}
/**
- * Returns the root directory of the checked-out module.
- * <p>
- * This is usually where <tt>pom.xml</tt>, <tt>build.xml</tt>
- * and so on exists.
+ * Returns the root directory of the checked-out module. <p> This is usually
+ * where <tt>pom.xml</tt>, <tt>build.xml</tt> and so on exists.
*/
public final FilePath getModuleRoot() {
FilePath ws = getWorkspace();
- if (ws==null) return null;
- return getParent().getScm().getModuleRoot(ws,this);
+ if (ws == null) {
+ return null;
+ }
+ return getParent().getScm().getModuleRoot(ws, this);
}
/**
- * Returns the root directories of all checked-out modules.
- * <p>
- * Some SCMs support checking out multiple modules into the same workspace.
- * In these cases, the returned array will have a length greater than one.
+ * Returns the root directories of all checked-out modules. <p> Some SCMs
+ * support checking out multiple modules into the same workspace. In these
+ * cases, the returned array will have a length greater than one.
+ *
* @return The roots of all modules checked out from the SCM.
*/
public FilePath[] getModuleRoots() {
FilePath ws = getWorkspace();
- if (ws==null) return null;
- return getParent().getScm().getModuleRoots(ws,this);
+ if (ws == null) {
+ return null;
+ }
+ return getParent().getScm().getModuleRoots(ws, this);
}
/**
- * List of users who committed a change since the last non-broken build till now.
+ * List of users who committed a change since the last non-broken build till
+ * now.
*
- * <p>
- * This list at least always include people who made changes in this build, but
- * if the previous build was a failure it also includes the culprit list from there.
- * Culprits of unstable build are also included
- * see <a href="http://issues.hudson-ci.org/browse/HUDSON-4617">HUDSON-4617</a> for details
- * @return
- * can be empty but never null.
+ * <p> This list at least always include people who made changes in this
+ * build, but if the previous build was a failure it also includes the
+ * culprit list from there. Culprits of unstable build are also included see
+ * <a href="http://issues.hudson-ci.org/browse/HUDSON-4617">HUDSON-4617</a>
+ * for details
+ *
+ * @return can be empty but never null.
*/
@Exported
public Set<User> getCulprits() {
- if (culprits==null) {
+ if (culprits == null) {
Set<User> r = new HashSet<User>();
R p = getPreviousCompletedBuild();
- if (p !=null && isBuilding()) {
+ if (p != null && isBuilding()) {
Result pr = p.getResult();
- if (pr!=null && pr.isWorseOrEqualTo(Result.UNSTABLE)) {
+ if (pr != null && pr.isWorseOrEqualTo(Result.UNSTABLE)) {
// we are still building, so this is just the current latest information,
// but we seems to be failing so far, so inherit culprits from the previous build.
// isBuilding() check is to avoid recursion when loading data from old Hudson, which doesn't record
@@ -269,16 +273,17 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
r.addAll(p.getCulprits());
}
}
- for (Entry e : getChangeSet())
+ for (Entry e : getChangeSet()) {
r.add(e.getAuthor());
+ }
if (upstreamCulprits) {
// If we have dependencies since the last successful build, add their authors to our list
R previousBuild = getPreviousSuccessfulBuild();
if (previousBuild != null) {
- Map <AbstractProject,AbstractBuild.DependencyChange> depmap = getDependencyChanges(previousBuild);
+ Map<AbstractProject, AbstractBuild.DependencyChange> depmap = getDependencyChanges(previousBuild);
for (AbstractBuild.DependencyChange dep : depmap.values()) {
- for (AbstractBuild<?,?> b : dep.getBuilds()) {
+ for (AbstractBuild<?, ?> b : dep.getBuilds()) {
for (Entry entry : b.getChangeSet()) {
r.add(entry.getAuthor());
}
@@ -292,7 +297,7 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
return new AbstractSet<User>() {
public Iterator<User> iterator() {
- return new AdaptedIterator<String,User>(culprits.iterator()) {
+ return new AdaptedIterator<String, User>(culprits.iterator()) {
protected User adapt(String id) {
return User.get(id);
}
@@ -311,9 +316,11 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
* @since 1.191
*/
public boolean hasParticipant(User user) {
- for (ChangeLogSet.Entry e : getChangeSet())
- if (e.getAuthor()==user)
+ for (ChangeLogSet.Entry e : getChangeSet()) {
+ if (e.getAuthor() == user) {
return true;
+ }
+ }
return false;
}
@@ -330,41 +337,44 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
public synchronized void delete() throws IOException {
// Need to check if deleting this build affects lastSuccessful/lastStable symlinks
R lastSuccessful = getProject().getLastSuccessfulBuild(),
- lastStable = getProject().getLastStableBuild();
+ lastStable = getProject().getLastStableBuild();
super.delete();
try {
- if (lastSuccessful == this)
+ if (lastSuccessful == this) {
updateSymlink("lastSuccessful", getProject().getLastSuccessfulBuild());
- if (lastStable == this)
+ }
+ if (lastStable == this) {
updateSymlink("lastStable", getProject().getLastStableBuild());
+ }
} catch (InterruptedException ex) {
LOGGER.warning("Interrupted update of lastSuccessful/lastStable symlinks for "
- + getProject().getDisplayName());
+ + getProject().getDisplayName());
// handle it later
Thread.currentThread().interrupt();
}
}
- private void updateSymlink(String name, AbstractBuild<?,?> newTarget) throws InterruptedException {
- if (newTarget != null)
+ private void updateSymlink(String name, AbstractBuild<?, ?> newTarget) throws InterruptedException {
+ if (newTarget != null) {
newTarget.createSymlink(new LogTaskListener(LOGGER, Level.WARNING), name);
- else
- new File(getProject().getBuildDir(), "../"+name).delete();
+ } else {
+ new File(getProject().getBuildDir(), "../" + name).delete();
+ }
}
private void createSymlink(TaskListener listener, String name) throws InterruptedException {
- Util.createSymlink(getProject().getBuildDir(),"builds/"+getId(),"../"+name,listener);
+ Util.createSymlink(getProject().getBuildDir(), "builds/" + getId(), "../" + name, listener);
}
protected abstract class AbstractRunner extends Runner {
+
/**
* Since configuration can be changed while a build is in progress,
* create a launcher once and stick to it for the entire build duration.
*/
protected Launcher launcher;
-
/**
* Output/progress of this build goes here.
*/
@@ -380,44 +390,46 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
/**
* Allocates the workspace from {@link WorkspaceList}.
*
- * @param n
- * Passed in for the convenience. The node where the build is running.
- * @param wsl
- * Passed in for the convenience. The returned path must be registered to this object.
+ * @param n Passed in for the convenience. The node where the build is
+ * running.
+ * @param wsl Passed in for the convenience. The returned path must be
+ * registered to this object.
*/
protected Lease decideWorkspace(Node n, WorkspaceList wsl) throws InterruptedException, IOException {
// TODO: this cast is indicative of abstraction problem
- return wsl.allocate(n.getWorkspaceFor((TopLevelItem)getProject()));
+ return wsl.allocate(n.getWorkspaceFor((TopLevelItem) getProject()));
}
public Result run(BuildListener listener) throws Exception {
Node node = getCurrentNode();
- assert builtOn==null;
+ assert builtOn == null;
builtOn = node.getNodeName();
hudsonVersion = Hudson.VERSION;
this.listener = listener;
launcher = createLauncher(listener);
- if (!Hudson.getInstance().getNodes().isEmpty())
+ if (!Hudson.getInstance().getNodes().isEmpty()) {
listener.getLogger().println(node instanceof Hudson ? Messages.AbstractBuild_BuildingOnMaster() : Messages.AbstractBuild_BuildingRemotely(builtOn));
+ }
- final Lease lease = decideWorkspace(node,Computer.currentComputer().getWorkspaceList());
+ final Lease lease = decideWorkspace(node, Computer.currentComputer().getWorkspaceList());
try {
workspace = lease.path.getRemote();
- node.getFileSystemProvisioner().prepareWorkspace(AbstractBuild.this,lease.path,listener);
+ node.getFileSystemProvisioner().prepareWorkspace(AbstractBuild.this, lease.path, listener);
if (project.isCleanWorkspaceRequired()) {
listener.getLogger().println("Cleaning the workspace because project is configured to clean the workspace before each build.");
- if (!project.cleanWorkspace()){
+ if (!project.cleanWorkspace()) {
listener.getLogger().println("Workspace cleaning was attempted but SCM blocked the cleaning.");
}
}
-
+
checkout(listener);
- if (!preBuild(listener,project.getProperties()))
+ if (!preBuild(listener, project.getProperties())) {
return Result.FAILURE;
+ }
Result result = doRun(listener);
@@ -425,7 +437,7 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
if (c == null || c.isOffline()) {
// As can be seen in HUDSON-5073, when a build fails because of the slave connectivity problem,
// error message doesn't point users to the slave. So let's do it here.
- listener.hyperlink("/computer/" + builtOn + "/log","Looks like the node went offline during the build. Check the slave log for the details.");
+ listener.hyperlink("/computer/" + builtOn + "/log", "Looks like the node went offline during the build. Check the slave log for the details.");
if (c != null) {
// grab the end of the log file. This might not work very well if the slave already
@@ -448,8 +460,12 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
// this is ugly, but for historical reason, if non-null value is returned
// it should become the final result.
- if (result==null) result = getResult();
- if (result==null) result = Result.SUCCESS;
+ if (result == null) {
+ result = getResult();
+ }
+ if (result == null) {
+ result = Result.SUCCESS;
+ }
return result;
} finally {
@@ -459,31 +475,32 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
}
/**
- * Creates a {@link Launcher} that this build will use. This can be overridden by derived types
- * to decorate the resulting {@link Launcher}.
+ * Creates a {@link Launcher} that this build will use. This can be
+ * overridden by derived types to decorate the resulting
+ * {@link Launcher}.
*
- * @param listener
- * Always non-null. Connected to the main build output.
+ * @param listener Always non-null. Connected to the main build output.
*/
protected Launcher createLauncher(BuildListener listener) throws IOException, InterruptedException {
Launcher l = getCurrentNode().createLauncher(listener);
if (project instanceof BuildableItemWithBuildWrappers) {
BuildableItemWithBuildWrappers biwbw = (BuildableItemWithBuildWrappers) project;
- for (BuildWrapper bw : biwbw.getBuildWrappersList())
- l = bw.decorateLauncher(AbstractBuild.this,l,listener);
+ for (BuildWrapper bw : biwbw.getBuildWrappersList()) {
+ l = bw.decorateLauncher(AbstractBuild.this, l, listener);
+ }
}
buildEnvironments = new ArrayList<Environment>();
- for (NodeProperty nodeProperty: Hudson.getInstance().getGlobalNodeProperties()) {
+ for (NodeProperty nodeProperty : Hudson.getInstance().getGlobalNodeProperties()) {
Environment environment = nodeProperty.setUp(AbstractBuild.this, l, listener);
if (environment != null) {
buildEnvironments.add(environment);
}
}
- for (NodeProperty nodeProperty: Computer.currentComputer().getNode().getNodeProperties()) {
+ for (NodeProperty nodeProperty : Computer.currentComputer().getNode().getNodeProperties()) {
Environment environment = nodeProperty.setUp(AbstractBuild.this, l, listener);
if (environment != null) {
buildEnvironments.add(environment);
@@ -494,7 +511,7 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
}
private void checkout(BuildListener listener) throws Exception {
- for (int retryCount = project.getScmCheckoutRetryCount(); ; retryCount--) {
+ for (int retryCount = project.getScmCheckoutRetryCount();; retryCount--) {
// for historical reasons, null in the scm field means CVS, so we need to explicitly set this to something
// in case check out fails and leaves a broken changelog.xml behind.
// see http://www.nabble.com/CVSChangeLogSet.parse-yields-SAXParseExceptions-when-parsing-bad-*AccuRev*-changelog.xml-files-td22213663.html
@@ -502,7 +519,7 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
try {
if (project.checkout(AbstractBuild.this, launcher, listener,
- new File(getRootDir(), "changelog.xml"))) {
+ new File(getRootDir(), "changelog.xml"))) {
// check out succeeded
SCM scm = project.getScm();
@@ -521,7 +538,7 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
e.printStackTrace(listener.getLogger());
}
// all attempts failed
- if (retryCount == 0){
+ if (retryCount == 0) {
throw new RunnerAbortedException();
}
listener.getLogger().println("Retrying after 10 seconds");
@@ -530,13 +547,12 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
}
/**
- * The portion of a build that is specific to a subclass of {@link AbstractBuild}
- * goes here.
+ * The portion of a build that is specific to a subclass of
+ * {@link AbstractBuild} goes here.
*
- * @return
- * null to continue the build normally (that means the doRun method
- * itself run successfully)
- * Return a non-null value to abort the build right there with the specified result code.
+ * @return null to continue the build normally (that means the doRun
+ * method itself run successfully) Return a non-null value to abort the
+ * build right there with the specified result code.
*/
protected abstract Result doRun(BuildListener listener) throws Exception, RunnerAbortedException;
@@ -549,16 +565,19 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
try {
post2(listener);
- if (result.isBetterOrEqualTo(Result.UNSTABLE))
+ if (result.isBetterOrEqualTo(Result.UNSTABLE)) {
createSymlink(listener, "lastSuccessful");
+ }
- if (result.isBetterOrEqualTo(Result.SUCCESS))
+ if (result.isBetterOrEqualTo(Result.SUCCESS)) {
createSymlink(listener, "lastStable");
+ }
} finally {
// update the culprit list
HashSet<String> r = new HashSet<String>();
- for (User u : getCulprits())
+ for (User u : getCulprits()) {
r.add(u.getId());
+ }
culprits = r;
CheckPoint.CULPRITS_DETERMINED.report();
}
@@ -570,37 +589,37 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
}
/**
- * @deprecated as of 1.356
- * Use {@link #performAllBuildSteps(BuildListener, Map, boolean)}
+ * @deprecated as of 1.356 Use
+ * {@link #performAllBuildSteps(BuildListener, Map, boolean)}
*/
- protected final void performAllBuildStep(BuildListener listener, Map<?,? extends BuildStep> buildSteps, boolean phase) throws InterruptedException, IOException {
- performAllBuildSteps(listener,buildSteps.values(),phase);
+ protected final void performAllBuildStep(BuildListener listener, Map<?, ? extends BuildStep> buildSteps, boolean phase) throws InterruptedException, IOException {
+ performAllBuildSteps(listener, buildSteps.values(), phase);
}
- protected final boolean performAllBuildSteps(BuildListener listener, Map<?,? extends BuildStep> buildSteps, boolean phase) throws InterruptedException, IOException {
- return performAllBuildSteps(listener,buildSteps.values(),phase);
+ protected final boolean performAllBuildSteps(BuildListener listener, Map<?, ? extends BuildStep> buildSteps, boolean phase) throws InterruptedException, IOException {
+ return performAllBuildSteps(listener, buildSteps.values(), phase);
}
/**
- * @deprecated as of 1.356
- * Use {@link #performAllBuildSteps(BuildListener, Iterable, boolean)}
+ * @deprecated as of 1.356 Use
+ * {@link #performAllBuildSteps(BuildListener, Iterable, boolean)}
*/
protected final void performAllBuildStep(BuildListener listener, Iterable<? extends BuildStep> buildSteps, boolean phase) throws InterruptedException, IOException {
- performAllBuildSteps(listener,buildSteps,phase);
+ performAllBuildSteps(listener, buildSteps, phase);
}
/**
* Runs all the given build steps, even if one of them fail.
*
- * @param phase
- * true for the post build processing, and false for the final "run after finished" execution.
+ * @param phase true for the post build processing, and false for the
+ * final "run after finished" execution.
*/
protected final boolean performAllBuildSteps(BuildListener listener, Iterable<? extends BuildStep> buildSteps,
- boolean phase) throws InterruptedException, IOException {
+ boolean phase) throws InterruptedException, IOException {
boolean r = true;
for (BuildStep bs : buildSteps) {
- if (bs instanceof Publisher && ((Publisher) bs).needsToRun(getResult()) &&
- ((((Publisher) bs).needsToRunAfterFinalized()) ^ phase)) {
+ if (bs instanceof Publisher && ((Publisher) bs).needsToRun(getResult())
+ && ((((Publisher) bs).needsToRunAfterFinalized()) ^ phase)) {
try {
r &= perform(bs, listener);
} catch (Exception e) {
@@ -627,18 +646,20 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
return mon.perform(bs, AbstractBuild.this, launcher, listener);
}
- protected final boolean preBuild(BuildListener listener,Map<?,? extends BuildStep> steps) {
- return preBuild(listener,steps.values());
+ protected final boolean preBuild(BuildListener listener, Map<?, ? extends BuildStep> steps) {
+ return preBuild(listener, steps.values());
}
- protected final boolean preBuild(BuildListener listener,Collection<? extends BuildStep> steps) {
- return preBuild(listener,(Iterable<? extends BuildStep>)steps);
+ protected final boolean preBuild(BuildListener listener, Collection<? extends BuildStep> steps) {
+ return preBuild(listener, (Iterable<? extends BuildStep>) steps);
}
- protected final boolean preBuild(BuildListener listener,Iterable<? extends BuildStep> steps) {
- for (BuildStep bs : steps)
- if (!bs.prebuild(AbstractBuild.this,listener))
+ protected final boolean preBuild(BuildListener listener, Iterable<? extends BuildStep> steps) {
+ for (BuildStep bs : steps) {
+ if (!bs.prebuild(AbstractBuild.this, listener)) {
return false;
+ }
+ }
return true;
}
}
@@ -650,33 +671,36 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
*/
@Exported
public ChangeLogSet<? extends Entry> getChangeSet() {
- if (scm==null) {
+ if (scm == null) {
// for historical reason, null means CVS.
try {
Class<?> c = Hudson.getInstance().getPluginManager().uberClassLoader.loadClass("hudson.scm.CVSChangeLogParser");
- scm = (ChangeLogParser)c.newInstance();
+ scm = (ChangeLogParser) c.newInstance();
} catch (ClassNotFoundException e) {
// if CVS isn't available, fall back to something non-null.
scm = new NullChangeLogParser();
} catch (InstantiationException e) {
scm = new NullChangeLogParser();
- throw (Error)new InstantiationError().initCause(e);
+ throw (Error) new InstantiationError().initCause(e);
} catch (IllegalAccessException e) {
scm = new NullChangeLogParser();
- throw (Error)new IllegalAccessError().initCause(e);
+ throw (Error) new IllegalAccessError().initCause(e);
}
}
- if (changeSet==null) // cached value
+ if (changeSet == null) // cached value
+ {
try {
changeSet = calcChangeSet();
} finally {
// defensive check. if the calculation fails (such as through an exception),
// set a dummy value so that it'll work the next time. the exception will
// be still reported, giving the plugin developer an opportunity to fix it.
- if (changeSet==null)
- changeSet=ChangeLogSet.createEmpty(this);
+ if (changeSet == null) {
+ changeSet = ChangeLogSet.createEmpty(this);
+ }
}
+ }
return changeSet;
}
@@ -690,11 +714,12 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
private ChangeLogSet<? extends Entry> calcChangeSet() {
File changelogFile = new File(getRootDir(), "changelog.xml");
- if (!changelogFile.exists())
+ if (!changelogFile.exists()) {
return ChangeLogSet.createEmpty(this);
+ }
try {
- return scm.parse(this,changelogFile);
+ return scm.parse(this, changelogFile);
} catch (IOException e) {
e.printStackTrace();
} catch (SAXException e) {
@@ -707,12 +732,14 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
public EnvVars getEnvironment(TaskListener log) throws IOException, InterruptedException {
EnvVars env = super.getEnvironment(log);
FilePath ws = getWorkspace();
- if (ws!=null) // if this is done very early on in the build, workspace may not be decided yet. see HUDSON-3997
+ if (ws != null) // if this is done very early on in the build, workspace may not be decided yet. see HUDSON-3997
+ {
env.put("WORKSPACE", ws.getRemote());
+ }
// servlet container may have set CLASSPATH in its launch script,
// so don't let that inherit to the new child process.
// see http://www.nabble.com/Run-Job-with-JDK-1.4.2-tf4468601.html
- env.put("CLASSPATH","");
+ env.put("CLASSPATH", "");
JDK jdk = project.getJDK();
if (jdk != null) {
@@ -722,14 +749,17 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
}
jdk.buildEnvVars(env);
}
- project.getScm().buildEnvVars(this,env);
+ project.getScm().buildEnvVars(this, env);
- if (buildEnvironments!=null)
- for (Environment e : buildEnvironments)
+ if (buildEnvironments != null) {
+ for (Environment e : buildEnvironments) {
e.buildEnvVars(env);
+ }
+ }
- for (EnvironmentContributingAction a : Util.filter(getActions(),EnvironmentContributingAction.class))
- a.buildEnvVars(this,env);
+ for (EnvironmentContributingAction a : Util.filter(getActions(), EnvironmentContributingAction.class)) {
+ a.buildEnvVars(this, env);
+ }
EnvVars.resolve(env);
@@ -766,48 +796,47 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
bw.makeSensitiveBuildVariables(this, s);
}
}
-
+
return s;
}
/**
* Provides additional variables and their values to {@link Builder}s.
*
- * <p>
- * This mechanism is used by {@link MatrixConfiguration} to pass
- * the configuration values to the current build. It is up to
- * {@link Builder}s to decide whether it wants to recognize the values
- * or how to use them.
+ * <p> This mechanism is used by {@link MatrixConfiguration} to pass the
+ * configuration values to the current build. It is up to {@link Builder}s
+ * to decide whether it wants to recognize the values or how to use them.
*
- * <p>
- * This also includes build parameters if a build is parameterized.
+ * <p> This also includes build parameters if a build is parameterized.
*
- * @return
- * The returned map is mutable so that subtypes can put more values.
+ * @return The returned map is mutable so that subtypes can put more values.
*/
- public Map<String,String> getBuildVariables() {
- Map<String,String> r = new HashMap<String, String>();
+ public Map<String, String> getBuildVariables() {
+ Map<String, String> r = new HashMap<String, String>();
ParametersAction parameters = getAction(ParametersAction.class);
- if (parameters!=null) {
+ if (parameters != null) {
// this is a rather round about way of doing this...
for (ParameterValue p : parameters) {
String v = p.createVariableResolver(this).resolve(p.getName());
- if (v!=null) r.put(p.getName(),v);
+ if (v != null) {
+ r.put(p.getName(), v);
+ }
}
}
-
+
customizeBuildVariables(r);
// allow the BuildWrappers to contribute additional build variables
if (project instanceof BuildableItemWithBuildWrappers) {
- for (BuildWrapper bw : ((BuildableItemWithBuildWrappers) project).getBuildWrappersList())
- bw.makeBuildVariables(this,r);
+ for (BuildWrapper bw : ((BuildableItemWithBuildWrappers) project).getBuildWrappersList()) {
+ bw.makeBuildVariables(this, r);
+ }
}
return r;
}
-
+
/**
* @since 2.1.0
*/
@@ -815,7 +844,6 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
// nop
}
-
/**
* Creates {@link VariableResolver} backed by {@link #getBuildVariables()}.
*/
@@ -840,29 +868,32 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
// fingerprint related stuff
//
//
-
@Override
public String getWhyKeepLog() {
// if any of the downstream project is configured with 'keep dependency component',
// we need to keep this log
OUTER:
- for (AbstractProject<?,?> p : getParent().getDownstreamProjects()) {
- if (!p.isKeepDependencies()) continue;
-
- AbstractBuild<?,?> fb = p.getFirstBuild();
- if (fb==null) continue; // no active record
+ for (AbstractProject<?, ?> p : getParent().getDownstreamProjects()) {
+ if (!p.isKeepDependencies()) {
+ continue;
+ }
+ AbstractBuild<?, ?> fb = p.getFirstBuild();
+ if (fb == null) {
+ continue; // no active record
+ }
// is there any active build that depends on us?
for (int i : getDownstreamRelationship(p).listNumbersReverse()) {
// TODO: this is essentially a "find intersection between two sparse sequences"
// and we should be able to do much better.
- if (i<fb.getNumber())
+ if (i < fb.getNumber()) {
continue OUTER; // all the other records are younger than the first record, so pointless to search.
-
- AbstractBuild<?,?> b = p.getBuildByNumber(i);
- if (b!=null)
+ }
+ AbstractBuild<?, ?> b = p.getBuildByNumber(i);
+ if (b != null) {
return Messages.AbstractBuild_KeptBecause(b);
+ }
}
}
@@ -870,18 +901,20 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
}
/**
- * Gets the dependency relationship from this build (as the source)
- * and that project (as the sink.)
+ * Gets the dependency relationship from this build (as the source) and that
+ * project (as the sink.)
*
- * @return
- * range of build numbers that represent which downstream builds are using this build.
- * The range will be empty if no build of that project matches this, but it'll never be null.
+ * @return range of build numbers that represent which downstream builds are
+ * using this build. The range will be empty if no build of that project
+ * matches this, but it'll never be null.
*/
public RangeSet getDownstreamRelationship(AbstractProject that) {
RangeSet rs = new RangeSet();
FingerprintAction f = getAction(FingerprintAction.class);
- if (f==null) return rs;
+ if (f == null) {
+ return rs;
+ }
// look for fingerprints that point to this build as the source, and merge them all
for (Fingerprint e : f.getFingerprints().values()) {
@@ -892,8 +925,9 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
rs.add(e.getRangeSet(that));
} else {
BuildPtr o = e.getOriginal();
- if (o!=null && o.is(this))
+ if (o != null && o.is(this)) {
rs.add(e.getRangeSet(that));
+ }
}
}
@@ -901,36 +935,38 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
}
/**
- * Works like {@link #getDownstreamRelationship(AbstractProject)} but returns
- * the actual build objects, in ascending order.
+ * Works like {@link #getDownstreamRelationship(AbstractProject)} but
+ * returns the actual build objects, in ascending order.
+ *
* @since 1.150
*/
- public Iterable<AbstractBuild<?,?>> getDownstreamBuilds(final AbstractProject<?,?> that) {
+ public Iterable<AbstractBuild<?, ?>> getDownstreamBuilds(final AbstractProject<?, ?> that) {
final Iterable<Integer> nums = getDownstreamRelationship(that).listNumbers();
return new Iterable<AbstractBuild<?, ?>>() {
public Iterator<AbstractBuild<?, ?>> iterator() {
return Iterators.removeNull(
- new AdaptedIterator<Integer,AbstractBuild<?,?>>(nums) {
- protected AbstractBuild<?, ?> adapt(Integer item) {
- return that.getBuildByNumber(item);
- }
- });
+ new AdaptedIterator<Integer, AbstractBuild<?, ?>>(nums) {
+ protected AbstractBuild<?, ?> adapt(Integer item) {
+ return that.getBuildByNumber(item);
+ }
+ });
}
};
}
/**
- * Gets the dependency relationship from this build (as the sink)
- * and that project (as the source.)
+ * Gets the dependency relationship from this build (as the sink) and that
+ * project (as the source.)
*
- * @return
- * Build number of the upstream build that feed into this build,
- * or -1 if no record is available.
+ * @return Build number of the upstream build that feed into this build, or
+ * -1 if no record is available.
*/
public int getUpstreamRelationship(AbstractProject that) {
FingerprintAction f = getAction(FingerprintAction.class);
- if (f==null) return -1;
+ if (f == null) {
+ return -1;
+ }
int n = -1;
@@ -945,8 +981,9 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
}
} else {
BuildPtr o = e.getOriginal();
- if (o!=null && o.belongsTo(that))
- n = Math.max(n,o.getNumber());
+ if (o != null && o.belongsTo(that)) {
+ n = Math.max(n, o.getNumber());
+ }
}
}
@@ -954,16 +991,17 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
}
/**
- * Works like {@link #getUpstreamRelationship(AbstractProject)} but returns the
- * actual build object.
+ * Works like {@link #getUpstreamRelationship(AbstractProject)} but returns
+ * the actual build object.
*
- * @return
- * null if no such upstream build was found, or it was found but the
- * build record is already lost.
+ * @return null if no such upstream build was found, or it was found but the
+ * build record is already lost.
*/
- public AbstractBuild<?,?> getUpstreamRelationshipBuild(AbstractProject<?,?> that) {
+ public AbstractBuild<?, ?> getUpstreamRelationshipBuild(AbstractProject<?, ?> that) {
int n = getUpstreamRelationship(that);
- if (n==-1) return null;
+ if (n == -1) {
+ return null;
+ }
return that.getBuildByNumber(n);
}
@@ -971,15 +1009,16 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
* Gets the downstream builds of this build, which are the builds of the
* downstream projects that use artifacts of this build.
*
- * @return
- * For each project with fingerprinting enabled, returns the range
- * of builds (which can be empty if no build uses the artifact from this build.)
+ * @return For each project with fingerprinting enabled, returns the range
+ * of builds (which can be empty if no build uses the artifact from this
+ * build.)
*/
- public Map<AbstractProject,RangeSet> getDownstreamBuilds() {
- Map<AbstractProject,RangeSet> r = new HashMap<AbstractProject,RangeSet>();
+ public Map<AbstractProject, RangeSet> getDownstreamBuilds() {
+ Map<AbstractProject, RangeSet> r = new HashMap<AbstractProject, RangeSet>();
for (AbstractProject p : getParent().getDownstreamProjects()) {
- if (p.isFingerprintConfigured())
- r.put(p,getDownstreamRelationship(p));
+ if (p.isFingerprintConfigured()) {
+ r.put(p, getDownstreamRelationship(p));
+ }
}
return r;
}
@@ -990,48 +1029,54 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
*
* @see #getTransitiveUpstreamBuilds()
*/
- public Map<AbstractProject,Integer> getUpstreamBuilds() {
+ public Map<AbstractProject, Integer> getUpstreamBuilds() {
return _getUpstreamBuilds(getParent().getUpstreamProjects());
}
/**
- * Works like {@link #getUpstreamBuilds()} but also includes all the transitive
- * dependencies as well.
+ * Works like {@link #getUpstreamBuilds()} but also includes all the
+ * transitive dependencies as well.
*/
- public Map<AbstractProject,Integer> getTransitiveUpstreamBuilds() {
+ public Map<AbstractProject, Integer> getTransitiveUpstreamBuilds() {
return _getUpstreamBuilds(getParent().getTransitiveUpstreamProjects());
}
private Map<AbstractProject, Integer> _getUpstreamBuilds(Collection<AbstractProject> projects) {
- Map<AbstractProject,Integer> r = new HashMap<AbstractProject,Integer>();
+ Map<AbstractProject, Integer> r = new HashMap<AbstractProject, Integer>();
for (AbstractProject p : projects) {
int n = getUpstreamRelationship(p);
- if (n>=0)
- r.put(p,n);
+ if (n >= 0) {
+ r.put(p, n);
+ }
}
return r;
}
/**
- * Gets the changes in the dependency between the given build and this build.
+ * Gets the changes in the dependency between the given build and this
+ * build.
*/
- public Map<AbstractProject,DependencyChange> getDependencyChanges(AbstractBuild from) {
- if (from==null) return Collections.emptyMap(); // make it easy to call this from views
+ public Map<AbstractProject, DependencyChange> getDependencyChanges(AbstractBuild from) {
+ if (from == null) {
+ return Collections.emptyMap(); // make it easy to call this from views
+ }
FingerprintAction n = this.getAction(FingerprintAction.class);
FingerprintAction o = from.getAction(FingerprintAction.class);
- if (n==null || o==null) return Collections.emptyMap();
+ if (n == null || o == null) {
+ return Collections.emptyMap();
+ }
- Map<AbstractProject,Integer> ndep = n.getDependencies();
- Map<AbstractProject,Integer> odep = o.getDependencies();
+ Map<AbstractProject, Integer> ndep = n.getDependencies();
+ Map<AbstractProject, Integer> odep = o.getDependencies();
- Map<AbstractProject,DependencyChange> r = new HashMap<AbstractProject,DependencyChange>();
+ Map<AbstractProject, DependencyChange> r = new HashMap<AbstractProject, DependencyChange>();
- for (Map.Entry<AbstractProject,Integer> entry : odep.entrySet()) {
+ for (Map.Entry<AbstractProject, Integer> entry : odep.entrySet()) {
AbstractProject p = entry.getKey();
Integer oldNumber = entry.getValue();
Integer newNumber = ndep.get(p);
- if (newNumber!=null && oldNumber.compareTo(newNumber)<0) {
- r.put(p,new DependencyChange(p,oldNumber,newNumber));
+ if (newNumber != null && oldNumber.compareTo(newNumber) < 0) {
+ r.put(p, new DependencyChange(p, oldNumber, newNumber));
}
}
@@ -1042,6 +1087,7 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
* Represents a change in the dependency.
*/
public static final class DependencyChange {
+
/**
* The dependency project.
*/
@@ -1053,7 +1099,8 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
//TODO: review and check whether we can do it private
public final int fromId;
/**
- * {@link Build} object for {@link #fromId}. Can be null if the log is gone.
+ * {@link Build} object for {@link #fromId}. Can be null if the log is
+ * gone.
*/
//TODO: review and check whether we can do it private
public final AbstractBuild from;
@@ -1065,7 +1112,7 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
//TODO: review and check whether we can do it private
public final AbstractBuild to;
- public DependencyChange(AbstractProject<?,?> project, int fromId, int toId) {
+ public DependencyChange(AbstractProject<?, ?> project, int fromId, int toId) {
this.project = project;
this.fromId = fromId;
this.toId = toId;
@@ -1092,20 +1139,20 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
public AbstractBuild getTo() {
return to;
}
+
/**
- * Gets the {@link AbstractBuild} objects (fromId,toId].
- * <p>
- * This method returns all such available builds in the ascending order
- * of IDs, but due to log rotations, some builds may be already unavailable.
+ * Gets the {@link AbstractBuild} objects (fromId,toId]. <p> This method
+ * returns all such available builds in the ascending order of IDs, but
+ * due to log rotations, some builds may be already unavailable.
*/
public List<AbstractBuild> getBuilds() {
List<AbstractBuild> r = new ArrayList<AbstractBuild>();
- AbstractBuild<?,?> b = (AbstractBuild)project.getNearestBuild(fromId);
- if (b!=null && b.getNumber()==fromId)
+ AbstractBuild<?, ?> b = (AbstractBuild) project.getNearestBuild(fromId);
+ if (b != null && b.getNumber() == fromId) {
b = b.getNextBuild(); // fromId exclusive
-
- while (b!=null && b.getNumber()<=toId) {
+ }
+ while (b != null && b.getNumber() <= toId) {
r.add(b);
b = b.getNextBuild();
}
@@ -1117,21 +1164,20 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
//
// web methods
//
-
/**
* Stops this build if it's still going.
*
- * If we use this/executor/stop URL, it causes 404 if the build is already killed,
- * as {@link #getExecutor()} returns null.
+ * If we use this/executor/stop URL, it causes 404 if the build is already
+ * killed, as {@link #getExecutor()} returns null.
*/
public synchronized void doStop(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
Executor e = getExecutor();
- if (e!=null)
- e.doStop(req,rsp);
- else
- // nothing is building
+ if (e != null) {
+ e.doStop(req, rsp);
+ } else // nothing is building
+ {
rsp.forwardToPreviousPage(req);
+ }
}
-
private static final Logger LOGGER = Logger.getLogger(AbstractBuild.class.getName());
}
diff --git a/hudson-core/src/main/java/hudson/model/AbstractDescribableImpl.java b/hudson-core/src/main/java/hudson/model/AbstractDescribableImpl.java
index 138ef4c..6504482 100644
--- a/hudson-core/src/main/java/hudson/model/AbstractDescribableImpl.java
+++ b/hudson-core/src/main/java/hudson/model/AbstractDescribableImpl.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
*
* Kohsuke Kawaguchi
- *
+ *
*
*******************************************************************************/
@@ -22,6 +22,7 @@ package hudson.model;
* @author Kohsuke Kawaguchi
*/
public abstract class AbstractDescribableImpl<T extends AbstractDescribableImpl<T>> implements Describable<T> {
+
public Descriptor<T> getDescriptor() {
return Hudson.getInstance().getDescriptorOrDie(getClass());
}
diff --git a/hudson-core/src/main/java/hudson/model/AbstractItem.java b/hudson-core/src/main/java/hudson/model/AbstractItem.java
index 30c2515..ba0696c 100644
--- a/hudson-core/src/main/java/hudson/model/AbstractItem.java
+++ b/hudson-core/src/main/java/hudson/model/AbstractItem.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
*
* Kohsuke Kawaguchi, Winston Prakash, Daniel Dyer, Tom Huybrechts
- *
+ *
*******************************************************************************/
package hudson.model;
@@ -64,16 +64,15 @@ import org.eclipse.hudson.security.HudsonSecurityEntitiesHolder;
// Java doesn't let multiple inheritance.
@ExportedBean
public abstract class AbstractItem extends Actionable implements Item, HttpDeletable, AccessControlled, DescriptorByNameOwner {
+
/**
* Project name.
*/
protected /*final*/ transient String name;
-
/**
* Project description. Can be HTML.
*/
protected volatile String description;
-
private transient ItemGroup parent;
protected AbstractItem(ItemGroup parent, String name) {
@@ -85,14 +84,14 @@ public abstract class AbstractItem extends Actionable implements Item, HttpDelet
// noop
}
- @Exported(visibility=999)
+ @Exported(visibility = 999)
public String getName() {
return name;
}
/**
- * Get the term used in the UI to represent this kind of
- * {@link Item}. Must start with a capital letter.
+ * Get the term used in the UI to represent this kind of {@link Item}. Must
+ * start with a capital letter.
*/
public String getPronoun() {
return Messages.AbstractItem_Pronoun();
@@ -108,7 +107,7 @@ public abstract class AbstractItem extends Actionable implements Item, HttpDelet
}
public ItemGroup getParent() {
- assert parent!=null;
+ assert parent != null;
return parent;
}
@@ -129,16 +128,16 @@ public abstract class AbstractItem extends Actionable implements Item, HttpDelet
}
/**
- * Just update {@link #name} without performing the rename operation,
- * which would involve copying files and etc.
+ * Just update {@link #name} without performing the rename operation, which
+ * would involve copying files and etc.
*/
protected void doSetName(String name) {
this.name = name;
}
/**
- * Ad additional action which should be performed before the item will be renamed.
- * It's possible to add some logic in the subclasses.
+ * Ad additional action which should be performed before the item will be
+ * renamed. It's possible to add some logic in the subclasses.
*
* @param oldName old item name.
* @param newName new item name.
@@ -148,9 +147,8 @@ public abstract class AbstractItem extends Actionable implements Item, HttpDelet
}
/**
- * Renames this item.
- * Not all the Items need to support this operation, but if you decide to do so,
- * you can use this method.
+ * Renames this item. Not all the Items need to support this operation, but
+ * if you decide to do so, you can use this method.
*/
protected void renameTo(String newName) throws IOException {
// always synchronize from bigger objects first
@@ -158,24 +156,27 @@ public abstract class AbstractItem extends Actionable implements Item, HttpDelet
synchronized (parent) {
synchronized (this) {
// sanity check
- if (newName == null)
+ if (newName == null) {
throw new IllegalArgumentException("New name is not given");
+ }
// noop?
- if (this.name.equals(newName))
+ if (this.name.equals(newName)) {
return;
+ }
Item existing = parent.getItem(newName);
- if (existing != null && existing!=this)
- // the look up is case insensitive, so we need "existing!=this"
- // to allow people to rename "Foo" to "foo", for example.
- // see http://www.nabble.com/error-on-renaming-project-tt18061629.html
+ if (existing != null && existing != this) // the look up is case insensitive, so we need "existing!=this"
+ // to allow people to rename "Foo" to "foo", for example.
+ // see http://www.nabble.com/error-on-renaming-project-tt18061629.html
+ {
throw new IllegalArgumentException("Job " + newName
+ " already exists");
+ }
String oldName = this.name;
- performBeforeItemRenaming(oldName,newName);
+ performBeforeItemRenaming(oldName, newName);
File oldRoot = this.getRootDir();
@@ -205,8 +206,9 @@ public abstract class AbstractItem extends Actionable implements Item, HttpDelet
}
}
- if (interrupted)
+ if (interrupted) {
Thread.currentThread().interrupt();
+ }
if (!renamed) {
// failed to rename. it must be that some lengthy
@@ -226,7 +228,7 @@ public abstract class AbstractItem extends Actionable implements Item, HttpDelet
cp.setOverwrite(true);
cp.setPreserveLastModified(true);
cp.setFailOnError(false); // keep going even if
- // there's an error
+ // there's an error
cp.execute();
// try to delete as much as possible
@@ -241,21 +243,23 @@ public abstract class AbstractItem extends Actionable implements Item, HttpDelet
success = true;
} finally {
// if failed, back out the rename.
- if (!success)
+ if (!success) {
doSetName(oldName);
+ }
}
callOnRenamed(newName, parent, oldName);
- for (ItemListener l : ItemListener.all())
+ for (ItemListener l : ItemListener.all()) {
l.onRenamed(this, oldName, newName);
+ }
}
}
}
/**
- * A pointless function to work around what appears to be a HotSpot problem. See HUDSON-5756 and bug 6933067
- * on BugParade for more details.
+ * A pointless function to work around what appears to be a HotSpot problem.
+ * See HUDSON-5756 and bug 6933067 on BugParade for more details.
*/
private void callOnRenamed(String newName, ItemGroup parent, String oldName) throws IOException {
try {
@@ -272,19 +276,25 @@ public abstract class AbstractItem extends Actionable implements Item, HttpDelet
public final String getFullName() {
String n = getParent().getFullName();
- if(n.length()==0) return getName();
- else return n+'/'+getName();
+ if (n.length() == 0) {
+ return getName();
+ } else {
+ return n + '/' + getName();
+ }
}
public final String getFullDisplayName() {
String n = getParent().getFullDisplayName();
- if(n.length()==0) return getDisplayName();
- else return n+" \u00BB "+getDisplayName();
+ if (n.length() == 0) {
+ return getDisplayName();
+ } else {
+ return n + " \u00BB " + getDisplayName();
+ }
}
/**
- * Called right after when a {@link Item} is loaded from disk.
- * This is an opporunity to do a post load processing.
+ * Called right after when a {@link Item} is loaded from disk. This is an
+ * opporunity to do a post load processing.
*/
public void onLoad(ItemGroup<? extends Item> parent, String name) throws IOException {
this.parent = parent;
@@ -292,10 +302,9 @@ public abstract class AbstractItem extends Actionable implements Item, HttpDelet
}
/**
- * When a {@link Item} is copied from existing one,
- * the files are first copied on the file system,
- * then it will be loaded, then this method will be invoked
- * to perform any implementation-specific work.
+ * When a {@link Item} is copied from existing one, the files are first
+ * copied on the file system, then it will be loaded, then this method will
+ * be invoked to perform any implementation-specific work.
*/
public void onCopiedFrom(Item src) {
}
@@ -304,31 +313,32 @@ public abstract class AbstractItem extends Actionable implements Item, HttpDelet
// try to stick to the current view if possible
StaplerRequest req = Stapler.getCurrentRequest();
if (req != null) {
- String seed = Functions.getNearestAncestorUrl(req,this);
- if(seed!=null) {
+ String seed = Functions.getNearestAncestorUrl(req, this);
+ if (seed != null) {
// trim off the context path portion and leading '/', but add trailing '/'
- return seed.substring(req.getContextPath().length()+1)+'/';
+ return seed.substring(req.getContextPath().length() + 1) + '/';
}
}
// otherwise compute the path normally
- return getParent().getUrl()+getShortUrl();
+ return getParent().getUrl() + getShortUrl();
}
public String getShortUrl() {
- return getParent().getUrlChildPrefix()+'/'+Util.rawEncode(getName())+'/';
+ return getParent().getUrlChildPrefix() + '/' + Util.rawEncode(getName()) + '/';
}
public String getSearchUrl() {
return getShortUrl();
}
- @Exported(visibility=999,name="url")
+ @Exported(visibility = 999, name = "url")
public final String getAbsoluteUrl() {
StaplerRequest request = Stapler.getCurrentRequest();
- if(request==null)
+ if (request == null) {
throw new IllegalStateException("Not processing a HTTP request");
- return Util.encode(Hudson.getInstance().getRootUrl()+getUrl());
+ }
+ return Util.encode(Hudson.getInstance().getRootUrl() + getUrl());
}
/**
@@ -363,7 +373,9 @@ public abstract class AbstractItem extends Actionable implements Item, HttpDelet
* Save the settings to a file.
*/
public synchronized void save() throws IOException {
- if(BulkChange.contains(this)) return;
+ if (BulkChange.contains(this)) {
+ return;
+ }
getConfigFile().write(this);
SaveableListener.fireOnChange(this, getConfigFile());
}
@@ -379,7 +391,7 @@ public abstract class AbstractItem extends Actionable implements Item, HttpDelet
/**
* Accepts the new description.
*/
- public synchronized void doSubmitDescription( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException {
+ public synchronized void doSubmitDescription(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
checkPermission(CONFIGURE);
setDescription(req.getParameter("description"));
@@ -389,17 +401,19 @@ public abstract class AbstractItem extends Actionable implements Item, HttpDelet
/**
* Deletes this item.
*/
- @CLIMethod(name="delete-job")
- public void doDoDelete( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException, InterruptedException {
+ @CLIMethod(name = "delete-job")
+ public void doDoDelete(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException, InterruptedException {
requirePOST();
delete();
if (rsp != null) // null for CLI
- rsp.sendRedirect2(req.getContextPath()+"/"+getParent().getUrl());
+ {
+ rsp.sendRedirect2(req.getContextPath() + "/" + getParent().getUrl());
+ }
}
- public void delete( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException {
+ public void delete(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
try {
- doDoDelete(req,rsp);
+ doDoDelete(req, rsp);
} catch (InterruptedException e) {
// TODO: allow this in Stapler
throw new ServletException(e);
@@ -423,8 +437,8 @@ public abstract class AbstractItem extends Actionable implements Item, HttpDelet
}
/**
- * A pointless function to work around what appears to be a HotSpot problem. See HUDSON-5756 and bug 6933067
- * on BugParade for more details.
+ * A pointless function to work around what appears to be a HotSpot problem.
+ * See HUDSON-5756 and bug 6933067 on BugParade for more details.
*/
private void invokeOnDeleted() throws IOException {
getParent().onDeleted(this);
@@ -487,7 +501,7 @@ public abstract class AbstractItem extends Actionable implements Item, HttpDelet
}
public String toString() {
- return getClass().getSimpleName()+'['+getFullName()+']';
+ return getClass().getSimpleName() + '[' + getFullName() + ']';
}
/**
@@ -495,13 +509,13 @@ public abstract class AbstractItem extends Actionable implements Item, HttpDelet
*/
@CLIResolver
public static AbstractItem resolveForCLI(
- @Argument(required=true,metaVar="NAME",usage="Job name") String name) throws CmdLineException {
+ @Argument(required = true, metaVar = "NAME", usage = "Job name") String name) throws CmdLineException {
AbstractItem item = Hudson.getInstance().getItemByFullName(name, AbstractItem.class);
- if (item==null){
- if (AbstractProject.findNearest(name) != null){
- throw new CmdLineException(null,Messages.AbstractItem_NoSuchJobExists2(name, AbstractProject.findNearest(name).getFullName()));
- }else{
- throw new CmdLineException(null,Messages.AbstractItem_NoSuchJobExists(name));
+ if (item == null) {
+ if (AbstractProject.findNearest(name) != null) {
+ throw new CmdLineException(null, Messages.AbstractItem_NoSuchJobExists2(name, AbstractProject.findNearest(name).getFullName()));
+ } else {
+ throw new CmdLineException(null, Messages.AbstractItem_NoSuchJobExists(name));
}
}
return item;
diff --git a/hudson-core/src/main/java/hudson/model/AbstractModelObject.java b/hudson-core/src/main/java/hudson/model/AbstractModelObject.java
index c419f51..dadd8ff 100644
--- a/hudson-core/src/main/java/hudson/model/AbstractModelObject.java
+++ b/hudson-core/src/main/java/hudson/model/AbstractModelObject.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
-*
-* Kohsuke Kawaguchi
- *
+ * Contributors:
+ *
+ * Kohsuke Kawaguchi
+ *
*
*******************************************************************************/
@@ -35,40 +35,41 @@ import hudson.search.SearchIndex;
/**
* {@link ModelObject} with some convenience methods.
- *
+ *
* @author Kohsuke Kawaguchi
* @author Nikita Levyankov
*/
public abstract class AbstractModelObject implements SearchableModelObject {
+
/**
* Displays the error in a page.
*/
protected final void sendError(Exception e, StaplerRequest req, StaplerResponse rsp) throws ServletException, IOException {
- sendError(e.getMessage(),req,rsp);
+ sendError(e.getMessage(), req, rsp);
}
protected final void sendError(Exception e) throws ServletException, IOException {
- sendError(e,Stapler.getCurrentRequest(),Stapler.getCurrentResponse());
+ sendError(e, Stapler.getCurrentRequest(), Stapler.getCurrentResponse());
}
protected final void sendError(String message, StaplerRequest req, StaplerResponse rsp) throws ServletException, IOException {
- req.setAttribute("message",message);
- rsp.forward(this,"error",req);
+ req.setAttribute("message", message);
+ rsp.forward(this, "error", req);
}
/**
- * @param pre
- * If true, the message is put in a PRE tag.
+ * @param pre If true, the message is put in a PRE tag.
*/
protected final void sendError(String message, StaplerRequest req, StaplerResponse rsp, boolean pre) throws ServletException, IOException {
- req.setAttribute("message",message);
- if(pre)
- req.setAttribute("pre",true);
- rsp.forward(this,"error",req);
+ req.setAttribute("message", message);
+ if (pre) {
+ req.setAttribute("pre", true);
+ }
+ rsp.forward(this, "error", req);
}
protected final void sendError(String message) throws ServletException, IOException {
- sendError(message,Stapler.getCurrentRequest(),Stapler.getCurrentResponse());
+ sendError(message, Stapler.getCurrentRequest(), Stapler.getCurrentResponse());
}
/**
@@ -76,22 +77,25 @@ public abstract class AbstractModelObject implements SearchableModelObject {
*/
protected final void requirePOST() throws ServletException {
StaplerRequest req = Stapler.getCurrentRequest();
- if (req==null) return; // invoked outside the context of servlet
+ if (req == null) {
+ return; // invoked outside the context of servlet
+ }
String method = req.getMethod();
- if(!method.equalsIgnoreCase("POST"))
- throw new ServletException("Must be POST, Can't be "+method);
+ if (!method.equalsIgnoreCase("POST")) {
+ throw new ServletException("Must be POST, Can't be " + method);
+ }
}
/**
- * Checks jndi,environment, hudson environment and system properties for specified key.
- * Property is checked in direct order:
- * <ol>
- * <li>JNDI ({@link InitialContext#lookup(String)})</li>
- * <li>Hudson environment ({@link EnvVars#masterEnvVars})</li>
- * <li>System properties ({@link System#getProperty(String)})</li>
- * </ol>
+ * Checks jndi,environment, hudson environment and system properties for
+ * specified key. Property is checked in direct order: <ol> <li>JNDI
+ * ({@link InitialContext#lookup(String)})</li> <li>Hudson environment
+ * ({@link EnvVars#masterEnvVars})</li> <li>System properties
+ * ({@link System#getProperty(String)})</li> </ol>
+ *
* @param key - the name of the configured property.
- * @return the string value of the configured property, or null if there is no property with that key.
+ * @return the string value of the configured property, or null if there is
+ * no property with that key.
*/
protected String getConfiguredHudsonProperty(String key) {
if (StringUtils.isNotBlank(key)) {
diff --git a/hudson-core/src/main/java/hudson/model/AbstractProject.java b/hudson-core/src/main/java/hudson/model/AbstractProject.java
index f4ed61b..c9d0537 100644
--- a/hudson-core/src/main/java/hudson/model/AbstractProject.java
+++ b/hudson-core/src/main/java/hudson/model/AbstractProject.java
@@ -140,16 +140,19 @@ public abstract class AbstractProject<P extends AbstractProject<P, R>, R extends
public static final String SLAVE_KEY = "slave";
public static final String ASSIGNED_LABEL_KEY = "_.assignedLabelString";
/**
- * {@link SCM} associated with the project. To allow derived classes to link {@link SCM}
- * config to elsewhere, access to this variable should always go through {@link #getScm()}.
+ * {@link SCM} associated with the project. To allow derived classes to link
+ * {@link SCM} config to elsewhere, access to this variable should always go
+ * through {@link #getScm()}.
*
- * @deprecated as of 2.2.0 don't use this field directly, logic was moved to {@link org.eclipse.hudson.api.model.IProjectProperty}.
- * Use getter/setter for accessing to this field.
+ * @deprecated as of 2.2.0 don't use this field directly, logic was moved to
+ * {@link org.eclipse.hudson.api.model.IProjectProperty}. Use getter/setter
+ * for accessing to this field.
*/
@Deprecated
private volatile SCM scm = new NullSCM();
/**
- * State returned from {@link SCM#poll(AbstractProject, Launcher, FilePath, TaskListener, SCMRevisionState)}.
+ * State returned from
+ * {@link SCM#poll(AbstractProject, Launcher, FilePath, TaskListener, SCMRevisionState)}.
*/
private volatile transient SCMRevisionState pollingBaseline = null;
/**
@@ -161,8 +164,9 @@ public abstract class AbstractProject<P extends AbstractProject<P, R>, R extends
/**
* The quiet period. Null to delegate to the system default.
*
- * @deprecated as of 2.2.0 don't use this field directly, logic was moved to {@link org.eclipse.hudson.api.model.IProjectProperty}.
- * Use getter/setter for accessing to this field.
+ * @deprecated as of 2.2.0 don't use this field directly, logic was moved to
+ * {@link org.eclipse.hudson.api.model.IProjectProperty}. Use getter/setter
+ * for accessing to this field.
*
*/
@Deprecated
@@ -170,8 +174,9 @@ public abstract class AbstractProject<P extends AbstractProject<P, R>, R extends
/**
* The retry count. Null to delegate to the system default.
*
- * @deprecated as of 2.2.0 don't use this field directly, logic was moved to {@link org.eclipse.hudson.api.model.IProjectProperty}.
- * Use getter/setter for accessing to this field.
+ * @deprecated as of 2.2.0 don't use this field directly, logic was moved to
+ * {@link org.eclipse.hudson.api.model.IProjectProperty}. Use getter/setter
+ * for accessing to this field.
*/
@Deprecated
private volatile Integer scmCheckoutRetryCount = null;
@@ -185,7 +190,7 @@ public abstract class AbstractProject<P extends AbstractProject<P, R>, R extends
* @see #canRoam
*
* @deprecated as of 2.2.0 don't use this field directly, logic was moved to
- * {@link hudson.model.AbstractProject#getAppointedNode()#getName()}.
+ * {@link hudson.model.AbstractProject#getAppointedNode()#getName()}.
*/
@Deprecated
private String assignedNode;
@@ -193,7 +198,7 @@ public abstract class AbstractProject<P extends AbstractProject<P, R>, R extends
* Node list is dropdown or textfield
*
* @deprecated as of 2.2.0 don't use this field directly, logic was moved to
- * {@link hudson.model.AbstractProject#getAppointedNode()#isAdvancedAffinityChooser()}.
+ * {@link hudson.model.AbstractProject#getAppointedNode()#isAdvancedAffinityChooser()}.
*/
@Deprecated
private Boolean advancedAffinityChooser;
@@ -204,7 +209,7 @@ public abstract class AbstractProject<P extends AbstractProject<P, R>, R extends
* existing Hudson installations nicely.
*
* @deprecated as of 2.2.0 don't use this field directly, logic was moved to
- * {@link hudson.model.AbstractProject#getAppointedNode()#getCanRoam}.
+ * {@link hudson.model.AbstractProject#getAppointedNode()#getCanRoam}.
*/
@Deprecated
private volatile boolean canRoam;
@@ -236,12 +241,13 @@ public abstract class AbstractProject<P extends AbstractProject<P, R>, R extends
* Identifies {@link JDK} to be used. Null if no explicit configuration is
* required.
*
- * <p> Can't store {@link JDK} directly because {@link Hudson} and {@link Project}
- * are saved independently.
+ * <p> Can't store {@link JDK} directly because {@link Hudson} and
+ * {@link Project} are saved independently.
*
* @see Hudson#getJDK(String)
- * @deprecated as of 2.2.0 don't use this field directly, logic was moved to {@link org.eclipse.hudson.api.model.IProjectProperty}.
- * Use getter/setter for accessing to this field.
+ * @deprecated as of 2.2.0 don't use this field directly, logic was moved to
+ * {@link org.eclipse.hudson.api.model.IProjectProperty}. Use getter/setter
+ * for accessing to this field.
*/
@Deprecated
private volatile String jdk;
@@ -256,8 +262,9 @@ public abstract class AbstractProject<P extends AbstractProject<P, R>, R extends
*
* @deprecated as of 2.2.0
*
- * don't use this field directly, logic was moved to {@link org.eclipse.hudson.api.model.IProjectProperty}.
- * Use getter/setter for accessing to this field.
+ * don't use this field directly, logic was moved to
+ * {@link org.eclipse.hudson.api.model.IProjectProperty}. Use getter/setter
+ * for accessing to this field.
*/
protected List<Trigger<?>> triggers = new Vector<Trigger<?>>();
/**
@@ -271,16 +278,18 @@ public abstract class AbstractProject<P extends AbstractProject<P, R>, R extends
@CopyOnWrite
protected transient volatile List<Action> transientActions = new Vector<Action>();
/**
- * @deprecated as of 2.2.0 Don't use this field directly, logic was moved to {@link org.eclipse.hudson.api.model.IProjectProperty}.
- * Use getter/setter for accessing to this field.
+ * @deprecated as of 2.2.0 Don't use this field directly, logic was moved to
+ * {@link org.eclipse.hudson.api.model.IProjectProperty}. Use getter/setter
+ * for accessing to this field.
*/
@Deprecated
private boolean concurrentBuild;
/**
* True to clean the workspace prior to each build.
*
- * @deprecated as of 2.2.0 don't use this field directly, logic was moved to {@link org.eclipse.hudson.api.model.IProjectProperty}.
- * Use getter/setter for accessing to this field.
+ * @deprecated as of 2.2.0 don't use this field directly, logic was moved to
+ * {@link org.eclipse.hudson.api.model.IProjectProperty}. Use getter/setter
+ * for accessing to this field.
*/
@Deprecated
private volatile boolean cleanWorkspaceRequired;
@@ -315,7 +324,6 @@ public abstract class AbstractProject<P extends AbstractProject<P, R>, R extends
this.builds = new RunMap<R>();
this.builds.load(this, new Constructor<R>() {
-
public R create(File dir) throws IOException {
return loadBuild(dir);
}
@@ -498,7 +506,8 @@ public abstract class AbstractProject<P extends AbstractProject<P, R>, R extends
}
/**
- * Assigns this job to the given node. A convenience method over {@link #setAssignedLabel(Label)}.
+ * Assigns this job to the given node. A convenience method over
+ * {@link #setAssignedLabel(Label)}.
*
* @param node node.
* @throws java.io.IOException exception
@@ -554,8 +563,8 @@ public abstract class AbstractProject<P extends AbstractProject<P, R>, R extends
}
/**
- * Get the term used in the UI to represent this kind of {@link AbstractProject}.
- * Must start with a capital letter.
+ * Get the term used in the UI to represent this kind of
+ * {@link AbstractProject}. Must start with a capital letter.
*/
@Override
public String getPronoun() {
@@ -581,9 +590,9 @@ public abstract class AbstractProject<P extends AbstractProject<P, R>, R extends
* @return null if the workspace is on a slave that's not connected.
* @deprecated as of 1.319 To support concurrent builds of the same project,
* this method is moved to {@link AbstractBuild}. For backward
- * compatibility, this method returns the right {@link AbstractBuild#getWorkspace()}
- * if called from {@link Executor}, and otherwise the workspace of the last
- * build.
+ * compatibility, this method returns the right
+ * {@link AbstractBuild#getWorkspace()} if called from {@link Executor}, and
+ * otherwise the workspace of the last build.
*
* <p> If you are calling this method during a build from an executor,
* switch it to {@link AbstractBuild#getWorkspace()}. If you are calling
@@ -1456,15 +1465,14 @@ public abstract class AbstractProject<P extends AbstractProject<P, R>, R extends
* Useful for locking and mutual exclusion control.
*
* @deprecated as of 1.319 Projects no longer have a fixed workspace, ands
- * builds will find an available workspace via
- * {@link WorkspaceList} for each build (furthermore, that happens after a
- * build is started.) So a {@link Resource} representation for a workspace
- * at the project level no longer makes sense.
+ * builds will find an available workspace via {@link WorkspaceList} for
+ * each build (furthermore, that happens after a build is started.) So a
+ * {@link Resource} representation for a workspace at the project level no
+ * longer makes sense.
*
* <p> If you need to lock a workspace while you do some computation, see
- * the source code of
- * {@link #pollSCMChanges(TaskListener)} for how to obtain a lock of a
- * workspace through {@link WorkspaceList}.
+ * the source code of {@link #pollSCMChanges(TaskListener)} for how to
+ * obtain a lock of a workspace through {@link WorkspaceList}.
*/
public Resource getWorkspaceResource() {
return new Resource(getFullDisplayName() + " workspace");
@@ -2031,8 +2039,8 @@ public abstract class AbstractProject<P extends AbstractProject<P, R>, R extends
}
/**
- * @deprecated As of 1.261. Use {@link #buildDescribable(StaplerRequest, List)}
- * instead.
+ * @deprecated As of 1.261. Use
+ * {@link #buildDescribable(StaplerRequest, List)} instead.
*/
protected final <T extends Describable<T>> List<T> buildDescribable(StaplerRequest req, List<? extends Descriptor<T>> descriptors, String prefix) throws FormException, ServletException {
return buildDescribable(req, descriptors);
@@ -2163,7 +2171,6 @@ public abstract class AbstractProject<P extends AbstractProject<P, R>, R extends
getDisplayName() + ' ' + getScm().getDescriptor().getDisplayName() + " changes",
getUrl() + "changes",
entries, new FeedAdapter<FeedItem>() {
-
public String getEntryTitle(FeedItem item) {
return "#" + item.getBuild().number + ' ' + item.e.getMsg() + " (" + item.e.getAuthor() + ")";
}
@@ -2211,10 +2218,11 @@ public abstract class AbstractProject<P extends AbstractProject<P, R>, R extends
* given to the users.
*
* <p> Some {@link Descriptor}s define their own schemes for controlling
- * applicability (such as {@link BuildStepDescriptor#isApplicable(Class)}),
- * This method works like AND in conjunction with them; Both this method
- * and that method need to return true in order for a given {@link Descriptor}
- * to show up for the given {@link Project}.
+ * applicability (such as
+ * {@link BuildStepDescriptor#isApplicable(Class)}), This method works
+ * like AND in conjunction with them; Both this method and that method
+ * need to return true in order for a given {@link Descriptor} to show
+ * up for the given {@link Project}.
*
* <p> The default implementation returns true for everything.
*
@@ -2275,14 +2283,14 @@ public abstract class AbstractProject<P extends AbstractProject<P, R>, R extends
return (AbstractProject) Hudson.getInstance().getItem(nearest);
}
private static final Comparator<Integer> REVERSE_INTEGER_COMPARATOR = new Comparator<Integer>() {
-
public int compare(Integer o1, Integer o2) {
return o2 - o1;
}
};
private static final Logger LOGGER = Logger.getLogger(AbstractProject.class.getName());
/**
- * Permission to abort a build. For now, let's make it the same as {@link #BUILD}
+ * Permission to abort a build. For now, let's make it the same as
+ * {@link #BUILD}
*/
public static final Permission ABORT = BUILD;
diff --git a/hudson-core/src/main/java/hudson/model/AbstractStatusIcon.java b/hudson-core/src/main/java/hudson/model/AbstractStatusIcon.java
index f107883..de063c1 100644
--- a/hudson-core/src/main/java/hudson/model/AbstractStatusIcon.java
+++ b/hudson-core/src/main/java/hudson/model/AbstractStatusIcon.java
@@ -7,8 +7,8 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
- *
+ * Contributors:
+ *
*
*******************************************************************************/
@@ -35,7 +35,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
-
package hudson.model;
/**
diff --git a/hudson-core/src/main/java/hudson/model/Action.java b/hudson-core/src/main/java/hudson/model/Action.java
index 60955fa..7fa2925 100644
--- a/hudson-core/src/main/java/hudson/model/Action.java
+++ b/hudson-core/src/main/java/hudson/model/Action.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
-*
-* Kohsuke Kawaguchi, Michael B. Donohue
- *
+ * Contributors:
+ *
+ * Kohsuke Kawaguchi, Michael B. Donohue
+ *
*
*******************************************************************************/
@@ -19,53 +19,48 @@ package hudson.model;
import hudson.tasks.test.TestResultProjectAction;
/**
- * Object that contributes additional information, behaviors, and UIs to {@link ModelObject}
- * (more specifically {@link Actionable} objects, which most interesting {@link ModelObject}s are.)
+ * Object that contributes additional information, behaviors, and UIs to
+ * {@link ModelObject} (more specifically {@link Actionable} objects, which most
+ * interesting {@link ModelObject}s are.)
*
- * <p>
- * {@link Action}s added to a model object creates additional URL subspace under the parent model object,
- * through which it can interact with users. {@link Action}s are also capable of exposing themselves
- * to the left hand side menu of a {@link ModelObject} (for example to {@link Project}, {@link Build}, and etc.)
+ * <p> {@link Action}s added to a model object creates additional URL subspace
+ * under the parent model object, through which it can interact with users.
+ * {@link Action}s are also capable of exposing themselves to the left hand side
+ * menu of a {@link ModelObject} (for example to {@link Project}, {@link Build},
+ * and etc.)
*
- * <p>
- * Some actions use the latter without the former (for example, to add a link to an external website),
- * while others do the former without the latter (for example, to just draw some graphs in <tt>floatingBox.jelly</tt>),
- * and still some others do both.
+ * <p> Some actions use the latter without the former (for example, to add a
+ * link to an external website), while others do the former without the latter
+ * (for example, to just draw some graphs in <tt>floatingBox.jelly</tt>), and
+ * still some others do both.
*
- * <p>
- * If an action has a view named <tt>floatingBox.jelly</tt>,
- * it will be displayed as a floating box on the top page of
- * the target {@link ModelObject}. (For example, this is how
- * the JUnit test result trend shows up in the project top page.
- * See {@link TestResultProjectAction}.
+ * <p> If an action has a view named <tt>floatingBox.jelly</tt>, it will be
+ * displayed as a floating box on the top page of the target
+ * {@link ModelObject}. (For example, this is how the JUnit test result trend
+ * shows up in the project top page. See {@link TestResultProjectAction}.
*
- * <h2>Persistence</h2>
- * <p>
- * Actions are often persisted as a part of {@link Actionable}
- * (for example with {@link Build}) via XStream. In some other cases,
- * {@link Action}s are transient and not persisted (such as
- * when it's used with {@link Job}).
+ * <h2>Persistence</h2> <p> Actions are often persisted as a part of
+ * {@link Actionable} (for example with {@link Build}) via XStream. In some
+ * other cases, {@link Action}s are transient and not persisted (such as when
+ * it's used with {@link Job}).
*
* @author Kohsuke Kawaguchi
*/
public interface Action extends ModelObject {
+
/**
* Gets the file name of the icon.
*
- * @return
- * If just a file name (like "abc.png") is returned, it will be
- * interpreted as a file name inside <tt>/images/24x24</tt>.
- * This is useful for using one of the stock images.
- * <p>
- * If an absolute file name that starts from '/' is returned (like
- * "/plugin/foo/abc.png'), then it will be interpreted as a path
- * from the context root of Hudson. This is useful to pick up
- * image files from a plugin.
- * <p>
- * Finally, return null to hide it from the task list. This is normally not very useful,
- * but this can be used for actions that only contribute <tt>floatBox.jelly</tt>
- * and no task list item. The other case where this is useful is
- * to avoid showing links that require a privilege when the user is anonymous.
+ * @return If just a file name (like "abc.png") is returned, it will be
+ * interpreted as a file name inside <tt>/images/24x24</tt>. This is useful
+ * for using one of the stock images. <p> If an absolute file name that
+ * starts from '/' is returned (like "/plugin/foo/abc.png'), then it will be
+ * interpreted as a path from the context root of Hudson. This is useful to
+ * pick up image files from a plugin. <p> Finally, return null to hide it
+ * from the task list. This is normally not very useful, but this can be
+ * used for actions that only contribute <tt>floatBox.jelly</tt> and no task
+ * list item. The other case where this is useful is to avoid showing links
+ * that require a privilege when the user is anonymous.
* @see Hudson#isAdmin()
*/
String getIconFileName();
@@ -73,33 +68,30 @@ public interface Action extends ModelObject {
/**
* Gets the string to be displayed.
*
- * The convention is to capitalize the first letter of each word,
- * such as "Test Result".
+ * The convention is to capitalize the first letter of each word, such as
+ * "Test Result".
*/
String getDisplayName();
/**
* Gets the URL path name.
*
- * <p>
- * For example, if this method returns "xyz", and if the parent object
- * (that this action is associated with) is bound to /foo/bar/zot,
- * then this action object will be exposed to /foo/bar/zot/xyz.
+ * <p> For example, if this method returns "xyz", and if the parent object
+ * (that this action is associated with) is bound to /foo/bar/zot, then this
+ * action object will be exposed to /foo/bar/zot/xyz.
*
- * <p>
- * This method should return a string that's unique among other {@link Action}s.
+ * <p> This method should return a string that's unique among other
+ * {@link Action}s.
*
- * <p>
- * The returned string can be an absolute URL, like "http://www.sun.com/",
- * which is useful for directly connecting to external systems.
+ * <p> The returned string can be an absolute URL, like
+ * "http://www.sun.com/", which is useful for directly connecting to
+ * external systems.
*
- * <p>
- * If the returned string starts with '/', like '/foo', then it's assumed to be
- * relative to the context path of the Hudson webapp.
+ * <p> If the returned string starts with '/', like '/foo', then it's
+ * assumed to be relative to the context path of the Hudson webapp.
*
- * @return
- * null if this action object doesn't need to be bound to web
- * (when you do that, be sure to also return null from {@link #getIconFileName()}.
+ * @return null if this action object doesn't need to be bound to web (when
+ * you do that, be sure to also return null from {@link #getIconFileName()}.
*/
String getUrlName();
}
diff --git a/hudson-core/src/main/java/hudson/model/Actionable.java b/hudson-core/src/main/java/hudson/model/Actionable.java
index 9940d08..e1339c7 100644
--- a/hudson-core/src/main/java/hudson/model/Actionable.java
+++ b/hudson-core/src/main/java/hudson/model/Actionable.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
-*
-* Kohsuke Kawaguchi, Stephen Connolly
- *
+ * Contributors:
+ *
+ * Kohsuke Kawaguchi, Stephen Connolly
+ *
*
*******************************************************************************/
@@ -32,26 +32,27 @@ import java.util.concurrent.CopyOnWriteArrayList;
*/
@ExportedBean
public abstract class Actionable extends AbstractModelObject {
+
/**
* Actions contributed to this model object.
*
- * Typed more strongly than it should to improve the serialization signature.
+ * Typed more strongly than it should to improve the serialization
+ * signature.
*/
private volatile CopyOnWriteArrayList<Action> actions;
/**
* Gets actions contributed to this build.
*
- * <p>
- * A new {@link Action} can be added by {@code getActions().add(...)}.
+ * <p> A new {@link Action} can be added by {@code getActions().add(...)}.
*
- * @return
- * may be empty but never null.
+ * @return may be empty but never null.
*/
@Exported
public synchronized List<Action> getActions() {
- if(actions==null)
+ if (actions == null) {
actions = new CopyOnWriteArrayList<Action>();
+ }
return actions;
}
@@ -59,15 +60,16 @@ public abstract class Actionable extends AbstractModelObject {
* Gets all actions of a specified type that contributed to this build.
*
* @param type The type of action to return.
- * @return
- * may be empty but never null.
+ * @return may be empty but never null.
* @see #getAction(Class)
*/
public <T extends Action> List<T> getActions(Class<T> type) {
List<T> result = new Vector<T>();
- for (Action a : getActions())
- if (type.isInstance(a))
+ for (Action a : getActions()) {
+ if (type.isInstance(a)) {
result.add(type.cast(a));
+ }
+ }
return result;
}
@@ -77,38 +79,48 @@ public abstract class Actionable extends AbstractModelObject {
* Short for <tt>getActions().add(a)</tt>
*/
public void addAction(Action a) {
- if(a==null) throw new IllegalArgumentException();
+ if (a == null) {
+ throw new IllegalArgumentException();
+ }
getActions().add(a);
}
public Action getAction(int index) {
- if(actions==null) return null;
+ if (actions == null) {
+ return null;
+ }
return actions.get(index);
}
/**
- * Gets the action (first instance to be found) of a specified type that contributed to this build.
+ * Gets the action (first instance to be found) of a specified type that
+ * contributed to this build.
*
* @param type
* @return The action or <code>null</code> if no such actions exist.
* @see #getActions(Class)
*/
public <T extends Action> T getAction(Class<T> type) {
- for (Action a : getActions())
- if (type.isInstance(a))
+ for (Action a : getActions()) {
+ if (type.isInstance(a)) {
return type.cast(a);
+ }
+ }
return null;
}
public Object getDynamic(String token, StaplerRequest req, StaplerResponse rsp) {
for (Action a : getActions()) {
- if(a==null)
+ if (a == null) {
continue; // be defensive
+ }
String urlName = a.getUrlName();
- if(urlName==null)
+ if (urlName == null) {
continue;
- if(urlName.equals(token))
+ }
+ if (urlName.equals(token)) {
return a;
+ }
}
return null;
}
diff --git a/hudson-core/src/main/java/hudson/model/AdministrativeMonitor.java b/hudson-core/src/main/java/hudson/model/AdministrativeMonitor.java
index ebb6513..94f0506 100644
--- a/hudson-core/src/main/java/hudson/model/AdministrativeMonitor.java
+++ b/hudson-core/src/main/java/hudson/model/AdministrativeMonitor.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
-*
+ * Contributors:
+ *
* Kohsuke Kawaguchi
- *
+ *
*
*******************************************************************************/
@@ -30,37 +30,29 @@ import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
/**
- * Checks the health of a subsystem of Hudson and if there's something
- * that requires administrator's attention, notify the administrator.
+ * Checks the health of a subsystem of Hudson and if there's something that
+ * requires administrator's attention, notify the administrator.
*
- * <h2>How to implement?</h2>
- * <p>
- * Plugins who wish to contribute such notifications can implement this
- * class and put {@link Extension} on it to register it to Hudson.
+ * <h2>How to implement?</h2> <p> Plugins who wish to contribute such
+ * notifications can implement this class and put {@link Extension} on it to
+ * register it to Hudson.
*
- * <p>
- * Once installed, it's the implementor's responsibility to perform
- * monitoring and activate/deactivate the monitor accordingly. Sometimes
- * this can be done by updating a flag from code (see {@link SCMTrigger}
- * for one such example), while other times it's more convenient to do
- * so by running some code periodically (for this, use {@link TimerTrigger#timer})
+ * <p> Once installed, it's the implementor's responsibility to perform
+ * monitoring and activate/deactivate the monitor accordingly. Sometimes this
+ * can be done by updating a flag from code (see {@link SCMTrigger} for one such
+ * example), while other times it's more convenient to do so by running some
+ * code periodically (for this, use {@link TimerTrigger#timer})
*
- * <p>
- * {@link AdministrativeMonitor}s are bound to URL by {@link Hudson#getAdministrativeMonitor(String)}.
- * See {@link #getUrl()}.
+ * <p> {@link AdministrativeMonitor}s are bound to URL by
+ * {@link Hudson#getAdministrativeMonitor(String)}. See {@link #getUrl()}.
*
- * <h3>Views</h3>
- * <dl>
- * <dt>message.jelly</dt>
- * <dd>
- * If {@link #isActivated()} returns true, Hudson will use the <tt>message.jelly</tt>
- * view of this object to render the warning text. This happens in the
+ * <h3>Views</h3> <dl> <dt>message.jelly</dt> <dd> If {@link #isActivated()}
+ * returns true, Hudson will use the <tt>message.jelly</tt> view of this object
+ * to render the warning text. This happens in the
* <tt>http://SERVER/hudson/manage</tt> page. This view should typically render
* a DIV box with class='error' or class='warning' with a human-readable text
* inside it. It often also contains a link to a page that provides more details
- * about the problem.
- * </dd>
- * </dl>
+ * about the problem. </dd> </dl>
*
* @author Kohsuke Kawaguchi
* @since 1.273
@@ -68,12 +60,13 @@ import org.kohsuke.stapler.StaplerResponse;
*/
@LegacyInstancesAreScopedToHudson
public abstract class AdministrativeMonitor extends AbstractModelObject implements ExtensionPoint {
+
/**
- * Human-readable ID of this monitor, which needs to be unique within the system.
+ * Human-readable ID of this monitor, which needs to be unique within the
+ * system.
*
- * <p>
- * This ID is used to remember persisted setting for this monitor,
- * so the ID should remain consistent beyond the Hudson JVM lifespan.
+ * <p> This ID is used to remember persisted setting for this monitor, so
+ * the ID should remain consistent beyond the Hudson JVM lifespan.
*/
public final String id;
@@ -86,10 +79,11 @@ public abstract class AdministrativeMonitor extends AbstractModelObject implemen
}
/**
- * Returns the URL of this monitor, relative to the context path, like "administrativeMonitor/foobar".
+ * Returns the URL of this monitor, relative to the context path, like
+ * "administrativeMonitor/foobar".
*/
public String getUrl() {
- return "administrativeMonitor/"+id;
+ return "administrativeMonitor/" + id;
}
public String getDisplayName() {
@@ -106,29 +100,31 @@ public abstract class AdministrativeMonitor extends AbstractModelObject implemen
public void disable(boolean value) throws IOException {
Hudson hudson = Hudson.getInstance();
Set<String> set = hudson.disabledAdministrativeMonitors;
- if(value) set.add(id);
- else set.remove(id);
+ if (value) {
+ set.add(id);
+ } else {
+ set.remove(id);
+ }
hudson.save();
}
/**
- * Returns true if this monitor {@link #disable(boolean) isn't disabled} earlier.
+ * Returns true if this monitor {@link #disable(boolean) isn't disabled}
+ * earlier.
*
- * <p>
- * This flag implements the ability for the admin to say "no thank you" to the monitor that
- * he wants to ignore.
+ * <p> This flag implements the ability for the admin to say "no thank you"
+ * to the monitor that he wants to ignore.
*/
public boolean isEnabled() {
return !Hudson.getInstance().disabledAdministrativeMonitors.contains(id);
}
/**
- * Returns true if this monitor is activated and
- * wants to produce a warning message.
+ * Returns true if this monitor is activated and wants to produce a warning
+ * message.
*
- * <p>
- * This method is called from the HTML rendering thread,
- * so it should run efficiently.
+ * <p> This method is called from the HTML rendering thread, so it should
+ * run efficiently.
*/
public abstract boolean isActivated();
@@ -138,7 +134,7 @@ public abstract class AdministrativeMonitor extends AbstractModelObject implemen
public void doDisable(StaplerRequest req, StaplerResponse rsp) throws IOException {
Hudson.getInstance().checkPermission(Hudson.ADMINISTER);
disable(true);
- rsp.sendRedirect2(req.getContextPath()+"/manage");
+ rsp.sendRedirect2(req.getContextPath() + "/manage");
}
/**
diff --git a/hudson-core/src/main/java/hudson/model/AllView.java b/hudson-core/src/main/java/hudson/model/AllView.java
index 255dfd3..b426975 100644
--- a/hudson-core/src/main/java/hudson/model/AllView.java
+++ b/hudson-core/src/main/java/hudson/model/AllView.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
-*
-* Kohsuke Kawaguchi, Tom Huybrechts
- *
+ * Contributors:
+ *
+ * Kohsuke Kawaguchi, Tom Huybrechts
+ *
*
*******************************************************************************/
@@ -35,6 +35,7 @@ import hudson.Extension;
* @since 1.269
*/
public class AllView extends View {
+
@DataBoundConstructor
public AllView(String name) {
super(name);
@@ -44,7 +45,7 @@ public class AllView extends View {
this(name);
this.owner = owner;
}
-
+
@Override
public String getDescription() {
return Hudson.getInstance().getDescription();
@@ -72,7 +73,7 @@ public class AllView extends View {
}
@Override
- public synchronized void doSubmitDescription( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException {
+ public synchronized void doSubmitDescription(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
checkPermission(Hudson.ADMINISTER);
Hudson.getInstance().setSystemMessage(req.getParameter("description"));
@@ -96,11 +97,14 @@ public class AllView extends View {
@Extension
public static final class DescriptorImpl extends ViewDescriptor {
+
@Override
public boolean isInstantiable() {
- for (View v : Stapler.getCurrentRequest().findAncestorObject(ViewGroup.class).getViews())
- if(v instanceof AllView)
+ for (View v : Stapler.getCurrentRequest().findAncestorObject(ViewGroup.class).getViews()) {
+ if (v instanceof AllView) {
return false;
+ }
+ }
return true;
}
diff --git a/hudson-core/src/main/java/hudson/model/Api.java b/hudson-core/src/main/java/hudson/model/Api.java
index efd1a8f..c10ae1b 100644
--- a/hudson-core/src/main/java/hudson/model/Api.java
+++ b/hudson-core/src/main/java/hudson/model/Api.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
*
* Kohsuke Kawaguchi, Seiji Sogabe
- *
+ *
*
*******************************************************************************/
@@ -41,14 +41,14 @@ import java.util.List;
/**
* Used to expose remote access API for ".../api/"
*
- * <p>
- * If the parent object has a <tt>_api.jelly</tt> view, it will be included
+ * <p> If the parent object has a <tt>_api.jelly</tt> view, it will be included
* in the api index page.
*
* @author Kohsuke Kawaguchi
* @see Exported
*/
public class Api extends AbstractModelObject {
+
/**
* Model object to be exposed as XML/JSON/etc.
*/
@@ -68,22 +68,21 @@ public class Api extends AbstractModelObject {
}
public Object getBean() {
- return bean;
+ return bean;
}
-
/**
* Exposes the bean as XML.
*/
public void doXml(StaplerRequest req, StaplerResponse rsp,
- @QueryParameter String xpath,
- @QueryParameter String wrapper,
- @QueryParameter int depth) throws IOException, ServletException {
+ @QueryParameter String xpath,
+ @QueryParameter String wrapper,
+ @QueryParameter int depth) throws IOException, ServletException {
String[] excludes = req.getParameterValues("exclude");
- if(xpath==null && excludes==null) {
+ if (xpath == null && excludes == null) {
// serve the whole thing
- rsp.serveExposedBean(req,bean,Flavor.XML);
+ rsp.serveExposedBean(req, bean, Flavor.XML);
return;
}
@@ -91,7 +90,7 @@ public class Api extends AbstractModelObject {
// first write to String
Model p = MODEL_BUILDER.get(bean.getClass());
- p.writeTo(bean,depth,Flavor.XML.createDataWriter(bean,sw));
+ p.writeTo(bean, depth, Flavor.XML.createDataWriter(bean, sw));
// apply XPath
Object result;
@@ -99,28 +98,29 @@ public class Api extends AbstractModelObject {
Document dom = new SAXReader().read(new StringReader(sw.toString()));
// apply exclusions
- if (excludes!=null) {
+ if (excludes != null) {
for (String exclude : excludes) {
- List<org.dom4j.Node> list = (List<org.dom4j.Node>)dom.selectNodes(exclude);
+ List<org.dom4j.Node> list = (List<org.dom4j.Node>) dom.selectNodes(exclude);
for (org.dom4j.Node n : list) {
Element parent = n.getParent();
- if(parent!=null)
+ if (parent != null) {
parent.remove(n);
+ }
}
}
}
-
- if(xpath==null) {
- result = dom;
+
+ if (xpath == null) {
+ result = dom;
} else {
List list = dom.selectNodes(xpath);
- if (wrapper!=null) {
+ if (wrapper != null) {
Element root = DocumentFactory.getInstance().createElement(wrapper);
for (Object o : list) {
if (o instanceof String) {
root.addText(o.toString());
} else {
- root.add(((org.dom4j.Node)o).detach());
+ root.add(((org.dom4j.Node) o).detach());
}
}
result = root;
@@ -130,7 +130,7 @@ public class Api extends AbstractModelObject {
return;
} else if (list.size() > 1) {
rsp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
- rsp.getWriter().print(Messages.Api_MultipleMatch(xpath,list.size()));
+ rsp.getWriter().print(Messages.Api_MultipleMatch(xpath, list.size()));
return;
} else {
result = list.get(0);
@@ -143,13 +143,13 @@ public class Api extends AbstractModelObject {
OutputStream o = rsp.getCompressedOutputStream(req);
try {
- if(result instanceof CharacterData) {
+ if (result instanceof CharacterData) {
rsp.setContentType("text/plain;charset=UTF-8");
- o.write(((CharacterData)result).getText().getBytes("UTF-8"));
+ o.write(((CharacterData) result).getText().getBytes("UTF-8"));
return;
}
- if(result instanceof String || result instanceof Number || result instanceof Boolean) {
+ if (result instanceof String || result instanceof Number || result instanceof Boolean) {
rsp.setContentType("text/plain;charset=UTF-8");
o.write(result.toString().getBytes("UTF-8"));
return;
@@ -177,8 +177,7 @@ public class Api extends AbstractModelObject {
* Exposes the bean as JSON.
*/
public void doJson(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
- rsp.serveExposedBean(req,bean, Flavor.JSON);
+ rsp.serveExposedBean(req, bean, Flavor.JSON);
}
-
private static final ModelBuilder MODEL_BUILDER = new ModelBuilder();
}
diff --git a/hudson-core/src/main/java/hudson/model/AppointedNode.java b/hudson-core/src/main/java/hudson/model/AppointedNode.java
index 49f44c8..41926e6 100644
--- a/hudson-core/src/main/java/hudson/model/AppointedNode.java
+++ b/hudson-core/src/main/java/hudson/model/AppointedNode.java
@@ -29,16 +29,14 @@ import org.apache.commons.lang3.builder.HashCodeBuilder;
public class AppointedNode implements Serializable {
/**
- * If this project is configured to be only built on a certain label,
- * this value will be set to that label.
+ * If this project is configured to be only built on a certain label, this
+ * value will be set to that label.
*/
private String nodeName;
-
/**
* Node list dropdown or textfield.
*/
private Boolean advancedAffinityChooser;
-
/**
* True if this project can be built on any node.
*/
@@ -84,8 +82,8 @@ public class AppointedNode implements Serializable {
}
/**
- * Sets true if the node configured with advanced label expression
- * and false if with combobox.
+ * Sets true if the node configured with advanced label expression and false
+ * if with combobox.
*
* @param advancedAffinityChooser boolean.
*/
@@ -94,8 +92,8 @@ public class AppointedNode implements Serializable {
}
/**
- * If this project is configured to be always built on this node,
- * return that {@link Node}. Otherwise null.
+ * If this project is configured to be always built on this node, return
+ * that {@link Node}. Otherwise null.
*
* @return assigned label
*/
@@ -110,7 +108,8 @@ public class AppointedNode implements Serializable {
}
/**
- * Gets the textual representation of the assigned label as it was entered by the user.
+ * Gets the textual representation of the assigned label as it was entered
+ * by the user.
*
* @return assigned label as string
*/
@@ -142,7 +141,6 @@ public class AppointedNode implements Serializable {
}
}
-
@Override
public boolean equals(Object o) {
if (this == o) {
@@ -153,16 +151,16 @@ public class AppointedNode implements Serializable {
}
AppointedNode that = (AppointedNode) o;
return new EqualsBuilder()
- .append(advancedAffinityChooser, that.advancedAffinityChooser)
- .append(nodeName, that.nodeName)
- .isEquals();
+ .append(advancedAffinityChooser, that.advancedAffinityChooser)
+ .append(nodeName, that.nodeName)
+ .isEquals();
}
@Override
public int hashCode() {
return new HashCodeBuilder()
- .append(advancedAffinityChooser)
- .append(nodeName)
- .toHashCode();
+ .append(advancedAffinityChooser)
+ .append(nodeName)
+ .toHashCode();
}
}
diff --git a/hudson-core/src/main/java/hudson/model/AsyncPeriodicWork.java b/hudson-core/src/main/java/hudson/model/AsyncPeriodicWork.java
index f918eb0..067e076 100644
--- a/hudson-core/src/main/java/hudson/model/AsyncPeriodicWork.java
+++ b/hudson-core/src/main/java/hudson/model/AsyncPeriodicWork.java
@@ -8,9 +8,9 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- *
+ *
* Kohsuke Kawaguchi, Winston Prakash
- *
+ *
*******************************************************************************/
package hudson.model;
@@ -25,19 +25,18 @@ import org.eclipse.hudson.security.HudsonSecurityManager;
/**
* {@link PeriodicWork} that takes a long time to run.
*
- * <p>
- * Subclasses will implement the {@link #execute(TaskListener)} method and can carry out a long-running task.
- * This runs in a separate thread so as not to block the timer thread, and this class handles
- * all those details.
+ * <p> Subclasses will implement the {@link #execute(TaskListener)} method and
+ * can carry out a long-running task. This runs in a separate thread so as not
+ * to block the timer thread, and this class handles all those details.
*
* @author Kohsuke Kawaguchi
*/
public abstract class AsyncPeriodicWork extends PeriodicWork {
+
/**
* Name of the work.
*/
public final String name;
-
private Thread thread;
protected AsyncPeriodicWork(String name) {
@@ -45,23 +44,24 @@ public abstract class AsyncPeriodicWork extends PeriodicWork {
}
/**
- * Schedules this periodic work now in a new thread, if one isn't already running.
+ * Schedules this periodic work now in a new thread, if one isn't already
+ * running.
*/
public final void doRun() {
try {
- if(thread!=null && thread.isAlive()) {
- logger.log(Level.INFO, name+" thread is still running. Execution aborted.");
+ if (thread != null && thread.isAlive()) {
+ logger.log(Level.INFO, name + " thread is still running. Execution aborted.");
return;
}
thread = new Thread(new Runnable() {
public void run() {
- logger.log(Level.INFO, "Started "+name);
+ logger.log(Level.INFO, "Started " + name);
long startTime = System.currentTimeMillis();
StreamTaskListener l = createListener();
try {
HudsonSecurityManager.grantFullControl();
-
+
execute(l);
} catch (IOException e) {
e.printStackTrace(l.fatalError(e.getMessage()));
@@ -71,13 +71,13 @@ public abstract class AsyncPeriodicWork extends PeriodicWork {
l.closeQuietly();
}
- logger.log(Level.INFO, "Finished "+name+". "+
- (System.currentTimeMillis()-startTime)+" ms");
+ logger.log(Level.INFO, "Finished " + name + ". "
+ + (System.currentTimeMillis() - startTime) + " ms");
}
- },name+" thread");
+ }, name + " thread");
thread.start();
} catch (Throwable t) {
- logger.log(Level.SEVERE, name+" thread failed with error", t);
+ logger.log(Level.SEVERE, name + " thread failed with error", t);
}
}
@@ -93,18 +93,17 @@ public abstract class AsyncPeriodicWork extends PeriodicWork {
* Determines the log file that records the result of this task.
*/
protected File getLogFile() {
- return new File(Hudson.getInstance().getRootDir(),name+".log");
+ return new File(Hudson.getInstance().getRootDir(), name + ".log");
}
/**
* Executes the task.
*
- * @param listener
- * Output sent will be reported to the users. (this work is TBD.)
- * @throws InterruptedException
- * The caller will record the exception and moves on.
- * @throws IOException
- * The caller will record the exception and moves on.
+ * @param listener Output sent will be reported to the users. (this work is
+ * TBD.)
+ * @throws InterruptedException The caller will record the exception and
+ * moves on.
+ * @throws IOException The caller will record the exception and moves on.
*/
protected abstract void execute(TaskListener listener) throws IOException, InterruptedException;
}
diff --git a/hudson-core/src/main/java/hudson/model/AutoCompletionCandidates.java b/hudson-core/src/main/java/hudson/model/AutoCompletionCandidates.java
index 5898257..3610ce0 100644
--- a/hudson-core/src/main/java/hudson/model/AutoCompletionCandidates.java
+++ b/hudson-core/src/main/java/hudson/model/AutoCompletionCandidates.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -29,13 +29,13 @@ import java.util.Arrays;
import java.util.List;
/**
- * Data representation of the auto-completion candidates.
- * <p>
- * This object should be returned from your doAutoCompleteXYZ methods.
+ * Data representation of the auto-completion candidates. <p> This object should
+ * be returned from your doAutoCompleteXYZ methods.
*
* @author Kohsuke Kawaguchi
*/
public class AutoCompletionCandidates implements HttpResponse {
+
private final List<String> values = new ArrayList<String>();
public AutoCompletionCandidates add(String v) {
@@ -53,6 +53,6 @@ public class AutoCompletionCandidates implements HttpResponse {
for (String value : values) {
r.suggestions.add(new hudson.search.Search.Item(value));
}
- rsp.serveExposedBean(req,r, Flavor.JSON);
+ rsp.serveExposedBean(req, r, Flavor.JSON);
}
}
diff --git a/hudson-core/src/main/java/hudson/model/BallColor.java b/hudson-core/src/main/java/hudson/model/BallColor.java
index d55c768..3a2c0d8 100644
--- a/hudson-core/src/main/java/hudson/model/BallColor.java
+++ b/hudson-core/src/main/java/hudson/model/BallColor.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
-*
-* Kohsuke Kawaguchi, Simon Wiest
- *
+ * Contributors:
+ *
+ * Kohsuke Kawaguchi, Simon Wiest
+ *
*
*******************************************************************************/
@@ -28,40 +28,35 @@ import java.util.Locale;
/**
* Ball color used for the build status indication.
*
- * <p>
- * There are four basic colors, plus their animated "bouncy" versions.
- * {@link #ordinal()} is the sort order.
+ * <p> There are four basic colors, plus their animated "bouncy" versions.
+ * {@link #ordinal()} is the sort order.
*
- * <p>
- * Note that multiple {@link BallColor} instances may map to the same
- * RGB color, to avoid the rainbow effect.
+ * <p> Note that multiple {@link BallColor} instances may map to the same RGB
+ * color, to avoid the rainbow effect.
*
- * <h2>Historical Note</h2>
- * <p>
- * Hudson started to overload colors &mdash; for example grey could mean
- * either disabled, aborted, or not yet built. As a result, {@link BallColor}
- * becomes more like a "logical" color, in the sense that different {@link BallColor}
- * values can map to the same RGB color. See issue #956.
+ * <h2>Historical Note</h2> <p> Hudson started to overload colors &mdash; for
+ * example grey could mean either disabled, aborted, or not yet built. As a
+ * result, {@link BallColor} becomes more like a "logical" color, in the sense
+ * that different {@link BallColor} values can map to the same RGB color. See
+ * issue #956.
*
* @author Kohsuke Kawaguchi
*/
public enum BallColor implements StatusIcon {
- RED("red",Messages._BallColor_Failed(), ColorPalette.RED),
- RED_ANIME("red_anime",Messages._BallColor_InProgress(), ColorPalette.RED),
- YELLOW("yellow",Messages._BallColor_Unstable(), ColorPalette.YELLOW),
- YELLOW_ANIME("yellow_anime",Messages._BallColor_InProgress(), ColorPalette.YELLOW),
- BLUE("blue",Messages._BallColor_Success(), ColorPalette.BLUE),
- BLUE_ANIME("blue_anime",Messages._BallColor_InProgress(), ColorPalette.BLUE),
- // for historical reasons they are called grey.
- GREY("grey",Messages._BallColor_Pending(), ColorPalette.GREY),
- GREY_ANIME("grey_anime",Messages._BallColor_InProgress(), ColorPalette.GREY),
-
- DISABLED("grey",Messages._BallColor_Disabled(), ColorPalette.GREY),
- DISABLED_ANIME("grey_anime",Messages._BallColor_InProgress(), ColorPalette.GREY),
- ABORTED("grey",Messages._BallColor_Aborted(), ColorPalette.GREY),
- ABORTED_ANIME("grey_anime",Messages._BallColor_InProgress(), ColorPalette.GREY),
- ;
+ RED("red", Messages._BallColor_Failed(), ColorPalette.RED),
+ RED_ANIME("red_anime", Messages._BallColor_InProgress(), ColorPalette.RED),
+ YELLOW("yellow", Messages._BallColor_Unstable(), ColorPalette.YELLOW),
+ YELLOW_ANIME("yellow_anime", Messages._BallColor_InProgress(), ColorPalette.YELLOW),
+ BLUE("blue", Messages._BallColor_Success(), ColorPalette.BLUE),
+ BLUE_ANIME("blue_anime", Messages._BallColor_InProgress(), ColorPalette.BLUE),
+ // for historical reasons they are called grey.
+ GREY("grey", Messages._BallColor_Pending(), ColorPalette.GREY),
+ GREY_ANIME("grey_anime", Messages._BallColor_InProgress(), ColorPalette.GREY),
+ DISABLED("grey", Messages._BallColor_Disabled(), ColorPalette.GREY),
+ DISABLED_ANIME("grey_anime", Messages._BallColor_InProgress(), ColorPalette.GREY),
+ ABORTED("grey", Messages._BallColor_Aborted(), ColorPalette.GREY),
+ ABORTED_ANIME("grey_anime", Messages._BallColor_InProgress(), ColorPalette.GREY),;
private final Localizable description;
private final String image;
private final Color baseColor;
@@ -70,7 +65,7 @@ public enum BallColor implements StatusIcon {
this.baseColor = baseColor;
// name() is not usable in the constructor, so I have to repeat the name twice
// in the constants definition.
- this.image = image+ (image.endsWith("_anime")?".gif":".png");
+ this.image = image + (image.endsWith("_anime") ? ".gif" : ".png");
this.description = description;
}
@@ -82,18 +77,21 @@ public enum BallColor implements StatusIcon {
}
public String getImageOf(String size) {
- return Stapler.getCurrentRequest().getContextPath()+Hudson.RESOURCE_PATH+"/images/"+size+'/'+image;
+ return Stapler.getCurrentRequest().getContextPath() + Hudson.RESOURCE_PATH + "/images/" + size + '/' + image;
}
/**
- * Gets the human-readable description used as img/@alt.
+ * Gets the human-readable description used as img/
+ *
+ * @alt.
*/
public String getDescription() {
return description.toString(LocaleProvider.getLocale());
}
/**
- * Gets the RGB color of this color. Animation effect is not reflected to this value.
+ * Gets the RGB color of this color. Animation effect is not reflected to
+ * this value.
*/
public Color getBaseColor() {
return baseColor;
@@ -103,7 +101,7 @@ public enum BallColor implements StatusIcon {
* Returns the {@link #getBaseColor()} in the "#RRGGBB" format.
*/
public String getHtmlBaseColor() {
- return String.format("#%06X",baseColor.getRGB()&0xFFFFFF);
+ return String.format("#%06X", baseColor.getRGB() & 0xFFFFFF);
}
/**
@@ -118,16 +116,22 @@ public enum BallColor implements StatusIcon {
* Gets the animated version.
*/
public BallColor anime() {
- if(isAnimated()) return this;
- else return valueOf(name()+"_ANIME");
+ if (isAnimated()) {
+ return this;
+ } else {
+ return valueOf(name() + "_ANIME");
+ }
}
/**
* Gets the unanimated version.
*/
public BallColor noAnime() {
- if(isAnimated()) return valueOf(name().substring(0,name().length()-6));
- else return this;
+ if (isAnimated()) {
+ return valueOf(name().substring(0, name().length() - 6));
+ } else {
+ return this;
+ }
}
/**
diff --git a/hudson-core/src/main/java/hudson/model/BaseBuildableProject.java b/hudson-core/src/main/java/hudson/model/BaseBuildableProject.java
index 5ce3761..ab913c3 100644
--- a/hudson-core/src/main/java/hudson/model/BaseBuildableProject.java
+++ b/hudson-core/src/main/java/hudson/model/BaseBuildableProject.java
@@ -40,47 +40,45 @@ import org.kohsuke.stapler.StaplerResponse;
*
* @author Anton Kozak.
*/
-public abstract class BaseBuildableProject<P extends BaseBuildableProject<P,B>,B extends AbstractBuild<P,B>>
- extends AbstractProject<P, B>
- implements Saveable, BuildableItemWithBuildWrappers, IBaseBuildableProject {
+public abstract class BaseBuildableProject<P extends BaseBuildableProject<P, B>, B extends AbstractBuild<P, B>>
+ extends AbstractProject<P, B>
+ implements Saveable, BuildableItemWithBuildWrappers, IBaseBuildableProject {
public static final String BUILDERS_PROPERTY_NAME = "builders";
-
/**
* List of active {@link Builder}s configured for this project.
*
- * @deprecated as of 2.2.0
- * don't use this field directly, logic was moved to {@link org.eclipse.hudson.api.model.IProjectProperty}.
- * Use getter/setter for accessing to this field.
+ * @deprecated as of 2.2.0 don't use this field directly, logic was moved to
+ * {@link org.eclipse.hudson.api.model.IProjectProperty}. Use getter/setter
+ * for accessing to this field.
*/
@Deprecated
- private DescribableList<Builder,Descriptor<Builder>> builders =
- new DescribableList<Builder,Descriptor<Builder>>(this);
-
+ private DescribableList<Builder, Descriptor<Builder>> builders =
+ new DescribableList<Builder, Descriptor<Builder>>(this);
/**
* List of active {@link Publisher}s configured for this project.
*
- * @deprecated as of 2.2.0
- * don't use this field directly, logic was moved to {@link org.eclipse.hudson.api.model.IProjectProperty}.
- * Use getter/setter for accessing to this field.
+ * @deprecated as of 2.2.0 don't use this field directly, logic was moved to
+ * {@link org.eclipse.hudson.api.model.IProjectProperty}. Use getter/setter
+ * for accessing to this field.
*/
@Deprecated
- private DescribableList<Publisher,Descriptor<Publisher>> publishers =
- new DescribableList<Publisher,Descriptor<Publisher>>(this);
-
+ private DescribableList<Publisher, Descriptor<Publisher>> publishers =
+ new DescribableList<Publisher, Descriptor<Publisher>>(this);
/**
* List of active {@link BuildWrapper}s configured for this project.
*
- * @deprecated as of 2.2.0
- * don't use this field directly, logic was moved to {@link org.eclipse.hudson.api.model.IProjectProperty}.
- * Use getter/setter for accessing to this field.
+ * @deprecated as of 2.2.0 don't use this field directly, logic was moved to
+ * {@link org.eclipse.hudson.api.model.IProjectProperty}. Use getter/setter
+ * for accessing to this field.
*/
@Deprecated
- private DescribableList<BuildWrapper,Descriptor<BuildWrapper>> buildWrappers =
- new DescribableList<BuildWrapper,Descriptor<BuildWrapper>>(this);
+ private DescribableList<BuildWrapper, Descriptor<BuildWrapper>> buildWrappers =
+ new DescribableList<BuildWrapper, Descriptor<BuildWrapper>>(this);
/**
* Creates a new project.
+ *
* @param parent parent {@link ItemGroup}.
* @param name the name of the project.
*/
@@ -106,14 +104,14 @@ public abstract class BaseBuildableProject<P extends BaseBuildableProject<P,B>,B
}
protected void buildDependencyGraph(DependencyGraph graph) {
- getPublishersList().buildDependencyGraph(this,graph);
- getBuildersList().buildDependencyGraph(this,graph);
- getBuildWrappersList().buildDependencyGraph(this,graph);
+ getPublishersList().buildDependencyGraph(this, graph);
+ getBuildersList().buildDependencyGraph(this, graph);
+ getBuildWrappersList().buildDependencyGraph(this, graph);
}
@Override
- protected void submit( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException, FormException {
- super.submit(req,rsp);
+ protected void submit(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException, FormException {
+ super.submit(req, rsp);
JSONObject json = req.getSubmittedForm();
buildBuildWrappers(req, json, BuildWrappers.getFor(this));
setBuilders(DescribableListUtil.buildFromHetero(this, req, json, "builder", Builder.all()));
@@ -125,14 +123,18 @@ public abstract class BaseBuildableProject<P extends BaseBuildableProject<P,B>,B
protected List<Action> createTransientActions() {
List<Action> r = super.createTransientActions();
- for (BuildStep step : getBuildersList())
+ for (BuildStep step : getBuildersList()) {
r.addAll(step.getProjectActions(this));
- for (BuildStep step : getPublishersList())
+ }
+ for (BuildStep step : getPublishersList()) {
r.addAll(step.getProjectActions(this));
- for (BuildWrapper step : getBuildWrappersList())
+ }
+ for (BuildWrapper step : getBuildWrappersList()) {
r.addAll(step.getProjectActions(this));
- for (Trigger trigger : getTriggersList())
+ }
+ for (Trigger trigger : getTriggersList()) {
r.addAll(trigger.getProjectActions());
+ }
return r;
}
@@ -147,21 +149,21 @@ public abstract class BaseBuildableProject<P extends BaseBuildableProject<P,B>,B
* @inheritDoc
*/
@SuppressWarnings("unchecked")
- public DescribableList<Builder,Descriptor<Builder>> getBuildersList() {
+ public DescribableList<Builder, Descriptor<Builder>> getBuildersList() {
return CascadingUtil.getDescribableListProjectProperty(this, BUILDERS_PROPERTY_NAME).getValue();
}
/**
* @inheritDoc
*/
- public void setBuilders(DescribableList<Builder,Descriptor<Builder>> builders) {
+ public void setBuilders(DescribableList<Builder, Descriptor<Builder>> builders) {
CascadingUtil.getDescribableListProjectProperty(this, BUILDERS_PROPERTY_NAME).setValue(builders);
}
/**
* @inheritDoc
*/
- public Map<Descriptor<Publisher>,Publisher> getPublishers() {
+ public Map<Descriptor<Publisher>, Publisher> getPublishers() {
return getPublishersList().toMap();
}
@@ -179,7 +181,8 @@ public abstract class BaseBuildableProject<P extends BaseBuildableProject<P,B>,B
}
/**
- * Adds a new {@link BuildStep} to this {@link Project} and saves the configuration.
+ * Adds a new {@link BuildStep} to this {@link Project} and saves the
+ * configuration.
*
* @param publisher publisher.
* @throws java.io.IOException exception.
@@ -187,7 +190,7 @@ public abstract class BaseBuildableProject<P extends BaseBuildableProject<P,B>,B
@SuppressWarnings("unchecked")
public void addPublisher(Publisher publisher) throws IOException {
CascadingUtil.getExternalProjectProperty(this,
- publisher.getDescriptor().getJsonSafeClassName()).setValue(publisher);
+ publisher.getDescriptor().getJsonSafeClassName()).setValue(publisher);
save();
}
@@ -205,7 +208,7 @@ public abstract class BaseBuildableProject<P extends BaseBuildableProject<P,B>,B
/**
* @inheritDoc
*/
- public Map<Descriptor<BuildWrapper>,BuildWrapper> getBuildWrappers() {
+ public Map<Descriptor<BuildWrapper>, BuildWrapper> getBuildWrappers() {
return getBuildWrappersList().toMap();
}
@@ -225,7 +228,7 @@ public abstract class BaseBuildableProject<P extends BaseBuildableProject<P,B>,B
* @throws hudson.model.Descriptor.FormException if any.
*/
protected void buildPublishers(StaplerRequest req, JSONObject json, List<Descriptor<Publisher>> descriptors)
- throws FormException {
+ throws FormException {
CascadingUtil.buildExternalProperties(req, json, descriptors, this);
}
@@ -238,7 +241,7 @@ public abstract class BaseBuildableProject<P extends BaseBuildableProject<P,B>,B
* @throws hudson.model.Descriptor.FormException if any.
*/
protected void buildBuildWrappers(StaplerRequest req, JSONObject json, List<Descriptor<BuildWrapper>> descriptors)
- throws FormException {
+ throws FormException {
CascadingUtil.buildExternalProperties(req, json, descriptors, this);
}
diff --git a/hudson-core/src/main/java/hudson/model/BooleanParameterDefinition.java b/hudson-core/src/main/java/hudson/model/BooleanParameterDefinition.java
index d43eadf..7c135a3 100644
--- a/hudson-core/src/main/java/hudson/model/BooleanParameterDefinition.java
+++ b/hudson-core/src/main/java/hudson/model/BooleanParameterDefinition.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -29,6 +29,7 @@ import hudson.Extension;
* @author huybrechts
*/
public class BooleanParameterDefinition extends SimpleParameterDefinition {
+
private final boolean defaultValue;
@DataBoundConstructor
@@ -49,7 +50,7 @@ public class BooleanParameterDefinition extends SimpleParameterDefinition {
}
public ParameterValue createValue(String value) {
- return new BooleanParameterValue(getName(),Boolean.valueOf(value),getDescription());
+ return new BooleanParameterValue(getName(), Boolean.valueOf(value), getDescription());
}
@Override
@@ -59,6 +60,7 @@ public class BooleanParameterDefinition extends SimpleParameterDefinition {
@Extension
public static class DescriptorImpl extends ParameterDescriptor {
+
@Override
public String getDisplayName() {
return Messages.BooleanParameterDefinition_DisplayName();
@@ -73,15 +75,15 @@ public class BooleanParameterDefinition extends SimpleParameterDefinition {
@Override
public boolean equals(Object o) {
return super.equals(o) && new EqualsBuilder()
- .append(isDefaultValue(), ((BooleanParameterDefinition) o).isDefaultValue())
- .isEquals();
+ .append(isDefaultValue(), ((BooleanParameterDefinition) o).isDefaultValue())
+ .isEquals();
}
@Override
public int hashCode() {
return new HashCodeBuilder()
- .appendSuper(super.hashCode())
- .append(isDefaultValue())
- .toHashCode();
+ .appendSuper(super.hashCode())
+ .append(isDefaultValue())
+ .toHashCode();
}
}
diff --git a/hudson-core/src/main/java/hudson/model/BooleanParameterValue.java b/hudson-core/src/main/java/hudson/model/BooleanParameterValue.java
index 2c0885f..726b7e8 100644
--- a/hudson-core/src/main/java/hudson/model/BooleanParameterValue.java
+++ b/hudson-core/src/main/java/hudson/model/BooleanParameterValue.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
-*
-* Kohsuke Kawaguchi, Luca Domenico Milanesio, Tom Huybrechts
- *
+ * Contributors:
+ *
+ * Kohsuke Kawaguchi, Luca Domenico Milanesio, Tom Huybrechts
+ *
*
*******************************************************************************/
@@ -28,7 +28,8 @@ import hudson.util.VariableResolver;
* {@link ParameterValue} created from {@link BooleanParameterDefinition}.
*/
public class BooleanParameterValue extends ParameterValue {
- @Exported(visibility=4)
+
+ @Exported(visibility = 4)
public final boolean value;
@DataBoundConstructor
@@ -45,9 +46,9 @@ public class BooleanParameterValue extends ParameterValue {
* Exposes the name/value as an environment variable.
*/
@Override
- public void buildEnvVars(AbstractBuild<?,?> build, EnvVars env) {
- env.put(name,Boolean.toString(value));
- env.put(name.toUpperCase(Locale.ENGLISH),Boolean.toString(value)); // backward compatibility pre 1.345
+ public void buildEnvVars(AbstractBuild<?, ?> build, EnvVars env) {
+ env.put(name, Boolean.toString(value));
+ env.put(name.toUpperCase(Locale.ENGLISH), Boolean.toString(value)); // backward compatibility pre 1.345
}
@Override
@@ -61,13 +62,21 @@ public class BooleanParameterValue extends ParameterValue {
@Override
public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
- if (!super.equals(o)) return false;
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ if (!super.equals(o)) {
+ return false;
+ }
BooleanParameterValue that = (BooleanParameterValue) o;
- if (value != that.value) return false;
+ if (value != that.value) {
+ return false;
+ }
return true;
}
@@ -81,6 +90,6 @@ public class BooleanParameterValue extends ParameterValue {
@Override
public String toString() {
- return "(BooleanParameterValue) " + getName() + "='" + value + "'";
+ return "(BooleanParameterValue) " + getName() + "='" + value + "'";
}
}
diff --git a/hudson-core/src/main/java/hudson/model/Build.java b/hudson-core/src/main/java/hudson/model/Build.java
index af6acca..fbdae12 100644
--- a/hudson-core/src/main/java/hudson/model/Build.java
+++ b/hudson-core/src/main/java/hudson/model/Build.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
-*
-* Kohsuke Kawaguchi, Martin Eigenbrodt
- *
+ * Contributors:
+ *
+ * Kohsuke Kawaguchi, Martin Eigenbrodt
+ *
*
*******************************************************************************/
@@ -32,46 +32,47 @@ import java.util.logging.Logger;
import static hudson.model.Result.FAILURE;
import static hudson.model.Result.ABORTED;
+
/**
* A build of a {@link Project}.
*
- * <h2>Steps of a build</h2>
- * <p>
- * Roughly speaking, a {@link Build} goes through the following stages:
+ * <h2>Steps of a build</h2> <p> Roughly speaking, a {@link Build} goes through
+ * the following stages:
*
- * <dl>
- * <dt>SCM checkout
- * <dd>Hudson decides which directory to use for a build, then the source code is checked out
+ * <dl> <dt>SCM checkout <dd>Hudson decides which directory to use for a build,
+ * then the source code is checked out
*
- * <dt>Pre-build steps
- * <dd>Everyone gets their {@link BuildStep#prebuild(AbstractBuild, BuildListener)} invoked
- * to indicate that the build is starting
+ * <dt>Pre-build steps <dd>Everyone gets their
+ * {@link BuildStep#prebuild(AbstractBuild, BuildListener)} invoked to indicate
+ * that the build is starting
*
* <dt>Build wrapper set up
- * <dd>{@link BuildWrapper#setUp(AbstractBuild, Launcher, BuildListener)} is invoked. This is normally
- * to prepare an environment for the build.
+ * <dd>{@link BuildWrapper#setUp(AbstractBuild, Launcher, BuildListener)} is
+ * invoked. This is normally to prepare an environment for the build.
*
* <dt>Builder runs
- * <dd>{@link Builder#perform(AbstractBuild, Launcher, BuildListener)} is invoked. This is where
- * things that are useful to users happen, like calling Ant, Make, etc.
+ * <dd>{@link Builder#perform(AbstractBuild, Launcher, BuildListener)} is
+ * invoked. This is where things that are useful to users happen, like calling
+ * Ant, Make, etc.
*
* <dt>Recorder runs
- * <dd>{@link Recorder#perform(AbstractBuild, Launcher, BuildListener)} is invoked. This is normally
- * to record the output from the build, such as test results.
+ * <dd>{@link Recorder#perform(AbstractBuild, Launcher, BuildListener)} is
+ * invoked. This is normally to record the output from the build, such as test
+ * results.
*
* <dt>Notifier runs
- * <dd>{@link Notifier#perform(AbstractBuild, Launcher, BuildListener)} is invoked. This is normally
- * to send out notifications, based on the results determined so far.
- * </dl>
+ * <dd>{@link Notifier#perform(AbstractBuild, Launcher, BuildListener)} is
+ * invoked. This is normally to send out notifications, based on the results
+ * determined so far. </dl>
*
- * <p>
- * And beyond that, the build is considered complete, and from then on {@link Build} object is there to
- * keep the record of what happened in this build.
+ * <p> And beyond that, the build is considered complete, and from then on
+ * {@link Build} object is there to keep the record of what happened in this
+ * build.
*
* @author Kohsuke Kawaguchi
*/
-public abstract class Build <P extends BaseBuildableProject<P,B>,B extends Build<P,B>>
- extends AbstractBuild<P,B> {
+public abstract class Build<P extends BaseBuildableProject<P, B>, B extends Build<P, B>>
+ extends AbstractBuild<P, B> {
/**
* Creates a new build.
@@ -88,7 +89,7 @@ public abstract class Build <P extends BaseBuildableProject<P,B>,B extends Build
* Loads a build from a log file.
*/
protected Build(P project, File buildDir) throws IOException {
- super(project,buildDir);
+ super(project, buildDir);
}
//
@@ -104,55 +105,67 @@ public abstract class Build <P extends BaseBuildableProject<P,B>,B extends Build
protected Runner createRunner() {
return new RunnerImpl();
}
-
+
protected class RunnerImpl extends AbstractRunner {
+
protected Result doRun(BuildListener listener) throws Exception {
- if(!preBuild(listener,project.getBuilders()))
+ if (!preBuild(listener, project.getBuilders())) {
return FAILURE;
- if(!preBuild(listener,project.getPublishers()))
+ }
+ if (!preBuild(listener, project.getPublishers())) {
return FAILURE;
+ }
Result r = null;
try {
List<BuildWrapper> wrappers = new ArrayList<BuildWrapper>(project.getBuildWrappers().values());
-
+
ParametersAction parameters = getAction(ParametersAction.class);
- if (parameters != null)
- parameters.createBuildWrappers(Build.this,wrappers);
+ if (parameters != null) {
+ parameters.createBuildWrappers(Build.this, wrappers);
+ }
- for( BuildWrapper w : wrappers ) {
- Environment e = w.setUp((AbstractBuild<?,?>)Build.this, launcher, listener);
- if(e==null)
+ for (BuildWrapper w : wrappers) {
+ Environment e = w.setUp((AbstractBuild<?, ?>) Build.this, launcher, listener);
+ if (e == null) {
return (r = FAILURE);
+ }
buildEnvironments.add(e);
}
- if(!build(listener,project.getBuilders()))
+ if (!build(listener, project.getBuilders())) {
r = FAILURE;
+ }
} catch (InterruptedException e) {
r = ABORTED;
throw e;
} finally {
- if (r != null) setResult(r);
+ if (r != null) {
+ setResult(r);
+ }
// tear down in reverse order
- boolean failed=false;
- for( int i=buildEnvironments.size()-1; i>=0; i-- ) {
- if (!buildEnvironments.get(i).tearDown(Build.this,listener)) {
- failed=true;
- }
+ boolean failed = false;
+ for (int i = buildEnvironments.size() - 1; i >= 0; i--) {
+ if (!buildEnvironments.get(i).tearDown(Build.this, listener)) {
+ failed = true;
+ }
}
// WARNING The return in the finally clause will trump any return before
- if (failed) return FAILURE;
+ if (failed) {
+ return FAILURE;
+ }
}
return r;
}
public void post2(BuildListener listener) throws IOException, InterruptedException {
- if (!performAllBuildSteps(listener, project.getPublishers(), true))
+ if (!performAllBuildSteps(listener, project.getPublishers(), true)) {
setResult(FAILURE);
- if (!performAllBuildSteps(listener, project.getProperties(), true))
+ }
+ if (!performAllBuildSteps(listener, project.getProperties(), true)) {
setResult(FAILURE);
+ }
}
@Override
@@ -164,12 +177,13 @@ public abstract class Build <P extends BaseBuildableProject<P,B>,B extends Build
}
private boolean build(BuildListener listener, Collection<Builder> steps) throws IOException, InterruptedException {
- for( BuildStep bs : steps )
- if(!perform(bs,listener))
+ for (BuildStep bs : steps) {
+ if (!perform(bs, listener)) {
return false;
+ }
+ }
return true;
}
}
-
private static final Logger LOGGER = Logger.getLogger(Build.class.getName());
}
diff --git a/hudson-core/src/main/java/hudson/model/BuildAuthorizationToken.java b/hudson-core/src/main/java/hudson/model/BuildAuthorizationToken.java
index 735c61c..44bce71 100644
--- a/hudson-core/src/main/java/hudson/model/BuildAuthorizationToken.java
+++ b/hudson-core/src/main/java/hudson/model/BuildAuthorizationToken.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
*
* Kohsuke Kawaguchi, Winston Prakash
- *
+ *
*******************************************************************************/
package hudson.model;
@@ -26,15 +26,16 @@ import org.eclipse.hudson.security.HudsonSecurityEntitiesHolder;
import org.springframework.security.AccessDeniedException;
/**
- * Authorization token to allow projects to trigger themselves under the secured environment.
+ * Authorization token to allow projects to trigger themselves under the secured
+ * environment.
*
* @author Kohsuke Kawaguchi
* @see BuildableItem
- * @deprecated 2008-07-20
- * Use {@link ACL} and {@link AbstractProject#BUILD}. This code is only here
- * for the backward compatibility.
+ * @deprecated 2008-07-20 Use {@link ACL} and {@link AbstractProject#BUILD}.
+ * This code is only here for the backward compatibility.
*/
public final class BuildAuthorizationToken {
+
private final String token;
public BuildAuthorizationToken(String token) {
@@ -44,24 +45,27 @@ public final class BuildAuthorizationToken {
public static BuildAuthorizationToken create(StaplerRequest req) {
if (req.getParameter("pseudoRemoteTrigger") != null) {
String token = Util.fixEmpty(req.getParameter("authToken"));
- if(token!=null)
+ if (token != null) {
return new BuildAuthorizationToken(token);
+ }
}
-
+
return null;
}
public static void checkPermission(AbstractProject project, BuildAuthorizationToken token, StaplerRequest req, StaplerResponse rsp) throws IOException {
- if (!HudsonSecurityEntitiesHolder.getHudsonSecurityManager().isUseSecurity())
+ if (!HudsonSecurityEntitiesHolder.getHudsonSecurityManager().isUseSecurity()) {
return; // everyone is authorized
-
- if(token!=null && token.token != null) {
+ }
+ if (token != null && token.token != null) {
//check the provided token
String providedToken = req.getParameter("token");
- if (providedToken != null && providedToken.equals(token.token))
+ if (providedToken != null && providedToken.equals(token.token)) {
return;
- if (providedToken != null)
+ }
+ if (providedToken != null) {
throw new AccessDeniedException(Messages.BuildAuthorizationToken_InvalidTokenProvided());
+ }
}
project.checkPermission(AbstractProject.BUILD);
@@ -72,8 +76,9 @@ public final class BuildAuthorizationToken {
}
public static final class ConverterImpl extends AbstractSingleValueConverter {
+
public boolean canConvert(Class type) {
- return type== BuildAuthorizationToken.class;
+ return type == BuildAuthorizationToken.class;
}
public Object fromString(String str) {
@@ -82,7 +87,7 @@ public final class BuildAuthorizationToken {
@Override
public String toString(Object obj) {
- return ((BuildAuthorizationToken)obj).token;
+ return ((BuildAuthorizationToken) obj).token;
}
}
}
diff --git a/hudson-core/src/main/java/hudson/model/BuildBadgeAction.java b/hudson-core/src/main/java/hudson/model/BuildBadgeAction.java
index 33f7b24..2360e8e 100644
--- a/hudson-core/src/main/java/hudson/model/BuildBadgeAction.java
+++ b/hudson-core/src/main/java/hudson/model/BuildBadgeAction.java
@@ -7,27 +7,25 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
-*
-* Kohsuke Kawaguchi
- *
+ * Contributors:
+ *
+ * Kohsuke Kawaguchi
+ *
*
*******************************************************************************/
package hudson.model;
/**
- * {@link Action} that puts a little icon (or icons)
- * next to the build in the build history.
+ * {@link Action} that puts a little icon (or icons) next to the build in the
+ * build history.
*
- * <p>
- * This can be implemented by {@link Action}s that associate themselves
- * with {@link Run}.
+ * <p> This can be implemented by {@link Action}s that associate themselves with
+ * {@link Run}.
*
- * <p>
- * Actions with this marker should have a view <tt>badge.jelly</tt>,
- * which will be called to render the badges. The expected visual appearance
- * of a badge is a 16x16 icon.
+ * <p> Actions with this marker should have a view <tt>badge.jelly</tt>, which
+ * will be called to render the badges. The expected visual appearance of a
+ * badge is a 16x16 icon.
*
* @author Kohsuke Kawaguchi
* @since 1.150
diff --git a/hudson-core/src/main/java/hudson/model/BuildListener.java b/hudson-core/src/main/java/hudson/model/BuildListener.java
index 62ee8b4..8554225 100644
--- a/hudson-core/src/main/java/hudson/model/BuildListener.java
+++ b/hudson-core/src/main/java/hudson/model/BuildListener.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
-*
-* Kohsuke Kawaguchi
- *
+ * Contributors:
+ *
+ * Kohsuke Kawaguchi
+ *
*
*******************************************************************************/
@@ -28,8 +28,7 @@ public interface BuildListener extends TaskListener {
/**
* Called when a build is started.
*
- * @param causes
- * Causes that started a build. See {@link Run#getCauses()}.
+ * @param causes Causes that started a build. See {@link Run#getCauses()}.
*/
void started(List<Cause> causes);
diff --git a/hudson-core/src/main/java/hudson/model/BuildTimelineWidget.java b/hudson-core/src/main/java/hudson/model/BuildTimelineWidget.java
index bd83534..2da64c8 100644
--- a/hudson-core/src/main/java/hudson/model/BuildTimelineWidget.java
+++ b/hudson-core/src/main/java/hudson/model/BuildTimelineWidget.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -38,15 +38,13 @@ import org.kohsuke.stapler.QueryParameter;
/**
* UI widget for showing the SMILE timeline control.
*
- * <p>
- * Return this from your "getTimeline" method.
+ * <p> Return this from your "getTimeline" method.
*
* @author Kohsuke Kawaguchi, Winston Prakash
* @since 1.372
*/
public class BuildTimelineWidget {
-
protected final RunList<?> builds;
public BuildTimelineWidget(RunList<?> builds) {
@@ -88,7 +86,7 @@ public class BuildTimelineWidget {
}
return result;
}
-
+
/**
* List of {@link Event} that the timeline component will display.
*/
@@ -101,11 +99,10 @@ public class BuildTimelineWidget {
// Date needs to be converted into iso-8601 date format.
JsonConfig config = new JsonConfig();
config.registerJsonValueProcessor(Date.class, new JsonValueProcessor() {
-
public synchronized Object processArrayValue(Object value, JsonConfig jsonConfig) {
- if (value != null){
- DateFormat dateFormat = new SimpleDateFormat("MMM dd yyyy HH:mm:ss 'GMT'Z", Functions.getClientLocale());
- return dateFormat.format(value);
+ if (value != null) {
+ DateFormat dateFormat = new SimpleDateFormat("MMM dd yyyy HH:mm:ss 'GMT'Z", Functions.getClientLocale());
+ return dateFormat.format(value);
}
return null;
}
@@ -123,28 +120,28 @@ public class BuildTimelineWidget {
}
/**
- * Event data to be rendered on timeline.
- * See http://code.google.com/p/simile-widgets/wiki/Timeline_EventSources
-
- * <p>
- * This is bound to JSON and sent to the client-side JavaScript.
+ * Event data to be rendered on timeline. See
+ * http://code.google.com/p/simile-widgets/wiki/Timeline_EventSources
+ *
+ * <p> This is bound to JSON and sent to the client-side JavaScript.
*/
public static class Event {
//TODO: review and check whether we can do it private
- public Date start;
+ public Date start;
public Date end;
public String title, description;
/**
- * If true, the event occurs over a time duration. No icon. The event will be
- * drawn as a dark blue tape. The tape color is set with the color attribute.
- * Default color is #58A0DC
+ * If true, the event occurs over a time duration. No icon. The event
+ * will be drawn as a dark blue tape. The tape color is set with the
+ * color attribute. Default color is #58A0DC
*
- * If false (default), the event is focused on a specific "instant" (shown with the icon).
- * The event will be drawn as a blue dot icon (default) with a pale blue tape.
- * The tape is the default color (or color attribute color), with opacity
- * set to 20. To change the opacity, change the theme's instant: {impreciseOpacity: 20}
- * value. Maximum 100.
+ * If false (default), the event is focused on a specific "instant"
+ * (shown with the icon). The event will be drawn as a blue dot icon
+ * (default) with a pale blue tape. The tape is the default color (or
+ * color attribute color), with opacity set to 20. To change the
+ * opacity, change the theme's instant: {impreciseOpacity: 20} value.
+ * Maximum 100.
*/
public Boolean durationEvent;
/**
@@ -152,9 +149,9 @@ public class BuildTimelineWidget {
*/
public String link;
/**
- * Color of the text and tape (duration events) to display in the timeline.
- * If the event has durationEvent = false, then the bar's opacity will
- * be applied (default 20%). See durationEvent, above.
+ * Color of the text and tape (duration events) to display in the
+ * timeline. If the event has durationEvent = false, then the bar's
+ * opacity will be applied (default 20%). See durationEvent, above.
*/
public String color;
/**
diff --git a/hudson-core/src/main/java/hudson/model/BuildableItem.java b/hudson-core/src/main/java/hudson/model/BuildableItem.java
index 7bd6574..ed4263e 100644
--- a/hudson-core/src/main/java/hudson/model/BuildableItem.java
+++ b/hudson-core/src/main/java/hudson/model/BuildableItem.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
-*
-* Kohsuke Kawaguchi
- *
+ * Contributors:
+ *
+ * Kohsuke Kawaguchi
+ *
*
*******************************************************************************/
@@ -19,25 +19,25 @@ package hudson.model;
import hudson.model.Queue.Task;
/**
- * {@link Item} that can be "built", for
- * whatever meaning of "build".
+ * {@link Item} that can be "built", for whatever meaning of "build".
*
- * <p>
- * This interface is used by utility code.
+ * <p> This interface is used by utility code.
*
* @author Kohsuke Kawaguchi
*/
public interface BuildableItem extends Item, Task {
- /**
- * @deprecated
- * Use {@link #scheduleBuild(Cause)}. Since 1.283
- */
+
+ /**
+ * @deprecated Use {@link #scheduleBuild(Cause)}. Since 1.283
+ */
boolean scheduleBuild();
- boolean scheduleBuild(Cause c);
- /**
- * @deprecated
- * Use {@link #scheduleBuild(int, Cause)}. Since 1.283
- */
- boolean scheduleBuild(int quietPeriod);
- boolean scheduleBuild(int quietPeriod, Cause c);
+
+ boolean scheduleBuild(Cause c);
+
+ /**
+ * @deprecated Use {@link #scheduleBuild(int, Cause)}. Since 1.283
+ */
+ boolean scheduleBuild(int quietPeriod);
+
+ boolean scheduleBuild(int quietPeriod, Cause c);
}
diff --git a/hudson-core/src/main/java/hudson/model/BuildableItemWithBuildWrappers.java b/hudson-core/src/main/java/hudson/model/BuildableItemWithBuildWrappers.java
index 00524b5..822f1a5 100644
--- a/hudson-core/src/main/java/hudson/model/BuildableItemWithBuildWrappers.java
+++ b/hudson-core/src/main/java/hudson/model/BuildableItemWithBuildWrappers.java
@@ -8,7 +8,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- *
+ *
*
*******************************************************************************/
@@ -24,23 +24,22 @@ import hudson.util.DescribableList;
* @since 1.335
*/
public interface BuildableItemWithBuildWrappers extends BuildableItem {
+
/**
* {@link BuildableItemWithBuildWrappers} needs to be an instance of
* {@link AbstractProject}.
*
- * <p>
- * This method must be always implemented as {@code (AbstractProject)this}, but
- * defining this method emphasizes the fact that this cast must be doable.
+ * <p> This method must be always implemented as
+ * {@code (AbstractProject)this}, but defining this method emphasizes the
+ * fact that this cast must be doable.
*/
- AbstractProject<?,?> asProject();
+ AbstractProject<?, ?> asProject();
/**
* {@link BuildWrapper}s associated with this {@link AbstractProject}.
*
- * @return
- * can be empty but never null. This list is live, and changes to it will be reflected
- * to the project configuration.
+ * @return can be empty but never null. This list is live, and changes to it
+ * will be reflected to the project configuration.
*/
- DescribableList<BuildWrapper,Descriptor<BuildWrapper>> getBuildWrappersList();
+ DescribableList<BuildWrapper, Descriptor<BuildWrapper>> getBuildWrappersList();
}
-
diff --git a/hudson-core/src/main/java/hudson/model/Cause.java b/hudson-core/src/main/java/hudson/model/Cause.java
index 52ced23..65c7abd 100644
--- a/hudson-core/src/main/java/hudson/model/Cause.java
+++ b/hudson-core/src/main/java/hudson/model/Cause.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
*
* Michael B. Donohue, Seiji Sogabe, Winston Prakash
- *
+ *
*******************************************************************************/
package hudson.model;
@@ -28,17 +28,14 @@ import com.thoughtworks.xstream.converters.UnmarshallingContext;
import org.eclipse.hudson.security.HudsonSecurityManager;
/**
- * Cause object base class. This class hierarchy is used to keep track of why
- * a given build was started. This object encapsulates the UI rendering of the cause,
- * as well as providing more useful information in respective subypes.
+ * Cause object base class. This class hierarchy is used to keep track of why a
+ * given build was started. This object encapsulates the UI rendering of the
+ * cause, as well as providing more useful information in respective subypes.
*
* The Cause object is connected to a build via the {@link CauseAction} object.
*
- * <h2>Views</h2>
- * <dl>
- * <dt>description.jelly
- * <dd>Renders the cause to HTML. By default, it puts the short description.
- * </dl>
+ * <h2>Views</h2> <dl> <dt>description.jelly <dd>Renders the cause to HTML. By
+ * default, it puts the short description. </dl>
*
* @author Michael Donohue
* @see Run#getCauses()
@@ -46,26 +43,27 @@ import org.eclipse.hudson.security.HudsonSecurityManager;
*/
@ExportedBean
public abstract class Cause {
+
/**
* One-line human-readable text of the cause.
*
- * <p>
- * By default, this method is used to render HTML as well.
+ * <p> By default, this method is used to render HTML as well.
*/
- @Exported(visibility=3)
+ @Exported(visibility = 3)
public abstract String getShortDescription();
/**
* Called when the cause is registered to {@link AbstractBuild}.
*
- * @param build
- * never null
+ * @param build never null
* @since 1.376
*/
- public void onAddedTo(AbstractBuild build) {}
+ public void onAddedTo(AbstractBuild build) {
+ }
/**
* Report a line to the listener about this cause.
+ *
* @since 1.362
*/
public void print(TaskListener listener) {
@@ -74,24 +72,29 @@ public abstract class Cause {
/**
* Fall back implementation when no other type is available.
+ *
* @deprecated since 2009-02-08
*/
public static class LegacyCodeCause extends Cause {
- private StackTraceElement [] stackTrace;
+
+ private StackTraceElement[] stackTrace;
+
public LegacyCodeCause() {
stackTrace = new Exception().getStackTrace();
}
-
+
@Override
public String getShortDescription() {
return Messages.Cause_LegacyCodeCause_ShortDescription();
}
}
-
+
/**
- * A build is triggered by the completion of another build (AKA upstream build.)
+ * A build is triggered by the completion of another build (AKA upstream
+ * build.)
*/
public static class UpstreamCause extends Cause {
+
private String upstreamProject, upstreamUrl;
private int upstreamBuild;
/**
@@ -105,10 +108,10 @@ public abstract class Cause {
* @deprecated since 2009-02-28
*/
// for backward bytecode compatibility
- public UpstreamCause(AbstractBuild<?,?> up) {
- this((Run<?,?>)up);
+ public UpstreamCause(AbstractBuild<?, ?> up) {
+ this((Run<?, ?>) up);
}
-
+
public UpstreamCause(Run<?, ?> up) {
upstreamBuild = up.getNumber();
upstreamProject = up.getParent().getFullName();
@@ -119,32 +122,32 @@ public abstract class Cause {
/**
* Returns true if this cause points to a build in the specified job.
*/
- public boolean pointsTo(Job<?,?> j) {
+ public boolean pointsTo(Job<?, ?> j) {
return j.getFullName().equals(upstreamProject);
}
/**
* Returns true if this cause points to the specified build.
*/
- public boolean pointsTo(Run<?,?> r) {
- return r.getNumber()==upstreamBuild && pointsTo(r.getParent());
+ public boolean pointsTo(Run<?, ?> r) {
+ return r.getNumber() == upstreamBuild && pointsTo(r.getParent());
}
- @Exported(visibility=3)
+ @Exported(visibility = 3)
public String getUpstreamProject() {
return upstreamProject;
}
- @Exported(visibility=3)
+ @Exported(visibility = 3)
public int getUpstreamBuild() {
return upstreamBuild;
}
- @Exported(visibility=3)
+ @Exported(visibility = 3)
public String getUpstreamUrl() {
return upstreamUrl;
}
-
+
@Override
public String getShortDescription() {
return Messages.Cause_UpstreamCause_ShortDescription(upstreamProject, upstreamBuild);
@@ -153,17 +156,23 @@ public abstract class Cause {
@Override
public void print(TaskListener listener) {
listener.getLogger().println(
- Messages.Cause_UpstreamCause_ShortDescription(
- HyperlinkNote.encodeTo('/'+upstreamUrl, upstreamProject),
- HyperlinkNote.encodeTo('/'+upstreamUrl+upstreamBuild, Integer.toString(upstreamBuild)))
- );
+ Messages.Cause_UpstreamCause_ShortDescription(
+ HyperlinkNote.encodeTo('/' + upstreamUrl, upstreamProject),
+ HyperlinkNote.encodeTo('/' + upstreamUrl + upstreamBuild, Integer.toString(upstreamBuild))));
}
public static class ConverterImpl extends XStream2.PassthruConverter<UpstreamCause> {
- public ConverterImpl(XStream2 xstream) { super(xstream); }
- @Override protected void callback(UpstreamCause uc, UnmarshallingContext context) {
+
+ public ConverterImpl(XStream2 xstream) {
+ super(xstream);
+ }
+
+ @Override
+ protected void callback(UpstreamCause uc, UnmarshallingContext context) {
if (uc.upstreamCause != null) {
- if (uc.upstreamCauses == null) uc.upstreamCauses = new ArrayList<Cause>();
+ if (uc.upstreamCauses == null) {
+ uc.upstreamCauses = new ArrayList<Cause>();
+ }
uc.upstreamCauses.add(uc.upstreamCause);
uc.upstreamCause = null;
OldDataMonitor.report(context, "1.288");
@@ -176,14 +185,16 @@ public abstract class Cause {
* A build is started by an user action.
*/
public static class UserCause extends Cause {
+
private String authenticationName;
+
public UserCause() {
this.authenticationName = HudsonSecurityManager.getAuthentication().getName();
}
- @Exported(visibility=3)
+ @Exported(visibility = 3)
public String getUserName() {
- User u = User.get(authenticationName, false);
+ User u = User.get(authenticationName, false);
return u != null ? u.getDisplayName() : authenticationName;
}
@@ -194,8 +205,8 @@ public abstract class Cause {
@Override
public boolean equals(Object o) {
- return o instanceof UserCause && Arrays.equals(new Object[] {authenticationName},
- new Object[] {((UserCause)o).authenticationName});
+ return o instanceof UserCause && Arrays.equals(new Object[]{authenticationName},
+ new Object[]{((UserCause) o).authenticationName});
}
@Override
@@ -205,6 +216,7 @@ public abstract class Cause {
}
public static class RemoteCause extends Cause {
+
private String addr;
private String note;
@@ -215,7 +227,7 @@ public abstract class Cause {
@Override
public String getShortDescription() {
- if(note != null) {
+ if (note != null) {
return Messages.Cause_RemoteCause_ShortDescriptionWithNote(addr, note);
} else {
return Messages.Cause_RemoteCause_ShortDescription(addr);
@@ -224,8 +236,8 @@ public abstract class Cause {
@Override
public boolean equals(Object o) {
- return o instanceof RemoteCause && Arrays.equals(new Object[] {addr, note},
- new Object[] {((RemoteCause)o).addr, ((RemoteCause)o).note});
+ return o instanceof RemoteCause && Arrays.equals(new Object[]{addr, note},
+ new Object[]{((RemoteCause) o).addr, ((RemoteCause) o).note});
}
@Override
diff --git a/hudson-core/src/main/java/hudson/model/CauseAction.java b/hudson-core/src/main/java/hudson/model/CauseAction.java
index 387f687..1cdd488 100644
--- a/hudson-core/src/main/java/hudson/model/CauseAction.java
+++ b/hudson-core/src/main/java/hudson/model/CauseAction.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
*
* Michael B. Donohue
- *
+ *
*
*******************************************************************************/
@@ -31,47 +31,48 @@ import java.util.Map;
@ExportedBean
public class CauseAction implements FoldableAction, RunAction {
+
/**
* @deprecated since 2009-02-28
*/
@Deprecated
// there can be multiple causes, so this is deprecated
private transient Cause cause;
-
private List<Cause> causes = new ArrayList<Cause>();
- @Exported(visibility=2)
- public List<Cause> getCauses() {
- return causes;
- }
-
- public CauseAction(Cause c) {
- this.causes.add(c);
- }
-
- public CauseAction(CauseAction ca) {
- this.causes.addAll(ca.causes);
- }
-
- public String getDisplayName() {
- return "Cause";
- }
-
- public String getIconFileName() {
- // no icon
- return null;
- }
-
- public String getUrlName() {
- return "cause";
- }
+ @Exported(visibility = 2)
+ public List<Cause> getCauses() {
+ return causes;
+ }
+
+ public CauseAction(Cause c) {
+ this.causes.add(c);
+ }
+
+ public CauseAction(CauseAction ca) {
+ this.causes.addAll(ca.causes);
+ }
+
+ public String getDisplayName() {
+ return "Cause";
+ }
+
+ public String getIconFileName() {
+ // no icon
+ return null;
+ }
+
+ public String getUrlName() {
+ return "cause";
+ }
/**
* Get list of causes with duplicates combined into counters.
+ *
* @return Map of Cause to number of occurrences of that Cause
*/
- public Map<Cause,Integer> getCauseCounts() {
- Map<Cause,Integer> result = new LinkedHashMap<Cause,Integer>();
+ public Map<Cause, Integer> getCauseCounts() {
+ Map<Cause, Integer> result = new LinkedHashMap<Cause, Integer>();
for (Cause c : causes) {
Integer i = result.get(c);
result.put(c, i == null ? 1 : i.intValue() + 1);
@@ -80,11 +81,12 @@ public class CauseAction implements FoldableAction, RunAction {
}
/**
- * @deprecated as of 1.288
- * but left here for backward compatibility.
+ * @deprecated as of 1.288 but left here for backward compatibility.
*/
public String getShortDescription() {
- if(causes.isEmpty()) return "N/A";
+ if (causes.isEmpty()) {
+ return "N/A";
+ }
return causes.get(0).getShortDescription();
}
@@ -110,7 +112,7 @@ public class CauseAction implements FoldableAction, RunAction {
public void foldIntoExisting(hudson.model.Queue.Item item, Task owner, List<Action> otherActions) {
CauseAction existing = item.getAction(CauseAction.class);
- if (existing!=null) {
+ if (existing != null) {
existing.causes.addAll(this.causes);
return;
}
@@ -119,11 +121,18 @@ public class CauseAction implements FoldableAction, RunAction {
}
public static class ConverterImpl extends XStream2.PassthruConverter<CauseAction> {
- public ConverterImpl(XStream2 xstream) { super(xstream); }
- @Override protected void callback(CauseAction ca, UnmarshallingContext context) {
+
+ public ConverterImpl(XStream2 xstream) {
+ super(xstream);
+ }
+
+ @Override
+ protected void callback(CauseAction ca, UnmarshallingContext context) {
// if we are being read in from an older version
if (ca.cause != null) {
- if (ca.causes == null) ca.causes = new ArrayList<Cause>();
+ if (ca.causes == null) {
+ ca.causes = new ArrayList<Cause>();
+ }
ca.causes.add(ca.cause);
OldDataMonitor.report(context, "1.288");
}
diff --git a/hudson-core/src/main/java/hudson/model/CheckPoint.java b/hudson-core/src/main/java/hudson/model/CheckPoint.java
index 9ae9ecd..b7f6d1b 100644
--- a/hudson-core/src/main/java/hudson/model/CheckPoint.java
+++ b/hudson-core/src/main/java/hudson/model/CheckPoint.java
@@ -7,53 +7,53 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
package hudson.model;
/**
- * Provides a mechanism for synchronizing build executions in the face of concurrent builds.
+ * Provides a mechanism for synchronizing build executions in the face of
+ * concurrent builds.
*
- * <p>
- * At certain points of a build, {@link BuildStep}s and other extension points often need
- * to refer to what happened in its earlier build. For example, a {@link SCM} check out
- * can run concurrently, but the changelog computation requires that the check out of the
- * earlier build has completed. Or if Hudson is sending out an e-mail, he needs to know
- * the result of the previous build, so that he can decide an e-mail is necessary or not.
+ * <p> At certain points of a build, {@link BuildStep}s and other extension
+ * points often need to refer to what happened in its earlier build. For
+ * example, a {@link SCM} check out can run concurrently, but the changelog
+ * computation requires that the check out of the earlier build has completed.
+ * Or if Hudson is sending out an e-mail, he needs to know the result of the
+ * previous build, so that he can decide an e-mail is necessary or not.
*
- * <p>
- * Check pointing is a primitive mechanism to provide this sort of synchronization.
- * These methods can be only invoked from {@link Executor} threads.
+ * <p> Check pointing is a primitive mechanism to provide this sort of
+ * synchronization. These methods can be only invoked from {@link Executor}
+ * threads.
*
- * <p>
- * Each {@link CheckPoint} instance represents unique check points. {@link CheckPoint}
- * instances are normally created as a static instance, because two builds of the same project
- * needs to refer to the same check point instance for synchronization to happen properly.
+ * <p> Each {@link CheckPoint} instance represents unique check points.
+ * {@link CheckPoint} instances are normally created as a static instance,
+ * because two builds of the same project needs to refer to the same check point
+ * instance for synchronization to happen properly.
*
- * <p>
- * This class defines a few well-known check point instances. plugins can define
- * their additional check points for their own use.
+ * <p> This class defines a few well-known check point instances. plugins can
+ * define their additional check points for their own use.
*
- * <h2>Example</h2>
- * <p>
- * {@link JUnitResultArchiver} provides a good example of how a {@link Recorder} can
- * depend on its earlier result.
+ * <h2>Example</h2> <p> {@link JUnitResultArchiver} provides a good example of
+ * how a {@link Recorder} can depend on its earlier result.
*
* @author Kohsuke Kawaguchi
- * @see BuildStep#getRequiredMonitorService()
+ * @see BuildStep#getRequiredMonitorService()
* @since 1.319
*/
public final class CheckPoint {
+
private final Object identity;
private final String internalName;
/**
- * For advanced uses. Creates a check point that uses the given object as its identity.
+ * For advanced uses. Creates a check point that uses the given object as
+ * its identity.
*/
public CheckPoint(String internalName, Object identity) {
this.internalName = internalName;
@@ -61,9 +61,9 @@ public final class CheckPoint {
}
/**
- * @param internalName
- * Name of this check point that's used in the logging, stack traces, debug messages, and so on.
- * This is not displayed to users. No need for i18n.
+ * @param internalName Name of this check point that's used in the logging,
+ * stack traces, debug messages, and so on. This is not displayed to users.
+ * No need for i18n.
*/
public CheckPoint(String internalName) {
this(internalName, new Object());
@@ -71,8 +71,10 @@ public final class CheckPoint {
@Override
public boolean equals(Object that) {
- if (that == null || getClass() != that.getClass()) return false;
- return identity== ((CheckPoint) that).identity;
+ if (that == null || getClass() != that.getClass()) {
+ return false;
+ }
+ return identity == ((CheckPoint) that).identity;
}
@Override
@@ -82,57 +84,53 @@ public final class CheckPoint {
@Override
public String toString() {
- return "Check point "+internalName;
+ return "Check point " + internalName;
}
/**
- * Records that the execution of the build has reached to a check point, idenified
- * by the given identifier.
+ * Records that the execution of the build has reached to a check point,
+ * idenified by the given identifier.
*
- * <p>
- * If the successive builds are {@linkplain #block() waiting for this check point},
- * they'll be released.
+ * <p> If the successive builds are
+ * {@linkplain #block() waiting for this check point}, they'll be released.
*
- * <p>
- * This method can be only called from an {@link Executor} thread.
+ * <p> This method can be only called from an {@link Executor} thread.
*/
public void report() {
Run.reportCheckpoint(this);
}
/**
- * Waits until the previous build in progress reaches a check point, identified
- * by the given identifier, or until the current executor becomes the youngest build in progress.
+ * Waits until the previous build in progress reaches a check point,
+ * identified by the given identifier, or until the current executor becomes
+ * the youngest build in progress.
*
- * <p>
- * Note that "previous build in progress" should be interpreted as "previous (build in progress)" instead of
- * "(previous build) if it's in progress". This makes a difference around builds that are aborted or
- * failed very early without reporting the check points. Imagine the following time sequence:
+ * <p> Note that "previous build in progress" should be interpreted as
+ * "previous (build in progress)" instead of "(previous build) if it's in
+ * progress". This makes a difference around builds that are aborted or
+ * failed very early without reporting the check points. Imagine the
+ * following time sequence:
*
- * <ol>
- * <li>Build #1, #2, and #3 happens around the same time
- * <li>Build #3 waits for check point {@link JUnitResultArchiver}
- * <li>Build #2 aborts before getting to that check point
- * <li>Build #1 finally checks in {@link JUnitResultArchiver}
- * </ol>
+ * <ol> <li>Build #1, #2, and #3 happens around the same time <li>Build #3
+ * waits for check point {@link JUnitResultArchiver} <li>Build #2 aborts
+ * before getting to that check point <li>Build #1 finally checks in
+ * {@link JUnitResultArchiver} </ol>
*
- * <p>
- * Using this method, build #3 correctly waits until the step 4. Because of this behavior,
- * the {@link #report()}/{@link #block()} pair can normally
- * be used without a try/finally block.
+ * <p> Using this method, build #3 correctly waits until the step 4. Because
+ * of this behavior, the {@link #report()}/{@link #block()} pair can
+ * normally be used without a try/finally block.
*
- * <p>
- * This method can be only called from an {@link Executor} thread.
+ * <p> This method can be only called from an {@link Executor} thread.
*
- * @throws InterruptedException
- * If the build (represented by the calling executor thread) is aborted while it's waiting.
+ * @throws InterruptedException If the build (represented by the calling
+ * executor thread) is aborted while it's waiting.
*/
public void block() throws InterruptedException {
Run.waitForCheckpoint(this);
}
-
/**
- * {@link CheckPoint} that indicates that {@link AbstractBuild#getCulprits()} is computed.
+ * {@link CheckPoint} that indicates that
+ * {@link AbstractBuild#getCulprits()} is computed.
*/
public static final CheckPoint CULPRITS_DETERMINED = new CheckPoint("CULPRITS_DETERMINED");
/**
@@ -141,9 +139,9 @@ public final class CheckPoint {
*/
public static final CheckPoint COMPLETED = new CheckPoint("COMPLETED");
/**
- * {@link CheckPoint} that indicates that the build has finished executing the "main" portion
- * ({@link Builder}s in case of {@link FreeStyleProject}) and now moving on to the post-build
- * steps.
+ * {@link CheckPoint} that indicates that the build has finished executing
+ * the "main" portion ({@link Builder}s in case of {@link FreeStyleProject})
+ * and now moving on to the post-build steps.
*/
public static final CheckPoint MAIN_COMPLETED = new CheckPoint("MAIN_COMPLETED");
}
diff --git a/hudson-core/src/main/java/hudson/model/ChoiceParameterDefinition.java b/hudson-core/src/main/java/hudson/model/ChoiceParameterDefinition.java
index 8bc053d..ad15897 100644
--- a/hudson-core/src/main/java/hudson/model/ChoiceParameterDefinition.java
+++ b/hudson-core/src/main/java/hudson/model/ChoiceParameterDefinition.java
@@ -8,7 +8,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- *
+ *
*
*******************************************************************************/
@@ -31,13 +31,14 @@ import java.util.Arrays;
* @author huybrechts
*/
public class ChoiceParameterDefinition extends SimpleParameterDefinition {
+
private final List<String> choices;
@DataBoundConstructor
public ChoiceParameterDefinition(String name, String choices, String description) {
super(name, description);
this.choices = Arrays.asList(choices.split("\\r?\\n"));
- if (choices.length()==0) {
+ if (choices.length() == 0) {
throw new IllegalArgumentException("No choices found");
}
}
@@ -49,7 +50,7 @@ public class ChoiceParameterDefinition extends SimpleParameterDefinition {
throw new IllegalArgumentException("No choices found");
}
}
-
+
@Exported
public List<String> getChoices() {
return choices;
@@ -64,10 +65,10 @@ public class ChoiceParameterDefinition extends SimpleParameterDefinition {
return new StringParameterValue(getName(), choices.get(0), getDescription());
}
-
private StringParameterValue checkValue(StringParameterValue value) {
- if (!choices.contains(value.value))
+ if (!choices.contains(value.value)) {
throw new IllegalArgumentException("Illegal choice: " + value.value);
+ }
return value;
}
@@ -84,6 +85,7 @@ public class ChoiceParameterDefinition extends SimpleParameterDefinition {
@Extension
public static class DescriptorImpl extends ParameterDescriptor {
+
@Override
public String getDisplayName() {
return Messages.ChoiceParameterDefinition_DisplayName();
@@ -98,16 +100,15 @@ public class ChoiceParameterDefinition extends SimpleParameterDefinition {
@Override
public boolean equals(Object o) {
return super.equals(o) && new EqualsBuilder()
- .append(getChoices(), ((ChoiceParameterDefinition) o).getChoices())
- .isEquals();
+ .append(getChoices(), ((ChoiceParameterDefinition) o).getChoices())
+ .isEquals();
}
@Override
public int hashCode() {
return new HashCodeBuilder()
- .appendSuper(super.hashCode())
- .append(getChoices())
- .toHashCode();
+ .appendSuper(super.hashCode())
+ .append(getChoices())
+ .toHashCode();
}
-
}
diff --git a/hudson-core/src/main/java/hudson/model/Computer.java b/hudson-core/src/main/java/hudson/model/Computer.java
index d91a093..592c0c9 100644
--- a/hudson-core/src/main/java/hudson/model/Computer.java
+++ b/hudson-core/src/main/java/hudson/model/Computer.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
*
* Kohsuke Kawaguchi, Winston Prakash, Seiji Sogabe, Stephen Connolly, Thomas J. Black, Tom Huybrechts
- *
+ *
*******************************************************************************/
package hudson.model;
@@ -75,26 +75,25 @@ import org.eclipse.hudson.security.HudsonSecurityEntitiesHolder;
import org.eclipse.hudson.security.HudsonSecurityManager;
/**
- * Represents the running state of a remote computer that holds {@link Executor}s.
+ * Represents the running state of a remote computer that holds
+ * {@link Executor}s.
*
- * <p>
- * {@link Executor}s on one {@link Computer} are transparently interchangeable
- * (that is the definition of {@link Computer}.)
+ * <p> {@link Executor}s on one {@link Computer} are transparently
+ * interchangeable (that is the definition of {@link Computer}.)
*
- * <p>
- * This object is related to {@link Node} but they have some significant difference.
- * {@link Computer} primarily works as a holder of {@link Executor}s, so
- * if a {@link Node} is configured (probably temporarily) with 0 executors,
- * you won't have a {@link Computer} object for it.
+ * <p> This object is related to {@link Node} but they have some significant
+ * difference. {@link Computer} primarily works as a holder of
+ * {@link Executor}s, so if a {@link Node} is configured (probably temporarily)
+ * with 0 executors, you won't have a {@link Computer} object for it.
*
* Also, even if you remove a {@link Node}, it takes time for the corresponding
- * {@link Computer} to be removed, if some builds are already in progress on that
- * node. Or when the node configuration is changed, unaffected {@link Computer} object
- * remains intact, while all the {@link Node} objects will go away.
+ * {@link Computer} to be removed, if some builds are already in progress on
+ * that node. Or when the node configuration is changed, unaffected
+ * {@link Computer} object remains intact, while all the {@link Node} objects
+ * will go away.
*
- * <p>
- * This object also serves UI (since {@link Node} is an interface and can't have
- * related side pages.)
+ * <p> This object also serves UI (since {@link Node} is an interface and can't
+ * have related side pages.)
*
* @author Kohsuke Kawaguchi
*/
@@ -105,46 +104,38 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
* Parameter in request for deleting the slave.
*/
private static final String DELETE_MODE_KEY = "deleteMode";
-
/**
- * Key for delete mode when the jobs are stopping before the slave will delete
+ * Key for delete mode when the jobs are stopping before the slave will
+ * delete
*/
private static final String DELETE_MODE_STOP_KEY = "0";
-
private final CopyOnWriteArrayList<Executor> executors = new CopyOnWriteArrayList<Executor>();
// TODO:
private final CopyOnWriteArrayList<OneOffExecutor> oneOffExecutors = new CopyOnWriteArrayList<OneOffExecutor>();
-
private int numExecutors;
-
/**
* Contains info about reason behind computer being offline.
*/
protected volatile OfflineCause offlineCause;
-
private long connectTime = 0;
-
/**
* True if Hudson shouldn't start new builds on this node.
*/
private boolean temporarilyOffline;
-
/**
- * {@link Node} object may be created and deleted independently
- * from this object.
+ * {@link Node} object may be created and deleted independently from this
+ * object.
*/
protected String nodeName;
-
/**
* @see #getHostName()
*/
private volatile String cachedHostName;
private volatile boolean hostNameCached;
-
private final WorkspaceList workspaceList = new WorkspaceList();
public Computer(Node node) {
- assert node.getNumExecutors()!=0 : "Computer created with 0 executors";
+ assert node.getNumExecutors() != 0 : "Computer created with 0 executors";
setNode(node);
}
@@ -152,11 +143,12 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
* This is where the log from the remote agent goes.
*/
protected File getLogFile() {
- return new File(Hudson.getInstance().getRootDir(),"slave-"+nodeName+".log");
+ return new File(Hudson.getInstance().getRootDir(), "slave-" + nodeName + ".log");
}
/**
- * Gets the object that coordinates the workspace allocation on this computer.
+ * Gets the object that coordinates the workspace allocation on this
+ * computer.
*/
public WorkspaceList getWorkspaceList() {
return workspaceList;
@@ -189,11 +181,10 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
}
/**
- * If the computer was offline (either temporarily or not),
- * this method will return the cause.
+ * If the computer was offline (either temporarily or not), this method will
+ * return the cause.
*
- * @return
- * null if the system was put offline without given a cause.
+ * @return null if the system was put offline without given a cause.
*/
@Exported
public OfflineCause getOfflineCause() {
@@ -203,16 +194,14 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
/**
* Gets the channel that can be used to run a program on this computer.
*
- * @return
- * never null when {@link #isOffline()}==false.
+ * @return never null when {@link #isOffline()}==false.
*/
public abstract VirtualChannel getChannel();
/**
* Gets the default charset of this computer.
*
- * @return
- * never null when {@link #isOffline()}==false.
+ * @return never null when {@link #isOffline()}==false.
*/
public abstract Charset getDefaultCharset();
@@ -224,122 +213,123 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
/**
* If {@link #getChannel()}==null, attempts to relaunch the slave agent.
*/
- public abstract void doLaunchSlaveAgent( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException;
+ public abstract void doLaunchSlaveAgent(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException;
/**
- * @deprecated since 2009-01-06. Use {@link #connect(boolean)}
+ * @deprecated since 2009-01-06. Use {@link #connect(boolean)}
*/
public final void launch() {
connect(true);
}
/**
- * Do the same as {@link #doLaunchSlaveAgent(StaplerRequest, StaplerResponse)}
- * but outside the context of serving a request.
+ * Do the same as
+ * {@link #doLaunchSlaveAgent(StaplerRequest, StaplerResponse)} but outside
+ * the context of serving a request.
*
- * <p>
- * If already connected or if this computer doesn't support proactive launching, no-op.
- * This method may return immediately
- * while the launch operation happens asynchronously.
+ * <p> If already connected or if this computer doesn't support proactive
+ * launching, no-op. This method may return immediately while the launch
+ * operation happens asynchronously.
*
* @see #disconnect()
*
- * @param forceReconnect
- * If true and a connect activity is already in progress, it will be cancelled and
- * the new one will be started. If false, and a connect activity is already in progress, this method
- * will do nothing and just return the pending connection operation.
- * @return
- * A {@link Future} representing pending completion of the task. The 'completion' includes
- * both a successful completion and a non-successful completion (such distinction typically doesn't
- * make much sense because as soon as {@link Computer} is connected it can be disconnected by some other threads.)
+ * @param forceReconnect If true and a connect activity is already in
+ * progress, it will be cancelled and the new one will be started. If false,
+ * and a connect activity is already in progress, this method will do
+ * nothing and just return the pending connection operation.
+ * @return A {@link Future} representing pending completion of the task. The
+ * 'completion' includes both a successful completion and a non-successful
+ * completion (such distinction typically doesn't make much sense because as
+ * soon as {@link Computer} is connected it can be disconnected by some
+ * other threads.)
*/
public final Future<?> connect(boolean forceReconnect) {
- connectTime = System.currentTimeMillis();
- return _connect(forceReconnect);
+ connectTime = System.currentTimeMillis();
+ return _connect(forceReconnect);
}
-
+
/**
- * Allows implementing-classes to provide an implementation for the connect method.
+ * Allows implementing-classes to provide an implementation for the connect
+ * method.
*
- * <p>
- * If already connected or if this computer doesn't support proactive launching, no-op.
- * This method may return immediately
- * while the launch operation happens asynchronously.
+ * <p> If already connected or if this computer doesn't support proactive
+ * launching, no-op. This method may return immediately while the launch
+ * operation happens asynchronously.
*
* @see #disconnect()
*
- * @param forceReconnect
- * If true and a connect activity is already in progress, it will be cancelled and
- * the new one will be started. If false, and a connect activity is already in progress, this method
- * will do nothing and just return the pending connection operation.
- * @return
- * A {@link Future} representing pending completion of the task. The 'completion' includes
- * both a successful completion and a non-successful completion (such distinction typically doesn't
- * make much sense because as soon as {@link Computer} is connected it can be disconnected by some other threads.)
+ * @param forceReconnect If true and a connect activity is already in
+ * progress, it will be cancelled and the new one will be started. If false,
+ * and a connect activity is already in progress, this method will do
+ * nothing and just return the pending connection operation.
+ * @return A {@link Future} representing pending completion of the task. The
+ * 'completion' includes both a successful completion and a non-successful
+ * completion (such distinction typically doesn't make much sense because as
+ * soon as {@link Computer} is connected it can be disconnected by some
+ * other threads.)
*/
protected abstract Future<?> _connect(boolean forceReconnect);
/**
* CLI command to reconnect this node.
*/
- @CLIMethod(name="connect-node")
- public void cliConnect(@Option(name="-f",usage="Cancel any currently pending connect operation and retry from scratch") boolean force) throws ExecutionException, InterruptedException {
+ @CLIMethod(name = "connect-node")
+ public void cliConnect(@Option(name = "-f", usage = "Cancel any currently pending connect operation and retry from scratch") boolean force) throws ExecutionException, InterruptedException {
checkPermission(Hudson.ADMINISTER);
connect(force).get();
}
/**
* Gets the time (since epoch) when this computer connected.
- *
+ *
* @return The time in ms since epoch when this computer last connected.
*/
public final long getConnectTime() {
- return connectTime;
+ return connectTime;
}
-
+
/**
* Disconnect this computer.
*
- * If this is the master, no-op. This method may return immediately
- * while the launch operation happens asynchronously.
+ * If this is the master, no-op. This method may return immediately while
+ * the launch operation happens asynchronously.
*
- * @param cause
- * Object that identifies the reason the node was disconnected.
+ * @param cause Object that identifies the reason the node was disconnected.
*
- * @return
- * {@link Future} to track the asynchronous disconnect operation.
+ * @return {@link Future} to track the asynchronous disconnect operation.
* @see #connect(boolean)
* @since 1.320
*/
public Future<?> disconnect(OfflineCause cause) {
offlineCause = cause;
- if (Util.isOverridden(Computer.class,getClass(),"disconnect"))
+ if (Util.isOverridden(Computer.class, getClass(), "disconnect")) {
return disconnect(); // legacy subtypes that extend disconnect().
-
- connectTime=0;
+ }
+ connectTime = 0;
return Futures.precomputed(null);
}
/**
* Equivalent to {@code disconnect(null)}
*
- * @deprecated as of 1.320.
- * Use {@link #disconnect(OfflineCause)} and specify the cause.
+ * @deprecated as of 1.320. Use {@link #disconnect(OfflineCause)} and
+ * specify the cause.
*/
public Future<?> disconnect() {
- if (Util.isOverridden(Computer.class,getClass(),"disconnect",OfflineCause.class))
- // if the subtype already derives disconnect(OfflineCause), delegate to it
+ if (Util.isOverridden(Computer.class, getClass(), "disconnect", OfflineCause.class)) // if the subtype already derives disconnect(OfflineCause), delegate to it
+ {
return disconnect(null);
+ }
- connectTime=0;
+ connectTime = 0;
return Futures.precomputed(null);
}
/**
* CLI command to disconnects this node.
*/
- @CLIMethod(name="disconnect-node")
- public void cliDisconnect(@Option(name="-m",usage="Record the note about why you are disconnecting this node") String cause) throws ExecutionException, InterruptedException {
+ @CLIMethod(name = "disconnect-node")
+ public void cliDisconnect(@Option(name = "-m", usage = "Record the note about why you are disconnecting this node") String cause) throws ExecutionException, InterruptedException {
checkPermission(Hudson.ADMINISTER);
disconnect(new ByCLI(cause)).get();
}
@@ -347,24 +337,23 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
/**
* CLI command to mark the node offline.
*/
- @CLIMethod(name="offline-node")
- public void cliOffline(@Option(name="-m",usage="Record the note about why you are disconnecting this node") String cause) throws ExecutionException, InterruptedException {
+ @CLIMethod(name = "offline-node")
+ public void cliOffline(@Option(name = "-m", usage = "Record the note about why you are disconnecting this node") String cause) throws ExecutionException, InterruptedException {
checkPermission(Hudson.ADMINISTER);
- setTemporarilyOffline(true,new ByCLI(cause));
+ setTemporarilyOffline(true, new ByCLI(cause));
}
- @CLIMethod(name="online-node")
+ @CLIMethod(name = "online-node")
public void cliOnline() throws ExecutionException, InterruptedException {
checkPermission(Hudson.ADMINISTER);
- setTemporarilyOffline(false,null);
+ setTemporarilyOffline(false, null);
}
/**
* Number of {@link Executor}s that are configured for this computer.
*
- * <p>
- * When this value is decreased, it is temporarily possible
- * for {@link #executors} to have a larger number than this.
+ * <p> When this value is decreased, it is temporarily possible for
+ * {@link #executors} to have a larger number than this.
*/
// ugly name to let EL access this
@Exported
@@ -382,13 +371,13 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
/**
* Returns the {@link Node} that this computer represents.
*
- * @return
- * null if the configuration has changed and the node is removed, yet the corresponding {@link Computer}
- * is not yet gone.
+ * @return null if the configuration has changed and the node is removed,
+ * yet the corresponding {@link Computer} is not yet gone.
*/
public Node getNode() {
- if(nodeName==null)
+ if (nodeName == null) {
return Hudson.getInstance();
+ }
return Hudson.getInstance().getNode(nodeName);
}
@@ -424,7 +413,7 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
@Exported
public boolean isOffline() {
- return temporarilyOffline || getChannel()==null;
+ return temporarilyOffline || getChannel() == null;
}
public final boolean isOnline() {
@@ -432,15 +421,17 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
}
/**
- * This method is called to determine whether manual launching of the slave is allowed at this point in time.
- * @return {@code true} if manual launching of the slave is allowed at this point in time.
+ * This method is called to determine whether manual launching of the slave
+ * is allowed at this point in time.
+ *
+ * @return {@code true} if manual launching of the slave is allowed at this
+ * point in time.
*/
@Exported
public boolean isManualLaunchAllowed() {
return getRetentionStrategy().isManualLaunchAllowed(this);
}
-
/**
* Is a {@link #connect(boolean)} operation in progress?
*/
@@ -448,8 +439,9 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
/**
* Returns true if this computer is supposed to be launched via JNLP.
- * @deprecated since 2008-05-18.
- * See {@linkplain #isLaunchSupported()} and {@linkplain ComputerLauncher}
+ *
+ * @deprecated since 2008-05-18. See {@linkplain #isLaunchSupported()} and
+ * {@linkplain ComputerLauncher}
*/
@Exported
@Deprecated
@@ -458,11 +450,11 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
}
/**
- * Returns true if this computer can be launched by Hudson proactively and automatically.
+ * Returns true if this computer can be launched by Hudson proactively and
+ * automatically.
*
- * <p>
- * For example, JNLP slaves return {@code false} from this, because the launch process
- * needs to be initiated from the slave side.
+ * <p> For example, JNLP slaves return {@code false} from this, because the
+ * launch process needs to be initiated from the slave side.
*/
@Exported
public boolean isLaunchSupported() {
@@ -472,15 +464,13 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
/**
* Returns true if this node is marked temporarily offline by the user.
*
- * <p>
- * In contrast, {@link #isOffline()} represents the actual online/offline
- * state. For example, this method may return false while {@link #isOffline()}
- * returns true if the slave agent failed to launch.
+ * <p> In contrast, {@link #isOffline()} represents the actual
+ * online/offline state. For example, this method may return false while
+ * {@link #isOffline()} returns true if the slave agent failed to launch.
*
- * @deprecated
- * You should almost always want {@link #isOffline()}.
- * This method is marked as deprecated to warn people when they
- * accidentally call this method.
+ * @deprecated You should almost always want {@link #isOffline()}. This
+ * method is marked as deprecated to warn people when they accidentally call
+ * this method.
*/
@Exported
public boolean isTemporarilyOffline() {
@@ -488,20 +478,19 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
}
/**
- * @deprecated as of 1.320.
- * Use {@link #setTemporarilyOffline(boolean, OfflineCause)}
+ * @deprecated as of 1.320. Use
+ * {@link #setTemporarilyOffline(boolean, OfflineCause)}
*/
public void setTemporarilyOffline(boolean temporarilyOffline) {
- setTemporarilyOffline(temporarilyOffline,null);
+ setTemporarilyOffline(temporarilyOffline, null);
}
/**
* Marks the computer as temporarily offline. This retains the underlying
* {@link Channel} connection, but prevent builds from executing.
*
- * @param cause
- * If the first argument is true, specify the reason why the node is being put
- * offline.
+ * @param cause If the first argument is true, specify the reason why the
+ * node is being put offline.
*/
public void setTemporarilyOffline(boolean temporarilyOffline, OfflineCause cause) {
offlineCause = temporarilyOffline ? cause : null;
@@ -515,17 +504,19 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
@Exported
public String getIcon() {
- if(isOffline())
+ if (isOffline()) {
return "computer-x.png";
- else
+ } else {
return "computer.png";
+ }
}
public String getIconAltText() {
- if(isOffline())
+ if (isOffline()) {
return "[offline]";
- else
+ } else {
return "[online]";
+ }
}
@Exported
@@ -538,7 +529,7 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
}
public String getUrl() {
- return "computer/"+getDisplayName()+"/";
+ return "computer/" + getDisplayName() + "/";
}
/**
@@ -549,11 +540,12 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
}
public RunList getBuilds() {
- return new RunList(Hudson.getInstance().getAllItems(Job.class)).node(getNode());
+ return new RunList(Hudson.getInstance().getAllItems(Job.class)).node(getNode());
}
/**
* Returns jobs that running on current computer.
+ *
* @return List<AbstractProject>.
*/
@Exported
@@ -561,7 +553,7 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
List<AbstractProject> jobs = new ArrayList<AbstractProject>();
Queue queue = Hudson.getInstance().getQueue();
if (getTiedJobs() != null) {
- for (AbstractProject project : getTiedJobs()) {
+ for (AbstractProject project : getTiedJobs()) {
if (project.isBuilding() || queue.contains(project)) {
jobs.add(project);
}
@@ -575,11 +567,12 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
* configuration is updated.
*/
protected void setNode(Node node) {
- assert node!=null;
- if(node instanceof Slave)
+ assert node != null;
+ if (node instanceof Slave) {
this.nodeName = node.getNodeName();
- else
+ } else {
this.nodeName = null;
+ }
setNumExecutors(node.getNumExecutors());
@@ -589,33 +582,37 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
}
/**
- * Called by {@link Hudson#updateComputerList()} to notify {@link Computer} that it will be discarded.
+ * Called by {@link Hudson#updateComputerList()} to notify {@link Computer}
+ * that it will be discarded.
*/
protected void kill() {
setNumExecutors(0);
}
private synchronized void setNumExecutors(int n) {
- if(numExecutors==n) return; // no-op
-
- int diff = n-numExecutors;
+ if (numExecutors == n) {
+ return; // no-op
+ }
+ int diff = n - numExecutors;
this.numExecutors = n;
- if(diff<0) {
+ if (diff < 0) {
// send signal to all idle executors to potentially kill them off
- for( Executor e : executors )
- if(e.isIdle())
+ for (Executor e : executors) {
+ if (e.isIdle()) {
e.interrupt();
+ }
+ }
} else {
// if the number is increased, add new ones
- while(executors.size()<numExecutors) {
+ while (executors.size() < numExecutors) {
Executor e = new Executor(this, executors.size());
e.start();
executors.add(e);
}
}
}
-
+
/**
* @since 2.1.0
*/
@@ -624,24 +621,27 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
}
/**
- * Returns the number of idle {@link Executor}s that can start working immediately.
+ * Returns the number of idle {@link Executor}s that can start working
+ * immediately.
*/
public int countIdle() {
int n = 0;
for (Executor e : executors) {
- if(e.isIdle())
+ if (e.isIdle()) {
n++;
+ }
}
return n;
}
/**
- * Returns the number of {@link Executor}s that are doing some work right now.
+ * Returns the number of {@link Executor}s that are doing some work right
+ * now.
*/
public final int countBusy() {
- return countExecutors()-countIdle();
+ return countExecutors() - countIdle();
}
-
+
/**
* @since 2.1.0
*/
@@ -650,15 +650,15 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
}
/**
- * Returns the current size of the executor pool for this computer.
- * This number may temporarily differ from {@link #getNumExecutors()} if there
- * are busy tasks when the configured size is decreased. OneOffExecutors are
+ * Returns the current size of the executor pool for this computer. This
+ * number may temporarily differ from {@link #getNumExecutors()} if there
+ * are busy tasks when the configured size is decreased. OneOffExecutors are
* not included in this count.
*/
public final int countExecutors() {
return executors.size();
}
-
+
/**
* @since 2.1.0
*/
@@ -673,7 +673,6 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
return oneOffExecutors.size();
}
-
/**
* Gets the read-only snapshot view of all {@link Executor}s.
*/
@@ -695,24 +694,25 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
*/
@Exported
public final boolean isIdle() {
- if (!oneOffExecutors.isEmpty())
+ if (!oneOffExecutors.isEmpty()) {
return false;
- for (Executor e : executors)
- if(!e.isIdle())
+ }
+ for (Executor e : executors) {
+ if (!e.isIdle()) {
return false;
+ }
+ }
return true;
}
/**
* Returns the time when this computer last became idle.
*
- * <p>
- * If this computer is already idle, the return value will point to the
+ * <p> If this computer is already idle, the return value will point to the
* time in the past since when this computer has been idle.
*
- * <p>
- * If this computer is busy, the return value will point to the
- * time in the future where this computer will be expected to become free.
+ * <p> If this computer is busy, the return value will point to the time in
+ * the future where this computer will be expected to become free.
*/
public final long getIdleStartMilliseconds() {
long firstIdle = Long.MIN_VALUE;
@@ -737,12 +737,14 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
}
/**
- * Called by {@link Executor} to kill excessive executors from this computer.
+ * Called by {@link Executor} to kill excessive executors from this
+ * computer.
*/
/*package*/ synchronized void removeExecutor(Executor e) {
executors.remove(e);
- if(!isAlive())
+ if (!isAlive()) {
Hudson.getInstance().removeComputer(this);
+ }
}
/**
@@ -752,9 +754,11 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
* the administrator yanks it out, so that we can see why it died.
*/
private boolean isAlive() {
- for (Executor e : executors)
- if (e.isAlive())
+ for (Executor e : executors) {
+ if (e.isAlive()) {
return true;
+ }
+ }
return false;
}
@@ -768,48 +772,47 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
}
public String getSearchUrl() {
- return "computer/"+nodeName;
+ return "computer/" + nodeName;
}
/**
* {@link RetentionStrategy} associated with this computer.
*
- * @return
- * never null. This method return {@code RetentionStrategy<? super T>} where
- * {@code T=this.getClass()}.
+ * @return never null. This method return
+ * {@code RetentionStrategy<? super T>} where {@code T=this.getClass()}.
*/
public abstract RetentionStrategy getRetentionStrategy();
/**
* Expose monitoring data for the remote API.
*/
- @Exported(inline=true)
- public Map<String/*monitor name*/,Object> getMonitorData() {
- Map<String,Object> r = new HashMap<String, Object>();
- for (NodeMonitor monitor : NodeMonitor.getAll())
- r.put(monitor.getClass().getName(),monitor.data(this));
+ @Exported(inline = true)
+ public Map<String/*monitor name*/, Object> getMonitorData() {
+ Map<String, Object> r = new HashMap<String, Object>();
+ for (NodeMonitor monitor : NodeMonitor.getAll()) {
+ r.put(monitor.getClass().getName(), monitor.data(this));
+ }
return r;
}
/**
- * Gets the system properties of the JVM on this computer.
- * If this is the master, it returns the system property of the master computer.
+ * Gets the system properties of the JVM on this computer. If this is the
+ * master, it returns the system property of the master computer.
*/
- public Map<Object,Object> getSystemProperties() throws IOException, InterruptedException {
+ public Map<Object, Object> getSystemProperties() throws IOException, InterruptedException {
return RemotingDiagnostics.getSystemProperties(getChannel());
}
/**
- * @deprecated as of 1.292
- * Use {@link #getEnvironment()} instead.
+ * @deprecated as of 1.292 Use {@link #getEnvironment()} instead.
*/
- public Map<String,String> getEnvVars() throws IOException, InterruptedException {
+ public Map<String, String> getEnvVars() throws IOException, InterruptedException {
return getEnvironment();
}
/**
- * Gets the environment variables of the JVM on this computer.
- * If this is the master, it returns the system property of the master computer.
+ * Gets the environment variables of the JVM on this computer. If this is
+ * the master, it returns the system property of the master computer.
*/
public EnvVars getEnvironment() throws IOException, InterruptedException {
return EnvVars.getRemote(getChannel());
@@ -817,10 +820,10 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
/**
* Gets the thread dump of the slave JVM.
- * @return
- * key is the thread name, and the value is the pre-formatted dump.
+ *
+ * @return key is the thread name, and the value is the pre-formatted dump.
*/
- public Map<String,String> getThreadDump() throws IOException, InterruptedException {
+ public Map<String, String> getThreadDump() throws IOException, InterruptedException {
return RemotingDiagnostics.getThreadDump(getChannel());
}
@@ -828,48 +831,51 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
* Obtains the heap dump.
*/
public HeapDump getHeapDump() throws IOException {
- return new HeapDump(this,getChannel());
+ return new HeapDump(this, getChannel());
}
/**
- * This method tries to compute the name of the host that's reachable by all the other nodes.
+ * This method tries to compute the name of the host that's reachable by all
+ * the other nodes.
*
- * <p>
- * Since it's possible that the slave is not reachable from the master (it may be behind a firewall,
- * connecting to master via JNLP), this method may return null.
+ * <p> Since it's possible that the slave is not reachable from the master
+ * (it may be behind a firewall, connecting to master via JNLP), this method
+ * may return null.
*
- * It's surprisingly tricky for a machine to know a name that other systems can get to,
- * especially between things like DNS search suffix, the hosts file, and YP.
+ * It's surprisingly tricky for a machine to know a name that other systems
+ * can get to, especially between things like DNS search suffix, the hosts
+ * file, and YP.
*
- * <p>
- * So the technique here is to compute possible interfaces and names on the slave,
- * then try to ping them from the master, and pick the one that worked.
+ * <p> So the technique here is to compute possible interfaces and names on
+ * the slave, then try to ping them from the master, and pick the one that
+ * worked.
*
- * <p>
- * The computation may take some time, so it employs caching to make the successive lookups faster.
+ * <p> The computation may take some time, so it employs caching to make the
+ * successive lookups faster.
*
* @since 1.300
- * @return
- * null if the host name cannot be computed (for example because this computer is offline,
- * because the slave is behind the firewall, etc.)
+ * @return null if the host name cannot be computed (for example because
+ * this computer is offline, because the slave is behind the firewall, etc.)
*/
public String getHostName() throws IOException, InterruptedException {
- if(hostNameCached)
- // in the worst case we end up having multiple threads computing the host name simultaneously, but that's not harmful, just wasteful.
+ if (hostNameCached) // in the worst case we end up having multiple threads computing the host name simultaneously, but that's not harmful, just wasteful.
+ {
return cachedHostName;
+ }
VirtualChannel channel = getChannel();
- if(channel==null) return null; // can't compute right now
-
- for( String address : channel.call(new ListPossibleNames())) {
+ if (channel == null) {
+ return null; // can't compute right now
+ }
+ for (String address : channel.call(new ListPossibleNames())) {
try {
InetAddress ia = InetAddress.getByName(address);
- if(!(ia instanceof Inet4Address)) {
- LOGGER.fine(address+" is not an IPv4 address");
+ if (!(ia instanceof Inet4Address)) {
+ LOGGER.fine(address + " is not an IPv4 address");
continue;
}
- if(!ComputerPinger.checkIsReachable(ia, 3)) {
- LOGGER.fine(address+" didn't respond to ping");
+ if (!ComputerPinger.checkIsReachable(ia, 3)) {
+ LOGGER.fine(address + " didn't respond to ping");
continue;
}
cachedHostName = ia.getCanonicalHostName();
@@ -877,7 +883,7 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
return cachedHostName;
} catch (IOException e) {
// if a given name fails to parse on this host, we get this error
- LOGGER.log(Level.FINE, "Failed to parse "+address,e);
+ LOGGER.log(Level.FINE, "Failed to parse " + address, e);
}
}
@@ -901,28 +907,29 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
oneOffExecutors.remove(e);
}
- private static class ListPossibleNames implements Callable<List<String>,IOException> {
+ private static class ListPossibleNames implements Callable<List<String>, IOException> {
+
public List<String> call() throws IOException {
List<String> names = new ArrayList<String>();
Enumeration<NetworkInterface> nis = NetworkInterface.getNetworkInterfaces();
while (nis.hasMoreElements()) {
- NetworkInterface ni = nis.nextElement();
- LOGGER.fine("Listing up IP addresses for "+ni.getDisplayName());
+ NetworkInterface ni = nis.nextElement();
+ LOGGER.fine("Listing up IP addresses for " + ni.getDisplayName());
Enumeration<InetAddress> e = ni.getInetAddresses();
while (e.hasMoreElements()) {
- InetAddress ia = e.nextElement();
- if(ia.isLoopbackAddress()) {
- LOGGER.fine(ia+" is a loopback address");
+ InetAddress ia = e.nextElement();
+ if (ia.isLoopbackAddress()) {
+ LOGGER.fine(ia + " is a loopback address");
continue;
}
- if(!(ia instanceof Inet4Address)) {
- LOGGER.fine(ia+" is not an IPv4 address");
+ if (!(ia instanceof Inet4Address)) {
+ LOGGER.fine(ia + " is not an IPv4 address");
continue;
}
- LOGGER.fine(ia+" is a viable candidate");
+ LOGGER.fine(ia + " is a viable candidate");
names.add(ia.getHostAddress());
}
}
@@ -931,13 +938,13 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
private static final long serialVersionUID = 1L;
}
- private static class GetFallbackName implements Callable<String,IOException> {
+ private static class GetFallbackName implements Callable<String, IOException> {
+
public String call() throws IOException {
return System.getProperty("host.name");
}
private static final long serialVersionUID = 1L;
}
-
public static final ExecutorService threadPoolForRemoting = Executors.newCachedThreadPool(new ExceptionCatchingThreadFactory(new DaemonThreadFactory()));
//
@@ -945,27 +952,29 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
// UI
//
//
- public void doRssAll( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException {
+ public void doRssAll(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
rss(req, rsp, " all builds", getBuilds());
}
- public void doRssFailed( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException {
+
+ public void doRssFailed(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
rss(req, rsp, " failed builds", getBuilds().failureOnly());
}
+
private void rss(StaplerRequest req, StaplerResponse rsp, String suffix, RunList runs) throws IOException, ServletException {
- RSS.forwardToRss(getDisplayName()+ suffix, getUrl(),
- runs.newBuilds(), Run.FEED_ADAPTER, req, rsp );
+ RSS.forwardToRss(getDisplayName() + suffix, getUrl(),
+ runs.newBuilds(), Run.FEED_ADAPTER, req, rsp);
}
public HttpResponse doToggleOffline(@QueryParameter String offlineMessage) throws IOException, ServletException {
checkPermission(Hudson.ADMINISTER);
- if(!temporarilyOffline) {
+ if (!temporarilyOffline) {
offlineMessage = Util.fixEmptyAndTrim(offlineMessage);
setTemporarilyOffline(!temporarilyOffline,
OfflineCause.create(hudson.slaves.Messages._SlaveComputer_DisconnectedBy(
- HudsonSecurityManager.getAuthentication().getName(),
- offlineMessage!=null ? " : " + offlineMessage : "")));
+ HudsonSecurityManager.getAuthentication().getName(),
+ offlineMessage != null ? " : " + offlineMessage : "")));
} else {
- setTemporarilyOffline(!temporarilyOffline,null);
+ setTemporarilyOffline(!temporarilyOffline, null);
}
return HttpResponses.redirectToDot();
}
@@ -977,7 +986,7 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
/**
* Dumps the contents of the export table.
*/
- public void doDumpExportTable( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException, InterruptedException {
+ public void doDumpExportTable(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException, InterruptedException {
// this is a debug probe and may expose sensitive information
checkPermission(Hudson.ADMINISTER);
@@ -986,7 +995,7 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
VirtualChannel vc = getChannel();
if (vc instanceof Channel) {
w.println("Master to slave");
- ((Channel)vc).dumpExportTable(w);
+ ((Channel) vc).dumpExportTable(w);
w.flush(); // flush here once so that even if the dump from the slave fails, the client gets some useful info
w.println("\n\n\nSlave to master");
@@ -997,7 +1006,8 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
w.close();
}
- private static final class DumpExportTableTask implements Callable<String,IOException> {
+ private static final class DumpExportTableTask implements Callable<String, IOException> {
+
public String call() throws IOException {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
@@ -1008,8 +1018,7 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
}
/**
- * For system diagnostics.
- * Run arbitrary script.
+ * For system diagnostics. Run arbitrary script.
*/
public void doScript(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
_doScript(req, rsp, "_script.jelly");
@@ -1022,7 +1031,7 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
_doScript(req, rsp, "_scriptText.jelly");
}
- protected void _doScript( StaplerRequest req, StaplerResponse rsp, String view) throws IOException, ServletException {
+ protected void _doScript(StaplerRequest req, StaplerResponse rsp, String view) throws IOException, ServletException {
// ability to run arbitrary script is dangerous,
// so tie it to the admin access
checkPermission(Hudson.ADMINISTER);
@@ -1039,13 +1048,13 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
}
}
- req.getView(this,view).forward(req,rsp);
+ req.getView(this, view).forward(req, rsp);
}
/**
* Accepts the update to the node configuration.
*/
- public void doConfigSubmit( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException, FormException {
+ public void doConfigSubmit(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException, FormException {
checkPermission(CONFIGURE);
final Hudson app = Hudson.getInstance();
@@ -1056,23 +1065,23 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
synchronized (app) {
List<Node> nodes = new ArrayList<Node>(app.getNodes());
int i = nodes.indexOf(getNode());
- if(i<0) {
- sendError("This slave appears to be removed while you were editing the configuration",req,rsp);
+ if (i < 0) {
+ sendError("This slave appears to be removed while you were editing the configuration", req, rsp);
return;
}
- nodes.set(i,result);
+ nodes.set(i, result);
app.setNodes(nodes);
}
// take the user back to the slave top page.
- rsp.sendRedirect2("../"+result.getNodeName()+'/');
+ rsp.sendRedirect2("../" + result.getNodeName() + '/');
}
/**
* Really deletes the slave.
*/
- @CLIMethod(name="delete-node")
+ @CLIMethod(name = "delete-node")
public HttpResponse doDoDelete() throws IOException {
checkPermission(DELETE);
Hudson.getInstance().removeNode(getNode());
@@ -1080,8 +1089,9 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
}
/**
- * Delete the slave.
- * If request have parameter 'deleteMode' than deleting performs in according with this parameter.
+ * Delete the slave. If request have parameter 'deleteMode' than deleting
+ * performs in according with this parameter.
+ *
* @param req StaplerRequest
* @return HttpResponse
* @throws IOException if any.
@@ -1106,17 +1116,16 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
return new HttpRedirect("..");
}
-
/**
* Handles incremental log.
*/
- public void doProgressiveLog( StaplerRequest req, StaplerResponse rsp) throws IOException {
- getLogText().doProgressText(req,rsp);
+ public void doProgressiveLog(StaplerRequest req, StaplerResponse rsp) throws IOException {
+ getLogText().doProgressText(req, rsp);
}
/**
- * Gets the current {@link Computer} that the build is running.
- * This method only works when called during a build, such as by
+ * Gets the current {@link Computer} that the build is running. This method
+ * only works when called during a build, such as by
* {@link Publisher}, {@link BuildWrapper}, etc.
*/
public static Computer currentComputer() {
@@ -1126,21 +1135,20 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
}
/**
- * Returns {@code true} if the computer is accepting tasks. Needed to allow slaves programmatic suspension of task
- * scheduling that does not overlap with being offline.
+ * Returns {@code true} if the computer is accepting tasks. Needed to allow
+ * slaves programmatic suspension of task scheduling that does not overlap
+ * with being offline.
*
* @return {@code true} if the computer is accepting tasks
*/
public boolean isAcceptingTasks() {
return true;
}
-
- public static final PermissionGroup PERMISSIONS = new PermissionGroup(Computer.class,Messages._Computer_Permissions_Title());
+ public static final PermissionGroup PERMISSIONS = new PermissionGroup(Computer.class, Messages._Computer_Permissions_Title());
/**
* Permission to configure slaves.
*/
- public static final Permission CONFIGURE = new Permission(PERMISSIONS,"Configure", Messages._Computer_ConfigurePermission_Description(), Permission.CONFIGURE);
- public static final Permission DELETE = new Permission(PERMISSIONS,"Delete", Messages._Computer_DeletePermission_Description(), Permission.DELETE);
-
+ public static final Permission CONFIGURE = new Permission(PERMISSIONS, "Configure", Messages._Computer_ConfigurePermission_Description(), Permission.CONFIGURE);
+ public static final Permission DELETE = new Permission(PERMISSIONS, "Delete", Messages._Computer_DeletePermission_Description(), Permission.DELETE);
private static final Logger LOGGER = Logger.getLogger(Computer.class.getName());
}
diff --git a/hudson-core/src/main/java/hudson/model/ComputerPinger.java b/hudson-core/src/main/java/hudson/model/ComputerPinger.java
index d2c3f14..878cbf5 100644
--- a/hudson-core/src/main/java/hudson/model/ComputerPinger.java
+++ b/hudson-core/src/main/java/hudson/model/ComputerPinger.java
@@ -8,7 +8,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- *
+ *
*
*******************************************************************************/
@@ -28,10 +28,11 @@ import java.util.logging.Logger;
* @since 1.378
*/
public abstract class ComputerPinger implements ExtensionPoint {
+
/**
* Is the specified address reachable?
*
- * @param ia The address to check.
+ * @param ia The address to check.
* @param timeout Timeout in seconds.
*/
public abstract boolean isReachable(InetAddress ia, int timeout) throws IOException;
@@ -46,7 +47,7 @@ public abstract class ComputerPinger implements ExtensionPoint {
/**
* Is this computer reachable via the given address?
*
- * @param ia The address to check.
+ * @param ia The address to check.
* @param timeout Timeout in seconds.
*/
public static boolean checkIsReachable(InetAddress ia, int timeout) throws IOException {
@@ -62,18 +63,18 @@ public abstract class ComputerPinger implements ExtensionPoint {
return false;
}
-
+
/**
- * Default pinger - use Java built-in functionality. This doesn't always work,
- * a host may be reachable even if this returns false.
+ * Default pinger - use Java built-in functionality. This doesn't always
+ * work, a host may be reachable even if this returns false.
*/
@Extension
public static class BuiltInComputerPinger extends ComputerPinger {
+
@Override
public boolean isReachable(InetAddress ia, int timeout) throws IOException {
return ia.isReachable(timeout * 1000);
}
}
-
private static final Logger LOGGER = Logger.getLogger(ComputerPinger.class.getName());
}
diff --git a/hudson-core/src/main/java/hudson/model/ComputerSet.java b/hudson-core/src/main/java/hudson/model/ComputerSet.java
index 5286c7c..3a70d68 100644
--- a/hudson-core/src/main/java/hudson/model/ComputerSet.java
+++ b/hudson-core/src/main/java/hudson/model/ComputerSet.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
-*
-* Kohsuke Kawaguchi, Stephen Connolly, Thomas J. Black
- *
+ * Contributors:
+ *
+ * Kohsuke Kawaguchi, Stephen Connolly, Thomas J. Black
+ *
*
*******************************************************************************/
@@ -44,14 +44,14 @@ import java.util.logging.Level;
import java.util.logging.Logger;
/**
- * Serves as the top of {@link Computer}s in the URL hierarchy.
- * <p>
- * Getter methods are prefixed with '_' to avoid collision with computer names.
+ * Serves as the top of {@link Computer}s in the URL hierarchy. <p> Getter
+ * methods are prefixed with '_' to avoid collision with computer names.
*
* @author Kohsuke Kawaguchi
*/
@ExportedBean
public final class ComputerSet extends AbstractModelObject {
+
/**
* This is the owner that persists {@link #monitors}.
*/
@@ -61,9 +61,7 @@ public final class ComputerSet extends AbstractModelObject {
SaveableListener.fireOnChange(this, getConfigFile());
}
};
-
- private static final DescribableList<NodeMonitor,Descriptor<NodeMonitor>> monitors
- = new DescribableList<NodeMonitor, Descriptor<NodeMonitor>>(MONITORS_OWNER);
+ private static final DescribableList<NodeMonitor, Descriptor<NodeMonitor>> monitors = new DescribableList<NodeMonitor, Descriptor<NodeMonitor>>(MONITORS_OWNER);
@Exported
public String getDisplayName() {
@@ -71,14 +69,13 @@ public final class ComputerSet extends AbstractModelObject {
}
/**
- * @deprecated as of 1.301
- * Use {@link #getMonitors()}.
+ * @deprecated as of 1.301 Use {@link #getMonitors()}.
*/
public static List<NodeMonitor> get_monitors() {
return monitors.toList();
}
- @Exported(name="computer",inline=true)
+ @Exported(name = "computer", inline = true)
public Computer[] get_all() {
return Hudson.getInstance().getComputers();
}
@@ -86,22 +83,24 @@ public final class ComputerSet extends AbstractModelObject {
/**
* Exposing {@link NodeMonitor#all()} for Jelly binding.
*/
- public DescriptorExtensionList<NodeMonitor,Descriptor<NodeMonitor>> getNodeMonitorDescriptors() {
+ public DescriptorExtensionList<NodeMonitor, Descriptor<NodeMonitor>> getNodeMonitorDescriptors() {
return NodeMonitor.all();
}
- public static DescribableList<NodeMonitor,Descriptor<NodeMonitor>> getMonitors() {
+ public static DescribableList<NodeMonitor, Descriptor<NodeMonitor>> getMonitors() {
return monitors;
}
/**
- * Returns a subset pf {@link #getMonitors()} that are {@linkplain NodeMonitor#isIgnored() not ignored}.
+ * Returns a subset pf {@link #getMonitors()} that are
+ * {@linkplain NodeMonitor#isIgnored() not ignored}.
*/
- public static Map<Descriptor<NodeMonitor>,NodeMonitor> getNonIgnoredMonitors() {
- Map<Descriptor<NodeMonitor>,NodeMonitor> r = new HashMap<Descriptor<NodeMonitor>, NodeMonitor>();
+ public static Map<Descriptor<NodeMonitor>, NodeMonitor> getNonIgnoredMonitors() {
+ Map<Descriptor<NodeMonitor>, NodeMonitor> r = new HashMap<Descriptor<NodeMonitor>, NodeMonitor>();
for (NodeMonitor m : monitors) {
- if(!m.isIgnored())
- r.put(m.getDescriptor(),m);
+ if (!m.isIgnored()) {
+ r.put(m.getDescriptor(), m);
+ }
}
return r;
}
@@ -124,41 +123,46 @@ public final class ComputerSet extends AbstractModelObject {
}
/**
- * Number of total {@link Executor}s that belong to this label that are functioning.
- * <p>
- * This excludes executors that belong to offline nodes.
+ * Number of total {@link Executor}s that belong to this label that are
+ * functioning. <p> This excludes executors that belong to offline nodes.
*/
@Exported
public int getTotalExecutors() {
- int r=0;
+ int r = 0;
for (Computer c : get_all()) {
- if(c.isOnline())
+ if (c.isOnline()) {
r += c.countExecutors();
+ }
}
return r;
}
/**
- * Number of busy {@link Executor}s that are carrying out some work right now.
+ * Number of busy {@link Executor}s that are carrying out some work right
+ * now.
*/
@Exported
public int getBusyExecutors() {
- int r=0;
+ int r = 0;
for (Computer c : get_all()) {
- if(c.isOnline())
+ if (c.isOnline()) {
r += c.countBusy();
+ }
}
return r;
}
/**
- * {@code getTotalExecutors()-getBusyExecutors()}, plus executors that are being brought online.
+ * {@code getTotalExecutors()-getBusyExecutors()}, plus executors that are
+ * being brought online.
*/
public int getIdleExecutors() {
- int r=0;
- for (Computer c : get_all())
- if(c.isOnline() || c.isConnecting())
+ int r = 0;
+ for (Computer c : get_all()) {
+ if (c.isOnline() || c.isConnecting()) {
r += c.countIdle();
+ }
+ }
return r;
}
@@ -173,9 +177,10 @@ public final class ComputerSet extends AbstractModelObject {
public void do_launchAll(StaplerRequest req, StaplerResponse rsp) throws IOException {
Hudson.getInstance().checkPermission(Hudson.ADMINISTER);
- for(Computer c : get_all()) {
- if(c.isLaunchSupported())
+ for (Computer c : get_all()) {
+ if (c.isLaunchSupported()) {
c.connect(true);
+ }
}
rsp.sendRedirect(".");
}
@@ -183,11 +188,12 @@ public final class ComputerSet extends AbstractModelObject {
/**
* Triggers the schedule update now.
*
- * TODO: ajax on the client side to wait until the update completion might be nice.
+ * TODO: ajax on the client side to wait until the update completion might
+ * be nice.
*/
- public void doUpdateNow( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException {
+ public void doUpdateNow(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
Hudson.getInstance().checkPermission(Hudson.ADMINISTER);
-
+
for (NodeMonitor nodeMonitor : NodeMonitor.getAll()) {
Thread t = nodeMonitor.triggerUpdate();
t.setName(nodeMonitor.getColumnCaption());
@@ -198,53 +204,54 @@ public final class ComputerSet extends AbstractModelObject {
/**
* First check point in creating a new slave.
*/
- public synchronized void doCreateItem( StaplerRequest req, StaplerResponse rsp,
- @QueryParameter String name, @QueryParameter String mode,
- @QueryParameter String from ) throws IOException, ServletException {
+ public synchronized void doCreateItem(StaplerRequest req, StaplerResponse rsp,
+ @QueryParameter String name, @QueryParameter String mode,
+ @QueryParameter String from) throws IOException, ServletException {
final Hudson app = Hudson.getInstance();
app.checkPermission(Hudson.ADMINISTER); // TODO: new permission?
- if(mode!=null && mode.equals("copy")) {
+ if (mode != null && mode.equals("copy")) {
name = checkName(name);
Node src = app.getNode(from);
- if(src==null) {
+ if (src == null) {
rsp.setStatus(SC_BAD_REQUEST);
- if(Util.fixEmpty(from)==null)
- sendError(Messages.ComputerSet_SpecifySlaveToCopy(),req,rsp);
- else
- sendError(Messages.ComputerSet_NoSuchSlave(from),req,rsp);
+ if (Util.fixEmpty(from) == null) {
+ sendError(Messages.ComputerSet_SpecifySlaveToCopy(), req, rsp);
+ } else {
+ sendError(Messages.ComputerSet_NoSuchSlave(from), req, rsp);
+ }
return;
}
// copy through XStream
String xml = Hudson.XSTREAM.toXML(src);
- Node result = (Node)Hudson.XSTREAM.fromXML(xml);
+ Node result = (Node) Hudson.XSTREAM.fromXML(xml);
result.setNodeName(name);
result.holdOffLaunchUntilSave = true;
app.addNode(result);
// send the browser to the config page
- rsp.sendRedirect2(result.getNodeName()+"/configure");
+ rsp.sendRedirect2(result.getNodeName() + "/configure");
} else {
// proceed to step 2
- if(mode==null) {
+ if (mode == null) {
rsp.sendError(SC_BAD_REQUEST);
return;
}
NodeDescriptor d = NodeDescriptor.all().find(mode);
- d.handleNewNodePage(this,name,req,rsp);
+ d.handleNewNodePage(this, name, req, rsp);
}
}
/**
* Really creates a new slave.
*/
- public synchronized void doDoCreateItem( StaplerRequest req, StaplerResponse rsp,
- @QueryParameter String name,
- @QueryParameter String type ) throws IOException, ServletException, FormException {
+ public synchronized void doDoCreateItem(StaplerRequest req, StaplerResponse rsp,
+ @QueryParameter String name,
+ @QueryParameter String type) throws IOException, ServletException, FormException {
final Hudson app = Hudson.getInstance();
app.checkPermission(Hudson.ADMINISTER); // TODO: new permission?
checkName(name);
@@ -258,17 +265,20 @@ public final class ComputerSet extends AbstractModelObject {
/**
* Makes sure that the given name is good as a slave name.
+ *
* @return trimmed name if valid; throws ParseException if not
*/
public String checkName(String name) throws Failure {
- if(name==null)
+ if (name == null) {
throw new Failure("Query parameter 'name' is required");
+ }
name = name.trim();
Hudson.checkGoodName(name);
- if(Hudson.getInstance().getNode(name)!=null)
+ if (Hudson.getInstance().getNode(name) != null) {
throw new Failure(Messages.ComputerSet_SlaveAlreadyExists(name));
+ }
// looks good
return name;
@@ -280,9 +290,10 @@ public final class ComputerSet extends AbstractModelObject {
public FormValidation doCheckName(@QueryParameter String value) throws IOException, ServletException {
Hudson.getInstance().checkPermission(Hudson.ADMINISTER);
- if(Util.fixEmpty(value)==null)
+ if (Util.fixEmpty(value) == null) {
return FormValidation.ok();
-
+ }
+
try {
checkName(value);
return FormValidation.ok();
@@ -294,19 +305,21 @@ public final class ComputerSet extends AbstractModelObject {
/**
* Accepts submission from the configuration page.
*/
- public synchronized void doConfigSubmit( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException, FormException {
+ public synchronized void doConfigSubmit(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException, FormException {
BulkChange bc = new BulkChange(MONITORS_OWNER);
try {
Hudson.getInstance().checkPermission(Hudson.ADMINISTER);
- monitors.rebuild(req,req.getSubmittedForm(),getNodeMonitorDescriptors());
+ monitors.rebuild(req, req.getSubmittedForm(), getNodeMonitorDescriptors());
// add in the rest of instances are ignored instances
- for (Descriptor<NodeMonitor> d : NodeMonitor.all())
- if(monitors.get(d)==null) {
+ for (Descriptor<NodeMonitor> d : NodeMonitor.all()) {
+ if (monitors.get(d) == null) {
NodeMonitor i = createDefaultInstance(d, true);
- if(i!=null)
+ if (i != null) {
monitors.add(i);
+ }
}
+ }
rsp.sendRedirect2(".");
} finally {
bc.commit();
@@ -317,7 +330,7 @@ public final class ComputerSet extends AbstractModelObject {
* {@link NodeMonitor}s are persisted in this file.
*/
private static XmlFile getConfigFile() {
- return new XmlFile(new File(Hudson.getInstance().getRootDir(),"nodeMonitors.xml"));
+ return new XmlFile(new File(Hudson.getInstance().getRootDir(), "nodeMonitors.xml"));
}
public Api getApi() {
@@ -327,33 +340,34 @@ public final class ComputerSet extends AbstractModelObject {
/**
* Just to force the execution of the static initializer.
*/
- public static void initialize() {}
-
+ public static void initialize() {
+ }
private static final Logger LOGGER = Logger.getLogger(ComputerSet.class.getName());
static {
try {
- DescribableList<NodeMonitor,Descriptor<NodeMonitor>> r
- = new DescribableList<NodeMonitor, Descriptor<NodeMonitor>>(Saveable.NOOP);
+ DescribableList<NodeMonitor, Descriptor<NodeMonitor>> r = new DescribableList<NodeMonitor, Descriptor<NodeMonitor>>(Saveable.NOOP);
// load persisted monitors
XmlFile xf = getConfigFile();
- if(xf.exists()) {
- DescribableList<NodeMonitor,Descriptor<NodeMonitor>> persisted =
- (DescribableList<NodeMonitor,Descriptor<NodeMonitor>>) xf.read();
+ if (xf.exists()) {
+ DescribableList<NodeMonitor, Descriptor<NodeMonitor>> persisted =
+ (DescribableList<NodeMonitor, Descriptor<NodeMonitor>>) xf.read();
r.replaceBy(persisted.toList());
}
// if we have any new monitors, let's add them
- for (Descriptor<NodeMonitor> d : NodeMonitor.all())
- if(r.get(d)==null) {
- NodeMonitor i = createDefaultInstance(d,false);
- if(i!=null)
+ for (Descriptor<NodeMonitor> d : NodeMonitor.all()) {
+ if (r.get(d) == null) {
+ NodeMonitor i = createDefaultInstance(d, false);
+ if (i != null) {
r.add(i);
+ }
}
+ }
monitors.replaceBy(r.toList());
} catch (IOException e) {
- LOGGER.log(Level.WARNING, "Failed to instanciate NodeMonitors",e);
+ LOGGER.log(Level.WARNING, "Failed to instanciate NodeMonitors", e);
}
}
@@ -363,9 +377,9 @@ public final class ComputerSet extends AbstractModelObject {
nm.setIgnored(ignored);
return nm;
} catch (InstantiationException e) {
- LOGGER.log(Level.SEVERE, "Failed to instanciate "+d.clazz,e);
+ LOGGER.log(Level.SEVERE, "Failed to instanciate " + d.clazz, e);
} catch (IllegalAccessException e) {
- LOGGER.log(Level.SEVERE, "Failed to instanciate "+d.clazz,e);
+ LOGGER.log(Level.SEVERE, "Failed to instanciate " + d.clazz, e);
}
return null;
}
diff --git a/hudson-core/src/main/java/hudson/model/DependecyDeclarer.java b/hudson-core/src/main/java/hudson/model/DependecyDeclarer.java
index e1cb56d..9beefe8 100644
--- a/hudson-core/src/main/java/hudson/model/DependecyDeclarer.java
+++ b/hudson-core/src/main/java/hudson/model/DependecyDeclarer.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
-*
-* Kohsuke Kawaguchi
- *
+ * Contributors:
+ *
+ * Kohsuke Kawaguchi
+ *
*
*******************************************************************************/
@@ -21,13 +21,12 @@ import hudson.tasks.Builder;
import hudson.tasks.Publisher;
/**
- * Marker interface for those {@link BuildStep}s that can participate
- * in the dependency graph computation process.
+ * Marker interface for those {@link BuildStep}s that can participate in the
+ * dependency graph computation process.
*
- * <p>
- * {@link Publisher}s, {@link Builder}s, and {@link JobProperty}s
- * can additional implement this method to add additional edges
- * to the dependency graph computation.
+ * <p> {@link Publisher}s, {@link Builder}s, and {@link JobProperty}s can
+ * additional implement this method to add additional edges to the dependency
+ * graph computation.
*
* @author Nicolas Lalevee
* @author Martin Ficker
@@ -39,16 +38,14 @@ public interface DependecyDeclarer {
// so that this concept can be extended elsewhere, like maven projects and so on.
/**
- * Invoked from {@link AbstractProject#buildDependencyGraph(DependencyGraph)}.
+ * Invoked from
+ * {@link AbstractProject#buildDependencyGraph(DependencyGraph)}.
*
- * @param owner
- * The project that owns the publishers, builders, etc.
- * This information is conceptually redundant, as those objects are
- * only configured against the single owner, but this information is
- * nevertheless passed in since often owner information is not recorded.
- * Never null.
- * @param graph
- * The dependency graph being built. Never null.
+ * @param owner The project that owns the publishers, builders, etc. This
+ * information is conceptually redundant, as those objects are only
+ * configured against the single owner, but this information is nevertheless
+ * passed in since often owner information is not recorded. Never null.
+ * @param graph The dependency graph being built. Never null.
*/
void buildDependencyGraph(AbstractProject owner, DependencyGraph graph);
}
diff --git a/hudson-core/src/main/java/hudson/model/DependencyGraph.java b/hudson-core/src/main/java/hudson/model/DependencyGraph.java
index 8f99bb0..0218519 100644
--- a/hudson-core/src/main/java/hudson/model/DependencyGraph.java
+++ b/hudson-core/src/main/java/hudson/model/DependencyGraph.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
*
* Kohsuke Kawaguchi, Martin Eigenbrodt. Seiji Sogabe, Alan Harder
- *
+ *
*
*******************************************************************************/
@@ -36,35 +36,31 @@ import java.util.Set;
import java.util.Stack;
/**
- * Maintains the build dependencies between {@link AbstractProject}s
- * for efficient dependency computation.
+ * Maintains the build dependencies between {@link AbstractProject}s for
+ * efficient dependency computation.
*
- * <p>
- * The "master" data of dependencies are owned/persisted/maintained by
+ * <p> The "master" data of dependencies are owned/persisted/maintained by
* individual {@link AbstractProject}s, but because of that, it's relatively
- * slow to compute backward edges.
+ * slow to compute backward edges.
*
- * <p>
- * This class builds the complete bi-directional dependency graph
- * by collecting information from all {@link AbstractProject}s.
+ * <p> This class builds the complete bi-directional dependency graph by
+ * collecting information from all {@link AbstractProject}s.
*
- * <p>
- * Once built, {@link DependencyGraph} is immutable, and every time
- * there's a change (which is relatively rare), a new instance
- * will be created. This eliminates the need of synchronization.
+ * <p> Once built, {@link DependencyGraph} is immutable, and every time there's
+ * a change (which is relatively rare), a new instance will be created. This
+ * eliminates the need of synchronization.
*
- * @see Hudson#getDependencyGraph()
+ * @see Hudson#getDependencyGraph()
* @author Kohsuke Kawaguchi
*/
public final class DependencyGraph implements Comparator<AbstractProject> {
private Map<AbstractProject, List<DependencyGroup>> forward = new HashMap<AbstractProject, List<DependencyGroup>>();
private Map<AbstractProject, List<DependencyGroup>> backward = new HashMap<AbstractProject, List<DependencyGroup>>();
-
private boolean built;
-
/**
- * A unique set that holds the list of projects that have already computed its dependency graph
+ * A unique set that holds the list of projects that have already computed
+ * its dependency graph
*/
private Set<AbstractProject> alreadyComputedProjects = new HashSet<AbstractProject>();
@@ -79,8 +75,9 @@ public final class DependencyGraph implements Comparator<AbstractProject> {
NotSerilizableSecurityContext system = new NotSerilizableSecurityContext();
system.setAuthentication(ACL.SYSTEM);
SecurityContextHolder.setContext(system);
- for( AbstractProject p : Hudson.getInstance().getAllItems(AbstractProject.class) )
+ for (AbstractProject p : Hudson.getInstance().getAllItems(AbstractProject.class)) {
p.buildDependencyGraph(this);
+ }
forward = finalize(forward);
backward = finalize(backward);
@@ -101,7 +98,9 @@ public final class DependencyGraph implements Comparator<AbstractProject> {
}
/**
- * Add this project to the set of projects that have already computed its dependency graph
+ * Add this project to the set of projects that have already computed its
+ * dependency graph
+ *
* @param project
*/
public void addToAlreadyComputedProjects(AbstractProject project) {
@@ -110,38 +109,42 @@ public final class DependencyGraph implements Comparator<AbstractProject> {
/**
* Check if the project has already computed its dependency graph
+ *
* @param project
*/
public boolean isAlreadyComputedProject(AbstractProject project) {
return alreadyComputedProjects.contains(this);
}
-
/**
- * Gets all the immediate downstream projects (IOW forward edges) of the given project.
+ * Gets all the immediate downstream projects (IOW forward edges) of the
+ * given project.
*
- * @return
- * can be empty but never null.
+ * @return can be empty but never null.
*/
public List<AbstractProject> getDownstream(AbstractProject p) {
- return get(forward,p,false);
+ return get(forward, p, false);
}
/**
- * Gets all the immediate upstream projects (IOW backward edges) of the given project.
+ * Gets all the immediate upstream projects (IOW backward edges) of the
+ * given project.
*
- * @return
- * can be empty but never null.
+ * @return can be empty but never null.
*/
public List<AbstractProject> getUpstream(AbstractProject p) {
- return get(backward,p,true);
+ return get(backward, p, true);
}
private List<AbstractProject> get(Map<AbstractProject, List<DependencyGroup>> map, AbstractProject src, boolean up) {
List<DependencyGroup> v = map.get(src);
- if(v==null) return Collections.emptyList();
+ if (v == null) {
+ return Collections.emptyList();
+ }
List<AbstractProject> result = new ArrayList<AbstractProject>(v.size());
- for (Dependency d : v) result.add(up ? d.getUpstreamProject() : d.getDownstreamProject());
+ for (Dependency d : v) {
+ result.add(up ? d.getUpstreamProject() : d.getDownstreamProject());
+ }
return result;
}
@@ -149,20 +152,23 @@ public final class DependencyGraph implements Comparator<AbstractProject> {
* @since 1.341
*/
public List<Dependency> getDownstreamDependencies(AbstractProject p) {
- return get(forward,p);
+ return get(forward, p);
}
/**
* @since 1.341
*/
public List<Dependency> getUpstreamDependencies(AbstractProject p) {
- return get(backward,p);
+ return get(backward, p);
}
private List<Dependency> get(Map<AbstractProject, List<DependencyGroup>> map, AbstractProject src) {
List<DependencyGroup> v = map.get(src);
- if(v!=null) return Collections.<Dependency>unmodifiableList(v);
- else return Collections.emptyList();
+ if (v != null) {
+ return Collections.<Dependency>unmodifiableList(v);
+ } else {
+ return Collections.emptyList();
+ }
}
/**
@@ -170,17 +176,18 @@ public final class DependencyGraph implements Comparator<AbstractProject> {
*/
@Deprecated
public void addDependency(AbstractProject upstream, AbstractProject downstream) {
- addDependency(new Dependency(upstream,downstream));
+ addDependency(new Dependency(upstream, downstream));
}
/**
* Called during the dependency graph build phase to add a dependency edge.
*/
public void addDependency(Dependency dep) {
- if(built)
+ if (built) {
throw new IllegalStateException();
- add(forward,dep.getUpstreamProject(),dep);
- add(backward,dep.getDownstreamProject(),dep);
+ }
+ add(forward, dep.getUpstreamProject(), dep);
+ add(backward, dep.getDownstreamProject(), dep);
}
/**
@@ -188,8 +195,9 @@ public final class DependencyGraph implements Comparator<AbstractProject> {
*/
@Deprecated
public void addDependency(AbstractProject upstream, Collection<? extends AbstractProject> downstream) {
- for (AbstractProject p : downstream)
- addDependency(upstream,p);
+ for (AbstractProject p : downstream) {
+ addDependency(upstream, p);
+ }
}
/**
@@ -197,27 +205,28 @@ public final class DependencyGraph implements Comparator<AbstractProject> {
*/
@Deprecated
public void addDependency(Collection<? extends AbstractProject> upstream, AbstractProject downstream) {
- for (AbstractProject p : upstream)
- addDependency(p,downstream);
+ for (AbstractProject p : upstream) {
+ addDependency(p, downstream);
+ }
}
/**
- * Lists up {@link DependecyDeclarer} from the collection and let them builds dependencies.
+ * Lists up {@link DependecyDeclarer} from the collection and let them
+ * builds dependencies.
*/
public void addDependencyDeclarers(AbstractProject upstream, Collection<?> possibleDependecyDeclarers) {
for (Object o : possibleDependecyDeclarers) {
if (o instanceof DependecyDeclarer) {
DependecyDeclarer dd = (DependecyDeclarer) o;
- dd.buildDependencyGraph(upstream,this);
+ dd.buildDependencyGraph(upstream, this);
}
}
}
/**
* Returns true if a project has a non-direct dependency to another project.
- * <p>
- * A non-direct dependency is a path of dependency "edge"s from the source to the destination,
- * where the length is greater than 1.
+ * <p> A non-direct dependency is a path of dependency "edge"s from the
+ * source to the destination, where the length is greater than 1.
*/
public boolean hasIndirectDependencies(AbstractProject src, AbstractProject dst) {
Set<AbstractProject> visited = new HashSet<AbstractProject>();
@@ -226,29 +235,33 @@ public final class DependencyGraph implements Comparator<AbstractProject> {
queue.addAll(getDownstream(src));
queue.remove(dst);
- while(!queue.isEmpty()) {
+ while (!queue.isEmpty()) {
AbstractProject p = queue.pop();
- if(p==dst)
+ if (p == dst) {
return true;
- if(visited.add(p))
+ }
+ if (visited.add(p)) {
queue.addAll(getDownstream(p));
+ }
}
return false;
}
/**
- * Gets all the direct and indirect upstream dependencies of the given project.
+ * Gets all the direct and indirect upstream dependencies of the given
+ * project.
*/
public Set<AbstractProject> getTransitiveUpstream(AbstractProject src) {
- return getTransitive(backward,src,true);
+ return getTransitive(backward, src, true);
}
/**
- * Gets all the direct and indirect downstream dependencies of the given project.
+ * Gets all the direct and indirect downstream dependencies of the given
+ * project.
*/
public Set<AbstractProject> getTransitiveDownstream(AbstractProject src) {
- return getTransitive(forward,src,false);
+ return getTransitive(forward, src, false);
}
private Set<AbstractProject> getTransitive(Map<AbstractProject, List<DependencyGroup>> direction, AbstractProject src, boolean up) {
@@ -257,12 +270,13 @@ public final class DependencyGraph implements Comparator<AbstractProject> {
queue.add(src);
- while(!queue.isEmpty()) {
+ while (!queue.isEmpty()) {
AbstractProject p = queue.pop();
- for (AbstractProject child : get(direction,p,up)) {
- if(visited.add(child))
+ for (AbstractProject child : get(direction, p, up)) {
+ if (visited.add(child)) {
queue.add(child);
+ }
}
}
@@ -271,14 +285,14 @@ public final class DependencyGraph implements Comparator<AbstractProject> {
private void add(Map<AbstractProject, List<DependencyGroup>> map, AbstractProject key, Dependency dep) {
List<DependencyGroup> set = map.get(key);
- if(set==null) {
+ if (set == null) {
set = new ArrayList<DependencyGroup>();
- map.put(key,set);
+ map.put(key, set);
}
for (ListIterator<DependencyGroup> it = set.listIterator(); it.hasNext();) {
DependencyGroup d = it.next();
// Check for existing edge that connects the same two projects:
- if (d.getUpstreamProject()==dep.getUpstreamProject() && d.getDownstreamProject()==dep.getDownstreamProject()) {
+ if (d.getUpstreamProject() == dep.getUpstreamProject() && d.getDownstreamProject() == dep.getDownstreamProject()) {
d.add(dep);
return;
}
@@ -289,45 +303,52 @@ public final class DependencyGraph implements Comparator<AbstractProject> {
private Map<AbstractProject, List<DependencyGroup>> finalize(Map<AbstractProject, List<DependencyGroup>> m) {
for (Entry<AbstractProject, List<DependencyGroup>> e : m.entrySet()) {
- Collections.sort( e.getValue(), NAME_COMPARATOR );
- e.setValue( Collections.unmodifiableList(e.getValue()) );
+ Collections.sort(e.getValue(), NAME_COMPARATOR);
+ e.setValue(Collections.unmodifiableList(e.getValue()));
}
return Collections.unmodifiableMap(m);
}
-
/**
* Margins between the project name and its bounding box.
*/
private static final int MARGIN = 4;
-
-
private static final Comparator<Dependency> NAME_COMPARATOR = new Comparator<Dependency>() {
public int compare(Dependency lhs, Dependency rhs) {
int cmp = lhs.getUpstreamProject().getName().compareTo(rhs.getUpstreamProject().getName());
return cmp != 0 ? cmp : lhs.getDownstreamProject().getName().compareTo(rhs.getDownstreamProject().getName());
}
};
-
public static final DependencyGraph EMPTY = new DependencyGraph(false);
/**
- * Compare to Projects based on the topological order defined by this Dependency Graph
+ * Compare to Projects based on the topological order defined by this
+ * Dependency Graph
*/
public int compare(AbstractProject o1, AbstractProject o2) {
Set<AbstractProject> o1sdownstreams = getTransitiveDownstream(o1);
Set<AbstractProject> o2sdownstreams = getTransitiveDownstream(o2);
if (o1sdownstreams.contains(o2)) {
- if (o2sdownstreams.contains(o1)) return 0; else return 1;
+ if (o2sdownstreams.contains(o1)) {
+ return 0;
+ } else {
+ return 1;
+ }
} else {
- if (o2sdownstreams.contains(o1)) return -1; else return 0;
- }
+ if (o2sdownstreams.contains(o1)) {
+ return -1;
+ } else {
+ return 0;
+ }
+ }
}
/**
* Represents an edge in the dependency graph.
+ *
* @since 1.341
*/
public static class Dependency {
+
private AbstractProject upstream, downstream;
public Dependency(AbstractProject upstream, AbstractProject downstream) {
@@ -344,16 +365,19 @@ public final class DependencyGraph implements Comparator<AbstractProject> {
}
/**
- * Decide whether build should be triggered and provide any Actions for the build.
- * Default implementation always returns true (for backward compatibility), and
- * adds no Actions. Subclasses may override to control how/if the build is triggered.
+ * Decide whether build should be triggered and provide any Actions for
+ * the build. Default implementation always returns true (for backward
+ * compatibility), and adds no Actions. Subclasses may override to
+ * control how/if the build is triggered.
+ *
* @param build Build of upstream project that just completed
* @param listener For any error/log output
- * @param actions Add Actions for the triggered build to this list; never null
+ * @param actions Add Actions for the triggered build to this list;
+ * never null
* @return True to trigger a build of the downstream project
*/
public boolean shouldTriggerBuild(AbstractBuild build, TaskListener listener,
- List<Action> actions) {
+ List<Action> actions) {
return true;
}
@@ -361,13 +385,17 @@ public final class DependencyGraph implements Comparator<AbstractProject> {
* Does this method point to itself?
*/
public boolean pointsItself() {
- return upstream==downstream;
+ return upstream == downstream;
}
@Override
public boolean equals(Object obj) {
- if (obj == null) return false;
- if (getClass() != obj.getClass()) return false;
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
final Dependency that = (Dependency) obj;
return this.upstream == that.upstream || this.downstream == that.downstream;
@@ -386,6 +414,7 @@ public final class DependencyGraph implements Comparator<AbstractProject> {
* Collect multiple dependencies between the same two projects.
*/
private static class DependencyGroup extends Dependency {
+
private Set<Dependency> group = new LinkedHashSet<Dependency>();
DependencyGroup(Dependency first) {
@@ -399,14 +428,15 @@ public final class DependencyGraph implements Comparator<AbstractProject> {
@Override
public boolean shouldTriggerBuild(AbstractBuild build, TaskListener listener,
- List<Action> actions) {
+ List<Action> actions) {
List<Action> check = new ArrayList<Action>();
for (Dependency d : group) {
if (d.shouldTriggerBuild(build, listener, check)) {
actions.addAll(check);
return true;
- } else
+ } else {
check.clear();
+ }
}
return false;
}
diff --git a/hudson-core/src/main/java/hudson/model/Describable.java b/hudson-core/src/main/java/hudson/model/Describable.java
index 6873f26..a928831 100644
--- a/hudson-core/src/main/java/hudson/model/Describable.java
+++ b/hudson-core/src/main/java/hudson/model/Describable.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
-*
-* Kohsuke Kawaguchi
- *
+ * Contributors:
+ *
+ * Kohsuke Kawaguchi
+ *
*
*******************************************************************************/
@@ -22,12 +22,13 @@ package hudson.model;
* @author Kohsuke Kawaguchi
*/
public interface Describable<T extends Describable<T>> {
+
/**
* Gets the descriptor for this instance.
*
- * <p>
- * {@link Descriptor} is a singleton for every concrete {@link Describable}
- * implementation, so if <tt>a.getClass()==b.getClass()</tt> then
+ * <p> {@link Descriptor} is a singleton for every concrete
+ * {@link Describable} implementation, so if
+ * <tt>a.getClass()==b.getClass()</tt> then
* <tt>a.getDescriptor()==b.getDescriptor()</tt> must hold.
*/
Descriptor<T> getDescriptor();
diff --git a/hudson-core/src/main/java/hudson/model/Descriptor.java b/hudson-core/src/main/java/hudson/model/Descriptor.java
index 5fc51e9..3d17178 100644
--- a/hudson-core/src/main/java/hudson/model/Descriptor.java
+++ b/hudson-core/src/main/java/hudson/model/Descriptor.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
*
* Kohsuke Kawaguchi
- *
+ *
*
*******************************************************************************/
@@ -61,82 +61,73 @@ import java.beans.Introspector;
/**
* Metadata about a configurable instance.
*
- * <p>
- * {@link Descriptor} is an object that has metadata about a {@link Describable}
- * object, and also serves as a factory (in a way this relationship is similar
- * to {@link Object}/{@link Class} relationship.
+ * <p> {@link Descriptor} is an object that has metadata about a
+ * {@link Describable} object, and also serves as a factory (in a way this
+ * relationship is similar to {@link Object}/{@link Class} relationship.
*
- * A {@link Descriptor}/{@link Describable}
- * combination is used throughout in Hudson to implement a
- * configuration/extensibility mechanism.
+ * A {@link Descriptor}/{@link Describable} combination is used throughout in
+ * Hudson to implement a configuration/extensibility mechanism.
*
- * <p>
- * Take the list view support as an example, which is implemented
- * in {@link ListView} class. Whenever a new view is created, a new
- * {@link ListView} instance is created with the configuration
- * information. This instance gets serialized to XML, and this instance
- * will be called to render the view page. This is the job
- * of {@link Describable} &mdash; each instance represents a specific
- * configuration of a view (what projects are in it, regular expression, etc.)
+ * <p> Take the list view support as an example, which is implemented in
+ * {@link ListView} class. Whenever a new view is created, a new
+ * {@link ListView} instance is created with the configuration information. This
+ * instance gets serialized to XML, and this instance will be called to render
+ * the view page. This is the job of {@link Describable} &mdash; each instance
+ * represents a specific configuration of a view (what projects are in it,
+ * regular expression, etc.)
*
- * <p>
- * For Hudson to create such configured {@link ListView} instance, Hudson
- * needs another object that captures the metadata of {@link ListView},
- * and that is what a {@link Descriptor} is for. {@link ListView} class
- * has a singleton descriptor, and this descriptor helps render
- * the configuration form, remember system-wide configuration, and works as a factory.
+ * <p> For Hudson to create such configured {@link ListView} instance, Hudson
+ * needs another object that captures the metadata of {@link ListView}, and that
+ * is what a {@link Descriptor} is for. {@link ListView} class has a singleton
+ * descriptor, and this descriptor helps render the configuration form, remember
+ * system-wide configuration, and works as a factory.
*
- * <p>
- * {@link Descriptor} also usually have its associated views.
+ * <p> {@link Descriptor} also usually have its associated views.
*
*
- * <h2>Persistence</h2>
- * <p>
- * {@link Descriptor} can persist data just by storing them in fields.
- * However, it is the responsibility of the derived type to properly
- * invoke {@link #save()} and {@link #load()}.
+ * <h2>Persistence</h2> <p> {@link Descriptor} can persist data just by storing
+ * them in fields. However, it is the responsibility of the derived type to
+ * properly invoke {@link #save()} and {@link #load()}.
*
- * <h2>Reflection Enhancement</h2>
- * {@link Descriptor} defines addition to the standard Java reflection
- * and provides reflective information about its corresponding {@link Describable}.
- * These are primarily used by tag libraries to
- * keep the Jelly scripts concise.
+ * <h2>Reflection Enhancement</h2> {@link Descriptor} defines addition to the
+ * standard Java reflection and provides reflective information about its
+ * corresponding {@link Describable}. These are primarily used by tag libraries
+ * to keep the Jelly scripts concise.
*
* @author Kohsuke Kawaguchi
* @see Describable
*/
public abstract class Descriptor<T extends Describable<T>> implements Saveable {
+
/**
* Up to Hudson 1.61 this was used as the primary persistence mechanism.
- * Going forward Hudson simply persists all the non-transient fields
- * of {@link Descriptor}, just like others, so this is pointless.
+ * Going forward Hudson simply persists all the non-transient fields of
+ * {@link Descriptor}, just like others, so this is pointless.
*
* @deprecated since 2006-11-16
*/
@Deprecated
- private transient Map<String,Object> properties;
-
+ private transient Map<String, Object> properties;
/**
* The class being described by this descriptor.
*/
public transient final Class<? extends T> clazz;
-
- private transient final Map<String,String> checkMethods = new ConcurrentHashMap<String,String>();
-
+ private transient final Map<String, String> checkMethods = new ConcurrentHashMap<String, String>();
/**
- * Lazily computed list of properties on {@link #clazz} and on the descriptor itself.
+ * Lazily computed list of properties on {@link #clazz} and on the
+ * descriptor itself.
*/
- private transient volatile Map<String, PropertyType> propertyTypes,globalPropertyTypes;
+ private transient volatile Map<String, PropertyType> propertyTypes, globalPropertyTypes;
/**
* Represents a readable property on {@link Describable}.
*/
public static final class PropertyType {
//TODO: review and check whether we can do it private
+
public final Class clazz;
//TODO: review and check whether we can do it private
public final Type type;
-
private volatile Class itemType;
public Class getClazz() {
@@ -153,43 +144,46 @@ public abstract class Descriptor<T extends Describable<T>> implements Saveable {
}
PropertyType(Field f) {
- this(f.getType(),f.getGenericType());
+ this(f.getType(), f.getGenericType());
}
PropertyType(Method getter) {
- this(getter.getReturnType(),getter.getGenericReturnType());
+ this(getter.getReturnType(), getter.getGenericReturnType());
}
public Enum[] getEnumConstants() {
- return (Enum[])clazz.getEnumConstants();
+ return (Enum[]) clazz.getEnumConstants();
}
/**
* If the property is a collection/array type, what is an item type?
*/
public Class getItemType() {
- if(itemType==null)
+ if (itemType == null) {
itemType = computeItemType();
+ }
return itemType;
}
private Class computeItemType() {
- if(clazz.isArray()) {
+ if (clazz.isArray()) {
return clazz.getComponentType();
}
- if(Collection.class.isAssignableFrom(clazz)) {
+ if (Collection.class.isAssignableFrom(clazz)) {
Type col = Types.getBaseClass(type, Collection.class);
- if (col instanceof ParameterizedType)
- return Types.erasure(Types.getTypeArgument(col,0));
- else
+ if (col instanceof ParameterizedType) {
+ return Types.erasure(Types.getTypeArgument(col, 0));
+ } else {
return Object.class;
+ }
}
return null;
}
/**
- * Returns {@link Descriptor} whose 'clazz' is the same as {@link #getItemType() the item type}.
+ * Returns {@link Descriptor} whose 'clazz' is the same as
+ * {@link #getItemType() the item type}.
*/
public Descriptor getItemTypeDescriptor() {
return Hudson.getInstance().getDescriptor(getItemType());
@@ -200,7 +194,8 @@ public abstract class Descriptor<T extends Describable<T>> implements Saveable {
}
/**
- * Returns all the descriptors that produce types assignable to the item type.
+ * Returns all the descriptors that produce types assignable to the item
+ * type.
*/
public List<? extends Descriptor> getApplicableDescriptors() {
return Hudson.getInstance().getDescriptorList(clazz);
@@ -215,16 +210,18 @@ public abstract class Descriptor<T extends Describable<T>> implements Saveable {
}
/**
- * Infers the type of the corresponding {@link Describable} from the outer class.
- * This version works when you follow the common convention, where a descriptor
- * is written as the static nested class of the describable class.
- *
+ * Infers the type of the corresponding {@link Describable} from the outer
+ * class. This version works when you follow the common convention, where a
+ * descriptor is written as the static nested class of the describable
+ * class.
+ *
* @since 1.278
*/
protected Descriptor() {
- this.clazz = (Class<T>)getClass().getEnclosingClass();
- if(clazz==null)
- throw new AssertionError(getClass()+" doesn't have an outer class. Use the constructor that takes the Class object explicitly.");
+ this.clazz = (Class<T>) getClass().getEnclosingClass();
+ if (clazz == null) {
+ throw new AssertionError(getClass() + " doesn't have an outer class. Use the constructor that takes the Class object explicitly.");
+ }
// detect an type error
Type bt = Types.getBaseClass(getClass(), Descriptor.class);
@@ -232,19 +229,20 @@ public abstract class Descriptor<T extends Describable<T>> implements Saveable {
ParameterizedType pt = (ParameterizedType) bt;
// this 't' is the closest approximation of T of Descriptor<T>.
Class t = Types.erasure(pt.getActualTypeArguments()[0]);
- if(!t.isAssignableFrom(clazz))
- throw new AssertionError("Outer class "+clazz+" of "+getClass()+" is not assignable to "+t+". Perhaps wrong outer class?");
+ if (!t.isAssignableFrom(clazz)) {
+ throw new AssertionError("Outer class " + clazz + " of " + getClass() + " is not assignable to " + t + ". Perhaps wrong outer class?");
+ }
}
// detect a type error. this Descriptor is supposed to be returned from getDescriptor(), so make sure its type match up.
// this prevents a bug like http://www.nabble.com/Creating-a-new-parameter-Type-%3A-Masked-Parameter-td24786554.html
try {
Method getd = clazz.getMethod("getDescriptor");
- if(!getd.getReturnType().isAssignableFrom(getClass())) {
- throw new AssertionError(getClass()+" must be assignable to "+getd.getReturnType());
+ if (!getd.getReturnType().isAssignableFrom(getClass())) {
+ throw new AssertionError(getClass() + " must be assignable to " + getd.getReturnType());
}
} catch (NoSuchMethodException e) {
- throw new AssertionError(getClass()+" is missing getDescriptor method.");
+ throw new AssertionError(getClass() + " is missing getDescriptor method.");
}
}
@@ -255,16 +253,17 @@ public abstract class Descriptor<T extends Describable<T>> implements Saveable {
public abstract String getDisplayName();
/**
- * Uniquely identifies this {@link Descriptor} among all the other {@link Descriptor}s.
+ * Uniquely identifies this {@link Descriptor} among all the other
+ * {@link Descriptor}s.
+ *
+ * <p> Historically {@link #clazz} is assumed to be unique, so this method
+ * uses that as the default, but if you are adding {@link Descriptor}s
+ * programmatically for the same type, you can change this to disambiguate
+ * them.
*
- * <p>
- * Historically {@link #clazz} is assumed to be unique, so this method uses that as the default,
- * but if you are adding {@link Descriptor}s programmatically for the same type, you can change
- * this to disambiguate them.
+ * @return Stick to valid Java identifier character, plus '.', which had to
+ * be allowed for historical reasons.
*
- * @return
- * Stick to valid Java identifier character, plus '.', which had to be allowed for historical reasons.
- *
* @since 1.391
*/
public String getId() {
@@ -272,11 +271,13 @@ public abstract class Descriptor<T extends Describable<T>> implements Saveable {
}
/**
- * Gets the URL that this Descriptor is bound to, relative to the nearest {@link DescriptorByNameOwner}.
- * Since {@link Hudson} is a {@link DescriptorByNameOwner}, there's always one such ancestor to any request.
+ * Gets the URL that this Descriptor is bound to, relative to the nearest
+ * {@link DescriptorByNameOwner}. Since {@link Hudson} is a
+ * {@link DescriptorByNameOwner}, there's always one such ancestor to any
+ * request.
*/
public String getDescriptorUrl() {
- return "descriptorByName/"+getId();
+ return "descriptorByName/" + getId();
}
private String getCurrentDescriptorByNameUrl() {
@@ -286,35 +287,38 @@ public abstract class Descriptor<T extends Describable<T>> implements Saveable {
}
/**
- * If the field "xyz" of a {@link Describable} has the corresponding "doCheckXyz" method,
- * return the form-field validation string. Otherwise null.
- * <p>
- * This method is used to hook up the form validation method to the corresponding HTML input element.
+ * If the field "xyz" of a {@link Describable} has the corresponding
+ * "doCheckXyz" method, return the form-field validation string. Otherwise
+ * null. <p> This method is used to hook up the form validation method to
+ * the corresponding HTML input element.
*/
public String getCheckUrl(String fieldName) {
String method = checkMethods.get(fieldName);
- if(method==null) {
+ if (method == null) {
method = calcCheckUrl(fieldName);
- checkMethods.put(fieldName,method);
+ checkMethods.put(fieldName, method);
}
if (method.equals(NONE)) // == would do, but it makes IDE flag a warning
+ {
return null;
+ }
// put this under the right contextual umbrella.
// a is always non-null because we already have Hudson as the sentinel
- return singleQuote(getCurrentDescriptorByNameUrl()+'/')+'+'+method;
+ return singleQuote(getCurrentDescriptorByNameUrl() + '/') + '+' + method;
}
private String calcCheckUrl(String fieldName) {
String capitalizedFieldName = StringUtils.capitalize(fieldName);
- Method method = ReflectionUtils.getPublicMethodNamed(getClass(),"doCheck"+ capitalizedFieldName);
+ Method method = ReflectionUtils.getPublicMethodNamed(getClass(), "doCheck" + capitalizedFieldName);
- if(method==null)
+ if (method == null) {
return NONE;
+ }
- return singleQuote(getDescriptorUrl() +"/check"+capitalizedFieldName) + buildParameterList(method, new StringBuilder()).append(".toString()");
+ return singleQuote(getDescriptorUrl() + "/check" + capitalizedFieldName) + buildParameterList(method, new StringBuilder()).append(".toString()");
}
/**
@@ -323,73 +327,87 @@ public abstract class Descriptor<T extends Describable<T>> implements Saveable {
private StringBuilder buildParameterList(Method method, StringBuilder query) {
for (Parameter p : ReflectionUtils.getParameters(method)) {
QueryParameter qp = p.annotation(QueryParameter.class);
- if (qp!=null) {
+ if (qp != null) {
String name = qp.value();
- if (name.length()==0) name = p.name();
- if (name==null || name.length()==0)
+ if (name.length() == 0) {
+ name = p.name();
+ }
+ if (name == null || name.length() == 0) {
continue; // unknown parameter name. we'll report the error when the form is submitted.
-
+ }
RelativePath rp = p.annotation(RelativePath.class);
- if (rp!=null)
- name = rp.value()+'/'+name;
+ if (rp != null) {
+ name = rp.value() + '/' + name;
+ }
- if (query.length()==0) query.append("+qs(this)");
+ if (query.length() == 0) {
+ query.append("+qs(this)");
+ }
if (name.equals("value")) {
// The special 'value' parameter binds to the the current field
query.append(".addThis()");
} else {
- query.append(".nearBy('"+name+"')");
+ query.append(".nearBy('" + name + "')");
}
continue;
}
Method m = ReflectionUtils.getPublicMethodNamed(p.type(), "fromStapler");
- if (m!=null) buildParameterList(m,query);
+ if (m != null) {
+ buildParameterList(m, query);
+ }
}
return query;
}
/**
- * Computes the list of other form fields that the given field depends on, via the doFillXyzItems method,
- * and sets that as the 'fillDependsOn' attribute. Also computes the URL of the doFillXyzItems and
- * sets that as the 'fillUrl' attribute.
+ * Computes the list of other form fields that the given field depends on,
+ * via the doFillXyzItems method, and sets that as the 'fillDependsOn'
+ * attribute. Also computes the URL of the doFillXyzItems and sets that as
+ * the 'fillUrl' attribute.
*/
- public void calcFillSettings(String field, Map<String,Object> attributes) {
+ public void calcFillSettings(String field, Map<String, Object> attributes) {
String capitalizedFieldName = StringUtils.capitalize(field);
String methodName = "doFill" + capitalizedFieldName + "Items";
Method method = ReflectionUtils.getPublicMethodNamed(getClass(), methodName);
- if(method==null)
+ if (method == null) {
throw new IllegalStateException(String.format("%s doesn't have the %s method for filling a drop-down list", getClass(), methodName));
+ }
// build query parameter line by figuring out what should be submitted
List<String> depends = buildFillDependencies(method, new ArrayList<String>());
- if (!depends.isEmpty())
- attributes.put("fillDependsOn",Util.join(depends," "));
+ if (!depends.isEmpty()) {
+ attributes.put("fillDependsOn", Util.join(depends, " "));
+ }
attributes.put("fillUrl", String.format("%s/%s/fill%sItems", getCurrentDescriptorByNameUrl(), getDescriptorUrl(), capitalizedFieldName));
}
private List<String> buildFillDependencies(Method method, List<String> depends) {
for (Parameter p : ReflectionUtils.getParameters(method)) {
QueryParameter qp = p.annotation(QueryParameter.class);
- if (qp!=null) {
+ if (qp != null) {
String name = qp.value();
- if (name.length()==0) name = p.name();
- if (name==null || name.length()==0)
+ if (name.length() == 0) {
+ name = p.name();
+ }
+ if (name == null || name.length() == 0) {
continue; // unknown parameter name. we'll report the error when the form is submitted.
-
+ }
RelativePath rp = p.annotation(RelativePath.class);
- if (rp!=null)
- name = rp.value()+'/'+name;
+ if (rp != null) {
+ name = rp.value() + '/' + name;
+ }
depends.add(name);
continue;
}
Method m = ReflectionUtils.getPublicMethodNamed(p.type(), "fromStapler");
- if (m!=null)
- buildFillDependencies(m,depends);
+ if (m != null) {
+ buildFillDependencies(m, depends);
+ }
}
return depends;
}
@@ -397,30 +415,32 @@ public abstract class Descriptor<T extends Describable<T>> implements Saveable {
/**
* Computes the auto-completion setting
*/
- public void calcAutoCompleteSettings(String field, Map<String,Object> attributes) {
+ public void calcAutoCompleteSettings(String field, Map<String, Object> attributes) {
String capitalizedFieldName = StringUtils.capitalize(field);
String methodName = "doAutoComplete" + capitalizedFieldName;
Method method = ReflectionUtils.getPublicMethodNamed(getClass(), methodName);
- if(method==null)
+ if (method == null) {
return; // no auto-completion
-
+ }
attributes.put("autoCompleteUrl", String.format("%s/%s/autoComplete%s", getCurrentDescriptorByNameUrl(), getDescriptorUrl(), capitalizedFieldName));
}
/**
- * Used by Jelly to abstract away the handlign of global.jelly vs config.jelly databinding difference.
+ * Used by Jelly to abstract away the handlign of global.jelly vs
+ * config.jelly databinding difference.
*/
public PropertyType getPropertyType(Object instance, String field) {
// in global.jelly, instance==descriptor
- return instance==this ? getGlobalPropertyType(field) : getPropertyType(field);
+ return instance == this ? getGlobalPropertyType(field) : getPropertyType(field);
}
/**
* Obtains the property type of the given field of {@link #clazz}
*/
public PropertyType getPropertyType(String field) {
- if(propertyTypes==null)
+ if (propertyTypes == null) {
propertyTypes = buildPropertyTypes(clazz);
+ }
return propertyTypes.get(field);
}
@@ -428,113 +448,115 @@ public abstract class Descriptor<T extends Describable<T>> implements Saveable {
* Obtains the property type of the given field of this descriptor.
*/
public PropertyType getGlobalPropertyType(String field) {
- if(globalPropertyTypes==null)
+ if (globalPropertyTypes == null) {
globalPropertyTypes = buildPropertyTypes(getClass());
+ }
return globalPropertyTypes.get(field);
}
/**
- * Given the class, list up its {@link PropertyType}s from its public fields/getters.
+ * Given the class, list up its {@link PropertyType}s from its public
+ * fields/getters.
*/
private Map<String, PropertyType> buildPropertyTypes(Class<?> clazz) {
Map<String, PropertyType> r = new HashMap<String, PropertyType>();
- for (Field f : clazz.getFields())
- r.put(f.getName(),new PropertyType(f));
+ for (Field f : clazz.getFields()) {
+ r.put(f.getName(), new PropertyType(f));
+ }
- for (Method m : clazz.getMethods())
- if(m.getName().startsWith("get"))
- r.put(Introspector.decapitalize(m.getName().substring(3)),new PropertyType(m));
+ for (Method m : clazz.getMethods()) {
+ if (m.getName().startsWith("get")) {
+ r.put(Introspector.decapitalize(m.getName().substring(3)), new PropertyType(m));
+ }
+ }
return r;
}
/**
- * Gets the class name nicely escaped to be usable as a key in the structured form submission.
+ * Gets the class name nicely escaped to be usable as a key in the
+ * structured form submission.
*/
public final String getJsonSafeClassName() {
- return getId().replace('.','-');
+ return getId().replace('.', '-');
}
/**
- * @deprecated
- * Implement {@link #newInstance(StaplerRequest, JSONObject)} method instead.
- * Deprecated as of 1.145.
+ * @deprecated Implement {@link #newInstance(StaplerRequest, JSONObject)}
+ * method instead. Deprecated as of 1.145.
*/
public T newInstance(StaplerRequest req) throws FormException {
- throw new UnsupportedOperationException(getClass()+" should implement newInstance(StaplerRequest,JSONObject)");
+ throw new UnsupportedOperationException(getClass() + " should implement newInstance(StaplerRequest,JSONObject)");
}
-
/**
* Creates a configured instance from the submitted form.
*
- * <p>
- * Hudson only invokes this method when the user wants an instance of <tt>T</tt>.
- * So there's no need to check that in the implementation.
+ * <p> Hudson only invokes this method when the user wants an instance of
+ * <tt>T</tt>. So there's no need to check that in the implementation.
*
- * <p>
- * Starting 1.206, the default implementation of this method does the following:
+ * <p> Starting 1.206, the default implementation of this method does the
+ * following:
* <pre>
* req.bindJSON(clazz,formData);
- * </pre>
- * <p>
- * ... which performs the databinding on the constructor of {@link #clazz}.
+ * </pre> <p> ... which performs the databinding on the constructor of
+ * {@link #clazz}.
*
- * <p>
- * For some types of {@link Describable}, such as {@link ListViewColumn}, this method
- * can be invoked with null request object for historical reason. Such design is considered
- * broken, but due to the compatibility reasons we cannot fix it. Because of this, the
- * default implementation gracefully handles null request, but the contract of the method
- * still is "request is always non-null." Extension points that need to define the "default instance"
- * semantics should define a descriptor subtype and add the no-arg newInstance method.
+ * <p> For some types of {@link Describable}, such as
+ * {@link ListViewColumn}, this method can be invoked with null request
+ * object for historical reason. Such design is considered broken, but due
+ * to the compatibility reasons we cannot fix it. Because of this, the
+ * default implementation gracefully handles null request, but the contract
+ * of the method still is "request is always non-null." Extension points
+ * that need to define the "default instance" semantics should define a
+ * descriptor subtype and add the no-arg newInstance method.
*
- * @param req
- * Always non-null (see note above.) This object includes represents the entire submission.
- * @param formData
- * The JSON object that captures the configuration data for this {@link Descriptor}.
- * See http://wiki.hudson-ci.org/display/HUDSON/Structured+Form+Submission
- * Always non-null.
+ * @param req Always non-null (see note above.) This object includes
+ * represents the entire submission.
+ * @param formData The JSON object that captures the configuration data for
+ * this {@link Descriptor}. See
+ * http://wiki.hudson-ci.org/display/HUDSON/Structured+Form+Submission
+ * Always non-null.
*
- * @throws FormException
- * Signals a problem in the submitted form.
+ * @throws FormException Signals a problem in the submitted form.
* @since 1.145
*/
public T newInstance(StaplerRequest req, JSONObject formData) throws FormException {
try {
Method m = getClass().getMethod("newInstance", StaplerRequest.class);
- if(!Modifier.isAbstract(m.getDeclaringClass().getModifiers())) {
+ if (!Modifier.isAbstract(m.getDeclaringClass().getModifiers())) {
// this class overrides newInstance(StaplerRequest).
// maintain the backward compatible behavior
return verifyNewInstance(newInstance(req));
} else {
- if (req==null) {
+ if (req == null) {
// yes, req is supposed to be always non-null, but see the note above
return verifyNewInstance(clazz.newInstance());
}
// new behavior as of 1.206
- return verifyNewInstance(req.bindJSON(clazz,formData));
+ return verifyNewInstance(req.bindJSON(clazz, formData));
}
} catch (NoSuchMethodException e) {
throw new AssertionError(e); // impossible
} catch (InstantiationException e) {
- throw new Error("Failed to instantiate "+clazz+" from "+formData,e);
+ throw new Error("Failed to instantiate " + clazz + " from " + formData, e);
} catch (IllegalAccessException e) {
- throw new Error("Failed to instantiate "+clazz+" from "+formData,e);
+ throw new Error("Failed to instantiate " + clazz + " from " + formData, e);
} catch (RuntimeException e) {
- throw new RuntimeException("Failed to instantiate "+clazz+" from "+formData,e);
+ throw new RuntimeException("Failed to instantiate " + clazz + " from " + formData, e);
}
}
/**
- * Look out for a typical error a plugin developer makes.
- * See http://hudson.361315.n4.nabble.com/Help-Hint-needed-Post-build-action-doesn-t-stay-activated-td2308833.html
+ * Look out for a typical error a plugin developer makes. See
+ * http://hudson.361315.n4.nabble.com/Help-Hint-needed-Post-build-action-doesn-t-stay-activated-td2308833.html
*/
private T verifyNewInstance(T t) {
- if (t!=null && t.getDescriptor()!=this) {
+ if (t != null && t.getDescriptor() != this) {
// TODO: should this be a fatal error?
- LOGGER.warning("Father of "+ t+" and its getDescriptor() points to two different instances. Probably malplaced @Extension. See http://hudson.361315.n4.nabble.com/Help-Hint-needed-Post-build-action-doesn-t-stay-activated-td2308833.html");
+ LOGGER.warning("Father of " + t + " and its getDescriptor() points to two different instances. Probably malplaced @Extension. See http://hudson.361315.n4.nabble.com/Help-Hint-needed-Post-build-action-doesn-t-stay-activated-td2308833.html");
}
return t;
}
@@ -542,19 +564,18 @@ public abstract class Descriptor<T extends Describable<T>> implements Saveable {
/**
* Returns the resource path to the help screen HTML, if any.
*
- * <p>
- * Starting 1.282, this method uses "convention over configuration" &mdash; you should
- * just put the "help.html" (and its localized versions, if any) in the same directory
- * you put your Jelly view files, and this method will automatically does the right thing.
+ * <p> Starting 1.282, this method uses "convention over configuration"
+ * &mdash; you should just put the "help.html" (and its localized versions,
+ * if any) in the same directory you put your Jelly view files, and this
+ * method will automatically does the right thing.
*
- * <p>
- * This value is relative to the context root of Hudson, so normally
- * the values are something like <tt>"/plugin/emma/help.html"</tt> to
- * refer to static resource files in a plugin, or <tt>"/publisher/EmmaPublisher/abc"</tt>
- * to refer to Jelly script <tt>abc.jelly</tt> or a method <tt>EmmaPublisher.doAbc()</tt>.
+ * <p> This value is relative to the context root of Hudson, so normally the
+ * values are something like <tt>"/plugin/emma/help.html"</tt> to refer to
+ * static resource files in a plugin, or
+ * <tt>"/publisher/EmmaPublisher/abc"</tt> to refer to Jelly script
+ * <tt>abc.jelly</tt> or a method <tt>EmmaPublisher.doAbc()</tt>.
*
- * @return
- * null to indicate that there's no help.
+ * @return null to indicate that there's no help.
*/
public String getHelpFile() {
return getHelpFile(null);
@@ -563,31 +584,33 @@ public abstract class Descriptor<T extends Describable<T>> implements Saveable {
/**
* Returns the path to the help screen HTML for the given field.
*
- * <p>
- * The help files are assumed to be at "help/FIELDNAME.html" with possible
- * locale variations.
+ * <p> The help files are assumed to be at "help/FIELDNAME.html" with
+ * possible locale variations.
*/
public String getHelpFile(final String fieldName) {
- for(Class c=clazz; c!=null; c=c.getSuperclass()) {
+ for (Class c = clazz; c != null; c = c.getSuperclass()) {
String page = "/descriptor/" + getId() + "/help";
String suffix;
- if(fieldName==null) {
- suffix="";
+ if (fieldName == null) {
+ suffix = "";
} else {
- page += '/'+fieldName;
- suffix='-'+fieldName;
+ page += '/' + fieldName;
+ suffix = '-' + fieldName;
}
try {
- if(Stapler.getCurrentRequest().getView(c,"help"+suffix)!=null)
+ if (Stapler.getCurrentRequest().getView(c, "help" + suffix) != null) {
return page;
+ }
} catch (IOException e) {
throw new Error(e);
}
- InputStream in = getHelpStream(c,suffix);
+ InputStream in = getHelpStream(c, suffix);
IOUtils.closeQuietly(in);
- if(in!=null) return page;
+ if (in != null) {
+ return page;
+ }
}
return null;
}
@@ -595,22 +618,23 @@ public abstract class Descriptor<T extends Describable<T>> implements Saveable {
/**
* Checks if the given object is created from this {@link Descriptor}.
*/
- public final boolean isInstance( T instance ) {
+ public final boolean isInstance(T instance) {
return clazz.isInstance(instance);
}
/**
- * Checks if the type represented by this descriptor is a subtype of the given type.
+ * Checks if the type represented by this descriptor is a subtype of the
+ * given type.
*/
public final boolean isSubTypeOf(Class type) {
return type.isAssignableFrom(clazz);
}
/**
- * @deprecated
- * As of 1.239, use {@link #configure(StaplerRequest, JSONObject)}.
+ * @deprecated As of 1.239, use
+ * {@link #configure(StaplerRequest, JSONObject)}.
*/
- public boolean configure( StaplerRequest req ) throws FormException {
+ public boolean configure(StaplerRequest req) throws FormException {
return true;
}
@@ -619,13 +643,12 @@ public abstract class Descriptor<T extends Describable<T>> implements Saveable {
*
* Can be overriden to store descriptor-specific information.
*
- * @param json
- * The JSON object that captures the configuration data for this {@link Descriptor}.
- * See http://wiki.hudson-ci.org/display/HUDSON/Structured+Form+Submission
- * @return false
- * to keep the client in the same config page.
+ * @param json The JSON object that captures the configuration data for this
+ * {@link Descriptor}. See
+ * http://wiki.hudson-ci.org/display/HUDSON/Structured+Form+Submission
+ * @return false to keep the client in the same config page.
*/
- public boolean configure( StaplerRequest req, JSONObject json ) throws FormException {
+ public boolean configure(StaplerRequest req, JSONObject json) throws FormException {
// compatibility
return configure(req);
}
@@ -635,14 +658,15 @@ public abstract class Descriptor<T extends Describable<T>> implements Saveable {
}
public String getGlobalConfigPage() {
- return getViewPage(clazz, "global.jelly",null);
+ return getViewPage(clazz, "global.jelly", null);
}
private String getViewPage(Class<?> clazz, String pageName, String defaultValue) {
- while(clazz!=Object.class) {
+ while (clazz != Object.class) {
String name = clazz.getName().replace('.', '/').replace('$', '/') + "/" + pageName;
- if(clazz.getClassLoader().getResource(name)!=null)
- return '/'+name;
+ if (clazz.getClassLoader().getResource(name) != null) {
+ return '/' + name;
+ }
clazz = clazz.getSuperclass();
}
return defaultValue;
@@ -654,45 +678,46 @@ public abstract class Descriptor<T extends Describable<T>> implements Saveable {
// it doesn't exist.
// Or this error is fatal, in which case we want the developer to see what page he's missing.
// so we put the page name.
- return getViewPage(clazz,pageName,pageName);
+ return getViewPage(clazz, pageName, pageName);
}
-
/**
* Saves the configuration info to the disk.
*/
public synchronized void save() {
- if(BulkChange.contains(this)) return;
+ if (BulkChange.contains(this)) {
+ return;
+ }
try {
getConfigFile().write(this);
SaveableListener.fireOnChange(this, getConfigFile());
} catch (IOException e) {
- LOGGER.log(Level.WARNING, "Failed to save "+getConfigFile(),e);
+ LOGGER.log(Level.WARNING, "Failed to save " + getConfigFile(), e);
}
}
/**
* Loads the data from the disk into this object.
*
- * <p>
- * The constructor of the derived class must call this method.
- * (If we do that in the base class, the derived class won't
- * get a chance to set default values.)
+ * <p> The constructor of the derived class must call this method. (If we do
+ * that in the base class, the derived class won't get a chance to set
+ * default values.)
*/
public synchronized void load() {
XmlFile file = getConfigFile();
- if(!file.exists())
+ if (!file.exists()) {
return;
+ }
try {
file.unmarshal(this);
} catch (IOException e) {
- LOGGER.log(Level.WARNING, "Failed to load "+file, e);
+ LOGGER.log(Level.WARNING, "Failed to load " + file, e);
}
}
public XmlFile getConfigFile() {
- return new XmlFile(new File(Hudson.getInstance().getRootDir(),getId()+".xml"));
+ return new XmlFile(new File(Hudson.getInstance().getRootDir(), getId() + ".xml"));
}
/**
@@ -700,23 +725,25 @@ public abstract class Descriptor<T extends Describable<T>> implements Saveable {
*/
public void doHelp(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
String path = req.getRestOfPath();
- if(path.contains("..")) throw new ServletException("Illegal path: "+path);
+ if (path.contains("..")) {
+ throw new ServletException("Illegal path: " + path);
+ }
- path = path.replace('/','-');
+ path = path.replace('/', '-');
- for (Class c=clazz; c!=null; c=c.getSuperclass()) {
- RequestDispatcher rd = Stapler.getCurrentRequest().getView(c, "help"+path);
- if(rd!=null) {// Jelly-generated help page
- rd.forward(req,rsp);
+ for (Class c = clazz; c != null; c = c.getSuperclass()) {
+ RequestDispatcher rd = Stapler.getCurrentRequest().getView(c, "help" + path);
+ if (rd != null) {// Jelly-generated help page
+ rd.forward(req, rsp);
return;
}
- InputStream in = getHelpStream(c,path);
- if(in!=null) {
+ InputStream in = getHelpStream(c, path);
+ if (in != null) {
// TODO: generalize macro expansion and perhaps even support JEXL
rsp.setContentType("text/html;charset=UTF-8");
- String literal = IOUtils.toString(in,"UTF-8");
- rsp.getWriter().println(Util.replaceMacro(literal, Collections.singletonMap("rootURL",req.getContextPath())));
+ String literal = IOUtils.toString(in, "UTF-8");
+ rsp.getWriter().println(Util.replaceMacro(literal, Collections.singletonMap("rootURL", req.getContextPath())));
in.close();
return;
}
@@ -726,41 +753,45 @@ public abstract class Descriptor<T extends Describable<T>> implements Saveable {
private InputStream getHelpStream(Class c, String suffix) {
Locale locale = Stapler.getCurrentRequest().getLocale();
- String base = c.getName().replace('.', '/').replace('$','/') + "/help"+suffix;
+ String base = c.getName().replace('.', '/').replace('$', '/') + "/help" + suffix;
ClassLoader cl = c.getClassLoader();
- if(cl==null) return null;
-
+ if (cl == null) {
+ return null;
+ }
+
InputStream in;
in = cl.getResourceAsStream(base + '_' + locale.getLanguage() + '_' + locale.getCountry() + '_' + locale.getVariant() + ".html");
- if(in!=null) return in;
+ if (in != null) {
+ return in;
+ }
in = cl.getResourceAsStream(base + '_' + locale.getLanguage() + '_' + locale.getCountry() + ".html");
- if(in!=null) return in;
+ if (in != null) {
+ return in;
+ }
in = cl.getResourceAsStream(base + '_' + locale.getLanguage() + ".html");
- if(in!=null) return in;
+ if (in != null) {
+ return in;
+ }
// default
- return cl.getResourceAsStream(base+".html");
+ return cl.getResourceAsStream(base + ".html");
}
-
//
// static methods
//
-
-
// to work around warning when creating a generic array type
- public static <T> T[] toArray( T... values ) {
+ public static <T> T[] toArray(T... values) {
return values;
}
- public static <T> List<T> toList( T... values ) {
+ public static <T> List<T> toList(T... values) {
return new ArrayList<T>(Arrays.asList(values));
}
- public static <T extends Describable<T>>
- Map<Descriptor<T>,T> toMap(Iterable<T> describables) {
- Map<Descriptor<T>,T> m = new LinkedHashMap<Descriptor<T>,T>();
+ public static <T extends Describable<T>> Map<Descriptor<T>, T> toMap(Iterable<T> describables) {
+ Map<Descriptor<T>, T> m = new LinkedHashMap<Descriptor<T>, T>();
if (null != describables) {
for (T d : describables) {
m.put(d.getDescriptor(), d);
@@ -770,37 +801,33 @@ public abstract class Descriptor<T extends Describable<T>> implements Saveable {
}
/**
- * Used to build {@link Describable} instance list from &lt;f:hetero-list> tag.
+ * Used to build {@link Describable} instance list from &lt;f:hetero-list>
+ * tag.
*
- * @param req
- * Request that represents the form submission.
- * @param formData
- * Structured form data that represents the contains data for the list of describables.
- * @param key
- * The JSON property name for 'formData' that represents the data for the list of describables.
- * @param descriptors
- * List of descriptors to create instances from.
- * @return
- * Can be empty but never null.
+ * @param req Request that represents the form submission.
+ * @param formData Structured form data that represents the contains data
+ * for the list of describables.
+ * @param key The JSON property name for 'formData' that represents the data
+ * for the list of describables.
+ * @param descriptors List of descriptors to create instances from.
+ * @return Can be empty but never null.
*/
- public static <T extends Describable<T>>
- List<T> newInstancesFromHeteroList(StaplerRequest req, JSONObject formData, String key,
- Collection<? extends Descriptor<T>> descriptors) throws FormException {
+ public static <T extends Describable<T>> List<T> newInstancesFromHeteroList(StaplerRequest req, JSONObject formData, String key,
+ Collection<? extends Descriptor<T>> descriptors) throws FormException {
- return newInstancesFromHeteroList(req,formData.get(key),descriptors);
+ return newInstancesFromHeteroList(req, formData.get(key), descriptors);
}
- public static <T extends Describable<T>>
- List<T> newInstancesFromHeteroList(StaplerRequest req, Object formData,
- Collection<? extends Descriptor<T>> descriptors) throws FormException {
+ public static <T extends Describable<T>> List<T> newInstancesFromHeteroList(StaplerRequest req, Object formData,
+ Collection<? extends Descriptor<T>> descriptors) throws FormException {
List<T> items = new ArrayList<T>();
- if (formData!=null) {
+ if (formData != null) {
for (Object o : JSONArray.fromObject(formData)) {
- JSONObject jo = (JSONObject)o;
+ JSONObject jo = (JSONObject) o;
String kind = jo.getString("kind");
- items.add(find(descriptors,kind).newInstance(req,jo));
+ items.add(find(descriptors, kind).newInstance(req, jo));
}
}
@@ -812,17 +839,19 @@ public abstract class Descriptor<T extends Describable<T>> implements Saveable {
*/
public static <T extends Descriptor> T find(Collection<? extends T> list, String className) {
for (T d : list) {
- if(d.getClass().getName().equals(className))
+ if (d.getClass().getName().equals(className)) {
return d;
+ }
}
return null;
}
public static Descriptor find(String className) {
- return find(Hudson.getInstance().getExtensionList(Descriptor.class),className);
+ return find(Hudson.getInstance().getExtensionList(Descriptor.class), className);
}
public static final class FormException extends Exception implements HttpResponse {
+
private final String formField;
public FormException(String message, String formField) {
@@ -849,20 +878,19 @@ public abstract class Descriptor<T extends Describable<T>> implements Saveable {
public void generateResponse(StaplerRequest req, StaplerResponse rsp, Object node) throws IOException, ServletException {
// for now, we can't really use the field name that caused the problem.
- new Failure(getMessage()).generateResponse(req,rsp,node);
+ new Failure(getMessage()).generateResponse(req, rsp, node);
}
}
-
private static final Logger LOGGER = Logger.getLogger(Descriptor.class.getName());
-
/**
* Used in {@link #checkMethods} to indicate that there's no check method.
*/
private static final String NONE = "\u0000";
private Object readResolve() {
- if (properties!=null)
+ if (properties != null) {
OldDataMonitor.report(this, "1.62");
+ }
return this;
}
}
diff --git a/hudson-core/src/main/java/hudson/model/DescriptorByNameOwner.java b/hudson-core/src/main/java/hudson/model/DescriptorByNameOwner.java
index b013f32..d9e0936 100644
--- a/hudson-core/src/main/java/hudson/model/DescriptorByNameOwner.java
+++ b/hudson-core/src/main/java/hudson/model/DescriptorByNameOwner.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
-*
-* Kohsuke Kawaguchi
- *
+ * Contributors:
+ *
+ * Kohsuke Kawaguchi
+ *
*
*******************************************************************************/
@@ -21,23 +21,23 @@ package hudson.model;
* Binding them at some specific object (instead of {@link Hudson}), allows
* {@link Descriptor}s to perform context-specific form field validation.
*
- * <p>
- * {@link Descriptor#getCheckUrl(String)} finds an ancestor with this interface
- * and generates URLs against it.
+ * <p> {@link Descriptor#getCheckUrl(String)} finds an ancestor with this
+ * interface and generates URLs against it.
*
* @author Kohsuke Kawaguchi
* @since 1.294
* @see Descriptor#getCheckUrl(String)
*/
public interface DescriptorByNameOwner extends ModelObject {
+
/**
* Exposes all {@link Descriptor}s by its name to URL.
*
- * <p>
- * Implementation should always delegate to {@link Hudson#getDescriptorByName(String)}.
+ * <p> Implementation should always delegate to
+ * {@link Hudson#getDescriptorByName(String)}.
*
- * @param id
- * Either {@link Descriptor#getId()} (recommended) or the short name.
+ * @param id Either {@link Descriptor#getId()} (recommended) or the short
+ * name.
*/
- Descriptor getDescriptorByName(String id);
+ Descriptor getDescriptorByName(String id);
}
diff --git a/hudson-core/src/main/java/hudson/model/DescriptorVisibilityFilter.java b/hudson-core/src/main/java/hudson/model/DescriptorVisibilityFilter.java
index 78e3d82..ad27e9a 100644
--- a/hudson-core/src/main/java/hudson/model/DescriptorVisibilityFilter.java
+++ b/hudson-core/src/main/java/hudson/model/DescriptorVisibilityFilter.java
@@ -8,7 +8,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- *
+ *
*
*******************************************************************************/
@@ -32,18 +32,16 @@ public abstract class DescriptorVisibilityFilter implements ExtensionPoint {
/**
* Decides if the given descriptor should be visible to the user.
*
- * @param context
- * The object that indicates where the visibility of a descriptor is evaluated.
- * For example, if Hudson is deciding whether a {@link FreeStyleProject} should gets a
- * {@link SCMDescriptor}, the context object will be the {@link FreeStyleProject}.
- * The caller can pass in null if there's no context.
- * @param descriptor
- * Descriptor whose visibility is evaluated. Never null.
+ * @param context The object that indicates where the visibility of a
+ * descriptor is evaluated. For example, if Hudson is deciding whether a
+ * {@link FreeStyleProject} should gets a {@link SCMDescriptor}, the context
+ * object will be the {@link FreeStyleProject}. The caller can pass in null
+ * if there's no context.
+ * @param descriptor Descriptor whose visibility is evaluated. Never null.
*
- * @return
- * true to allow the descriptor to be visible. false to hide it.
- * If any of the installed {@link DescriptorVisibilityFilter} returns false,
- * the descriptor is not shown.
+ * @return true to allow the descriptor to be visible. false to hide it. If
+ * any of the installed {@link DescriptorVisibilityFilter} returns false,
+ * the descriptor is not shown.
*/
public abstract boolean filter(Object context, Descriptor descriptor);
@@ -54,12 +52,13 @@ public abstract class DescriptorVisibilityFilter implements ExtensionPoint {
public static <T extends Descriptor> List<T> apply(Object context, Iterable<T> source) {
ExtensionList<DescriptorVisibilityFilter> filters = all();
List<T> r = new ArrayList<T>();
-
+
OUTER:
for (T d : source) {
for (DescriptorVisibilityFilter f : filters) {
- if (!f.filter(context,d))
+ if (!f.filter(context, d)) {
continue OUTER; // veto-ed. not shown
+ }
}
r.add(d);
}
diff --git a/hudson-core/src/main/java/hudson/model/DirectoryBrowserSupport.java b/hudson-core/src/main/java/hudson/model/DirectoryBrowserSupport.java
index bbeb888..f197544 100644
--- a/hudson-core/src/main/java/hudson/model/DirectoryBrowserSupport.java
+++ b/hudson-core/src/main/java/hudson/model/DirectoryBrowserSupport.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
*
* Kohsuke Kawaguchi, Erik Ramfelt
- *
+ *
*
*******************************************************************************/
@@ -47,9 +47,8 @@ import java.util.logging.Level;
/**
* Has convenience methods to serve file system.
*
- * <p>
- * This object can be used in a mix-in style to provide a directory browsing capability
- * to a {@link ModelObject}.
+ * <p> This object can be used in a mix-in style to provide a directory browsing
+ * capability to a {@link ModelObject}.
*
* @author Kohsuke Kawaguchi
*/
@@ -59,31 +58,27 @@ public final class DirectoryBrowserSupport implements HttpResponse {
public final ModelObject owner;
//TODO: review and check whether we can do it private
public final String title;
-
private final FilePath base;
private final String icon;
private final boolean serveDirIndex;
private String indexFileName = "index.html";
+
/**
- * @deprecated as of 1.297
- * Use {@link #DirectoryBrowserSupport(ModelObject, FilePath, String, String, boolean)}
+ * @deprecated as of 1.297 Use
+ * {@link #DirectoryBrowserSupport(ModelObject, FilePath, String, String, boolean)}
*/
public DirectoryBrowserSupport(ModelObject owner, String title) {
- this(owner,null,title,null,false);
+ this(owner, null, title, null, false);
}
/**
- * @param owner
- * The parent model object under which the directory browsing is added.
- * @param base
- * The root of the directory that's bound to URL.
- * @param title
- * Used in the HTML caption.
- * @param icon
- * The icon file name, like "folder.png"
- * @param serveDirIndex
- * True to generate the directory index.
- * False to serve "index.html"
+ * @param owner The parent model object under which the directory browsing
+ * is added.
+ * @param base The root of the directory that's bound to URL.
+ * @param title Used in the HTML caption.
+ * @param icon The icon file name, like "folder.png"
+ * @param serveDirIndex True to generate the directory index. False to serve
+ * "index.html"
*/
public DirectoryBrowserSupport(ModelObject owner, FilePath base, String title, String icon, boolean serveDirIndex) {
this.owner = owner;
@@ -95,15 +90,16 @@ public final class DirectoryBrowserSupport implements HttpResponse {
public void generateResponse(StaplerRequest req, StaplerResponse rsp, Object node) throws IOException, ServletException {
try {
- serveFile(req,rsp,base,icon,serveDirIndex);
+ serveFile(req, rsp, base, icon, serveDirIndex);
} catch (InterruptedException e) {
- throw new IOException2("interrupted",e);
+ throw new IOException2("interrupted", e);
}
}
/**
- * If the directory is requested but the directory listing is disabled, a file of this name
- * is served. By default it's "index.html".
+ * If the directory is requested but the directory listing is disabled, a
+ * file of this name is served. By default it's "index.html".
+ *
* @since 1.312
*/
public void setIndexFileName(String fileName) {
@@ -111,29 +107,29 @@ public final class DirectoryBrowserSupport implements HttpResponse {
}
/**
- * Serves a file from the file system (Maps the URL to a directory in a file system.)
+ * Serves a file from the file system (Maps the URL to a directory in a file
+ * system.)
*
- * @param icon
- * The icon file name, like "folder-open.png"
- * @param serveDirIndex
- * True to generate the directory index.
- * False to serve "index.html"
- * @deprecated as of 1.297
- * Instead of calling this method explicitly, just return the {@link DirectoryBrowserSupport} object
- * from the {@code doXYZ} method and let Stapler generate a response for you.
+ * @param icon The icon file name, like "folder-open.png"
+ * @param serveDirIndex True to generate the directory index. False to serve
+ * "index.html"
+ * @deprecated as of 1.297 Instead of calling this method explicitly, just
+ * return the {@link DirectoryBrowserSupport} object from the {@code doXYZ}
+ * method and let Stapler generate a response for you.
*/
public void serveFile(StaplerRequest req, StaplerResponse rsp, FilePath root, String icon, boolean serveDirIndex) throws IOException, ServletException, InterruptedException {
// handle form submission
String pattern = req.getParameter("pattern");
- if(pattern==null)
+ if (pattern == null) {
pattern = req.getParameter("path"); // compatibility with Hudson<1.129
- if(pattern!=null) {
+ }
+ if (pattern != null) {
rsp.sendRedirect2(pattern);
return;
}
String path = getPath(req);
- if(path.replace('\\','/').indexOf("/../")!=-1) {
+ if (path.replace('\\', '/').indexOf("/../") != -1) {
// don't serve anything other than files in the artifacts dir
rsp.sendError(HttpServletResponse.SC_BAD_REQUEST);
return;
@@ -143,48 +139,52 @@ public final class DirectoryBrowserSupport implements HttpResponse {
// and the GLOB portion "**/*.xml" (the rest)
StringBuilder _base = new StringBuilder();
StringBuilder _rest = new StringBuilder();
- int restSize=-1; // number of ".." needed to go back to the 'base' level.
- boolean zip=false; // if we are asked to serve a zip file bundle
+ int restSize = -1; // number of ".." needed to go back to the 'base' level.
+ boolean zip = false; // if we are asked to serve a zip file bundle
boolean plain = false; // if asked to serve a plain text directory listing
{
boolean inBase = true;
- StringTokenizer pathTokens = new StringTokenizer(path,"/");
- while(pathTokens.hasMoreTokens()) {
+ StringTokenizer pathTokens = new StringTokenizer(path, "/");
+ while (pathTokens.hasMoreTokens()) {
String pathElement = pathTokens.nextToken();
// Treat * and ? as wildcard unless they match a literal filename
- if((pathElement.contains("?") || pathElement.contains("*"))
- && inBase && !(new FilePath(root, (_base.length() > 0 ? _base + "/" : "") + pathElement).exists()))
+ if ((pathElement.contains("?") || pathElement.contains("*"))
+ && inBase && !(new FilePath(root, (_base.length() > 0 ? _base + "/" : "") + pathElement).exists())) {
inBase = false;
- if(pathElement.equals("*zip*")) {
+ }
+ if (pathElement.equals("*zip*")) {
// the expected syntax is foo/bar/*zip*/bar.zip
// the last 'bar.zip' portion is to causes browses to set a good default file name.
// so the 'rest' portion ends here.
- zip=true;
+ zip = true;
break;
}
- if(pathElement.equals("*plain*")) {
+ if (pathElement.equals("*plain*")) {
plain = true;
break;
}
- StringBuilder sb = inBase?_base:_rest;
- if(sb.length()>0) sb.append('/');
+ StringBuilder sb = inBase ? _base : _rest;
+ if (sb.length() > 0) {
+ sb.append('/');
+ }
sb.append(pathElement);
- if(!inBase)
+ if (!inBase) {
restSize++;
+ }
}
}
- restSize = Math.max(restSize,0);
+ restSize = Math.max(restSize, 0);
String base = _base.toString();
String rest = _rest.toString();
// this is the base file/directory
- FilePath baseFile = new FilePath(root,base);
+ FilePath baseFile = new FilePath(root, base);
- if(baseFile.isDirectory()) {
- if(zip) {
+ if (baseFile.isDirectory()) {
+ if (zip) {
rsp.setContentType("application/zip");
- baseFile.zip(rsp.getOutputStream(),rest);
+ baseFile.zip(rsp.getOutputStream(), rest);
return;
}
if (plain) {
@@ -202,10 +202,10 @@ public final class DirectoryBrowserSupport implements HttpResponse {
return;
}
- if(rest.length()==0) {
+ if (rest.length() == 0) {
// if the target page to be displayed is a directory and the path doesn't end with '/', redirect
StringBuffer reqUrl = req.getRequestURL();
- if(reqUrl.charAt(reqUrl.length()-1)!='/') {
+ if (reqUrl.charAt(reqUrl.length() - 1) != '/') {
rsp.sendRedirect2(reqUrl.append('/').toString());
return;
}
@@ -213,28 +213,27 @@ public final class DirectoryBrowserSupport implements HttpResponse {
FileCallable<List<List<Path>>> glob = null;
- if(rest.length()>0) {
+ if (rest.length() > 0) {
// the rest is Ant glob pattern
- glob = new PatternScanner(rest,createBackRef(restSize));
- } else
- if(serveDirIndex) {
+ glob = new PatternScanner(rest, createBackRef(restSize));
+ } else if (serveDirIndex) {
// serve directory index
glob = new ChildPathBuilder();
}
- if(glob!=null) {
+ if (glob != null) {
// serve glob
req.setAttribute("it", this);
- List<Path> parentPaths = buildParentPath(base,restSize);
- req.setAttribute("parentPath",parentPaths);
+ List<Path> parentPaths = buildParentPath(base, restSize);
+ req.setAttribute("parentPath", parentPaths);
req.setAttribute("backPath", createBackRef(restSize));
- req.setAttribute("topPath", createBackRef(parentPaths.size()+restSize));
+ req.setAttribute("topPath", createBackRef(parentPaths.size() + restSize));
req.setAttribute("files", baseFile.act(glob));
req.setAttribute("icon", icon);
req.setAttribute("path", path);
- req.setAttribute("pattern",rest);
+ req.setAttribute("pattern", rest);
req.setAttribute("dir", baseFile);
- req.getView(this,"dir.jelly").forward(req, rsp);
+ req.getView(this, "dir.jelly").forward(req, rsp);
return;
}
@@ -244,22 +243,23 @@ public final class DirectoryBrowserSupport implements HttpResponse {
}
//serve a single file
- if(!baseFile.exists()) {
+ if (!baseFile.exists()) {
rsp.sendError(HttpServletResponse.SC_NOT_FOUND);
return;
}
boolean view = rest.equals("*view*");
- if(rest.equals("*fingerprint*")) {
- rsp.forward(Hudson.getInstance().getFingerprint(baseFile.digest()),"/",req);
+ if (rest.equals("*fingerprint*")) {
+ rsp.forward(Hudson.getInstance().getFingerprint(baseFile.digest()), "/", req);
return;
}
ContentInfo ci = baseFile.act(new ContentInfo());
- if(LOGGER.isLoggable(Level.FINE))
- LOGGER.fine("Serving "+baseFile+" with lastModified="+ci.lastModified+", contentLength="+ci.contentLength);
+ if (LOGGER.isLoggable(Level.FINE)) {
+ LOGGER.fine("Serving " + baseFile + " with lastModified=" + ci.lastModified + ", contentLength=" + ci.contentLength);
+ }
InputStream in = baseFile.read();
if (view) {
@@ -269,14 +269,15 @@ public final class DirectoryBrowserSupport implements HttpResponse {
// pseudo file name to let the Stapler set text/plain
rsp.serveFile(req, in, ci.lastModified, -1, ci.contentLength, "plain.txt");
} else {
- rsp.serveFile(req, in, ci.lastModified, -1, ci.contentLength, baseFile.getName() );
+ rsp.serveFile(req, in, ci.lastModified, -1, ci.contentLength, baseFile.getName());
}
}
private String getPath(StaplerRequest req) {
String path = req.getRestOfPath();
- if(path.length()==0)
+ if (path.length() == 0) {
path = "/";
+ }
return path;
}
@@ -289,6 +290,7 @@ public final class DirectoryBrowserSupport implements HttpResponse {
}
private static final class ContentInfo implements FileCallable<ContentInfo> {
+
long contentLength;
long lastModified;
@@ -297,32 +299,34 @@ public final class DirectoryBrowserSupport implements HttpResponse {
lastModified = f.lastModified();
return this;
}
-
private static final long serialVersionUID = 1L;
}
/**
- * Builds a list of {@link Path} that represents ancestors
- * from a string like "/foo/bar/zot".
+ * Builds a list of {@link Path} that represents ancestors from a string
+ * like "/foo/bar/zot".
*/
private List<Path> buildParentPath(String pathList, int restSize) {
List<Path> r = new ArrayList<Path>();
StringTokenizer tokens = new StringTokenizer(pathList, "/");
int total = tokens.countTokens();
- int current=1;
- while(tokens.hasMoreTokens()) {
+ int current = 1;
+ while (tokens.hasMoreTokens()) {
String token = tokens.nextToken();
- r.add(new Path(createBackRef(total-current+restSize),token,true,0, true));
+ r.add(new Path(createBackRef(total - current + restSize), token, true, 0, true));
current++;
}
return r;
}
private static String createBackRef(int times) {
- if(times==0) return "./";
- StringBuilder buf = new StringBuilder(3*times);
- for(int i=0; i<times; i++ )
+ if (times == 0) {
+ return "./";
+ }
+ StringBuilder buf = new StringBuilder(3 * times);
+ for (int i = 0; i < times; i++) {
buf.append("../");
+ }
return buf.toString();
}
@@ -330,6 +334,7 @@ public final class DirectoryBrowserSupport implements HttpResponse {
* Represents information about one file or folder.
*/
public static final class Path implements Serializable {
+
/**
* Relative URL to this path from the current page.
*/
@@ -338,16 +343,13 @@ public final class DirectoryBrowserSupport implements HttpResponse {
* Name of this path. Just the file name portion.
*/
private final String title;
-
private final boolean isFolder;
-
/**
* File size, or null if this is not a file.
*/
private final long size;
-
/**
- * If the current user can read the file.
+ * If the current user can read the file.
*/
private final boolean isReadable;
@@ -362,7 +364,7 @@ public final class DirectoryBrowserSupport implements HttpResponse {
public boolean isFolder() {
return isFolder;
}
-
+
public boolean isReadable() {
return isReadable;
}
@@ -376,42 +378,48 @@ public final class DirectoryBrowserSupport implements HttpResponse {
}
public String getIconName() {
- if (isReadable)
- return isFolder?"folder.png":"text.png";
- else
- return isFolder?"folder-error.png":"text-error.png";
+ if (isReadable) {
+ return isFolder ? "folder.png" : "text.png";
+ } else {
+ return isFolder ? "folder-error.png" : "text-error.png";
+ }
}
public long getSize() {
return size;
}
-
private static final long serialVersionUID = 1L;
}
-
-
private static final class FileComparator implements Comparator<File> {
+
public int compare(File lhs, File rhs) {
// directories first, files next
- int r = dirRank(lhs)-dirRank(rhs);
- if(r!=0) return r;
+ int r = dirRank(lhs) - dirRank(rhs);
+ if (r != 0) {
+ return r;
+ }
// otherwise alphabetical
return lhs.getName().compareTo(rhs.getName());
}
private int dirRank(File f) {
- if(f.isDirectory()) return 0;
- else return 1;
+ if (f.isDirectory()) {
+ return 0;
+ } else {
+ return 1;
+ }
}
}
/**
- * Simple list of names of children of a folder.
- * Subfolders will have a trailing slash appended.
+ * Simple list of names of children of a folder. Subfolders will have a
+ * trailing slash appended.
*/
private static final class SimpleChildList implements FileCallable<List<String>> {
+
private static final long serialVersionUID = 1L;
+
public List<String> invoke(File f, VirtualChannel channel) throws IOException {
List<String> r = new ArrayList<String>();
String[] kids = f.list(); // no need to sort
@@ -427,39 +435,41 @@ public final class DirectoryBrowserSupport implements HttpResponse {
}
/**
- * Builds a list of list of {@link Path}. The inner
- * list of {@link Path} represents one child item to be shown
- * (this mechanism is used to skip empty intermediate directory.)
+ * Builds a list of list of {@link Path}. The inner list of {@link Path}
+ * represents one child item to be shown (this mechanism is used to skip
+ * empty intermediate directory.)
*/
private static final class ChildPathBuilder implements FileCallable<List<List<Path>>> {
+
public List<List<Path>> invoke(File cur, VirtualChannel channel) throws IOException {
List<List<Path>> r = new ArrayList<List<Path>>();
File[] files = cur.listFiles();
if (files != null) {
- Arrays.sort(files,new FileComparator());
-
- for( File f : files ) {
- Path p = new Path(Util.rawEncode(f.getName()),f.getName(),f.isDirectory(),f.length(), f.canRead());
- if(!f.isDirectory()) {
+ Arrays.sort(files, new FileComparator());
+
+ for (File f : files) {
+ Path p = new Path(Util.rawEncode(f.getName()), f.getName(), f.isDirectory(), f.length(), f.canRead());
+ if (!f.isDirectory()) {
r.add(Collections.singletonList(p));
} else {
// find all empty intermediate directory
List<Path> l = new ArrayList<Path>();
l.add(p);
String relPath = Util.rawEncode(f.getName());
- while(true) {
+ while (true) {
// files that don't start with '.' qualify for 'meaningful files', nor SCM related files
File[] sub = f.listFiles(new FilenameFilter() {
public boolean accept(File dir, String name) {
return !name.startsWith(".") && !name.equals("CVS") && !name.equals(".svn");
}
});
- if(sub==null || sub.length!=1 || !sub[0].isDirectory())
+ if (sub == null || sub.length != 1 || !sub[0].isDirectory()) {
break;
+ }
f = sub[0];
- relPath += '/'+Util.rawEncode(f.getName());
- l.add(new Path(relPath,f.getName(),true,0, f.canRead()));
+ relPath += '/' + Util.rawEncode(f.getName());
+ l.add(new Path(relPath, f.getName(), true, 0, f.canRead()));
}
r.add(l);
}
@@ -468,7 +478,6 @@ public final class DirectoryBrowserSupport implements HttpResponse {
return r;
}
-
private static final long serialVersionUID = 1L;
}
@@ -477,26 +486,27 @@ public final class DirectoryBrowserSupport implements HttpResponse {
* paths.
*/
private static class PatternScanner implements FileCallable<List<List<Path>>> {
+
private final String pattern;
/**
* String like "../../../" that cancels the 'rest' portion. Can be "./"
*/
private final String baseRef;
- public PatternScanner(String pattern,String baseRef) {
+ public PatternScanner(String pattern, String baseRef) {
this.pattern = pattern;
this.baseRef = baseRef;
}
public List<List<Path>> invoke(File baseDir, VirtualChannel channel) throws IOException {
- FileSet fs = Util.createFileSet(baseDir,pattern);
+ FileSet fs = Util.createFileSet(baseDir, pattern);
DirectoryScanner ds = fs.getDirectoryScanner();
String[] files = ds.getIncludedFiles();
if (files.length > 0) {
List<List<Path>> r = new ArrayList<List<Path>>(files.length);
for (String match : files) {
- List<Path> file = buildPathList(baseDir, new File(baseDir,match));
+ List<Path> file = buildPathList(baseDir, new File(baseDir, match));
r.add(file);
}
return r;
@@ -506,7 +516,8 @@ public final class DirectoryBrowserSupport implements HttpResponse {
}
/**
- * Builds a path list from the current workspace directory down to the specified file path.
+ * Builds a path list from the current workspace directory down to the
+ * specified file path.
*/
private List<Path> buildPathList(File baseDir, File filePath) throws IOException {
List<Path> pathList = new ArrayList<Path>();
@@ -533,9 +544,7 @@ public final class DirectoryBrowserSupport implements HttpResponse {
Path path = new Path(href.toString(), filePath.getName(), filePath.isDirectory(), filePath.length(), filePath.canRead());
pathList.add(path);
}
-
private static final long serialVersionUID = 1L;
}
-
private static final Logger LOGGER = Logger.getLogger(DirectoryBrowserSupport.class.getName());
}
diff --git a/hudson-core/src/main/java/hudson/model/DownloadService.java b/hudson-core/src/main/java/hudson/model/DownloadService.java
index d540dda..2f2a5be 100644
--- a/hudson-core/src/main/java/hudson/model/DownloadService.java
+++ b/hudson-core/src/main/java/hudson/model/DownloadService.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
-*
-* Kohsuke Kawaguchi
- *
+ * Contributors:
+ *
+ * Kohsuke Kawaguchi
+ *
*
*******************************************************************************/
@@ -35,17 +35,17 @@ import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
/**
- * Service for plugins to periodically retrieve update data files
- * (like the one in the update center) through browsers.
+ * Service for plugins to periodically retrieve update data files (like the one
+ * in the update center) through browsers.
*
- * <p>
- * Because the retrieval of the file goes through XmlHttpRequest,
- * we cannot reliably pass around binary.
+ * <p> Because the retrieval of the file goes through XmlHttpRequest, we cannot
+ * reliably pass around binary.
*
* @author Kohsuke Kawaguchi
*/
@Extension
public class DownloadService extends PageDecorator {
+
public DownloadService() {
super(DownloadService.class);
}
@@ -54,29 +54,31 @@ public class DownloadService extends PageDecorator {
* Builds up an HTML fragment that starts all the download jobs.
*/
public String generateFragment() {
- if (neverUpdate) return "";
-
+ if (neverUpdate) {
+ return "";
+ }
+
StringBuilder buf = new StringBuilder();
- if(Hudson.getInstance().hasPermission(Hudson.READ)) {
+ if (Hudson.getInstance().hasPermission(Hudson.READ)) {
long now = System.currentTimeMillis();
for (Downloadable d : Downloadable.all()) {
- if(d.getDue()<now && d.lastAttempt+10*1000<now) {
+ if (d.getDue() < now && d.lastAttempt + 10 * 1000 < now) {
buf.append("<script>")
- .append("Behaviour.addLoadEvent(function() {")
- .append(" downloadService.download(")
- .append(QuotedStringTokenizer.quote(d.getId()))
- .append(',')
- .append(QuotedStringTokenizer.quote(d.getUrl()))
- .append(',')
- .append("{version:")
- .append(QuotedStringTokenizer.quote(Hudson.VERSION + "-" + Util.getDigestOf(Hudson.getInstance().getSecretKey())))
- .append('}')
- .append(',')
- .append(QuotedStringTokenizer.quote(Stapler.getCurrentRequest().getContextPath()+'/'+getUrl()+"/byId/"+d.getId()+"/postBack"))
- .append(',')
- .append("null);")
- .append("});")
- .append("</script>");
+ .append("Behaviour.addLoadEvent(function() {")
+ .append(" downloadService.download(")
+ .append(QuotedStringTokenizer.quote(d.getId()))
+ .append(',')
+ .append(QuotedStringTokenizer.quote(d.getUrl()))
+ .append(',')
+ .append("{version:")
+ .append(QuotedStringTokenizer.quote(Hudson.VERSION + "-" + Util.getDigestOf(Hudson.getInstance().getSecretKey())))
+ .append('}')
+ .append(',')
+ .append(QuotedStringTokenizer.quote(Stapler.getCurrentRequest().getContextPath() + '/' + getUrl() + "/byId/" + d.getId() + "/postBack"))
+ .append(',')
+ .append("null);")
+ .append("});")
+ .append("</script>");
d.lastAttempt = now;
}
}
@@ -85,41 +87,42 @@ public class DownloadService extends PageDecorator {
}
/**
- * Gets {@link Downloadable} by its ID.
- * Used to bind them to URL.
+ * Gets {@link Downloadable} by its ID. Used to bind them to URL.
*/
public Downloadable getById(String id) {
- for (Downloadable d : Downloadable.all())
- if(d.getId().equals(id))
+ for (Downloadable d : Downloadable.all()) {
+ if (d.getId().equals(id)) {
return d;
+ }
+ }
return null;
}
/**
- * Represents a periodically updated JSON data file obtained from a remote URL.
+ * Represents a periodically updated JSON data file obtained from a remote
+ * URL.
*
- * <p>
- * This mechanism is one of the basis of the update center, which involves fetching
- * up-to-date data file.
+ * <p> This mechanism is one of the basis of the update center, which
+ * involves fetching up-to-date data file.
*
* @since 1.305
*/
public static class Downloadable implements ExtensionPoint {
+
private final String id;
private final String url;
private final long interval;
- private volatile long due=0;
- private volatile long lastAttempt=Long.MIN_VALUE;
+ private volatile long due = 0;
+ private volatile long lastAttempt = Long.MIN_VALUE;
/**
*
- * @param url
- * URL relative to {@link UpdateCenter#getUrl()}.
- * So if this string is "foo.json", the ultimate URL will be
- * something like "https://hudson.java.net/foo.json"
+ * @param url URL relative to {@link UpdateCenter#getUrl()}. So if this
+ * string is "foo.json", the ultimate URL will be something like
+ * "https://hudson.java.net/foo.json"
*
- * For security and privacy reasons, we don't allow the retrieval
- * from random locations.
+ * For security and privacy reasons, we don't allow the retrieval from
+ * random locations.
*/
public Downloadable(String id, String url, long interval) {
this.id = id;
@@ -131,15 +134,15 @@ public class DownloadService extends PageDecorator {
* Uses the class name as an ID.
*/
public Downloadable(Class id) {
- this(id.getName().replace('$','.'));
+ this(id.getName().replace('$', '.'));
}
public Downloadable(String id) {
- this(id,id+".json");
+ this(id, id + ".json");
}
public Downloadable(String id, String url) {
- this(id,url,TimeUnit2.DAYS.toMillis(1));
+ this(id, url, TimeUnit2.DAYS.toMillis(1));
}
public String getId() {
@@ -150,14 +153,13 @@ public class DownloadService extends PageDecorator {
* URL to download.
*/
public String getUrl() {
- return Hudson.getInstance().getUpdateCenter().getDefaultBaseUrl()+"updates/"+url;
+ return Hudson.getInstance().getUpdateCenter().getDefaultBaseUrl() + "updates/" + url;
}
/**
* How often do we retrieve the new image?
*
- * @return
- * number of milliseconds between retrieval.
+ * @return number of milliseconds between retrieval.
*/
public long getInterval() {
return interval;
@@ -167,42 +169,44 @@ public class DownloadService extends PageDecorator {
* This is where the retrieved file will be stored.
*/
public TextFile getDataFile() {
- return new TextFile(new File(Hudson.getInstance().getRootDir(),"updates/"+id));
+ return new TextFile(new File(Hudson.getInstance().getRootDir(), "updates/" + id));
}
/**
* When shall we retrieve this file next time?
*/
public long getDue() {
- if(due==0)
- // if the file doesn't exist, this code should result
- // in a very small (but >0) due value, which should trigger
- // the retrieval immediately.
- due = getDataFile().file.lastModified()+interval;
+ if (due == 0) // if the file doesn't exist, this code should result
+ // in a very small (but >0) due value, which should trigger
+ // the retrieval immediately.
+ {
+ due = getDataFile().file.lastModified() + interval;
+ }
return due;
}
/**
- * Loads the current file into JSON and returns it, or null
- * if no data exists.
+ * Loads the current file into JSON and returns it, or null if no data
+ * exists.
*/
public JSONObject getData() throws IOException {
TextFile df = getDataFile();
- if(df.exists())
+ if (df.exists()) {
return JSONObject.fromObject(df.read());
+ }
return null;
}
/**
- * This is where the browser sends us the data.
+ * This is where the browser sends us the data.
*/
public void doPostBack(StaplerRequest req, StaplerResponse rsp) throws IOException {
long dataTimestamp = System.currentTimeMillis();
TextFile df = getDataFile();
- df.write(IOUtils.toString(req.getInputStream(),"UTF-8"));
+ df.write(IOUtils.toString(req.getInputStream(), "UTF-8"));
df.file.setLastModified(dataTimestamp);
- due = dataTimestamp+getInterval();
- LOGGER.info("Obtained the updated data file for "+id);
+ due = dataTimestamp + getInterval();
+ LOGGER.info("Obtained the updated data file for " + id);
rsp.setContentType("text/plain"); // So browser won't try to parse response
}
@@ -218,15 +222,13 @@ public class DownloadService extends PageDecorator {
*/
public static Downloadable get(String id) {
for (Downloadable d : all()) {
- if(d.id.equals(id))
+ if (d.id.equals(id)) {
return d;
+ }
}
return null;
}
-
private static final Logger LOGGER = Logger.getLogger(Downloadable.class.getName());
}
-
- public static boolean neverUpdate = Boolean.getBoolean(DownloadService.class.getName()+".never");
+ public static boolean neverUpdate = Boolean.getBoolean(DownloadService.class.getName() + ".never");
}
-
diff --git a/hudson-core/src/main/java/hudson/model/Environment.java b/hudson-core/src/main/java/hudson/model/Environment.java
index b238060..4bacd18 100644
--- a/hudson-core/src/main/java/hudson/model/Environment.java
+++ b/hudson-core/src/main/java/hudson/model/Environment.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
-*
-* Tom Huybrechts
- *
+ * Contributors:
+ *
+ * Tom Huybrechts
+ *
*
*******************************************************************************/
@@ -23,76 +23,69 @@ import java.io.IOException;
import java.util.Map;
/**
- * Represents some resources that are set up for the duration of a build
- * to be torn down when the build is over.
+ * Represents some resources that are set up for the duration of a build to be
+ * torn down when the build is over.
*
- * <p>
- * This is often used to run a parallel server necessary during a build,
- * such as an application server, a database reserved for the build,
- * X server for performing UI tests, etc.
+ * <p> This is often used to run a parallel server necessary during a build,
+ * such as an application server, a database reserved for the build, X server
+ * for performing UI tests, etc.
*
- * <p>
- * By having a plugin that does this, instead of asking each build script to do this,
- * we can simplify the build script. {@link Environment} abstraction also gives
- * you guaranteed "tear down" phase, so that such resource won't keep running forever.
+ * <p> By having a plugin that does this, instead of asking each build script to
+ * do this, we can simplify the build script. {@link Environment} abstraction
+ * also gives you guaranteed "tear down" phase, so that such resource won't keep
+ * running forever.
*
* @since 1.286
*/
public abstract class Environment {
- /**
- * Adds environmental variables for the builds to the given map.
- *
- * <p>
- * If the {@link Environment} object wants to pass in information to the
- * build that runs, it can do so by exporting additional environment
- * variables to the map.
- *
- * <p>
- * When this method is invoked, the map already contains the current
- * "planned export" list.
- *
- * @param env
- * never null. This really should have been typed as {@link EnvVars}
- * but by the time we realized it it was too late.
- */
- public void buildEnvVars(Map<String,String> env) {
- // no-op by default
- }
- /**
- * Runs after the {@link Builder} completes, and performs a tear down.
- *
- * <p>
- * This method is invoked even when the build failed, so that the clean up
- * operation can be performed regardless of the build result (for example,
- * you'll want to stop application server even if a build fails.)
- *
- * @param build
- * The same {@link Build} object given to the set up method.
- * @param listener
- * The same {@link BuildListener} object given to the set up
- * method.
- * @return true if the build can continue, false if there was an error and
- * the build needs to be aborted.
- * @throws IOException
- * terminates the build abnormally. Hudson will handle the
- * exception and reports a nice error message.
- */
- public boolean tearDown(AbstractBuild build, BuildListener listener)
- throws IOException, InterruptedException {
- return true;
- }
+ /**
+ * Adds environmental variables for the builds to the given map.
+ *
+ * <p> If the {@link Environment} object wants to pass in information to the
+ * build that runs, it can do so by exporting additional environment
+ * variables to the map.
+ *
+ * <p> When this method is invoked, the map already contains the current
+ * "planned export" list.
+ *
+ * @param env never null. This really should have been typed as
+ * {@link EnvVars} but by the time we realized it it was too late.
+ */
+ public void buildEnvVars(Map<String, String> env) {
+ // no-op by default
+ }
+
+ /**
+ * Runs after the {@link Builder} completes, and performs a tear down.
+ *
+ * <p> This method is invoked even when the build failed, so that the clean
+ * up operation can be performed regardless of the build result (for
+ * example, you'll want to stop application server even if a build fails.)
+ *
+ * @param build The same {@link Build} object given to the set up method.
+ * @param listener The same {@link BuildListener} object given to the set up
+ * method.
+ * @return true if the build can continue, false if there was an error and
+ * the build needs to be aborted.
+ * @throws IOException terminates the build abnormally. Hudson will handle
+ * the exception and reports a nice error message.
+ */
+ public boolean tearDown(AbstractBuild build, BuildListener listener)
+ throws IOException, InterruptedException {
+ return true;
+ }
/**
- * Creates {@link Environment} implementation that just sets the variables as given in the parameter.
+ * Creates {@link Environment} implementation that just sets the variables
+ * as given in the parameter.
*/
- public static Environment create(final EnvVars envVars) {
- return new Environment() {
- @Override
- public void buildEnvVars(Map<String, String> env) {
- env.putAll(envVars);
- }
- };
- }
-
+ public static Environment create(final EnvVars envVars) {
+ return new Environment() {
+ @Override
+ public void buildEnvVars(Map<String, String> env) {
+ env.putAll(envVars);
+ }
+ };
+ }
}
diff --git a/hudson-core/src/main/java/hudson/model/EnvironmentContributingAction.java b/hudson-core/src/main/java/hudson/model/EnvironmentContributingAction.java
index 29f1b7d..3dfe727 100644
--- a/hudson-core/src/main/java/hudson/model/EnvironmentContributingAction.java
+++ b/hudson-core/src/main/java/hudson/model/EnvironmentContributingAction.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -21,12 +21,13 @@ import hudson.EnvVars;
/**
* {@link Action} that contributes environment variables during a build.
*
- * <p>
- * For example, your {@link hudson.tasks.Builder} can add an {@link EnvironmentContributingAction} so that
- * the rest of the builders or publishers see some behavior changes.
+ * <p> For example, your {@link hudson.tasks.Builder} can add an
+ * {@link EnvironmentContributingAction} so that the rest of the builders or
+ * publishers see some behavior changes.
*
- * Another use case is for you to {@linkplain Queue#schedule(hudson.model.Queue.Task, int, Action...) submit a job} with
- * {@link EnvironmentContributingAction}s.
+ * Another use case is for you to
+ * {@linkplain Queue#schedule(hudson.model.Queue.Task, int, Action...) submit a job}
+ * with {@link EnvironmentContributingAction}s.
*
* @author Kohsuke Kawaguchi
* @since 1.318
@@ -34,13 +35,13 @@ import hudson.EnvVars;
* @see hudson.tasks.BuildWrapper
*/
public interface EnvironmentContributingAction extends Action {
+
/**
- * Called by {@link AbstractBuild} to allow plugins to contribute environment variables.
+ * Called by {@link AbstractBuild} to allow plugins to contribute
+ * environment variables.
*
- * @param build
- * The calling build. Never null.
- * @param env
- * Environment variables should be added to this map.
+ * @param build The calling build. Never null.
+ * @param env Environment variables should be added to this map.
*/
- public void buildEnvVars(AbstractBuild<?,?> build, EnvVars env);
+ public void buildEnvVars(AbstractBuild<?, ?> build, EnvVars env);
}
diff --git a/hudson-core/src/main/java/hudson/model/EnvironmentContributor.java b/hudson-core/src/main/java/hudson/model/EnvironmentContributor.java
index 825e9dd..ff8711c 100644
--- a/hudson-core/src/main/java/hudson/model/EnvironmentContributor.java
+++ b/hudson-core/src/main/java/hudson/model/EnvironmentContributor.java
@@ -7,7 +7,7 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
*
*
*******************************************************************************/
@@ -35,7 +35,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
-
package hudson.model;
import hudson.EnvVars;
@@ -47,35 +46,33 @@ import java.io.IOException;
/**
* Contributes environment variables to builds.
*
- * <p>
- * This extension point can be used to externally add environment variables. Aside from adding environment variables
- * of the fixed name, a typical strategy is to look for specific {@link JobProperty}s and other similar configurations
+ * <p> This extension point can be used to externally add environment variables.
+ * Aside from adding environment variables of the fixed name, a typical strategy
+ * is to look for specific {@link JobProperty}s and other similar configurations
* of {@link Job}s to compute values.
*
* @author Kohsuke Kawaguchi
* @since 1.392
*/
public abstract class EnvironmentContributor implements ExtensionPoint {
+
/**
* Contributes environment variables used for a build.
*
- * <p>
- * This method can be called repeatedly for the same {@link Run}, thus
- * the computation of this method needs to be efficient. If you have a time-consuming
- * computation, one strategy is to take the hit once and then add the result as {@link InvisibleAction}
- * to {@link Run}, then reuse those values later on.
+ * <p> This method can be called repeatedly for the same {@link Run}, thus
+ * the computation of this method needs to be efficient. If you have a
+ * time-consuming computation, one strategy is to take the hit once and then
+ * add the result as {@link InvisibleAction} to {@link Run}, then reuse
+ * those values later on.
*
- * <p>
- * This method gets invoked concurrently for multiple {@link Run}s that are being built at the same time,
- * so it must be concurrent-safe.
+ * <p> This method gets invoked concurrently for multiple {@link Run}s that
+ * are being built at the same time, so it must be concurrent-safe.
*
- * @param r
- * Build that's being performed. Never null.
- * @param envs
- * Partially built environment variable map. Implementation of this method is expected to
- * add additional variables here. Never null.
- * @param listener
- * Connected to the build console. Can be used to report errors. Never null.
+ * @param r Build that's being performed. Never null.
+ * @param envs Partially built environment variable map. Implementation of
+ * this method is expected to add additional variables here. Never null.
+ * @param listener Connected to the build console. Can be used to report
+ * errors. Never null.
*/
public abstract void buildEnvironmentFor(Run r, EnvVars envs, TaskListener listener) throws IOException, InterruptedException;
diff --git a/hudson-core/src/main/java/hudson/model/EnvironmentSpecific.java b/hudson-core/src/main/java/hudson/model/EnvironmentSpecific.java
index 40f4a39..0ec7196 100644
--- a/hudson-core/src/main/java/hudson/model/EnvironmentSpecific.java
+++ b/hudson-core/src/main/java/hudson/model/EnvironmentSpecific.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
-*
-* Tom Huybrechts
- *
+ * Contributors:
+ *
+ * Tom Huybrechts
+ *
*
*******************************************************************************/
@@ -21,17 +21,17 @@ import hudson.slaves.NodeSpecific;
/**
* Represents any concept that can be adapted for a certain environment.
- *
+ *
* Mainly for documentation purposes.
*
* @since 1.286
- * @param <T>
- * Concrete type that represents the thing that can be adapted.
+ * @param <T> Concrete type that represents the thing that can be adapted.
* @see NodeSpecific
*/
public interface EnvironmentSpecific<T extends EnvironmentSpecific<T>> {
- /**
- * Returns a specialized copy of T for functioning in the given environment.
- */
- T forEnvironment(EnvVars environment);
+
+ /**
+ * Returns a specialized copy of T for functioning in the given environment.
+ */
+ T forEnvironment(EnvVars environment);
}
diff --git a/hudson-core/src/main/java/hudson/model/Executor.java b/hudson-core/src/main/java/hudson/model/Executor.java
index 5cea7e0..f3e5ee5 100644
--- a/hudson-core/src/main/java/hudson/model/Executor.java
+++ b/hudson-core/src/main/java/hudson/model/Executor.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
*
* Kohsuke Kawaguchi, Winston Prakash, Brian Westrich, Stephen Connolly, Tom Huybrechts
- *
+ *
*******************************************************************************/
package hudson.model;
@@ -40,7 +40,6 @@ import java.lang.reflect.Method;
import static hudson.model.queue.Executables.*;
import org.eclipse.hudson.security.HudsonSecurityManager;
-
/**
* Thread that executes builds.
*
@@ -48,32 +47,30 @@ import org.eclipse.hudson.security.HudsonSecurityManager;
*/
@ExportedBean
public class Executor extends Thread implements ModelObject {
+
protected final Computer owner;
private final Queue queue;
-
private long startTime;
/**
* Used to track when a job was last executed.
*/
private long finishTime;
-
/**
- * Executor number that identifies it among other executors for the same {@link Computer}.
+ * Executor number that identifies it among other executors for the same
+ * {@link Computer}.
*/
private int number;
/**
- * {@link Queue.Executable} being executed right now, or null if the executor is idle.
+ * {@link Queue.Executable} being executed right now, or null if the
+ * executor is idle.
*/
private volatile Queue.Executable executable;
-
private volatile WorkUnit workUnit;
-
private Throwable causeOfDeath;
-
private boolean induceDeath;
public Executor(Computer owner, int n) {
- super("Executor #"+n+" for "+owner.getDisplayName());
+ super("Executor #" + n + " for " + owner.getDisplayName());
this.owner = owner;
this.queue = Hudson.getInstance().getQueue();
this.number = n;
@@ -86,12 +83,12 @@ public class Executor extends Thread implements ModelObject {
try {
finishTime = System.currentTimeMillis();
- while(shouldRun()) {
+ while (shouldRun()) {
executable = null;
workUnit = null;
- synchronized(owner) {
- if(owner.getNumExecutors()<owner.getExecutors().size()) {
+ synchronized (owner) {
+ if (owner.getNumExecutors() < owner.getExecutors().size()) {
// we've got too many executors.
owner.removeExecutor(this);
return;
@@ -101,8 +98,12 @@ public class Executor extends Thread implements ModelObject {
// clear the interrupt flag as a precaution.
// sometime an interrupt aborts a build but without clearing the flag.
// see issue #1583
- if (Thread.interrupted()) continue;
- if (induceDeath) throw new ThreadDeath();
+ if (Thread.interrupted()) {
+ continue;
+ }
+ if (induceDeath) {
+ throw new ThreadDeath();
+ }
SubTask task;
try {
@@ -128,11 +129,11 @@ public class Executor extends Thread implements ModelObject {
workUnit.context.synchronizeStart();
if (executable instanceof Actionable) {
- for (Action action: workUnit.context.actions) {
+ for (Action action : workUnit.context.actions) {
((Actionable) executable).addAction(action);
}
}
- setName(threadName+" : executing "+executable.toString());
+ setName(threadName + " : executing " + executable.toString());
queue.execute(executable, task);
} catch (Throwable e) {
// for some reason the executor died. this is really
@@ -145,7 +146,7 @@ public class Executor extends Thread implements ModelObject {
setName(threadName);
finishTime = System.currentTimeMillis();
try {
- workUnit.context.synchronizeEnd(executable,problems,finishTime - startTime);
+ workUnit.context.synchronizeEnd(executable, problems, finishTime - startTime);
} catch (InterruptedException e) {
workUnit.context.abort(e);
continue;
@@ -154,7 +155,7 @@ public class Executor extends Thread implements ModelObject {
}
}
}
- } catch(RuntimeException e) {
+ } catch (RuntimeException e) {
causeOfDeath = e;
throw e;
} catch (Error e) {
@@ -185,8 +186,7 @@ public class Executor extends Thread implements ModelObject {
/**
* Returns the current {@link Queue.Task} this executor is running.
*
- * @return
- * null if the executor is idle.
+ * @return null if the executor is idle.
*/
@Exported
public Queue.Executable getCurrentExecutable() {
@@ -194,11 +194,11 @@ public class Executor extends Thread implements ModelObject {
}
/**
- * Returns the current {@link WorkUnit} (of {@link #getCurrentExecutable() the current executable})
- * that this executor is running.
+ * Returns the current {@link WorkUnit} (of
+ * {@link #getCurrentExecutable() the current executable}) that this
+ * executor is running.
*
- * @return
- * null if the executor is idle.
+ * @return null if the executor is idle.
*/
@Exported
public WorkUnit getCurrentWorkUnit() {
@@ -206,13 +206,15 @@ public class Executor extends Thread implements ModelObject {
}
/**
- * If {@linkplain #getCurrentExecutable() current executable} is {@link AbstractBuild},
- * return the workspace that this executor is using, or null if the build hasn't gotten
- * to that point yet.
+ * If {@linkplain #getCurrentExecutable() current executable} is
+ * {@link AbstractBuild}, return the workspace that this executor is using,
+ * or null if the build hasn't gotten to that point yet.
*/
public FilePath getCurrentWorkspace() {
Executable e = executable;
- if(e==null) return null;
+ if (e == null) {
+ return null;
+ }
if (e instanceof AbstractBuild) {
AbstractBuild ab = (AbstractBuild) e;
return ab.getWorkspace();
@@ -224,15 +226,14 @@ public class Executor extends Thread implements ModelObject {
* Same as {@link #getName()}.
*/
public String getDisplayName() {
- return "Executor #"+getNumber();
+ return "Executor #" + getNumber();
}
/**
- * Gets the executor number that uniquely identifies it among
- * other {@link Executor}s for the same computer.
+ * Gets the executor number that uniquely identifies it among other
+ * {@link Executor}s for the same computer.
*
- * @return
- * a sequential number starting from 0.
+ * @return a sequential number starting from 0.
*/
@Exported
public int getNumber() {
@@ -244,20 +245,22 @@ public class Executor extends Thread implements ModelObject {
*/
@Exported
public boolean isIdle() {
- return executable==null && causeOfDeath==null;
+ return executable == null && causeOfDeath == null;
}
/**
- * The opposite of {@link #isIdle()} &mdash; the executor is doing some work.
+ * The opposite of {@link #isIdle()} &mdash; the executor is doing some
+ * work.
*/
public boolean isBusy() {
- return executable!=null || causeOfDeath!=null;
+ return executable != null || causeOfDeath != null;
}
/**
* If this thread dies unexpectedly, obtain the cause of the failure.
*
- * @return null if the death is expected death or the thread is {@link #isAlive() still alive}.
+ * @return null if the death is expected death or the thread is
+ * {@link #isAlive() still alive}.
* @since 1.142
*/
public Throwable getCauseOfDeath() {
@@ -267,41 +270,47 @@ public class Executor extends Thread implements ModelObject {
/**
* Returns the progress of the current build in the number between 0-100.
*
- * @return -1
- * if it's impossible to estimate the progress.
+ * @return -1 if it's impossible to estimate the progress.
*/
@Exported
public int getProgress() {
Queue.Executable e = executable;
- if(e==null) return -1;
+ if (e == null) {
+ return -1;
+ }
long d = Executables.getEstimatedDurationFor(e);
- if(d<0) return -1;
+ if (d < 0) {
+ return -1;
+ }
- int num = (int)(getElapsedTime()*100/d);
- if(num>=100) num=99;
+ int num = (int) (getElapsedTime() * 100 / d);
+ if (num >= 100) {
+ num = 99;
+ }
return num;
}
/**
* Returns true if the current build is likely stuck.
*
- * <p>
- * This is a heuristics based approach, but if the build is suspiciously taking for a long time,
- * this method returns true.
+ * <p> This is a heuristics based approach, but if the build is suspiciously
+ * taking for a long time, this method returns true.
*/
@Exported
public boolean isLikelyStuck() {
Queue.Executable e = executable;
- if(e==null) return false;
+ if (e == null) {
+ return false;
+ }
long elapsed = getElapsedTime();
long d = Executables.getEstimatedDurationFor(e);
- if(d>=0) {
+ if (d >= 0) {
// if it's taking 10 times longer than ETA, consider it stuck
- return d*10 < elapsed;
+ return d * 10 < elapsed;
} else {
// if no ETA is available, a build taking longer than a day is considered stuck
- return TimeUnit2.MILLISECONDS.toHours(elapsed)>24;
+ return TimeUnit2.MILLISECONDS.toHours(elapsed) > 24;
}
}
@@ -312,8 +321,7 @@ public class Executor extends Thread implements ModelObject {
/**
* Gets the string that says how long since this build has started.
*
- * @return
- * string like "3 minutes" "1 day" etc.
+ * @return string like "3 minutes" "1 day" etc.
*/
public String getTimestampString() {
return Util.getPastTimeString(getElapsedTime());
@@ -325,30 +333,42 @@ public class Executor extends Thread implements ModelObject {
*/
public String getEstimatedRemainingTime() {
Queue.Executable e = executable;
- if(e==null) return Messages.Executor_NotAvailable();
+ if (e == null) {
+ return Messages.Executor_NotAvailable();
+ }
long d = Executables.getEstimatedDurationFor(e);
- if(d<0) return Messages.Executor_NotAvailable();
+ if (d < 0) {
+ return Messages.Executor_NotAvailable();
+ }
- long eta = d-getElapsedTime();
- if(eta<=0) return Messages.Executor_NotAvailable();
+ long eta = d - getElapsedTime();
+ if (eta <= 0) {
+ return Messages.Executor_NotAvailable();
+ }
return Util.getTimeSpanString(eta);
}
/**
- * The same as {@link #getEstimatedRemainingTime()} but return
- * it as a number of milli-seconds.
+ * The same as {@link #getEstimatedRemainingTime()} but return it as a
+ * number of milli-seconds.
*/
public long getEstimatedRemainingTimeMillis() {
Queue.Executable e = executable;
- if(e==null) return -1;
+ if (e == null) {
+ return -1;
+ }
long d = Executables.getEstimatedDurationFor(e);
- if(d<0) return -1;
+ if (d < 0) {
+ return -1;
+ }
- long eta = d-getElapsedTime();
- if(eta<=0) return -1;
+ long eta = d - getElapsedTime();
+ if (eta <= 0) {
+ return -1;
+ }
return eta;
}
@@ -356,9 +376,9 @@ public class Executor extends Thread implements ModelObject {
/**
* Stops the current build.
*/
- public void doStop( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException {
+ public void doStop(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
Queue.Executable e = executable;
- if(e!=null) {
+ if (e != null) {
Tasks.getOwnerTaskOf(getParentOf(e)).checkAbortPermission();
interrupt();
}
@@ -370,8 +390,9 @@ public class Executor extends Thread implements ModelObject {
*/
public HttpResponse doYank() {
Hudson.getInstance().checkPermission(Hudson.ADMINISTER);
- if (isAlive())
+ if (isAlive()) {
throw new Failure("Can't yank a live executor");
+ }
owner.removeExecutor(this);
return HttpResponses.redirectViaContextPath("/");
}
@@ -381,7 +402,7 @@ public class Executor extends Thread implements ModelObject {
*/
public boolean hasStopPermission() {
Queue.Executable e = executable;
- return e!=null && Tasks.getOwnerTaskOf(getParentOf(e)).hasAbortPermission();
+ return e != null && Tasks.getOwnerTaskOf(getParentOf(e)).hasAbortPermission();
}
public Computer getOwner() {
@@ -393,9 +414,9 @@ public class Executor extends Thread implements ModelObject {
*/
public long getIdleStartMilliseconds() {
Queue.Executable e = executable;
- if (e == null)
+ if (e == null) {
return Math.max(finishTime, owner.getConnectTime());
- else {
+ } else {
return Math.max(startTime + Math.max(0, Executables.getEstimatedDurationFor(e)),
System.currentTimeMillis() + 15000);
}
@@ -409,8 +430,9 @@ public class Executor extends Thread implements ModelObject {
}
/**
- * Creates a proxy object that executes the callee in the context that impersonates
- * this executor. Useful to export an object to a remote channel.
+ * Creates a proxy object that executes the callee in the context that
+ * impersonates this executor. Useful to export an object to a remote
+ * channel.
*/
public <T> T newImpersonatingProxy(Class<T> type, T core) {
return new InterceptingProxy() {
@@ -418,41 +440,43 @@ public class Executor extends Thread implements ModelObject {
final Executor old = IMPERSONATION.get();
IMPERSONATION.set(Executor.this);
try {
- return m.invoke(o,args);
+ return m.invoke(o, args);
} finally {
IMPERSONATION.set(old);
}
}
- }.wrap(type,core);
+ }.wrap(type, core);
}
/**
- * Returns the executor of the current thread or null if current thread is not an executor.
+ * Returns the executor of the current thread or null if current thread is
+ * not an executor.
*/
public static Executor currentExecutor() {
Thread t = Thread.currentThread();
- if (t instanceof Executor) return (Executor) t;
+ if (t instanceof Executor) {
+ return (Executor) t;
+ }
return IMPERSONATION.get();
}
-
+
/**
- * Returns the estimated duration for the executable.
- * Protects against {@link AbstractMethodError}s if the {@link Executable} implementation
- * was compiled against Hudson < 1.383
+ * Returns the estimated duration for the executable. Protects against
+ * {@link AbstractMethodError}s if the {@link Executable} implementation was
+ * compiled against Hudson < 1.383
+ *
+
*
- * @deprecated as of 1.388
- * Use {@link Executables#getEstimatedDurationFor(Executable)}
+ * @deprecated as of 1.388 Use
+ * {@link Executables#getEstimatedDurationFor(Executable)}
*/
public static long getEstimatedDurationFor(Executable e) {
return Executables.getEstimatedDurationFor(e);
}
-
/**
- * Mechanism to allow threads (in particular the channel request handling threads) to
- * run on behalf of {@link Executor}.
+ * Mechanism to allow threads (in particular the channel request handling
+ * threads) to run on behalf of {@link Executor}.
*/
private static final ThreadLocal<Executor> IMPERSONATION = new ThreadLocal<Executor>();
-
private static final Logger LOGGER = Logger.getLogger(Executor.class.getName());
-
}
diff --git a/hudson-core/src/main/java/hudson/model/ExecutorListener.java b/hudson-core/src/main/java/hudson/model/ExecutorListener.java
index e22c9ba..cd4cec7 100644
--- a/hudson-core/src/main/java/hudson/model/ExecutorListener.java
+++ b/hudson-core/src/main/java/hudson/model/ExecutorListener.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
-*
-* Kohsuke Kawaguchi, Stephen Connolly
- *
+ * Contributors:
+ *
+ * Kohsuke Kawaguchi, Stephen Connolly
+ *
*
*******************************************************************************/
@@ -18,14 +18,15 @@ package hudson.model;
/**
* A listener for task related events from Executors
-*
+ *
* @author Stephen Connolly
-* @since 17-Jun-2008 18:58:12
-*/
+ * @since 17-Jun-2008 18:58:12
+ */
public interface ExecutorListener {
/**
* Called whenever a task is accepted by an executor.
+ *
* @param executor The executor.
* @param task The task.
*/
@@ -33,17 +34,21 @@ public interface ExecutorListener {
/**
* Called whenever a task is completed without any problems by an executor.
+ *
* @param executor The executor.
* @param task The task.
- * @param durationMS The number of milliseconds that the task took to complete.
+ * @param durationMS The number of milliseconds that the task took to
+ * complete.
*/
void taskCompleted(Executor executor, Queue.Task task, long durationMS);
/**
* Called whenever a task is completed without any problems by an executor.
+ *
* @param executor The executor.
* @param task The task.
- * @param durationMS The number of milliseconds that the task took to complete.
+ * @param durationMS The number of milliseconds that the task took to
+ * complete.
* @param problems The exception that was thrown.
*/
void taskCompletedWithProblems(Executor executor, Queue.Task task, long durationMS, Throwable problems);
diff --git a/hudson-core/src/main/java/hudson/model/ExternalJob.java b/hudson-core/src/main/java/hudson/model/ExternalJob.java
index b6e8b94..b06c8ac 100644
--- a/hudson-core/src/main/java/hudson/model/ExternalJob.java
+++ b/hudson-core/src/main/java/hudson/model/ExternalJob.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
-*
-* Kohsuke Kawaguchi, id:cactusman
- *
+ * Contributors:
+ *
+ * Kohsuke Kawaguchi, id:cactusman
+ *
*
*******************************************************************************/
@@ -27,38 +27,38 @@ import java.io.File;
import java.io.IOException;
/**
- * Job that runs outside Hudson whose result is submitted to Hudson
- * (either via web interface, or simply by placing files on the file system,
- * for compatibility.)
+ * Job that runs outside Hudson whose result is submitted to Hudson (either via
+ * web interface, or simply by placing files on the file system, for
+ * compatibility.)
*
* @author Kohsuke Kawaguchi
*/
-public class ExternalJob extends ViewJob<ExternalJob,ExternalRun> implements TopLevelItem {
+public class ExternalJob extends ViewJob<ExternalJob, ExternalRun> implements TopLevelItem {
+
public ExternalJob(String name) {
- this(Hudson.getInstance(),name);
+ this(Hudson.getInstance(), name);
}
public ExternalJob(ItemGroup parent, String name) {
- super(parent,name);
+ super(parent, name);
}
@Override
protected void reload() {
- this.runs.load(this,new Constructor<ExternalRun>() {
+ this.runs.load(this, new Constructor<ExternalRun>() {
public ExternalRun create(File dir) throws IOException {
- return new ExternalRun(ExternalJob.this,dir);
+ return new ExternalRun(ExternalJob.this, dir);
}
});
}
-
-
// keep track of the previous time we started a build
private transient long lastBuildStartTime;
/**
* Creates a new build of this project for immediate execution.
*
- * Needs to be synchronized so that two {@link #newBuild()} invocations serialize each other.
+ * Needs to be synchronized so that two {@link #newBuild()} invocations
+ * serialize each other.
*/
public synchronized ExternalRun newBuild() throws IOException {
// make sure we don't start two builds in the same second
@@ -78,7 +78,8 @@ public class ExternalJob extends ViewJob<ExternalJob,ExternalRun> implements Top
}
/**
- * Used to check if this is an external job and ready to accept a build result.
+ * Used to check if this is an external job and ready to accept a build
+ * result.
*/
public void doAcceptBuildResult(StaplerResponse rsp) throws IOException, ServletException {
rsp.setStatus(HttpServletResponse.SC_OK);
@@ -87,7 +88,7 @@ public class ExternalJob extends ViewJob<ExternalJob,ExternalRun> implements Top
/**
* Used to post the build result from a remote machine.
*/
- public void doPostBuildResult( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException {
+ public void doPostBuildResult(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
checkPermission(AbstractProject.BUILD);
ExternalRun run = newBuild();
run.acceptRemoteSubmission(req.getReader());
@@ -97,7 +98,6 @@ public class ExternalJob extends ViewJob<ExternalJob,ExternalRun> implements Top
public TopLevelItemDescriptor getDescriptor() {
return DESCRIPTOR;
}
-
@Extension
public static final TopLevelItemDescriptor DESCRIPTOR = new DescriptorImpl();
@@ -107,12 +107,13 @@ public class ExternalJob extends ViewJob<ExternalJob,ExternalRun> implements Top
}
public static final class DescriptorImpl extends TopLevelItemDescriptor {
+
public String getDisplayName() {
return Messages.ExternalJob_DisplayName();
}
public ExternalJob newInstance(ItemGroup parent, String name) {
- return new ExternalJob(parent,name);
+ return new ExternalJob(parent, name);
}
}
}
diff --git a/hudson-core/src/main/java/hudson/model/ExternalRun.java b/hudson-core/src/main/java/hudson/model/ExternalRun.java
index 68d650e..561e505 100644
--- a/hudson-core/src/main/java/hudson/model/ExternalRun.java
+++ b/hudson-core/src/main/java/hudson/model/ExternalRun.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
-*
-* Kohsuke Kawaguchi
- *
+ * Contributors:
+ *
+ * Kohsuke Kawaguchi
+ *
*
*******************************************************************************/
@@ -35,15 +35,16 @@ import static javax.xml.stream.XMLStreamConstants.*;
/**
* {@link Run} for {@link ExternalJob}.
- *
+ *
* @author Kohsuke Kawaguchi
*/
-public class ExternalRun extends Run<ExternalJob,ExternalRun> {
+public class ExternalRun extends Run<ExternalJob, ExternalRun> {
+
/**
* Loads a run from a log file.
*/
ExternalRun(ExternalJob owner, File runDir) throws IOException {
- super(owner,runDir);
+ super(owner, runDir);
}
/**
@@ -54,14 +55,14 @@ public class ExternalRun extends Run<ExternalJob,ExternalRun> {
}
/**
- * Instead of performing a build, run the specified command,
- * record the log and its exit code, then call it a build.
+ * Instead of performing a build, run the specified command, record the log
+ * and its exit code, then call it a build.
*/
public void run(final String[] cmd) {
run(new Runner() {
public Result run(BuildListener listener) throws Exception {
- Proc proc = new Proc.LocalProc(cmd,getEnvironment(listener),System.in,new DualOutputStream(System.out,listener.getLogger()));
- return proc.join()==0?Result.SUCCESS:Result.FAILURE;
+ Proc proc = new Proc.LocalProc(cmd, getEnvironment(listener), System.in, new DualOutputStream(System.out, listener.getLogger()));
+ return proc.join() == 0 ? Result.SUCCESS : Result.FAILURE;
}
public void post(BuildListener listener) {
@@ -75,11 +76,10 @@ public class ExternalRun extends Run<ExternalJob,ExternalRun> {
}
/**
- * Instead of performing a build, accept the log and the return code
- * from a remote machine.
+ * Instead of performing a build, accept the log and the return code from a
+ * remote machine.
*
- * <p>
- * The format of the XML is:
+ * <p> The format of the XML is:
*
* <pre><xmp>
* <run>
@@ -94,47 +94,49 @@ public class ExternalRun extends Run<ExternalJob,ExternalRun> {
run(new Runner() {
private String elementText(XMLStreamReader r) throws XMLStreamException {
StringBuilder buf = new StringBuilder();
- while(true) {
+ while (true) {
int type = r.next();
- if(type== CHARACTERS || type== CDATA)
+ if (type == CHARACTERS || type == CDATA) {
buf.append(r.getTextCharacters(), r.getTextStart(), r.getTextLength());
- else
+ } else {
return buf.toString();
+ }
}
}
public Result run(BuildListener listener) throws Exception {
PrintStream logger = null;
try {
- logger = new PrintStream(new DecodingStream(listener.getLogger()));
-
- XMLInputFactory xif = XMLInputFactory.newInstance();
- XMLStreamReader p = xif.createXMLStreamReader(in);
-
- p.nextTag(); // get to the <run>
- p.nextTag(); // get to the <log>
-
- charset=p.getAttributeValue(null,"content-encoding");
- while(p.next()!= END_ELEMENT) {
- int type = p.getEventType();
- if(type== CHARACTERS || type== CDATA)
- logger.print(p.getText());
- }
- p.nextTag(); // get to <result>
-
-
-
- Result r = Integer.parseInt(elementText(p))==0?Result.SUCCESS:Result.FAILURE;
-
- p.nextTag(); // get to <duration> (optional)
- if(p.getEventType()== START_ELEMENT
- && p.getLocalName().equals("duration")) {
- duration[0] = Long.parseLong(elementText(p));
- }
-
- return r;
+ logger = new PrintStream(new DecodingStream(listener.getLogger()));
+
+ XMLInputFactory xif = XMLInputFactory.newInstance();
+ XMLStreamReader p = xif.createXMLStreamReader(in);
+
+ p.nextTag(); // get to the <run>
+ p.nextTag(); // get to the <log>
+
+ charset = p.getAttributeValue(null, "content-encoding");
+ while (p.next() != END_ELEMENT) {
+ int type = p.getEventType();
+ if (type == CHARACTERS || type == CDATA) {
+ logger.print(p.getText());
+ }
+ }
+ p.nextTag(); // get to <result>
+
+
+
+ Result r = Integer.parseInt(elementText(p)) == 0 ? Result.SUCCESS : Result.FAILURE;
+
+ p.nextTag(); // get to <duration> (optional)
+ if (p.getEventType() == START_ELEMENT
+ && p.getLocalName().equals("duration")) {
+ duration[0] = Long.parseLong(elementText(p));
+ }
+
+ return r;
} finally {
- IOUtils.closeQuietly(logger);
+ IOUtils.closeQuietly(logger);
}
}
@@ -147,11 +149,10 @@ public class ExternalRun extends Run<ExternalJob,ExternalRun> {
}
});
- if(duration[0]!=0) {
+ if (duration[0] != 0) {
super.duration = duration[0];
// save the updated duration
save();
}
}
-
}
diff --git a/hudson-core/src/main/java/hudson/model/Failure.java b/hudson-core/src/main/java/hudson/model/Failure.java
index c094884..d1c7b14 100644
--- a/hudson-core/src/main/java/hudson/model/Failure.java
+++ b/hudson-core/src/main/java/hudson/model/Failure.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
*
* Kohsuke Kawaguchi
- *
+ *
*
*******************************************************************************/
@@ -24,21 +24,23 @@ import javax.servlet.ServletException;
import java.io.IOException;
/**
- * Represents an error induced by user, encountered during HTTP request processing.
+ * Represents an error induced by user, encountered during HTTP request
+ * processing.
*
- * <p>
- * The error page is rendered into HTML, but without a stack trace. So only use
- * this exception when the error condition is anticipated by the program, and where
- * we nor users don't need to see the stack trace to figure out the root cause.
+ * <p> The error page is rendered into HTML, but without a stack trace. So only
+ * use this exception when the error condition is anticipated by the program,
+ * and where we nor users don't need to see the stack trace to figure out the
+ * root cause.
*
* @author Kohsuke Kawaguchi
* @since 1.321
*/
public class Failure extends RuntimeException implements HttpResponse {
+
private final boolean pre;
public Failure(String message) {
- this(message,false);
+ this(message, false);
}
public Failure(String message, boolean pre) {
@@ -47,12 +49,15 @@ public class Failure extends RuntimeException implements HttpResponse {
}
public void generateResponse(StaplerRequest req, StaplerResponse rsp, Object node) throws IOException, ServletException {
- req.setAttribute("message",getMessage());
- if(pre)
- req.setAttribute("pre",true);
+ req.setAttribute("message", getMessage());
+ if (pre) {
+ req.setAttribute("pre", true);
+ }
if (node instanceof AbstractItem) // Maintain ancestors
- rsp.forward(Hudson.getInstance(), ((AbstractItem)node).getUrl() + "error", req);
- else
- rsp.forward(node instanceof AbstractModelObject ? node : Hudson.getInstance() ,"error", req);
+ {
+ rsp.forward(Hudson.getInstance(), ((AbstractItem) node).getUrl() + "error", req);
+ } else {
+ rsp.forward(node instanceof AbstractModelObject ? node : Hudson.getInstance(), "error", req);
+ }
}
}
diff --git a/hudson-core/src/main/java/hudson/model/FileParameterDefinition.java b/hudson-core/src/main/java/hudson/model/FileParameterDefinition.java
index 4409b20..210cb4c 100644
--- a/hudson-core/src/main/java/hudson/model/FileParameterDefinition.java
+++ b/hudson-core/src/main/java/hudson/model/FileParameterDefinition.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
-*
-* Kohsuke Kawaguchi, Seiji Sogabe, Tom Huybrechts
- *
+ * Contributors:
+ *
+ * Kohsuke Kawaguchi, Seiji Sogabe, Tom Huybrechts
+ *
*
*******************************************************************************/
@@ -29,12 +29,13 @@ import java.io.File;
/**
* {@link ParameterDefinition} for doing file upload.
*
- * <p>
- * The file will be then placed into the workspace at the beginning of a build.
+ * <p> The file will be then placed into the workspace at the beginning of a
+ * build.
*
* @author Kohsuke Kawaguchi
*/
public class FileParameterDefinition extends ParameterDefinition {
+
@DataBoundConstructor
public FileParameterDefinition(String name, String description) {
super(name, description);
@@ -49,6 +50,7 @@ public class FileParameterDefinition extends ParameterDefinition {
@Extension
public static class DescriptorImpl extends ParameterDescriptor {
+
@Override
public String getDisplayName() {
return Messages.FileParameterDefinition_DisplayName();
@@ -60,16 +62,16 @@ public class FileParameterDefinition extends ParameterDefinition {
}
}
- @Override
- public ParameterValue createValue(StaplerRequest req) {
- throw new UnsupportedOperationException();
- }
+ @Override
+ public ParameterValue createValue(StaplerRequest req) {
+ throw new UnsupportedOperationException();
+ }
@Override
public ParameterValue createValue(CLICommand command, String value) throws IOException, InterruptedException {
// capture the file to the server
- FilePath src = new FilePath(command.channel,value);
- File local = File.createTempFile("hudson","parameter");
+ FilePath src = new FilePath(command.channel, value);
+ File local = File.createTempFile("hudson", "parameter");
src.copyTo(new FilePath(local));
FileParameterValue p = new FileParameterValue(getName(), local, src.getName());
diff --git a/hudson-core/src/main/java/hudson/model/FileParameterValue.java b/hudson-core/src/main/java/hudson/model/FileParameterValue.java
index 381c48a..dcdd0a7 100644
--- a/hudson-core/src/main/java/hudson/model/FileParameterValue.java
+++ b/hudson-core/src/main/java/hudson/model/FileParameterValue.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
-*
-* Kohsuke Kawaguchi
- *
+ * Contributors:
+ *
+ * Kohsuke Kawaguchi
+ *
*
*******************************************************************************/
@@ -41,22 +41,19 @@ import javax.servlet.ServletException;
/**
* {@link ParameterValue} for {@link FileParameterDefinition}.
*
- * <h2>Persistence</h2>
- * <p>
- * {@link DiskFileItem} is persistable via serialization,
- * (although the data may get very large in XML) so this object
+ * <h2>Persistence</h2> <p> {@link DiskFileItem} is persistable via
+ * serialization, (although the data may get very large in XML) so this object
* as a whole is persistable.
*
* @author Kohsuke Kawaguchi
*/
public class FileParameterValue extends ParameterValue {
- private FileItem file;
+ private FileItem file;
/**
* The name of the originally uploaded file.
*/
private final String originalFileName;
-
private String location;
@DataBoundConstructor
@@ -91,55 +88,61 @@ public class FileParameterValue extends ParameterValue {
}
@Override
- public BuildWrapper createBuildWrapper(AbstractBuild<?,?> build) {
+ public BuildWrapper createBuildWrapper(AbstractBuild<?, ?> build) {
return new BuildWrapper() {
@Override
public Environment setUp(AbstractBuild build, Launcher launcher, BuildListener listener) throws IOException, InterruptedException {
- if (!StringUtils.isEmpty(file.getName())) {
- listener.getLogger().println("Copying file to "+location);
+ if (!StringUtils.isEmpty(file.getName())) {
+ listener.getLogger().println("Copying file to " + location);
FilePath locationFilePath = build.getWorkspace().child(location);
locationFilePath.getParent().mkdirs();
- locationFilePath.copyFrom(file);
- file = null;
+ locationFilePath.copyFrom(file);
+ file = null;
locationFilePath.copyTo(new FilePath(getLocationUnderBuild(build)));
- }
- return new Environment() {};
+ }
+ return new Environment() {
+ };
}
};
}
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = super.hashCode();
- result = prime * result
- + ((location == null) ? 0 : location.hashCode());
- return result;
- }
-
- /**
- * In practice this will always be false, since location should be unique.
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (!super.equals(obj))
- return false;
- if (getClass() != obj.getClass())
- return false;
- FileParameterValue other = (FileParameterValue) obj;
- if (location == null) {
- if (other.location != null)
- return false;
- } else if (!location.equals(other.location))
- return false;
- return true;
- }
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result
+ + ((location == null) ? 0 : location.hashCode());
+ return result;
+ }
+
+ /**
+ * In practice this will always be false, since location should be unique.
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!super.equals(obj)) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ FileParameterValue other = (FileParameterValue) obj;
+ if (location == null) {
+ if (other.location != null) {
+ return false;
+ }
+ } else if (!location.equals(other.location)) {
+ return false;
+ }
+ return true;
+ }
@Override
public String getShortDescription() {
- return "(FileParameterValue) " + getName() + "='" + originalFileName + "'";
+ return "(FileParameterValue) " + getName() + "='" + originalFileName + "'";
}
/**
@@ -152,7 +155,7 @@ public class FileParameterValue extends ParameterValue {
*/
public void doDynamic(StaplerRequest request, StaplerResponse response) throws ServletException, IOException {
if (("/" + originalFileName).equals(request.getRestOfPath())) {
- AbstractBuild build = (AbstractBuild)request.findAncestor(AbstractBuild.class).getObject();
+ AbstractBuild build = (AbstractBuild) request.findAncestor(AbstractBuild.class).getObject();
File fileParameter = getLocationUnderBuild(build);
if (fileParameter.isFile()) {
response.serveFile(request, fileParameter.toURI().toURL());
@@ -174,6 +177,7 @@ public class FileParameterValue extends ParameterValue {
* Default implementation from {@link File}.
*/
public static final class FileItemImpl implements FileItem {
+
private final File file;
public FileItemImpl(File file) {
diff --git a/hudson-core/src/main/java/hudson/model/Fingerprint.java b/hudson-core/src/main/java/hudson/model/Fingerprint.java
index 6166a8d..ceaad00 100644
--- a/hudson-core/src/main/java/hudson/model/Fingerprint.java
+++ b/hudson-core/src/main/java/hudson/model/Fingerprint.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
-*
+ * Contributors:
+ *
* Kohsuke Kawaguchi
- *
+ *
*
*******************************************************************************/
@@ -48,19 +48,20 @@ import java.util.logging.Logger;
/**
* A file being tracked by Hudson.
*
- * <p>
- * Lifecycle is managed by {@link FingerprintMap}.
+ * <p> Lifecycle is managed by {@link FingerprintMap}.
*
* @author Kohsuke Kawaguchi
* @see FingerprintMap
*/
@ExportedBean
public class Fingerprint implements ModelObject, Saveable {
+
/**
* Pointer to a {@link Build}.
*/
- @ExportedBean(defaultVisibility=2)
+ @ExportedBean(defaultVisibility = 2)
public static class BuildPtr {
+
final String name;
final int number;
@@ -70,14 +71,12 @@ public class Fingerprint implements ModelObject, Saveable {
}
public BuildPtr(Run run) {
- this( run.getParent().getFullName(), run.getNumber() );
+ this(run.getParent().getFullName(), run.getNumber());
}
/**
- * Gets {@link Job#getFullName() the full name of the job}.
- * <p>
- * Such job could be since then removed,
- * so there might not be a corresponding
+ * Gets {@link Job#getFullName() the full name of the job}. <p> Such job
+ * could be since then removed, so there might not be a corresponding
* {@link Job}.
*/
@Exported
@@ -86,18 +85,16 @@ public class Fingerprint implements ModelObject, Saveable {
}
/**
- * Gets the {@link Job} that this pointer points to,
- * or null if such a job no longer exists.
+ * Gets the {@link Job} that this pointer points to, or null if such a
+ * job no longer exists.
*/
public AbstractProject getJob() {
- return Hudson.getInstance().getItemByFullName(name,AbstractProject.class);
+ return Hudson.getInstance().getItemByFullName(name, AbstractProject.class);
}
/**
- * Gets the project build number.
- * <p>
- * Such {@link Run} could be since then
- * discarded.
+ * Gets the project build number. <p> Such {@link Run} could be since
+ * then discarded.
*/
@Exported
public int getNumber() {
@@ -105,24 +102,26 @@ public class Fingerprint implements ModelObject, Saveable {
}
/**
- * Gets the {@link Job} that this pointer points to,
- * or null if such a job no longer exists.
+ * Gets the {@link Job} that this pointer points to, or null if such a
+ * job no longer exists.
*/
public Run getRun() {
Job j = getJob();
- if(j==null) return null;
+ if (j == null) {
+ return null;
+ }
return j.getBuildByNumber(number);
}
private boolean isAlive() {
- return getRun()!=null;
+ return getRun() != null;
}
/**
* Returns true if {@link BuildPtr} points to the given run.
*/
public boolean is(Run r) {
- return r.getNumber()==number && r.getParent().getFullName().equals(name);
+ return r.getNumber() == number && r.getParent().getFullName().equals(name);
}
/**
@@ -133,18 +132,18 @@ public class Fingerprint implements ModelObject, Saveable {
}
/**
- * Returns true if {@link BuildPtr} points to the given job
- * or one of its subordinates.
+ * Returns true if {@link BuildPtr} points to the given job or one of
+ * its subordinates.
*
- * <p>
- * This is useful to check if an artifact in MavenModule
- * belongs to MavenModuleSet.
+ * <p> This is useful to check if an artifact in MavenModule belongs to
+ * MavenModuleSet.
*/
public boolean belongsTo(Job job) {
Item p = Hudson.getInstance().getItemByFullName(name);
- while(p!=null) {
- if(p==job)
+ while (p != null) {
+ if (p == job) {
return true;
+ }
// go up the chain while we
ItemGroup<? extends Item> parent = p.getParent();
@@ -162,13 +161,14 @@ public class Fingerprint implements ModelObject, Saveable {
/**
* Range of build numbers [start,end). Immutable.
*/
- @ExportedBean(defaultVisibility=4)
+ @ExportedBean(defaultVisibility = 4)
public static final class Range {
+
final int start;
final int end;
public Range(int start, int end) {
- assert start<end;
+ assert start < end;
this.start = start;
this.end = end;
}
@@ -184,46 +184,47 @@ public class Fingerprint implements ModelObject, Saveable {
}
public boolean isSmallerThan(int i) {
- return end<=i;
+ return end <= i;
}
public boolean isBiggerThan(int i) {
- return i<start;
+ return i < start;
}
public boolean includes(int i) {
- return start<=i && i<end;
+ return start <= i && i < end;
}
public Range expandRight() {
- return new Range(start,end+1);
+ return new Range(start, end + 1);
}
public Range expandLeft() {
- return new Range(start-1,end);
+ return new Range(start - 1, end);
}
public boolean isAdjacentTo(Range that) {
- return this.end==that.start;
+ return this.end == that.start;
}
@Override
public String toString() {
- return "["+start+","+end+")";
+ return "[" + start + "," + end + ")";
}
/**
- * Returns true if two {@link Range}s can't be combined into a single range.
+ * Returns true if two {@link Range}s can't be combined into a single
+ * range.
*/
public boolean isIndependent(Range that) {
- return this.end<that.start ||that.end<this.start;
+ return this.end < that.start || that.end < this.start;
}
/**
* Returns true if this range only represents a single number.
*/
public boolean isSingle() {
- return end-1==start;
+ return end - 1 == start;
}
/**
@@ -232,17 +233,18 @@ public class Fingerprint implements ModelObject, Saveable {
public Range combine(Range that) {
assert !isIndependent(that);
return new Range(
- Math.min(this.start,that.start),
- Math.max(this.end ,that.end ));
+ Math.min(this.start, that.start),
+ Math.max(this.end, that.end));
}
}
/**
* Set of {@link Range}s.
*/
- @ExportedBean(defaultVisibility=3)
+ @ExportedBean(defaultVisibility = 3)
public static final class RangeSet {
// sorted
+
private final List<Range> ranges;
public RangeSet() {
@@ -260,9 +262,9 @@ public class Fingerprint implements ModelObject, Saveable {
final List<Range> ranges = getRanges();
return new Iterable<Integer>() {
public Iterator<Integer> iterator() {
- return new Iterators.FlattenIterator<Integer,Range>(ranges) {
+ return new Iterators.FlattenIterator<Integer, Range>(ranges) {
protected Iterator<Integer> expand(Range range) {
- return Iterators.sequence(range.start,range.end).iterator();
+ return Iterators.sequence(range.start, range.end).iterator();
}
};
}
@@ -287,7 +289,6 @@ public class Fingerprint implements ModelObject, Saveable {
// }
// };
// }
-
/**
* List all numbers in this range set in the descending order.
*/
@@ -295,9 +296,9 @@ public class Fingerprint implements ModelObject, Saveable {
final List<Range> ranges = getRanges();
return new Iterable<Integer>() {
public Iterator<Integer> iterator() {
- return new Iterators.FlattenIterator<Integer,Range>(Iterators.reverse(ranges)) {
+ return new Iterators.FlattenIterator<Integer, Range>(Iterators.reverse(ranges)) {
protected Iterator<Integer> expand(Range range) {
- return Iterators.reverseSequence(range.start,range.end).iterator();
+ return Iterators.reverseSequence(range.start, range.end).iterator();
}
};
}
@@ -313,66 +314,71 @@ public class Fingerprint implements ModelObject, Saveable {
}
/**
- * Expands the range set to include the given value.
- * If the set already includes this number, this will be a no-op.
+ * Expands the range set to include the given value. If the set already
+ * includes this number, this will be a no-op.
*/
public synchronized void add(int n) {
- for( int i=0; i<ranges.size(); i++ ) {
+ for (int i = 0; i < ranges.size(); i++) {
Range r = ranges.get(i);
- if(r.includes(n)) return; // already included
- if(r.end==n) {
- ranges.set(i,r.expandRight());
+ if (r.includes(n)) {
+ return; // already included
+ }
+ if (r.end == n) {
+ ranges.set(i, r.expandRight());
checkCollapse(i);
return;
}
- if(r.start==n+1) {
- ranges.set(i,r.expandLeft());
- checkCollapse(i-1);
+ if (r.start == n + 1) {
+ ranges.set(i, r.expandLeft());
+ checkCollapse(i - 1);
return;
}
- if(r.isBiggerThan(n)) {
+ if (r.isBiggerThan(n)) {
// needs to insert a single-value Range
- ranges.add(i,new Range(n,n+1));
+ ranges.add(i, new Range(n, n + 1));
return;
}
}
- ranges.add(new Range(n,n+1));
+ ranges.add(new Range(n, n + 1));
}
private void checkCollapse(int i) {
- if(i<0 || i==ranges.size()-1) return;
+ if (i < 0 || i == ranges.size() - 1) {
+ return;
+ }
Range lhs = ranges.get(i);
- Range rhs = ranges.get(i+1);
- if(lhs.isAdjacentTo(rhs)) {
+ Range rhs = ranges.get(i + 1);
+ if (lhs.isAdjacentTo(rhs)) {
// collapsed
- Range r = new Range(lhs.start,rhs.end);
- ranges.set(i,r);
- ranges.remove(i+1);
+ Range r = new Range(lhs.start, rhs.end);
+ ranges.set(i, r);
+ ranges.remove(i + 1);
}
}
public synchronized boolean includes(int i) {
for (Range r : ranges) {
- if(r.includes(i))
+ if (r.includes(i)) {
return true;
+ }
}
return false;
}
public synchronized void add(RangeSet that) {
- int lhs=0,rhs=0;
- while(lhs<this.ranges.size() && rhs<that.ranges.size()) {
+ int lhs = 0, rhs = 0;
+ while (lhs < this.ranges.size() && rhs < that.ranges.size()) {
Range lr = this.ranges.get(lhs);
Range rr = that.ranges.get(rhs);
// no overlap
- if(lr.end<rr.start) {
+ if (lr.end < rr.start) {
lhs++;
continue;
}
- if(rr.end<lr.start) {
- ranges.add(lhs,rr);
+ if (rr.end < lr.start) {
+ ranges.add(lhs, rr);
lhs++;
rhs++;
continue;
@@ -383,23 +389,25 @@ public class Fingerprint implements ModelObject, Saveable {
rhs++;
// since ranges[lhs] is expanded, it might overlap with others in this.ranges
- while(lhs+1<this.ranges.size() && !m.isIndependent(this.ranges.get(lhs+1))) {
- m = m.combine(this.ranges.get(lhs+1));
- this.ranges.remove(lhs+1);
+ while (lhs + 1 < this.ranges.size() && !m.isIndependent(this.ranges.get(lhs + 1))) {
+ m = m.combine(this.ranges.get(lhs + 1));
+ this.ranges.remove(lhs + 1);
}
- this.ranges.set(lhs,m);
+ this.ranges.set(lhs, m);
}
// if anything is left in that.ranges, add them all
- this.ranges.addAll(that.ranges.subList(rhs,that.ranges.size()));
+ this.ranges.addAll(that.ranges.subList(rhs, that.ranges.size()));
}
@Override
public synchronized String toString() {
StringBuilder buf = new StringBuilder();
for (Range r : ranges) {
- if(buf.length()>0) buf.append(',');
+ if (buf.length() > 0) {
+ buf.append(',');
+ }
buf.append(r);
}
return buf.toString();
@@ -410,32 +418,33 @@ public class Fingerprint implements ModelObject, Saveable {
}
/**
- * Returns the smallest value in this range.
- * <p>
- * If this range is empty, this method throws an exception.
+ * Returns the smallest value in this range. <p> If this range is empty,
+ * this method throws an exception.
*/
public synchronized int min() {
return ranges.get(0).start;
}
/**
- * Returns the largest value in this range.
- * <p>
- * If this range is empty, this method throws an exception.
+ * Returns the largest value in this range. <p> If this range is empty,
+ * this method throws an exception.
*/
public synchronized int max() {
- return ranges.get(ranges.size()-1).end;
+ return ranges.get(ranges.size() - 1).end;
}
/**
* Returns true if all the integers logically in this {@link RangeSet}
- * is smaller than the given integer. For example, {[1,3)} is smaller than 3,
- * but {[1,3),[100,105)} is not smaller than anything less than 105.
+ * is smaller than the given integer. For example, {[1,3)} is smaller
+ * than 3, but {[1,3),[100,105)} is not smaller than anything less than
+ * 105.
*
* Note that {} is smaller than any n.
*/
public synchronized boolean isSmallerThan(int n) {
- if(ranges.isEmpty()) return true;
+ if (ranges.isEmpty()) {
+ return true;
+ }
return ranges.get(ranges.size() - 1).isSmallerThan(n);
}
@@ -445,21 +454,22 @@ public class Fingerprint implements ModelObject, Saveable {
*/
public static RangeSet fromString(String list, boolean skipError) {
RangeSet rs = new RangeSet();
- for (String s : Util.tokenize(list,",")) {
+ for (String s : Util.tokenize(list, ",")) {
s = s.trim();
// s is either single number or range "x-y".
// note that the end range is inclusive in this notation, but not in the Range class
try {
- if(s.contains("-")) {
- String[] tokens = Util.tokenize(s,"-");
- rs.ranges.add(new Range(Integer.parseInt(tokens[0]),Integer.parseInt(tokens[1])+1));
+ if (s.contains("-")) {
+ String[] tokens = Util.tokenize(s, "-");
+ rs.ranges.add(new Range(Integer.parseInt(tokens[0]), Integer.parseInt(tokens[1]) + 1));
} else {
int n = Integer.parseInt(s);
- rs.ranges.add(new Range(n,n+1));
+ rs.ranges.add(new Range(n, n + 1));
}
} catch (NumberFormatException e) {
- if (!skipError)
- throw new IllegalArgumentException("Unable to parse "+list);
+ if (!skipError) {
+ throw new IllegalArgumentException("Unable to parse " + list);
+ }
// ignore malformed text
}
@@ -468,6 +478,7 @@ public class Fingerprint implements ModelObject, Saveable {
}
static final class ConverterImpl implements Converter {
+
private final Converter collectionConv; // used to convert ArrayList in it
public ConverterImpl(Converter collectionConv) {
@@ -475,58 +486,56 @@ public class Fingerprint implements ModelObject, Saveable {
}
public boolean canConvert(Class type) {
- return type==RangeSet.class;
+ return type == RangeSet.class;
}
public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) {
RangeSet src = (RangeSet) source;
- StringBuilder buf = new StringBuilder(src.ranges.size()*10);
+ StringBuilder buf = new StringBuilder(src.ranges.size() * 10);
for (Range r : src.ranges) {
- if(buf.length()>0) buf.append(',');
- if(r.isSingle())
+ if (buf.length() > 0) {
+ buf.append(',');
+ }
+ if (r.isSingle()) {
buf.append(r.start);
- else
- buf.append(r.start).append('-').append(r.end-1);
+ } else {
+ buf.append(r.start).append('-').append(r.end - 1);
+ }
}
writer.setValue(buf.toString());
}
public Object unmarshal(HierarchicalStreamReader reader, final UnmarshallingContext context) {
- if(reader.hasMoreChildren()) {
+ if (reader.hasMoreChildren()) {
/* old format where <range> elements are nested like
- <range>
- <start>1337</start>
- <end>1479</end>
- </range>
+ <range>
+ <start>1337</start>
+ <end>1479</end>
+ </range>
*/
- return new RangeSet((List<Range>)(collectionConv.unmarshal(reader,context)));
+ return new RangeSet((List<Range>) (collectionConv.unmarshal(reader, context)));
} else {
- return RangeSet.fromString(reader.getValue(),true);
+ return RangeSet.fromString(reader.getValue(), true);
}
}
}
}
-
private final Date timestamp;
-
/**
- * Null if this fingerprint is for a file that's
- * apparently produced outside.
+ * Null if this fingerprint is for a file that's apparently produced
+ * outside.
*/
private final BuildPtr original;
-
private final byte[] md5sum;
-
private final String fileName;
-
/**
* Range of builds that use this file keyed by a job full name.
*/
- private final Hashtable<String,RangeSet> usages = new Hashtable<String,RangeSet>();
+ private final Hashtable<String, RangeSet> usages = new Hashtable<String, RangeSet>();
public Fingerprint(Run build, String fileName, byte[] md5sum) throws IOException {
- this.original = build==null ? null : new BuildPtr(build);
+ this.original = build == null ? null : new BuildPtr(build);
this.md5sum = md5sum;
this.fileName = fileName;
this.timestamp = new Date();
@@ -534,15 +543,11 @@ public class Fingerprint implements ModelObject, Saveable {
}
/**
- * The first build in which this file showed up,
- * if the file looked like it's created there.
- * <p>
- * This is considered as the "source" of this file,
- * or the owner, in the sense that this project "owns"
- * this file.
+ * The first build in which this file showed up, if the file looked like
+ * it's created there. <p> This is considered as the "source" of this file,
+ * or the owner, in the sense that this project "owns" this file.
*
- * @return null
- * if the file is apparently created outside Hudson.
+ * @return null if the file is apparently created outside Hudson.
*/
@Exported
public BuildPtr getOriginal() {
@@ -564,7 +569,7 @@ public class Fingerprint implements ModelObject, Saveable {
/**
* Gets the MD5 hash string.
*/
- @Exported(name="hash")
+ @Exported(name = "hash")
public String getHashString() {
return Util.toHexString(md5sum);
}
@@ -580,23 +585,23 @@ public class Fingerprint implements ModelObject, Saveable {
/**
* Gets the string that says how long since this build has scheduled.
*
- * @return
- * string like "3 minutes" "1 day" etc.
+ * @return string like "3 minutes" "1 day" etc.
*/
public String getTimestampString() {
- long duration = System.currentTimeMillis()-timestamp.getTime();
+ long duration = System.currentTimeMillis() - timestamp.getTime();
return Util.getPastTimeString(duration);
}
/**
* Gets the build range set for the given job name.
*
- * <p>
- * These builds of this job has used this file.
+ * <p> These builds of this job has used this file.
*/
public RangeSet getRangeSet(String jobFullName) {
RangeSet r = usages.get(jobFullName);
- if(r==null) r = new RangeSet();
+ if (r == null) {
+ r = new RangeSet();
+ }
return r;
}
@@ -614,16 +619,16 @@ public class Fingerprint implements ModelObject, Saveable {
return r;
}
- public Hashtable<String,RangeSet> getUsages() {
+ public Hashtable<String, RangeSet> getUsages() {
return usages;
}
- @ExportedBean(defaultVisibility=2)
+ @ExportedBean(defaultVisibility = 2)
public static final class RangeItem {
//TODO: review and check whether we can do it private
+
@Exported
public final String name;
-
//TODO: review and check whether we can do it private
@Exported
public final RangeSet ranges;
@@ -643,27 +648,28 @@ public class Fingerprint implements ModelObject, Saveable {
}
// this is for remote API
- @Exported(name="usage")
+ @Exported(name = "usage")
public List<RangeItem> _getUsages() {
List<RangeItem> r = new ArrayList<RangeItem>();
- for (Entry<String, RangeSet> e : usages.entrySet())
- r.add(new RangeItem(e.getKey(),e.getValue()));
+ for (Entry<String, RangeSet> e : usages.entrySet()) {
+ r.add(new RangeItem(e.getKey(), e.getValue()));
+ }
return r;
}
public synchronized void add(AbstractBuild b) throws IOException {
- add(b.getParent().getFullName(),b.getNumber());
+ add(b.getParent().getFullName(), b.getNumber());
}
/**
* Records that a build of a job has used this file.
*/
public synchronized void add(String jobFullName, int n) throws IOException {
- synchronized(usages) {
+ synchronized (usages) {
RangeSet r = usages.get(jobFullName);
- if(r==null) {
+ if (r == null) {
r = new RangeSet();
- usages.put(jobFullName,r);
+ usages.put(jobFullName, r);
}
r.add(n);
}
@@ -671,25 +677,27 @@ public class Fingerprint implements ModelObject, Saveable {
}
/**
- * Returns true if any of the builds recorded in this fingerprint
- * is still retained.
+ * Returns true if any of the builds recorded in this fingerprint is still
+ * retained.
*
- * <p>
- * This is used to find out old fingerprint records that can be removed
+ * <p> This is used to find out old fingerprint records that can be removed
* without losing too much information.
*/
public synchronized boolean isAlive() {
- if(original!=null && original.isAlive())
+ if (original != null && original.isAlive()) {
return true;
+ }
- for (Entry<String,RangeSet> e : usages.entrySet()) {
- Job j = Hudson.getInstance().getItemByFullName(e.getKey(),Job.class);
- if(j==null)
+ for (Entry<String, RangeSet> e : usages.entrySet()) {
+ Job j = Hudson.getInstance().getItemByFullName(e.getKey(), Job.class);
+ if (j == null) {
continue;
+ }
int oldest = j.getFirstBuild().getNumber();
- if(!e.getValue().isSmallerThan(oldest))
+ if (!e.getValue().isSmallerThan(oldest)) {
return true;
+ }
}
return false;
}
@@ -698,18 +706,22 @@ public class Fingerprint implements ModelObject, Saveable {
* Save the settings to a file.
*/
public synchronized void save() throws IOException {
- if(BulkChange.contains(this)) return;
+ if (BulkChange.contains(this)) {
+ return;
+ }
- long start=0;
- if(logger.isLoggable(Level.FINE))
+ long start = 0;
+ if (logger.isLoggable(Level.FINE)) {
start = System.currentTimeMillis();
+ }
File file = getFingerprintFile(md5sum);
getConfigFile(file).write(this);
SaveableListener.fireOnChange(this, getConfigFile(file));
- if(logger.isLoggable(Level.FINE))
- logger.fine("Saving fingerprint "+file+" took "+(System.currentTimeMillis()-start)+"ms");
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine("Saving fingerprint " + file + " took " + (System.currentTimeMillis() - start) + "ms");
+ }
}
public Api getApi() {
@@ -720,16 +732,16 @@ public class Fingerprint implements ModelObject, Saveable {
* The file we save our configuration.
*/
private static XmlFile getConfigFile(File file) {
- return new XmlFile(XSTREAM,file);
+ return new XmlFile(XSTREAM, file);
}
/**
* Determines the file name from md5sum.
*/
private static File getFingerprintFile(byte[] md5sum) {
- assert md5sum.length==16;
- return new File( Hudson.getInstance().getRootDir(),
- "fingerprints/"+ Util.toHexString(md5sum,0,1)+'/'+Util.toHexString(md5sum,1,1)+'/'+Util.toHexString(md5sum,2,md5sum.length-2)+".xml");
+ assert md5sum.length == 16;
+ return new File(Hudson.getInstance().getRootDir(),
+ "fingerprints/" + Util.toHexString(md5sum, 0, 1) + '/' + Util.toHexString(md5sum, 1, 1) + '/' + Util.toHexString(md5sum, 2, md5sum.length - 2) + ".xml");
}
/**
@@ -740,50 +752,51 @@ public class Fingerprint implements ModelObject, Saveable {
}
/*package*/ static Fingerprint load(File file) throws IOException {
XmlFile configFile = getConfigFile(file);
- if(!configFile.exists())
+ if (!configFile.exists()) {
return null;
+ }
- long start=0;
- if(logger.isLoggable(Level.FINE))
+ long start = 0;
+ if (logger.isLoggable(Level.FINE)) {
start = System.currentTimeMillis();
+ }
try {
Fingerprint f = (Fingerprint) configFile.read();
- if(logger.isLoggable(Level.FINE))
- logger.fine("Loading fingerprint "+file+" took "+(System.currentTimeMillis()-start)+"ms");
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine("Loading fingerprint " + file + " took " + (System.currentTimeMillis() - start) + "ms");
+ }
return f;
} catch (IOException e) {
- if(file.exists() && file.length()==0) {
+ if (file.exists() && file.length() == 0) {
// Despite the use of AtomicFile, there are reports indicating that people often see
// empty XML file, presumably either due to file system corruption (perhaps by sudden
// power loss, etc.) or abnormal program termination.
// generally we don't want to wipe out user data just because we can't load it,
// but if the file size is 0, which is what's reported in HUDSON-2012, then it seems
// like recovering it silently by deleting the file is not a bad idea.
- logger.log(Level.WARNING, "Size zero fingerprint. Disk corruption? "+configFile,e);
+ logger.log(Level.WARNING, "Size zero fingerprint. Disk corruption? " + configFile, e);
file.delete();
return null;
}
- logger.log(Level.WARNING, "Failed to load "+configFile,e);
+ logger.log(Level.WARNING, "Failed to load " + configFile, e);
throw e;
}
}
-
private static final XStream XSTREAM = new XStream2();
+
static {
- XSTREAM.alias("fingerprint",Fingerprint.class);
- XSTREAM.alias("range",Range.class);
- XSTREAM.alias("ranges",RangeSet.class);
- XSTREAM.registerConverter(new HexBinaryConverter(),10);
+ XSTREAM.alias("fingerprint", Fingerprint.class);
+ XSTREAM.alias("range", Range.class);
+ XSTREAM.alias("ranges", RangeSet.class);
+ XSTREAM.registerConverter(new HexBinaryConverter(), 10);
XSTREAM.registerConverter(new RangeSet.ConverterImpl(
- new CollectionConverter(XSTREAM.getMapper()) {
- @Override
- protected Object createCollection(Class type) {
- return new ArrayList();
- }
- }
- ),10);
+ new CollectionConverter(XSTREAM.getMapper()) {
+ @Override
+ protected Object createCollection(Class type) {
+ return new ArrayList();
+ }
+ }), 10);
}
-
private static final Logger logger = Logger.getLogger(Fingerprint.class.getName());
}
diff --git a/hudson-core/src/main/java/hudson/model/FingerprintCleanupThread.java b/hudson-core/src/main/java/hudson/model/FingerprintCleanupThread.java
index 650ab41..2850d7a 100644
--- a/hudson-core/src/main/java/hudson/model/FingerprintCleanupThread.java
+++ b/hudson-core/src/main/java/hudson/model/FingerprintCleanupThread.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
-*
-* Kohsuke Kawaguchi
- *
+ * Contributors:
+ *
+ * Kohsuke Kawaguchi
+ *
*
*******************************************************************************/
@@ -25,12 +25,11 @@ import java.util.logging.Level;
import java.util.regex.Pattern;
/**
- * Scans the fingerprint database and remove old records
- * that are no longer relevant.
+ * Scans the fingerprint database and remove old records that are no longer
+ * relevant.
*
- * <p>
- * A {@link Fingerprint} is removed when none of the builds that
- * it point to is available in the records.
+ * <p> A {@link Fingerprint} is removed when none of the builds that it point to
+ * is available in the records.
*
* @author Kohsuke Kawaguchi
*/
@@ -55,16 +54,17 @@ public final class FingerprintCleanupThread extends AsyncPeriodicWork {
protected void execute(TaskListener listener) {
int numFiles = 0;
- File root = new File(Hudson.getInstance().getRootDir(),"fingerprints");
+ File root = new File(Hudson.getInstance().getRootDir(), "fingerprints");
File[] files1 = root.listFiles(LENGTH2DIR_FILTER);
- if(files1!=null) {
+ if (files1 != null) {
for (File file1 : files1) {
File[] files2 = file1.listFiles(LENGTH2DIR_FILTER);
- for(File file2 : files2) {
+ for (File file2 : files2) {
File[] files3 = file2.listFiles(FINGERPRINTFILE_FILTER);
- for(File file3 : files3) {
- if(check(file3))
+ for (File file3 : files3) {
+ if (check(file3)) {
numFiles++;
+ }
}
deleteIfEmpty(file2);
}
@@ -72,7 +72,7 @@ public final class FingerprintCleanupThread extends AsyncPeriodicWork {
}
}
- logger.log(Level.INFO, "Cleaned up "+numFiles+" records");
+ logger.log(Level.INFO, "Cleaned up " + numFiles + " records");
}
/**
@@ -80,9 +80,12 @@ public final class FingerprintCleanupThread extends AsyncPeriodicWork {
*/
private void deleteIfEmpty(File dir) {
String[] r = dir.list();
- if(r==null) return; // can happen in a rare occasion
- if(r.length==0)
+ if (r == null) {
+ return; // can happen in a rare occasion
+ }
+ if (r.length == 0) {
dir.delete();
+ }
}
/**
@@ -91,22 +94,20 @@ public final class FingerprintCleanupThread extends AsyncPeriodicWork {
private boolean check(File fingerprintFile) {
try {
Fingerprint fp = Fingerprint.load(fingerprintFile);
- if(!fp.isAlive()) {
+ if (!fp.isAlive()) {
fingerprintFile.delete();
return true;
}
} catch (IOException e) {
- logger.log(Level.WARNING, "Failed to process "+fingerprintFile, e);
+ logger.log(Level.WARNING, "Failed to process " + fingerprintFile, e);
}
return false;
}
-
private static final FileFilter LENGTH2DIR_FILTER = new FileFilter() {
public boolean accept(File f) {
- return f.isDirectory() && f.getName().length()==2;
+ return f.isDirectory() && f.getName().length() == 2;
}
};
-
private static final FileFilter FINGERPRINTFILE_FILTER = new FileFilter() {
private final Pattern PATTERN = Pattern.compile("[0-9a-f]{28}\\.xml");
diff --git a/hudson-core/src/main/java/hudson/model/FingerprintMap.java b/hudson-core/src/main/java/hudson/model/FingerprintMap.java
index b96e9ca..d5a8840 100644
--- a/hudson-core/src/main/java/hudson/model/FingerprintMap.java
+++ b/hudson-core/src/main/java/hudson/model/FingerprintMap.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
*
* Kohsuke Kawaguchi
- *
+ *
*
*******************************************************************************/
@@ -28,63 +28,63 @@ import java.util.concurrent.ConcurrentHashMap;
/**
* Cache of {@link Fingerprint}s.
*
- * <p>
- * This implementation makes sure that no two {@link Fingerprint} objects
- * lie around for the same hash code, and that unused {@link Fingerprint}
- * will be adequately GC-ed to prevent memory leak.
+ * <p> This implementation makes sure that no two {@link Fingerprint} objects
+ * lie around for the same hash code, and that unused {@link Fingerprint} will
+ * be adequately GC-ed to prevent memory leak.
*
* @author Kohsuke Kawaguchi
- * @see Hudson#getFingerprintMap()
+ * @see Hudson#getFingerprintMap()
*/
-public final class FingerprintMap extends KeyedDataStorage<Fingerprint,FingerprintParams> {
+public final class FingerprintMap extends KeyedDataStorage<Fingerprint, FingerprintParams> {
/**
- * @deprecated since 2007-03-26.
- * Some old version of Hudson incorrectly serialized this information to the disk.
- * So we need this field to be here for such configuration to be read correctly.
- * This field is otherwise no longer in use.
+ * @deprecated since 2007-03-26. Some old version of Hudson incorrectly
+ * serialized this information to the disk. So we need this field to be here
+ * for such configuration to be read correctly. This field is otherwise no
+ * longer in use.
*/
- private transient ConcurrentHashMap<String,Object> core = new ConcurrentHashMap<String,Object>();
+ private transient ConcurrentHashMap<String, Object> core = new ConcurrentHashMap<String, Object>();
/**
* Returns true if there's some data in the fingerprint database.
*/
public boolean isReady() {
- return new File(Hudson.getInstance().getRootDir(),"fingerprints").exists();
+ return new File(Hudson.getInstance().getRootDir(), "fingerprints").exists();
}
/**
- * @param build
- * set to non-null if {@link Fingerprint} to be created (if so)
- * will have this build as the owner. Otherwise null, to indicate
- * an owner-less build.
+ * @param build set to non-null if {@link Fingerprint} to be created (if so)
+ * will have this build as the owner. Otherwise null, to indicate an
+ * owner-less build.
*/
public Fingerprint getOrCreate(AbstractBuild build, String fileName, byte[] md5sum) throws IOException {
- return getOrCreate(build,fileName, Util.toHexString(md5sum));
+ return getOrCreate(build, fileName, Util.toHexString(md5sum));
}
public Fingerprint getOrCreate(AbstractBuild build, String fileName, String md5sum) throws IOException {
- return super.getOrCreate(md5sum, new FingerprintParams(build,fileName));
+ return super.getOrCreate(md5sum, new FingerprintParams(build, fileName));
}
public Fingerprint getOrCreate(Run build, String fileName, String md5sum) throws IOException {
- return super.getOrCreate(md5sum, new FingerprintParams(build,fileName));
+ return super.getOrCreate(md5sum, new FingerprintParams(build, fileName));
}
@Override
protected Fingerprint get(String md5sum, boolean createIfNotExist, FingerprintParams createParams) throws IOException {
// sanity check
- if(md5sum.length()!=32)
+ if (md5sum.length() != 32) {
return null; // illegal input
+ }
md5sum = md5sum.toLowerCase(Locale.ENGLISH);
- return super.get(md5sum,createIfNotExist,createParams);
+ return super.get(md5sum, createIfNotExist, createParams);
}
private byte[] toByteArray(String md5sum) {
byte[] data = new byte[16];
- for( int i=0; i<md5sum.length(); i+=2 )
- data[i/2] = (byte)Integer.parseInt(md5sum.substring(i,i+2),16);
+ for (int i = 0; i < md5sum.length(); i += 2) {
+ data[i / 2] = (byte) Integer.parseInt(md5sum.substring(i, i + 2), 16);
+ }
return data;
}
@@ -97,12 +97,15 @@ public final class FingerprintMap extends KeyedDataStorage<Fingerprint,Fingerpri
}
private Object readResolve() {
- if (core != null) OldDataMonitor.report(Hudson.getInstance(), "1.91");
+ if (core != null) {
+ OldDataMonitor.report(Hudson.getInstance(), "1.91");
+ }
return this;
}
}
class FingerprintParams {
+
/**
* Null if the build isn't claiming to be the owner.
*/
@@ -113,6 +116,6 @@ class FingerprintParams {
this.build = build;
this.fileName = fileName;
- assert fileName!=null;
+ assert fileName != null;
}
}
diff --git a/hudson-core/src/main/java/hudson/model/FreeStyleBuild.java b/hudson-core/src/main/java/hudson/model/FreeStyleBuild.java
index cee96ca..47ad34c 100644
--- a/hudson-core/src/main/java/hudson/model/FreeStyleBuild.java
+++ b/hudson-core/src/main/java/hudson/model/FreeStyleBuild.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
-*
-* Kohsuke Kawaguchi
- *
+ * Contributors:
+ *
+ * Kohsuke Kawaguchi
+ *
*
*******************************************************************************/
@@ -25,7 +25,8 @@ import java.io.File;
/**
* @author Kohsuke Kawaguchi
*/
-public class FreeStyleBuild extends Build<FreeStyleProject,FreeStyleBuild> {
+public class FreeStyleBuild extends Build<FreeStyleProject, FreeStyleBuild> {
+
public FreeStyleBuild(FreeStyleProject project) throws IOException {
super(project);
}
@@ -39,14 +40,16 @@ public class FreeStyleBuild extends Build<FreeStyleProject,FreeStyleBuild> {
run(new RunnerImpl());
}
- protected class RunnerImpl extends Build<FreeStyleProject,FreeStyleBuild>.RunnerImpl {
+ protected class RunnerImpl extends Build<FreeStyleProject, FreeStyleBuild>.RunnerImpl {
+
@Override
protected Lease decideWorkspace(Node n, WorkspaceList wsl) throws IOException, InterruptedException {
String customWorkspace = getProject().getCustomWorkspace();
- if (customWorkspace != null)
- // we allow custom workspaces to be concurrently used between jobs.
+ if (customWorkspace != null) // we allow custom workspaces to be concurrently used between jobs.
+ {
return Lease.createDummyLease(n.getRootPath().child(getEnvironment(listener).expand(customWorkspace)));
- return super.decideWorkspace(n,wsl);
+ }
+ return super.decideWorkspace(n, wsl);
}
}
}
diff --git a/hudson-core/src/main/java/hudson/model/FreeStyleProject.java b/hudson-core/src/main/java/hudson/model/FreeStyleProject.java
index d9280a7..034c7f8 100644
--- a/hudson-core/src/main/java/hudson/model/FreeStyleProject.java
+++ b/hudson-core/src/main/java/hudson/model/FreeStyleProject.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
-*
-* Kohsuke Kawaguchi, id:cactusman, Anton Kozak, Nikita Levyankov
- *
+ * Contributors:
+ *
+ * Kohsuke Kawaguchi, id:cactusman, Anton Kozak, Nikita Levyankov
+ *
*
*******************************************************************************/
@@ -29,19 +29,19 @@ import javax.servlet.ServletException;
/**
* Free-style software project.
- *
+ *
* @author Kohsuke Kawaguchi
*/
-public class FreeStyleProject extends Project<FreeStyleProject,FreeStyleBuild> implements TopLevelItem,
- IFreeStyleProject {
+public class FreeStyleProject extends Project<FreeStyleProject, FreeStyleBuild> implements TopLevelItem,
+ IFreeStyleProject {
/**
* See {@link #setCustomWorkspace(String)}.
*
* @since 1.216
- * @deprecated as of 2.2.0
- * don't use this field directly, logic was moved to {@link org.eclipse.hudson.api.model.IProjectProperty}.
- * Use getter/setter for accessing to this field.
+ * @deprecated as of 2.2.0 don't use this field directly, logic was moved to
+ * {@link org.eclipse.hudson.api.model.IProjectProperty}. Use getter/setter
+ * for accessing to this field.
*/
@Deprecated
private String customWorkspace;
@@ -76,10 +76,10 @@ public class FreeStyleProject extends Project<FreeStyleProject,FreeStyleBuild> i
@Override
protected void submit(StaplerRequest req, StaplerResponse rsp)
- throws IOException, ServletException, Descriptor.FormException {
+ throws IOException, ServletException, Descriptor.FormException {
super.submit(req, rsp);
setCustomWorkspace(
- req.hasParameter("customWorkspace") ? req.getParameter("customWorkspace.directory") : null);
+ req.hasParameter("customWorkspace") ? req.getParameter("customWorkspace.directory") : null);
}
@Override
@@ -103,17 +103,17 @@ public class FreeStyleProject extends Project<FreeStyleProject,FreeStyleBuild> i
public DescriptorImpl getDescriptor() {
return DESCRIPTOR;
}
-
- @Extension(ordinal=1000)
+ @Extension(ordinal = 1000)
public static final DescriptorImpl DESCRIPTOR = new DescriptorImpl();
public static final class DescriptorImpl extends AbstractProjectDescriptor {
+
public String getDisplayName() {
return Messages.FreeStyleProject_DisplayName();
}
public FreeStyleProject newInstance(ItemGroup parent, String name) {
- return new FreeStyleProject(parent,name);
+ return new FreeStyleProject(parent, name);
}
}
}
diff --git a/hudson-core/src/main/java/hudson/model/FullDuplexHttpChannel.java b/hudson-core/src/main/java/hudson/model/FullDuplexHttpChannel.java
index af08988..3864e1f 100644
--- a/hudson-core/src/main/java/hudson/model/FullDuplexHttpChannel.java
+++ b/hudson-core/src/main/java/hudson/model/FullDuplexHttpChannel.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -32,18 +32,17 @@ import java.util.UUID;
import java.util.logging.Logger;
/**
- * Builds a {@link Channel} on top of two HTTP streams (one used for each direction.)
+ * Builds a {@link Channel} on top of two HTTP streams (one used for each
+ * direction.)
*
* @author Kohsuke Kawaguchi
*/
abstract class FullDuplexHttpChannel {
- private Channel channel;
+ private Channel channel;
private InputStream upload;
-
private final UUID uuid;
private final boolean restricted;
-
private boolean completed;
public FullDuplexHttpChannel(UUID uuid, boolean restricted) throws IOException {
@@ -54,8 +53,7 @@ abstract class FullDuplexHttpChannel {
/**
* This is where we send the data to the client.
*
- * <p>
- * If this connection is lost, we'll abort the channel.
+ * <p> If this connection is lost, we'll abort the channel.
*/
public synchronized void download(StaplerRequest req, StaplerResponse rsp) throws InterruptedException, IOException {
rsp.setStatus(HttpServletResponse.SC_OK);
@@ -64,15 +62,18 @@ abstract class FullDuplexHttpChannel {
// this is created first, and this controls the lifespan of the channel
rsp.addHeader("Transfer-Encoding", "chunked");
OutputStream out = rsp.getOutputStream();
- if (DIY_CHUNKING) out = new ChunkedOutputStream(out);
+ if (DIY_CHUNKING) {
+ out = new ChunkedOutputStream(out);
+ }
// send something out so that the client will see the HTTP headers
out.write("Starting HTTP duplex channel".getBytes());
out.flush();
// wait until we have the other channel
- while(upload==null)
+ while (upload == null) {
wait();
+ }
try {
channel = new Channel("HTTP full-duplex channel " + uuid,
@@ -98,7 +99,7 @@ abstract class FullDuplexHttpChannel {
ping.interrupt();
} finally {
// publish that we are done
- completed=true;
+ completed = true;
notify();
}
}
@@ -111,23 +112,24 @@ abstract class FullDuplexHttpChannel {
public synchronized void upload(StaplerRequest req, StaplerResponse rsp) throws InterruptedException, IOException {
rsp.setStatus(HttpServletResponse.SC_OK);
InputStream in = req.getInputStream();
- if(DIY_CHUNKING) in = new ChunkedInputStream(in);
+ if (DIY_CHUNKING) {
+ in = new ChunkedInputStream(in);
+ }
// publish the upload channel
upload = in;
notify();
// wait until we are done
- while (!completed)
+ while (!completed) {
wait();
+ }
}
public Channel getChannel() {
return channel;
}
-
private static final Logger LOGGER = Logger.getLogger(FullDuplexHttpChannel.class.getName());
-
/**
* Set to true if the servlet container doesn't support chunked encoding.
*/
diff --git a/hudson-core/src/main/java/hudson/model/HealthReport.java b/hudson-core/src/main/java/hudson/model/HealthReport.java
index 56d0bc0..dbd49c3 100644
--- a/hudson-core/src/main/java/hudson/model/HealthReport.java
+++ b/hudson-core/src/main/java/hudson/model/HealthReport.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
*
* Kohsuke Kawaguchi, Stephen Connolly
- *
+ *
*
*******************************************************************************/
@@ -29,8 +29,7 @@ import java.util.List;
import java.util.Locale;
/**
- * Represents health of something (typically project).
- * A number between 0-100.
+ * Represents health of something (typically project). A number between 0-100.
*
* @author connollys
* @since 1.115
@@ -39,28 +38,30 @@ import java.util.Locale;
// this is always exported as a part of Job and never on its own, so start with 2.
public class HealthReport implements Serializable, Comparable<HealthReport> {
// These are now 0-20, 21-40, 41-60, 61-80, 81+ but filenames unchanged for compatibility
+
private static final String HEALTH_OVER_80 = "health-80plus.png";
private static final String HEALTH_61_TO_80 = "health-60to79.png";
private static final String HEALTH_41_TO_60 = "health-40to59.png";
private static final String HEALTH_21_TO_40 = "health-20to39.png";
private static final String HEALTH_0_TO_20 = "health-00to19.png";
private static final String HEALTH_UNKNOWN = "empty.png";
-
/**
* The percentage health score (from 0 to 100 inclusive).
*/
private int score;
-
/**
- * The path to the icon corresponding to this health score or <code>null</code> to use the default icon
- * corresponding to the current health score.
+ * The path to the icon corresponding to this health score or
+ * <code>null</code> to use the default icon corresponding to the current
+ * health score.
* <p/>
- * If the path begins with a '/' then it will be the absolute path, otherwise the image is assumed to be in one of
- * <code>/images/16x16/</code>, <code>/images/24x24/</code> or <code>/images/32x32/</code> depending on the icon
- * size selected by the user.
+ * If the path begins with a '/' then it will be the absolute path,
+ * otherwise the image is assumed to be in one of
+ * <code>/images/16x16/</code>,
+ * <code>/images/24x24/</code> or
+ * <code>/images/32x32/</code> depending on the icon size selected by the
+ * user.
*/
private String iconUrl;
-
/**
* Recover the health icon's tool-tip when deserializing.
*
@@ -68,7 +69,6 @@ public class HealthReport implements Serializable, Comparable<HealthReport> {
*/
@Deprecated
private transient String description;
-
/**
* The health icon's tool-tip.
*/
@@ -77,18 +77,21 @@ public class HealthReport implements Serializable, Comparable<HealthReport> {
/**
* Create a new HealthReport.
*
- * @param score The percentage health score (from 0 to 100 inclusive).
- * @param iconUrl The path to the icon corresponding to this {@link Action}'s health or <code>null</code> to
- * display the default icon corresponding to the current health score.
- * <p/>
- * If the path begins with a '/' then it will be the absolute path, otherwise the image is
- * assumed to be in one of <code>/images/16x16/</code>, <code>/images/24x24/</code> or
- * <code>/images/32x32/</code> depending on the icon size selected by the user.
- * When calculating the url to display for absolute paths, the getIconUrl(String) method
- * will replace /32x32/ in the path with the appropriate size.
+ * @param score The percentage health score (from 0 to 100 inclusive).
+ * @param iconUrl The path to the icon corresponding to this
+ * {@link Action}'s health or <code>null</code> to display the default icon
+ * corresponding to the current health score.
+ * <p/>
+ * If the path begins with a '/' then it will be the absolute path,
+ * otherwise the image is assumed to be in one
+ * of <code>/images/16x16/</code>, <code>/images/24x24/</code> or
+ * <code>/images/32x32/</code> depending on the icon size selected by the
+ * user. When calculating the url to display for absolute paths, the
+ * getIconUrl(String) method will replace /32x32/ in the path with the
+ * appropriate size.
* @param description The health icon's tool-tip.
- * @deprecated since 2008-10-18.
- * Use {@link #HealthReport(int, String, org.jvnet.localizer.Localizable)}
+ * @deprecated since 2008-10-18. Use
+ * {@link #HealthReport(int, String, org.jvnet.localizer.Localizable)}
*/
@Deprecated
public HealthReport(int score, String iconUrl, String description) {
@@ -98,15 +101,18 @@ public class HealthReport implements Serializable, Comparable<HealthReport> {
/**
* Create a new HealthReport.
*
- * @param score The percentage health score (from 0 to 100 inclusive).
- * @param iconUrl The path to the icon corresponding to this {@link Action}'s health or <code>null</code> to
- * display the default icon corresponding to the current health score.
- * <p/>
- * If the path begins with a '/' then it will be the absolute path, otherwise the image is
- * assumed to be in one of <code>/images/16x16/</code>, <code>/images/24x24/</code> or
- * <code>/images/32x32/</code> depending on the icon size selected by the user.
- * When calculating the url to display for absolute paths, the getIconUrl(String) method
- * will replace /32x32/ in the path with the appropriate size.
+ * @param score The percentage health score (from 0 to 100 inclusive).
+ * @param iconUrl The path to the icon corresponding to this
+ * {@link Action}'s health or <code>null</code> to display the default icon
+ * corresponding to the current health score.
+ * <p/>
+ * If the path begins with a '/' then it will be the absolute path,
+ * otherwise the image is assumed to be in one
+ * of <code>/images/16x16/</code>, <code>/images/24x24/</code> or
+ * <code>/images/32x32/</code> depending on the icon size selected by the
+ * user. When calculating the url to display for absolute paths, the
+ * getIconUrl(String) method will replace /32x32/ in the path with the
+ * appropriate size.
* @param description The health icon's tool-tip.
*/
public HealthReport(int score, String iconUrl, Localizable description) {
@@ -133,10 +139,10 @@ public class HealthReport implements Serializable, Comparable<HealthReport> {
/**
* Create a new HealthReport.
*
- * @param score The percentage health score (from 0 to 100 inclusive).
+ * @param score The percentage health score (from 0 to 100 inclusive).
* @param description The health icon's tool-tip.
- * @deprecated since 2008-10-18.
- * Use {@link #HealthReport(int, org.jvnet.localizer.Localizable)}
+ * @deprecated since 2008-10-18. Use
+ * {@link #HealthReport(int, org.jvnet.localizer.Localizable)}
*/
@Deprecated
public HealthReport(int score, String description) {
@@ -146,7 +152,7 @@ public class HealthReport implements Serializable, Comparable<HealthReport> {
/**
* Create a new HealthReport.
*
- * @param score The percentage health score (from 0 to 100 inclusive).
+ * @param score The percentage health score (from 0 to 100 inclusive).
* @param description The health icon's tool-tip.
*/
public HealthReport(int score, Localizable description) {
@@ -245,7 +251,8 @@ public class HealthReport implements Serializable, Comparable<HealthReport> {
/**
* Setter for property 'localizibleDescription'.
*
- * @param localizibleDescription Value to set for property 'localizibleDescription'.
+ * @param localizibleDescription Value to set for property
+ * 'localizibleDescription'.
*/
public void setLocalizibleDescription(Localizable localizibleDescription) {
this.localizibleDescription = localizibleDescription;
@@ -280,10 +287,18 @@ public class HealthReport implements Serializable, Comparable<HealthReport> {
* Utility method to find the report with the lowest health.
*/
public static HealthReport min(HealthReport a, HealthReport b) {
- if (a == null && b == null) return null;
- if (a == null) return b;
- if (b == null) return a;
- if (a.compareTo(b) <= 0) return a;
+ if (a == null && b == null) {
+ return null;
+ }
+ if (a == null) {
+ return b;
+ }
+ if (b == null) {
+ return a;
+ }
+ if (a.compareTo(b) <= 0) {
+ return a;
+ }
return b;
}
@@ -291,10 +306,18 @@ public class HealthReport implements Serializable, Comparable<HealthReport> {
* Utility method to find the report with the highest health.
*/
public static HealthReport max(HealthReport a, HealthReport b) {
- if (a == null && b == null) return null;
- if (a == null) return b;
- if (b == null) return a;
- if (a.compareTo(b) >= 0) return a;
+ if (a == null && b == null) {
+ return null;
+ }
+ if (a == null) {
+ return b;
+ }
+ if (b == null) {
+ return a;
+ }
+ if (a.compareTo(b) >= 0) {
+ return a;
+ }
return b;
}
@@ -302,8 +325,13 @@ public class HealthReport implements Serializable, Comparable<HealthReport> {
* Fix deserialization of older data.
*/
public static class ConverterImpl extends XStream2.PassthruConverter<HealthReport> {
- public ConverterImpl(XStream2 xstream) { super(xstream); }
- @Override protected void callback(HealthReport hr, UnmarshallingContext context) {
+
+ public ConverterImpl(XStream2 xstream) {
+ super(xstream);
+ }
+
+ @Override
+ protected void callback(HealthReport hr, UnmarshallingContext context) {
// If we are being read back in from an older version
if (hr.localizibleDescription == null) {
hr.localizibleDescription = new NonLocalizable(hr.description == null ? "" : hr.description);
@@ -313,9 +341,11 @@ public class HealthReport implements Serializable, Comparable<HealthReport> {
}
/**
- * In order to provide backwards compatibility, we use this crazy class to fake out localization.
+ * In order to provide backwards compatibility, we use this crazy class to
+ * fake out localization.
*/
private static class NonLocalizable extends Localizable {
+
/**
* The string that we don't know how to localize
*/
diff --git a/hudson-core/src/main/java/hudson/model/HealthReportingAction.java b/hudson-core/src/main/java/hudson/model/HealthReportingAction.java
index fca6634..348ba27 100644
--- a/hudson-core/src/main/java/hudson/model/HealthReportingAction.java
+++ b/hudson-core/src/main/java/hudson/model/HealthReportingAction.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
-*
-* Kohsuke Kawaguchi, Stephen Connolly
- *
+ * Contributors:
+ *
+ * Kohsuke Kawaguchi, Stephen Connolly
+ *
*
*******************************************************************************/
@@ -18,26 +18,24 @@ package hudson.model;
/**
* An {@link Action} that can return information about the health of the Job.
- * <p>
- * The health of a {@link Job} is the lowest health returned by the HealthReportingAction's
- * that contribute to the Job.
- * <p>
- * When a particular Action "wins", it's gets to determine the icon and associated description.
- * <p>
- * This provides a mechanism for plugins to present important summary information
- * on the {@link View} main pages without eating up significant screen real estate.
+ * <p> The health of a {@link Job} is the lowest health returned by the
+ * HealthReportingAction's that contribute to the Job. <p> When a particular
+ * Action "wins", it's gets to determine the icon and associated description.
+ * <p> This provides a mechanism for plugins to present important summary
+ * information on the {@link View} main pages without eating up significant
+ * screen real estate.
*
* @author Stephen Connolly
* @since 1.115
*/
public interface HealthReportingAction extends Action {
+
/**
* Get this {@link Action}'s {@link HealthReport}.
*
- * @return
- * The health report for this instance of the Action or
- * <code>null</code> if the Action does not want to
- * contribute a HealthReport.
+ * @return The health report for this instance of the Action or
+ * <code>null</code> if the Action does not want to contribute a
+ * HealthReport.
*/
HealthReport getBuildHealth();
}
diff --git a/hudson-core/src/main/java/hudson/model/Hudson.java b/hudson-core/src/main/java/hudson/model/Hudson.java
index 0a2216f..a65aa68 100644
--- a/hudson-core/src/main/java/hudson/model/Hudson.java
+++ b/hudson-core/src/main/java/hudson/model/Hudson.java
@@ -7,11 +7,11 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
*
* Kohsuke Kawaguchi, Winston Prakash, Nikita Levyankov, Erik Ramfelt, Koichi Fujikawa,
* Seiji Sogabe, Stephen Connolly, Tom Huybrechts, Alan Harder
- *
+ *
*******************************************************************************/
package hudson.model;
@@ -221,7 +221,6 @@ import org.springframework.security.ui.AbstractProcessingFilter;
public final class Hudson extends Node implements ItemGroup<TopLevelItem>, StaplerProxy, StaplerFallback, ViewGroup, AccessControlled, DescriptorByNameOwner {
private transient Logger logger = LoggerFactory.getLogger(Hudson.class);
-
private transient final Queue queue;
/**
* Stores various objects scoped to {@link Hudson}.
@@ -232,13 +231,14 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
*/
private transient final Map<Node, Computer> computers = new CopyOnWriteMap.Hash<Node, Computer>();
/**
- * We update this field to the current version of Hudson whenever we save {@code config.xml}.
- * This can be used to detect when an upgrade happens from one version to next.
+ * We update this field to the current version of Hudson whenever we save
+ * {@code config.xml}. This can be used to detect when an upgrade happens
+ * from one version to next.
*
- * <p>
- * Since this field is introduced starting 1.301, "1.0" is used to represent every version
- * up to 1.300. This value may also include non-standard versions like "1.301-SNAPSHOT" or
- * "?", etc., so parsing needs to be done with a care.
+ * <p> Since this field is introduced starting 1.301, "1.0" is used to
+ * represent every version up to 1.300. This value may also include
+ * non-standard versions like "1.301-SNAPSHOT" or "?", etc., so parsing
+ * needs to be done with a care.
*
* @since 1.301
*/
@@ -252,14 +252,14 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
* Job allocation strategy.
*/
private Mode mode = Mode.NORMAL;
-
/**
* Message displayed in the top page.
*/
private String systemMessage;
private static transient final String HUDSON_WORKSPACES_PROPERTY_KEY = "HUDSON_WORKSPACES";
/**
- * Workspace root dir which could be configured by setting HUDSON_WORKSPACES property.
+ * Workspace root dir which could be configured by setting HUDSON_WORKSPACES
+ * property.
*/
private volatile String configuredWorkspaceRoot;
/**
@@ -290,26 +290,24 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
* Currently active My Views tab bar.
*/
private volatile MyViewsTabBar myViewsTabBar = new DefaultMyViewsTabBar();
-
/**
* Script support (if available)
*/
private volatile ScriptSupport scriptSupport;
-
/**
- * All {@link ExtensionList} keyed by their {@link ExtensionList#extensionType}.
+ * All {@link ExtensionList} keyed by their
+ * {@link ExtensionList#extensionType}.
*/
private transient final Memoizer<Class, ExtensionList> extensionLists = new Memoizer<Class, ExtensionList>() {
-
public ExtensionList compute(Class key) {
return ExtensionList.create(Hudson.this, key);
}
};
/**
- * All {@link DescriptorExtensionList} keyed by their {@link DescriptorExtensionList#describableType}.
+ * All {@link DescriptorExtensionList} keyed by their
+ * {@link DescriptorExtensionList#describableType}.
*/
private transient final Memoizer<Class, DescriptorExtensionList> descriptorLists = new Memoizer<Class, DescriptorExtensionList>() {
-
public DescriptorExtensionList compute(Class key) {
return DescriptorExtensionList.createDescriptorList(Hudson.this, key);
}
@@ -344,21 +342,19 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
}
}
/**
- * Set of installed cluster nodes.
- * <p>
- * We use this field with copy-on-write semantics.
- * This field has mutable list (to keep the serialization look clean),
- * but it shall never be modified. Only new completely populated slave
- * list can be set here.
- * <p>
- * The field name should be really {@code nodes}, but again the backward compatibility
- * prevents us from renaming.
+ * Set of installed cluster nodes. <p> We use this field with copy-on-write
+ * semantics. This field has mutable list (to keep the serialization look
+ * clean), but it shall never be modified. Only new completely populated
+ * slave list can be set here. <p> The field name should be really
+ * {@code nodes}, but again the backward compatibility prevents us from
+ * renaming.
*/
private volatile NodeList slaves;
/**
* Quiet period.
*
- * This is {@link Integer} so that we can initialize it to '5' for upgrading users.
+ * This is {@link Integer} so that we can initialize it to '5' for upgrading
+ * users.
*/
/*package*/ Integer quietPeriod;
/**
@@ -370,9 +366,9 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
*/
private final CopyOnWriteArrayList<View> views = new CopyOnWriteArrayList<View>();
/**
- * Name of the primary view.
- * <p>
- * Start with null, so that we can upgrade pre-1.269 data well.
+ * Name of the primary view. <p> Start with null, so that we can upgrade
+ * pre-1.269 data well.
+ *
* @since 1.269
*/
private volatile String primaryView;
@@ -381,14 +377,13 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
* Loaded plugins.
*/
public transient final PluginManager pluginManager;
-
private transient PluginCenter pluginCenter;
-
public transient volatile TcpSlaveAgentListener tcpSlaveAgentListener;
private transient UDPBroadcastThread udpBroadcastThread;
private transient DNSMultiCast dnsMultiCast;
/**
* List of registered {@link ItemListener}s.
+ *
* @deprecated as of 1.286
*/
private transient final CopyOnWriteList<ItemListener> itemListeners = ExtensionListView.createCopyOnWriteList(ItemListener.class);
@@ -398,12 +393,12 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
private transient final CopyOnWriteList<SCMListener> scmListeners = new CopyOnWriteList<SCMListener>();
/**
* List of registered {@link ComputerListener}s.
+ *
* @deprecated as of 1.286
*/
private transient final CopyOnWriteList<ComputerListener> computerListeners = ExtensionListView.createCopyOnWriteList(ComputerListener.class);
/**
- * TCP slave agent port.
- * 0 for random, -1 to disable.
+ * TCP slave agent port. 0 for random, -1 to disable.
*/
private int slaveAgentPort = 0;
/**
@@ -415,8 +410,9 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
*/
private volatile CrumbIssuer crumbIssuer;
/**
- * All labels known to Hudson. This allows us to reuse the same label instances
- * as much as possible, even though that's not a strict requirement.
+ * All labels known to Hudson. This allows us to reuse the same label
+ * instances as much as possible, even though that's not a strict
+ * requirement.
*/
private transient final ConcurrentHashMap<String, Label> labels = new ConcurrentHashMap<String, Label>();
/**
@@ -430,8 +426,8 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
public transient final NodeProvisioner overallNodeProvisioner = new NodeProvisioner(null, overallLoad);
public transient final ServletContext servletContext;
/**
- * Transient action list. Useful for adding navigation items to the navigation bar
- * on the left.
+ * Transient action list. Useful for adding navigation items to the
+ * navigation bar on the left.
*/
private transient final List<Action> actions = new CopyOnWriteArrayList<Action>();
/**
@@ -462,7 +458,6 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
* Code that handles {@link ItemGroup} work.
*/
private transient final ItemGroupMixIn itemGroupMixIn = new ItemGroupMixIn(this, this) {
-
@Override
protected void add(TopLevelItem item) {
items.put(item.getName(), item);
@@ -474,8 +469,8 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
}
/**
- *send the browser to the config page
- * use View to trim view/{default-view} from URL if possible
+ * send the browser to the config page use View to trim
+ * view/{default-view} from URL if possible
*/
@Override
protected String redirectAfterCreateItem(StaplerRequest req, TopLevelItem result) throws IOException {
@@ -496,10 +491,10 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
public static Hudson getInstance() {
return theInstance;
}
-
private transient final UpdateCenter updateCenter = new UpdateCenter();
/**
- * True if the user opted out from the statistics tracking. We'll never send anything if this is true.
+ * True if the user opted out from the statistics tracking. We'll never send
+ * anything if this is true.
*/
private Boolean noUsageStatistics;
/**
@@ -516,8 +511,8 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
}
/**
- * @param pluginManager
- * If non-null, use existing plugin manager. create a new one.
+ * @param pluginManager If non-null, use existing plugin manager. create a
+ * new one.
*/
public Hudson(File root, ServletContext context, PluginManager pluginManager) throws IOException, InterruptedException, ReactorException {
// As hudson is starting, grant this process full control
@@ -556,9 +551,9 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
pluginManager = new LocalPluginManager(this);
}
this.pluginManager = pluginManager;
-
+
pluginCenter = new PluginCenter(root);
-
+
// JSON binding needs to be able to see all the classes from all the plugins
WebApp.get(servletContext).setClassLoader(pluginManager.uberClassLoader);
@@ -609,11 +604,11 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
for (ItemListener l : ItemListener.all()) {
l.onLoaded();
}
-
- if (!ScriptSupport.getAvailableScriptSupports().isEmpty()){
+
+ if (!ScriptSupport.getAvailableScriptSupports().isEmpty()) {
scriptSupport = ScriptSupport.getAvailableScriptSupports().get(0);
}
-
+
} finally {
HudsonSecurityManager.resetFullControl();
}
@@ -622,12 +617,11 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
/**
* Executes a reactor.
*
- * @param is
- * If non-null, this can be consulted for ignoring some tasks. Only used during the initialization of Hudson.
+ * @param is If non-null, this can be consulted for ignoring some tasks.
+ * Only used during the initialization of Hudson.
*/
private void executeReactor(final InitStrategy is, TaskBuilder... builders) throws IOException, InterruptedException, ReactorException {
Reactor reactor = new Reactor(builders) {
-
/**
* Sets the thread name to the task for better diagnostics.
*/
@@ -638,7 +632,7 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
}
// full access in the initialization thread
- HudsonSecurityManager.grantFullControl();
+ HudsonSecurityManager.grantFullControl();
String taskName = task.getDisplayName();
Thread t = Thread.currentThread();
@@ -677,14 +671,13 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
/**
* Aggregates all the listeners into one and returns it.
*
- * <p>
- * At this point plugins are not loaded yet, so we fall back to the META-INF/services look up to discover implementations.
- * As such there's no way for plugins to participate into this process.
+ * <p> At this point plugins are not loaded yet, so we fall back to the
+ * META-INF/services look up to discover implementations. As such there's no
+ * way for plugins to participate into this process.
*/
private ReactorListener buildReactorListener() throws IOException {
List<ReactorListener> r = (List) Service.loadInstances(Thread.currentThread().getContextClassLoader(), InitReactorListener.class);
r.add(new ReactorListener() {
-
public void onTaskStarted(Task t) {
logger.debug("Started " + t.getDisplayName());
}
@@ -698,7 +691,7 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
}
public void onAttained(Milestone milestone) {
-
+
String s = "Attained " + milestone.toString();
if (milestone instanceof InitMilestone) {
initLevel = (InitMilestone) milestone;
@@ -715,9 +708,8 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
}
/**
- * Makes {@link AdjunctManager} URL-bound.
- * The dummy parameter allows us to use different URLs for the same adjunct,
- * for proper cache handling.
+ * Makes {@link AdjunctManager} URL-bound. The dummy parameter allows us to
+ * use different URLs for the same adjunct, for proper cache handling.
*/
public AdjunctManager getAdjuncts(String dummy) {
return adjuncts;
@@ -755,11 +747,11 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
public PluginManager getPluginManager() {
return pluginManager;
}
-
+
public PluginCenter getPluginCenter() {
return pluginCenter;
}
-
+
public HudsonSecurityManager getSecurityManager() {
return HudsonSecurityEntitiesHolder.getHudsonSecurityManager();
}
@@ -793,9 +785,8 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
}
/**
- * Returns a secret key that survives across container start/stop.
- * <p>
- * This value is useful for implementing some of the security features.
+ * Returns a secret key that survives across container start/stop. <p> This
+ * value is useful for implementing some of the security features.
*/
public String getSecretKey() {
return getSecurityManager().getSecretKey();
@@ -803,6 +794,7 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
/**
* Gets {@linkplain #getSecretKey() the secret key} as a key for AES-128.
+ *
* @since 1.308
*/
public SecretKey getSecretKeyAsAES128() {
@@ -810,56 +802,64 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
}
/**
- * Gets the SCM descriptor by name. Primarily used for making them web-visible.
+ * Gets the SCM descriptor by name. Primarily used for making them
+ * web-visible.
*/
public Descriptor<SCM> getScm(String shortClassName) {
return findDescriptor(shortClassName, SCM.all());
}
/**
- * Gets the repository browser descriptor by name. Primarily used for making them web-visible.
+ * Gets the repository browser descriptor by name. Primarily used for making
+ * them web-visible.
*/
public Descriptor<RepositoryBrowser<?>> getRepositoryBrowser(String shortClassName) {
return findDescriptor(shortClassName, RepositoryBrowser.all());
}
/**
- * Gets the builder descriptor by name. Primarily used for making them web-visible.
+ * Gets the builder descriptor by name. Primarily used for making them
+ * web-visible.
*/
public Descriptor<Builder> getBuilder(String shortClassName) {
return findDescriptor(shortClassName, Builder.all());
}
/**
- * Gets the build wrapper descriptor by name. Primarily used for making them web-visible.
+ * Gets the build wrapper descriptor by name. Primarily used for making them
+ * web-visible.
*/
public Descriptor<BuildWrapper> getBuildWrapper(String shortClassName) {
return findDescriptor(shortClassName, BuildWrapper.all());
}
/**
- * Gets the publisher descriptor by name. Primarily used for making them web-visible.
+ * Gets the publisher descriptor by name. Primarily used for making them
+ * web-visible.
*/
public Descriptor<Publisher> getPublisher(String shortClassName) {
return findDescriptor(shortClassName, Publisher.all());
}
/**
- * Gets the trigger descriptor by name. Primarily used for making them web-visible.
+ * Gets the trigger descriptor by name. Primarily used for making them
+ * web-visible.
*/
public TriggerDescriptor getTrigger(String shortClassName) {
return (TriggerDescriptor) findDescriptor(shortClassName, Trigger.all());
}
/**
- * Gets the retention strategy descriptor by name. Primarily used for making them web-visible.
+ * Gets the retention strategy descriptor by name. Primarily used for making
+ * them web-visible.
*/
public Descriptor<RetentionStrategy<?>> getRetentionStrategy(String shortClassName) {
return findDescriptor(shortClassName, RetentionStrategy.all());
}
/**
- * Gets the {@link JobPropertyDescriptor} by name. Primarily used for making them web-visible.
+ * Gets the {@link JobPropertyDescriptor} by name. Primarily used for making
+ * them web-visible.
*/
public JobPropertyDescriptor getJobProperty(String shortClassName) {
// combining these two lines triggers javac bug. See issue #610.
@@ -870,11 +870,11 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
/**
* Exposes {@link Descriptor} by its name to URL.
*
- * After doing all the {@code getXXX(shortClassName)} methods, I finally realized that
- * this just doesn't scale.
+ * After doing all the {@code getXXX(shortClassName)} methods, I finally
+ * realized that this just doesn't scale.
*
- * @param id
- * Either {@link Descriptor#getId()} (recommended) or the short name of a {@link Describable} subtype (for compatibility)
+ * @param id Either {@link Descriptor#getId()} (recommended) or the short
+ * name of a {@link Describable} subtype (for compatibility)
*/
public Descriptor getDescriptor(String id) {
// legacy descriptors that are reigstered manually doesn't show up in getExtensionList, so check them explicitly.
@@ -898,10 +898,10 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
}
/**
- * Gets the {@link Descriptor} that corresponds to the given {@link Describable} type.
- * <p>
- * If you have an instance of {@code type} and call {@link Describable#getDescriptor()},
- * you'll get the same instance that this method returns.
+ * Gets the {@link Descriptor} that corresponds to the given
+ * {@link Describable} type. <p> If you have an instance of {@code type} and
+ * call {@link Describable#getDescriptor()}, you'll get the same instance
+ * that this method returns.
*/
public Descriptor getDescriptor(Class<? extends Describable> type) {
for (Descriptor d : getExtensionList(Descriptor.class)) {
@@ -913,10 +913,10 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
}
/**
- * Works just like {@link #getDescriptor(Class)} but don't take no for an answer.
+ * Works just like {@link #getDescriptor(Class)} but don't take no for an
+ * answer.
*
- * @throws AssertionError
- * If the descriptor is missing.
+ * @throws AssertionError If the descriptor is missing.
* @since 1.326
*/
public Descriptor getDescriptorOrDie(Class<? extends Describable> type) {
@@ -940,7 +940,8 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
}
/**
- * Gets the {@link SecurityRealm} descriptors by name. Primarily used for making them web-visible.
+ * Gets the {@link SecurityRealm} descriptors by name. Primarily used for
+ * making them web-visible.
*/
public Descriptor<SecurityRealm> getSecurityRealms(String shortClassName) {
return findDescriptor(shortClassName, SecurityRealm.all());
@@ -962,8 +963,7 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
/**
* Gets all the installed {@link ItemListener}s.
*
- * @deprecated as of 1.286.
- * Use {@link ItemListener#all()}.
+ * @deprecated as of 1.286. Use {@link ItemListener#all()}.
*/
public CopyOnWriteList<ItemListener> getJobListeners() {
return itemListeners;
@@ -979,8 +979,7 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
/**
* Gets all the installed {@link ComputerListener}s.
*
- * @deprecated as of 1.286.
- * Use {@link ComputerListener#all()}.
+ * @deprecated as of 1.286. Use {@link ComputerListener#all()}.
*/
public CopyOnWriteList<ComputerListener> getComputerListeners() {
return computerListeners;
@@ -989,8 +988,7 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
/**
* Gets the plugin object from its short name.
*
- * <p>
- * This allows URL <tt>hudson/plugin/ID</tt> to be served by the views
+ * <p> This allows URL <tt>hudson/plugin/ID</tt> to be served by the views
* of the plugin class.
*/
public Plugin getPlugin(String shortName) {
@@ -1004,12 +1002,12 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
/**
* Gets the plugin object from its class.
*
- * <p>
- * This allows easy storage of plugin information in the plugin singleton without
- * every plugin reimplementing the singleton pattern.
+ * <p> This allows easy storage of plugin information in the plugin
+ * singleton without every plugin reimplementing the singleton pattern.
*
- * @param clazz The plugin class (beware class-loader fun, this will probably only work
- * from within the hpi that defines the plugin class, it may or may not work in other cases)
+ * @param clazz The plugin class (beware class-loader fun, this will
+ * probably only work from within the hpi that defines the plugin class, it
+ * may or may not work in other cases)
*
* @return The plugin instance.
*/
@@ -1083,9 +1081,8 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
/**
* Updates {@link #computers} by using {@link #getSlaves()}.
*
- * <p>
- * This method tries to reuse existing {@link Computer} objects
- * so that we won't upset {@link Executor}s running in it.
+ * <p> This method tries to reuse existing {@link Computer} objects so that
+ * we won't upset {@link Executor}s running in it.
*/
private void updateComputerList() throws IOException {
synchronized (updateComputerLock) {// just so that we don't have two code updating computer list at the same time
@@ -1163,17 +1160,16 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
/**
* Returns the transient {@link Action}s associated with the top page.
*
- * <p>
- * Adding {@link Action} is primarily useful for plugins to contribute
- * an item to the navigation bar of the top page. See existing {@link Action}
- * implementation for it affects the GUI.
+ * <p> Adding {@link Action} is primarily useful for plugins to contribute
+ * an item to the navigation bar of the top page. See existing
+ * {@link Action} implementation for it affects the GUI.
*
- * <p>
- * To register an {@link Action}, implement {@link RootAction} extension point, or write code like
+ * <p> To register an {@link Action}, implement {@link RootAction} extension
+ * point, or write code like
* {@code Hudson.getInstance().getActions().add(...)}.
*
- * @return
- * Live list where the changes can be made. Can be empty but never null.
+ * @return Live list where the changes can be made. Can be empty but never
+ * null.
* @since 1.172
*/
public List<Action> getActions() {
@@ -1210,9 +1206,9 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
}
/**
- * Returns the read-only view of all the {@link TopLevelItem}s keyed by their names.
- * <p>
- * This method is efficient, as it doesn't involve any copying.
+ * Returns the read-only view of all the {@link TopLevelItem}s keyed by
+ * their names. <p> This method is efficient, as it doesn't involve any
+ * copying.
*
* @since 1.296
*/
@@ -1234,8 +1230,8 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
}
/**
- * Gets all the {@link Item}s recursively in the {@link ItemGroup} tree
- * and filter them by the given type.
+ * Gets all the {@link Item}s recursively in the {@link ItemGroup} tree and
+ * filter them by the given type.
*/
public <T extends Item> List<T> getAllItems(Class<T> type) {
List<T> r = new ArrayList<T>();
@@ -1263,9 +1259,8 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
/**
* Gets the list of all the projects.
*
- * <p>
- * Since {@link Project} can only show up under {@link Hudson},
- * no need to search recursively.
+ * <p> Since {@link Project} can only show up under {@link Hudson}, no need
+ * to search recursively.
*/
public List<Project> getProjects() {
return Util.createSubList(items.values(), Project.class);
@@ -1344,22 +1339,23 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
public MyViewsTabBar getMyViewsTabBar() {
return myViewsTabBar;
}
-
+
public ScriptSupport getScriptSupport() {
return scriptSupport;
}
/**
- * Returns true if the current running Hudson is upgraded from a version earlier than the specified version.
+ * Returns true if the current running Hudson is upgraded from a version
+ * earlier than the specified version.
*
- * <p>
- * This method continues to return true until the system configuration is saved, at which point
- * {@link #version} will be overwritten and Hudson forgets the upgrade history.
+ * <p> This method continues to return true until the system configuration
+ * is saved, at which point {@link #version} will be overwritten and Hudson
+ * forgets the upgrade history.
*
- * <p>
- * To handle SNAPSHOTS correctly, pass in "1.N.*" to test if it's upgrading from the version
- * equal or younger than N. So say if you implement a feature in 1.301 and you want to check
- * if the installation upgraded from pre-1.301, pass in "1.300.*"
+ * <p> To handle SNAPSHOTS correctly, pass in "1.N.*" to test if it's
+ * upgrading from the version equal or younger than N. So say if you
+ * implement a feature in 1.301 and you want to check if the installation
+ * upgraded from pre-1.301, pass in "1.300.*"
*
* @since 1.301
*/
@@ -1378,7 +1374,6 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
public Computer[] getComputers() {
Computer[] r = computers.values().toArray(new Computer[computers.size()]);
Arrays.sort(r, new Comparator<Computer>() {
-
final Collator collator = Collator.getInstance();
public int compare(Computer lhs, Computer rhs) {
@@ -1413,8 +1408,7 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
}
/**
- * @deprecated
- * UI method. Not meant to be used programmatically.
+ * @deprecated UI method. Not meant to be used programmatically.
*/
public ComputerSet getComputer() {
return new ComputerSet();
@@ -1530,8 +1524,7 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
/**
* Gets the slave node of the give name, hooked under this Hudson.
*
- * @deprecated
- * Use {@link #getNode(String)}. Since 1.252.
+ * @deprecated Use {@link #getNode(String)}. Since 1.252.
*/
public Slave getSlave(String name) {
Node n = getNode(name);
@@ -1561,16 +1554,15 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
}
/**
- * @deprecated
- * Use {@link #getNodes()}. Since 1.252.
+ * @deprecated Use {@link #getNodes()}. Since 1.252.
*/
public List<Slave> getSlaves() {
return (List) Collections.unmodifiableList(slaves);
}
/**
- * Returns all {@link Node}s in the system, excluding {@link Hudson} instance itself which
- * represents the master.
+ * Returns all {@link Node}s in the system, excluding {@link Hudson}
+ * instance itself which represents the master.
*/
public List<Node> getNodes() {
return Collections.unmodifiableList(slaves);
@@ -1579,8 +1571,7 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
/**
* Updates the slave list.
*
- * @deprecated
- * Use {@link #setNodes(List)}. Since 1.252.
+ * @deprecated Use {@link #setNodes(List)}. Since 1.252.
*/
public void setSlaves(List<Slave> slaves) throws IOException {
setNodes(slaves);
@@ -1705,9 +1696,8 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
}
/**
- * @deprecated
- * Why are you calling a method that always returns ""?
- * Perhaps you meant {@link #getRootUrl()}.
+ * @deprecated Why are you calling a method that always returns ""? Perhaps
+ * you meant {@link #getRootUrl()}.
*/
public String getUrl() {
return "";
@@ -1725,7 +1715,6 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
@Override
public SearchIndexBuilder makeSearchIndex() {
return super.makeSearchIndex().add("configure", "config", "configure").add("manage").add("log").add(getPrimaryView().makeSearchIndex()).add(new CollectionSearchIndex() {// for computers
-
protected Computer get(String key) {
return getComputer(key);
}
@@ -1734,7 +1723,6 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
return computers.values();
}
}).add(new CollectionSearchIndex() {// for users
-
protected User get(String key) {
return User.get(key, false);
}
@@ -1743,7 +1731,6 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
return User.getAll();
}
}).add(new CollectionSearchIndex() {// for views
-
protected View get(String key) {
return getView(key);
}
@@ -1772,19 +1759,15 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
}
/**
- * Gets the absolute URL of Hudson,
- * such as "http://localhost/hudson/".
+ * Gets the absolute URL of Hudson, such as "http://localhost/hudson/".
*
- * <p>
- * This method first tries to use the manually configured value, then
- * fall back to {@link StaplerRequest#getRootPath()}.
- * It is done in this order so that it can work correctly even in the face
- * of a reverse proxy.
+ * <p> This method first tries to use the manually configured value, then
+ * fall back to {@link StaplerRequest#getRootPath()}. It is done in this
+ * order so that it can work correctly even in the face of a reverse proxy.
*
- * @return
- * This method returns null if this parameter is not configured by the user.
- * The caller must gracefully deal with this situation.
- * The returned URL will always have the trailing '/'.
+ * @return This method returns null if this parameter is not configured by
+ * the user. The caller must gracefully deal with this situation. The
+ * returned URL will always have the trailing '/'.
* @since 1.66
* @see Descriptor#getCheckUrl(String)
* @see #getRootUrlFromRequest()
@@ -1804,14 +1787,15 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
}
/**
- * Gets the absolute URL of Hudson top page, such as "http://localhost/hudson/".
+ * Gets the absolute URL of Hudson top page, such as
+ * "http://localhost/hudson/".
*
- * <p>
- * Unlike {@link #getRootUrl()}, which uses the manually configured value,
- * this one uses the current request to reconstruct the URL. The benefit is
- * that this is immune to the configuration mistake (users often fail to set the root URL
- * correctly, especially when a migration is involved), but the downside
- * is that unless you are processing a request, this method doesn't work.
+ * <p> Unlike {@link #getRootUrl()}, which uses the manually configured
+ * value, this one uses the current request to reconstruct the URL. The
+ * benefit is that this is immune to the configuration mistake (users often
+ * fail to set the root URL correctly, especially when a migration is
+ * involved), but the downside is that unless you are processing a request,
+ * this method doesn't work.
*
* @since 1.263
*/
@@ -1834,8 +1818,9 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
/**
* {@inheritDoc}
* <p/>
- * If {@link Hudson#HUDSON_WORKSPACES_PROPERTY_KEY} is set through JNDI
- * or system properties or environment variables. workspaceRoot will be set based on property value.
+ * If {@link Hudson#HUDSON_WORKSPACES_PROPERTY_KEY} is set through JNDI or
+ * system properties or environment variables. workspaceRoot will be set
+ * based on property value.
*/
public FilePath getWorkspaceFor(TopLevelItem item) {
String workspaceRoot = getConfiguredWorkspaceRoot();
@@ -1847,7 +1832,8 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
}
/**
- * Checks jndi,environment properties and system properties for {@link Hudson#HUDSON_WORKSPACES_PROPERTY_KEY} value
+ * Checks jndi,environment properties and system properties for
+ * {@link Hudson#HUDSON_WORKSPACES_PROPERTY_KEY} value
*
* @return configured workspace root or "" if it is not set
*/
@@ -1873,8 +1859,8 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
}
/**
- * For binding {@link LogRecorderManager} to "/log".
- * Everything below here is admin-only, so do the check here.
+ * For binding {@link LogRecorderManager} to "/log". Everything below here
+ * is admin-only, so do the check here.
*/
public LogRecorderManager getLog() {
checkPermission(ADMINISTER);
@@ -1882,8 +1868,8 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
}
/**
- * A convenience method to check if there's some security
- * restrictions in place.
+ * A convenience method to check if there's some security restrictions in
+ * place.
*/
@Exported
public boolean isUseSecurity() {
@@ -1891,8 +1877,8 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
}
/**
- * If true, all the POST requests to Hudson would have to have crumb in it to protect
- * Hudson from CSRF vulnerabilities.
+ * If true, all the POST requests to Hudson would have to have crumb in it
+ * to protect Hudson from CSRF vulnerabilities.
*/
@Exported
public boolean isUseCrumbs() {
@@ -1900,21 +1886,20 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
}
/**
- * Returns the constant that captures the three basic security modes
- * in Hudson.
+ * Returns the constant that captures the three basic security modes in
+ * Hudson.
*/
public SecurityMode getSecurity() {
return getSecurityManager().getSecurity();
}
/**
- * @return
- * never null.
+ * @return never null.
*/
public SecurityRealm getSecurityRealm() {
return getSecurityManager().getSecurityRealm();
}
-
+
public void setSecurityRealm(SecurityRealm securityRealm) {
getSecurityManager().setSecurityRealm(securityRealm);
}
@@ -1924,13 +1909,13 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
}
/**
- * Returns {@link ExtensionList} that retains the discovered instances for the given extension type.
+ * Returns {@link ExtensionList} that retains the discovered instances for
+ * the given extension type.
*
- * @param extensionType
- * The base type that represents the extension point. Normally {@link ExtensionPoint} subtype
- * but that's not a hard requirement.
- * @return
- * Can be an empty list but never null.
+ * @param extensionType The base type that represents the extension point.
+ * Normally {@link ExtensionPoint} subtype but that's not a hard
+ * requirement.
+ * @return Can be an empty list but never null.
*/
@SuppressWarnings({"unchecked"})
public <T> ExtensionList<T> getExtensionList(Class<T> extensionType) {
@@ -1947,11 +1932,10 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
}
/**
- * Returns {@link ExtensionList} that retains the discovered {@link Descriptor} instances for the given
- * kind of {@link Describable}.
+ * Returns {@link ExtensionList} that retains the discovered
+ * {@link Descriptor} instances for the given kind of {@link Describable}.
*
- * @return
- * Can be an empty list but never null.
+ * @return Can be an empty list but never null.
*/
@SuppressWarnings({"unchecked"})
public <T extends Describable<T>, D extends Descriptor<T>> DescriptorExtensionList<T, D> getDescriptorList(Class<T> type) {
@@ -1969,30 +1953,28 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
}
/**
- * @return
- * never null.
+ * @return never null.
*/
public AuthorizationStrategy getAuthorizationStrategy() {
return getSecurityManager().getAuthorizationStrategy();
}
-
+
public void setAuthorizationStrategy(AuthorizationStrategy authorizationStrategy) {
- getSecurityManager().setAuthorizationStrategy(authorizationStrategy);
+ getSecurityManager().setAuthorizationStrategy(authorizationStrategy);
}
/**
- * Returns true if Hudson is quieting down.
- * <p>
- * No further jobs will be executed unless it
- * can be finished while other current pending builds
- * are still in progress.
+ * Returns true if Hudson is quieting down. <p> No further jobs will be
+ * executed unless it can be finished while other current pending builds are
+ * still in progress.
*/
public boolean isQuietingDown() {
return isQuietingDown;
}
/**
- * Returns true if the container initiated the termination of the web application.
+ * Returns true if the container initiated the termination of the web
+ * application.
*/
public boolean isTerminating() {
return terminating;
@@ -2001,9 +1983,8 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
/**
* Gets the initialization milestone that we've already reached.
*
- * @return
- * {@link InitMilestone#STARTED} even if the initialization hasn't been started, so that this method
- * never returns null.
+ * @return {@link InitMilestone#STARTED} even if the initialization hasn't
+ * been started, so that this method never returns null.
*/
public InitMilestone getInitLevel() {
return initLevel;
@@ -2015,17 +1996,16 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
}
/**
- * @deprecated
- * Left only for the compatibility of URLs.
- * Should not be invoked for any other purpose.
+ * @deprecated Left only for the compatibility of URLs. Should not be
+ * invoked for any other purpose.
*/
public TopLevelItem getJob(String name) {
return getItem(name);
}
/**
- * @deprecated
- * Used only for mapping jobs to URL in a case-insensitive fashion.
+ * @deprecated Used only for mapping jobs to URL in a case-insensitive
+ * fashion.
*/
public TopLevelItem getJobCaseInsensitive(String name) {
String match = Functions.toEmailSafeString(name);
@@ -2060,13 +2040,11 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
}
/**
- * Gets the {@link Item} object by its full name.
- * Full names are like path names, where each name of {@link Item} is
- * combined by '/'.
+ * Gets the {@link Item} object by its full name. Full names are like path
+ * names, where each name of {@link Item} is combined by '/'.
*
- * @return
- * null if either such {@link Item} doesn't exist under the given full name,
- * or it exists but it's no an instance of the given type.
+ * @return null if either such {@link Item} doesn't exist under the given
+ * full name, or it exists but it's no an instance of the given type.
*/
public <T extends Item> T getItemByFullName(String fullName, Class<T> type) {
StringTokenizer tokens = new StringTokenizer(fullName, "/");
@@ -2099,8 +2077,8 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
/**
* Gets the user of the given name.
*
- * @return
- * This method returns a non-null object for any user name, without validation.
+ * @return This method returns a non-null object for any user name, without
+ * validation.
*/
public User getUser(String name) {
return User.get(name, false);
@@ -2109,8 +2087,8 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
/**
* Creates a new job.
*
- * @throws IllegalArgumentException
- * if the project of the given name already exists.
+ * @throws IllegalArgumentException if the project of the given name already
+ * exists.
*/
public synchronized TopLevelItem createProject(TopLevelItemDescriptor type, String name) throws IOException {
return createProject(type, name, true);
@@ -2118,11 +2096,12 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
/**
* Creates a new job.
+ *
* @param type Descriptor for job type
* @param name Name for job
* @param notify Whether to fire onCreated method for all ItemListeners
- * @throws IllegalArgumentException
- * if a project of the give name already exists.
+ * @throws IllegalArgumentException if a project of the give name already
+ * exists.
*/
public synchronized TopLevelItem createProject(TopLevelItemDescriptor type, String name, boolean notify) throws IOException {
return itemGroupMixIn.createProject(type, name, notify);
@@ -2131,8 +2110,8 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
/**
* Overwrites the existing item by new one.
*
- * <p>
- * This is a short cut for deleting an existing job and adding a new one.
+ * <p> This is a short cut for deleting an existing job and adding a new
+ * one.
*/
public synchronized void putItem(TopLevelItem item) throws IOException, InterruptedException {
String name = item.getName();
@@ -2151,11 +2130,11 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
/**
* Creates a new job.
*
- * <p>
- * This version infers the descriptor from the type of the top-level item.
+ * <p> This version infers the descriptor from the type of the top-level
+ * item.
*
- * @throws IllegalArgumentException
- * if the project of the given name already exists.
+ * @throws IllegalArgumentException if the project of the given name already
+ * exists.
*/
public synchronized <T extends TopLevelItem> T createProject(Class<T> type, String name) throws IOException {
return type.cast(createProject((TopLevelItemDescriptor) getDescriptor(type), name));
@@ -2176,7 +2155,8 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
}
/**
- * Called in response to {@link Job#doDoDelete(StaplerRequest, StaplerResponse)}
+ * Called in response to
+ * {@link Job#doDoDelete(StaplerRequest, StaplerResponse)}
*/
public void onDeleted(TopLevelItem item) throws IOException {
for (ItemListener l : ItemListener.all()) {
@@ -2205,8 +2185,7 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
}
/**
- * Gets a {@link Fingerprint} object if it exists.
- * Otherwise null.
+ * Gets a {@link Fingerprint} object if it exists. Otherwise null.
*/
public Fingerprint _getFingerprint(String md5sum) throws IOException {
return fingerprintMap.get(md5sum);
@@ -2249,7 +2228,6 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
throw new IOException("Unable to create " + projectsDir + "\nPermission issue? Please create this directory manually.");
}
File[] subdirs = projectsDir.listFiles(new FileFilter() {
-
public boolean accept(File child) {
return child.isDirectory() && Items.getConfigFile(child).exists();
}
@@ -2257,7 +2235,6 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
TaskGraphBuilder g = new TaskGraphBuilder();
Handle loadHudson = g.requires(EXTENSIONS_AUGMENTED).attains(JOB_LOADED).add("Loading global config", new Executable() {
-
public void run(Reactor session) throws Exception {
XmlFile cfg = getConfigFile();
if (cfg.exists()) {
@@ -2282,7 +2259,6 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
for (final File subdir : subdirs) {
g.requires(loadHudson).attains(JOB_LOADED).notFatal().add("Loading job " + subdir.getName(), new Executable() {
-
public void run(Reactor session) throws Exception {
TopLevelItem item = (TopLevelItem) Items.load(Hudson.this, subdir);
items.put(item.getName(), item);
@@ -2291,7 +2267,6 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
}
g.requires(JOB_LOADED).add("Finalizing set up", new Executable() {
-
public void run(Reactor session) throws Exception {
rebuildDependencyGraph();
@@ -2576,8 +2551,7 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
}
/**
- * @deprecated as of 1.317
- * Use {@link #doQuietDown()} instead.
+ * @deprecated as of 1.317 Use {@link #doQuietDown()} instead.
*/
public synchronized void doQuietDown(StaplerResponse rsp) throws IOException, ServletException {
doQuietDown().generateResponse(null, rsp, this);
@@ -2632,8 +2606,9 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
}
/**
- * Creates a new job from its configuration XML. The type of the job created will be determined by
- * what's in this XML.
+ * Creates a new job from its configuration XML. The type of the job created
+ * will be determined by what's in this XML.
+ *
* @since 1.319
*/
public TopLevelItem createProjectFromXML(String name, InputStream xml) throws IOException {
@@ -2642,6 +2617,7 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
/**
* Reload a project to update its definition.
+ *
* @since 2.x.x
*/
public TopLevelItem reloadProjectFromDisk(File jobDir) throws IOException {
@@ -2654,12 +2630,9 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
/**
* Copys a job.
*
- * @param src
- * A {@link TopLevelItem} to be copied.
- * @param name
- * Name of the newly created project.
- * @return
- * Newly created {@link TopLevelItem}.
+ * @param src A {@link TopLevelItem} to be copied.
+ * @param name Name of the newly created project.
+ * @return Newly created {@link TopLevelItem}.
*/
@SuppressWarnings({"unchecked"})
public <T extends TopLevelItem> T copy(T src, String name) throws IOException {
@@ -2678,11 +2651,9 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
}
/**
- * Check if the given name is suitable as a name
- * for job, view, etc.
+ * Check if the given name is suitable as a name for job, view, etc.
*
- * @throws ParseException
- * if the given name is not good
+ * @throws ParseException if the given name is not good
*/
public static void checkGoodName(String name) throws Failure {
if (name == null || name.length() == 0) {
@@ -2704,6 +2675,7 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
/**
* Makes sure that the given name is good as a job name.
+ *
* @return trimmed name if valid; throws ParseException if not
*/
private String checkJobName(String name) throws Failure {
@@ -2798,8 +2770,7 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
/**
* RSS feed for log entries.
*
- * @deprecated
- * As on 1.267, moved to "/log/rss..."
+ * @deprecated As on 1.267, moved to "/log/rss..."
*/
public void doLogRss(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
String qs = req.getQueryString();
@@ -2814,10 +2785,9 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
checkPermission(ADMINISTER);
// engage "loading ..." UI and then run the actual task in a separate thread
- WebAppController.get().install( new HudsonIsLoading());
+ WebAppController.get().install(new HudsonIsLoading());
new Thread("Hudson config reload thread") {
-
@Override
public void run() {
try {
@@ -2843,7 +2813,7 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
executeReactor(null, loadTasks());
User.reload();
initLevel = InitMilestone.COMPLETED;
- WebAppController.get().install( this);
+ WebAppController.get().install(this);
}
/**
@@ -2882,8 +2852,8 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
}
/**
- * Simulates OutOfMemoryError.
- * Useful to make sure OutOfMemoryHeapDump setting.
+ * Simulates OutOfMemoryError. Useful to make sure OutOfMemoryHeapDump
+ * setting.
*/
public void doSimulateOutOfMemory() throws IOException {
checkPermission(ADMINISTER);
@@ -2916,7 +2886,6 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
FullDuplexHttpChannel server;
if (req.getHeader("Side").equals("download")) {
duplexChannels.put(uuid, server = new FullDuplexHttpChannel(uuid, !hasPermission(ADMINISTER)) {
-
protected void main(Channel channel) throws IOException, InterruptedException {
// capture the identity given by the transport, since this can be useful for SecurityRealm.createCliAuthenticator()
channel.setProperty(CLICommand.TRANSPORT_AUTHENTICATION, getAuthentication());
@@ -2962,7 +2931,8 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
}
/**
- * Queues up a restart of Hudson for when there are no builds running, if we can.
+ * Queues up a restart of Hudson for when there are no builds running, if we
+ * can.
*
* This first replaces "app" to {@link HudsonIsRestarting}
*
@@ -2990,10 +2960,9 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
public void restart() throws RestartNotSupportedException {
final Lifecycle lifecycle = Lifecycle.get();
lifecycle.verifyRestartable(); // verify that Hudson is restartable
- WebAppController.get().install( new HudsonIsRestarting());
+ WebAppController.get().install(new HudsonIsRestarting());
new Thread("restart thread") {
-
final String exitUser = getAuthentication().getName();
@Override
@@ -3018,7 +2987,9 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
}
/**
- * Queues up a restart to be performed once there are no builds currently running.
+ * Queues up a restart to be performed once there are no builds currently
+ * running.
+ *
* @since 1.332
*/
public void safeRestart() throws RestartNotSupportedException {
@@ -3028,7 +2999,6 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
isQuietingDown = true;
new Thread("safe-restart thread") {
-
final String exitUser = getAuthentication().getName();
@Override
@@ -3064,6 +3034,7 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
/**
* Shutdown the system.
+ *
* @since 1.161
*/
public void doExit(StaplerRequest req, StaplerResponse rsp) throws IOException {
@@ -3081,6 +3052,7 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
/**
* Shutdown the system safely.
+ *
* @since 1.332
*/
public void doSafeExit(StaplerRequest req, StaplerResponse rsp) throws IOException {
@@ -3094,7 +3066,6 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
final String exitUser = getAuthentication().getName();
final String exitAddr = req.getRemoteAddr().toString();
new Thread("safe-exit thread") {
-
@Override
public void run() {
try {
@@ -3119,15 +3090,16 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
}
/**
- * @deprecated As of release 3.0.0, replaced by {@link HudsonSecurityManager#getAuthentication()}
+ * @deprecated As of release 3.0.0, replaced by
+ * {@link HudsonSecurityManager#getAuthentication()}
*/
- @Deprecated public static Authentication getAuthentication() {
+ @Deprecated
+ public static Authentication getAuthentication() {
return HudsonSecurityManager.getAuthentication();
}
/**
- * For system diagnostics.
- * Run arbitrary Dynamic Language script.
+ * For system diagnostics. Run arbitrary Dynamic Language script.
*/
public void doScript(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
doScript(req, rsp, req.getView(this, "_script.jelly"));
@@ -3143,7 +3115,7 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
private void doScript(StaplerRequest req, StaplerResponse rsp, RequestDispatcher view) throws IOException, ServletException {
// ability to run arbitrary script is dangerous
checkPermission(ADMINISTER);
-
+
// if ("post".equals(req.getMethod().toLowerCase())) {
// JSONObject json = req.getSubmittedForm();
//
@@ -3151,16 +3123,16 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
// scriptSupport = req.bindJSON(ScriptSupport.class, json.getJSONObject("scriptSupport"));
// }
- String text = req.getParameter("script");
- if (text != null) {
- try {
- req.setAttribute("output",
- RemotingDiagnostics.executeScript(text, MasterComputer.localChannel, scriptSupport));
- } catch (InterruptedException e) {
- throw new ServletException(e);
- }
+ String text = req.getParameter("script");
+ if (text != null) {
+ try {
+ req.setAttribute("output",
+ RemotingDiagnostics.executeScript(text, MasterComputer.localChannel, scriptSupport));
+ } catch (InterruptedException e) {
+ throw new ServletException(e);
}
-
+ }
+
// }
view.forward(req, rsp);
@@ -3280,8 +3252,8 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
}
/**
- * @deprecated as of 1.294
- * Define your own check method, instead of relying on this generic one.
+ * @deprecated as of 1.294 Define your own check method, instead of relying
+ * on this generic one.
*/
public void doFieldCheck(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
doFieldCheck(
@@ -3292,17 +3264,17 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
}
/**
- * Checks if the value for a field is set; if not an error or warning text is displayed.
- * If the parameter "value" is not set then the parameter "errorText" is displayed
- * as an error text. If the parameter "errorText" is not set, then the parameter "warningText"
- * is displayed as a warning text.
- * <p>
- * If the text is set and the parameter "type" is set, it will validate that the value is of the
- * correct type. Supported types are "number, "number-positive" and "number-negative".
+ * Checks if the value for a field is set; if not an error or warning text
+ * is displayed. If the parameter "value" is not set then the parameter
+ * "errorText" is displayed as an error text. If the parameter "errorText"
+ * is not set, then the parameter "warningText" is displayed as a warning
+ * text. <p> If the text is set and the parameter "type" is set, it will
+ * validate that the value is of the correct type. Supported types are
+ * "number, "number-positive" and "number-negative".
*
- * @deprecated as of 1.324
- * Either use client-side validation (e.g. class="required number")
- * or define your own check method, instead of relying on this generic one.
+ * @deprecated as of 1.324 Either use client-side validation (e.g.
+ * class="required number") or define your own check method, instead of
+ * relying on this generic one.
*/
public FormValidation doFieldCheck(@QueryParameter(fixEmpty = true) String value,
@QueryParameter(fixEmpty = true) String type,
@@ -3340,12 +3312,10 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
}
/**
- * Serves static resources placed along with Jelly view files.
- * <p>
- * This method can serve a lot of files, so care needs to be taken
- * to make this method secure. It's not clear to me what's the best
- * strategy here, though the current implementation is based on
- * file extensions.
+ * Serves static resources placed along with Jelly view files. <p> This
+ * method can serve a lot of files, so care needs to be taken to make this
+ * method secure. It's not clear to me what's the best strategy here, though
+ * the current implementation is based on file extensions.
*/
public void doResources(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
String path = req.getRestOfPath();
@@ -3367,8 +3337,9 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
rsp.sendError(HttpServletResponse.SC_NOT_FOUND);
}
/**
- * Extension list that {@link #doResources(StaplerRequest, StaplerResponse)} can serve.
- * This set is mutable to allow plugins to add additional extensions.
+ * Extension list that {@link #doResources(StaplerRequest, StaplerResponse)}
+ * can serve. This set is mutable to allow plugins to add additional
+ * extensions.
*/
public static final Set<String> ALLOWED_RESOURCE_EXTENSIONS = new HashSet<String>(Arrays.asList(
"js|css|jpeg|jpg|png|gif|html|htm".split("\\|")));
@@ -3395,8 +3366,7 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
}
/**
- * @deprecated
- * Use {@link Functions#isWindows()}.
+ * @deprecated Use {@link Functions#isWindows()}.
*/
public static boolean isWindows() {
return File.pathSeparatorChar == ';';
@@ -3437,9 +3407,9 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
/**
* Gets the {@link Widget}s registered on this object.
*
- * <p>
- * Plugins who wish to contribute boxes on the side panel can add widgets
- * by {@code getWidgets().add(new MyWidget())} from {@link Plugin#start()}.
+ * <p> Plugins who wish to contribute boxes on the side panel can add
+ * widgets by {@code getWidgets().add(new MyWidget())} from
+ * {@link Plugin#start()}.
*/
public List<Widget> getWidgets() {
return widgets;
@@ -3575,7 +3545,8 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
return Futures.precomputed(null);
}
/**
- * {@link LocalChannel} instance that can be used to execute programs locally.
+ * {@link LocalChannel} instance that can be used to execute programs
+ * locally.
*/
public static final LocalChannel localChannel = new LocalChannel(threadPoolForRemoting);
}
@@ -3588,16 +3559,14 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
}
/**
- * @deprecated since 2007-12-18.
- * Use {@link #checkPermission(Permission)}
+ * @deprecated since 2007-12-18. Use {@link #checkPermission(Permission)}
*/
public static boolean adminCheck() throws IOException {
return adminCheck(Stapler.getCurrentRequest(), Stapler.getCurrentResponse());
}
/**
- * @deprecated since 2007-12-18.
- * Use {@link #checkPermission(Permission)}
+ * @deprecated since 2007-12-18. Use {@link #checkPermission(Permission)}
*/
public static boolean adminCheck(StaplerRequest req, StaplerResponse rsp) throws IOException {
if (isAdmin(req)) {
@@ -3609,31 +3578,29 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
}
/**
- * Checks if the current user (for which we are processing the current request)
- * has the admin access.
+ * Checks if the current user (for which we are processing the current
+ * request) has the admin access.
*
- * @deprecated since 2007-12-18.
- * This method is deprecated when Hudson moved from simple Unix root-like model
- * of "admin gets to do everything, and others don't have any privilege" to more
- * complex {@link ACL} and {@link Permission} based scheme.
+ * @deprecated since 2007-12-18. This method is deprecated when Hudson moved
+ * from simple Unix root-like model of "admin gets to do everything, and
+ * others don't have any privilege" to more complex {@link ACL} and
+ * {@link Permission} based scheme.
*
- * <p>
- * For a quick migration, use {@code Hudson.getInstance().getACL().hasPermission(Hudson.ADMINISTER)}
- * To check if the user has the 'administer' role in Hudson.
+ * <p> For a quick migration, use
+ * {@code Hudson.getInstance().getACL().hasPermission(Hudson.ADMINISTER)} To
+ * check if the user has the 'administer' role in Hudson.
*
- * <p>
- * But ideally, your plugin should first identify a suitable {@link Permission} (or create one,
- * if appropriate), then identify a suitable {@link AccessControlled} object to check its permission
- * against.
+ * <p> But ideally, your plugin should first identify a suitable
+ * {@link Permission} (or create one, if appropriate), then identify a
+ * suitable {@link AccessControlled} object to check its permission against.
*/
public static boolean isAdmin() {
return HudsonSecurityEntitiesHolder.getHudsonSecurityManager().getACL().hasPermission(ADMINISTER);
}
/**
- * @deprecated since 2007-12-18.
- * Define a custom {@link Permission} and check against ACL.
- * See {@link #isAdmin()} for more instructions.
+ * @deprecated since 2007-12-18. Define a custom {@link Permission} and
+ * check against ACL. See {@link #isAdmin()} for more instructions.
*/
public static boolean isAdmin(StaplerRequest req) {
return isAdmin();
@@ -3648,9 +3615,9 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
public static final XStream XSTREAM = new XStream2();
private static final int TWICE_CPU_NUM = Runtime.getRuntime().availableProcessors() * 2;
/**
- * Thread pool used to load configuration in parallel, to improve the start up time.
- * <p>
- * The idea here is to overlap the CPU and I/O, so we want more threads than CPU numbers.
+ * Thread pool used to load configuration in parallel, to improve the start
+ * up time. <p> The idea here is to overlap the CPU and I/O, so we want more
+ * threads than CPU numbers.
*/
/*package*/ transient final ExecutorService threadPoolForLoad = new ThreadPoolExecutor(
TWICE_CPU_NUM, TWICE_CPU_NUM,
@@ -3689,8 +3656,9 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
public static String VERSION = "?";
/**
- * Parses {@link #VERSION} into {@link VersionNumber}, or null if it's not parseable as a version number
- * (such as when Hudson is run with "mvn hudson-dev:run")
+ * Parses {@link #VERSION} into {@link VersionNumber}, or null if it's not
+ * parseable as a version number (such as when Hudson is run with "mvn
+ * hudson-dev:run")
*/
public static VersionNumber getVersion() {
try {
@@ -3719,18 +3687,16 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
public static String VERSION_HASH;
/**
* Prefix to static resources like images and javascripts in the war file.
- * Either "" or strings like "/static/VERSION", which avoids Hudson to pick up
- * stale cache when the user upgrades to a different version.
- * <p>
- * Value computed in {@link WebAppMain}.
+ * Either "" or strings like "/static/VERSION", which avoids Hudson to pick
+ * up stale cache when the user upgrades to a different version. <p> Value
+ * computed in {@link WebAppMain}.
*/
public static String RESOURCE_PATH = "";
/**
- * Prefix to resources alongside view scripts.
- * Strings like "/resources/VERSION", which avoids Hudson to pick up
- * stale cache when the user upgrades to a different version.
- * <p>
- * Value computed in {@link WebAppMain}.
+ * Prefix to resources alongside view scripts. Strings like
+ * "/resources/VERSION", which avoids Hudson to pick up stale cache when the
+ * user upgrades to a different version. <p> Value computed in
+ * {@link WebAppMain}.
*/
public static String VIEW_RESOURCE_PATH = "/resources/TBD";
public static boolean PARALLEL_LOAD = !"false".equals(System.getProperty(Hudson.class.getName() + ".parallelLoad"));
@@ -3738,13 +3704,15 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
public static boolean LOG_STARTUP_PERFORMANCE = Boolean.getBoolean(Hudson.class.getName() + ".logStartupPerformance");
private static final boolean CONSISTENT_HASH = true; // Boolean.getBoolean(Hudson.class.getName()+".consistentHash");
/**
- * Enabled by default as of 1.337. Will keep it for a while just in case we have some serious problems.
+ * Enabled by default as of 1.337. Will keep it for a while just in case we
+ * have some serious problems.
*/
public static boolean FLYWEIGHT_SUPPORT = !"false".equals(System.getProperty(Hudson.class.getName() + ".flyweightSupport"));
/**
- * Tentative switch to activate the concurrent build behavior.
- * When we merge this back to the trunk, this allows us to keep
- * this feature hidden for a while until we iron out the kinks.
+ * Tentative switch to activate the concurrent build behavior. When we merge
+ * this back to the trunk, this allows us to keep this feature hidden for a
+ * while until we iron out the kinks.
+ *
* @see AbstractProject#isConcurrentBuild()
*/
public static boolean CONCURRENT_BUILD = true;
@@ -3753,16 +3721,16 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
*/
private static final String WORKSPACE_DIRNAME = System.getProperty(Hudson.class.getName() + ".workspaceDirName", "workspace");
/**
- * Automatically try to launch a slave when Hudson is initialized or a new slave is created.
+ * Automatically try to launch a slave when Hudson is initialized or a new
+ * slave is created.
*/
public static boolean AUTOMATIC_SLAVE_LAUNCH = true;
private static final Pattern ICON_SIZE = Pattern.compile("\\d+x\\d+");
public static final PermissionGroup PERMISSIONS = Permission.HUDSON_PERMISSIONS;
public static final Permission ADMINISTER = Permission.HUDSON_ADMINISTER;
public static final Permission READ = new Permission(PERMISSIONS, "Read", Messages._Hudson_ReadPermission_Description(), Permission.READ);
-
public static final Authentication ANONYMOUS = HudsonSecurityManager.ANONYMOUS;
-
+
static {
XSTREAM.alias("hudson", Hudson.class);
XSTREAM.alias("slave", DumbSlave.class);
diff --git a/hudson-core/src/main/java/hudson/model/InvisibleAction.java b/hudson-core/src/main/java/hudson/model/InvisibleAction.java
index 5788315..3a87671 100644
--- a/hudson-core/src/main/java/hudson/model/InvisibleAction.java
+++ b/hudson-core/src/main/java/hudson/model/InvisibleAction.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
-*
-* Kohsuke Kawaguchi
- *
+ * Contributors:
+ *
+ * Kohsuke Kawaguchi
+ *
*
*******************************************************************************/
@@ -19,14 +19,14 @@ package hudson.model;
/**
* Partial {@link Action} implementation that doesn't have any UI presence.
*
- * <p>
- * This class can be used as a convenient base class, when you use
+ * <p> This class can be used as a convenient base class, when you use
* {@link Action} for just storing data associated with a build.
*
* @author Kohsuke Kawaguchi
* @since 1.188
*/
public abstract class InvisibleAction implements Action {
+
public final String getIconFileName() {
return null;
}
diff --git a/hudson-core/src/main/java/hudson/model/Item.java b/hudson-core/src/main/java/hudson/model/Item.java
index 49fb9ae..dc61234 100644
--- a/hudson-core/src/main/java/hudson/model/Item.java
+++ b/hudson-core/src/main/java/hudson/model/Item.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
-*
-* Kohsuke Kawaguchi, Yahoo! Inc.
- *
+ * Contributors:
+ *
+ * Kohsuke Kawaguchi, Yahoo! Inc.
+ *
*
*******************************************************************************/
@@ -30,32 +30,31 @@ import hudson.security.AccessControlled;
/**
* Basic configuration unit in Hudson.
*
- * <p>
- * Every {@link Item} is hosted in an {@link ItemGroup} called "parent",
- * and some {@link Item}s are {@link ItemGroup}s. This form a tree
- * structure, which is rooted at {@link Hudson}.
+ * <p> Every {@link Item} is hosted in an {@link ItemGroup} called "parent", and
+ * some {@link Item}s are {@link ItemGroup}s. This form a tree structure, which
+ * is rooted at {@link Hudson}.
*
- * <p>
- * Unlike file systems, where a file can be moved from one directory
- * to another, {@link Item} inherently belongs to a single {@link ItemGroup}
- * and that relationship will not change.
- * Think of
- * <a href="http://images.google.com/images?q=Windows%20device%20manager">Windows device manager</a>
- * &mdash; an HDD always show up under 'Disk drives' and it can never be moved to another parent.
+ * <p> Unlike file systems, where a file can be moved from one directory to
+ * another, {@link Item} inherently belongs to a single {@link ItemGroup} and
+ * that relationship will not change. Think of <a
+ * href="http://images.google.com/images?q=Windows%20device%20manager">Windows
+ * device manager</a> &mdash; an HDD always show up under 'Disk drives' and it
+ * can never be moved to another parent.
*
- * Similarly, {@link ItemGroup} is not a generic container. Each subclass
- * of {@link ItemGroup} can usually only host a certain limited kinds of
+ * Similarly, {@link ItemGroup} is not a generic container. Each subclass of
+ * {@link ItemGroup} can usually only host a certain limited kinds of
* {@link Item}s.
*
- * <p>
- * {@link Item}s have unique {@link #getName() name}s that distinguish themselves
- * among their siblings uniquely. The names can be combined by '/' to form an
- * item full name, which uniquely identifies an {@link Item} inside the whole {@link Hudson}.
+ * <p> {@link Item}s have unique {@link #getName() name}s that distinguish
+ * themselves among their siblings uniquely. The names can be combined by '/' to
+ * form an item full name, which uniquely identifies an {@link Item} inside the
+ * whole {@link Hudson}.
*
* @author Kohsuke Kawaguchi
* @see Items
*/
public interface Item extends PersistenceRoot, SearchableModelObject, AccessControlled {
+
/**
* Gets the parent that contains this item.
*/
@@ -69,26 +68,23 @@ public interface Item extends PersistenceRoot, SearchableModelObject, AccessCont
/**
* Gets the name of the item.
*
- * <p>
- * The name must be unique among other {@link Item}s that belong
- * to the same parent.
+ * <p> The name must be unique among other {@link Item}s that belong to the
+ * same parent.
*
- * <p>
- * This name is also used for directory name, so it cannot contain
- * any character that's not allowed on the file system.
+ * <p> This name is also used for directory name, so it cannot contain any
+ * character that's not allowed on the file system.
*
- * @see #getFullName()
+ * @see #getFullName()
*/
String getName();
/**
* Gets the full name of this item, like "abc/def/ghi".
*
- * <p>
- * Full name consists of {@link #getName() name}s of {@link Item}s
- * that lead from the root {@link Hudson} to this {@link Item},
- * separated by '/'. This is the unique name that identifies this
- * {@link Item} inside the whole {@link Hudson}.
+ * <p> Full name consists of {@link #getName() name}s of {@link Item}s that
+ * lead from the root {@link Hudson} to this {@link Item}, separated by '/'.
+ * This is the unique name that identifies this {@link Item} inside the
+ * whole {@link Hudson}.
*
* @see Hudson#getItemByFullName(String,Class)
*/
@@ -97,92 +93,84 @@ public interface Item extends PersistenceRoot, SearchableModelObject, AccessCont
/**
* Gets the human readable short name of this item.
*
- * <p>
- * This method should try to return a short concise human
- * readable string that describes this item.
- * The string need not be unique.
+ * <p> This method should try to return a short concise human readable
+ * string that describes this item. The string need not be unique.
*
- * <p>
- * The returned string should not include the display names
- * of {@link #getParent() ancestor items}.
+ * <p> The returned string should not include the display names of
+ * {@link #getParent() ancestor items}.
*/
String getDisplayName();
/**
- * Works like {@link #getDisplayName()} but return
- * the full path that includes all the display names
- * of the ancestors.
+ * Works like {@link #getDisplayName()} but return the full path that
+ * includes all the display names of the ancestors.
*/
String getFullDisplayName();
/**
- * Returns the URL of this item relative to the context root of the application.
+ * Returns the URL of this item relative to the context root of the
+ * application.
*
* @see AbstractItem#getUrl() for how to implement this.
*
- * @return
- * URL that ends with '/'.
+ * @return URL that ends with '/'.
*/
String getUrl();
/**
* Returns the URL of this item relative to the parent {@link ItemGroup}.
+ *
* @see AbstractItem#getShortUrl() for how to implement this.
*
- * @return
- * URL that ends with '/'.
+ * @return URL that ends with '/'.
*/
String getShortUrl();
/**
* Returns the absolute URL of this item. This relies on the current
- * {@link StaplerRequest} to figure out what the host name is,
- * so can be used only during processing client requests.
+ * {@link StaplerRequest} to figure out what the host name is, so can be
+ * used only during processing client requests.
*
- * @return
- * absolute URL.
- * @throws IllegalStateException
- * if the method is invoked outside the HTTP request processing.
+ * @return absolute URL.
+ * @throws IllegalStateException if the method is invoked outside the HTTP
+ * request processing.
*
- * @deprecated
- * This method shall <b>NEVER</b> be used during HTML page rendering, as it won't work with
- * network set up like Apache reverse proxy.
- * This method is only intended for the remote API clients who cannot resolve relative references
- * (even this won't work for the same reason, which should be fixed.)
+ * @deprecated This method shall <b>NEVER</b> be used during HTML page
+ * rendering, as it won't work with network set up like Apache reverse
+ * proxy. This method is only intended for the remote API clients who cannot
+ * resolve relative references (even this won't work for the same reason,
+ * which should be fixed.)
*/
String getAbsoluteUrl();
/**
- * Called right after when a {@link Item} is loaded from disk.
- * This is an opporunity to do a post load processing.
+ * Called right after when a {@link Item} is loaded from disk. This is an
+ * opporunity to do a post load processing.
*
- * @param name
- * Name of the directory (not a path --- just the name portion) from
- * which the configuration was loaded. This usually becomes the
- * {@link #getName() name} of this item.
+ * @param name Name of the directory (not a path --- just the name portion)
+ * from which the configuration was loaded. This usually becomes the
+ * {@link #getName() name} of this item.
*/
void onLoad(ItemGroup<? extends Item> parent, String name) throws IOException;
/**
- * When a {@link Item} is copied from existing one,
- * the files are first copied on the file system,
- * then it will be loaded, then this method will be invoked
- * to perform any implementation-specific work.
+ * When a {@link Item} is copied from existing one, the files are first
+ * copied on the file system, then it will be loaded, then this method will
+ * be invoked to perform any implementation-specific work.
*/
void onCopiedFrom(Item src);
/**
- * When an item is created from scratch (instead of copied),
- * this method will be invoked. Used as the post-construction initialization.
- */
+ * When an item is created from scratch (instead of copied), this method
+ * will be invoked. Used as the post-construction initialization.
+ */
void onCreatedFromScratch();
/**
* Save the settings to a file.
*
- * Use {@link Items#getConfigFile(Item)}
- * or {@link AbstractItem#getConfigFile()} to obtain the file
- * to save the data.
+ * Use {@link Items#getConfigFile(Item)} or
+ * {@link AbstractItem#getConfigFile()} to obtain the file to save the data.
*/
public void save() throws IOException;
@@ -190,15 +178,14 @@ public interface Item extends PersistenceRoot, SearchableModelObject, AccessCont
* Deletes this item.
*/
public void delete() throws IOException, InterruptedException;
-
- public static final PermissionGroup PERMISSIONS = new PermissionGroup(Item.class,Messages._Item_Permissions_Title());
+ public static final PermissionGroup PERMISSIONS = new PermissionGroup(Item.class, Messages._Item_Permissions_Title());
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 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);
public static final Permission WIPEOUT = new Permission(PERMISSIONS, "WipeOut", Messages._AbstractProject_WipeOutPermission_Description(), null, Functions
- .isWipeOutPermissionEnabled());
+ .isWipeOutPermissionEnabled());
}
diff --git a/hudson-core/src/main/java/hudson/model/ItemGroup.java b/hudson-core/src/main/java/hudson/model/ItemGroup.java
index 88b1807..f55506d 100644
--- a/hudson-core/src/main/java/hudson/model/ItemGroup.java
+++ b/hudson-core/src/main/java/hudson/model/ItemGroup.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
-*
-* Kohsuke Kawaguchi
- *
+ * Contributors:
+ *
+ * Kohsuke Kawaguchi
+ *
*
*******************************************************************************/
@@ -27,15 +27,16 @@ import java.io.File;
* @see ItemGroupMixIn
*/
public interface ItemGroup<T extends Item> extends PersistenceRoot, ModelObject {
+
/**
* Gets the full name of this {@link ItemGroup}.
*
- * @see Item#getFullName()
+ * @see Item#getFullName()
*/
String getFullName();
/**
- * @see Item#getFullDisplayName()
+ * @see Item#getFullDisplayName()
*/
String getFullDisplayName();
@@ -45,14 +46,14 @@ public interface ItemGroup<T extends Item> extends PersistenceRoot, ModelObject
Collection<T> getItems();
/**
- * Returns the path relative to the context root,
- * like "foo/bar/zot/". Note no leading slash but trailing slash.
+ * Returns the path relative to the context root, like "foo/bar/zot/". Note
+ * no leading slash but trailing slash.
*/
String getUrl();
/**
- * Gets the URL token that prefixes the URLs for child {@link Item}s.
- * Like "job", "item", etc.
+ * Gets the URL token that prefixes the URLs for child {@link Item}s. Like
+ * "job", "item", etc.
*/
String getUrlChildPrefix();
diff --git a/hudson-core/src/main/java/hudson/model/ItemGroupMixIn.java b/hudson-core/src/main/java/hudson/model/ItemGroupMixIn.java
index 513fd8a..1ad4e24 100644
--- a/hudson-core/src/main/java/hudson/model/ItemGroupMixIn.java
+++ b/hudson-core/src/main/java/hudson/model/ItemGroupMixIn.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
-*
-* Kohsuke Kawaguchi, CloudBees, Inc.
- *
+ * Contributors:
+ *
+ * Kohsuke Kawaguchi, CloudBees, Inc.
+ *
*
*******************************************************************************/
@@ -34,12 +34,14 @@ import java.io.InputStream;
import java.util.Map;
/**
- * Defines a bunch of static methods to be used as a "mix-in" for {@link ItemGroup}
- * implementations. Not meant for a consumption from outside {@link ItemGroup}s.
+ * Defines a bunch of static methods to be used as a "mix-in" for
+ * {@link ItemGroup} implementations. Not meant for a consumption from outside
+ * {@link ItemGroup}s.
*
* @author Kohsuke Kawaguchi
*/
public abstract class ItemGroupMixIn {
+
/**
* {@link ItemGroup} for which we are working.
*/
@@ -52,9 +54,8 @@ public abstract class ItemGroupMixIn {
}
/*
- * Callback methods to be implemented by the ItemGroup implementation.
- */
-
+ * Callback methods to be implemented by the ItemGroup implementation.
+ */
/**
* Adds a newly created item to the parent.
*/
@@ -66,17 +67,16 @@ public abstract class ItemGroupMixIn {
protected abstract File getRootDirFor(String name);
-/*
- * The rest is the methods that provide meat.
- */
-
+ /*
+ * The rest is the methods that provide meat.
+ */
/**
* Loads all the child {@link Item}s.
*
- * @param modulesDir
- * Directory that contains sub-directories for each child item.
+ * @param modulesDir Directory that contains sub-directories for each child
+ * item.
*/
- public static <K,V extends Item> Map<K,V> loadChildren(ItemGroup parent, File modulesDir, Function1<? extends K,? super V> key) {
+ public static <K, V extends Item> Map<K, V> loadChildren(ItemGroup parent, File modulesDir, Function1<? extends K, ? super V> key) {
modulesDir.mkdirs(); // make sure it exists
File[] subdirs = modulesDir.listFiles(new FileFilter() {
@@ -84,10 +84,10 @@ public abstract class ItemGroupMixIn {
return child.isDirectory();
}
});
- CopyOnWriteMap.Tree<K,V> configurations = new CopyOnWriteMap.Tree<K,V>();
+ CopyOnWriteMap.Tree<K, V> configurations = new CopyOnWriteMap.Tree<K, V>();
for (File subdir : subdirs) {
try {
- V item = (V) Items.load(parent,subdir);
+ V item = (V) Items.load(parent, subdir);
configurations.put(key.call(item), item);
} catch (IOException e) {
e.printStackTrace(); // TODO: logging
@@ -96,69 +96,75 @@ public abstract class ItemGroupMixIn {
return configurations;
}
-
/**
* {@link Item} -> name function.
*/
- public static final Function1<String,Item> KEYED_BY_NAME = new Function1<String, Item>() {
+ public static final Function1<String, Item> KEYED_BY_NAME = new Function1<String, Item>() {
public String call(Item item) {
return item.getName();
}
};
/**
- * Creates a {@link TopLevelItem} from the submission of the '/lib/hudson/newFromList/formList'
- * or throws an exception if it fails.
+ * Creates a {@link TopLevelItem} from the submission of the
+ * '/lib/hudson/newFromList/formList' or throws an exception if it fails.
*/
- public synchronized TopLevelItem createTopLevelItem( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException {
+ public synchronized TopLevelItem createTopLevelItem(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
acl.checkPermission(Job.CREATE);
TopLevelItem result;
String requestContentType = req.getContentType();
- if(requestContentType==null)
+ if (requestContentType == null) {
throw new Failure("No Content-Type header set");
+ }
boolean isXmlSubmission = requestContentType.startsWith("application/xml") || requestContentType.startsWith("text/xml");
String name = req.getParameter("name");
- if(name==null)
+ if (name == null) {
throw new Failure("Query parameter 'name' is required");
+ }
{// check if the name looks good
Hudson.checkGoodName(name);
name = name.trim();
- if(parent.getItem(name)!=null)
+ if (parent.getItem(name) != null) {
throw new Failure(Messages.Hudson_JobAlreadyExists(name));
+ }
}
String mode = req.getParameter("mode");
- if(mode!=null && mode.equals("copy")) {
+ if (mode != null && mode.equals("copy")) {
String from = req.getParameter("from");
// resolve a name to Item
Item src = parent.getItem(from);
- if (src==null)
+ if (src == null) {
src = Hudson.getInstance().getItemByFullName(from);
+ }
- if(src==null) {
- if(Util.fixEmpty(from)==null)
+ if (src == null) {
+ if (Util.fixEmpty(from) == null) {
throw new Failure("Specify which job to copy");
- else
- throw new Failure("No such job: "+from);
+ } else {
+ throw new Failure("No such job: " + from);
+ }
+ }
+ if (!(src instanceof TopLevelItem)) {
+ throw new Failure(from + " cannot be copied");
}
- if (!(src instanceof TopLevelItem))
- throw new Failure(from+" cannot be copied");
- result = copy((TopLevelItem) src,name);
+ result = copy((TopLevelItem) src, name);
} else {
- if(isXmlSubmission) {
+ if (isXmlSubmission) {
result = createProjectFromXML(name, req.getInputStream());
rsp.setStatus(HttpServletResponse.SC_OK);
return result;
} else {
- if(mode==null)
+ if (mode == null) {
throw new Failure("No mode given");
+ }
// create empty job and redirect to the project config screen
result = createProject(Items.getDescriptor(mode), name, true);
@@ -170,33 +176,36 @@ public abstract class ItemGroupMixIn {
}
/**
- * Computes the redirection target URL for the newly created {@link TopLevelItem}.
+ * Computes the redirection target URL for the newly created
+ * {@link TopLevelItem}.
*/
protected String redirectAfterCreateItem(StaplerRequest req, TopLevelItem result) throws IOException {
- return req.getContextPath()+'/'+result.getUrl()+"configure";
+ return req.getContextPath() + '/' + result.getUrl() + "configure";
}
/**
* Copies an existing {@link TopLevelItem} to a new name.
*
- * The caller is responsible for calling {@link ItemListener#fireOnCopied(Item, Item)}. This method
- * cannot do that because it doesn't know how to make the newly added item reachable from the parent.
+ * The caller is responsible for calling
+ * {@link ItemListener#fireOnCopied(Item, Item)}. This method cannot do that
+ * because it doesn't know how to make the newly added item reachable from
+ * the parent.
*/
@SuppressWarnings({"unchecked"})
public synchronized <T extends TopLevelItem> T copy(T src, String name) throws IOException {
acl.checkPermission(Job.CREATE);
- T result = (T)createProject(src.getDescriptor(),name,false);
+ T result = (T) createProject(src.getDescriptor(), name, false);
// copy config
- Util.copyFile(Items.getConfigFile(src).getFile(),Items.getConfigFile(result).getFile());
+ Util.copyFile(Items.getConfigFile(src).getFile(), Items.getConfigFile(result).getFile());
// reload from the new config
- result = (T)Items.load(parent,result.getRootDir());
+ result = (T) Items.load(parent, result.getRootDir());
result.onCopiedFrom(src);
add(result);
- ItemListener.fireOnCopied(src,result);
+ ItemListener.fireOnCopied(src, result);
return result;
}
@@ -208,10 +217,10 @@ public abstract class ItemGroupMixIn {
File configXml = Items.getConfigFile(getRootDirFor(name)).getFile();
configXml.getParentFile().mkdirs();
try {
- IOUtils.copy(xml,configXml);
+ IOUtils.copy(xml, configXml);
// load it
- TopLevelItem result = (TopLevelItem)Items.load(parent,configXml.getParentFile());
+ TopLevelItem result = (TopLevelItem) Items.load(parent, configXml.getParentFile());
add(result);
ItemListener.fireOnCreated(result);
@@ -225,16 +234,17 @@ public abstract class ItemGroupMixIn {
}
}
- public synchronized TopLevelItem createProject( TopLevelItemDescriptor type, String name, boolean notify )
+ public synchronized TopLevelItem createProject(TopLevelItemDescriptor type, String name, boolean notify)
throws IOException {
acl.checkPermission(Job.CREATE);
- if(parent.getItem(name)!=null)
- throw new IllegalArgumentException("Project of the name "+name+" already exists");
+ if (parent.getItem(name) != null) {
+ throw new IllegalArgumentException("Project of the name " + name + " already exists");
+ }
TopLevelItem item;
try {
- item = type.newInstance(parent,name);
+ item = type.newInstance(parent, name);
} catch (Exception e) {
throw new IllegalArgumentException(e);
}
@@ -242,8 +252,9 @@ public abstract class ItemGroupMixIn {
item.save();
add(item);
- if (notify)
+ if (notify) {
ItemListener.fireOnCreated(item);
+ }
return item;
}
diff --git a/hudson-core/src/main/java/hudson/model/Items.java b/hudson-core/src/main/java/hudson/model/Items.java
index 9c6eb53..d9c119a 100644
--- a/hudson-core/src/main/java/hudson/model/Items.java
+++ b/hudson-core/src/main/java/hudson/model/Items.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
-*
-* Kohsuke Kawaguchi
- *
+ * Contributors:
+ *
+ * Kohsuke Kawaguchi
+ *
*
*******************************************************************************/
@@ -47,27 +47,28 @@ import org.eclipse.hudson.model.project.property.TriggerProjectProperty;
/**
* Convenience methods related to {@link Item}.
- *
+ *
* @author Kohsuke Kawaguchi
*/
public class Items {
+
/**
* List of all installed {@link TopLevelItem} types.
*
- * @deprecated as of 1.286
- * Use {@link #all()} for read access and {@link Extension} for registration.
+ * @deprecated as of 1.286 Use {@link #all()} for read access and
+ * {@link Extension} for registration.
*/
- public static final List<TopLevelItemDescriptor> LIST = (List)new DescriptorList<TopLevelItem>(TopLevelItem.class);
+ public static final List<TopLevelItemDescriptor> LIST = (List) new DescriptorList<TopLevelItem>(TopLevelItem.class);
/**
* Returns all the registered {@link TopLevelItemDescriptor}s.
*/
- public static DescriptorExtensionList<TopLevelItem,TopLevelItemDescriptor> all() {
- return Hudson.getInstance().<TopLevelItem,TopLevelItemDescriptor>getDescriptorList(TopLevelItem.class);
+ public static DescriptorExtensionList<TopLevelItem, TopLevelItemDescriptor> all() {
+ return Hudson.getInstance().<TopLevelItem, TopLevelItemDescriptor>getDescriptorList(TopLevelItem.class);
}
public static TopLevelItemDescriptor getDescriptor(String fqcn) {
- return Descriptor.find(all(),fqcn);
+ return Descriptor.find(all(), fqcn);
}
/**
@@ -76,8 +77,9 @@ public class Items {
public static String toNameList(Collection<? extends Item> items) {
StringBuilder buf = new StringBuilder();
for (Item item : items) {
- if(buf.length()>0)
+ if (buf.length() > 0) {
buf.append(", ");
+ }
buf.append(item.getFullName());
}
return buf.toString();
@@ -90,12 +92,13 @@ public class Items {
Hudson hudson = Hudson.getInstance();
List<T> r = new ArrayList<T>();
- StringTokenizer tokens = new StringTokenizer(list,",");
- while(tokens.hasMoreTokens()) {
+ StringTokenizer tokens = new StringTokenizer(list, ",");
+ while (tokens.hasMoreTokens()) {
String fullName = tokens.nextToken().trim();
- T item = hudson.getItemByFullName(fullName,type);
- if(item!=null)
+ T item = hudson.getItemByFullName(fullName, type);
+ if (item != null) {
r.add(item);
+ }
}
return r;
}
@@ -103,12 +106,12 @@ public class Items {
/**
* Loads a {@link Item} from a config file.
*
- * @param dir
- * The directory that contains the config file, not the config file itself.
+ * @param dir The directory that contains the config file, not the config
+ * file itself.
*/
public static Item load(ItemGroup parent, File dir) throws IOException {
- Item item = (Item)getConfigFile(dir).read();
- item.onLoad(parent,dir.getName());
+ Item item = (Item) getConfigFile(dir).read();
+ item.onLoad(parent, dir.getName());
return item;
}
@@ -116,7 +119,7 @@ public class Items {
* The file we save our configuration.
*/
public static XmlFile getConfigFile(File dir) {
- return new XmlFile(XSTREAM,new File(dir,"config.xml"));
+ return new XmlFile(XSTREAM, new File(dir, "config.xml"));
}
/**
@@ -125,20 +128,19 @@ public class Items {
public static XmlFile getConfigFile(Item item) {
return getConfigFile(item.getRootDir());
}
-
/**
* Used to load/save job configuration.
*
- * When you extend {@link Job} in a plugin, try to put the alias so
- * that it produces a reasonable XML.
+ * When you extend {@link Job} in a plugin, try to put the alias so that it
+ * produces a reasonable XML.
*/
public static final XStream XSTREAM = new XStream2();
static {
- XSTREAM.alias("project",FreeStyleProject.class);
- XSTREAM.alias("matrix-project",MatrixProject.class);
+ XSTREAM.alias("project", FreeStyleProject.class);
+ XSTREAM.alias("matrix-project", MatrixProject.class);
XSTREAM.alias("axis", Axis.class);
- XSTREAM.alias("matrix-config",MatrixConfiguration.class);
+ XSTREAM.alias("matrix-config", MatrixConfiguration.class);
//aliases for project properties.
//TODO: think about migrating to xstream's annotations.
diff --git a/hudson-core/src/main/java/hudson/model/JDK.java b/hudson-core/src/main/java/hudson/model/JDK.java
index 94f8935..4b861f2 100644
--- a/hudson-core/src/main/java/hudson/model/JDK.java
+++ b/hudson-core/src/main/java/hudson/model/JDK.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
*
* Kohsuke Kawaguchi
- *
+ *
*
*******************************************************************************/
@@ -45,6 +45,7 @@ import org.kohsuke.stapler.QueryParameter;
* @author Kohsuke Kawaguchi
*/
public final class JDK extends ToolInstallation implements NodeSpecific<JDK>, EnvironmentSpecific<JDK> {
+
/**
* @deprecated since 2009-02-25
*/
@@ -63,8 +64,7 @@ public final class JDK extends ToolInstallation implements NodeSpecific<JDK>, En
/**
* install directory.
*
- * @deprecated as of 1.304
- * Use {@link #getHome()}
+ * @deprecated as of 1.304 Use {@link #getHome()}
*/
public String getJavaHome() {
return getHome();
@@ -74,14 +74,15 @@ public final class JDK extends ToolInstallation implements NodeSpecific<JDK>, En
* Gets the path to the bin directory.
*/
public File getBinDir() {
- return new File(getHome(),"bin");
+ return new File(getHome(), "bin");
}
+
/**
* Gets the path to 'java'.
*/
public File getExecutable() {
String execName = (File.separatorChar == '\\') ? "java.exe" : "java";
- return new File(getHome(),"bin/"+execName);
+ return new File(getHome(), "bin/" + execName);
}
/**
@@ -94,10 +95,10 @@ public final class JDK extends ToolInstallation implements NodeSpecific<JDK>, En
/**
* Sets PATH and JAVA_HOME from this JDK.
*/
- public void buildEnvVars(Map<String,String> env) {
+ public void buildEnvVars(Map<String, String> env) {
// see EnvVars javadoc for why this adss PATH.
- env.put("PATH+JDK",getHome()+"/bin");
- env.put("JAVA_HOME",getHome());
+ env.put("PATH+JDK", getHome() + "/bin");
+ env.put("JAVA_HOME", getHome());
}
public JDK forNode(Node node, TaskListener log) throws IOException, InterruptedException {
@@ -111,15 +112,14 @@ public final class JDK extends ToolInstallation implements NodeSpecific<JDK>, En
/**
* Checks if "java" is in PATH on the given node.
*
- * <p>
- * If it's not, then the user must specify a configured JDK,
- * so this is often useful for form field validation.
+ * <p> If it's not, then the user must specify a configured JDK, so this is
+ * often useful for form field validation.
*/
public static boolean isDefaultJDKValid(Node n) {
try {
TaskListener listener = new StreamTaskListener(new NullStream());
Launcher launcher = n.createLauncher(listener);
- return launcher.launch().cmds("java","-fullversion").stdout(listener).join()==0;
+ return launcher.launch().cmds("java", "-fullversion").stdout(listener).join() == 0;
} catch (IOException e) {
return false;
} catch (InterruptedException e) {
@@ -149,7 +149,7 @@ public final class JDK extends ToolInstallation implements NodeSpecific<JDK>, En
@Override
public List<JDKInstaller> getDefaultInstallers() {
- return Collections.singletonList(new JDKInstaller(null,false));
+ return Collections.singletonList(new JDKInstaller(null, false));
}
/**
@@ -159,16 +159,19 @@ public final class JDK extends ToolInstallation implements NodeSpecific<JDK>, En
// this can be used to check the existence of a file on the server, so needs to be protected
Hudson.getInstance().checkPermission(Hudson.ADMINISTER);
- if(value.getPath().equals(""))
+ if (value.getPath().equals("")) {
return FormValidation.ok();
+ }
- if(!value.isDirectory())
+ if (!value.isDirectory()) {
return FormValidation.error(Messages.Hudson_NotADirectory(value));
+ }
- File toolsJar = new File(value,"lib/tools.jar");
- File mac = new File(value,"lib/dt.jar");
- if(!toolsJar.exists() && !mac.exists())
+ File toolsJar = new File(value, "lib/tools.jar");
+ File mac = new File(value, "lib/dt.jar");
+ if (!toolsJar.exists() && !mac.exists()) {
return FormValidation.error(Messages.Hudson_NotJDKDir(value));
+ }
return FormValidation.ok();
}
@@ -179,9 +182,14 @@ public final class JDK extends ToolInstallation implements NodeSpecific<JDK>, En
}
public static class ConverterImpl extends ToolConverter {
- public ConverterImpl(XStream2 xstream) { super(xstream); }
- @Override protected String oldHomeField(ToolInstallation obj) {
- return ((JDK)obj).javaHome;
+
+ public ConverterImpl(XStream2 xstream) {
+ super(xstream);
+ }
+
+ @Override
+ protected String oldHomeField(ToolInstallation obj) {
+ return ((JDK) obj).javaHome;
}
}
}
diff --git a/hudson-core/src/main/java/hudson/model/Job.java b/hudson-core/src/main/java/hudson/model/Job.java
index a57c166..5e960f5 100644
--- a/hudson-core/src/main/java/hudson/model/Job.java
+++ b/hudson-core/src/main/java/hudson/model/Job.java
@@ -7,11 +7,11 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
*
* Kohsuke Kawaguchi, Winston Prakash, Martin Eigenbrodt, Matthew R. Harrah,
* Stephen Connolly, Tom Huybrechts, Anton Kozak, Nikita Levyankov
- *
+ *
*******************************************************************************/
package hudson.model;
@@ -70,7 +70,7 @@ import java.util.Set;
import java.util.SortedMap;
import javax.servlet.ServletException;
import net.sf.json.JSONException;
-
+
import net.sf.json.JSONObject;
import org.eclipse.hudson.api.model.ICascadingJob;
@@ -97,47 +97,42 @@ import org.eclipse.hudson.security.HudsonSecurityEntitiesHolder;
/**
* A job is an runnable entity under the monitoring of Hudson.
*
- * <p>
- * Every time it "runs", it will be recorded as a {@link Run} object.
+ * <p> Every time it "runs", it will be recorded as a {@link Run} object.
*
- * <p>
- * To create a custom job type, extend {@link TopLevelItemDescriptor} and put {@link Extension} on it.
+ * <p> To create a custom job type, extend {@link TopLevelItemDescriptor} and
+ * put {@link Extension} on it.
*
* @author Kohsuke Kawaguchi
* @author Nikita Levyankov
*/
public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, RunT>>
extends AbstractItem implements ExtensionPoint, StaplerOverridable, IJob, ICascadingJob {
+
private static transient final String HUDSON_BUILDS_PROPERTY_KEY = "HUDSON_BUILDS";
private static transient final String PROJECT_PROPERTY_KEY_PREFIX = "has";
public static final String PROPERTY_NAME_SEPARATOR = ";";
public static final String LOG_ROTATOR_PROPERTY_NAME = "logRotator";
public static final String PARAMETERS_DEFINITION_JOB_PROPERTY_PROPERTY_NAME = "parametersDefinitionProperties";
-
/**
* Next build number. Kept in a separate file because this is the only
* information that gets updated often. This allows the rest of the
- * configuration to be in the VCS.
- * <p>
- * In 1.28 and earlier, this field was stored in the project configuration
- * file, so even though this is marked as transient, don't move it around.
+ * configuration to be in the VCS. <p> In 1.28 and earlier, this field was
+ * stored in the project configuration file, so even though this is marked
+ * as transient, don't move it around.
*/
protected transient volatile int nextBuildNumber = 1;
/**
- * Newly copied jobs get this flag set, so that Hudson doesn't try to run the job until its configuration
- * is saved once.
+ * Newly copied jobs get this flag set, so that Hudson doesn't try to run
+ * the job until its configuration is saved once.
*/
private transient volatile boolean holdOffBuildUntilSave;
-
/**
- * @deprecated as of 2.2.0
- * don't use this field directly, logic was moved to {@link org.eclipse.hudson.api.model.IProjectProperty}.
- * Use getter/setter for accessing to this field.
+ * @deprecated as of 2.2.0 don't use this field directly, logic was moved to
+ * {@link org.eclipse.hudson.api.model.IProjectProperty}. Use getter/setter
+ * for accessing to this field.
*/
private volatile LogRotator logRotator;
-
private ConcurrentMap<String, IProjectProperty> jobProperties = new ConcurrentHashMap<String, IProjectProperty>();
-
/**
* Not all plugins are good at calculating their health report quickly.
* These fields are used to cache the health reports to speed up rendering
@@ -150,47 +145,44 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
* The author of the job;
*/
protected volatile String createdBy;
-
/**
* The time when the job was created;
*/
private volatile long creationTime;
-
/**
- * List of {@link UserProperty}s configured for this project.
- * According to new implementation {@link hudson.model.ParametersDefinitionProperty} were moved from this collection. So, this
- * field was left protected for backward compatibility. Don't use this field directly for adding or removing
- * values. Use {@link #addProperty(JobProperty)}, {@link #removeProperty(JobProperty)},
+ * List of {@link UserProperty}s configured for this project. According to
+ * new implementation {@link hudson.model.ParametersDefinitionProperty} were
+ * moved from this collection. So, this field was left protected for
+ * backward compatibility. Don't use this field directly for adding or
+ * removing values. Use {@link #addProperty(JobProperty)}, {@link #removeProperty(JobProperty)},
* {@link #removeProperty(Class)} instead.
*
* @since 2.2.0
*/
protected CopyOnWriteList<JobProperty<? super JobT>> properties = new CopyOnWriteList<JobProperty<? super JobT>>();
-
/**
* The name of the cascadingProject.
*/
String cascadingProjectName;
-
/**
- * The list with the names of children cascading projects. Required to avoid cyclic references and
- * to prohibition parent project "delete" action in case it has cascading children projects.
+ * The list with the names of children cascading projects. Required to avoid
+ * cyclic references and to prohibition parent project "delete" action in
+ * case it has cascading children projects.
*/
private Set<String> cascadingChildrenNames = new CopyOnWriteArraySet<String>();
-
/**
- * Set contains json-save names of cascadable {@link JobProperty} classes. Intended to be used for cascading support
- * of external hudson plugins, that extends {@link JobProperty} class.
- * See {@link #properties} field description
+ * Set contains json-save names of cascadable {@link JobProperty} classes.
+ * Intended to be used for cascading support of external hudson plugins,
+ * that extends {@link JobProperty} class. See {@link #properties} field
+ * description
+ *
* @since 2.2.0
*/
private Set<String> cascadingJobProperties = new CopyOnWriteArraySet<String>();
-
/**
* Selected cascadingProject for this job.
*/
protected transient JobT cascadingProject;
-
private transient ThreadLocal<Boolean> allowSave = new ThreadLocal<Boolean>() {
@Override
protected Boolean initialValue() {
@@ -223,7 +215,6 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
super(parent, name);
}
-
/**
* {@inheritDoc}
*/
@@ -244,7 +235,7 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
/**
* {@inheritDoc}
*/
- public void removeProjectProperty(String key){
+ public void removeProjectProperty(String key) {
jobProperties.remove(key);
}
@@ -252,10 +243,11 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
* Put map of job properties to existing ones.
*
* @param projectProperties new properties map.
- * @param replace true - to replace current properties, false - add to existing map
+ * @param replace true - to replace current properties, false - add to
+ * existing map
*/
protected void putAllProjectProperties(Map<String, ? extends IProjectProperty> projectProperties,
- boolean replace) {
+ boolean replace) {
if (null != projectProperties) {
if (replace) {
jobProperties.clear();
@@ -267,7 +259,7 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
/**
* {@inheritDoc}
*/
- public IProjectProperty getProperty(String key){
+ public IProjectProperty getProperty(String key) {
return CascadingUtil.getProjectProperty(this, key);
}
@@ -321,7 +313,7 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
@Override
public synchronized void save() throws IOException {
if (null == allowSave) {
- initAllowSave();
+ initAllowSave();
}
if (isAllowSave()) {
super.save();
@@ -335,7 +327,7 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
throws IOException {
super.onLoad(parent, name);
cascadingProject = (JobT) Functions.getItemByName(Hudson.getInstance().getAllItems(this.getClass()),
- cascadingProjectName);
+ cascadingProjectName);
initAllowSave();
TextFile f = getNextBuildNumberFile();
if (f.exists()) {
@@ -356,10 +348,12 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
}
if (properties == null) // didn't exist < 1.72
+ {
properties = new CopyOnWriteList<JobProperty<? super JobT>>();
+ }
- if(cascadingChildrenNames == null){
- cascadingChildrenNames = new CopyOnWriteArraySet<String>();
+ if (cascadingChildrenNames == null) {
+ cascadingChildrenNames = new CopyOnWriteArraySet<String>();
}
buildProjectProperties();
for (JobProperty p : getAllProperties()) {
@@ -370,8 +364,8 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
/**
* Resets overridden properties to the values defined in parent.
*
- * @param propertyName the name of the properties. It possible to pass several names
- * separated with {@link #PROPERTY_NAME_SEPARATOR}.
+ * @param propertyName the name of the properties. It possible to pass
+ * several names separated with {@link #PROPERTY_NAME_SEPARATOR}.
* @throws java.io.IOException exception.
*/
public void doResetProjectProperty(@QueryParameter final String propertyName) throws IOException {
@@ -395,8 +389,9 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
}
/**
- * Initializes and builds project properties. Also converts legacy properties to IProjectProperties.
- * Subclasses should inherit and override this behavior.
+ * Initializes and builds project properties. Also converts legacy
+ * properties to IProjectProperties. Subclasses should inherit and override
+ * this behavior.
*
* @throws IOException if any.
*/
@@ -451,7 +446,6 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
}
}
-
/**
* Initialize project properties if null.
*/
@@ -469,7 +463,7 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
this.holdOffBuildUntilSave = true;
this.creationTime = new GregorianCalendar().getTimeInMillis();
User user = User.current();
- if (user != null){
+ if (user != null) {
this.createdBy = user.getId();
grantProjectMatrixPermissions(user);
}
@@ -615,7 +609,6 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
CascadingUtil.getLogRotatorProjectProperty(this, LOG_ROTATOR_PROPERTY_NAME).setValue(logRotator);
}
-
/**
* {@inheritDoc}
*/
@@ -632,13 +625,15 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
public boolean supportsLogRotator() {
return true;
}
+
/**
* Method converts JobProperties to cascading values.
* <p/>
* If property is {@link AuthorizationMatrixProperty} - it will be skipped.
- * If property is {@link ParametersDefinitionProperty} - it will be added to list of parameterDefinition properties.
- * All the rest properties will be converted to {@link BaseProjectProperty} classes and added
- * to cascadingJobProperties set.
+ * If property is {@link ParametersDefinitionProperty} - it will be added to
+ * list of parameterDefinition properties. All the rest properties will be
+ * converted to {@link BaseProjectProperty} classes and added to
+ * cascadingJobProperties set.
*
* @param properties list of {@link JobProperty}
*/
@@ -654,7 +649,7 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
continue;
}
BaseProjectProperty projectProperty = CascadingUtil.getBaseProjectProperty(this,
- property.getDescriptor().getJsonSafeClassName());
+ property.getDescriptor().getJsonSafeClassName());
addCascadingJobProperty(projectProperty);
}
if (null == getProperty(PARAMETERS_DEFINITION_JOB_PROPERTY_PROPERTY_NAME)) {
@@ -663,8 +658,9 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
}
/**
- * @return list of cascading {@link JobProperty} instances. Includes {@link ParametersDefinitionProperty} and
- * children of {@link JobProperty} from external plugins.
+ * @return list of cascading {@link JobProperty} instances. Includes
+ * {@link ParametersDefinitionProperty} and children of {@link JobProperty}
+ * from external plugins.
*/
@SuppressWarnings("unchecked")
private CopyOnWriteList getCascadingJobProperties() {
@@ -686,28 +682,29 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
}
/**
- * Sets list of {@link ParametersDefinitionProperty}. Supports cascading functionality.
+ * Sets list of {@link ParametersDefinitionProperty}. Supports cascading
+ * functionality.
*
* @param properties properties to set.
*/
private void setParameterDefinitionProperties(CopyOnWriteList<ParametersDefinitionProperty> properties) {
CascadingUtil.setParameterDefinitionProperties(this, PARAMETERS_DEFINITION_JOB_PROPERTY_PROPERTY_NAME,
- properties);
+ properties);
}
/**
- * @return list of {@link ParametersDefinitionProperty}. Supports cascading functionality.
+ * @return list of {@link ParametersDefinitionProperty}. Supports cascading
+ * functionality.
*/
@SuppressWarnings("unchecked")
private CopyOnWriteList<ParametersDefinitionProperty> getParameterDefinitionProperties() {
return CascadingUtil.getCopyOnWriteListProjectProperty(this, PARAMETERS_DEFINITION_JOB_PROPERTY_PROPERTY_NAME)
- .getValue();
+ .getValue();
}
@Override
protected SearchIndexBuilder makeSearchIndex() {
return super.makeSearchIndex().add(new SearchIndex() {
-
public void find(String token, List<SearchItem> result) {
try {
if (token.startsWith("#")) {
@@ -747,13 +744,13 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
properties.add(jobProp);
} else if (jobProperty instanceof ParametersDefinitionProperty) {
CopyOnWriteList list = CascadingUtil.getCopyOnWriteListProjectProperty(this,
- PARAMETERS_DEFINITION_JOB_PROPERTY_PROPERTY_NAME).getOriginalValue();
+ PARAMETERS_DEFINITION_JOB_PROPERTY_PROPERTY_NAME).getOriginalValue();
if (null != list) {
list.add(jobProp);
}
} else {
BaseProjectProperty projectProperty = CascadingUtil.getBaseProjectProperty(this,
- jobProperty.getDescriptor().getJsonSafeClassName());
+ jobProperty.getDescriptor().getJsonSafeClassName());
projectProperty.setValue(jobProperty);
addCascadingJobProperty(projectProperty);
}
@@ -772,7 +769,7 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
properties.remove(jobProp);
} else if (jobProperty instanceof ParametersDefinitionProperty) {
CopyOnWriteList list = CascadingUtil.getCopyOnWriteListProjectProperty(this,
- PARAMETERS_DEFINITION_JOB_PROPERTY_PROPERTY_NAME).getOriginalValue();
+ PARAMETERS_DEFINITION_JOB_PROPERTY_PROPERTY_NAME).getOriginalValue();
if (null != list) {
list.remove(jobProp);
}
@@ -793,7 +790,7 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
CopyOnWriteList<JobProperty<? super JobT>> sourceProperties;
if (clazz.equals(ParametersDefinitionProperty.class)) {
sourceProperties = CascadingUtil.getCopyOnWriteListProjectProperty(this,
- PARAMETERS_DEFINITION_JOB_PROPERTY_PROPERTY_NAME).getOriginalValue();
+ PARAMETERS_DEFINITION_JOB_PROPERTY_PROPERTY_NAME).getOriginalValue();
} else if (clazz.equals(AuthorizationMatrixProperty.class)) {
sourceProperties = properties;
} else {
@@ -821,6 +818,7 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
/**
* List of all {@link JobProperty} exposed primarily for the remoting API.
* List contains cascadable {@link JobProperty} if any.
+ *
* @since 2.2.0
*/
@Exported(name = "property", inline = true)
@@ -836,8 +834,8 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
/**
* Gets the specific property, or null if the propert is not configured for
- * this job.
- * Supports cascading properties
+ * this job. Supports cascading properties