summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Lynggaard Hansen2012-07-19 14:36:51 (EDT)
committer Henrik Lynggaard Hansen2012-07-19 16:14:31 (EDT)
commitab9936c58622d403514fd5c2d465f810f0abc162 (patch)
tree4abe28dab352e901956f4eb3bb9450efb6018f64
parent69ba5185ed3612ec0de2c9bccd1d42eeb8fbc97c (diff)
downloadorg.eclipse.hudson.core-ab9936c58622d403514fd5c2d465f810f0abc162.zip
org.eclipse.hudson.core-ab9936c58622d403514fd5c2d465f810f0abc162.tar.gz
org.eclipse.hudson.core-ab9936c58622d403514fd5c2d465f810f0abc162.tar.bz2
Last of the reformat patchesrefs/changes/75/6875/1
- Reformat test utils maven module - Reformat cli maven module - Reformat few files in core which wasn't caught the first time - Reformat classes in hudson util maven module For whitespace there should now only be a few instances here and there. There is still a bunch of files which has like one or two errors, but whitespace and formatting is no longer the predominant error in sonar. This is intended as the catch the last patch before M4 hardening begins Change-Id: I9e9d5fabd1a3340e3819ec6edb84ecb6cff8152c Signed-off-by: Henrik Lynggaard Hansen <henrik@hlyh.dk>
-rw-r--r--hudson-cli/src/main/java/hudson/cli/CLI.java74
-rw-r--r--hudson-cli/src/main/java/hudson/cli/CliEntryPoint.java15
-rw-r--r--hudson-cli/src/main/java/hudson/cli/FullDuplexHttpStream.java67
-rw-r--r--hudson-cli/src/main/java/hudson/cli/SequenceOutputStream.java32
-rw-r--r--hudson-core/src/main/java/hudson/FilePath.java18
-rw-r--r--hudson-core/src/main/java/hudson/console/AnnotatedLargeText.java76
-rw-r--r--hudson-core/src/main/java/hudson/console/ConsoleAnnotationDescriptor.java30
-rw-r--r--hudson-core/src/main/java/hudson/console/ConsoleAnnotationOutputStream.java80
-rw-r--r--hudson-core/src/main/java/hudson/console/ConsoleAnnotator.java101
-rw-r--r--hudson-core/src/main/java/hudson/console/ConsoleAnnotatorFactory.java88
-rw-r--r--hudson-core/src/main/java/hudson/console/ConsoleNote.java207
-rw-r--r--hudson-core/src/main/java/hudson/console/ExpandableDetailsNote.java18
-rw-r--r--hudson-core/src/main/java/hudson/console/HudsonExceptionNote.java57
-rw-r--r--hudson-core/src/main/java/hudson/console/HyperlinkNote.java20
-rw-r--r--hudson-core/src/main/java/hudson/console/LineTransformationOutputStream.java55
-rw-r--r--hudson-core/src/main/java/hudson/console/PlainTextConsoleOutputStream.java23
-rw-r--r--hudson-core/src/main/java/hudson/console/UrlAnnotator.java23
-rw-r--r--hudson-core/src/main/java/hudson/matrix/MatrixProject.java10
-rw-r--r--hudson-core/src/main/java/hudson/model/AbstractBuild.java8
-rw-r--r--hudson-core/src/main/java/hudson/model/Hudson.java51
-rw-r--r--hudson-core/src/main/java/hudson/model/ItemGroupMixIn.java4
-rw-r--r--hudson-core/src/main/java/hudson/model/Run.java8
-rw-r--r--hudson-core/src/main/java/hudson/os/SU.java7
-rw-r--r--hudson-core/src/main/java/hudson/security/HudsonPrivateSecurityRealm.java4
-rw-r--r--hudson-core/src/main/java/hudson/util/FormFieldValidator.java8
-rw-r--r--hudson-core/src/main/java/hudson/util/Iterators.java6
-rw-r--r--hudson-jetty-war-executable/src/main/java/org/eclipse/hudson/jetty/JettyLauncher.java32
-rw-r--r--hudson-plugin-utils/src/main/java/org/hudsonci/utils/plugin/ui/RenderableEnum.java17
-rw-r--r--hudson-plugin-utils/src/main/java/org/hudsonci/utils/tasks/MetaProject.java66
-rw-r--r--hudson-plugin-utils/src/main/java/org/hudsonci/utils/tasks/OpenServerSocket.java31
-rw-r--r--hudson-plugin-utils/src/main/java/org/hudsonci/utils/tasks/OperationSupport.java19
-rw-r--r--hudson-plugin-utils/src/main/java/org/hudsonci/utils/tasks/PerformOperation.java19
-rw-r--r--hudson-plugin-utils/src/main/java/org/hudsonci/utils/tasks/UnsupportedProjectException.java31
-rw-r--r--hudson-service/src/main/java/org/hudsonci/events/EventConsumer.java10
-rw-r--r--hudson-service/src/main/java/org/hudsonci/events/EventPublisher.java10
-rw-r--r--hudson-service/src/main/java/org/hudsonci/events/internal/DiagnosticEventConsumer.java10
-rw-r--r--hudson-service/src/main/java/org/hudsonci/events/internal/EventPublisherImpl.java17
-rw-r--r--hudson-service/src/main/java/org/hudsonci/events/ready/ReadyDetector.java16
-rw-r--r--hudson-service/src/main/java/org/hudsonci/events/ready/ReadyDetectorStarter.java11
-rw-r--r--hudson-service/src/main/java/org/hudsonci/events/ready/ReadyEvent.java12
-rw-r--r--hudson-service/src/main/java/org/hudsonci/service/BuildNotFoundException.java7
-rw-r--r--hudson-service/src/main/java/org/hudsonci/service/BuildService.java31
-rw-r--r--hudson-service/src/main/java/org/hudsonci/service/DependencyGraphService.java7
-rw-r--r--hudson-service/src/main/java/org/hudsonci/service/DescriptorService.java7
-rw-r--r--hudson-service/src/main/java/org/hudsonci/service/NodeNotFoundException.java7
-rw-r--r--hudson-service/src/main/java/org/hudsonci/service/NodeService.java13
-rw-r--r--hudson-service/src/main/java/org/hudsonci/service/NotFoundException.java27
-rw-r--r--hudson-service/src/main/java/org/hudsonci/service/ProjectNotFoundException.java19
-rw-r--r--hudson-service/src/main/java/org/hudsonci/service/ProjectService.java112
-rw-r--r--hudson-service/src/main/java/org/hudsonci/service/QueueService.java13
-rw-r--r--hudson-service/src/main/java/org/hudsonci/service/ScriptService.java11
-rw-r--r--hudson-service/src/main/java/org/hudsonci/service/SecurityService.java23
-rw-r--r--hudson-service/src/main/java/org/hudsonci/service/ServiceRuntimeException.java16
-rw-r--r--hudson-service/src/main/java/org/hudsonci/service/SystemIntegrityViolationException.java14
-rw-r--r--hudson-service/src/main/java/org/hudsonci/service/SystemService.java26
-rw-r--r--hudson-service/src/main/java/org/hudsonci/service/internal/BuildServiceImpl.java16
-rw-r--r--hudson-service/src/main/java/org/hudsonci/service/internal/DependencyGraphServiceImpl.java7
-rw-r--r--hudson-service/src/main/java/org/hudsonci/service/internal/DescriptorServiceImpl.java8
-rw-r--r--hudson-service/src/main/java/org/hudsonci/service/internal/DummyStaplerRequest.java10
-rw-r--r--hudson-service/src/main/java/org/hudsonci/service/internal/DummyStaplerResponse.java24
-rw-r--r--hudson-service/src/main/java/org/hudsonci/service/internal/NodeServiceImpl.java7
-rw-r--r--hudson-service/src/main/java/org/hudsonci/service/internal/ProjectServiceImpl.java10
-rw-r--r--hudson-service/src/main/java/org/hudsonci/service/internal/QueueServiceImpl.java12
-rw-r--r--hudson-service/src/main/java/org/hudsonci/service/internal/ScriptServiceImpl.java12
-rw-r--r--hudson-service/src/main/java/org/hudsonci/service/internal/SecurityServiceImpl.java21
-rw-r--r--hudson-service/src/main/java/org/hudsonci/service/internal/ServicePreconditions.java21
-rw-r--r--hudson-service/src/main/java/org/hudsonci/service/internal/ServiceSupport.java26
-rw-r--r--hudson-service/src/main/java/org/hudsonci/service/internal/SystemServiceImpl.java107
-rw-r--r--hudson-service/src/main/java/org/hudsonci/service/internal/package-info.java19
-rw-r--r--hudson-service/src/main/java/org/hudsonci/service/package-info.java19
-rw-r--r--hudson-service/src/main/java/org/hudsonci/servlets/ServletContainer.java12
-rw-r--r--hudson-service/src/main/java/org/hudsonci/servlets/ServletContainerAware.java13
-rw-r--r--hudson-service/src/main/java/org/hudsonci/servlets/ServletRegistration.java37
-rw-r--r--hudson-service/src/main/java/org/hudsonci/servlets/internal/ServletContainerImpl.java23
-rw-r--r--hudson-service/src/main/java/org/hudsonci/servlets/internal/ServletContainerStarter.java15
-rw-r--r--hudson-service/src/main/java/org/hudsonci/servlets/internal/ServletRegistrationFilterAdapter.java32
-rw-r--r--hudson-test-framework/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java4
-rw-r--r--hudson-test-utils/src/main/java/org/hudsonci/utils/hamcrest/FileMatchers.java12
-rw-r--r--hudson-test-utils/src/main/java/org/hudsonci/utils/hamcrest/URLMatchers.java10
-rw-r--r--hudson-test-utils/src/main/java/org/hudsonci/utils/hamcrest/URLRespondsWithStatusMatcher.java28
-rw-r--r--hudson-test-utils/src/main/java/org/hudsonci/utils/junit/ext/URLIsReachable.java11
-rw-r--r--hudson-test-utils/src/main/java/org/hudsonci/utils/test/PropUtil.java23
-rw-r--r--hudson-test-utils/src/main/java/org/hudsonci/utils/test/TestUtil.java52
-rw-r--r--hudson-utils/src/main/java/org/hudsonci/utils/common/VersionFormatter.java50
-rw-r--r--hudson-utils/src/main/java/org/hudsonci/utils/common/VersionSupport.java28
-rw-r--r--hudson-utils/src/main/java/org/hudsonci/utils/event/EventHandlerSupport.java32
-rw-r--r--hudson-utils/src/main/java/org/hudsonci/utils/io/FileBeheader.java78
-rw-r--r--hudson-utils/src/main/java/org/hudsonci/utils/io/FileUtil.java50
-rw-r--r--hudson-utils/src/main/java/org/hudsonci/utils/marshal/xref/XReference.java32
-rw-r--r--hudson-utils/src/main/java/org/hudsonci/utils/marshal/xref/XReferenceConverter.java47
90 files changed, 1281 insertions, 1351 deletions
diff --git a/hudson-cli/src/main/java/hudson/cli/CLI.java b/hudson-cli/src/main/java/hudson/cli/CLI.java
index f22a40a..13476ac 100644
--- a/hudson-cli/src/main/java/hudson/cli/CLI.java
+++ b/hudson-cli/src/main/java/hudson/cli/CLI.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -43,48 +43,51 @@ import java.io.BufferedOutputStream;
/**
* CLI entry point to Hudson.
- *
+ *
* @author Kohsuke Kawaguchi
*/
public class CLI {
+
private final ExecutorService pool;
private final Channel channel;
private final CliEntryPoint entryPoint;
private final boolean ownsPool;
public CLI(URL hudson) throws IOException, InterruptedException {
- this(hudson,null);
+ this(hudson, null);
}
public CLI(URL hudson, ExecutorService exec) throws IOException, InterruptedException {
String url = hudson.toExternalForm();
- if(!url.endsWith("/")) url+='/';
+ if (!url.endsWith("/")) {
+ url += '/';
+ }
- ownsPool = exec==null;
- pool = exec!=null ? exec : Executors.newCachedThreadPool();
+ ownsPool = exec == null;
+ pool = exec != null ? exec : Executors.newCachedThreadPool();
int clip = getCliTcpPort(url);
- if(clip>=0) {
+ if (clip >= 0) {
// connect via CLI port
String host = new URL(url).getHost();
- LOGGER.fine("Trying to connect directly via TCP/IP to port "+clip+" of "+host);
- Socket s = new Socket(host,clip);
+ LOGGER.fine("Trying to connect directly via TCP/IP to port " + clip + " of " + host);
+ Socket s = new Socket(host, clip);
DataOutputStream dos = new DataOutputStream(s.getOutputStream());
dos.writeUTF("Protocol:CLI-connect");
- channel = new Channel("CLI connection to "+hudson, pool,
+ channel = new Channel("CLI connection to " + hudson, pool,
new BufferedInputStream(new SocketInputStream(s)),
new BufferedOutputStream(new SocketOutputStream(s)));
} else {
// connect via HTTP
- LOGGER.fine("Trying to connect to "+url+" via HTTP");
- url+="cli";
+ LOGGER.fine("Trying to connect to " + url + " via HTTP");
+ url += "cli";
hudson = new URL(url);
FullDuplexHttpStream con = new FullDuplexHttpStream(hudson);
- channel = new Channel("Chunked connection to "+hudson,
- pool,con.getInputStream(),con.getOutputStream());
- new PingThread(channel,30*1000) {
+ channel = new Channel("Chunked connection to " + hudson,
+ pool, con.getInputStream(), con.getOutputStream());
+ new PingThread(channel, 30 * 1000) {
protected void onDead() {
// noop. the point of ping is to keep the connection alive
// as most HTTP servers have a rather short read time out
@@ -93,10 +96,11 @@ public class CLI {
}
// execute the command
- entryPoint = (CliEntryPoint)channel.waitForRemoteProperty(CliEntryPoint.class.getName());
+ entryPoint = (CliEntryPoint) channel.waitForRemoteProperty(CliEntryPoint.class.getName());
- if(entryPoint.protocolVersion()!=CliEntryPoint.VERSION)
+ if (entryPoint.protocolVersion() != CliEntryPoint.VERSION) {
throw new IOException(Messages.CLI_VersionMismatch());
+ }
}
/**
@@ -107,29 +111,32 @@ public class CLI {
try {
head.connect();
} catch (IOException e) {
- throw (IOException)new IOException("Failed to connect to "+url).initCause(e);
+ throw (IOException) new IOException("Failed to connect to " + url).initCause(e);
}
String p = head.getHeaderField("X-Hudson-CLI-Port");
- if(p==null) return -1;
+ if (p == null) {
+ return -1;
+ }
return Integer.parseInt(p);
}
public void close() throws IOException, InterruptedException {
channel.close();
channel.join();
- if(ownsPool)
+ if (ownsPool) {
pool.shutdown();
+ }
}
public int execute(List<String> args, InputStream stdin, OutputStream stdout, OutputStream stderr) {
- return entryPoint.main(args,Locale.getDefault(),
+ return entryPoint.main(args, Locale.getDefault(),
new RemoteInputStream(stdin),
new RemoteOutputStream(stdout),
new RemoteOutputStream(stderr));
}
public int execute(List<String> args) {
- return execute(args,System.in,System.out,System.err);
+ return execute(args, System.in, System.out, System.err);
}
public int execute(String... args) {
@@ -148,24 +155,24 @@ public class CLI {
String url = System.getenv("HUDSON_URL");
- while(!args.isEmpty()) {
+ while (!args.isEmpty()) {
String head = args.get(0);
- if(head.equals("-s") && args.size()>=2) {
+ if (head.equals("-s") && args.size() >= 2) {
url = args.get(1);
- args = args.subList(2,args.size());
+ args = args.subList(2, args.size());
continue;
}
break;
}
-
- if(url==null) {
+
+ if (url == null) {
printUsageAndExit(Messages.CLI_NoURL());
return;
}
- if(args.isEmpty())
+ if (args.isEmpty()) {
args = Arrays.asList("help"); // default to help
-
+ }
CLI cli = new CLI(new URL(url));
try {
// execute the command
@@ -178,10 +185,11 @@ public class CLI {
}
private static void printUsageAndExit(String msg) {
- if(msg!=null) System.out.println(msg);
+ if (msg != null) {
+ System.out.println(msg);
+ }
System.err.println(Messages.CLI_Usage());
System.exit(-1);
}
-
private static final Logger LOGGER = Logger.getLogger(CLI.class.getName());
}
diff --git a/hudson-cli/src/main/java/hudson/cli/CliEntryPoint.java b/hudson-cli/src/main/java/hudson/cli/CliEntryPoint.java
index 7d5b620..80ee776 100644
--- a/hudson-cli/src/main/java/hudson/cli/CliEntryPoint.java
+++ b/hudson-cli/src/main/java/hudson/cli/CliEntryPoint.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -27,11 +27,11 @@ import java.util.Locale;
* @author Kohsuke Kawaguchi
*/
public interface CliEntryPoint {
+
/**
* Just like the static main method.
*
- * @param locale
- * Locale of this client.
+ * @param locale Locale of this client.
*/
int main(List<String> args, Locale locale, InputStream stdin, OutputStream stdout, OutputStream stderr);
@@ -41,10 +41,9 @@ public interface CliEntryPoint {
boolean hasCommand(String name);
/**
- * Returns {@link #VERSION}, so that the client and the server can detect version incompatibility
- * gracefully.
+ * Returns {@link #VERSION}, so that the client and the server can detect
+ * version incompatibility gracefully.
*/
int protocolVersion();
-
int VERSION = 1;
}
diff --git a/hudson-cli/src/main/java/hudson/cli/FullDuplexHttpStream.java b/hudson-cli/src/main/java/hudson/cli/FullDuplexHttpStream.java
index c3ecae8..8078314 100644
--- a/hudson-cli/src/main/java/hudson/cli/FullDuplexHttpStream.java
+++ b/hudson-cli/src/main/java/hudson/cli/FullDuplexHttpStream.java
@@ -8,7 +8,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- *
+ *
*
*******************************************************************************/
@@ -28,14 +28,15 @@ import java.util.logging.Logger;
import org.apache.commons.codec.binary.Base64;
/**
- * Creates a capacity-unlimited bi-directional {@link InputStream}/{@link OutputStream} pair over
- * HTTP, which is a request/response protocol.
+ * Creates a capacity-unlimited bi-directional
+ * {@link InputStream}/{@link OutputStream} pair over HTTP, which is a
+ * request/response protocol.
*
* @author Kohsuke Kawaguchi
*/
public class FullDuplexHttpStream {
- private final URL target;
+ private final URL target;
private final OutputStream output;
private final InputStream input;
@@ -51,8 +52,8 @@ public class FullDuplexHttpStream {
this.target = target;
String authorization = null;
- if (target.getUserInfo() != null) {
- authorization = new String(Base64.encodeBase64(target.getUserInfo().getBytes()));
+ if (target.getUserInfo() != null) {
+ authorization = new String(Base64.encodeBase64(target.getUserInfo().getBytes()));
}
CrumbData crumbData = new CrumbData();
@@ -64,77 +65,77 @@ public class FullDuplexHttpStream {
con.setDoOutput(true); // request POST to avoid caching
con.setRequestMethod("POST");
con.addRequestProperty("Session", uuid.toString());
- con.addRequestProperty("Side","download");
+ con.addRequestProperty("Side", "download");
if (authorization != null) {
con.addRequestProperty("Authorization", "Basic " + authorization);
}
- if(crumbData.isValid) {
+ if (crumbData.isValid) {
con.addRequestProperty(crumbData.crumbName, crumbData.crumb);
}
con.getOutputStream().close();
input = con.getInputStream();
// make sure we hit the right URL
- if(con.getHeaderField("Hudson-Duplex")==null)
- throw new IOException(target+" doesn't look like Hudson");
+ if (con.getHeaderField("Hudson-Duplex") == null) {
+ throw new IOException(target + " doesn't look like Hudson");
+ }
// client->server uses chunked encoded POST for unlimited capacity.
con = (HttpURLConnection) target.openConnection();
con.setDoOutput(true); // request POST
con.setRequestMethod("POST");
con.setChunkedStreamingMode(0);
- con.setRequestProperty("Content-type","application/octet-stream");
+ con.setRequestProperty("Content-type", "application/octet-stream");
con.addRequestProperty("Session", uuid.toString());
- con.addRequestProperty("Side","upload");
+ con.addRequestProperty("Side", "upload");
if (authorization != null) {
- con.addRequestProperty ("Authorization", "Basic " + authorization);
+ con.addRequestProperty("Authorization", "Basic " + authorization);
}
- if(crumbData.isValid) {
+ if (crumbData.isValid) {
con.addRequestProperty(crumbData.crumbName, crumbData.crumb);
}
output = con.getOutputStream();
}
-
static final int BLOCK_SIZE = 1024;
static final Logger LOGGER = Logger.getLogger(FullDuplexHttpStream.class.getName());
-
+
private final class CrumbData {
- String crumbName;
- String crumb;
- boolean isValid;
- private CrumbData() {
+ String crumbName;
+ String crumb;
+ boolean isValid;
+
+ private CrumbData() {
this.crumbName = "";
this.crumb = "";
this.isValid = false;
getData();
- }
+ }
- private void getData() {
+ private void getData() {
try {
String base = createCrumbUrlBase();
- crumbName = readData(base+"?xpath=/*/crumbRequestField/text()");
- crumb = readData(base+"?xpath=/*/crumb/text()");
+ crumbName = readData(base + "?xpath=/*/crumbRequestField/text()");
+ crumb = readData(base + "?xpath=/*/crumb/text()");
isValid = true;
- LOGGER.fine("Crumb data: "+crumbName+"="+crumb);
+ LOGGER.fine("Crumb data: " + crumbName + "=" + crumb);
} catch (IOException e) {
// presumably this Hudson doesn't use crumb
- LOGGER.log(Level.FINE,"Failed to get crumb data",e);
+ LOGGER.log(Level.FINE, "Failed to get crumb data", e);
}
- }
+ }
- private String createCrumbUrlBase() {
- String url = target.toExternalForm();
+ private String createCrumbUrlBase() {
+ String url = target.toExternalForm();
return new StringBuilder(url.substring(0, url.lastIndexOf("/cli"))).append("/crumbIssuer/api/xml/").toString();
- }
+ }
- private String readData(String dest) throws IOException {
+ private String readData(String dest) throws IOException {
HttpURLConnection con = (HttpURLConnection) new URL(dest).openConnection();
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(con.getInputStream()));
return reader.readLine();
- }
- finally {
+ } finally {
con.disconnect();
}
}
diff --git a/hudson-cli/src/main/java/hudson/cli/SequenceOutputStream.java b/hudson-cli/src/main/java/hudson/cli/SequenceOutputStream.java
index 94da896..98b44df 100644
--- a/hudson-cli/src/main/java/hudson/cli/SequenceOutputStream.java
+++ b/hudson-cli/src/main/java/hudson/cli/SequenceOutputStream.java
@@ -8,7 +8,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- *
+ *
*
*******************************************************************************/
@@ -21,12 +21,15 @@ import java.io.SequenceInputStream;
/**
* {@link OutputStream} version of {@link SequenceInputStream}.
*
- * Provides a single {@link OutputStream} view over multiple {@link OutputStream}s (each of the fixed length.)
+ * Provides a single {@link OutputStream} view over multiple
+ * {@link OutputStream}s (each of the fixed length.)
*
* @author Kohsuke Kawaguchi
*/
abstract class SequenceOutputStream extends OutputStream {
+
protected static class Block {
+
final OutputStream out;
long capacity;
@@ -35,7 +38,6 @@ abstract class SequenceOutputStream extends OutputStream {
this.capacity = capacity;
}
}
-
/**
* Current block being written.
*/
@@ -47,12 +49,12 @@ abstract class SequenceOutputStream extends OutputStream {
@Override
public void write(byte[] b, int off, int len) throws IOException {
- while(len>0) {
- int sz = (int)Math.min(len, block.capacity);
- block.out.write(b,off,sz);
- block.capacity -=sz;
- len-=sz;
- off+=sz;
+ while (len > 0) {
+ int sz = (int) Math.min(len, block.capacity);
+ block.out.write(b, off, sz);
+ block.capacity -= sz;
+ len -= sz;
+ off += sz;
swapIfNeeded();
}
}
@@ -64,9 +66,11 @@ abstract class SequenceOutputStream extends OutputStream {
}
private void swapIfNeeded() throws IOException {
- if(block.capacity >0) return;
+ if (block.capacity > 0) {
+ return;
+ }
block.out.close();
- block=next(block);
+ block = next(block);
}
@Override
@@ -77,12 +81,12 @@ abstract class SequenceOutputStream extends OutputStream {
@Override
public void close() throws IOException {
block.out.close();
- block=null;
+ block = null;
}
/**
- * Fetches the next {@link OutputStream} to write to,
- * along with their capacity.
+ * Fetches the next {@link OutputStream} to write to, along with their
+ * capacity.
*/
protected abstract Block next(Block current) throws IOException;
}
diff --git a/hudson-core/src/main/java/hudson/FilePath.java b/hudson-core/src/main/java/hudson/FilePath.java
index 692785a..1f14962 100644
--- a/hudson-core/src/main/java/hudson/FilePath.java
+++ b/hudson-core/src/main/java/hudson/FilePath.java
@@ -1602,7 +1602,7 @@ public final class FilePath implements Serializable {
readFromTar(remote + '/' + fileMask, new File(target.remote),
(remoteCompressionType != null ? remoteCompressionType.extract(pipe.getIn())
: FilePath.TarCompression.GZIP.extract(pipe.getIn())));
- } catch (IOException e) {// BuildException or IOException
+ } catch (IOException e) { // BuildException or IOException
try {
future.get(3, TimeUnit.SECONDS);
throw e; // the remote side completed successfully, so the error must be local
@@ -1678,8 +1678,8 @@ public final class FilePath implements Serializable {
IOUtils.copy(t, f);
f.setLastModified(te.getModTime().getTime());
int mode = te.getMode() & 0777;
- if (mode != 0 && !Functions.isWindows()) // be defensive
- {
+ // be defensive
+ if (mode != 0 && !Functions.isWindows()) {
Util.chmod(f, mode);
}
}
@@ -1754,7 +1754,7 @@ public final class FilePath implements Serializable {
// to this: (1) the user gave us aa/bb/cc/dd where cc/dd was correct
// and (2) the user gave us cc/dd where aa/bb/cc/dd was correct.
- {// check the (1) above first
+ { // check the (1) above first
String f = fileMask;
while (true) {
int idx = findSeparator(f);
@@ -1769,7 +1769,7 @@ public final class FilePath implements Serializable {
}
}
- {// check the (2) above next as this is more expensive.
+ { // check the (2) above next as this is more expensive.
// Try prepending "**/" to see if that results in a match
FileSet fs = Util.createFileSet(dir, "**/" + fileMask);
DirectoryScanner ds = fs.getDirectoryScanner(new Project());
@@ -1801,7 +1801,7 @@ public final class FilePath implements Serializable {
}
}
- {// finally, see if we can identify any sub portion that's valid. Otherwise bail out
+ { // finally, see if we can identify any sub portion that's valid. Otherwise bail out
String previous = null;
String pattern = fileMask;
@@ -1816,7 +1816,7 @@ public final class FilePath implements Serializable {
}
int idx = findSeparator(pattern);
- if (idx < 0) {// no more path component left to go back
+ if (idx < 0) { // no more path component left to go back
if (pattern.equals(fileMask)) {
return Messages.FilePath_validateAntFileMask_doesntMatchAnything(fileMask);
} else {
@@ -1893,8 +1893,8 @@ public final class FilePath implements Serializable {
}
try {
- if (!exists()) // no workspace. can't check
- {
+ // no workspace. can't check
+ if (!exists()) {
return FormValidation.ok();
}
diff --git a/hudson-core/src/main/java/hudson/console/AnnotatedLargeText.java b/hudson-core/src/main/java/hudson/console/AnnotatedLargeText.java
index a8fee67..2990f7c 100644
--- a/hudson-core/src/main/java/hudson/console/AnnotatedLargeText.java
+++ b/hudson-core/src/main/java/hudson/console/AnnotatedLargeText.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -48,23 +48,24 @@ import static java.lang.Math.abs;
import org.apache.commons.codec.binary.Base64;
/**
- * Extension to {@link LargeText} that handles annotations by {@link ConsoleAnnotator}.
+ * Extension to {@link LargeText} that handles annotations by
+ * {@link ConsoleAnnotator}.
*
- * <p>
- * In addition to run each line through {@link ConsoleAnnotationOutputStream} for adding markup,
- * this class persists {@link ConsoleAnnotator} into a byte sequence and send it to the client
- * as an HTTP header. The client JavaScript sends it back next time it fetches the following output.
+ * <p> In addition to run each line through
+ * {@link ConsoleAnnotationOutputStream} for adding markup, this class persists
+ * {@link ConsoleAnnotator} into a byte sequence and send it to the client as an
+ * HTTP header. The client JavaScript sends it back next time it fetches the
+ * following output.
*
- * <p>
- * The serialized {@link ConsoleAnnotator} is encrypted to avoid malicious clients from instantiating
- * arbitrary {@link ConsoleAnnotator}s.
+ * <p> The serialized {@link ConsoleAnnotator} is encrypted to avoid malicious
+ * clients from instantiating arbitrary {@link ConsoleAnnotator}s.
*
- * @param <T>
- * Context type.
+ * @param <T> Context type.
* @author Kohsuke Kawaguchi
* @since 1.349
*/
public class AnnotatedLargeText<T> extends LargeText {
+
/**
* Can be null.
*/
@@ -81,23 +82,24 @@ public class AnnotatedLargeText<T> extends LargeText {
}
public void doProgressiveHtml(StaplerRequest req, StaplerResponse rsp) throws IOException {
- req.setAttribute("html",true);
- doProgressText(req,rsp);
+ req.setAttribute("html", true);
+ doProgressText(req, rsp);
}
/**
* Aliasing what I think was a wrong name in {@link LargeText}
*/
public void doProgressiveText(StaplerRequest req, StaplerResponse rsp) throws IOException {
- doProgressText(req,rsp);
+ doProgressText(req, rsp);
}
/**
- * For reusing code between text/html and text/plain, we run them both through the same code path
- * and use this request attribute to differentiate.
+ * For reusing code between text/html and text/plain, we run them both
+ * through the same code path and use this request attribute to
+ * differentiate.
*/
private boolean isHtml() {
- return Stapler.getCurrentRequest().getAttribute("html")!=null;
+ return Stapler.getCurrentRequest().getAttribute("html") != null;
}
@Override
@@ -106,38 +108,40 @@ public class AnnotatedLargeText<T> extends LargeText {
}
private ConsoleAnnotator createAnnotator(StaplerRequest req) throws IOException {
- ObjectInputStream ois = null;
+ ObjectInputStream ois = null;
try {
- String base64 = req!=null ? req.getHeader("X-ConsoleAnnotator") : null;
- if (base64!=null) {
+ String base64 = req != null ? req.getHeader("X-ConsoleAnnotator") : null;
+ if (base64 != null) {
Cipher sym = Secret.getCipher("AES");
sym.init(Cipher.DECRYPT_MODE, Hudson.getInstance().getSecretKeyAsAES128());
ois = new ObjectInputStreamEx(new GZIPInputStream(
- new CipherInputStream(new ByteArrayInputStream(Base64.decodeBase64(base64)),sym)),
+ new CipherInputStream(new ByteArrayInputStream(Base64.decodeBase64(base64)), sym)),
Hudson.getInstance().pluginManager.uberClassLoader);
long timestamp = ois.readLong();
- if (TimeUnit2.HOURS.toMillis(1) > abs(System.currentTimeMillis()-timestamp))
- // don't deserialize something too old to prevent a replay attack
- return (ConsoleAnnotator)ois.readObject();
+ if (TimeUnit2.HOURS.toMillis(1) > abs(System.currentTimeMillis() - timestamp)) // don't deserialize something too old to prevent a replay attack
+ {
+ return (ConsoleAnnotator) ois.readObject();
+ }
}
} catch (GeneralSecurityException e) {
throw new IOException2(e);
} catch (ClassNotFoundException e) {
throw new IOException2(e);
} finally {
- IOUtils.closeQuietly(ois);
+ IOUtils.closeQuietly(ois);
}
// start from scratch
- return ConsoleAnnotator.initial(context==null ? null : context.getClass());
+ return ConsoleAnnotator.initial(context == null ? null : context.getClass());
}
@Override
public long writeLogTo(long start, Writer w) throws IOException {
- if (isHtml())
+ if (isHtml()) {
return writeHtmlTo(start, w);
- else
- return super.writeLogTo(start,w);
+ } else {
+ return super.writeLogTo(start, w);
+ }
}
@Override
@@ -148,19 +152,20 @@ public class AnnotatedLargeText<T> extends LargeText {
public long writeHtmlTo(long start, Writer w) throws IOException {
ConsoleAnnotationOutputStream caw = new ConsoleAnnotationOutputStream(
w, createAnnotator(Stapler.getCurrentRequest()), context, charset);
- long r = super.writeLogTo(start,caw);
+ long r = super.writeLogTo(start, caw);
ObjectOutputStream oos = null;
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Cipher sym = Secret.getCipher("AES");
sym.init(Cipher.ENCRYPT_MODE, Hudson.getInstance().getSecretKeyAsAES128());
- oos = new ObjectOutputStream(new GZIPOutputStream(new CipherOutputStream(baos,sym)));
+ oos = new ObjectOutputStream(new GZIPOutputStream(new CipherOutputStream(baos, sym)));
oos.writeLong(System.currentTimeMillis()); // send timestamp to prevent a replay attack
- oos.writeObject(caw.getConsoleAnnotator());
+ oos.writeObject(caw.getConsoleAnnotator());
StaplerResponse rsp = Stapler.getCurrentResponse();
- if (rsp!=null)
+ if (rsp != null) {
rsp.setHeader("X-ConsoleAnnotator", new String(Base64.encodeBase64(baos.toByteArray())));
+ }
} catch (GeneralSecurityException e) {
throw new IOException2(e);
} finally {
@@ -168,5 +173,4 @@ public class AnnotatedLargeText<T> extends LargeText {
}
return r;
}
-
}
diff --git a/hudson-core/src/main/java/hudson/console/ConsoleAnnotationDescriptor.java b/hudson-core/src/main/java/hudson/console/ConsoleAnnotationDescriptor.java
index eee9c12..66705cc 100644
--- a/hudson-core/src/main/java/hudson/console/ConsoleAnnotationDescriptor.java
+++ b/hudson-core/src/main/java/hudson/console/ConsoleAnnotationDescriptor.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -36,6 +36,7 @@ import java.net.URL;
* @since 1.349
*/
public abstract class ConsoleAnnotationDescriptor extends Descriptor<ConsoleNote<?>> implements ExtensionPoint {
+
public ConsoleAnnotationDescriptor(Class<? extends ConsoleNote<?>> clazz) {
super(clazz);
}
@@ -51,37 +52,40 @@ public abstract class ConsoleAnnotationDescriptor extends Descriptor<ConsoleNote
public abstract String getDisplayName();
/**
- * Returns true if this descriptor has a JavaScript to be inserted on applicable console page.
+ * Returns true if this descriptor has a JavaScript to be inserted on
+ * applicable console page.
*/
public boolean hasScript() {
- return hasResource("/script.js") !=null;
+ return hasResource("/script.js") != null;
}
/**
- * Returns true if this descriptor has a stylesheet to be inserted on applicable console page.
+ * Returns true if this descriptor has a stylesheet to be inserted on
+ * applicable console page.
*/
public boolean hasStylesheet() {
- return hasResource("/style.css") !=null;
+ return hasResource("/style.css") != null;
}
private URL hasResource(String name) {
- return clazz.getClassLoader().getResource(clazz.getName().replace('.','/').replace('$','/')+ name);
+ return clazz.getClassLoader().getResource(clazz.getName().replace('.', '/').replace('$', '/') + name);
}
- @WebMethod(name="script.js")
+ @WebMethod(name = "script.js")
public void doScriptJs(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
rsp.serveFile(req, hasResource("/script.js"), TimeUnit2.DAYS.toMillis(1));
}
- @WebMethod(name="style.css")
+ @WebMethod(name = "style.css")
public void doStyleCss(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
rsp.serveFile(req, hasResource("/style.css"), TimeUnit2.DAYS.toMillis(1));
}
/**
- * Returns all the registered {@link ConsoleAnnotationDescriptor} descriptors.
+ * Returns all the registered {@link ConsoleAnnotationDescriptor}
+ * descriptors.
*/
- public static DescriptorExtensionList<ConsoleNote<?>,ConsoleAnnotationDescriptor> all() {
- return (DescriptorExtensionList)Hudson.getInstance().getDescriptorList(ConsoleNote.class);
+ public static DescriptorExtensionList<ConsoleNote<?>, ConsoleAnnotationDescriptor> all() {
+ return (DescriptorExtensionList) Hudson.getInstance().getDescriptorList(ConsoleNote.class);
}
}
diff --git a/hudson-core/src/main/java/hudson/console/ConsoleAnnotationOutputStream.java b/hudson-core/src/main/java/hudson/console/ConsoleAnnotationOutputStream.java
index dbb7804..d0c90b7 100644
--- a/hudson-core/src/main/java/hudson/console/ConsoleAnnotationOutputStream.java
+++ b/hudson-core/src/main/java/hudson/console/ConsoleAnnotationOutputStream.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -33,19 +33,18 @@ import java.util.logging.Level;
import java.util.logging.Logger;
/**
- * Used to convert plain text console output (as byte sequence) + embedded annotations into HTML (as char sequence),
- * by using {@link ConsoleAnnotator}.
+ * Used to convert plain text console output (as byte sequence) + embedded
+ * annotations into HTML (as char sequence), by using {@link ConsoleAnnotator}.
*
- * @param <T>
- * Context type.
+ * @param <T> Context type.
* @author Kohsuke Kawaguchi
* @since 1.349
*/
public class ConsoleAnnotationOutputStream<T> extends LineTransformationOutputStream {
+
private final Writer out;
private final T context;
private ConsoleAnnotator<T> ann;
-
/**
* Reused buffer that stores char representation of a single line.
*/
@@ -62,7 +61,7 @@ public class ConsoleAnnotationOutputStream<T> extends LineTransformationOutputSt
this.out = out;
this.ann = ConsoleAnnotator.cast(ann);
this.context = context;
- this.lineOut = new WriterOutputStream(line,charset);
+ this.lineOut = new WriterOutputStream(line, charset);
}
public ConsoleAnnotator getConsoleAnnotator() {
@@ -70,26 +69,27 @@ public class ConsoleAnnotationOutputStream<T> extends LineTransformationOutputSt
}
/**
- * Called after we read the whole line of plain text, which is stored in {@link #buf}.
- * This method performs annotations and send the result to {@link #out}.
+ * Called after we read the whole line of plain text, which is stored in
+ * {@link #buf}. This method performs annotations and send the result to
+ * {@link #out}.
*/
protected void eol(byte[] in, int sz) throws IOException {
line.reset();
final StringBuffer strBuf = line.getStringBuffer();
- int next = ConsoleNote.findPreamble(in,0,sz);
+ int next = ConsoleNote.findPreamble(in, 0, sz);
- List<ConsoleAnnotator<T>> annotators=null;
+ List<ConsoleAnnotator<T>> annotators = null;
- {// perform byte[]->char[] while figuring out the char positions of the BLOBs
+ { // perform byte[]->char[] while figuring out the char positions of the BLOBs
int written = 0;
- while (next>=0) {
- if (next>written) {
- lineOut.write(in,written,next-written);
+ while (next >= 0) {
+ if (next > written) {
+ lineOut.write(in, written, next - written);
lineOut.flush();
written = next;
} else {
- assert next==written;
+ assert next == written;
}
// character position of this annotation in this line
@@ -100,42 +100,46 @@ public class ConsoleAnnotationOutputStream<T> extends LineTransformationOutputSt
try {
final ConsoleNote a = ConsoleNote.readFrom(new DataInputStream(b));
- if (a!=null) {
- if (annotators==null)
+ if (a != null) {
+ if (annotators == null) {
annotators = new ArrayList<ConsoleAnnotator<T>>();
+ }
annotators.add(new ConsoleAnnotator<T>() {
public ConsoleAnnotator annotate(T context, MarkupText text) {
- return a.annotate(context,text,charPos);
+ return a.annotate(context, text, charPos);
}
});
}
} catch (IOException e) {
// if we failed to resurrect an annotation, ignore it.
- LOGGER.log(Level.FINE,"Failed to resurrect annotation",e);
+ LOGGER.log(Level.FINE, "Failed to resurrect annotation", e);
} catch (ClassNotFoundException e) {
- LOGGER.log(Level.FINE,"Failed to resurrect annotation",e);
+ LOGGER.log(Level.FINE, "Failed to resurrect annotation", e);
}
int bytesUsed = rest - b.available(); // bytes consumed by annotations
written += bytesUsed;
- next = ConsoleNote.findPreamble(in,written,sz-written);
+ next = ConsoleNote.findPreamble(in, written, sz - written);
}
// finish the remaining bytes->chars conversion
- lineOut.write(in,written,sz-written);
+ lineOut.write(in, written, sz - written);
- if (annotators!=null) {
+ if (annotators != null) {
// aggregate newly retrieved ConsoleAnnotators into the current one.
- if (ann!=null) annotators.add(ann);
+ if (ann != null) {
+ annotators.add(ann);
+ }
ann = ConsoleAnnotator.combine(annotators);
}
}
lineOut.flush();
MarkupText mt = new MarkupText(strBuf.toString());
- if (ann!=null)
- ann = ann.annotate(context,mt);
+ if (ann != null) {
+ ann = ann.annotate(context, mt);
+ }
out.write(mt.toString(true)); // this perform escapes
}
@@ -151,30 +155,32 @@ public class ConsoleAnnotationOutputStream<T> extends LineTransformationOutputSt
}
/**
- * {@link StringWriter} enhancement that's capable of shrinking the buffer size.
+ * {@link StringWriter} enhancement that's capable of shrinking the buffer
+ * size.
*
- * <p>
- * The problem is that {@link StringBuffer#setLength(int)} doesn't actually release
- * the underlying buffer, so for us to truncate the buffer, we need to create a new {@link StringWriter} instance.
+ * <p> The problem is that {@link StringBuffer#setLength(int)} doesn't
+ * actually release the underlying buffer, so for us to truncate the buffer,
+ * we need to create a new {@link StringWriter} instance.
*/
private static class LineBuffer extends ProxyWriter {
+
private LineBuffer(int initialSize) {
super(new StringWriter(initialSize));
}
private void reset() {
StringBuffer buf = getStringBuffer();
- if (buf.length()>4096)
+ if (buf.length() > 4096) {
out = new StringWriter(256);
- else
+ } else {
buf.setLength(0);
+ }
}
private StringBuffer getStringBuffer() {
- StringWriter w = (StringWriter)out;
+ StringWriter w = (StringWriter) out;
return w.getBuffer();
}
}
-
private static final Logger LOGGER = Logger.getLogger(ConsoleAnnotationOutputStream.class.getName());
}
diff --git a/hudson-core/src/main/java/hudson/console/ConsoleAnnotator.java b/hudson-core/src/main/java/hudson/console/ConsoleAnnotator.java
index f994259..6490531 100644
--- a/hudson-core/src/main/java/hudson/console/ConsoleAnnotator.java
+++ b/hudson-core/src/main/java/hudson/console/ConsoleAnnotator.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -27,32 +27,31 @@ import java.util.ListIterator;
/**
* Annotates one line of console output.
*
- * <p>
- * In Hudson, console output annotation is done line by line, and
- * we model this as a state machine &mdash;
- * the code encapsulates some state, and it uses that to annotate one line (and possibly update the state.)
+ * <p> In Hudson, console output annotation is done line by line, and we model
+ * this as a state machine &mdash; the code encapsulates some state, and it uses
+ * that to annotate one line (and possibly update the state.)
*
- * <p>
- * A {@link ConsoleAnnotator} instance encapsulates this state, and the {@link #annotate(Object, MarkupText)}
- * method is used to annotate the next line based on the current state. The method returns another
- * {@link ConsoleAnnotator} instance that represents the altered state for annotating the next line.
+ * <p> A {@link ConsoleAnnotator} instance encapsulates this state, and the
+ * {@link #annotate(Object, MarkupText)} method is used to annotate the next
+ * line based on the current state. The method returns another
+ * {@link ConsoleAnnotator} instance that represents the altered state for
+ * annotating the next line.
*
- * <p>
- * {@link ConsoleAnnotator}s are run when a browser requests console output, and the above-mentioned chain
- * invocation is done for each client request separately. Therefore, logically you can think of this process as:
+ * <p> {@link ConsoleAnnotator}s are run when a browser requests console output,
+ * and the above-mentioned chain invocation is done for each client request
+ * separately. Therefore, logically you can think of this process as:
*
* <pre>
* ConsoleAnnotator ca = ...;
* ca.annotate(context,line1).annotate(context,line2)...
* </pre>
*
- * <p>
- * Because of a browser can request console output incrementally, in addition to above a console annotator
- * can be serialized at any point and deserialized back later to continue annotation where it left off.
+ * <p> Because of a browser can request console output incrementally, in
+ * addition to above a console annotator can be serialized at any point and
+ * deserialized back later to continue annotation where it left off.
*
- * <p>
- * {@link ConsoleAnnotator} instances can be created in a few different ways. See {@link ConsoleNote}
- * and {@link ConsoleAnnotatorFactory}.
+ * <p> {@link ConsoleAnnotator} instances can be created in a few different
+ * ways. See {@link ConsoleNote} and {@link ConsoleAnnotatorFactory}.
*
* @author Kohsuke Kawaguchi
* @see ConsoleAnnotatorFactory
@@ -60,25 +59,25 @@ import java.util.ListIterator;
* @since 1.349
*/
public abstract class ConsoleAnnotator<T> implements Serializable {
+
/**
* Annotates one line.
*
- * @param context
- * The object that owns the console output. Never null.
- * @param text
- * Contains a single line of console output, and defines convenient methods to add markup.
- * The callee should put markup into this object. Never null.
- * @return
- * The {@link ConsoleAnnotator} object that will annotate the next line of the console output.
- * To indicate that you are not interested in the following lines, return null.
+ * @param context The object that owns the console output. Never null.
+ * @param text Contains a single line of console output, and defines
+ * convenient methods to add markup. The callee should put markup into this
+ * object. Never null.
+ * @return The {@link ConsoleAnnotator} object that will annotate the next
+ * line of the console output. To indicate that you are not interested in
+ * the following lines, return null.
*/
- public abstract ConsoleAnnotator annotate(T context, MarkupText text );
+ public abstract ConsoleAnnotator annotate(T context, MarkupText text);
/**
* Cast operation that restricts T.
*/
public static <T> ConsoleAnnotator<T> cast(ConsoleAnnotator<? super T> a) {
- return (ConsoleAnnotator)a;
+ return (ConsoleAnnotator) a;
}
/**
@@ -86,11 +85,14 @@ public abstract class ConsoleAnnotator<T> implements Serializable {
*/
public static <T> ConsoleAnnotator<T> combine(Collection<? extends ConsoleAnnotator<? super T>> all) {
switch (all.size()) {
- case 0: return null; // none
- case 1: return cast(all.iterator().next()); // just one
+ case 0:
+ return null; // none
+ case 1:
+ return cast(all.iterator().next()); // just one
}
class Aggregator extends ConsoleAnnotator<T> {
+
List<ConsoleAnnotator<T>> list;
Aggregator(Collection list) {
@@ -100,18 +102,24 @@ public abstract class ConsoleAnnotator<T> implements Serializable {
public ConsoleAnnotator annotate(T context, MarkupText text) {
ListIterator<ConsoleAnnotator<T>> itr = list.listIterator();
while (itr.hasNext()) {
- ConsoleAnnotator a = itr.next();
- ConsoleAnnotator b = a.annotate(context,text);
- if (a!=b) {
- if (b==null) itr.remove();
- else itr.set(b);
+ ConsoleAnnotator a = itr.next();
+ ConsoleAnnotator b = a.annotate(context, text);
+ if (a != b) {
+ if (b == null) {
+ itr.remove();
+ } else {
+ itr.set(b);
+ }
}
}
switch (list.size()) {
- case 0: return null; // no more annotator left
- case 1: return list.get(0); // no point in aggregating
- default: return this;
+ case 0:
+ return null; // no more annotator left
+ case 1:
+ return list.get(0); // no point in aggregating
+ default:
+ return this;
}
}
}
@@ -119,27 +127,28 @@ public abstract class ConsoleAnnotator<T> implements Serializable {
}
/**
- * Returns the all {@link ConsoleAnnotator}s for the given context type aggregated into a single
- * annotator.
+ * Returns the all {@link ConsoleAnnotator}s for the given context type
+ * aggregated into a single annotator.
*/
public static <T> ConsoleAnnotator<T> initial(T context) {
return combine(_for(context));
}
/**
- * List all the console annotators that can work for the specified context type.
+ * List all the console annotators that can work for the specified context
+ * type.
*/
public static <T> List<ConsoleAnnotator<T>> _for(T context) {
- List<ConsoleAnnotator<T>> r = new ArrayList<ConsoleAnnotator<T>>();
+ List<ConsoleAnnotator<T>> r = new ArrayList<ConsoleAnnotator<T>>();
for (ConsoleAnnotatorFactory f : ConsoleAnnotatorFactory.all()) {
if (f.type().isInstance(context)) {
ConsoleAnnotator ca = f.newInstance(context);
- if (ca!=null)
+ if (ca != null) {
r.add(ca);
+ }
}
}
return r;
}
-
private static final long serialVersionUID = 1L;
}
diff --git a/hudson-core/src/main/java/hudson/console/ConsoleAnnotatorFactory.java b/hudson-core/src/main/java/hudson/console/ConsoleAnnotatorFactory.java
index bad1b0b..955d421 100644
--- a/hudson-core/src/main/java/hudson/console/ConsoleAnnotatorFactory.java
+++ b/hudson-core/src/main/java/hudson/console/ConsoleAnnotatorFactory.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -34,45 +34,48 @@ import java.lang.reflect.Type;
import java.net.URL;
/**
- * Entry point to the {@link ConsoleAnnotator} extension point. This class creates a new instance
- * of {@link ConsoleAnnotator} that starts a new console annotation session.
+ * Entry point to the {@link ConsoleAnnotator} extension point. This class
+ * creates a new instance of {@link ConsoleAnnotator} that starts a new console
+ * annotation session.
+ *
+ * <p> {@link ConsoleAnnotatorFactory}s are used whenever a browser requests
+ * console output (as opposed to when the console output is being produced
+ * &mdash; for that see {@link ConsoleNote}.)
*
- * <p>
- * {@link ConsoleAnnotatorFactory}s are used whenever a browser requests console output (as opposed to when
- * the console output is being produced &mdash; for that see {@link ConsoleNote}.)
+ * <p> {@link ConsoleAnnotator}s returned by {@link ConsoleAnnotatorFactory} are
+ * asked to start from an arbitrary line of the output, because typically
+ * browsers do not request the entire console output. Because of this,
+ * {@link ConsoleAnnotatorFactory} is generally suitable for peep-hole local
+ * annotation that only requires a small contextual information, such as keyword
+ * coloring, URL hyperlinking, and so on.
*
- * <p>
- * {@link ConsoleAnnotator}s returned by {@link ConsoleAnnotatorFactory} are asked to start from
- * an arbitrary line of the output, because typically browsers do not request the entire console output.
- * Because of this, {@link ConsoleAnnotatorFactory} is generally suitable for peep-hole local annotation
- * that only requires a small contextual information, such as keyword coloring, URL hyperlinking, and so on.
+ * <p> To register, put
*
- * <p>
- * To register, put @{@link Extension} on your {@link ConsoleAnnotatorFactory} subtype.
+ * @{@link Extension} on your {@link ConsoleAnnotatorFactory} subtype.
+ *
+ * <h2>Behaviour, JavaScript, and CSS</h2> <p> {@link ConsoleNote} can have
+ * associated <tt>script.js</tt> and <tt>style.css</tt> (put them in the same
+ * resource directory that you normally put Jelly scripts), which will be loaded
+ * into the HTML page whenever the console notes are used. This allows you to
+ * use minimal markup in code generation, and do the styling in CSS and perform
+ * the rest of the interesting work as a CSS behaviour/JavaScript.
*
- * <h2>Behaviour, JavaScript, and CSS</h2>
- * <p>
- * {@link ConsoleNote} can have associated <tt>script.js</tt> and <tt>style.css</tt> (put them
- * in the same resource directory that you normally put Jelly scripts), which will be loaded into
- * the HTML page whenever the console notes are used. This allows you to use minimal markup in
- * code generation, and do the styling in CSS and perform the rest of the interesting work as a CSS behaviour/JavaScript.
- *
* @author Kohsuke Kawaguchi
* @since 1.349
*/
public abstract class ConsoleAnnotatorFactory<T> implements ExtensionPoint {
+
/**
- * Called when a console output page is requested to create a stateful {@link ConsoleAnnotator}.
+ * Called when a console output page is requested to create a stateful
+ * {@link ConsoleAnnotator}.
*
- * <p>
- * This method can be invoked concurrently by multiple threads.
+ * <p> This method can be invoked concurrently by multiple threads.
*
- * @param context
- * The model object that owns the console output, such as {@link Run}.
- * This method is only called when the context object if assignable to
- * {@linkplain #type() the advertised type}.
- * @return
- * null if this factory is not going to participate in the annotation of this console.
+ * @param context The model object that owns the console output, such as
+ * {@link Run}. This method is only called when the context object if
+ * assignable to {@linkplain #type() the advertised type}.
+ * @return null if this factory is not going to participate in the
+ * annotation of this console.
*/
public abstract ConsoleAnnotator newInstance(T context);
@@ -81,37 +84,40 @@ public abstract class ConsoleAnnotatorFactory<T> implements ExtensionPoint {
*/
public Class type() {
Type type = Types.getBaseClass(getClass(), ConsoleAnnotator.class);
- if (type instanceof ParameterizedType)
- return Types.erasure(Types.getTypeArgument(type,0));
- else
+ if (type instanceof ParameterizedType) {
+ return Types.erasure(Types.getTypeArgument(type, 0));
+ } else {
return Object.class;
+ }
}
/**
- * Returns true if this descriptor has a JavaScript to be inserted on applicable console page.
+ * Returns true if this descriptor has a JavaScript to be inserted on
+ * applicable console page.
*/
public boolean hasScript() {
- return getResource("/script.js") !=null;
+ return getResource("/script.js") != null;
}
public boolean hasStylesheet() {
- return getResource("/style.css") !=null;
+ return getResource("/style.css") != null;
}
private URL getResource(String fileName) {
Class c = getClass();
- return c.getClassLoader().getResource(c.getName().replace('.','/').replace('$','/')+ fileName);
+ return c.getClassLoader().getResource(c.getName().replace('.', '/').replace('$', '/') + fileName);
}
/**
- * Serves the JavaScript file associated with this console annotator factory.
+ * Serves the JavaScript file associated with this console annotator
+ * factory.
*/
- @WebMethod(name="script.js")
+ @WebMethod(name = "script.js")
public void doScriptJs(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
rsp.serveFile(req, getResource("/script.js"), TimeUnit2.DAYS.toMillis(1));
}
- @WebMethod(name="style.css")
+ @WebMethod(name = "style.css")
public void doStyleCss(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
rsp.serveFile(req, getResource("/style.css"), TimeUnit2.DAYS.toMillis(1));
}
diff --git a/hudson-core/src/main/java/hudson/console/ConsoleNote.java b/hudson-core/src/main/java/hudson/console/ConsoleNote.java
index 56b31f8..b807426 100644
--- a/hudson-core/src/main/java/hudson/console/ConsoleNote.java
+++ b/hudson-core/src/main/java/hudson/console/ConsoleNote.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -49,65 +49,66 @@ import java.util.zip.GZIPOutputStream;
/**
* Data that hangs off from a console output.
*
- * <p>
- * A {@link ConsoleNote} can be put into a console output while it's being written, and it represents
- * a machine readable information about a particular position of the console output.
+ * <p> A {@link ConsoleNote} can be put into a console output while it's being
+ * written, and it represents a machine readable information about a particular
+ * position of the console output.
*
- * <p>
- * When Hudson is reading back a console output for display, a {@link ConsoleNote} is used
- * to trigger {@link ConsoleAnnotator}, which in turn uses the information in the note to
- * generate markup. In this way, we can overlay richer information on top of the console output.
+ * <p> When Hudson is reading back a console output for display, a
+ * {@link ConsoleNote} is used to trigger {@link ConsoleAnnotator}, which in
+ * turn uses the information in the note to generate markup. In this way, we can
+ * overlay richer information on top of the console output.
*
- * <h2>Comparison with {@link ConsoleAnnotatorFactory}</h2>
- * <p>
- * Compared to {@link ConsoleAnnotatorFactory}, the main advantage of {@link ConsoleNote} is that
- * it can be emitted into the output by the producer of the output (or by a filter), which can
- * have a much better knowledge about the context of what's being executed.
+ * <h2>Comparison with {@link ConsoleAnnotatorFactory}</h2> <p> Compared to
+ * {@link ConsoleAnnotatorFactory}, the main advantage of {@link ConsoleNote} is
+ * that it can be emitted into the output by the producer of the output (or by a
+ * filter), which can have a much better knowledge about the context of what's
+ * being executed.
*
- * <ol>
- * <li>
- * For example, when your plugin is about to report an error message, you can emit a {@link ConsoleNote}
- * that indicates an error, instead of printing an error message as plain text. The {@link #annotate(Object, MarkupText, int)}
- * method will then generate the proper error message, with all the HTML markup that makes error message
- * more user friendly.
+ * <ol> <li> For example, when your plugin is about to report an error message,
+ * you can emit a {@link ConsoleNote} that indicates an error, instead of
+ * printing an error message as plain text. The
+ * {@link #annotate(Object, MarkupText, int)} method will then generate the
+ * proper error message, with all the HTML markup that makes error message more
+ * user friendly.
*
- * <li>
- * Or consider annotating output from Ant. A modified {@link BuildListener} can place a {@link ConsoleNote}
- * every time a new target execution starts. These notes can be then later used to build the outline
- * that shows what targets are executed, hyperlinked to their corresponding locations in the build output.
- * </ol>
+ * <li> Or consider annotating output from Ant. A modified {@link BuildListener}
+ * can place a {@link ConsoleNote} every time a new target execution starts.
+ * These notes can be then later used to build the outline that shows what
+ * targets are executed, hyperlinked to their corresponding locations in the
+ * build output. </ol>
*
- * <p>
- * Doing these things by {@link ConsoleAnnotatorFactory} would be a lot harder, as they can only rely
- * on the pattern matching of the output.
+ * <p> Doing these things by {@link ConsoleAnnotatorFactory} would be a lot
+ * harder, as they can only rely on the pattern matching of the output.
*
- * <h2>Persistence</h2>
- * <p>
- * {@link ConsoleNote}s are serialized and gzip compressed into a byte sequence and then embedded into the
- * console output text file, with a bit of preamble/postamble to allow tools to ignore them. In this way
- * {@link ConsoleNote} always sticks to a particular point in the console output.
+ * <h2>Persistence</h2> <p> {@link ConsoleNote}s are serialized and gzip
+ * compressed into a byte sequence and then embedded into the console output
+ * text file, with a bit of preamble/postamble to allow tools to ignore them. In
+ * this way {@link ConsoleNote} always sticks to a particular point in the
+ * console output.
*
- * <p>
- * This design allows descendant processes of Hudson to emit {@link ConsoleNote}s. For example, Ant forked
- * by a shell forked by Hudson can put an encoded note in its stdout, and Hudson will correctly understands that.
- * The preamble and postamble includes a certain ANSI escape sequence designed in such a way to minimize garbage
- * if this output is observed by a human being directly.
+ * <p> This design allows descendant processes of Hudson to emit
+ * {@link ConsoleNote}s. For example, Ant forked by a shell forked by Hudson can
+ * put an encoded note in its stdout, and Hudson will correctly understands
+ * that. The preamble and postamble includes a certain ANSI escape sequence
+ * designed in such a way to minimize garbage if this output is observed by a
+ * human being directly.
*
- * <p>
- * Because of this persistence mechanism, {@link ConsoleNote}s need to be serializable, and care should be taken
- * to reduce footprint of the notes, if you are putting a lot of notes. Serialization format compatibility
- * is also important, although {@link ConsoleNote}s that failed to deserialize will be simply ignored, so the
- * worst thing that can happen is that you just lose some notes.
+ * <p> Because of this persistence mechanism, {@link ConsoleNote}s need to be
+ * serializable, and care should be taken to reduce footprint of the notes, if
+ * you are putting a lot of notes. Serialization format compatibility is also
+ * important, although {@link ConsoleNote}s that failed to deserialize will be
+ * simply ignored, so the worst thing that can happen is that you just lose some
+ * notes.
*
- * <h2>Behaviour, JavaScript, and CSS</h2>
- * <p>
- * {@link ConsoleNote} can have associated <tt>script.js</tt> and <tt>style.css</tt> (put them
- * in the same resource directory that you normally put Jelly scripts), which will be loaded into
- * the HTML page whenever the console notes are used. This allows you to use minimal markup in
- * code generation, and do the styling in CSS and perform the rest of the interesting work as a CSS behaviour/JavaScript.
+ * <h2>Behaviour, JavaScript, and CSS</h2> <p> {@link ConsoleNote} can have
+ * associated <tt>script.js</tt> and <tt>style.css</tt> (put them in the same
+ * resource directory that you normally put Jelly scripts), which will be loaded
+ * into the HTML page whenever the console notes are used. This allows you to
+ * use minimal markup in code generation, and do the styling in CSS and perform
+ * the rest of the interesting work as a CSS behaviour/JavaScript.
*
- * @param <T>
- * Contextual model object that this console is associated with, such as {@link Run}.
+ * @param <T> Contextual model object that this console is associated with, such
+ * as {@link Run}.
*
* @author Kohsuke Kawaguchi
* @see ConsoleAnnotationDescriptor
@@ -115,34 +116,34 @@ import java.util.zip.GZIPOutputStream;
* @since 1.349
*/
public abstract class ConsoleNote<T> implements Serializable, Describable<ConsoleNote<?>> {
+
/**
- * When the line of a console output that this annotation is attached is read by someone,
- * a new {@link ConsoleNote} is de-serialized and this method is invoked to annotate that line.
+ * When the line of a console output that this annotation is attached is
+ * read by someone, a new {@link ConsoleNote} is de-serialized and this
+ * method is invoked to annotate that line.
*
- * @param context
- * The object that owns the console output in question.
- * @param text
- * Represents a line of the console output being annotated.
- * @param charPos
- * The character position in 'text' where this annotation is attached.
+ * @param context The object that owns the console output in question.
+ * @param text Represents a line of the console output being annotated.
+ * @param charPos The character position in 'text' where this annotation is
+ * attached.
*
- * @return
- * if non-null value is returned, this annotator will handle the next line.
- * this mechanism can be used to annotate multiple lines starting at the annotated position.
+ * @return if non-null value is returned, this annotator will handle the
+ * next line. this mechanism can be used to annotate multiple lines starting
+ * at the annotated position.
*/
public abstract ConsoleAnnotator annotate(T context, MarkupText text, int charPos);
public ConsoleAnnotationDescriptor getDescriptor() {
- return (ConsoleAnnotationDescriptor)Hudson.getInstance().getDescriptorOrDie(getClass());
+ return (ConsoleAnnotationDescriptor) Hudson.getInstance().getDescriptorOrDie(getClass());
}
/**
* Prints this note into a stream.
*
- * <p>
- * The most typical use of this is {@code n.encodedTo(System.out)} where stdout is connected to Hudson.
- * The encoded form doesn't include any new line character to work better in the line-oriented nature
- * of {@link ConsoleAnnotator}.
+ * <p> The most typical use of this is {@code n.encodedTo(System.out)} where
+ * stdout is connected to Hudson. The encoded form doesn't include any new
+ * line character to work better in the line-oriented nature of
+ * {@link ConsoleAnnotator}.
*/
public void encodeTo(OutputStream out) throws IOException {
// atomically write to the final output, to minimize the chance of something else getting in between the output.
@@ -154,9 +155,8 @@ public abstract class ConsoleNote<T> implements Serializable, Describable<Consol
/**
* Prints this note into a writer.
*
- * <p>
- * Technically, this method only works if the {@link Writer} to {@link OutputStream}
- * encoding is ASCII compatible.
+ * <p> Technically, this method only works if the {@link Writer} to
+ * {@link OutputStream} encoding is ASCII compatible.
*/
public void encodeTo(Writer out) throws IOException {
out.write(encodeToBytes().toString());
@@ -176,10 +176,10 @@ public abstract class ConsoleNote<T> implements Serializable, Describable<Consol
DataOutputStream dos = null;
try {
- dos = new DataOutputStream(new Base64OutputStream(buf2,true,-1,null));
+ dos = new DataOutputStream(new Base64OutputStream(buf2, true, -1, null));
buf2.write(PREAMBLE);
dos.writeInt(buf.size());
- buf.writeTo(dos);
+ buf.writeTo(dos);
buf2.write(POSTAMBLE);
} finally {
IOUtils.closeQuietly(dos);
@@ -197,23 +197,23 @@ public abstract class ConsoleNote<T> implements Serializable, Describable<Consol
}
/**
- * Reads a note back from {@linkplain #encodeTo(OutputStream) its encoded form}.
+ * Reads a note back from
+ * {@linkplain #encodeTo(OutputStream) its encoded form}.
*
- * @param in
- * Must point to the beginning of a preamble.
+ * @param in Must point to the beginning of a preamble.
*
* @return null if the encoded form is malformed.
*/
public static ConsoleNote readFrom(DataInputStream in) throws IOException, ClassNotFoundException {
- ObjectInputStream ois = null;
- DataInputStream decoded = null;
-
+ ObjectInputStream ois = null;
+ DataInputStream decoded = null;
+
try {
byte[] preamble = new byte[PREAMBLE.length];
in.readFully(preamble);
- if (!Arrays.equals(preamble,PREAMBLE))
+ if (!Arrays.equals(preamble, PREAMBLE)) {
return null; // not a valid preamble
-
+ }
decoded = new DataInputStream(new UnbufferedBase64InputStream(in));
int sz = decoded.readInt();
//Size should be greater than Zero. See http://issues.hudson-ci.org/browse/HUDSON-6558
@@ -225,9 +225,9 @@ public abstract class ConsoleNote<T> implements Serializable, Describable<Consol
byte[] postamble = new byte[POSTAMBLE.length];
in.readFully(postamble);
- if (!Arrays.equals(postamble,POSTAMBLE))
+ if (!Arrays.equals(postamble, POSTAMBLE)) {
return null; // not a valid postamble
-
+ }
ois = new ObjectInputStreamEx(
new GZIPInputStream(new ByteArrayInputStream(buf)), Hudson.getInstance().pluginManager.uberClassLoader);
return (ConsoleNote) ois.readObject();
@@ -236,8 +236,8 @@ public abstract class ConsoleNote<T> implements Serializable, Describable<Consol
// package that up as IOException so that the caller won't fatally die.
throw new IOException2(e);
} finally {
- IOUtils.closeQuietly(ois);
- IOUtils.closeQuietly(decoded);
+ IOUtils.closeQuietly(ois);
+ IOUtils.closeQuietly(decoded);
}
}
@@ -247,25 +247,22 @@ public abstract class ConsoleNote<T> implements Serializable, Describable<Consol
public static void skip(DataInputStream in) throws IOException {
byte[] preamble = new byte[PREAMBLE.length];
in.readFully(preamble);
- if (!Arrays.equals(preamble,PREAMBLE))
+ if (!Arrays.equals(preamble, PREAMBLE)) {
return; // not a valid preamble
-
+ }
DataInputStream decoded = new DataInputStream(new UnbufferedBase64InputStream(in));
int sz = decoded.readInt();
- IOUtils.skip(decoded,sz);
+ IOUtils.skip(decoded, sz);
byte[] postamble = new byte[POSTAMBLE.length];
in.readFully(postamble);
}
-
private static final long serialVersionUID = 1L;
-
public static final String PREAMBLE_STR = "\u001B[8mha:";
public static final String POSTAMBLE_STR = "\u001B[0m";
-
/**
- * Preamble of the encoded form. ANSI escape sequence to stop echo back
- * plus a few magic characters.
+ * Preamble of the encoded form. ANSI escape sequence to stop echo back plus
+ * a few magic characters.
*/
public static final byte[] PREAMBLE = PREAMBLE_STR.getBytes();
/**
@@ -280,12 +277,13 @@ public abstract class ConsoleNote<T> implements Serializable, Describable<Consol
int e = start + len - PREAMBLE.length + 1;
OUTER:
- for (int i=start; i<e; i++) {
- if (buf[i]==PREAMBLE[0]) {
+ for (int i = start; i < e; i++) {
+ if (buf[i] == PREAMBLE[0]) {
// check for the rest of the match
- for (int j=1; j<PREAMBLE.length; j++) {
- if (buf[i+j]!=PREAMBLE[j])
+ for (int j = 1; j < PREAMBLE.length; j++) {
+ if (buf[i + j] != PREAMBLE[j]) {
continue OUTER;
+ }
}
return i; // found it
}
@@ -300,8 +298,9 @@ public abstract class ConsoleNote<T> implements Serializable, Describable<Consol
*/
public static List<String> removeNotes(Collection<String> logLines) {
List<String> r = new ArrayList<String>(logLines.size());
- for (String l : logLines)
+ for (String l : logLines) {
r.add(removeNotes(l));
+ }
return r;
}
@@ -313,10 +312,14 @@ public abstract class ConsoleNote<T> implements Serializable, Describable<Consol
public static String removeNotes(String line) {
while (true) {
int idx = line.indexOf(PREAMBLE_STR);
- if (idx<0) return line;
- int e = line.indexOf(POSTAMBLE_STR,idx);
- if (e<0) return line;
- line = line.substring(0,idx)+line.substring(e+POSTAMBLE_STR.length());
+ if (idx < 0) {
+ return line;
+ }
+ int e = line.indexOf(POSTAMBLE_STR, idx);
+ if (e < 0) {
+ return line;
+ }
+ line = line.substring(0, idx) + line.substring(e + POSTAMBLE_STR.length());
}
}
}
diff --git a/hudson-core/src/main/java/hudson/console/ExpandableDetailsNote.java b/hudson-core/src/main/java/hudson/console/ExpandableDetailsNote.java
index 4bedcef..73d9133 100644
--- a/hudson-core/src/main/java/hudson/console/ExpandableDetailsNote.java
+++ b/hudson-core/src/main/java/hudson/console/ExpandableDetailsNote.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.console;
import hudson.Extension;
@@ -46,15 +45,16 @@ import java.util.logging.Level;
import java.util.logging.Logger;
/**
- * Renders a button that can be clicked to reveal additional block tag (and HTML inside it.)
+ * Renders a button that can be clicked to reveal additional block tag (and HTML
+ * inside it.)
*
- * <p>
- * Useful if you want the user to be able to see additional details.
+ * <p> Useful if you want the user to be able to see additional details.
*
* @author Kohsuke Kawaguchi
* @since 1.395
*/
public class ExpandableDetailsNote extends ConsoleNote {
+
private final String caption;
private final String html;
@@ -66,7 +66,7 @@ public class ExpandableDetailsNote extends ConsoleNote {
@Override
public ConsoleAnnotator annotate(Object context, MarkupText text, int charPos) {
text.addMarkup(charPos,
- "<input type=button value='"+caption+"' class='reveal-expandable-detail'><div class='expandable-detail'>"+html+"</div>");
+ "<input type=button value='" + caption + "' class='reveal-expandable-detail'><div class='expandable-detail'>" + html + "</div>");
return null;
}
@@ -75,17 +75,17 @@ public class ExpandableDetailsNote extends ConsoleNote {
return new ExpandableDetailsNote(buttonCaption, html).encode();
} catch (IOException e) {
// impossible, but don't make this a fatal problem
- LOGGER.log(Level.WARNING, "Failed to serialize "+HyperlinkNote.class,e);
+ LOGGER.log(Level.WARNING, "Failed to serialize " + HyperlinkNote.class, e);
return "";
}
}
@Extension
public static final class DescriptorImpl extends ConsoleAnnotationDescriptor {
+
public String getDisplayName() {
return "Expandable details";
}
}
-
private static final Logger LOGGER = Logger.getLogger(ExpandableDetailsNote.class.getName());
}
diff --git a/hudson-core/src/main/java/hudson/console/HudsonExceptionNote.java b/hudson-core/src/main/java/hudson/console/HudsonExceptionNote.java
index 05cfe78..dd82080 100644
--- a/hudson-core/src/main/java/hudson/console/HudsonExceptionNote.java
+++ b/hudson-core/src/main/java/hudson/console/HudsonExceptionNote.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.console;
import hudson.Extension;
@@ -45,11 +44,11 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
- * Placed on the beginning of the exception stack trace produced by Hudson, which in turn produces hyperlinked stack trace.
+ * Placed on the beginning of the exception stack trace produced by Hudson,
+ * which in turn produces hyperlinked stack trace.
*
- * <p>
- * Exceptions in the user code (like junit etc) should be handled differently. This is only for exceptions
- * that occur inside Hudson.
+ * <p> Exceptions in the user code (like junit etc) should be handled
+ * differently. This is only for exceptions that occur inside Hudson.
*
* @author Kohsuke Kawaguchi
* @since 1.349
@@ -63,14 +62,15 @@ public class HudsonExceptionNote extends ConsoleNote<Object> {
// <TAB>at org.acme.Foo.method(Foo.java:123)
// Caused by: java.lang.ClassNotFoundException:
String line = text.getText();
- int end = line.indexOf(':',charPos);
- if (end<0) {
- if (CLASSNAME.matcher(line.substring(charPos)).matches())
+ int end = line.indexOf(':', charPos);
+ if (end < 0) {
+ if (CLASSNAME.matcher(line.substring(charPos)).matches()) {
end = line.length();
- else
+ } else {
return null; // unexpected format. abort.
+ }
}
- text.addHyperlinkLowKey(charPos,end,annotateClassName(line.substring(charPos,end)));
+ text.addHyperlinkLowKey(charPos, end, annotateClassName(line.substring(charPos, end)));
return new ConsoleAnnotator() {
public ConsoleAnnotator annotate(Object context, MarkupText text) {
@@ -78,21 +78,24 @@ public class HudsonExceptionNote extends ConsoleNote<Object> {
Matcher m = STACK_TRACE_ELEMENT.matcher(line);
if (m.find()) {// allow the match to happen in the middle of a line to cope with prefix. Ant and Maven put them, among many other tools.
- text.addHyperlinkLowKey(m.start()+4,m.end(),annotateMethodName(m.group(1),m.group(2),m.group(3),Integer.parseInt(m.group(4))));
+ text.addHyperlinkLowKey(m.start() + 4, m.end(), annotateMethodName(m.group(1), m.group(2), m.group(3), Integer.parseInt(m.group(4))));
return this;
}
int idx = line.indexOf(CAUSED_BY);
- if (idx>=0) {
+ if (idx >= 0) {
int s = idx + CAUSED_BY.length();
int e = line.indexOf(':', s);
- if (e<0) e = line.length();
- text.addHyperlinkLowKey(s,e,annotateClassName(line.substring(s,e)));
+ if (e < 0) {
+ e = line.length();
+ }
+ text.addHyperlinkLowKey(s, e, annotateClassName(line.substring(s, e)));
return this;
}
- if (AND_MORE.matcher(line).matches())
+ if (AND_MORE.matcher(line).matches()) {
return this;
+ }
// looks like we are done with the stack trace
return null;
@@ -101,37 +104,33 @@ public class HudsonExceptionNote extends ConsoleNote<Object> {
}
// TODO; separate out the annotations and mark up
-
private String annotateMethodName(String className, String methodName, String sourceFileName, int lineNumber) {
- return "http://stacktrace.hudson-ci.org/search/?query="+className+'.'+methodName+"&entity=method";
+ return "http://stacktrace.hudson-ci.org/search/?query=" + className + '.' + methodName + "&entity=method";
}
private String annotateClassName(String className) {
- return "http://stacktrace.hudson-ci.org/search?query="+className;
+ return "http://stacktrace.hudson-ci.org/search?query=" + className;
}
@Extension
public static final class DescriptorImpl extends ConsoleAnnotationDescriptor {
+
@Override
public String getDisplayName() {
return "Exception Stack Trace";
}
}
-
/**
* Regular expression that represents a valid class name.
*/
private static final String CLASSNAME_PATTERN = "[\\p{L}0-9$_.]+";
-
- private static final Pattern CLASSNAME = Pattern.compile(CLASSNAME_PATTERN+"\r?\n?");
-
+ private static final Pattern CLASSNAME = Pattern.compile(CLASSNAME_PATTERN + "\r?\n?");
/**
- * Matches to the line like "\tat org.acme.Foo.method(File.java:123)"
- * and captures class name, method name, source file name, and line number separately.
+ * Matches to the line like "\tat org.acme.Foo.method(File.java:123)" and
+ * captures class name, method name, source file name, and line number
+ * separately.
*/
- private static final Pattern STACK_TRACE_ELEMENT = Pattern.compile("\tat ("+CLASSNAME_PATTERN+")\\.([\\p{L}0-9$_<>]+)\\((\\S+):([0-9]+)\\)");
-
+ private static final Pattern STACK_TRACE_ELEMENT = Pattern.compile("\tat (" + CLASSNAME_PATTERN + ")\\.([\\p{L}0-9$_<>]+)\\((\\S+):([0-9]+)\\)");
private static final String CAUSED_BY = "Caused by: ";
-
private static final Pattern AND_MORE = Pattern.compile("\t... [0-9]+ more\n");
}
diff --git a/hudson-core/src/main/java/hudson/console/HyperlinkNote.java b/hudson-core/src/main/java/hudson/console/HyperlinkNote.java
index 83239b1..efb6448 100644
--- a/hudson-core/src/main/java/hudson/console/HyperlinkNote.java
+++ b/hudson-core/src/main/java/hudson/console/HyperlinkNote.java
@@ -7,7 +7,7 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
*
*******************************************************************************/
@@ -34,7 +34,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
-
package hudson.console;
import hudson.Extension;
@@ -52,8 +51,10 @@ import java.util.logging.Logger;
* @since 1.362
*/
public class HyperlinkNote extends ConsoleNote {
+
/**
- * If this starts with '/', it's interpreted as a path within the context path.
+ * If this starts with '/', it's interpreted as a path within the context
+ * path.
*/
private final String url;
private final int length;
@@ -66,28 +67,29 @@ public class HyperlinkNote extends ConsoleNote {
@Override
public ConsoleAnnotator annotate(Object context, MarkupText text, int charPos) {
String url = this.url;
- if (url.startsWith("/"))
- url = Hudson.getInstance().getRootUrl()+url.substring(1);
- text.addHyperlink(charPos,charPos+length,url);
+ if (url.startsWith("/")) {
+ url = Hudson.getInstance().getRootUrl() + url.substring(1);
+ }
+ text.addHyperlink(charPos, charPos + length, url);
return null;
}
public static String encodeTo(String url, String text) {
try {
- return new HyperlinkNote(url,text.length()).encode()+text;
+ return new HyperlinkNote(url, text.length()).encode() + text;
} catch (IOException e) {
// impossible, but don't make this a fatal problem
- LOGGER.log(Level.WARNING, "Failed to serialize "+HyperlinkNote.class,e);
+ LOGGER.log(Level.WARNING, "Failed to serialize " + HyperlinkNote.class, e);
return text;
}
}
@Extension
public static final class DescriptorImpl extends ConsoleAnnotationDescriptor {
+
public String getDisplayName() {
return "Hyperlinks";
}
}
-
private static final Logger LOGGER = Logger.getLogger(HyperlinkNote.class.getName());
}
diff --git a/hudson-core/src/main/java/hudson/console/LineTransformationOutputStream.java b/hudson-core/src/main/java/hudson/console/LineTransformationOutputStream.java
index fbb4460..86794a4 100644
--- a/hudson-core/src/main/java/hudson/console/LineTransformationOutputStream.java
+++ b/hudson-core/src/main/java/hudson/console/LineTransformationOutputStream.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -22,8 +22,8 @@ import java.io.IOException;
import java.io.OutputStream;
/**
- * Filtering {@link OutputStream} that buffers text by line, so that the derived class
- * can perform some manipulation based on the contents of the whole line.
+ * Filtering {@link OutputStream} that buffers text by line, so that the derived
+ * class can perform some manipulation based on the contents of the whole line.
*
* TODO: Mac is supposed to be CR-only. This class needs to handle that.
*
@@ -31,40 +31,44 @@ import java.io.OutputStream;
* @since 1.349
*/
public abstract class LineTransformationOutputStream extends OutputStream {
+
private ByteArrayOutputStream2 buf = new ByteArrayOutputStream2();
/**
* Called for each end of the line.
*
- * @param b
- * Contents of the whole line, including the EOL code like CR/LF.
- * @param len
- * Specifies the length of the valid contents in 'b'. The rest is garbage.
- * This is so that the caller doesn't have to allocate an array of the exact size.
+ * @param b Contents of the whole line, including the EOL code like CR/LF.
+ * @param len Specifies the length of the valid contents in 'b'. The rest is
+ * garbage. This is so that the caller doesn't have to allocate an array of
+ * the exact size.
*/
protected abstract void eol(byte[] b, int len) throws IOException;
public void write(int b) throws IOException {
buf.write(b);
- if (b==LF) eol();
+ if (b == LF) {
+ eol();
+ }
}
private void eol() throws IOException {
- eol(buf.getBuffer(),buf.size());
+ eol(buf.getBuffer(), buf.size());
// reuse the buffer under normal circumstances, but don't let the line buffer grow unbounded
- if (buf.size()>4096)
+ if (buf.size() > 4096) {
buf = new ByteArrayOutputStream2();
- else
+ } else {
buf.reset();
+ }
}
@Override
public void write(byte[] b, int off, int len) throws IOException {
- int end = off+len;
+ int end = off + len;
- for( int i=off; i<end; i++ )
+ for (int i = off; i < end; i++) {
write(b[i]);
+ }
}
@Override
@@ -75,14 +79,14 @@ public abstract class LineTransformationOutputStream extends OutputStream {
/**
* Forces the EOL behavior.
*
- * Useful if the caller wants to make sure the buffered content is all processed, but without
- * actually neither flushing nor closing the stream.
+ * Useful if the caller wants to make sure the buffered content is all
+ * processed, but without actually neither flushing nor closing the stream.
*/
public void forceEol() throws IOException {
- if (buf.size()>0) {
+ if (buf.size() > 0) {
/*
- because LargeText cuts output at the line end boundary, this is
- possible only for the very end of the console output, if the output ends without NL.
+ because LargeText cuts output at the line end boundary, this is
+ possible only for the very end of the console output, if the output ends without NL.
*/
eol();
}
@@ -90,17 +94,16 @@ public abstract class LineTransformationOutputStream extends OutputStream {
protected String trimEOL(String line) {
int slen = line.length();
- while (slen>0) {
- char ch = line.charAt(slen-1);
- if (ch=='\r' || ch=='\n') {
+ while (slen > 0) {
+ char ch = line.charAt(slen - 1);
+ if (ch == '\r' || ch == '\n') {
slen--;
continue;
}
break;
}
- line = line.substring(0,slen);
+ line = line.substring(0, slen);
return line;
}
-
private static final int LF = 0x0A;
}
diff --git a/hudson-core/src/main/java/hudson/console/PlainTextConsoleOutputStream.java b/hudson-core/src/main/java/hudson/console/PlainTextConsoleOutputStream.java
index 035f3b9..bd13cdb 100644
--- a/hudson-core/src/main/java/hudson/console/PlainTextConsoleOutputStream.java
+++ b/hudson-core/src/main/java/hudson/console/PlainTextConsoleOutputStream.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -28,6 +28,7 @@ import java.util.logging.Logger;
* @author Kohsuke Kawaguchi
*/
public class PlainTextConsoleOutputStream extends LineTransformationOutputStream {
+
private final OutputStream out;
/**
@@ -42,16 +43,16 @@ public class PlainTextConsoleOutputStream extends LineTransformationOutputStream
*/
protected void eol(byte[] in, int sz) throws IOException {
- int next = ConsoleNote.findPreamble(in,0,sz);
+ int next = ConsoleNote.findPreamble(in, 0, sz);
// perform byte[]->char[] while figuring out the char positions of the BLOBs
int written = 0;
- while (next>=0) {
- if (next>written) {
- out.write(in,written,next-written);
+ while (next >= 0) {
+ if (next > written) {
+ out.write(in, written, next - written);
written = next;
} else {
- assert next==written;
+ assert next == written;
}
int rest = sz - next;
@@ -63,10 +64,10 @@ public class PlainTextConsoleOutputStream extends LineTransformationOutputStream
written += bytesUsed;
- next = ConsoleNote.findPreamble(in,written,sz-written);
+ next = ConsoleNote.findPreamble(in, written, sz - written);
}
// finish the remaining bytes->chars conversion
- out.write(in,written,sz-written);
+ out.write(in, written, sz - written);
}
@Override
@@ -79,7 +80,5 @@ public class PlainTextConsoleOutputStream extends LineTransformationOutputStream
super.close();
out.close();
}
-
-
private static final Logger LOGGER = Logger.getLogger(ConsoleAnnotationOutputStream.class.getName());
}
diff --git a/hudson-core/src/main/java/hudson/console/UrlAnnotator.java b/hudson-core/src/main/java/hudson/console/UrlAnnotator.java
index e8aaf39..ffcf48c 100644
--- a/hudson-core/src/main/java/hudson/console/UrlAnnotator.java
+++ b/hudson-core/src/main/java/hudson/console/UrlAnnotator.java
@@ -8,7 +8,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- *
+ *
*
*******************************************************************************/
@@ -27,36 +27,35 @@ import java.util.regex.Pattern;
*/
@Extension
public class UrlAnnotator extends ConsoleAnnotatorFactory<Object> {
+
@Override
public ConsoleAnnotator newInstance(Object context) {
return new UrlConsoleAnnotator();
}
private static class UrlConsoleAnnotator extends ConsoleAnnotator {
+
public ConsoleAnnotator annotate(Object context, MarkupText text) {
for (SubText t : text.findTokens(URL)) {
int prev = t.start() - 1;
- char ch = prev>=0 ? text.charAt(prev) : ' ';
+ char ch = prev >= 0 ? text.charAt(prev) : ' ';
int idx = OPEN.indexOf(ch);
- if (idx>=0) {// if inside a bracket, exclude the end bracket.
- t=t.subText(0,t.getText().indexOf(CLOSE.charAt(idx)));
+ if (idx >= 0) {// if inside a bracket, exclude the end bracket.
+ t = t.subText(0, t.getText().indexOf(CLOSE.charAt(idx)));
}
t.href(t.getText());
}
return this;
}
-
private static final long serialVersionUID = 1L;
-
/**
- * Starts with a word boundary and protocol identifier,
- * don't include any whitespace, '&lt;', nor '>'.
- * In addition, the last character shouldn't be ',' ':', '"', etc, as often those things show up right next
- * to URL in plain text (e.g., test="http://www.example.com/")
+ * Starts with a word boundary and protocol identifier, don't include
+ * any whitespace, '&lt;', nor '>'. In addition, the last character
+ * shouldn't be ',' ':', '"', etc, as often those things show up right
+ * next to URL in plain text (e.g., test="http://www.example.com/")
*/
private static final Pattern URL = Pattern.compile("\\b(http|https|ftp)://[^\\s<>]+[^\\s<>,:\"'()\\[\\]=]");
-
private static final String OPEN = "'\"()[]<>";
- private static final String CLOSE= "'\")(][><";
+ private static final String CLOSE = "'\")(][><";
}
}
diff --git a/hudson-core/src/main/java/hudson/matrix/MatrixProject.java b/hudson-core/src/main/java/hudson/matrix/MatrixProject.java
index 11cfc23..efa44b2 100644
--- a/hudson-core/src/main/java/hudson/matrix/MatrixProject.java
+++ b/hudson-core/src/main/java/hudson/matrix/MatrixProject.java
@@ -251,11 +251,11 @@ public class MatrixProject extends BaseBuildableProject<MatrixProject, MatrixBui
//Convert legacy properties to IProjectProperty logic
if (null != axes && null == getProperty(AXES_PROPERTY_NAME)) {
setAxes(axes);
- axes = null;//Reset to null. No longer needed.
+ axes = null; //Reset to null. No longer needed.
}
if (null != combinationFilter && null == getProperty(COMBINATION_FILTER_PROPERTY_NAME)) {
setCombinationFilter(combinationFilter);
- combinationFilter = null;//Reset to null. No longer needed.
+ combinationFilter = null; //Reset to null. No longer needed.
}
if (null == getProperty(RUN_SEQUENTIALLY_PROPERTY_NAME)) {
setRunSequentially(runSequentially);
@@ -263,15 +263,15 @@ public class MatrixProject extends BaseBuildableProject<MatrixProject, MatrixBui
}
if (null != touchStoneCombinationFilter && null == getProperty(TOUCH_STONE_COMBINATION_FILTER_PROPERTY_NAME)) {
setTouchStoneCombinationFilter(touchStoneCombinationFilter);
- touchStoneCombinationFilter = null;//Reset to null. No longer needed.
+ touchStoneCombinationFilter = null; //Reset to null. No longer needed.
}
if (null != touchStoneResultCondition && null == getProperty(TOUCH_STONE_RESULT_CONDITION_PROPERTY_NAME)) {
setTouchStoneResultCondition(touchStoneResultCondition);
- touchStoneResultCondition = null;//Reset to null. No longer needed.
+ touchStoneResultCondition = null; //Reset to null. No longer needed.
}
if (null != customWorkspace && null == getProperty(CUSTOM_WORKSPACE_PROPERTY_NAME)) {
setCustomWorkspace(customWorkspace);
- customWorkspace = null;//Reset to null. No longer needed.
+ customWorkspace = null; //Reset to null. No longer needed.
}
save();
rebuildConfigurations();
diff --git a/hudson-core/src/main/java/hudson/model/AbstractBuild.java b/hudson-core/src/main/java/hudson/model/AbstractBuild.java
index 16f8a7c..c9a46d4 100644
--- a/hudson-core/src/main/java/hudson/model/AbstractBuild.java
+++ b/hudson-core/src/main/java/hudson/model/AbstractBuild.java
@@ -688,8 +688,8 @@ public abstract class AbstractBuild<P extends AbstractProject<P, R>, R extends A
}
}
- if (changeSet == null) // cached value
- {
+ // cached value
+ if (changeSet == null) {
try {
changeSet = calcChangeSet();
} finally {
@@ -1174,8 +1174,8 @@ public abstract class AbstractBuild<P extends AbstractProject<P, R>, R extends A
Executor e = getExecutor();
if (e != null) {
e.doStop(req, rsp);
- } else // nothing is building
- {
+ } else {
+ // nothing is building
rsp.forwardToPreviousPage(req);
}
}
diff --git a/hudson-core/src/main/java/hudson/model/Hudson.java b/hudson-core/src/main/java/hudson/model/Hudson.java
index a65aa68..8835cc9 100644
--- a/hudson-core/src/main/java/hudson/model/Hudson.java
+++ b/hudson-core/src/main/java/hudson/model/Hudson.java
@@ -323,7 +323,8 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
super(h);
}
- public CloudList() {// needed for XStream deserialization
+ // needed for XStream deserialization
+ public CloudList() {
}
public Cloud getByName(String name) {
@@ -592,7 +593,8 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
updateComputerList();
- {// master is online now
+ // master is online now
+ {
Computer c = toComputer();
if (c != null) {
for (ComputerListener cl : ComputerListener.all()) {
@@ -1085,7 +1087,8 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
* 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
+ // just so that we don't have two code updating computer list at the same time
+ synchronized (updateComputerLock) {
Map<String, Computer> byName = new HashMap<String, Computer>();
for (Computer c : computers.values()) {
if (c.getNode() == null) {
@@ -1585,8 +1588,8 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
throw new IllegalArgumentException();
}
ArrayList<Node> nl = new ArrayList<Node>(this.slaves);
- if (!nl.contains(n)) // defensive check
- {
+ // defensive check
+ if (!nl.contains(n)) {
nl.add(n);
}
setNodes(nl);
@@ -1714,7 +1717,8 @@ 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
+ 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);
}
@@ -1722,7 +1726,8 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
protected Collection<Computer> all() {
return computers.values();
}
- }).add(new CollectionSearchIndex() {// for users
+ }).add(new CollectionSearchIndex() {
+ // for users
protected User get(String key) {
return User.get(key, false);
}
@@ -1730,7 +1735,8 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
protected Collection<User> all() {
return User.getAll();
}
- }).add(new CollectionSearchIndex() {// for views
+ }).add(new CollectionSearchIndex() {
+ // for views
protected View get(String key) {
return getView(key);
}
@@ -1747,8 +1753,8 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
@Exported
public View getPrimaryView() {
View v = getView(primaryView);
- if (v == null) // fallback
- {
+ // fallback
+ if (v == null) {
v = views.get(0);
}
return v;
@@ -1917,7 +1923,7 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
* requirement.
* @return Can be an empty list but never null.
*/
- @SuppressWarnings({"unchecked"})
+ @SuppressWarnings({"unchecked" })
public <T> ExtensionList<T> getExtensionList(Class<T> extensionType) {
return extensionLists.get(extensionType);
}
@@ -1937,7 +1943,7 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
*
* @return Can be an empty list but never null.
*/
- @SuppressWarnings({"unchecked"})
+ @SuppressWarnings({"unchecked" })
public <T extends Describable<T>, D extends Descriptor<T>> DescriptorExtensionList<T, D> getDescriptorList(Class<T> type) {
return descriptorLists.get(type);
}
@@ -2270,9 +2276,10 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
public void run(Reactor session) throws Exception {
rebuildDependencyGraph();
- {// recompute label objects - populates the labels mapping.
- for (Node slave : slaves) // Note that not all labels are visible until the slaves have connected.
- {
+ // recompute label objects - populates the labels mapping.
+ {
+ for (Node slave : slaves) {
+ // Note that not all labels are visible until the slaves have connected.
slave.getAssignedLabels();
}
getAssignedLabels();
@@ -2343,9 +2350,9 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
pluginManager.stop();
}
- if (getRootDir().exists()) // if we are aborting because we failed to create HUDSON_HOME,
+ // if we are aborting because we failed to create HUDSON_HOME,
// don't try to save. Issue #536
- {
+ if (getRootDir().exists()) {
getQueue().save();
}
@@ -2634,7 +2641,7 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
* @param name Name of the newly created project.
* @return Newly created {@link TopLevelItem}.
*/
- @SuppressWarnings({"unchecked"})
+ @SuppressWarnings({"unchecked" })
public <T extends TopLevelItem> T copy(T src, String name) throws IOException {
return itemGroupMixIn.copy(src, name);
}
@@ -2924,8 +2931,8 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
restart();
- if (rsp != null) // null for CLI
- {
+ // null for CLI
+ if (rsp != null) {
rsp.sendRedirect2(".");
}
}
@@ -2948,8 +2955,8 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
safeRestart();
- if (rsp != null) // null for CLI
- {
+ // null for CLI
+ if (rsp != null) {
rsp.sendRedirect2(".");
}
}
diff --git a/hudson-core/src/main/java/hudson/model/ItemGroupMixIn.java b/hudson-core/src/main/java/hudson/model/ItemGroupMixIn.java
index 1ad4e24..38c0aa7 100644
--- a/hudson-core/src/main/java/hudson/model/ItemGroupMixIn.java
+++ b/hudson-core/src/main/java/hudson/model/ItemGroupMixIn.java
@@ -126,7 +126,7 @@ public abstract class ItemGroupMixIn {
throw new Failure("Query parameter 'name' is required");
}
- {// check if the name looks good
+ { // check if the name looks good
Hudson.checkGoodName(name);
name = name.trim();
if (parent.getItem(name) != null) {
@@ -191,7 +191,7 @@ public abstract class ItemGroupMixIn {
* because it doesn't know how to make the newly added item reachable from
* the parent.
*/
- @SuppressWarnings({"unchecked"})
+ @SuppressWarnings({"unchecked" })
public synchronized <T extends TopLevelItem> T copy(T src, String name) throws IOException {
acl.checkPermission(Job.CREATE);
diff --git a/hudson-core/src/main/java/hudson/model/Run.java b/hudson-core/src/main/java/hudson/model/Run.java
index 4233ab2..8e1c436 100644
--- a/hudson-core/src/main/java/hudson/model/Run.java
+++ b/hudson-core/src/main/java/hudson/model/Run.java
@@ -282,7 +282,7 @@ public abstract class Run<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
/**
* Obtains 'this' in a more type safe signature.
*/
- @SuppressWarnings({"unchecked"})
+ @SuppressWarnings({"unchecked" })
private RunT _this() {
return (RunT) this;
}
@@ -665,7 +665,7 @@ public abstract class Run<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
RunT answer;
while (true) {
RunT n = r.previousBuildInProgress;
- if (n == null) {// no field computed yet.
+ if (n == null) { // no field computed yet.
n = r.getPreviousBuild();
fixUp.add(r);
}
@@ -1393,11 +1393,11 @@ public abstract class Run<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
CheckPoint.MAIN_COMPLETED.report();
} catch (ThreadDeath t) {
throw t;
- } catch (AbortException e) {// orderly abortion.
+ } catch (AbortException e) { // orderly abortion.
result = Result.FAILURE;
listener.error(e.getMessage());
LOGGER.log(FINE, "Build " + this + " aborted", e);
- } catch (RunnerAbortedException e) {// orderly abortion.
+ } catch (RunnerAbortedException e) { // orderly abortion.
result = Result.FAILURE;
LOGGER.log(FINE, "Build " + this + " aborted", e);
} catch (InterruptedException e) {
diff --git a/hudson-core/src/main/java/hudson/os/SU.java b/hudson-core/src/main/java/hudson/os/SU.java
index cce4d9d..4982a92 100644
--- a/hudson-core/src/main/java/hudson/os/SU.java
+++ b/hudson-core/src/main/java/hudson/os/SU.java
@@ -61,8 +61,8 @@ public abstract class SU {
* be shut down.
*/
public static VirtualChannel start(final TaskListener listener, final String rootUsername, final String rootPassword) throws IOException, InterruptedException {
- if (File.pathSeparatorChar == ';') // on Windows
- {
+ // on Windows
+ if (File.pathSeparatorChar == ';') {
return newLocalChannel(); // TODO: perhaps use RunAs to run as an Administrator?
}
String os = Util.fixNull(System.getProperty("os.name"));
@@ -143,7 +143,8 @@ public abstract class SU {
throw new IOException(exc);
}
- if (uid == 0) // already running as root
+ // already running as root
+ if (uid == 0)
{
return newLocalChannel();
}
diff --git a/hudson-core/src/main/java/hudson/security/HudsonPrivateSecurityRealm.java b/hudson-core/src/main/java/hudson/security/HudsonPrivateSecurityRealm.java
index 316e3c1..c961400 100644
--- a/hudson-core/src/main/java/hudson/security/HudsonPrivateSecurityRealm.java
+++ b/hudson-core/src/main/java/hudson/security/HudsonPrivateSecurityRealm.java
@@ -678,7 +678,7 @@ public class HudsonPrivateSecurityRealm extends AbstractPasswordBasedSecurityRea
private String generateSalt() {
StringBuilder buf = new StringBuilder();
SecureRandom sr = new SecureRandom();
- for (int i = 0; i < 6; i++) {// log2(52^6)=34.20... so, this is about 32bit strong.
+ for (int i = 0; i < 6; i++) { // log2(52^6)=34.20... so, this is about 32bit strong.
boolean upper = sr.nextBoolean();
char ch = (char) (sr.nextInt(26) + 'a');
if (upper) {
@@ -712,7 +712,7 @@ public class HudsonPrivateSecurityRealm extends AbstractPasswordBasedSecurityRea
if (req.getRequestURI().equals(req.getContextPath() + "/")) {
if (needsToCreateFirstUser()) {
((HttpServletResponse) response).sendRedirect("securityRealm/firstUser");
- } else {// the first user already created. the role of this filter is over.
+ } else { // the first user already created. the role of this filter is over.
PluginServletFilter.removeFilter(this);
chain.doFilter(request, response);
}
diff --git a/hudson-core/src/main/java/hudson/util/FormFieldValidator.java b/hudson-core/src/main/java/hudson/util/FormFieldValidator.java
index a560fa8..90e8671 100644
--- a/hudson-core/src/main/java/hudson/util/FormFieldValidator.java
+++ b/hudson-core/src/main/java/hudson/util/FormFieldValidator.java
@@ -317,7 +317,7 @@ public abstract class FormFieldValidator {
protected void check() throws IOException, ServletException {
String value = fixEmpty(request.getParameter("value"));
- if (value == null) {// nothing entered yet
+ if (value == null) { // nothing entered yet
ok();
return;
}
@@ -377,7 +377,7 @@ public abstract class FormFieldValidator {
try {
FilePath ws = getBaseDirectory(p);
- if (ws == null || !ws.exists()) {// no workspace. can't check
+ if (ws == null || !ws.exists()) { // no workspace. can't check
ok();
return;
}
@@ -459,12 +459,12 @@ public abstract class FormFieldValidator {
try {
FilePath ws = getBaseDirectory(p);
- if (ws == null) {// can't check
+ if (ws == null) { // can't check
ok();
return;
}
- if (!ws.exists()) {// no workspace. can't check
+ if (!ws.exists()) { // no workspace. can't check
ok();
return;
}
diff --git a/hudson-core/src/main/java/hudson/util/Iterators.java b/hudson-core/src/main/java/hudson/util/Iterators.java
index 76a36cc..06335c5 100644
--- a/hudson-core/src/main/java/hudson/util/Iterators.java
+++ b/hudson-core/src/main/java/hudson/util/Iterators.java
@@ -232,7 +232,7 @@ public class Iterators {
/**
* Casts {@link Iterator} by taking advantage of its covariant-ness.
*/
- @SuppressWarnings({"unchecked"})
+ @SuppressWarnings({"unchecked" })
public static <T> Iterator<T> cast(Iterator<? extends T> itr) {
return (Iterator) itr;
}
@@ -240,7 +240,7 @@ public class Iterators {
/**
* Casts {@link Iterable} by taking advantage of its covariant-ness.
*/
- @SuppressWarnings({"unchecked"})
+ @SuppressWarnings({"unchecked" })
public static <T> Iterable<T> cast(Iterable<? extends T> itr) {
return (Iterable) itr;
}
@@ -248,7 +248,7 @@ public class Iterators {
/**
* Returns an {@link Iterator} that only returns items of the given subtype.
*/
- @SuppressWarnings({"unchecked"})
+ @SuppressWarnings({"unchecked" })
public static <U, T extends U> Iterator<T> subType(Iterator<U> itr, final Class<T> type) {
return (Iterator) new FilterIterator<U>(itr) {
protected boolean filter(U u) {
diff --git a/hudson-jetty-war-executable/src/main/java/org/eclipse/hudson/jetty/JettyLauncher.java b/hudson-jetty-war-executable/src/main/java/org/eclipse/hudson/jetty/JettyLauncher.java
index 8afa23c..8857c70 100644
--- a/hudson-jetty-war-executable/src/main/java/org/eclipse/hudson/jetty/JettyLauncher.java
+++ b/hudson-jetty-war-executable/src/main/java/org/eclipse/hudson/jetty/JettyLauncher.java
@@ -42,9 +42,9 @@ public class JettyLauncher {
String keyStorePath = null;
String keyStorePassword = null;
-
+
String updateServer = null;
-
+
boolean disableUpdateCenterSwitch = false;
for (int i = 0; i < args.length; i++) {
@@ -52,32 +52,32 @@ public class JettyLauncher {
String portStr = args[i].substring("--httpPort=".length());
httpPort = Integer.parseInt(portStr);
}
-
+
if (args[i].startsWith("--httpsPort=")) {
String portStr = args[i].substring("--httpsPort=".length());
httpsPort = Integer.parseInt(portStr);
}
-
+
if (args[i].startsWith("--httpsKeyStore=")) {
keyStorePath = args[i].substring("--httpsKeyStore=".length());
}
-
+
if (args[i].startsWith("--httpsKeyStorePassword=")) {
keyStorePassword = args[i].substring("--httpsKeyStorePassword=".length());
}
-
+
if (args[i].startsWith("--prefix=")) {
String prefix = args[i].substring("--prefix=".length());
- if (prefix.startsWith("/")){
+ if (prefix.startsWith("/")) {
contextPath = prefix;
- }else{
+ } else {
contextPath = "/" + prefix;
}
}
if (args[i].startsWith("--updateServer=")) {
updateServer = args[i].substring("--updateServer=".length());
}
-
+
if (args[i].startsWith("--disableUpdateCenterSwitch=")) {
disableUpdateCenterSwitch = true;
}
@@ -101,7 +101,7 @@ public class JettyLauncher {
if (keyStorePath != null) {
httpsConnector.setKeystore(keyStorePath);
}
- if (keyStorePassword != null){
+ if (keyStorePassword != null) {
httpsConnector.setKeyPassword(keyStorePassword);
}
connectors.add(httpsConnector);
@@ -123,13 +123,13 @@ public class JettyLauncher {
// This is used by Windows Service Installer in Hudson Management
System.out.println("War - " + warUrl.getPath());
System.setProperty("executable-war", warUrl.getPath());
-
- if (updateServer != null){
- System.setProperty("updateServer", updateServer);
+
+ if (updateServer != null) {
+ System.setProperty("updateServer", updateServer);
}
-
- if (disableUpdateCenterSwitch){
- System.setProperty("hudson.pluginManager.disableUpdateCenterSwitch", "true");
+
+ if (disableUpdateCenterSwitch) {
+ System.setProperty("hudson.pluginManager.disableUpdateCenterSwitch", "true");
}
server.addHandler(context);
diff --git a/hudson-plugin-utils/src/main/java/org/hudsonci/utils/plugin/ui/RenderableEnum.java b/hudson-plugin-utils/src/main/java/org/hudsonci/utils/plugin/ui/RenderableEnum.java
index 845c4bf..170373e 100644
--- a/hudson-plugin-utils/src/main/java/org/hudsonci/utils/plugin/ui/RenderableEnum.java
+++ b/hudson-plugin-utils/src/main/java/org/hudsonci/utils/plugin/ui/RenderableEnum.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -25,8 +25,8 @@ import java.io.Serializable;
* @since 2.1.0
*/
public class RenderableEnum<E extends Enum<E>>
- implements Comparable<E>, Serializable
-{
+ implements Comparable<E>, Serializable {
+
private final E value;
public RenderableEnum(final E value) {
@@ -36,7 +36,6 @@ public class RenderableEnum<E extends Enum<E>>
// These are all getXXX so that jelly can reference them with an explicit method call.
// ie. ${enum.name} -> getName(), otherwise its gotta be ${enum.name()}.
-
public String getDisplayName() {
// TODO: Allow lookup of human/i18n name, look up resource bundle for enum type, then key off enum name
return value.name();
@@ -50,10 +49,12 @@ public class RenderableEnum<E extends Enum<E>>
return value.ordinal();
}
+ @Override
public boolean equals(final Object obj) {
return value.equals(obj);
}
+ @Override
public int hashCode() {
return value.hashCode();
}
@@ -62,12 +63,12 @@ public class RenderableEnum<E extends Enum<E>>
return value.compareTo(obj);
}
- @SuppressWarnings({"unchecked"})
+ @SuppressWarnings({"unchecked" })
public static RenderableEnum[] forEnum(final Class<? extends Enum> source) {
assert source != null;
Enum[] values = source.getEnumConstants();
RenderableEnum[] target = new RenderableEnum[values.length];
- for (int i=0; i<values.length; i++) {
+ for (int i = 0; i < values.length; i++) {
target[i] = new RenderableEnum(values[i]);
}
return target;
diff --git a/hudson-plugin-utils/src/main/java/org/hudsonci/utils/tasks/MetaProject.java b/hudson-plugin-utils/src/main/java/org/hudsonci/utils/tasks/MetaProject.java
index 1af8133..bdd2f27 100644
--- a/hudson-plugin-utils/src/main/java/org/hudsonci/utils/tasks/MetaProject.java
+++ b/hudson-plugin-utils/src/main/java/org/hudsonci/utils/tasks/MetaProject.java
@@ -45,37 +45,34 @@ import static com.google.common.base.Preconditions.checkNotNull;
/**
* Provides a unified interface for {@link AbstractProject} types.
- *
- * Avoiding generic types where possible to avoid <tt>"inconvertible types" due to capture###</tt>.
+ *
+ * Avoiding generic types where possible to avoid <tt>"inconvertible types" due
+ * to capture###</tt>.
*
* @author <a href="mailto:jason@planet57.com">Jason Dillon</a>
* @since 2.1.0
*/
-@SuppressWarnings( {"rawtypes", "unchecked"} )
-public class MetaProject
-{
- private static final Logger log = LoggerFactory.getLogger(MetaProject.class);
+@SuppressWarnings({"rawtypes", "unchecked" })
+public class MetaProject {
+ private static final Logger log = LoggerFactory.getLogger(MetaProject.class);
private final AbstractProject delegate;
- public static enum Type
- {
+ public static enum Type {
+
/**
* Any other project type (like MavenModuleSet, etc).
*/
UNSUPPORTED,
-
/**
* Sub-class of {@link Project}.
*/
NORMAL,
-
/**
* Sub-class of {@link MatrixProject}.
*/
MULTICONFIG
}
-
private final Type type;
public MetaProject(final AbstractProject project) {
@@ -83,11 +80,9 @@ public class MetaProject
if (delegate instanceof MatrixProject) {
type = Type.MULTICONFIG;
- }
- else if (delegate instanceof Project) {
+ } else if (delegate instanceof Project) {
type = Type.NORMAL;
- }
- else {
+ } else {
type = Type.UNSUPPORTED;
log.debug("Unsupported project type: {}", project.getClass().getName());
}
@@ -121,15 +116,15 @@ public class MetaProject
/**
* Typed access to project instance as a normal {@link Project}.
*/
- public Project<?,?> asNormal() {
- return (Project)getDelegate();
+ public Project<?, ?> asNormal() {
+ return (Project) getDelegate();
}
/**
* Typed access to project instance as a multi-config {@link MatrixProject}.
*/
public MatrixProject asMultiConfig() {
- return (MatrixProject)getDelegate();
+ return (MatrixProject) getDelegate();
}
public ItemGroup getParent() {
@@ -176,16 +171,17 @@ public class MetaProject
public Collection<Trigger> getTriggers() {
return getDelegate().getTriggers().values();
}
-
+
public void addTrigger(final Trigger item) throws IOException {
checkNotNull(item);
getDelegate().addTrigger(item);
}
/**
- * @throws UnsupportedProjectException if the Project type is {@link Type#UNSUPPORTED}.
+ * @throws UnsupportedProjectException if the Project type is
+ * {@link Type#UNSUPPORTED}.
*/
- public DescribableList<BuildWrapper,Descriptor<BuildWrapper>> getBuildWrappersList() {
+ public DescribableList<BuildWrapper, Descriptor<BuildWrapper>> getBuildWrappersList() {
switch (getType()) {
case NORMAL:
return asNormal().getBuildWrappersList();
@@ -198,16 +194,18 @@ public class MetaProject
}
/**
- * @throws UnsupportedProjectException if the Project type is {@link Type#UNSUPPORTED}.
+ * @throws UnsupportedProjectException if the Project type is
+ * {@link Type#UNSUPPORTED}.
*/
public Collection<BuildWrapper> getBuildWrappers() {
return getBuildWrappersList().toList();
}
/**
- * @throws UnsupportedProjectException if the Project type is {@link Type#UNSUPPORTED}.
+ * @throws UnsupportedProjectException if the Project type is
+ * {@link Type#UNSUPPORTED}.
*/
- public DescribableList<Builder,Descriptor<Builder>> getBuildersList() {
+ public DescribableList<Builder, Descriptor<Builder>> getBuildersList() {
switch (getType()) {
case NORMAL:
return asNormal().getBuildersList();
@@ -220,16 +218,18 @@ public class MetaProject
}
/**
- * @throws UnsupportedProjectException if the Project type is {@link Type#UNSUPPORTED}.
+ * @throws UnsupportedProjectException if the Project type is
+ * {@link Type#UNSUPPORTED}.
*/
public Collection<Builder> getBuilders() {
return getBuildersList().toList();
}
/**
- * @throws UnsupportedProjectException if the Project type is {@link Type#UNSUPPORTED}.
+ * @throws UnsupportedProjectException if the Project type is
+ * {@link Type#UNSUPPORTED}.
*/
- public DescribableList<Publisher,Descriptor<Publisher>> getPublishersList() {
+ public DescribableList<Publisher, Descriptor<Publisher>> getPublishersList() {
switch (getType()) {
case NORMAL:
return asNormal().getPublishersList();
@@ -242,7 +242,8 @@ public class MetaProject
}
/**
- * @throws UnsupportedProjectException if the Project type is {@link Type#UNSUPPORTED}.
+ * @throws UnsupportedProjectException if the Project type is
+ * {@link Type#UNSUPPORTED}.
*/
public Collection<Publisher> getPublishers() {
return getPublishersList().toList();
@@ -271,13 +272,12 @@ public class MetaProject
}
// FIXME: Extract out to service
+ public static interface Filter {
- public static interface Filter
- {
/**
* Return true to include the given project in the result.
*
- * @param project Never null
+ * @param project Never null
*/
boolean accept(MetaProject project);
}
@@ -287,7 +287,7 @@ public class MetaProject
for (Item item : Hudson.getInstance().getItems()) {
if (item instanceof AbstractProject) {
- MetaProject project = new MetaProject((AbstractProject)item);
+ MetaProject project = new MetaProject((AbstractProject) item);
if (filter == null || filter.accept(project)) {
projects.add(project);
}
@@ -305,7 +305,7 @@ public class MetaProject
checkNotNull(id);
Job job = JobUuid.find(id);
if (job instanceof AbstractProject) {
- return new MetaProject((AbstractProject)job);
+ return new MetaProject((AbstractProject) job);
}
return null;
}
diff --git a/hudson-plugin-utils/src/main/java/org/hudsonci/utils/tasks/OpenServerSocket.java b/hudson-plugin-utils/src/main/java/org/hudsonci/utils/tasks/OpenServerSocket.java
index fd4552d..66f2f6a 100644
--- a/hudson-plugin-utils/src/main/java/org/hudsonci/utils/tasks/OpenServerSocket.java
+++ b/hudson-plugin-utils/src/main/java/org/hudsonci/utils/tasks/OpenServerSocket.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -43,18 +43,17 @@ import java.net.SocketException;
* @since 2.1.0
*/
public class OpenServerSocket
- implements Callable<OpenServerSocket.Acceptor,IOException>
-{
- private static final Logger log = LoggerFactory.getLogger(OpenServerSocket.class);
+ implements Callable<OpenServerSocket.Acceptor, IOException> {
+ private static final Logger log = LoggerFactory.getLogger(OpenServerSocket.class);
public static final int DEFAULT_SO_TIMEOUT = 30 * 1000;
/**
* Used to accept a new connection on the remote server socket.
*/
public interface Acceptor
- extends Closeable
- {
+ extends Closeable {
+
int getPort();
Connection accept(boolean close) throws IOException;
@@ -66,8 +65,8 @@ public class OpenServerSocket
* Represents the accepted connection.
*/
public interface Connection
- extends Closeable
- {
+ extends Closeable {
+
InputStream getInput();
OutputStream getOutput();
@@ -83,12 +82,10 @@ public class OpenServerSocket
}
// TODO: Document behavior on both sides of channel so its easier to comprehend whats going on here
-
private class AcceptorImpl
- implements Acceptor, Serializable
- {
- private static final long serialVersionUID = 1L;
+ implements Acceptor, Serializable {
+ private static final long serialVersionUID = 1L;
private transient final ServerSocket serverSocket;
public AcceptorImpl() throws IOException {
@@ -130,12 +127,10 @@ public class OpenServerSocket
}
private class ConnectionImpl
- implements Connection, Serializable
- {
- private static final long serialVersionUID = 1L;
+ implements Connection, Serializable {
+ private static final long serialVersionUID = 1L;
private InputStream input;
-
private OutputStream output;
public ConnectionImpl(final InputStream input, final OutputStream output) {
diff --git a/hudson-plugin-utils/src/main/java/org/hudsonci/utils/tasks/OperationSupport.java b/hudson-plugin-utils/src/main/java/org/hudsonci/utils/tasks/OperationSupport.java
index 2472ae6..8f6ebd8 100644
--- a/hudson-plugin-utils/src/main/java/org/hudsonci/utils/tasks/OperationSupport.java
+++ b/hudson-plugin-utils/src/main/java/org/hudsonci/utils/tasks/OperationSupport.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -31,30 +31,25 @@ import static com.google.common.base.Preconditions.checkNotNull;
* @author <a href="mailto:jason@planet57.com">Jason Dillon</a>
* @since 2.1.0
*/
-public abstract class OperationSupport<T extends BuildStep>
-{
+public abstract class OperationSupport<T extends BuildStep> {
+
/**
* Server-side logger.
*/
protected final Logger log = LoggerFactory.getLogger(getClass());
-
protected final T owner;
-
- protected final AbstractBuild<?,?> build;
-
+ protected final AbstractBuild<?, ?> build;
protected final BuildListener listener;
-
/**
* Build console logger.
*/
protected final TaskListenerLogger logger;
-
/**
* Muxed server+build console logger.
*/
protected final Logger muxlog;
- public OperationSupport(final T owner, final AbstractBuild<?,?> build, final BuildListener listener) {
+ public OperationSupport(final T owner, final AbstractBuild<?, ?> build, final BuildListener listener) {
this.owner = checkNotNull(owner);
this.build = checkNotNull(build);
this.listener = checkNotNull(listener);
diff --git a/hudson-plugin-utils/src/main/java/org/hudsonci/utils/tasks/PerformOperation.java b/hudson-plugin-utils/src/main/java/org/hudsonci/utils/tasks/PerformOperation.java
index 84a9086..a8a7901 100644
--- a/hudson-plugin-utils/src/main/java/org/hudsonci/utils/tasks/PerformOperation.java
+++ b/hudson-plugin-utils/src/main/java/org/hudsonci/utils/tasks/PerformOperation.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -33,8 +33,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
* @since 2.1.0
*/
public abstract class PerformOperation<T extends BuildStep>
- extends OperationSupport<T>
-{
+ extends OperationSupport<T> {
+
protected final Launcher launcher;
public PerformOperation(final T owner, final AbstractBuild<?, ?> build, final Launcher launcher, final BuildListener listener) {
@@ -50,18 +50,15 @@ public abstract class PerformOperation<T extends BuildStep>
boolean result = doExecute();
log.debug("Finished in {}", watch);
return result;
- }
- catch (InterruptedException e) {
+ } catch (InterruptedException e) {
log.debug("Failed after {}", watch);
onFailure(e);
throw e;
- }
- catch (IOException e) {
+ } catch (IOException e) {
log.debug("Failed after {}", watch);
onFailure(e);
throw e;
- }
- catch (Exception e) {
+ } catch (Exception e) {
log.debug("Failed after {}", watch);
onFailure(e);
throw new OperationFailure(e);
diff --git a/hudson-plugin-utils/src/main/java/org/hudsonci/utils/tasks/UnsupportedProjectException.java b/hudson-plugin-utils/src/main/java/org/hudsonci/utils/tasks/UnsupportedProjectException.java
index bf47d2a..fb4d7c1 100644
--- a/hudson-plugin-utils/src/main/java/org/hudsonci/utils/tasks/UnsupportedProjectException.java
+++ b/hudson-plugin-utils/src/main/java/org/hudsonci/utils/tasks/UnsupportedProjectException.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -19,32 +19,29 @@ package org.hudsonci.utils.tasks;
import hudson.model.AbstractProject;
/**
- * Indicates that an operation on a sub-class of {@link AbstractProject} is not supported by a project type.
- *
+ * Indicates that an operation on a sub-class of {@link AbstractProject} is not
+ * supported by a project type.
+ *
* @author Jamie Whitehouse
* @since 2.1.0
*/
public class UnsupportedProjectException
- extends RuntimeException
-{
- private static final long serialVersionUID = 1L;
+ extends RuntimeException {
+ private static final long serialVersionUID = 1L;
private final AbstractProject project;
- public UnsupportedProjectException( final AbstractProject project )
- {
- super(String.format( "Unsupported project '%s' of type %s.", project.getFullDisplayName(), project.getClass()));
+ public UnsupportedProjectException(final AbstractProject project) {
+ super(String.format("Unsupported project '%s' of type %s.", project.getFullDisplayName(), project.getClass()));
this.project = project;
}
-
- public UnsupportedProjectException( final AbstractProject project, final String moreDetail )
- {
- super(String.format( "Unsupported project '%s' of type %s : %s.", project.getFullDisplayName(), project.getClass(), moreDetail));
+
+ public UnsupportedProjectException(final AbstractProject project, final String moreDetail) {
+ super(String.format("Unsupported project '%s' of type %s : %s.", project.getFullDisplayName(), project.getClass(), moreDetail));
this.project = project;
}
- public AbstractProject getProject()
- {
+ public AbstractProject getProject() {
return project;
}
}
diff --git a/hudson-service/src/main/java/org/hudsonci/events/EventConsumer.java b/hudson-service/src/main/java/org/hudsonci/events/EventConsumer.java
index ec13c3e..463488f 100644
--- a/hudson-service/src/main/java/org/hudsonci/events/EventConsumer.java
+++ b/hudson-service/src/main/java/org/hudsonci/events/EventConsumer.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -24,7 +24,7 @@ import java.util.EventObject;
* @author <a href="mailto:jason@planet57.com">Jason Dillon</a>
* @since 2.1.0
*/
-public interface EventConsumer
-{
+public interface EventConsumer {
+
void consume(EventObject event) throws Exception;
}
diff --git a/hudson-service/src/main/java/org/hudsonci/events/EventPublisher.java b/hudson-service/src/main/java/org/hudsonci/events/EventPublisher.java
index c97a74d..ecaf2ed 100644
--- a/hudson-service/src/main/java/org/hudsonci/events/EventPublisher.java
+++ b/hudson-service/src/main/java/org/hudsonci/events/EventPublisher.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -29,7 +29,7 @@ import java.util.EventObject;
* @since 2.1.0
*/
@ImplementedBy(EventPublisherImpl.class)
-public interface EventPublisher
-{
+public interface EventPublisher {
+
void publish(EventObject event);
}
diff --git a/hudson-service/src/main/java/org/hudsonci/events/internal/DiagnosticEventConsumer.java b/hudson-service/src/main/java/org/hudsonci/events/internal/DiagnosticEventConsumer.java
index a275ed5..899bd7b 100644
--- a/hudson-service/src/main/java/org/hudsonci/events/internal/DiagnosticEventConsumer.java
+++ b/hudson-service/src/main/java/org/hudsonci/events/internal/DiagnosticEventConsumer.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -33,8 +33,8 @@ import java.util.EventObject;
@Named
@Singleton
public class DiagnosticEventConsumer
- implements EventConsumer
-{
+ implements EventConsumer {
+
private static final Logger log = LoggerFactory.getLogger(DiagnosticEventConsumer.class);
public void consume(final EventObject event) throws Exception {
diff --git a/hudson-service/src/main/java/org/hudsonci/events/internal/EventPublisherImpl.java b/hudson-service/src/main/java/org/hudsonci/events/internal/EventPublisherImpl.java
index d80ca46..caf88cb 100644
--- a/hudson-service/src/main/java/org/hudsonci/events/internal/EventPublisherImpl.java
+++ b/hudson-service/src/main/java/org/hudsonci/events/internal/EventPublisherImpl.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -38,10 +38,9 @@ import static com.google.common.base.Preconditions.checkNotNull;
@Named
@Singleton
public class EventPublisherImpl
- implements EventPublisher
-{
- private static final Logger log = LoggerFactory.getLogger(EventPublisherImpl.class);
+ implements EventPublisher {
+ private static final Logger log = LoggerFactory.getLogger(EventPublisherImpl.class);
private final List<EventConsumer> consumers;
@Inject
@@ -67,11 +66,9 @@ public class EventPublisherImpl
try {
target.consume(event);
- }
- catch (Exception e) {
+ } catch (Exception e) {
log.error("Consumer raised an exception", e);
- }
- finally {
+ } finally {
Thread.currentThread().setContextClassLoader(cl);
}
}
diff --git a/hudson-service/src/main/java/org/hudsonci/events/ready/ReadyDetector.java b/hudson-service/src/main/java/org/hudsonci/events/ready/ReadyDetector.java
index aa7fd3f..81d213b 100644
--- a/hudson-service/src/main/java/org/hudsonci/events/ready/ReadyDetector.java
+++ b/hudson-service/src/main/java/org/hudsonci/events/ready/ReadyDetector.java
@@ -42,14 +42,11 @@ import static com.google.common.base.Preconditions.checkNotNull;
@Named
@Singleton
public class ReadyDetector
- extends Thread
-{
- private static final Logger log = LoggerFactory.getLogger(ReadyDetector.class);
+ extends Thread {
+ private static final Logger log = LoggerFactory.getLogger(ReadyDetector.class);
private final EventPublisher publisher;
-
private final Hudson hudson;
-
private final WebAppController controller;
@Inject
@@ -66,12 +63,10 @@ public class ReadyDetector
publisher.publish(new ReadyEvent(hudson));
log.info("Hudson is ready.");
break;
- }
- else {
+ } else {
try {
Thread.sleep(500);
- }
- catch (InterruptedException e) {
+ } catch (InterruptedException e) {
log.warn("Interrupted while waiting for initialization; ignoring", e);
}
}
@@ -113,8 +108,7 @@ public class ReadyDetector
Field field = filter.getClass().getDeclaredField("filter");
field.setAccessible(true);
return (Filter) field.get(filter);
- }
- catch (Exception e) {
+ } catch (Exception e) {
throw new Error("Failed to access HudsonFilter.filter delegate", e);
}
}
diff --git a/hudson-service/src/main/java/org/hudsonci/events/ready/ReadyDetectorStarter.java b/hudson-service/src/main/java/org/hudsonci/events/ready/ReadyDetectorStarter.java
index b4ad12c..4e7a2d4 100644
--- a/hudson-service/src/main/java/org/hudsonci/events/ready/ReadyDetectorStarter.java
+++ b/hudson-service/src/main/java/org/hudsonci/events/ready/ReadyDetectorStarter.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -38,10 +38,9 @@ import static com.google.common.base.Preconditions.checkNotNull;
@Singleton
@Priority(Integer.MIN_VALUE) // run last
public class ReadyDetectorStarter
- extends ItemListener
-{
- private static final Logger log = LoggerFactory.getLogger(ReadyDetectorStarter.class);
+ extends ItemListener {
+ private static final Logger log = LoggerFactory.getLogger(ReadyDetectorStarter.class);
// FIXME: Use of ItemListener for server life-cycle bits is a work around
private final ReadyDetector detector;
diff --git a/hudson-service/src/main/java/org/hudsonci/events/ready/ReadyEvent.java b/hudson-service/src/main/java/org/hudsonci/events/ready/ReadyEvent.java
index 48d159f..430a5bc 100644
--- a/hudson-service/src/main/java/org/hudsonci/events/ready/ReadyEvent.java
+++ b/hudson-service/src/main/java/org/hudsonci/events/ready/ReadyEvent.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -27,13 +27,13 @@ import java.util.EventObject;
* @since 2.1.0
*/
public class ReadyEvent
- extends EventObject
-{
+ extends EventObject {
+
public ReadyEvent(final Hudson hudson) {
super(hudson);
}
public Hudson getHudson() {
- return (Hudson)getSource();
+ return (Hudson) getSource();
}
}
diff --git a/hudson-service/src/main/java/org/hudsonci/service/BuildNotFoundException.java b/hudson-service/src/main/java/org/hudsonci/service/BuildNotFoundException.java
index 1f636cb..6fe5367 100644
--- a/hudson-service/src/main/java/org/hudsonci/service/BuildNotFoundException.java
+++ b/hudson-service/src/main/java/org/hudsonci/service/BuildNotFoundException.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -26,6 +26,7 @@ import hudson.model.AbstractBuild;
* @since 2.1.0
*/
public class BuildNotFoundException extends NotFoundException {
+
public BuildNotFoundException(String message) {
super(message);
}
diff --git a/hudson-service/src/main/java/org/hudsonci/service/BuildService.java b/hudson-service/src/main/java/org/hudsonci/service/BuildService.java
index 778438e..4955196 100644
--- a/hudson-service/src/main/java/org/hudsonci/service/BuildService.java
+++ b/hudson-service/src/main/java/org/hudsonci/service/BuildService.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -23,14 +23,12 @@ import hudson.model.AbstractBuild;
import hudson.model.AbstractProject;
/**
- * Operations on {@link AbstractBuild} instances.
- * <p>
- * The intent of these operations is that the build is or already has executed
- * and is available in the system.
- * <p>
- * Note: To schedule builds, see {@link ProjectService#scheduleBuild}. Since
- * scheduled builds have not necessarily been executed, that is intentionally
- * not an operation supported by this interface.
+ * Operations on {@link AbstractBuild} instances. <p> The intent of these
+ * operations is that the build is or already has executed and is available in
+ * the system. <p> Note: To schedule builds, see
+ * {@link ProjectService#scheduleBuild}. Since scheduled builds have not
+ * necessarily been executed, that is intentionally not an operation supported
+ * by this interface.
*
* @since 2.1.0
*/
@@ -41,12 +39,10 @@ public interface BuildService {
// TODO void getConsoleContent(AbstractProject<?, ?> project, int
// buildNumber);
// TODO void getTestResults(AbstractProject<?, ?> project, int buildNumber);
-
/**
* Delete a build from a project by buildNumber
*
- * <p>
- * The current thread context must have {@link hudson.model.Run#DELETE}
+ * <p> The current thread context must have {@link hudson.model.Run#DELETE}
* permission to perform this operation.
*
* @param project the project to the build belongs to
@@ -62,8 +58,7 @@ public interface BuildService {
/**
* Keep or release a build.
*
- * <p>
- * The current thread context must have {@link hudson.model.Run#UPDATE}
+ * <p> The current thread context must have {@link hudson.model.Run#UPDATE}
* permission to perform this operation.
*
* @param project the project to the build belongs to
@@ -80,8 +75,7 @@ public interface BuildService {
/**
* Stop or abort a build
*
- * <p>
- * The current thread context must have permission to abort the build.
+ * <p> The current thread context must have permission to abort the build.
*
* @param project the project to the build belongs to
* @param buildNumber the buildNumber to operate on which must be
@@ -134,5 +128,4 @@ public interface BuildService {
* project
*/
AbstractBuild getBuild(String projectName, int buildNumber);
-
}
diff --git a/hudson-service/src/main/java/org/hudsonci/service/DependencyGraphService.java b/hudson-service/src/main/java/org/hudsonci/service/DependencyGraphService.java
index da4fa16..dbfe215 100644
--- a/hudson-service/src/main/java/org/hudsonci/service/DependencyGraphService.java
+++ b/hudson-service/src/main/java/org/hudsonci/service/DependencyGraphService.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -32,6 +32,7 @@ import com.google.inject.ImplementedBy;
*/
@ImplementedBy(DependencyGraphServiceImpl.class)
public interface DependencyGraphService {
+
DependencyGraph getGraph();
void rebuild();
diff --git a/hudson-service/src/main/java/org/hudsonci/service/DescriptorService.java b/hudson-service/src/main/java/org/hudsonci/service/DescriptorService.java
index 88d6d38..f1b6f6d 100644
--- a/hudson-service/src/main/java/org/hudsonci/service/DescriptorService.java
+++ b/hudson-service/src/main/java/org/hudsonci/service/DescriptorService.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -40,5 +40,4 @@ public interface DescriptorService {
<T extends Describable<T>, D extends Descriptor<T>> DescriptorExtensionList<T, D> getDescriptorList(Class<T> type);
Descriptor getDescriptorOrDie(Class<? extends Describable> type);
-
}
diff --git a/hudson-service/src/main/java/org/hudsonci/service/NodeNotFoundException.java b/hudson-service/src/main/java/org/hudsonci/service/NodeNotFoundException.java
index 5c868b0..e319579 100644
--- a/hudson-service/src/main/java/org/hudsonci/service/NodeNotFoundException.java
+++ b/hudson-service/src/main/java/org/hudsonci/service/NodeNotFoundException.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -22,6 +22,7 @@ package org.hudsonci.service;
* @since 2.1.0
*/
public class NodeNotFoundException extends NotFoundException {
+
public NodeNotFoundException(String message) {
super(message);
}
diff --git a/hudson-service/src/main/java/org/hudsonci/service/NodeService.java b/hudson-service/src/main/java/org/hudsonci/service/NodeService.java
index b7474dd..d7a0860 100644
--- a/hudson-service/src/main/java/org/hudsonci/service/NodeService.java
+++ b/hudson-service/src/main/java/org/hudsonci/service/NodeService.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -32,6 +32,7 @@ import com.google.inject.ImplementedBy;
*/
@ImplementedBy(NodeServiceImpl.class)
public interface NodeService {
+
/**
* Get the node with the given name.
*
@@ -71,9 +72,9 @@ public interface NodeService {
List<Node> getAllNodes();
/**
- * @returns all {@link Node}s in the system, excluding {@link hudson.model.Hudson}
- * instance itself which represents the master, that have
- * {@link hudson.model.Item#READ} permission.
+ * @returns all {@link Node}s in the system, excluding
+ * {@link hudson.model.Hudson} instance itself which represents the master,
+ * that have {@link hudson.model.Item#READ} permission.
*/
List<Node> getNodes();
diff --git a/hudson-service/src/main/java/org/hudsonci/service/NotFoundException.java b/hudson-service/src/main/java/org/hudsonci/service/NotFoundException.java
index d239d8a..27820eb 100644
--- a/hudson-service/src/main/java/org/hudsonci/service/NotFoundException.java
+++ b/hudson-service/src/main/java/org/hudsonci/service/NotFoundException.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -18,22 +18,19 @@ package org.hudsonci.service;
/**
* Thrown when a system entity that is needed to perform a service level action
- * cannot be found within the system.
- * <p>
- * An example of where this may be useful is when a source project identified by
- * a project name may not exist any more, and therefore cannot be copied to a
- * new project. Also, typically of the service APIs, all {@literal get*} methods
- * may throw this when an entity is not found.
- * <p>
- * Extend this class with a specific implementation for each type of system
- * entity that may not be found.
- * <p>
- * Service API users should do their best to verify an entity exists prior to
- * performing an operation that may trigger this exception.
+ * cannot be found within the system. <p> An example of where this may be useful
+ * is when a source project identified by a project name may not exist any more,
+ * and therefore cannot be copied to a new project. Also, typically of the
+ * service APIs, all {@literal get*} methods may throw this when an entity is
+ * not found. <p> Extend this class with a specific implementation for each type
+ * of system entity that may not be found. <p> Service API users should do their
+ * best to verify an entity exists prior to performing an operation that may
+ * trigger this exception.
*
* @since 2.1.0
*/
public abstract class NotFoundException extends ServiceRuntimeException {
+
protected NotFoundException() {
}
diff --git a/hudson-service/src/main/java/org/hudsonci/service/ProjectNotFoundException.java b/hudson-service/src/main/java/org/hudsonci/service/ProjectNotFoundException.java
index 912e3ea..dbcb927 100644
--- a/hudson-service/src/main/java/org/hudsonci/service/ProjectNotFoundException.java
+++ b/hudson-service/src/main/java/org/hudsonci/service/ProjectNotFoundException.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -19,21 +19,20 @@ package org.hudsonci.service;
import hudson.model.AbstractProject;
/**
- * Thrown when an {@link AbstractProject} is needed to perform an operation, but could not be located.
+ * Thrown when an {@link AbstractProject} is needed to perform an operation, but
+ * could not be located.
*
* @author plynch
* @since 2.1.0
*/
public class ProjectNotFoundException
- extends NotFoundException
-{
- public ProjectNotFoundException(String message)
- {
+ extends NotFoundException {
+
+ public ProjectNotFoundException(String message) {
super(message);
}
- public ProjectNotFoundException(String message, Throwable cause)
- {
+ public ProjectNotFoundException(String message, Throwable cause) {
super(message, cause);
}
}
diff --git a/hudson-service/src/main/java/org/hudsonci/service/ProjectService.java b/hudson-service/src/main/java/org/hudsonci/service/ProjectService.java
index 0d521ab..1a65e02 100644
--- a/hudson-service/src/main/java/org/hudsonci/service/ProjectService.java
+++ b/hudson-service/src/main/java/org/hudsonci/service/ProjectService.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -29,20 +29,22 @@ import java.util.UUID;
import org.hudsonci.service.internal.ProjectServiceImpl;
/**
- * Service API related to Projects and Job models, such as that by {@link AbstractProject}.
+ * Service API related to Projects and Job models, such as that by
+ * {@link AbstractProject}.
*
* @author plynch
* @since 2.1.0
*/
@ImplementedBy(ProjectServiceImpl.class)
-public interface ProjectService
-{
+public interface ProjectService {
+
/**
* Get the project identified by a UUID.
*
* @param id UUID identifier of the project to get
* @return the project associated with the UUID
- * @throws ProjectNotFoundException if a project cannot be found for the given UUID
+ * @throws ProjectNotFoundException if a project cannot be found for the
+ * given UUID
*/
AbstractProject<?, ?> getProject(final UUID id);
@@ -57,44 +59,48 @@ public interface ProjectService
/**
* Get the project identified by a full project name.
*
- * The current thread context must have {@link Item#READ} permission on the project in order to
- * get it.
+ * The current thread context must have {@link Item#READ} permission on the
+ * project in order to get it.
*
- * @param projectFullName full project name as reported by {@link AbstractProject#getFullName}
+ * @param projectFullName full project name as reported by
+ * {@link AbstractProject#getFullName}
* @return the project associated with projectFullName
- * @throws ProjectNotFoundException if a project with the specified full name does not exist
+ * @throws ProjectNotFoundException if a project with the specified full
+ * name does not exist
*/
AbstractProject<?, ?> getProjectByFullName(String projectFullName);
/**
* Find the project identified by a full project name.
*
- * The current thread context must have {@link Item#READ} permission on the project in order to
- * find it.
+ * The current thread context must have {@link Item#READ} permission on the
+ * project in order to find it.
*
- * @param projectFullName full project name as reported by {@link AbstractProject#getFullName}
+ * @param projectFullName full project name as reported by
+ * {@link AbstractProject#getFullName}
* @return the project associated with projectFullName or null if not found
*/
AbstractProject<?, ?> findProjectByFullName(String projectFullName);
/**
- * Check if a project with given name as reported by {@link AbstractProject#getName}
- * already exists in the system.
+ * Check if a project with given name as reported by
+ * {@link AbstractProject#getName} already exists in the system.
*
- * In order to determine if a project exists, the current thread context must have {@link Item#READ}
- * permission on it.
+ * In order to determine if a project exists, the current thread context
+ * must have {@link Item#READ} permission on it.
*
* @param projectName project name to lookup
- * @return true if a project with the specified name is readable and exists in the system
+ * @return true if a project with the specified name is readable and exists
+ * in the system
*/
boolean projectExists(String projectName);
/**
* Get a list of all projects of a specific {@literal type} in the system.
*
- * <p>The current thread must have {@link Item#READ} permission
- * on each project returned and {@link Item#READ} permission on the {@link hudson.model.Node}
- * where the projects reside.
+ * <p>The current thread must have {@link Item#READ} permission on each
+ * project returned and {@link Item#READ} permission on the
+ * {@link hudson.model.Node} where the projects reside.
*
* @return a list of all projects implemented by type T
*/
@@ -102,65 +108,79 @@ public interface ProjectService
List<AbstractProject> getAllProjects();
/**
- * Copy a source project to a new project which will be named the
- * value of {@literal targetProjectName}
+ * Copy a source project to a new project which will be named the value of
+ * {@literal targetProjectName}
*
- * <p>The current thread must have {@link Item#EXTENDED_READ} permission
- * on {@literal src} and {@link Item#CREATE} permission on the {@link hudson.model.Node}
- * where the project will be copied too, in order for the operation to succeed.
+ * <p>The current thread must have {@link Item#EXTENDED_READ} permission on
+ * {@literal src} and {@link Item#CREATE} permission on the
+ * {@link hudson.model.Node} where the project will be copied too, in order
+ * for the operation to succeed.
*
* @param <T> the type of new target project
* @param src source project to copy from
* @param targetProjectName the name to create the new project with
* @return the newly created target project
- * @throws SystemIntegrityViolationException if a project already exists with the targetProjectName
- * @throws ServiceRuntimeException if there was an unexpected problem creating the project
+ * @throws SystemIntegrityViolationException if a project already exists
+ * with the targetProjectName
+ * @throws ServiceRuntimeException if there was an unexpected problem
+ * creating the project
*/
<T extends AbstractProject<?, ?>> T copyProject(T src, String targetProjectName);
/**
* Create a new project in the system from XML.
*
- * <p>The current thread must have {@link hudson.model.Item#CREATE} permission on the
- * {@link hudson.model.Node} where the project will created, in order for the operation to
- * succeed.
+ * <p>The current thread must have {@link hudson.model.Item#CREATE}
+ * permission on the {@link hudson.model.Node} where the project will
+ * created, in order for the operation to succeed.
*
- * <p>Buffering or closing of the InputStream should be done outside of this method.
+ * <p>Buffering or closing of the InputStream should be done outside of this
+ * method.
*
* @param projectName the name of the new project.
* @param xml XML document describing the new project
- * @return a {@link hudson.model.TopLevelItem} representing the newly created project
- * @throws SystemIntegrityViolationException if a project already exists with projectName
- * @throws ServiceRuntimeException if there was an unexpected problem creating the project
+ * @return a {@link hudson.model.TopLevelItem} representing the newly
+ * created project
+ * @throws SystemIntegrityViolationException if a project already exists
+ * with projectName
+ * @throws ServiceRuntimeException if there was an unexpected problem
+ * creating the project
*/
TopLevelItem createProjectFromXML(String projectName, InputStream xml);
/**
- * Find and return a project with the given name ( as defined by {@link AbstractProject#getName} )
- * , or return {@literal null} if one cannot be found.
+ * Find and return a project with the given name ( as defined by
+ * {@link AbstractProject#getName} ) , or return {@literal null} if one
+ * cannot be found.
*
- * <p>The current thread context must have {@link Item#READ} permission on the project in order to find it.
+ * <p>The current thread context must have {@link Item#READ} permission on
+ * the project in order to find it.
*
* @param projectName
- * @return a project for the specified name if it is readable and exists, otherwise null
+ * @return a project for the specified name if it is readable and exists,
+ * otherwise null
*/
- AbstractProject<?,?> findProject(String projectName);
+ AbstractProject<?, ?> findProject(String projectName);
/**
- * Tries to find a project with the given name as defined by {@link AbstractProject#getName}.
+ * Tries to find a project with the given name as defined by
+ * {@link AbstractProject#getName}.
*
- * <p>The current thread context must have {@link Item#READ} permission on the project in order to find it.
+ * <p>The current thread context must have {@link Item#READ} permission on
+ * the project in order to find it.
*
* @param projectName the project name for the project
- * @return an AbstractProject for the specified name if one exists, never null
+ * @return an AbstractProject for the specified name if one exists, never
+ * null
* @throws ProjectNotFoundException if the project cannot be found
*/
- AbstractProject<?,?> getProject(String projectName);
+ AbstractProject<?, ?> getProject(String projectName);
/**
* Return a collection of all project names in the system.
*
- * <p>{@link Item#READ} access is required to return a job name in the collection.
+ * <p>{@link Item#READ} access is required to return a job name in the
+ * collection.
*
* @return a collection, never null, of all project names in the system
*/
diff --git a/hudson-service/src/main/java/org/hudsonci/service/QueueService.java b/hudson-service/src/main/java/org/hudsonci/service/QueueService.java
index 9fc6994..a0f413b 100644
--- a/hudson-service/src/main/java/org/hudsonci/service/QueueService.java
+++ b/hudson-service/src/main/java/org/hudsonci/service/QueueService.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -28,13 +28,14 @@ import org.hudsonci.service.internal.QueueServiceImpl;
* @since 2.1.0
*/
@ImplementedBy(QueueServiceImpl.class)
-public interface QueueService
-{
+public interface QueueService {
+
/**
* Get the queue.
*
* @return the master {@link Queue}
- * @throws AccessDeniedException if current context does not have {@link Hudson#ADMINISTER} permission.
+ * @throws AccessDeniedException if current context does not have
+ * {@link Hudson#ADMINISTER} permission.
*/
Queue getQueue();
}
diff --git a/hudson-service/src/main/java/org/hudsonci/service/ScriptService.java b/hudson-service/src/main/java/org/hudsonci/service/ScriptService.java
index 72c99e7..4a59e35 100644
--- a/hudson-service/src/main/java/org/hudsonci/service/ScriptService.java
+++ b/hudson-service/src/main/java/org/hudsonci/service/ScriptService.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -27,12 +27,11 @@ import com.google.inject.ImplementedBy;
* @since 2.1.0
*/
@ImplementedBy(ScriptServiceImpl.class)
-public interface ScriptService
-{
+public interface ScriptService {
+
/**
* Execute a script on the master.
*/
String execute(String script) throws Exception;
-
// TODO: Add execution for a specific node
}
diff --git a/hudson-service/src/main/java/org/hudsonci/service/SecurityService.java b/hudson-service/src/main/java/org/hudsonci/service/SecurityService.java
index 53a1772..27b953f 100644
--- a/hudson-service/src/main/java/org/hudsonci/service/SecurityService.java
+++ b/hudson-service/src/main/java/org/hudsonci/service/SecurityService.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -35,6 +35,7 @@ import com.google.inject.ImplementedBy;
*/
@ImplementedBy(SecurityServiceImpl.class)
public interface SecurityService {
+
/**
* Check a Permission against {@link hudson.model.Hudson} for the current
* user.
@@ -47,11 +48,10 @@ public interface SecurityService {
void checkPermission(Permission permission);
/**
- * Check a Permission against an {@link AccessControlled} object in the current
- * security context.
- * <p>
- * Recommended to use this instead of checking permission on the object
- * directly. Consider this method a funnel for access security.
+ * Check a Permission against an {@link AccessControlled} object in the
+ * current security context. <p> Recommended to use this instead of checking
+ * permission on the object directly. Consider this method a funnel for
+ * access security.
*
* @param controlled the instance under control
* @param permission the permission to check on the access controlled object
@@ -60,10 +60,9 @@ public interface SecurityService {
/**
* Check if a an {@link AccessControlled} instance will allow the current
- * security context the specified {@link Permission}.
- * <p>
- * Recommended to use this instead of checking has permission on the object
- * directly. Consider this method a funnel for access security.
+ * security context the specified {@link Permission}. <p> Recommended to use
+ * this instead of checking has permission on the object directly. Consider
+ * this method a funnel for access security.
*
* @param controlled the instance under control
* @param permission the permission to check on the access controlled object
diff --git a/hudson-service/src/main/java/org/hudsonci/service/ServiceRuntimeException.java b/hudson-service/src/main/java/org/hudsonci/service/ServiceRuntimeException.java
index b9e0c45..795d8e0 100644
--- a/hudson-service/src/main/java/org/hudsonci/service/ServiceRuntimeException.java
+++ b/hudson-service/src/main/java/org/hudsonci/service/ServiceRuntimeException.java
@@ -7,25 +7,25 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
package org.hudsonci.service;
/**
- * Base class of all service layer {@link RuntimeException}s.
- * <p>
- * Generally the service layer API should only throw unchecked exceptions that extend this base class.
+ * Base class of all service layer {@link RuntimeException}s. <p> Generally the
+ * service layer API should only throw unchecked exceptions that extend this
+ * base class.
*
* @since 2.1.0
*/
public class ServiceRuntimeException
- extends RuntimeException
-{
+ extends RuntimeException {
+
public ServiceRuntimeException() {
}
diff --git a/hudson-service/src/main/java/org/hudsonci/service/SystemIntegrityViolationException.java b/hudson-service/src/main/java/org/hudsonci/service/SystemIntegrityViolationException.java
index 8942671..fd44f40 100644
--- a/hudson-service/src/main/java/org/hudsonci/service/SystemIntegrityViolationException.java
+++ b/hudson-service/src/main/java/org/hudsonci/service/SystemIntegrityViolationException.java
@@ -7,25 +7,25 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
package org.hudsonci.service;
/**
- * Thrown when the integrity of the system would be compromised if
- * a requested operation was allowed to proceed.
+ * Thrown when the integrity of the system would be compromised if a requested
+ * operation was allowed to proceed.
*
* @author plynch
* @since 2.1.0
*/
public class SystemIntegrityViolationException
- extends ServiceRuntimeException
-{
+ extends ServiceRuntimeException {
+
public SystemIntegrityViolationException() {
}
diff --git a/hudson-service/src/main/java/org/hudsonci/service/SystemService.java b/hudson-service/src/main/java/org/hudsonci/service/SystemService.java
index c383a51..04d0b34 100644
--- a/hudson-service/src/main/java/org/hudsonci/service/SystemService.java
+++ b/hudson-service/src/main/java/org/hudsonci/service/SystemService.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -28,20 +28,22 @@ import org.hudsonci.service.internal.SystemServiceImpl;
/**
* General system access.
*
- * <p>All operations involving restarting, quiet down, or reloading the system require {@link Hudson#ADMINISTER} permission.
+ * <p>All operations involving restarting, quiet down, or reloading the system
+ * require {@link Hudson#ADMINISTER} permission.
*
* @author plynch
* @since 2.1.0
*/
@ImplementedBy(SystemServiceImpl.class)
-public interface SystemService
-{
+public interface SystemService {
+
String DEFAULT_URL = "http://localhost:8082";
/**
* The installation location.
*
- * @throws IllegalStateException when the installation directory cannot be reliably determined
+ * @throws IllegalStateException when the installation directory cannot be
+ * reliably determined
*/
File getInstallationDirectory();
@@ -54,17 +56,20 @@ public interface SystemService
/**
* The default location where the server will store log files.
*
- * @throws IllegalStateException if the log directory cannot be reliably determined
+ * @throws IllegalStateException if the log directory cannot be reliably
+ * determined
*/
File getLogDirectory();
/**
* Return the {@link XmlFile} representation of the system config file
*
- * The current thread requires {@link Hudson#ADMINISTER} permission to get the file.
+ * The current thread requires {@link Hudson#ADMINISTER} permission to get
+ * the file.
*
* @return XmlFile representation of the system config file,
- * @throws ServiceRuntimeException if there is an unexpected problem accessing the config file.
+ * @throws ServiceRuntimeException if there is an unexpected problem
+ * accessing the config file.
*/
XmlFile getConfigFile();
@@ -77,7 +82,6 @@ public interface SystemService
String getSystemMessage();
// FIXME: Drop do* prefix on these methods. do* is specific to stapler and should be dropped from the service API
-
boolean isQuietingDown();
void doQuietDown(boolean toggle);
diff --git a/hudson-service/src/main/java/org/hudsonci/service/internal/BuildServiceImpl.java b/hudson-service/src/main/java/org/hudsonci/service/internal/BuildServiceImpl.java
index e74e765..c3db007 100644
--- a/hudson-service/src/main/java/org/hudsonci/service/internal/BuildServiceImpl.java
+++ b/hudson-service/src/main/java/org/hudsonci/service/internal/BuildServiceImpl.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -46,6 +46,7 @@ import com.google.common.base.Preconditions;
@Named
@Singleton
public class BuildServiceImpl extends ServiceSupport implements BuildService {
+
private final ProjectService projects;
private final SecurityService security;
@@ -87,7 +88,7 @@ public class BuildServiceImpl extends ServiceSupport implements BuildService {
return getBuild(project, buildNumber);
}
- public AbstractBuild<?, ?> getBuild(final AbstractProject<?,?> project, final int buildNumber)
+ public AbstractBuild<?, ?> getBuild(final AbstractProject<?, ?> project, final int buildNumber)
throws BuildNotFoundException {
AbstractBuild<?, ?> build = findBuild(project, buildNumber);
if (build == null) {
@@ -104,11 +105,11 @@ public class BuildServiceImpl extends ServiceSupport implements BuildService {
return project != null ? findBuild(project, buildNumber) : null;
}
- public AbstractBuild<?,?> findBuild(final AbstractProject<?, ?> project, final int buildNumber) {
+ public AbstractBuild<?, ?> findBuild(final AbstractProject<?, ?> project, final int buildNumber) {
checkNotNull(project, "project");
checkBuildNumber(buildNumber);
- AbstractBuild<?,?> build = project.getBuildByNumber(buildNumber);
+ AbstractBuild<?, ?> build = project.getBuildByNumber(buildNumber);
if (build != null) {
this.security.checkPermission(build, Item.READ);
@@ -117,7 +118,7 @@ public class BuildServiceImpl extends ServiceSupport implements BuildService {
return build;
}
- public void stopBuild(final AbstractProject<?, ?> project, final int buildNumber){
+ public void stopBuild(final AbstractProject<?, ?> project, final int buildNumber) {
AbstractBuild<?, ?> build = getBuild(project, buildNumber);
log.debug("Stopping build: {} #{}", project.getName(), buildNumber);
try {
@@ -129,5 +130,4 @@ public class BuildServiceImpl extends ServiceSupport implements BuildService {
throw new ServiceRuntimeException("Stop failed for " + project.getName() + " #" + buildNumber, e);
}
}
-
}
diff --git a/hudson-service/src/main/java/org/hudsonci/service/internal/DependencyGraphServiceImpl.java b/hudson-service/src/main/java/org/hudsonci/service/internal/DependencyGraphServiceImpl.java
index 4743bbc..e8b527b 100644
--- a/hudson-service/src/main/java/org/hudsonci/service/internal/DependencyGraphServiceImpl.java
+++ b/hudson-service/src/main/java/org/hudsonci/service/internal/DependencyGraphServiceImpl.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -27,7 +27,6 @@ import javax.inject.Singleton;
import org.hudsonci.service.DependencyGraphService;
-
/**
* Default implementation of {@link DependencyGraphService}.
*
diff --git a/hudson-service/src/main/java/org/hudsonci/service/internal/DescriptorServiceImpl.java b/hudson-service/src/main/java/org/hudsonci/service/internal/DescriptorServiceImpl.java
index 4085b59..4834a73 100644
--- a/hudson-service/src/main/java/org/hudsonci/service/internal/DescriptorServiceImpl.java
+++ b/hudson-service/src/main/java/org/hudsonci/service/internal/DescriptorServiceImpl.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -38,6 +38,7 @@ import org.hudsonci.service.DescriptorService;
@Named
@Singleton
public class DescriptorServiceImpl extends ServiceSupport implements DescriptorService {
+
@Inject
DescriptorServiceImpl() {
}
@@ -67,5 +68,4 @@ public class DescriptorServiceImpl extends ServiceSupport implements DescriptorS
checkNotNull(type, "type");
return getHudson().getDescriptorList(type);
}
-
}
diff --git a/hudson-service/src/main/java/org/hudsonci/service/internal/DummyStaplerRequest.java b/hudson-service/src/main/java/org/hudsonci/service/internal/DummyStaplerRequest.java
index 481ef52..92c60b0 100644
--- a/hudson-service/src/main/java/org/hudsonci/service/internal/DummyStaplerRequest.java
+++ b/hudson-service/src/main/java/org/hudsonci/service/internal/DummyStaplerRequest.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -50,8 +50,8 @@ import org.kohsuke.stapler.bind.BoundObjectTable;
* @since 2.1.0
*/
public class DummyStaplerRequest
- implements StaplerRequest
-{
+ implements StaplerRequest {
+
public static final DummyStaplerRequest INSTANCE = new DummyStaplerRequest();
public Stapler getStapler() {
diff --git a/hudson-service/src/main/java/org/hudsonci/service/internal/DummyStaplerResponse.java b/hudson-service/src/main/java/org/hudsonci/service/internal/DummyStaplerResponse.java
index 9bb6d55..f911603 100644
--- a/hudson-service/src/main/java/org/hudsonci/service/internal/DummyStaplerResponse.java
+++ b/hudson-service/src/main/java/org/hudsonci/service/internal/DummyStaplerResponse.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -39,10 +39,10 @@ import java.util.Locale;
* @since 2.1.0
*/
public class DummyStaplerResponse
- implements StaplerResponse
-{
+ implements StaplerResponse {
+
public static final DummyStaplerResponse INSTANCE = new DummyStaplerResponse();
-
+
public void forward(Object it, String url, StaplerRequest request) throws ServletException, IOException {
}
@@ -65,23 +65,19 @@ public class DummyStaplerResponse
}
public void serveFile(StaplerRequest req, InputStream data, long lastModified, long expiration, long contentLength, String fileName) throws
- ServletException, IOException
- {
+ ServletException, IOException {
}
public void serveFile(StaplerRequest req, InputStream data, long lastModified, long expiration, int contentLength, String fileName) throws
- ServletException, IOException
- {
+ ServletException, IOException {
}
public void serveFile(StaplerRequest req, InputStream data, long lastModified, long contentLength, String fileName) throws
- ServletException, IOException
- {
+ ServletException, IOException {
}
public void serveFile(StaplerRequest req, InputStream data, long lastModified, int contentLength, String fileName) throws
- ServletException, IOException
- {
+ ServletException, IOException {
}
public void serveExposedBean(StaplerRequest req, Object exposedBean, Flavor flavor) throws ServletException, IOException {
diff --git a/hudson-service/src/main/java/org/hudsonci/service/internal/NodeServiceImpl.java b/hudson-service/src/main/java/org/hudsonci/service/internal/NodeServiceImpl.java
index 8246b28..1b43a36 100644
--- a/hudson-service/src/main/java/org/hudsonci/service/internal/NodeServiceImpl.java
+++ b/hudson-service/src/main/java/org/hudsonci/service/internal/NodeServiceImpl.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -107,5 +107,4 @@ public class NodeServiceImpl extends ServiceSupport implements NodeService {
this.security.checkPermission(node, Permission.READ);
return node;
}
-
}
diff --git a/hudson-service/src/main/java/org/hudsonci/service/internal/ProjectServiceImpl.java b/hudson-service/src/main/java/org/hudsonci/service/internal/ProjectServiceImpl.java
index c24999c..ac52553 100644
--- a/hudson-service/src/main/java/org/hudsonci/service/internal/ProjectServiceImpl.java
+++ b/hudson-service/src/main/java/org/hudsonci/service/internal/ProjectServiceImpl.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -43,7 +43,6 @@ import org.hudsonci.utils.tasks.JobUuid;
import com.google.common.base.Preconditions;
-
/**
* Default {@link ProjectService} implementation.
*
@@ -52,6 +51,7 @@ import com.google.common.base.Preconditions;
@Named
@Singleton
public class ProjectServiceImpl extends ServiceSupport implements ProjectService {
+
private final SecurityService securityService;
@Inject
@@ -59,7 +59,6 @@ public class ProjectServiceImpl extends ServiceSupport implements ProjectService
this.securityService = Preconditions.checkNotNull(securityService);
}
-
public AbstractProject<?, ?> getProject(final UUID id) {
AbstractProject<?, ?> project = findProject(id);
if (project == null) {
@@ -185,5 +184,4 @@ public class ProjectServiceImpl extends ServiceSupport implements ProjectService
// Hudson only returns jobnames when the current context has Item.READ perms on it
return getHudson().getJobNames();
}
-
}
diff --git a/hudson-service/src/main/java/org/hudsonci/service/internal/QueueServiceImpl.java b/hudson-service/src/main/java/org/hudsonci/service/internal/QueueServiceImpl.java
index 24e9bd1..15fe1b7 100644
--- a/hudson-service/src/main/java/org/hudsonci/service/internal/QueueServiceImpl.java
+++ b/hudson-service/src/main/java/org/hudsonci/service/internal/QueueServiceImpl.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -36,9 +36,9 @@ import org.hudsonci.service.SecurityService;
@Named
@Singleton
public class QueueServiceImpl
- extends ServiceSupport
- implements QueueService
-{
+ extends ServiceSupport
+ implements QueueService {
+
private final SecurityService security;
@Inject
diff --git a/hudson-service/src/main/java/org/hudsonci/service/internal/ScriptServiceImpl.java b/hudson-service/src/main/java/org/hudsonci/service/internal/ScriptServiceImpl.java
index e004ef5..1db5629 100644
--- a/hudson-service/src/main/java/org/hudsonci/service/internal/ScriptServiceImpl.java
+++ b/hudson-service/src/main/java/org/hudsonci/service/internal/ScriptServiceImpl.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -39,9 +39,9 @@ import static com.google.common.base.Preconditions.checkNotNull;
@Named
@Singleton
public class ScriptServiceImpl
- extends ServiceSupport
- implements ScriptService
-{
+ extends ServiceSupport
+ implements ScriptService {
+
private final SecurityService security;
@Inject
diff --git a/hudson-service/src/main/java/org/hudsonci/service/internal/SecurityServiceImpl.java b/hudson-service/src/main/java/org/hudsonci/service/internal/SecurityServiceImpl.java
index 43b36dd..53a4a58 100644
--- a/hudson-service/src/main/java/org/hudsonci/service/internal/SecurityServiceImpl.java
+++ b/hudson-service/src/main/java/org/hudsonci/service/internal/SecurityServiceImpl.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -40,9 +40,9 @@ import static com.google.common.base.Preconditions.checkNotNull;
@Named
@Singleton
public class SecurityServiceImpl
- extends ServiceSupport
- implements SecurityService
-{
+ extends ServiceSupport
+ implements SecurityService {
+
@Inject
SecurityServiceImpl() {
super();
@@ -73,8 +73,7 @@ public class SecurityServiceImpl
ctx.setAuthentication(auth);
try {
task.run();
- }
- finally {
+ } finally {
ctx.setAuthentication(current);
}
}
@@ -87,8 +86,7 @@ public class SecurityServiceImpl
ctx.setAuthentication(auth);
try {
return task.call();
- }
- finally {
+ } finally {
ctx.setAuthentication(current);
}
}
@@ -96,8 +94,7 @@ public class SecurityServiceImpl
public <T> T callAs2(final Authentication auth, final Callable<T> task) {
try {
return callAs(auth, task);
- }
- catch (Exception e) {
+ } catch (Exception e) {
if (e instanceof RuntimeException) {
throw (RuntimeException) e;
}
diff --git a/hudson-service/src/main/java/org/hudsonci/service/internal/ServicePreconditions.java b/hudson-service/src/main/java/org/hudsonci/service/internal/ServicePreconditions.java
index 57f8ae8..c9469a0 100644
--- a/hudson-service/src/main/java/org/hudsonci/service/internal/ServicePreconditions.java
+++ b/hudson-service/src/main/java/org/hudsonci/service/internal/ServicePreconditions.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -75,7 +75,8 @@ public abstract class ServicePreconditions {
}
/**
- * Check the projectName of an {@link hudson.model.AbstractProject} for shallow validity
+ * Check the projectName of an {@link hudson.model.AbstractProject} for
+ * shallow validity
*
* @param projectName the project name to check
* @return the unmodified projectName if not null
@@ -98,8 +99,8 @@ public abstract class ServicePreconditions {
}
/**
- * Check a {@link org.hudsonci.rest.model.DocumentDTO} ID (UUID) for
- * shallow validity
+ * Check a {@link org.hudsonci.rest.model.DocumentDTO} ID (UUID) for shallow
+ * validity
*
* @param id the Document id to check
* @return the unmodified document id
@@ -140,11 +141,9 @@ public abstract class ServicePreconditions {
/**
* IF the passed reference is null, throws a NullPointerException with
- * appropriate message.
- * <p>
- * While not itself a precondition, this is a common operation if a
- * precondition fails and can be used when custom validation was performed
- * for a rest argument.
+ * appropriate message. <p> While not itself a precondition, this is a
+ * common operation if a precondition fails and can be used when custom
+ * validation was performed for a rest argument.
*
* @param <T> reference to a value to check for null
* @param reference reference to a value to check for null
diff --git a/hudson-service/src/main/java/org/hudsonci/service/internal/ServiceSupport.java b/hudson-service/src/main/java/org/hudsonci/service/internal/ServiceSupport.java
index 9e3bb34..d4c4d33 100644
--- a/hudson-service/src/main/java/org/hudsonci/service/internal/ServiceSupport.java
+++ b/hudson-service/src/main/java/org/hudsonci/service/internal/ServiceSupport.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -27,23 +27,20 @@ import static com.google.common.base.Preconditions.checkNotNull;
/**
* Base Hudson Service from which all service implementations should extend.
*
- * <p>Common {@literal preconditions} of service implementation methods
- * include:
+ * <p>Common {@literal preconditions} of service implementation methods include:
*
- * <ul>
- * <li>throw a {@link NullPointerException} if a null object
- * reference is passed in any parameter.
- * <li>throw an {@link org.springframework.security.AccessDeniedException} if the current thread context does not hold a required authority
- * to perform an operation
+ * <ul> <li>throw a {@link NullPointerException} if a null object reference is
+ * passed in any parameter. <li>throw an
+ * {@link org.springframework.security.AccessDeniedException} if the current
+ * thread context does not hold a required authority to perform an operation
* </ul>
*
* @author plynch
* @since 2.1.0
*/
-public abstract class ServiceSupport
-{
- protected final Logger log = LoggerFactory.getLogger(getClass());
+public abstract class ServiceSupport {
+ protected final Logger log = LoggerFactory.getLogger(getClass());
private Hudson hudson;
@Inject
@@ -51,8 +48,7 @@ public abstract class ServiceSupport
this.hudson = checkNotNull(hudson);
}
- protected Hudson getHudson()
- {
+ protected Hudson getHudson() {
return hudson;
}
}
diff --git a/hudson-service/src/main/java/org/hudsonci/service/internal/SystemServiceImpl.java b/hudson-service/src/main/java/org/hudsonci/service/internal/SystemServiceImpl.java
index 0ede321..4f7110f 100644
--- a/hudson-service/src/main/java/org/hudsonci/service/internal/SystemServiceImpl.java
+++ b/hudson-service/src/main/java/org/hudsonci/service/internal/SystemServiceImpl.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -48,9 +48,9 @@ import static com.google.common.base.Preconditions.checkNotNull;
@Named
@Singleton
public class SystemServiceImpl
- extends ServiceSupport
- implements SystemService
-{
+ extends ServiceSupport
+ implements SystemService {
+
private final SecurityService securityService;
@Inject
@@ -71,8 +71,7 @@ public class SystemServiceImpl
// Jar containing Launcher is expected in <install>/lib/some.jar (so .jar file - lib dir - should get us the install dir)
dir = dir.getParentFile().getParentFile();
dir = FileUtil.canonicalize(dir);
- }
- catch (NullPointerException e) {
+ } catch (NullPointerException e) {
throw new IllegalStateException("Could not reliably determine the installation directory", e);
}
return dir;
@@ -91,142 +90,112 @@ public class SystemServiceImpl
return getHudson().getRootDir();
}
- public XmlFile getConfigFile()
- {
+ public XmlFile getConfigFile() {
securityService.checkPermission(Hudson.ADMINISTER);
// Hudson.getConfigFile() is not public, so we have to duplicate some muck here
File f = new File(getWorkingDirectory(), "config.xml");
return new XmlFile(Hudson.XSTREAM, f);
}
- public String getUrl()
- {
+ public String getUrl() {
String url = getHudson().getRootUrl();
if (url == null) {
log.warn("Underlying Hudson root url is null; using DEFAULT_URL");
url = DEFAULT_URL;
- }
- else if (url.endsWith("/")) {
+ } else if (url.endsWith("/")) {
url = url.substring(0, url.length() - 1);
}
return url;
}
- public String getVersion()
- {
+ public String getVersion() {
return Hudson.getVersion().toString();
}
- public InitMilestone getInitLevel()
- {
+ public InitMilestone getInitLevel() {
return getHudson().getInitLevel();
}
- public boolean isQuietingDown()
- {
+ public boolean isQuietingDown() {
return getHudson().isQuietingDown();
}
- public boolean isTerminating()
- {
+ public boolean isTerminating() {
return getHudson().isTerminating();
}
- public String getSystemMessage()
- {
+ public String getSystemMessage() {
return getHudson().getSystemMessage();
}
- public void doQuietDown()
- {
+ public void doQuietDown() {
//securityService.checkPermission(Hudson.ADMINISTER);
- try{getHudson().doQuietDown();}catch(final IOException e){}
+ try {
+ getHudson().doQuietDown();
+ } catch (final IOException e) {
+ }
}
- public void doQuietDown(boolean toggle)
- {
+ public void doQuietDown(boolean toggle) {
//securityService.checkPermission(Hudson.ADMINISTER);
- if (toggle)
- {
+ if (toggle) {
log.debug("Quieting down");
doQuietDown();
- }
- else
- {
+ } else {
log.debug("Canceling quiet down");
doCancelQuietDown();
}
}
- public void doCancelQuietDown()
- {
+ public void doCancelQuietDown() {
//securityService.checkPermission(Hudson.ADMINISTER);
getHudson().doCancelQuietDown();
}
- public void doReload()
- {
+ public void doReload() {
//securityService.checkPermission(Hudson.ADMINISTER);
log.debug("Reloading configuration");
- try
- {
+ try {
getHudson().doReload();
- }
- catch (IOException ex)
- {
+ } catch (IOException ex) {
throw new ServiceRuntimeException("Could not reload.", ex);
}
}
- public void doRestart(boolean safely)
- {
+ public void doRestart(boolean safely) {
//securityService.checkPermission(Hudson.ADMINISTER);
- try
- {
- if (safely)
- {
+ try {
+ if (safely) {
log.debug("Restarting (safely)");
getHudson().safeRestart();
- }
- else
- {
+ } else {
log.debug("Restarting");
getHudson().restart();
}
- }
- catch (RestartNotSupportedException ex)
- {
+ } catch (RestartNotSupportedException ex) {
throw new ServiceRuntimeException("Restart not supported", ex);
}
}
- public void doRestart()
- {
+ public void doRestart() {
//securityService.checkPermission(Hudson.ADMINISTER);
log.debug("Restarting");
- try
- {
+ try {
getHudson().safeRestart();
- }
- catch (RestartNotSupportedException ex)
- {
+ } catch (RestartNotSupportedException ex) {
throw new ServiceRuntimeException("Restart not supported", ex);
}
}
- public void doRestartSafely()
- {
+ public void doRestartSafely() {
//securityService.checkPermission(Hudson.ADMINISTER);
log.debug("Restarting (safely)");
- try
- {
+ try {
getHudson().restart();
- }
- catch (RestartNotSupportedException ex)
- {
+ } catch (RestartNotSupportedException ex) {
throw new ServiceRuntimeException("Restart not supported", ex);
}
}
diff --git a/hudson-service/src/main/java/org/hudsonci/service/internal/package-info.java b/hudson-service/src/main/java/org/hudsonci/service/internal/package-info.java
index 74db1d8..54698a6 100644
--- a/hudson-service/src/main/java/org/hudsonci/service/internal/package-info.java
+++ b/hudson-service/src/main/java/org/hudsonci/service/internal/package-info.java
@@ -1,17 +1,18 @@
-/*******************************************************************************
+/**
+ * *****************************************************************************
*
* Copyright (c) 2010-2011 Sonatype, Inc.
*
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
+ * All rights reserved. This program and the accompanying materials are made
+ * available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
*
- *
- *
*
- *******************************************************************************/
-
+ *
+ *
+ ******************************************************************************
+ */
package org.hudsonci.service.internal;
diff --git a/hudson-service/src/main/java/org/hudsonci/service/package-info.java b/hudson-service/src/main/java/org/hudsonci/service/package-info.java
index 3b4fa16..6e2ee85 100644
--- a/hudson-service/src/main/java/org/hudsonci/service/package-info.java
+++ b/hudson-service/src/main/java/org/hudsonci/service/package-info.java
@@ -1,17 +1,18 @@
-/*******************************************************************************
+/**
+ * *****************************************************************************
*
* Copyright (c) 2010-2011 Sonatype, Inc.
*
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
+ * All rights reserved. This program and the accompanying materials are made
+ * available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
*
- *
- *
*
- *******************************************************************************/
-
+ *
+ *
+ ******************************************************************************
+ */
package org.hudsonci.service;
diff --git a/hudson-service/src/main/java/org/hudsonci/servlets/ServletContainer.java b/hudson-service/src/main/java/org/hudsonci/servlets/ServletContainer.java
index 7b4eaf1..35572fc 100644
--- a/hudson-service/src/main/java/org/hudsonci/servlets/ServletContainer.java
+++ b/hudson-service/src/main/java/org/hudsonci/servlets/ServletContainer.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -27,11 +27,11 @@ import org.hudsonci.servlets.internal.ServletContainerImpl;
* @since 2.1.0
*/
@ImplementedBy(ServletContainerImpl.class)
-public interface ServletContainer
-{
+public interface ServletContainer {
+
void start() throws Exception;
void stop() throws Exception;
-
+
ServletRegistration.Handle register(ServletRegistration registration) throws Exception;
}
diff --git a/hudson-service/src/main/java/org/hudsonci/servlets/ServletContainerAware.java b/hudson-service/src/main/java/org/hudsonci/servlets/ServletContainerAware.java
index 8671b02..459d0cb 100644
--- a/hudson-service/src/main/java/org/hudsonci/servlets/ServletContainerAware.java
+++ b/hudson-service/src/main/java/org/hudsonci/servlets/ServletContainerAware.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -19,13 +19,14 @@ package org.hudsonci.servlets;
import hudson.ExtensionPoint;
/**
- * Extension to allow plugins to be aware of the {@link ServletContainer} and register servlets.
+ * Extension to allow plugins to be aware of the {@link ServletContainer} and
+ * register servlets.
*
* @author <a href="mailto:jason@planet57.com">Jason Dillon</a>
* @since 2.1.0
*/
public interface ServletContainerAware
- extends ExtensionPoint
-{
+ extends ExtensionPoint {
+
void setServletContainer(ServletContainer container) throws Exception;
}
diff --git a/hudson-service/src/main/java/org/hudsonci/servlets/ServletRegistration.java b/hudson-service/src/main/java/org/hudsonci/servlets/ServletRegistration.java
index 68b3262..45cd803 100644
--- a/hudson-service/src/main/java/org/hudsonci/servlets/ServletRegistration.java
+++ b/hudson-service/src/main/java/org/hudsonci/servlets/ServletRegistration.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -27,16 +27,12 @@ import java.util.Map;
* @since 2.1.0
*/
public class ServletRegistration
- implements Cloneable
-{
- private String name;
+ implements Cloneable {
+ private String name;
private Class<? extends Servlet> servletType;
-
private Servlet servlet;
-
private String uriPrefix;
-
private Map<String, String> parameters;
public String getName() {
@@ -96,27 +92,26 @@ public class ServletRegistration
public ServletRegistration clone() {
try {
return (ServletRegistration) super.clone();
- }
- catch (CloneNotSupportedException e) {
+ } catch (CloneNotSupportedException e) {
throw (InternalError) new InternalError().initCause(e);
}
}
@Override
public String toString() {
- return "ServletRegistration{" +
- "name='" + name + '\'' +
- ", servletType=" + servletType +
- ", servlet=" + servlet +
- ", uriPrefix='" + uriPrefix + '\'' +
- ", parameters=" + parameters +
- '}';
+ return "ServletRegistration{"
+ + "name='" + name + '\''
+ + ", servletType=" + servletType
+ + ", servlet=" + servlet
+ + ", uriPrefix='" + uriPrefix + '\''
+ + ", parameters=" + parameters
+ + '}';
}
- public static interface Handle
- {
+ public static interface Handle {
+
ServletRegistration getRegistration();
-
+
void setEnabled(boolean enabled);
boolean isEnabled();
diff --git a/hudson-service/src/main/java/org/hudsonci/servlets/internal/ServletContainerImpl.java b/hudson-service/src/main/java/org/hudsonci/servlets/internal/ServletContainerImpl.java
index 0e8c85e..3ec32ad 100644
--- a/hudson-service/src/main/java/org/hudsonci/servlets/internal/ServletContainerImpl.java
+++ b/hudson-service/src/main/java/org/hudsonci/servlets/internal/ServletContainerImpl.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -43,12 +43,10 @@ import static com.google.common.base.Preconditions.checkNotNull;
@Named
@Singleton
public class ServletContainerImpl
- implements ServletContainer
-{
- private static final Logger log = LoggerFactory.getLogger(ServletContainerImpl.class);
+ implements ServletContainer {
+ private static final Logger log = LoggerFactory.getLogger(ServletContainerImpl.class);
private final Map<ServletRegistration, Filter> registrations = new LinkedHashMap<ServletRegistration, Filter>();
-
private final List<ServletContainerAware> concerned;
@Inject
@@ -70,11 +68,9 @@ public class ServletContainerImpl
Thread.currentThread().setContextClassLoader(target.getClass().getClassLoader());
try {
target.setServletContainer(this);
- }
- catch (Exception e) {
+ } catch (Exception e) {
log.error("Exception while exposing servlet container to: " + target, e);
- }
- finally {
+ } finally {
Thread.currentThread().setContextClassLoader(cl);
}
}
@@ -105,10 +101,9 @@ public class ServletContainerImpl
}
private class HandleImpl
- implements ServletRegistration.Handle
- {
- private final ServletRegistration registration;
+ implements ServletRegistration.Handle {
+ private final ServletRegistration registration;
private final ServletRegistrationFilterAdapter filterAdapter;
private HandleImpl(final ServletRegistration registration, final ServletRegistrationFilterAdapter filterAdapter) {
diff --git a/hudson-service/src/main/java/org/hudsonci/servlets/internal/ServletContainerStarter.java b/hudson-service/src/main/java/org/hudsonci/servlets/internal/ServletContainerStarter.java
index 59edbc3..3602475 100644
--- a/hudson-service/src/main/java/org/hudsonci/servlets/internal/ServletContainerStarter.java
+++ b/hudson-service/src/main/java/org/hudsonci/servlets/internal/ServletContainerStarter.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -37,12 +37,10 @@ import static com.google.common.base.Preconditions.checkNotNull;
@Named
@Singleton
public class ServletContainerStarter
- extends ItemListener
-{
- private static final Logger log = LoggerFactory.getLogger(ServletContainerStarter.class);
+ extends ItemListener {
+ private static final Logger log = LoggerFactory.getLogger(ServletContainerStarter.class);
// FIXME: Use of ItemListener for server life-cycle bits is a work around
-
private final ServletContainer servlets;
@Inject
@@ -54,8 +52,7 @@ public class ServletContainerStarter
public void onLoaded() {
try {
servlets.start();
- }
- catch (Exception e) {
+ } catch (Exception e) {
log.error("Failed to start servlet container", e);
}
}
diff --git a/hudson-service/src/main/java/org/hudsonci/servlets/internal/ServletRegistrationFilterAdapter.java b/hudson-service/src/main/java/org/hudsonci/servlets/internal/ServletRegistrationFilterAdapter.java
index f3270f4..379d3d6 100644
--- a/hudson-service/src/main/java/org/hudsonci/servlets/internal/ServletRegistrationFilterAdapter.java
+++ b/hudson-service/src/main/java/org/hudsonci/servlets/internal/ServletRegistrationFilterAdapter.java
@@ -39,22 +39,19 @@ import java.util.Iterator;
import static com.google.common.base.Preconditions.checkNotNull;
/**
- * Wraps a {@link Servlet} as a {@link Filter} for installation via {@link hudson.util.PluginServletFilter}.
+ * Wraps a {@link Servlet} as a {@link Filter} for installation via
+ * {@link hudson.util.PluginServletFilter}.
*
* @author <a href="mailto:jason@planet57.com">Jason Dillon</a>
* @since 2.1.0
*/
public class ServletRegistrationFilterAdapter
- implements Filter
-{
- private static final Logger log = LoggerFactory.getLogger(ServletRegistrationFilterAdapter.class);
+ implements Filter {
+ private static final Logger log = LoggerFactory.getLogger(ServletRegistrationFilterAdapter.class);
private final ServletRegistration registration;
-
private final Servlet servlet;
-
private final String uriPrefix;
-
private boolean enabled;
public ServletRegistrationFilterAdapter(final ServletRegistration registration) throws Exception {
@@ -96,8 +93,7 @@ public class ServletRegistrationFilterAdapter
public void init(final FilterConfig config) throws ServletException {
checkNotNull(config);
- servlet.init(new ServletConfig()
- {
+ servlet.init(new ServletConfig() {
public String getServletName() {
return registration.getName();
}
@@ -109,8 +105,7 @@ public class ServletRegistrationFilterAdapter
public Enumeration getInitParameterNames() {
final Iterator<String> iter = registration.getParameters().keySet().iterator();
- return new Enumeration()
- {
+ return new Enumeration() {
public boolean hasMoreElements() {
return iter.hasNext();
}
@@ -132,21 +127,18 @@ public class ServletRegistrationFilterAdapter
}
public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain)
- throws IOException, ServletException
- {
+ throws IOException, ServletException {
assert chain != null;
if (isEnabled() && request instanceof HttpServletRequest && response instanceof HttpServletResponse) {
doFilter((HttpServletRequest) request, (HttpServletResponse) response, chain);
- }
- else {
+ } else {
chain.doFilter(request, response);
}
}
private void doFilter(final HttpServletRequest request, final HttpServletResponse response, final FilterChain chain)
- throws IOException, ServletException
- {
+ throws IOException, ServletException {
assert request != null;
assert response != null;
assert chain != null;
@@ -158,8 +150,7 @@ public class ServletRegistrationFilterAdapter
if (request.getRequestURI().startsWith(contextPath + uriPrefix)) {
// Wrap the request to augment the servlet uriPrefix
- HttpServletRequestWrapper req = new HttpServletRequestWrapper(request)
- {
+ HttpServletRequestWrapper req = new HttpServletRequestWrapper(request) {
@Override
public String getServletPath() {
return String.format("/%s", uriPrefix);
@@ -167,8 +158,7 @@ public class ServletRegistrationFilterAdapter
};
servlet.service(req, response);
- }
- else {
+ } else {
chain.doFilter(request, response);
}
}
diff --git a/hudson-test-framework/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java b/hudson-test-framework/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java
index 6f5dc9b..4d37239 100644
--- a/hudson-test-framework/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java
+++ b/hudson-test-framework/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java
@@ -1182,8 +1182,8 @@ public abstract class HudsonTestCase extends TestCase implements RootAction {
streak++;
}
- if (streak > 5) // the system is quiet for a while
- {
+ // the system is quiet for a while
+ if (streak > 5) {
return;
}
diff --git a/hudson-test-utils/src/main/java/org/hudsonci/utils/hamcrest/FileMatchers.java b/hudson-test-utils/src/main/java/org/hudsonci/utils/hamcrest/FileMatchers.java
index 6c83966..de71fec 100644
--- a/hudson-test-utils/src/main/java/org/hudsonci/utils/hamcrest/FileMatchers.java
+++ b/hudson-test-utils/src/main/java/org/hudsonci/utils/hamcrest/FileMatchers.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -25,8 +25,7 @@ import org.hamcrest.TypeSafeMatcher;
/**
* Bulk of implementation copied freely from
- * http://www.time4tea.net/wiki/display/MAIN/Testing+Files+with+Hamcrest
- * <p>
+ * http://www.time4tea.net/wiki/display/MAIN/Testing+Files+with+Hamcrest <p>
* Converted to pure Hamcrest
*
* @author time4tea technology ltd 2007
@@ -67,7 +66,6 @@ public class FileMatchers {
description.appendValue(fileTested);
description.appendText(" exists");
}
-
};
}
@@ -128,7 +126,6 @@ public class FileMatchers {
// public static Matcher<File> sized(Long size) {
// return sized(Matchers.equalTo(size));
// }
-
public static Matcher<File> sized(final Matcher<Long> size) {
return new TypeSafeMatcher<File>() {
File fileTested;
@@ -194,7 +191,6 @@ public class FileMatchers {
public static Matcher<File> withAbsolutePath(final Matcher<String> path) {
return new TypeSafeMatcher<File>() {
// File fileTested;
-
@Override
public boolean matchesSafely(File item) {
// fileTested = item;
diff --git a/hudson-test-utils/src/main/java/org/hudsonci/utils/hamcrest/URLMatchers.java b/hudson-test-utils/src/main/java/org/hudsonci/utils/hamcrest/URLMatchers.java
index c0aae60..ca2c520 100644
--- a/hudson-test-utils/src/main/java/org/hudsonci/utils/hamcrest/URLMatchers.java
+++ b/hudson-test-utils/src/main/java/org/hudsonci/utils/hamcrest/URLMatchers.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -24,12 +24,12 @@ import org.hamcrest.Matcher;
public class URLMatchers {
@Factory
- public static Matcher<URL> respondsWithStatus(int statusCode){
+ public static Matcher<URL> respondsWithStatus(int statusCode) {
return new URLRespondsWithStatusMatcher(statusCode);
}
@Factory
- public static Matcher<URL> respondsWithStatusWithin(int statusCode, int timeoutMillis){
+ public static Matcher<URL> respondsWithStatusWithin(int statusCode, int timeoutMillis) {
return new URLRespondsWithStatusMatcher(statusCode, timeoutMillis);
}
}
diff --git a/hudson-test-utils/src/main/java/org/hudsonci/utils/hamcrest/URLRespondsWithStatusMatcher.java b/hudson-test-utils/src/main/java/org/hudsonci/utils/hamcrest/URLRespondsWithStatusMatcher.java
index 6a86dfc..1432275 100644
--- a/hudson-test-utils/src/main/java/org/hudsonci/utils/hamcrest/URLRespondsWithStatusMatcher.java
+++ b/hudson-test-utils/src/main/java/org/hudsonci/utils/hamcrest/URLRespondsWithStatusMatcher.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -38,10 +38,10 @@ public class URLRespondsWithStatusMatcher extends TypeSafeMatcher<URL> {
}
public URLRespondsWithStatusMatcher(final int statusCode, final int timeout) {
- if(timeout < 0){
+ if (timeout < 0) {
throw new IllegalArgumentException("timeout cannot be negative");
}
- if(statusCode < -1){
+ if (statusCode < -1) {
throw new IllegalArgumentException("status code cannot be less than negative one");
}
this.statusCode = statusCode;
@@ -49,24 +49,23 @@ public class URLRespondsWithStatusMatcher extends TypeSafeMatcher<URL> {
}
public void describeTo(Description description) {
- if(timedOut){
+ if (timedOut) {
description.appendValue(urlString).appendText(" to connect within ").appendValue(timeout).appendText("ms");
- } else if (e != null){
+ } else if (e != null) {
description.appendValue(urlString).appendText(" to successfully connect");
} else {
description.appendValue(urlString).appendText(" to respond with ").appendValue(statusCode);
}
}
-
@Override
protected void describeMismatchSafely(URL item, Description mismatchDescription) {
- if(timedOut){
+ if (timedOut) {
mismatchDescription.appendText("took longer.");
- if(this.e != null){
+ if (this.e != null) {
mismatchDescription.appendText(this.e.getMessage());
}
- } else if (e != null){
+ } else if (e != null) {
mismatchDescription.appendText("got ").appendValue(this.e);
// description.appendText("got exception ").appendValue(e);
} else {
@@ -81,23 +80,22 @@ public class URLRespondsWithStatusMatcher extends TypeSafeMatcher<URL> {
try {
URL url = new URL(item.toString());
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
- if(timeout > -1){
+ if (timeout > -1) {
urlConnection.setConnectTimeout(timeout);
urlConnection.setReadTimeout(timeout);
}
urlConnection.setUseCaches(false);
urlConnection.connect();
this.receivedStatusCode = urlConnection.getResponseCode();
- } catch (SocketTimeoutException ste){
+ } catch (SocketTimeoutException ste) {
timedOut = true;
this.e = ste;
} catch (IOException ioe) {
this.e = ioe;
- } catch (Exception e){
+ } catch (Exception e) {
this.e = e;
}
return (!timedOut && e == null && this.receivedStatusCode == this.statusCode);
}
-
}
diff --git a/hudson-test-utils/src/main/java/org/hudsonci/utils/junit/ext/URLIsReachable.java b/hudson-test-utils/src/main/java/org/hudsonci/utils/junit/ext/URLIsReachable.java
index f9167fa..1db62b7 100644
--- a/hudson-test-utils/src/main/java/org/hudsonci/utils/junit/ext/URLIsReachable.java
+++ b/hudson-test-utils/src/main/java/org/hudsonci/utils/junit/ext/URLIsReachable.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -30,7 +30,7 @@ public class URLIsReachable {
private String message = ""; // arg 3, ideally the test name
public URLIsReachable(final String urlString) throws MalformedURLException {
- final String[] args = new String[] { urlString };
+ final String[] args = new String[]{urlString};
init(args);
}
@@ -57,10 +57,9 @@ public class URLIsReachable {
} catch (AssertionError ae) {
System.err.println("[WARN] "
+ String.format("%s caused a test to be ignored %s, %s", this.getClass().getSimpleName(),
- this.message, ae.getMessage()));
+ this.message, ae.getMessage()));
return false;
}
return true;
}
-
}
diff --git a/hudson-test-utils/src/main/java/org/hudsonci/utils/test/PropUtil.java b/hudson-test-utils/src/main/java/org/hudsonci/utils/test/PropUtil.java
index ee54d08..925d4c5 100644
--- a/hudson-test-utils/src/main/java/org/hudsonci/utils/test/PropUtil.java
+++ b/hudson-test-utils/src/main/java/org/hudsonci/utils/test/PropUtil.java
@@ -7,30 +7,27 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
package org.hudsonci.utils.test;
-public class PropUtil
-{
- public static String get( String name, String def )
- {
- String val = System.getProperty( name, def );
- if ( val == null || val.length() == 0 || ( val.startsWith( "${" ) && val.endsWith( "}" ) ) )
- {
+public class PropUtil {
+
+ public static String get(String name, String def) {
+ String val = System.getProperty(name, def);
+ if (val == null || val.length() == 0 || (val.startsWith("${") && val.endsWith("}"))) {
val = def;
}
return val;
}
- public static int get( String name, int def )
- {
- return Integer.parseInt( get( name, String.valueOf( def ) ) );
+ public static int get(String name, int def) {
+ return Integer.parseInt(get(name, String.valueOf(def)));
}
}
diff --git a/hudson-test-utils/src/main/java/org/hudsonci/utils/test/TestUtil.java b/hudson-test-utils/src/main/java/org/hudsonci/utils/test/TestUtil.java
index e351ca4..ad6e69d 100644
--- a/hudson-test-utils/src/main/java/org/hudsonci/utils/test/TestUtil.java
+++ b/hudson-test-utils/src/main/java/org/hudsonci/utils/test/TestUtil.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -29,23 +29,21 @@ import com.google.common.base.Preconditions;
* @author <a href="mailto:jason@planet57.com">Jason Dillon</a>
* @since 2.1.0
*/
-public class TestUtil
-{
- private final Class owningClass;
+public class TestUtil {
+ private final Class owningClass;
/**
* The base-directory which tests should be run from.
*
- * @see #initBaseDir() This field is initialized from the return of this method on instance construction.
+ * @see #initBaseDir() This field is initialized from the return of this
+ * method on instance construction.
*/
protected final File baseDir;
-
/**
* Instance logger which tests should use to produce tracing information.
*
- * <p>
- * Unless you have a really good reason to, do not change this field from your sub-class.
- * And if you do, please document why you have done so.
+ * <p> Unless you have a really good reason to, do not change this field
+ * from your sub-class. And if you do, please document why you have done so.
*/
protected final Logger log;
@@ -77,17 +75,19 @@ public class TestUtil
}
/**
- * Determine the value of <tt>${basedir}</tt>, which should be the base directory of
- * the module which the concrete test class is defined in.
+ * Determine the value of <tt>${basedir}</tt>, which should be the base
+ * directory of the module which the concrete test class is defined in.
*
- * <p>
- * If The system property <tt>basedir</tt> is already set, then that value is used,
- * otherwise we determine the value from the code-source of the containing concrete class
- * and set the <tt>basedir</tt> system property to that value.
+ * <p> If The system property <tt>basedir</tt> is already set, then that
+ * value is used, otherwise we determine the value from the code-source of
+ * the containing concrete class and set the <tt>basedir</tt> system
+ * property to that value.
*
- * @see #baseDir This field is always initialized to the value which this method returns.
+ * @see #baseDir This field is always initialized to the value which this
+ * method returns.
*
- * @return The base directory of the module which contains the concrete test class.
+ * @return The base directory of the module which contains the concrete test
+ * class.
*/
protected final File initBaseDir() {
File dir;
@@ -96,8 +96,7 @@ public class TestUtil
String tmp = System.getProperty("basedir");
if (tmp != null) {
dir = new File(tmp);
- }
- else {
+ } else {
// Find the directory which this class (or really the sub-class of TestSupport) is defined in.
String path = owningClass.getProtectionDomain().getCodeSource().getLocation().getFile();
@@ -116,8 +115,8 @@ public class TestUtil
/**
* Resolve the given path to a file rooted to {@link #baseDir}.
*
- * @param path The path to resolve.
- * @return The resolved file for the given path.
+ * @param path The path to resolve.
+ * @return The resolved file for the given path.
*/
public final File resolveFile(final String path) {
Preconditions.checkNotNull(path);
@@ -127,8 +126,7 @@ public class TestUtil
// Complain if the file is already absolute... probably an error
if (file.isAbsolute()) {
log.warn("Given path is already absolute; nothing to resolve: {}", file);
- }
- else {
+ } else {
file = new File(baseDir, path);
}
@@ -138,8 +136,8 @@ public class TestUtil
/**
* Resolve the given path to a path rooted to {@link #baseDir}.
*
- * @param path The path to resolve.
- * @return The resolved path for the given path.
+ * @param path The path to resolve.
+ * @return The resolved path for the given path.
*
* @see #resolveFile(String)
*/
diff --git a/hudson-utils/src/main/java/org/hudsonci/utils/common/VersionFormatter.java b/hudson-utils/src/main/java/org/hudsonci/utils/common/VersionFormatter.java
index 1e03922..b8eb041 100644
--- a/hudson-utils/src/main/java/org/hudsonci/utils/common/VersionFormatter.java
+++ b/hudson-utils/src/main/java/org/hudsonci/utils/common/VersionFormatter.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -18,56 +18,50 @@ package org.hudsonci.utils.common;
/**
* Utility supplying different ways to format a version number.
- *
+ *
* @author Jamie Whitehouse
* @since 2.1.0
*/
-class VersionFormatter
-{
+class VersionFormatter {
+
/**
* @return a formatted version number containing the raw information
*/
- public static String asRawVersion( String version, String timestamp, String sequence )
- {
+ public static String asRawVersion(String version, String timestamp, String sequence) {
StringBuilder buff = new StringBuilder();
- if ( version == null )
- {
+ if (version == null) {
version = VersionSupport.UNKNOWN;
}
- buff.append( version );
+ buff.append(version);
- if ( timestamp != null )
- {
- buff.append( "," ).append( timestamp );
+ if (timestamp != null) {
+ buff.append(",").append(timestamp);
}
- if ( sequence != null )
- {
- buff.append( "#" ).append( sequence );
+ if (sequence != null) {
+ buff.append("#").append(sequence);
}
return buff.toString();
}
/**
- * Generates an appropriate format based on the project being a release or development version. Example:
- * 0.2.1,201009291818#1
- *
- * @return a formatted version number in the simplest and most significant form
+ * Generates an appropriate format based on the project being a release or
+ * development version. Example: 0.2.1,201009291818#1
+ *
+ * @return a formatted version number in the simplest and most significant
+ * form
*/
- public static String asCanonicalVersion( String version, String timestamp, String sequence )
- {
+ public static String asCanonicalVersion(String version, String timestamp, String sequence) {
String derivedVersion = version;
- if ( derivedVersion == null )
- {
+ if (derivedVersion == null) {
derivedVersion = VersionSupport.UNKNOWN;
}
String snapshot = "-SNAPSHOT";
- if ( derivedVersion.contains( snapshot ) )
- {
- derivedVersion = asRawVersion( version.replace( snapshot, "" ), timestamp, sequence );
+ if (derivedVersion.contains(snapshot)) {
+ derivedVersion = asRawVersion(version.replace(snapshot, ""), timestamp, sequence);
}
return derivedVersion;
diff --git a/hudson-utils/src/main/java/org/hudsonci/utils/common/VersionSupport.java b/hudson-utils/src/main/java/org/hudsonci/utils/common/VersionSupport.java
index 5397083..23f7aa5 100644
--- a/hudson-utils/src/main/java/org/hudsonci/utils/common/VersionSupport.java
+++ b/hudson-utils/src/main/java/org/hudsonci/utils/common/VersionSupport.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -22,18 +22,13 @@ package org.hudsonci.utils.common;
* @author <a href="mailto:jason@planet57.com">Jason Dillon</a>
* @since 2.1.0
*/
-public class VersionSupport
-{
- public static final String RESOURCE_NAME = "version.properties";
+public class VersionSupport {
+ public static final String RESOURCE_NAME = "version.properties";
public static final String UNKNOWN = "unknown";
-
public static final String VERSION = "version";
-
public static final String TIMESTAMP = "timestamp";
-
public static final String SEQUENCE = "sequence";
-
private final PropertiesLoader props;
protected VersionSupport() {
@@ -53,21 +48,20 @@ public class VersionSupport
}
/**
- * @return a formatted version number in the simplest and most significant form
+ * @return a formatted version number in the simplest and most significant
+ * form
*/
- public String getCanonicalVersion()
- {
+ public String getCanonicalVersion() {
// FIXME cache the formatted version since users may be accessing it frequently?
// e.g. on every page of the web ui.
- return VersionFormatter.asCanonicalVersion( getVersion(), getTimestamp(), getSequence() );
+ return VersionFormatter.asCanonicalVersion(getVersion(), getTimestamp(), getSequence());
}
/**
* @return a formatted version number containing the raw information
*/
- public String getRawVersion()
- {
- return VersionFormatter.asRawVersion( getVersion(), getTimestamp(), getSequence() );
+ public String getRawVersion() {
+ return VersionFormatter.asRawVersion(getVersion(), getTimestamp(), getSequence());
}
@Override
diff --git a/hudson-utils/src/main/java/org/hudsonci/utils/event/EventHandlerSupport.java b/hudson-utils/src/main/java/org/hudsonci/utils/event/EventHandlerSupport.java
index fd4f2ba..5832ccb 100644
--- a/hudson-utils/src/main/java/org/hudsonci/utils/event/EventHandlerSupport.java
+++ b/hudson-utils/src/main/java/org/hudsonci/utils/event/EventHandlerSupport.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -31,16 +31,14 @@ import static com.google.common.base.Preconditions.checkNotNull;
* @since 2.1.0
*/
public abstract class EventHandlerSupport<ContextType, EventType>
- implements EventHandler<ContextType, EventType>
-{
- protected final Logger log = LoggerFactory.getLogger(getClass());
+ implements EventHandler<ContextType, EventType> {
+ protected final Logger log = LoggerFactory.getLogger(getClass());
private ContextType context;
-
private Class eventType;
public void init(final ContextType context) {
- this.context = checkNotNull( context );
+ this.context = checkNotNull(context);
}
protected ContextType getContext() {
@@ -48,10 +46,11 @@ public abstract class EventHandlerSupport<ContextType, EventType>
}
/**
- * Accepts the event if it is a compatible type; determined by {@link #getEventType}.
+ * Accepts the event if it is a compatible type; determined by
+ * {@link #getEventType}.
*/
public boolean accept(final Object event) {
- checkNotNull( event );
+ checkNotNull(event);
return getEventType().isAssignableFrom(event.getClass());
}
@@ -62,13 +61,12 @@ public abstract class EventHandlerSupport<ContextType, EventType>
if (eventType == null) {
// find public void handle(Object) method
for (Method method : getClass().getDeclaredMethods()) {
- if (Modifier.isPublic(method.getModifiers()) &&
- method.getReturnType() == Void.TYPE &&
- method.getName().equals("handle") &&
- method.getParameterTypes().length == 1 &&
- // Ignore methods with Object as param, generics muck puts this in here and matches when we want the specific typed method
- method.getParameterTypes()[0] != Object.class)
- {
+ if (Modifier.isPublic(method.getModifiers())
+ && method.getReturnType() == Void.TYPE
+ && method.getName().equals("handle")
+ && method.getParameterTypes().length == 1
+ && // Ignore methods with Object as param, generics muck puts this in here and matches when we want the specific typed method
+ method.getParameterTypes()[0] != Object.class) {
eventType = method.getParameterTypes()[0];
log.debug("Determined type: {}, from method: {}", eventType.getName(), method);
break;
diff --git a/hudson-utils/src/main/java/org/hudsonci/utils/io/FileBeheader.java b/hudson-utils/src/main/java/org/hudsonci/utils/io/FileBeheader.java
index 13a08cc..25c8a44 100644
--- a/hudson-utils/src/main/java/org/hudsonci/utils/io/FileBeheader.java
+++ b/hudson-utils/src/main/java/org/hudsonci/utils/io/FileBeheader.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -24,79 +24,67 @@ import java.nio.channels.FileChannel;
/**
* Removes the beginning of a file.
- *
+ *
* @author Jamie Whitehouse
* @since 2.1.0
*/
-public class FileBeheader
-{
+public class FileBeheader {
+
/**
- * Beware, the original file is modified when chopping; you relinquish
- * all control of the original file.
- *
+ * Beware, the original file is modified when chopping; you relinquish all
+ * control of the original file.
+ *
* Requires write access to the same directory as the original.
- *
+ *
* @param original the original file
* @param tailToKeep the number of bytes to keep at the end of the file
- *
+ *
* @return the original file chopped; for convenience
- *
+ *
* @throws IllegalArgumentException if original is a directory
- * @throws IllegalStateException if some error occurs; it's unreasonable to try and recover from this
+ * @throws IllegalStateException if some error occurs; it's unreasonable to
+ * try and recover from this
*/
- public static File chop( final File original, final long tailToKeep )
- {
- if ( !original.isFile() )
- {
- throw new IllegalArgumentException( "Cannot behead directories: " + original );
+ public static File chop(final File original, final long tailToKeep) {
+ if (!original.isFile()) {
+ throw new IllegalArgumentException("Cannot behead directories: " + original);
}
- File truncatedFile = new File( original.getParentFile(), original.getName() + ".truncated" );
+ File truncatedFile = new File(original.getParentFile(), original.getName() + ".truncated");
FileChannel whole = null;
FileChannel chopped = null;
- try
- {
- whole = new FileInputStream( original ).getChannel();
- chopped = new FileOutputStream( truncatedFile ).getChannel();
+ try {
+ whole = new FileInputStream(original).getChannel();
+ chopped = new FileOutputStream(truncatedFile).getChannel();
long originalLength = original.length();
long lengthToKeep = originalLength < tailToKeep ? 0 : originalLength - tailToKeep;
- whole.transferTo( lengthToKeep, originalLength, chopped );
- }
- catch ( IOException e )
- {
- throw new IllegalStateException( "Cannot behead file due to inconsistent internal state.", e );
- }
- finally
- {
- Closer.close( whole, chopped );
+ whole.transferTo(lengthToKeep, originalLength, chopped);
+ } catch (IOException e) {
+ throw new IllegalStateException("Cannot behead file due to inconsistent internal state.", e);
+ } finally {
+ Closer.close(whole, chopped);
}
// Replace original with chopped file.
- boolean isRenamed = truncatedFile.renameTo( original );
- if ( !( isRenamed ) )
- {
+ boolean isRenamed = truncatedFile.renameTo(original);
+ if (!(isRenamed)) {
IllegalStateException renameException =
- new IllegalStateException( "Cannot replace original with chopped file to: " + original );
+ new IllegalStateException("Cannot replace original with chopped file to: " + original);
String originalPath = original.getAbsolutePath();
boolean isDeleted = original.delete();
- if ( isDeleted )
- {
- boolean isRenamedAgain = truncatedFile.renameTo( new File( originalPath ) );
- if ( !isRenamedAgain )
- {
+ if (isDeleted) {
+ boolean isRenamedAgain = truncatedFile.renameTo(new File(originalPath));
+ if (!isRenamedAgain) {
throw renameException;
}
- }
- else
- {
+ } else {
throw renameException;
}
}
return original;
}
-
}
diff --git a/hudson-utils/src/main/java/org/hudsonci/utils/io/FileUtil.java b/hudson-utils/src/main/java/org/hudsonci/utils/io/FileUtil.java
index a43e9fa..6c3c642 100644
--- a/hudson-utils/src/main/java/org/hudsonci/utils/io/FileUtil.java
+++ b/hudson-utils/src/main/java/org/hudsonci/utils/io/FileUtil.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -24,59 +24,53 @@ import java.net.URL;
import static com.google.common.base.Preconditions.checkNotNull;
/**
- * I usually put these into something like "ResourceManager" and use it to
- * do all the loading. This manager can then cope with the exceptions and
- * logging so each part of the application doesn't have to.
- *
+ * I usually put these into something like "ResourceManager" and use it to do
+ * all the loading. This manager can then cope with the exceptions and logging
+ * so each part of the application doesn't have to.
+ *
* Having a separate manager for it also makes it easier to mock in tests to
* verify interactions.
- *
+ *
* @author Jamie Whitehouse
* @since 2.1.0
*/
-public class FileUtil
-{
+public class FileUtil {
+
public static File canonicalize(final File file) {
checkNotNull(file);
try {
return file.getCanonicalFile();
- }
- catch (IOException e) {
+ } catch (IOException e) {
throw new RuntimeException(e);
}
}
- public static URL getResource( String resource )
- {
- return Thread.currentThread().getContextClassLoader().getResource( resource );
+ public static URL getResource(String resource) {
+ return Thread.currentThread().getContextClassLoader().getResource(resource);
}
- public static File getResourceAsFile( String resource )
- {
- return new File( getResource( resource ).getFile() );
+ public static File getResourceAsFile(String resource) {
+ return new File(getResource(resource).getFile());
}
/**
* Gets a resource relative to the given class.
*/
- public static File getResourceAsFile( Class clazz, String resource )
- {
- return new File( clazz.getResource( resource ).getFile() );
+ public static File getResourceAsFile(Class clazz, String resource) {
+ return new File(clazz.getResource(resource).getFile());
}
-
+
/**
* Gets a resource using the current threads classloader.
*/
- public static InputStream getResourceAsStream( String resource )
- {
- return Thread.currentThread().getContextClassLoader().getResourceAsStream( resource );
+ public static InputStream getResourceAsStream(String resource) {
+ return Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);
}
/**
* Gets a resource using the given classes classloader.
*/
- public static InputStream getResourceAsStream( Class clazz, String resource )
- {
- return clazz.getClassLoader().getResourceAsStream( resource );
+ public static InputStream getResourceAsStream(Class clazz, String resource) {
+ return clazz.getClassLoader().getResourceAsStream(resource);
}
}
diff --git a/hudson-utils/src/main/java/org/hudsonci/utils/marshal/xref/XReference.java b/hudson-utils/src/main/java/org/hudsonci/utils/marshal/xref/XReference.java
index f9c410f..6f31b65 100644
--- a/hudson-utils/src/main/java/org/hudsonci/utils/marshal/xref/XReference.java
+++ b/hudson-utils/src/main/java/org/hudsonci/utils/marshal/xref/XReference.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -26,8 +26,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
* @author <a href="mailto:jason@planet57.com">Jason Dillon</a>
* @since 2.1.0
*/
-public abstract class XReference<T>
-{
+public abstract class XReference<T> {
+
protected transient Holder<T> holder;
public XReference(final T value) {
@@ -43,7 +43,7 @@ public abstract class XReference<T>
holder = new InstanceHolder<T>(value);
}
}
-
+
public T get() {
if (holder != null) {
return holder.get();
@@ -65,16 +65,16 @@ public abstract class XReference<T>
@Override
public String toString() {
- return getClass().getName() + "{" +
- "holder=" + holder +
- '}';
+ return getClass().getName() + "{"
+ + "holder=" + holder
+ + '}';
}
/**
* Provides delegation for instance access.
*/
- public static interface Holder<T>
- {
+ public static interface Holder<T> {
+
T get();
}
@@ -82,8 +82,8 @@ public abstract class XReference<T>
* Holds on to a specific instance.
*/
public static class InstanceHolder<T>
- implements Holder<T>
- {
+ implements Holder<T> {
+
protected final T instance;
protected InstanceHolder(final T instance) {
@@ -96,9 +96,9 @@ public abstract class XReference<T>
@Override
public String toString() {
- return "InstanceHolder{" +
- "instance=" + instance +
- '}';
+ return "InstanceHolder{"
+ + "instance=" + instance
+ + '}';
}
}
}
diff --git a/hudson-utils/src/main/java/org/hudsonci/utils/marshal/xref/XReferenceConverter.java b/hudson-utils/src/main/java/org/hudsonci/utils/marshal/xref/XReferenceConverter.java
index daf90c2..992e673 100644
--- a/hudson-utils/src/main/java/org/hudsonci/utils/marshal/xref/XReferenceConverter.java
+++ b/hudson-utils/src/main/java/org/hudsonci/utils/marshal/xref/XReferenceConverter.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -39,8 +39,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
* @since 2.1.0
*/
public abstract class XReferenceConverter
- extends AbstractReflectionConverter
-{
+ extends AbstractReflectionConverter {
+
protected HolderType holderType = HolderType.HARD;
public XReferenceConverter(final Mapper mapper, final ReflectionProvider reflection) {
@@ -65,14 +65,13 @@ public abstract class XReferenceConverter
super.doMarshal(source, writer, context);
// Then delegate the storage of the reference target
- XReference ref = (XReference)source;
+ XReference ref = (XReference) source;
Object target = ref.get();
if (target != null) {
try {
store(ref);
ref.holder = createStoredHolder(ref, target);
- }
- catch (Exception e) {
+ } catch (Exception e) {
throw new ConversionException("Failed to marshal reference: " + ref, e);
}
}
@@ -129,8 +128,8 @@ public abstract class XReferenceConverter
* Support for {@link XReference.Holder} implementations.
*/
protected abstract class HolderSupport
- implements XReference.Holder
- {
+ implements XReference.Holder {
+
protected final XReference ref;
protected HolderSupport(final XReference ref) {
@@ -140,8 +139,7 @@ public abstract class XReferenceConverter
protected Object doLoad() {
try {
return load(ref);
- }
- catch (Exception e) {
+ } catch (Exception e) {
throw new ConversionException("Failed to unmarshal reference: " + ref, e);
}
}
@@ -150,13 +148,12 @@ public abstract class XReferenceConverter
/**
* Default holder types.
*/
- public static enum HolderType
- {
+ public static enum HolderType {
+
/**
* Use hard references.
*/
HARD,
-
/**
* Use soft references.
*/
@@ -167,8 +164,8 @@ public abstract class XReferenceConverter
* Unmarshalling holder with a hard reference.
*/
protected class UnmarshalHolder
- extends HolderSupport
- {
+ extends HolderSupport {
+
protected Object instance;
protected UnmarshalHolder(final XReference ref) {
@@ -184,9 +181,9 @@ public abstract class XReferenceConverter
@Override
public String toString() {
- return "UnmarshalHolder{" +
- "instance=" + instance +
- '}';
+ return "UnmarshalHolder{"
+ + "instance=" + instance
+ + '}';
}
}
@@ -195,8 +192,8 @@ public abstract class XReferenceConverter
*/
@SuppressWarnings({"unchecked"})
protected class SoftUnmarshalHolder
- extends HolderSupport
- {
+ extends HolderSupport {
+
protected SoftReference instance;
protected SoftUnmarshalHolder(final XReference ref) {
@@ -220,9 +217,9 @@ public abstract class XReferenceConverter
@Override
public String toString() {
- return "SoftUnmarshalHolder{" +
- "instance=" + instance +
- '}';
+ return "SoftUnmarshalHolder{"
+ + "instance=" + instance
+ + '}';
}
}
}