use of com.openshift.restclient.NotFoundException in project jbosstools-openshift by jbosstools.
the class DeployImageJob method updateTriggerIfUpdate.
protected boolean updateTriggerIfUpdate(Connection connection, String project, String name) {
try {
IDeploymentConfig dc = connection.getResource(ResourceKind.DEPLOYMENT_CONFIG, project, name);
IDeploymentImageChangeTrigger trigger = (IDeploymentImageChangeTrigger) dc.getTriggers().stream().filter(t -> DeploymentTriggerType.IMAGE_CHANGE.equals(t.getType())).findFirst().orElse(null);
if (trigger == null || !ResourceKind.IMAGE_STREAM_TAG.equals(trigger.getKind()) || StringUtils.isBlank(trigger.getNamespace()) || connection.getResource(ResourceKind.IMAGE_STREAM, trigger.getNamespace(), trigger.getFrom().getName()) == null) {
return false;
}
DockerImageURI sourceImage = getSourceImage();
if (sourceImage.getName().equals(trigger.getFrom().getName()) && !sourceImage.getTag().equals(trigger.getFrom().getTag())) {
trigger.setFrom(new DockerImageURI(null, null, sourceImage.getName(), sourceImage.getTag()));
connection.updateResource(dc);
}
return true;
} catch (NotFoundException e) {
return false;
} catch (OpenShiftException e) {
if (e.getStatus() != null && e.getStatus().getCode() == IHttpConstants.STATUS_NOT_FOUND) {
return false;
}
throw e;
}
}
Aggregations