@Override public void delete(final MultipartUpload upload) throws BackgroundException { throw new NotfoundException(upload.getUploadId()); } }
protected Path list(final Session<?> session) throws BackgroundException { Path home; AttributedList<Path> list; try { home = session.getFeature(Home.class).find(); // Remove cached home to force error if repeated attempt to mount fails cache.invalidate(home); // Retrieve directory listing of default path final SessionListWorker worker = new SessionListWorker(cache, home, listener); listener.message(worker.getActivity()); list = worker.run(session); } catch(NotfoundException e) { log.warn(String.format("Mount failed with %s", e.getMessage())); // The default path does not exist or is not readable due to possible permission issues. Fallback // to default working directory home = new Path(String.valueOf(Path.DELIMITER), EnumSet.of(Path.Type.volume, Path.Type.directory)); // Remove cached home to force error if repeated attempt to mount fails cache.invalidate(home); // Retrieve directory listing of working directory final SessionListWorker worker = new SessionListWorker(cache, home, listener); listener.message(worker.getActivity()); list = worker.run(session); } cache.put(home, list); return home; }
log.warn(String.format("Ignore failure %s deleting placeholder file for %s", e.getDetail(), file)); continue;
public OneDriveFolder toFolder(final Path file, final boolean resolveLastItem) throws BackgroundException { final OneDriveItem item = this.toItem(file, resolveLastItem); if(!(item instanceof OneDriveFolder)) { throw new NotfoundException(String.format("%s is not a folder.", file.getAbsolute())); } return (OneDriveFolder) item; }
public OneDriveFile toFile(final Path file, final boolean resolveLastItem) throws BackgroundException { final OneDriveItem item = this.toItem(file, resolveLastItem); if(!(item instanceof OneDriveFile)) { throw new NotfoundException(String.format("%s is not a file.", file.getAbsolute())); } return (OneDriveFile) item; }
@Override public BackgroundException map(final IOException e) { final StringBuilder buffer = new StringBuilder(); this.append(buffer, e.getMessage()); if(e instanceof NoSuchFileException) { return new NotfoundException(buffer.toString(), e); } if(e instanceof FileSystemException) { return new LocalAccessDeniedException(buffer.toString(), e); } return this.wrap(e, buffer); } }
@Override public boolean accept(final Path file, final Local local, final TransferStatus parent) throws BackgroundException { if(!local.exists()) { // Local file is no more here throw new NotfoundException(local.getAbsolute()); } return true; }
@Override public boolean accept(final Path file, final Local local, final TransferStatus parent) throws BackgroundException { final Local volume = local.getVolume(); if(!volume.exists()) { throw new NotfoundException(String.format("Volume %s not mounted", volume.getAbsolute())); } return true; }
@Override public BackgroundException map(final JargonException e) { final StringBuilder buffer = new StringBuilder(); this.append(buffer, e.getMessage()); if(e instanceof CatNoAccessException) { return new AccessDeniedException(buffer.toString(), e); } if(e instanceof FileNotFoundException) { return new NotfoundException(buffer.toString(), e); } if(e instanceof DataNotFoundException) { return new NotfoundException(buffer.toString(), e); } if(e instanceof AuthenticationException) { return new LoginFailureException(buffer.toString(), e); } if(e instanceof InvalidUserException) { return new LoginFailureException(buffer.toString(), e); } if(e instanceof InvalidGroupException) { return new LoginFailureException(buffer.toString(), e); } return this.wrap(e, buffer); } }
private BackgroundException handle(final FTPException e, final StringBuilder buffer) { final int status = e.getCode(); switch(status) { case FTPReply.INSUFFICIENT_STORAGE: case FTPReply.STORAGE_ALLOCATION_EXCEEDED: return new QuotaException(buffer.toString(), e); case FTPReply.NOT_LOGGED_IN: return new LoginFailureException(buffer.toString(), e); case FTPReply.FAILED_SECURITY_CHECK: case FTPReply.DENIED_FOR_POLICY_REASONS: case FTPReply.NEED_ACCOUNT: case FTPReply.NEED_ACCOUNT_FOR_STORING_FILES: case FTPReply.FILE_NAME_NOT_ALLOWED: case FTPReply.FILE_ACTION_NOT_TAKEN: case FTPReply.ACTION_ABORTED: return new AccessDeniedException(buffer.toString(), e); case FTPReply.UNAVAILABLE_RESOURCE: case FTPReply.FILE_UNAVAILABLE: // Requested action not taken. File unavailable (e.g., file not found, no access) return new NotfoundException(buffer.toString(), e); case FTPReply.SERVICE_NOT_AVAILABLE: return new ConnectionRefusedException(buffer.toString(), e); } return new InteroperabilityException(buffer.toString(), e); } }
@Override public BackgroundException map(final StorageException e) { final StringBuilder buffer = new StringBuilder(); this.append(buffer, e.getMessage()); if(ExceptionUtils.getRootCause(e) instanceof UnknownHostException) { return new NotfoundException(buffer.toString(), e); } switch(e.getHttpStatusCode()) { case 403: return new LoginFailureException(buffer.toString(), e); case 404: return new NotfoundException(buffer.toString(), e); case 304: case 405: case 400: case 411: case 412: return new InteroperabilityException(buffer.toString(), e); case 500: // InternalError // OperationTimedOut return new ConnectionTimeoutException(buffer.toString(), e); case 503: // ServerBusy return new RetriableAccessDeniedException(buffer.toString(), e); } return this.wrap(e, buffer); } }
case HttpStatus.SC_GONE: case HttpStatus.SC_REQUESTED_RANGE_NOT_SATISFIABLE: return new NotfoundException(buffer.toString(), failure); case HttpStatus.SC_INSUFFICIENT_SPACE_ON_RESOURCE: case HttpStatus.SC_INSUFFICIENT_STORAGE:
public void cancel(final Transfer.Type type, final Path file, final TransferStatus status) throws BackgroundException { try { if(!status.getParameters().containsKey(REQUEST_PARAMETER_JOBID_IDENTIFIER)) { throw new NotfoundException(String.format("Missing job id parameter in status for %s", file.getName())); } final String job = status.getParameters().get(REQUEST_PARAMETER_JOBID_IDENTIFIER); if(log.isDebugEnabled()) { log.debug(String.format("Cancel job %s", job)); } final Ds3Client client = new SpectraClientBuilder().wrap(session.getClient(), session.getHost()); client.cancelJobSpectraS3(new CancelJobSpectraS3Request(job)); } catch(FailedRequestException e) { throw new SpectraExceptionMappingService().map(e); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } }
case HttpStatus.SC_BAD_REQUEST: if("file_not_present".equalsIgnoreCase(e.getCode())) { return new NotfoundException(buffer.toString(), e); return new NotfoundException(buffer.toString(), e);
throw new NotfoundException(String.format("Missing job id parameter in status for %s", file.getName()));
final String versionId = fileIdProvider.getFileid(file, new DisabledListProgressListener()); if(StringUtils.isEmpty(versionId)) { throw new NotfoundException(String.format("Version ID for %s is empty", file.getAbsolute())); throw new NotfoundException(file.getAbsolute()); throw new NotfoundException(file.getAbsolute());
return new InteroperabilityException(buffer.toString(), e); case NO_SUCH_FILE: return new NotfoundException(buffer.toString(), e); case PERMISSION_DENIED: return new AccessDeniedException(buffer.toString(), e);
throw new NotfoundException(String.format("Version ID for %s is empty", file.getAbsolute())); throw new NotfoundException(file.getAbsolute()); return new OneDrivePackageItem(getClient(), drive, itemId, OneDriveItem.ItemIdentifierType.Id); throw new NotfoundException(file.getAbsolute());
throw new NotfoundException(directory.getAbsolute()); return new Path(intermediate, directoryIdHash.substring(2), type, attributes); throw new NotfoundException(directory.getAbsolute());
@Override public PathAttributes find(final Path file) throws BackgroundException { if(file.isRoot()) { return PathAttributes.EMPTY; } try { final Path found = this.search(file); if(null == found) { throw new NotfoundException(file.getAbsolute()); } return found.attributes(); } catch(InteroperabilityException | AccessDeniedException | NotfoundException f) { log.warn(String.format("Failure listing directory %s. %s", file.getParent(), f.getMessage())); // Try native implementation final AttributesFinder feature = session._getFeature(AttributesFinder.class); if(feature instanceof DefaultAttributesFinderFeature) { throw f; } return feature.withCache(cache).find(file); } }