Skip to content

Commit 39015a4

Browse files
author
Marcus Linke
committed
Merge branch 'fix-progress-detail-serializer' of https://github.com/llamahunter/docker-java into llamahunter-fix-progress-detail-serializer
2 parents 95d6145 + 7ff1670 commit 39015a4

File tree

4 files changed

+61
-37
lines changed

4 files changed

+61
-37
lines changed

src/main/java/com/github/dockerjava/api/model/BuildResponseItem.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,23 @@ public class BuildResponseItem extends ResponseItem {
1414

1515
private static final String BUILD_SUCCESS = "Successfully built";
1616

17-
@JsonProperty("stream")
18-
private String stream;
19-
20-
public String getStream() {
21-
return stream;
22-
}
23-
2417
/**
2518
* Returns whether the stream field indicates a successful build operation
2619
*/
2720
@JsonIgnore
2821
public boolean isBuildSuccessIndicated() {
29-
if (getStream() == null)
22+
if (isErrorIndicated() || getStream() == null) {
3023
return false;
24+
}
3125

3226
return getStream().contains(BUILD_SUCCESS);
3327
}
3428

3529
@JsonIgnore
3630
public String getImageId() {
37-
if (!isBuildSuccessIndicated())
31+
if (!isBuildSuccessIndicated()) {
3832
return null;
33+
}
3934

4035
return getStream().replaceFirst(BUILD_SUCCESS, "").trim();
4136
}

src/main/java/com/github/dockerjava/api/model/PullResponseItem.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ public class PullResponseItem extends ResponseItem {
1818
*/
1919
@JsonIgnore
2020
public boolean isPullSuccessIndicated() {
21-
if (getStatus() == null)
21+
if (isErrorIndicated() || getStatus() == null) {
2222
return false;
23+
}
2324

2425
return (getStatus().contains("Download complete") || getStatus().contains("Image is up to date") || getStatus()
2526
.contains("Downloaded newer image"));

src/main/java/com/github/dockerjava/api/model/PushResponseItem.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,4 @@ public class PushResponseItem extends ResponseItem {
1111

1212
private static final long serialVersionUID = 8256977108011295857L;
1313

14-
/**
15-
* Returns whether the error field indicates an error
16-
*
17-
* @returns true: the error field indicates an error, false: the error field doesn't indicate an error
18-
*/
19-
@JsonIgnore
20-
public boolean isErrorIndicated() {
21-
if (getError() == null)
22-
return false;
23-
24-
return true;
25-
}
2614
}

src/main/java/com/github/dockerjava/api/model/ResponseItem.java

Lines changed: 55 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import java.io.Serializable;
44

5+
import com.fasterxml.jackson.annotation.JsonIgnore;
56
import org.apache.commons.lang.builder.ToStringBuilder;
67
import org.apache.commons.lang.builder.ToStringStyle;
78

@@ -16,57 +17,96 @@ public class ResponseItem implements Serializable {
1617

1718
private static final long serialVersionUID = -5187169652557467828L;
1819

20+
@JsonProperty("stream")
21+
private String stream;
22+
1923
@JsonProperty("status")
2024
private String status;
2125

26+
@JsonProperty("progressDetail")
27+
private ProgressDetail progressDetail;
28+
29+
@Deprecated
2230
@JsonProperty("progress")
2331
private String progress;
2432

25-
@JsonProperty("progressDetail")
26-
private ProgressDetail progressDetail;
33+
@JsonProperty("id")
34+
private String id;
2735

28-
@JsonProperty("error")
29-
private String error;
36+
@JsonProperty("from")
37+
private String from;
38+
39+
@JsonProperty("time")
40+
private long time;
3041

3142
@JsonProperty("errorDetail")
3243
private ErrorDetail errorDetail;
3344

34-
@JsonProperty("id")
35-
private String id;
45+
@Deprecated
46+
@JsonProperty("error")
47+
private String error;
3648

37-
public String getStatus() {
38-
return status;
49+
public String getStream() {
50+
return stream;
3951
}
4052

41-
public String getProgress() {
42-
return progress;
53+
public String getStatus() {
54+
return status;
4355
}
4456

4557
public ProgressDetail getProgressDetail() {
4658
return progressDetail;
4759
}
4860

61+
@Deprecated
62+
public String getProgress() {
63+
return progress;
64+
}
65+
4966
public String getId() {
5067
return id;
5168
}
5269

53-
public String getError() {
54-
return error;
70+
public String getFrom() {
71+
return from;
72+
}
73+
74+
public long getTime() {
75+
return time;
5576
}
5677

5778
public ErrorDetail getErrorDetail() {
5879
return errorDetail;
5980
}
6081

82+
@Deprecated
83+
public String getError() {
84+
return error;
85+
}
86+
87+
/**
88+
* Returns whether the error field indicates an error
89+
*
90+
* @returns true: the error field indicates an error, false: the error field doesn't indicate an error
91+
*/
92+
@JsonIgnore
93+
public boolean isErrorIndicated() {
94+
// check both the deprecated and current error fields, just in case
95+
return getError() != null || getErrorDetail() != null;
96+
}
97+
6198
@JsonIgnoreProperties(ignoreUnknown = false)
6299
public static class ProgressDetail implements Serializable {
63100
private static final long serialVersionUID = -1954994695645715264L;
64101

65102
@JsonProperty("current")
66-
int current;
103+
long current;
67104

68105
@JsonProperty("total")
69-
int total;
106+
long total;
107+
108+
@JsonProperty("start")
109+
long start;
70110

71111
@Override
72112
public String toString() {
@@ -79,7 +119,7 @@ public static class ErrorDetail implements Serializable {
79119
private static final long serialVersionUID = -9136704865403084083L;
80120

81121
@JsonProperty("code")
82-
String code;
122+
int code;
83123

84124
@JsonProperty("message")
85125
String message;

0 commit comments

Comments
 (0)