@Override @SuppressWarnings("fallthrough") public boolean stopDownload() { switch (getStatus()) { case IN_PROGRESS: if (request != null) { request.abort(); } status = TemplateDownloader.Status.ABORTED; return true; case UNKNOWN: case NOT_STARTED: case RECOVERABLE_ERROR: case UNRECOVERABLE_ERROR: case ABORTED: status = TemplateDownloader.Status.ABORTED; case DOWNLOAD_FINISHED: File f = new File(toFile); if (f.exists()) { f.delete(); } return true; default: return true; } }
public VerifyFormat invoke() { String uripath = null; try { URI str = new URI(downloadUrl); uripath = str.getPath(); } catch (URISyntaxException e) { s_logger.warn("Invalid download url: " + downloadUrl + ", This should not happen since we have validated the url before!!"); } String unsupportedFormat = ImageStoreUtil.checkTemplateFormat(file.getAbsolutePath(), uripath); if (unsupportedFormat == null || !unsupportedFormat.isEmpty()) { try { request.abort(); } catch (Exception ex) { s_logger.debug("Error on http connection : " + ex.getMessage()); } status = Status.UNRECOVERABLE_ERROR; errorString = "Template content is unsupported, or mismatch between selected format and template content. Found : " + unsupportedFormat; invalidFormat = true; } else { s_logger.debug("Verified format of downloading file " + file.getAbsolutePath() + " is supported"); verifiedFormat = true; invalidFormat = false; } return this; } }
@Override public boolean stopDownload() { switch (status) { case IN_PROGRESS: if (getMethod != null) { getMethod.abort(); } break; case UNKNOWN: case NOT_STARTED: case RECOVERABLE_ERROR: case UNRECOVERABLE_ERROR: case ABORTED: case DOWNLOAD_FINISHED: // Remove the object if it already has been uploaded. S3Utils.deleteObject(s3TO, s3TO.getBucketName(), s3Key); break; default: break; } status = TemplateDownloader.Status.ABORTED; return true; }
method.abort(); method.releaseConnection();
method.abort(); method.releaseConnection();
synchronized (mCancellationRequested) { if (mCancellationRequested.get()) { mGet.abort(); throw new OperationCancelledException();