org.jclouds.rest.ResourceNotFoundException Java Examples

The following examples show how to use org.jclouds.rest.ResourceNotFoundException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JenkinsAuthenticationFilter.java    From jenkins-rest with Apache License 2.0 6 votes vote down vote up
private Pair<Crumb, Boolean> getCrumb() {
    Pair<Crumb, Boolean> crumbValueInit = this.crumbPair;
    if (crumbValueInit == null) {
        synchronized(this) {
            crumbValueInit = this.crumbPair;
            if (crumbValueInit == null) {
                final Crumb crumb = jenkinsApi.crumbIssuerApi().crumb();
                final Boolean isRNFE = crumb.errors().isEmpty()
                        ? true
                        : crumb.errors().get(0).exceptionName().endsWith(ResourceNotFoundException.class.getSimpleName());
                this.crumbPair = crumbValueInit = new Pair(crumb, isRNFE);
            }
        }
    }
    return crumbValueInit;
}
 
Example #2
Source File: JenkinsFallbacks.java    From jenkins-rest with Apache License 2.0 5 votes vote down vote up
@Override
public Object createOrPropagate(final Throwable throwable) throws Exception {
    if (checkNotNull(throwable, "throwable") != null) {
        try {
            if (throwable.getClass() == ResourceNotFoundException.class) {
                return RequestStatus.create(true, null);
            } else {
                return RequestStatus.create(false, getErrors(throwable));
            }
        } catch (JsonSyntaxException e) {
            return RequestStatus.create(false, getErrors(e));
        }
    }
    throw propagate(throwable);
}
 
Example #3
Source File: DeleteRepositoryParser.java    From bitbucket-rest with Apache License 2.0 5 votes vote down vote up
@Override
public RequestStatus apply(final HttpResponse input) {
    final int statusCode = input.getStatusCode();
    if (statusCode >= 200 && statusCode < 400) {
        if (statusCode == 204) {
            throw new ResourceNotFoundException("The repository does not exist in this project.");
        } else {
            return RequestStatus.create(true, null);
        }
    } else {
        throw new RuntimeException(input.getStatusLine());
    }
}
 
Example #4
Source File: JcloudsIaas.java    From attic-stratos with Apache License 2.0 5 votes vote down vote up
private void detachVolume(MemberContext ctxt) {
    String clusterId = ctxt.getClusterId();
    ClusterContext clusterContext = CloudControllerContext.getInstance().getClusterContext(clusterId);
    if (clusterContext == null) {
        log.error(String.format(
                "Could not detach volume, Cluster context not found for the [member] %s [cluster-id] %s",
                ctxt.getMemberId(), clusterId));
        return;
    }

    if (clusterContext.getVolumes() != null) {
        for (Volume volume : clusterContext.getVolumes()) {
            try {
                String volumeId = volume.getId();
                if (volumeId == null) {
                    return;
                }
                detachVolume(ctxt.getInstanceId(), volumeId);
                if (volume.isRemoveOntermination()) {
                    deleteVolume(volumeId);
                }
            } catch (ResourceNotFoundException ignore) {
                if (log.isDebugEnabled()) {
                    log.debug(ignore);
                }
            }
        }
    }
}