Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
70 changes: 55 additions & 15 deletions src/main/java/com/github/dockerjava/api/model/ResponseItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deprecate also corresponding field?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's private, so don't really care as much.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not javadoc why it deprecated and what to use

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Talk to the docker people. Anyway, it's kind of obvious what the replacement is, no? ProgressDetail.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, not obvious when you don't remember all details of constantly changing API. Back to this place third time.

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() {
Expand All @@ -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;
Expand Down