forked from docker-java/docker-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPushImageResultCallback.java
More file actions
58 lines (49 loc) · 1.61 KB
/
Copy pathPushImageResultCallback.java
File metadata and controls
58 lines (49 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
* Created on 21.07.2015
*/
package com.github.dockerjava.core.command;
import com.github.dockerjava.api.exception.DockerClientException;
import com.github.dockerjava.api.model.PushResponseItem;
import com.github.dockerjava.core.async.ResultCallbackTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.CheckForNull;
import java.util.concurrent.TimeUnit;
/**
*
* @author Marcus Linke
*
*/
public class PushImageResultCallback extends ResultCallbackTemplate<PushImageResultCallback, PushResponseItem> {
private static final Logger LOGGER = LoggerFactory.getLogger(PushImageResultCallback.class);
@CheckForNull
private PushResponseItem latestItem = null;
@Override
public void onNext(PushResponseItem item) {
this.latestItem = item;
LOGGER.debug(item.toString());
}
@Override
protected void throwFirstError() {
super.throwFirstError();
if (latestItem == null) {
throw new DockerClientException("Could not push image");
} else if (latestItem.isErrorIndicated()) {
throw new DockerClientException("Could not push image: " + latestItem.getError());
}
}
/**
* Awaits the image to be pulled successful.
*
* @deprecated use {@link #awaitCompletion()} or {@link #awaitCompletion(long, TimeUnit)} instead
* @throws DockerClientException
* if the push fails.
*/
public void awaitSuccess() {
try {
awaitCompletion();
} catch (InterruptedException e) {
throw new DockerClientException("", e);
}
}
}