Skip to content

Commit 6105dcd

Browse files
committed
Cleaning up code
Removed literal status values and replaced them with status constant. Removed unused imports.
1 parent 39266d7 commit 6105dcd

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

src/main/java/com/offbytwo/jenkins/JenkinsServer.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
import javax.xml.bind.JAXBException;
1515

16+
import org.apache.commons.httpclient.HttpStatus;
1617
import org.apache.http.client.HttpResponseException;
1718
import org.apache.http.entity.ContentType;
1819
import org.dom4j.DocumentException;
@@ -237,7 +238,7 @@ public JobWithDetails getJob(FolderJob folder, String jobName) throws IOExceptio
237238

238239
return job;
239240
} catch (HttpResponseException e) {
240-
if (e.getStatusCode() == 404) {
241+
if (e.getStatusCode() == HttpStatus.SC_NOT_FOUND) {
241242
return null;
242243
}
243244
throw e;
@@ -259,7 +260,7 @@ public MavenJobWithDetails getMavenJob(FolderJob folder, String jobName) throws
259260

260261
return job;
261262
} catch (HttpResponseException e) {
262-
if (e.getStatusCode() == 404) {
263+
if (e.getStatusCode() == HttpStatus.SC_NOT_FOUND) {
263264
return null;
264265
}
265266
throw e;
@@ -276,7 +277,7 @@ public Optional<FolderJob> getFolderJob(Job job) throws IOException {
276277

277278
return Optional.of(folder);
278279
} catch (HttpResponseException e) {
279-
if (e.getStatusCode() == 404) {
280+
if (e.getStatusCode() == HttpStatus.SC_NOT_FOUND) {
280281
return null;
281282
}
282283
throw e;
@@ -523,7 +524,7 @@ public QueueItem getQueueItem(QueueReference ref) throws IOException
523524

524525
return job;
525526
} catch (HttpResponseException e) {
526-
if (e.getStatusCode() == 404) {
527+
if (e.getStatusCode() == HttpStatus.SC_NOT_FOUND) {
527528
return null;
528529
}
529530
throw e;
@@ -541,7 +542,7 @@ public Build getBuild(QueueItem q) throws IOException
541542

542543
return job;
543544
} catch (HttpResponseException e) {
544-
if (e.getStatusCode() == 404) {
545+
if (e.getStatusCode() == HttpStatus.SC_NOT_FOUND) {
545546
return null;
546547
}
547548
throw e;

src/main/java/com/offbytwo/jenkins/client/JenkinsHttpClient.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,12 @@
1515
import java.util.List;
1616
import java.util.Map;
1717

18-
import net.sf.json.JSONObject;
19-
2018
import org.apache.commons.io.IOUtils;
2119
import org.apache.commons.lang.StringUtils;
2220
import org.apache.http.HttpResponse;
2321
import org.apache.http.auth.AuthScope;
2422
import org.apache.http.auth.UsernamePasswordCredentials;
2523
import org.apache.http.client.CredentialsProvider;
26-
import org.apache.http.client.config.RequestConfig;
2724
import org.apache.http.client.methods.HttpGet;
2825
import org.apache.http.client.methods.HttpPost;
2926
import org.apache.http.client.methods.HttpRequestBase;
@@ -51,6 +48,8 @@
5148
import com.offbytwo.jenkins.model.Crumb;
5249
import com.offbytwo.jenkins.model.ExtractHeader;
5350

51+
import net.sf.json.JSONObject;
52+
5453
public class JenkinsHttpClient {
5554

5655
private static final int SO_TIMEOUT_IN_MILLISECONDS = 3000;

0 commit comments

Comments
 (0)