@Test public void testMapReadFailure() { assertEquals(SocketException.class, new SFTPExceptionMappingService().map(new SocketException("Unexpected end of sftp stream.")).getCause().getClass()); }
@Override public BackgroundException map(final IOException e) { if(ExceptionUtils.getRootCause(e) != e && ExceptionUtils.getRootCause(e) instanceof SSHException) { return this.map((SSHException) ExceptionUtils.getRootCause(e)); } final StringBuilder buffer = new StringBuilder(); this.append(buffer, e.getMessage()); if(ExceptionUtils.getRootCause(e) != e) { if(!StringUtils.equals(e.getMessage(), ExceptionUtils.getRootCause(e).getMessage())) { this.append(buffer, ExceptionUtils.getRootCause(e).getMessage()); } } if(e instanceof SFTPException) { final SFTPException failure = (SFTPException) e; final Response.StatusCode code = failure.getStatusCode(); switch(code) { case UNKNOWN: case BAD_MESSAGE: case FAILURE: case OP_UNSUPPORTED: 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); case NO_CONNECTION: case CONNECITON_LOST: return new ConnectionRefusedException(buffer.toString(), e); } } if(e instanceof UserAuthException) { return new LoginFailureException(buffer.toString(), e); } if(e instanceof ConnectionException) { return new ConnectionRefusedException(buffer.toString(), e); } if(e instanceof Buffer.BufferException) { return new InteroperabilityException(buffer.toString(), e); } if(e instanceof SSHException) { final SSHException failure = (SSHException) e; final DisconnectReason reason = failure.getDisconnectReason(); return this.map(e, buffer, reason); } return this.wrap(e, buffer); }
SFTPExceptionMappingService extends AbstractExceptionMappingService<IOException> { @Override public BackgroundException map(final IOException e) { if(ExceptionUtils.getRootCause(e) != e && ExceptionUtils.getRootCause(e) instanceof SSHException) { return this.map((SSHException) ExceptionUtils.getRootCause(e)); } final StringBuilder buffer = new StringBuilder(); this.append(buffer, e.getMessage()); if(ExceptionUtils.getRootCause(e) != e) { if(!StringUtils.equals(e.getMessage(), ExceptionUtils.getRootCause(e).getMessage())) { this.append(buffer, ExceptionUtils.getRootCause(e).getMessage()); } } if(e instanceof SFTPException) { final SFTPException failure = (SFTPException) e; final Response.StatusCode code = failure.getStatusCode(); switch(code) { case UNKNOWN: case BAD_MESSAGE: case FAILURE: case OP_UNSUPPORTED: 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); case NO_CONNECTION: case CONNECITON_LOST: return new ConnectionRefusedException(buffer.toString(), e); } } if(e instanceof UserAuthException) { return new LoginFailureException(buffer.toString(), e); } if(e instanceof ConnectionException) { return new ConnectionRefusedException(buffer.toString(), e); } if(e instanceof Buffer.BufferException) { return new InteroperabilityException(buffer.toString(), e); } if(e instanceof SSHException) { final SSHException failure = (SSHException) e; final DisconnectReason reason = failure.getDisconnectReason(); return this.map(e, buffer, reason); } return this.wrap(e, buffer); } }
SFTPExceptionMappingService extends AbstractExceptionMappingService<IOException> { @Override public BackgroundException map(final IOException e) { if(ExceptionUtils.getRootCause(e) != e && ExceptionUtils.getRootCause(e) instanceof SSHException) { return this.map((SSHException) ExceptionUtils.getRootCause(e)); } final StringBuilder buffer = new StringBuilder(); this.append(buffer, e.getMessage()); if(ExceptionUtils.getRootCause(e) != e) { if(!StringUtils.equals(e.getMessage(), ExceptionUtils.getRootCause(e).getMessage())) { this.append(buffer, ExceptionUtils.getRootCause(e).getMessage()); } } if(e instanceof SFTPException) { final SFTPException failure = (SFTPException) e; final Response.StatusCode code = failure.getStatusCode(); switch(code) { case UNKNOWN: case BAD_MESSAGE: case FAILURE: case OP_UNSUPPORTED: 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); case NO_CONNECTION: case CONNECITON_LOST: return new ConnectionRefusedException(buffer.toString(), e); } } if(e instanceof UserAuthException) { return new LoginFailureException(buffer.toString(), e); } if(e instanceof ConnectionException) { return new ConnectionRefusedException(buffer.toString(), e); } if(e instanceof Buffer.BufferException) { return new InteroperabilityException(buffer.toString(), e); } if(e instanceof SSHException) { final SSHException failure = (SSHException) e; final DisconnectReason reason = failure.getDisconnectReason(); return this.map(e, buffer, reason); } return this.wrap(e, buffer); }  }
SFTPExceptionMappingService extends AbstractExceptionMappingService<IOException> { @Override public BackgroundException map(final IOException e) { if(ExceptionUtils.getRootCause(e) != e && ExceptionUtils.getRootCause(e) instanceof SSHException) { return this.map((SSHException) ExceptionUtils.getRootCause(e)); } final StringBuilder buffer = new StringBuilder(); this.append(buffer, e.getMessage()); if(ExceptionUtils.getRootCause(e) != e) { if(!StringUtils.equals(e.getMessage(), ExceptionUtils.getRootCause(e).getMessage())) { this.append(buffer, ExceptionUtils.getRootCause(e).getMessage()); } } if(e instanceof SFTPException) { final SFTPException failure = (SFTPException) e; final Response.StatusCode code = failure.getStatusCode(); switch(code) { case UNKNOWN: case BAD_MESSAGE: case FAILURE: case OP_UNSUPPORTED: 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); case NO_CONNECTION: case CONNECITON_LOST: return new ConnectionRefusedException(buffer.toString(), e); } } if(e instanceof UserAuthException) { return new LoginFailureException(buffer.toString(), e); } if(e instanceof ConnectionException) { return new ConnectionRefusedException(buffer.toString(), e); } if(e instanceof Buffer.BufferException) { return new InteroperabilityException(buffer.toString(), e); } if(e instanceof SSHException) { final SSHException failure = (SSHException) e; final DisconnectReason reason = failure.getDisconnectReason(); return this.map(e, buffer, reason); } return this.wrap(e, buffer); }  @Override BackgroundException map(final IOException e); BackgroundException map(final IOException e, final StringBuilder buffer, final DisconnectReason reason); }
SFTPExceptionMappingService extends AbstractExceptionMappingService<IOException> { @Override public BackgroundException map(final IOException e) { if(ExceptionUtils.getRootCause(e) != e && ExceptionUtils.getRootCause(e) instanceof SSHException) { return this.map((SSHException) ExceptionUtils.getRootCause(e)); } final StringBuilder buffer = new StringBuilder(); this.append(buffer, e.getMessage()); if(ExceptionUtils.getRootCause(e) != e) { if(!StringUtils.equals(e.getMessage(), ExceptionUtils.getRootCause(e).getMessage())) { this.append(buffer, ExceptionUtils.getRootCause(e).getMessage()); } } if(e instanceof SFTPException) { final SFTPException failure = (SFTPException) e; final Response.StatusCode code = failure.getStatusCode(); switch(code) { case UNKNOWN: case BAD_MESSAGE: case FAILURE: case OP_UNSUPPORTED: 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); case NO_CONNECTION: case CONNECITON_LOST: return new ConnectionRefusedException(buffer.toString(), e); } } if(e instanceof UserAuthException) { return new LoginFailureException(buffer.toString(), e); } if(e instanceof ConnectionException) { return new ConnectionRefusedException(buffer.toString(), e); } if(e instanceof Buffer.BufferException) { return new InteroperabilityException(buffer.toString(), e); } if(e instanceof SSHException) { final SSHException failure = (SSHException) e; final DisconnectReason reason = failure.getDisconnectReason(); return this.map(e, buffer, reason); } return this.wrap(e, buffer); }  @Override BackgroundException map(final IOException e); BackgroundException map(final IOException e, final StringBuilder buffer, final DisconnectReason reason);  }