/** * @return Detailed message from the underlying cause. */ public String getDetail() { return this.getDetail(true); }
@Override public void close() throws IOException { super.close(); try { final T response = this.getStatus(); if(log.isDebugEnabled()) { log.debug(String.format("Closed stream %s with response value %s", this, response)); } } catch(BackgroundException e) { throw new IOException(e.getDetail(), e); } } }
@Override public boolean retryRequest(final HttpResponse response, final int executionCount, final HttpContext context) { switch(response.getStatusLine().getStatusCode()) { case HttpStatus.SC_UNAUTHORIZED: if(executionCount <= MAX_RETRIES) { try { log.info(String.format("Attempt to refresh OAuth tokens for failure %s", response)); service.setTokens(service.refresh()); return true; } catch(BackgroundException e) { log.warn(String.format("Failure refreshing OAuth tokens. %s", e.getDetail())); return false; } } break; } return false; } }
@Override public void visit(final AttributedList<Path> list, final int index, final Path f) { try { f.getType().add(Path.Type.encrypted); list.set(index, vault.decrypt(session, f)); } catch(BackgroundException e) { log.error(String.format("Failure decrypting %s. %s", f, e.getDetail())); f.getType().remove(Path.Type.encrypted); } }
@Override public void cleanup(final Transfer download) { // Save checksum before edit try { checksum = ChecksumComputeFactory.get(HashAlgorithm.md5).compute(local.getInputStream(), new TransferStatus()); } catch(BackgroundException e) { log.warn(String.format("Error computing checksum for %s. %s", local, e.getDetail())); } } };
log.warn(String.format("Failure interrupting session %s prior releasing to pool. %s", session, e.getDetail()));
@Override public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException { if(tokens.isExpired()) { try { tokens = this.refresh(tokens); } catch(BackgroundException e) { log.warn(String.format("Failure refreshing OAuth 2 tokens. %s", e.getDetail())); throw new IOException(e); } } if(StringUtils.isNotBlank(tokens.getAccessToken())) { if(log.isInfoEnabled()) { log.info(String.format("Authorizing service request with OAuth2 access token %s", tokens.getAccessToken())); } request.removeHeaders(HttpHeaders.AUTHORIZATION); request.addHeader(new BasicHeader(HttpHeaders.AUTHORIZATION, String.format("Bearer %s", tokens.getAccessToken()))); } }
@Override public Vault load(final Path directory, final String masterkey, final byte[] pepper) throws VaultUnlockCancelException { synchronized(registry) { if(registry.contains(directory)) { return registry.find(session, directory); } final Vault vault = VaultFactory.get(directory, masterkey, pepper); if(log.isInfoEnabled()) { log.info(String.format("Loading vault %s for session %s", vault, session)); } try { registry.add(vault.load(session, prompt, keychain)); } catch(BackgroundException e) { log.warn(String.format("Failure loading vault %s. %s", vault, e.getDetail())); throw new VaultUnlockCancelException(vault, e); } return vault; } } }
@Override public Space get() throws BackgroundException { final Path home = new SFTPHomeDirectoryService(session).find(); if(this.isSpaceAvailableExtensionAvailable()) { try { return this.getSpaceAvailable(session.sftp(), home); } catch(BackgroundException e) { log.info(String.format("Failure obtaining disk quota. %s.", e.getDetail())); } } if(this.isStatVFSOpenSSHSupported()) { try { return this.getSpaceStatVFSOpenSSH(session.sftp(), home); } catch(BackgroundException e) { log.info(String.format("Failure obtaining disk quota. %s.", e.getDetail())); } } try { return this.getSpaceShellPrompt(home); } catch(BackgroundException e) { log.info(String.format("Failure obtaining disk quota. %s.", e.getDetail())); } return new Space(0L, Long.MAX_VALUE); }
log.warn(String.format("Error computing checksum for %s. %s", local, e.getDetail())); return Worker.empty();
@Override public Map<String, String> getMetadata(final Path file) throws BackgroundException { try { final List<DavResource> resources = session.getClient().list(new DAVPathEncoder().encode(file)); for(DavResource resource : resources) { return resource.getCustomProps(); } return Collections.emptyMap(); } catch(SardineException e) { try { throw new DAVExceptionMappingService().map("Failure to read attributes of {0}", e, file); } catch(InteroperabilityException | NotfoundException i) { log.warn(String.format("Failure to obtain attributes of %s. %s", file, i.getDetail())); // Workaround for #8902 return Collections.emptyMap(); } } catch(IOException e) { throw new HttpExceptionMappingService().map(e, file); } }
@Override public void loadBundle() { final NSAlert alert = NSAlert.alert(); alert.setMessageText(null == failure.getMessage() ? LocaleFactory.localizedString("Unknown") : failure.getMessage()); alert.setInformativeText(null == failure.getDetail() ? LocaleFactory.localizedString("Unknown") : failure.getDetail()); alert.addButtonWithTitle(defaultButton); alert.addButtonWithTitle(cancelButton); if(new DefaultFailureDiagnostics().determine(failure) == FailureDiagnostics.Type.network) { alert.addButtonWithTitle(LocaleFactory.localizedString("Network Diagnostics", "Alert")); } this.loadBundle(alert); }
/** * @return No Content-Range support */ @Override public Append append(final Path file, final Long length, final Cache<Path> cache) throws BackgroundException { if(length >= preferences.getLong("s3.upload.multipart.threshold")) { if(preferences.getBoolean("s3.upload.multipart")) { try { final List<MultipartUpload> upload = multipartService.find(file); if(!upload.isEmpty()) { Long size = 0L; for(MultipartPart completed : multipartService.list(upload.iterator().next())) { size += completed.getSize(); } return new Append(size); } } catch(AccessDeniedException | InteroperabilityException e) { log.warn(String.format("Ignore failure listing incomplete multipart uploads. %s", e.getDetail())); } } } if(finder.withCache(cache).find(file)) { final PathAttributes attr = attributes.withCache(cache).find(file); return new Append(false, true).withSize(attr.getSize()).withChecksum(attr.getChecksum()); } return Write.notfound; }
@Override public boolean prompt(final TransferItem item, final TransferStatus status, final BackgroundException failure) throws BackgroundException { final StringAppender appender = new StringAppender(); appender.append(failure.getMessage()); appender.append(failure.getDetail()); console.message(appender.toString()); if(!prompt.prompt(LocaleFactory.localizedString("Continue", "Credentials"))) { throw failure; } return true; } }
throw new LoginFailureException(failure.getDetail(), failure);
@Override public void loadBundle() { final NSAlert alert = NSAlert.alert(); alert.setAlertStyle(NSAlert.NSWarningAlertStyle); alert.setMessageText(null == failure.getMessage() ? LocaleFactory.localizedString("Unknown") : failure.getMessage()); alert.setInformativeText(null == failure.getDetail() ? LocaleFactory.localizedString("Unknown") : failure.getDetail()); alert.addButtonWithTitle(LocaleFactory.localizedString("Cancel")); alert.addButtonWithTitle(LocaleFactory.localizedString("Continue", "Credentials")); alert.setShowsSuppressionButton(true); alert.suppressionButton().setTitle(LocaleFactory.localizedString("Always")); super.loadBundle(alert); } }
@Override public boolean alert(final Host host, final BackgroundException failure, final StringBuilder transcript) { switch(new DefaultFailureDiagnostics().determine(failure)) { case cancel: return false; default: final StringAppender appender = new StringAppender(); appender.append(failure.getMessage()); appender.append(failure.getDetail()); console.printf("%n%s%n", appender.toString()); } // Never repeat return false; } }
@Override public Path copy(final Path source, final Path target, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { if(source.isFile() || source.isPlaceholder()) { if(null == status.getStorageClass()) { // Keep same storage class status.setStorageClass(new S3StorageClassFeature(session).getClass(source)); } if(Encryption.Algorithm.NONE == status.getEncryption()) { // Keep encryption setting status.setEncryption(new S3EncryptionFeature(session).getEncryption(source)); } if(Acl.EMPTY == status.getAcl()) { // Apply non standard ACL try { status.setAcl(accessControlListFeature.getPermission(source)); } catch(AccessDeniedException | InteroperabilityException e) { log.warn(String.format("Ignore failure %s", e.getDetail())); } } final S3Object destination = new S3WriteFeature(session).getDetails(target, status); destination.setAcl(accessControlListFeature.convert(status.getAcl())); destination.setBucketName(containerService.getContainer(target).getName()); destination.replaceAllMetadata(new HashMap<String, Object>(new S3MetadataFeature(session, accessControlListFeature).getMetadata(source))); final String version = this.copy(source, destination, status); target.attributes().setVersionId(version); } return target; }
log.warn(String.format("Ignore failure %s", e.getDetail()));