diff --git a/src/main/java/com/github/dockerjava/api/model/BuildResponseItem.java b/src/main/java/com/github/dockerjava/api/model/BuildResponseItem.java index 37fae34e7..348a4c8f5 100644 --- a/src/main/java/com/github/dockerjava/api/model/BuildResponseItem.java +++ b/src/main/java/com/github/dockerjava/api/model/BuildResponseItem.java @@ -14,28 +14,23 @@ public class BuildResponseItem extends ResponseItem { private static final String BUILD_SUCCESS = "Successfully built"; - @JsonProperty("stream") - private String stream; - - public String getStream() { - return stream; - } - /** * Returns whether the stream field indicates a successful build operation */ @JsonIgnore public boolean isBuildSuccessIndicated() { - if (getStream() == null) + if (isErrorIndicated() || getStream() == null) { return false; + } return getStream().contains(BUILD_SUCCESS); } @JsonIgnore public String getImageId() { - if (!isBuildSuccessIndicated()) + if (!isBuildSuccessIndicated()) { return null; + } return getStream().replaceFirst(BUILD_SUCCESS, "").trim(); } diff --git a/src/main/java/com/github/dockerjava/api/model/PullResponseItem.java b/src/main/java/com/github/dockerjava/api/model/PullResponseItem.java index b2bedca60..834060b99 100644 --- a/src/main/java/com/github/dockerjava/api/model/PullResponseItem.java +++ b/src/main/java/com/github/dockerjava/api/model/PullResponseItem.java @@ -18,8 +18,9 @@ public class PullResponseItem extends ResponseItem { */ @JsonIgnore public boolean isPullSuccessIndicated() { - if (getStatus() == null) + if (isErrorIndicated() || getStatus() == null) { return false; + } return (getStatus().contains("Download complete") || getStatus().contains("Image is up to date") || getStatus() .contains("Downloaded newer image")); diff --git a/src/main/java/com/github/dockerjava/api/model/PushResponseItem.java b/src/main/java/com/github/dockerjava/api/model/PushResponseItem.java index 2555271fd..31a2329d8 100644 --- a/src/main/java/com/github/dockerjava/api/model/PushResponseItem.java +++ b/src/main/java/com/github/dockerjava/api/model/PushResponseItem.java @@ -11,16 +11,4 @@ public class PushResponseItem extends ResponseItem { private static final long serialVersionUID = 8256977108011295857L; - /** - * Returns whether the error field indicates an error - * - * @returns true: the error field indicates an error, false: the error field doesn't indicate an error - */ - @JsonIgnore - public boolean isErrorIndicated() { - if (getError() == null) - return false; - - return true; - } } diff --git a/src/main/java/com/github/dockerjava/api/model/ResponseItem.java b/src/main/java/com/github/dockerjava/api/model/ResponseItem.java index 3ea625164..ea16c0801 100644 --- a/src/main/java/com/github/dockerjava/api/model/ResponseItem.java +++ b/src/main/java/com/github/dockerjava/api/model/ResponseItem.java @@ -2,6 +2,7 @@ import java.io.Serializable; +import com.fasterxml.jackson.annotation.JsonIgnore; import org.apache.commons.lang.builder.ToStringBuilder; import org.apache.commons.lang.builder.ToStringStyle; @@ -16,57 +17,96 @@ public class ResponseItem implements Serializable { private static final long serialVersionUID = -5187169652557467828L; + @JsonProperty("stream") + private String stream; + @JsonProperty("status") private String status; + @JsonProperty("progressDetail") + private ProgressDetail progressDetail; + + @Deprecated @JsonProperty("progress") private String progress; - @JsonProperty("progressDetail") - private ProgressDetail progressDetail; + @JsonProperty("id") + private String id; - @JsonProperty("error") - private String error; + @JsonProperty("from") + private String from; + + @JsonProperty("time") + private long time; @JsonProperty("errorDetail") private ErrorDetail errorDetail; - @JsonProperty("id") - private String id; + @Deprecated + @JsonProperty("error") + private String error; - public String getStatus() { - return status; + public String getStream() { + return stream; } - public String getProgress() { - return progress; + public String getStatus() { + return status; } public ProgressDetail getProgressDetail() { return progressDetail; } + @Deprecated + public String getProgress() { + return progress; + } + public String getId() { return id; } - public String getError() { - return error; + public String getFrom() { + return from; + } + + public long getTime() { + return time; } public ErrorDetail getErrorDetail() { return errorDetail; } + @Deprecated + public String getError() { + return error; + } + + /** + * Returns whether the error field indicates an error + * + * @returns true: the error field indicates an error, false: the error field doesn't indicate an error + */ + @JsonIgnore + public boolean isErrorIndicated() { + // check both the deprecated and current error fields, just in case + return getError() != null || getErrorDetail() != null; + } + @JsonIgnoreProperties(ignoreUnknown = false) public static class ProgressDetail implements Serializable { private static final long serialVersionUID = -1954994695645715264L; @JsonProperty("current") - int current; + long current; @JsonProperty("total") - int total; + long total; + + @JsonProperty("start") + long start; @Override public String toString() { @@ -79,7 +119,7 @@ public static class ErrorDetail implements Serializable { private static final long serialVersionUID = -9136704865403084083L; @JsonProperty("code") - String code; + int code; @JsonProperty("message") String message;