From fa0669bc7d0510c53321bba960e077da49b20606 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20B=C3=B8gh=20Fangel?= Date: Mon, 2 May 2016 11:56:11 +0200 Subject: [PATCH 1/2] Added option on job to specify waitRetryDelay and bumped API version to 1.22 --- .../java/com/blitline/image/Blitline.java | 2 +- .../com/blitline/image/BlitlineImageJob.java | 41 ++++++++++++++++--- 2 files changed, 36 insertions(+), 7 deletions(-) diff --git a/blitline-image-client/src/main/java/com/blitline/image/Blitline.java b/blitline-image-client/src/main/java/com/blitline/image/Blitline.java index a74d7bb..0a59f8d 100644 --- a/blitline-image-client/src/main/java/com/blitline/image/Blitline.java +++ b/blitline-image-client/src/main/java/com/blitline/image/Blitline.java @@ -56,7 +56,7 @@ public class Blitline { /** * The API version this library will invoke. 1.21 added the ability to append arbitrary EXIF to saved images. */ - public static final String BLITLINE_API_VERSION = "1.21"; + public static final String BLITLINE_API_VERSION = "1.22"; private Blitline() { } diff --git a/blitline-image-client/src/main/java/com/blitline/image/BlitlineImageJob.java b/blitline-image-client/src/main/java/com/blitline/image/BlitlineImageJob.java index a539076..25e5c9a 100644 --- a/blitline-image-client/src/main/java/com/blitline/image/BlitlineImageJob.java +++ b/blitline-image-client/src/main/java/com/blitline/image/BlitlineImageJob.java @@ -34,6 +34,7 @@ public class BlitlineImageJob implements Serializable { private final Boolean extendedMetadata; private final String postbackUrl; private final Map postbackHeaders; + private final Integer waitRetryDelay; private final List functions = new LinkedList(); public BlitlineImageJob(String applicationId, Object src, Boolean extendedMetadata, String postbackUrl) { @@ -42,18 +43,25 @@ public BlitlineImageJob(String applicationId, Object src, Boolean extendedMetada public BlitlineImageJob(String applicationId, Object src, Boolean extendedMetadata, String postbackUrl, Map postbackHeaders) { + this(applicationId, src, extendedMetadata, postbackUrl, postbackHeaders, null); + } + + public BlitlineImageJob(String applicationId, + Object src, + Boolean extendedMetadata, + String postbackUrl, + Map postbackHeaders, + Integer waitRetryDelay) { Validate.notNull(applicationId, "application ID must not be null"); this.applicationId = applicationId; - Validate.notNull(src, "image source must not be null"); this.src = src; - this.extendedMetadata = extendedMetadata; - this.postbackUrl = postbackUrl; - this.postbackHeaders = postbackHeaders == null ? null : Collections.unmodifiableMap(new HashMap( - postbackHeaders)); + postbackHeaders)); + if (waitRetryDelay != null) Validate.inclusiveBetween(0, Integer.MAX_VALUE, waitRetryDelay); + this.waitRetryDelay = waitRetryDelay; } public String getApplicationId() { @@ -76,6 +84,15 @@ public Map getPostbackHeaders() { return postbackHeaders; } + /** + * Retrieve the value (in seconds) for wait_retry_delay which determines how long time Blitline will wait before it retries a failed job. + * If not set, then Blitline will not retry a failed job. + * @return + */ + public Integer getWaitRetryDelay() { + return waitRetryDelay; + } + /** * Retrieve the value that will be set on the specified HTTP header on the job postback, or {@code null} if the named header is * not set. @@ -124,6 +141,8 @@ public static class Builder { private Map postbackHeaders = new HashMap(); + private Integer waitRetryDelay; + /** * Constructs a {@code Builder} instance for a single {@code Job}. * @@ -249,6 +268,16 @@ public Builder withExtendedMetadata() { return this; } + /** + * Specifies that Blitline should retry a failed job after this amount of second. + * @param waitRetryDelay + * @return + */ + public Builder withWaitRetryDelay(Integer waitRetryDelay) { + this.waitRetryDelay = waitRetryDelay; + return this; + } + /** * Build the job and apply one or more functions. * @@ -258,7 +287,7 @@ public Builder withExtendedMetadata() { */ public BlitlineImageJob apply(Function... functions) { Map postbackHeaders = this.postbackHeaders.isEmpty() ? null : this.postbackHeaders; - BlitlineImageJob job = new BlitlineImageJob(applicationId, src, extendedMetadata, postbackUrl, postbackHeaders); + BlitlineImageJob job = new BlitlineImageJob(applicationId, src, extendedMetadata, postbackUrl, postbackHeaders, waitRetryDelay); job.apply(functions); return job; } From 2b05ae8171eb8fe64eafd27a7911f872f7c9bfaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20B=C3=B8gh=20Fangel?= Date: Mon, 9 May 2016 13:33:08 +0200 Subject: [PATCH 2/2] Filled in missing blank javadoc and reverted deletion of blank lines in constructor --- .../java/com/blitline/image/BlitlineImageJob.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/blitline-image-client/src/main/java/com/blitline/image/BlitlineImageJob.java b/blitline-image-client/src/main/java/com/blitline/image/BlitlineImageJob.java index 25e5c9a..ac8e5ea 100644 --- a/blitline-image-client/src/main/java/com/blitline/image/BlitlineImageJob.java +++ b/blitline-image-client/src/main/java/com/blitline/image/BlitlineImageJob.java @@ -54,12 +54,17 @@ public BlitlineImageJob(String applicationId, Integer waitRetryDelay) { Validate.notNull(applicationId, "application ID must not be null"); this.applicationId = applicationId; + Validate.notNull(src, "image source must not be null"); this.src = src; + this.extendedMetadata = extendedMetadata; + this.postbackUrl = postbackUrl; + this.postbackHeaders = postbackHeaders == null ? null : Collections.unmodifiableMap(new HashMap( postbackHeaders)); + if (waitRetryDelay != null) Validate.inclusiveBetween(0, Integer.MAX_VALUE, waitRetryDelay); this.waitRetryDelay = waitRetryDelay; } @@ -87,7 +92,8 @@ public Map getPostbackHeaders() { /** * Retrieve the value (in seconds) for wait_retry_delay which determines how long time Blitline will wait before it retries a failed job. * If not set, then Blitline will not retry a failed job. - * @return + * + * @return The value (in seconds) for wait_retry_delay */ public Integer getWaitRetryDelay() { return waitRetryDelay; @@ -98,7 +104,7 @@ public Integer getWaitRetryDelay() { * not set. * * @param name the name of the HTTP header - * @return + * @return The value for the specified header (or null if the header is not set) */ public String getPostbackHeader(String name) { if (postbackHeaders == null) { @@ -270,8 +276,9 @@ public Builder withExtendedMetadata() { /** * Specifies that Blitline should retry a failed job after this amount of second. - * @param waitRetryDelay - * @return + * + * @param waitRetryDelay The wait retry delay in seconds + * @return this {@code Builder} object */ public Builder withWaitRetryDelay(Integer waitRetryDelay) { this.waitRetryDelay = waitRetryDelay;