@Override public void changeCurrentDirectory(String path) throws GenericFileOperationFailedException { throw new GenericFileOperationFailedException("Operation 'cd " + path + "' not supported by the scp: protocol"); }
throw new GenericFileOperationFailedException("Interrupted during connecting", new InterruptedException("Interrupted during connecting")); GenericFileOperationFailedException failed = new GenericFileOperationFailedException("Cannot connect to " + configuration.remoteServerInformation(), e); LOG.trace("Cannot connect due: {}", failed.getMessage()); attempt++; if (attempt > endpoint.getMaximumReconnectAttempts()) { throw new GenericFileOperationFailedException("Interrupted during sleeping", ie);
protected void forceDisconnect() { // eager indicate we are no longer logged in loggedIn = false; // disconnect try { if (log.isDebugEnabled()) { log.debug("Force disconnecting from: {}", remoteServer()); } getOperations().forceDisconnect(); } catch (GenericFileOperationFailedException e) { // ignore just log a warning log.warn("Error occurred while disconnecting from " + remoteServer() + " due: " + e.getMessage() + ". This exception will be ignored."); } }
@Override protected boolean ignoreCannotRetrieveFile(String name, Exchange exchange, Exception cause) { if (getEndpoint().getConfiguration().isIgnoreFileNotFoundOrPermissionError()) { if (exchange != null) { // error code 550 is file not found int code = exchange.getIn().getHeader(FtpConstants.FTP_REPLY_CODE, 0, int.class); if (code == 550) { return true; } } if (cause instanceof GenericFileOperationFailedException) { GenericFileOperationFailedException generic = ObjectHelper.getException(GenericFileOperationFailedException.class, cause); //exchange is null and cause has the reason for failure to read directories if (generic.getCode() == 550) { return true; } } } return super.ignoreCannotRetrieveFile(name, exchange, cause); }
} else { throw new GenericFileOperationFailedException(client.getReplyCode(), client.getReplyString(), "Server refused connection"); throw new GenericFileOperationFailedException("Interrupted during connecting", new InterruptedException("Interrupted during connecting")); failed = (GenericFileOperationFailedException) e; } else { failed = new GenericFileOperationFailedException(client.getReplyCode(), client.getReplyString(), e.getMessage(), e); log.trace("Cannot connect due: {}", failed.getMessage()); attempt++; if (attempt > endpoint.getMaximumReconnectAttempts()) { throw new GenericFileOperationFailedException("Interrupted during sleeping", ie); client.setSoTimeout(ftpEndpoint.getSoTimeout()); } catch (IOException e) { throw new GenericFileOperationFailedException(client.getReplyCode(), client.getReplyString(), e.getMessage(), e); throw new GenericFileOperationFailedException(replyCode, replyString); throw new GenericFileOperationFailedException(client.getReplyCode(), client.getReplyString(), e.getMessage(), e); boolean result = sendSiteCommand(command); if (!result) { throw new GenericFileOperationFailedException("Site command: " + command + " returned false");
protected void disconnect() { // eager indicate we are no longer logged in loggedIn = false; // disconnect try { if (getOperations().isConnected()) { if (log.isDebugEnabled()) { log.debug("Disconnecting from: {}", remoteServer()); } getOperations().disconnect(); } } catch (GenericFileOperationFailedException e) { // ignore just log a warning log.warn("Error occurred while disconnecting from " + remoteServer() + " due: " + e.getMessage() + ". This exception will be ignored."); } }
@Override public List<ScpFile> listFiles(String path) throws GenericFileOperationFailedException { throw new GenericFileOperationFailedException("Operation 'ls " + path + "' not supported by the scp: protocol"); }
public void disconnect() throws GenericFileOperationFailedException { try { doDisconnect(); } catch (GenericFileOperationFailedException e) { clientActivityListener.onGeneralError(endpoint.getConfiguration().remoteServerInformation(), e.getMessage()); throw e; } }
@Override public boolean renameFile(String from, String to) throws GenericFileOperationFailedException { throw new GenericFileOperationFailedException("Operation 'rename' not supported by the scp: protocol"); }
public boolean connect(RemoteFileConfiguration configuration) throws GenericFileOperationFailedException { client.setCopyStreamListener(clientActivityListener); try { return doConnect(configuration); } catch (GenericFileOperationFailedException e) { clientActivityListener.onGeneralError(endpoint.getConfiguration().remoteServerInformation(), e.getMessage()); throw e; } }
@Override public void changeToParentDirectory() throws GenericFileOperationFailedException { throw new GenericFileOperationFailedException("Operation 'cd ..' not supported by the scp: protocol"); }
@Override public void postWriteCheck(Exchange exchange) { try { boolean isLast = exchange.getProperty(Exchange.BATCH_COMPLETE, false, Boolean.class); if (isLast && getEndpoint().isDisconnectOnBatchComplete()) { log.trace("postWriteCheck disconnect on batch complete from: {}", getEndpoint()); disconnect(); } if (getEndpoint().isDisconnect()) { log.trace("postWriteCheck disconnect from: {}", getEndpoint()); disconnect(); } } catch (GenericFileOperationFailedException e) { // ignore just log a warning log.warn("Exception occurred during disconnecting from: " + getEndpoint() + " " + e.getMessage()); } }
@Override public boolean deleteFile(String name) throws GenericFileOperationFailedException { throw new GenericFileOperationFailedException("Operation 'delete' not supported by the scp: protocol"); }
@Override protected void doStart() throws Exception { // turn off scheduler first, so autoCreate is handled before scheduler starts boolean startScheduler = isStartScheduler(); setStartScheduler(false); try { super.doStart(); if (endpoint.isAutoCreate()) { log.debug("Auto creating directory: {}", endpoint.getConfiguration().getDirectory()); try { connectIfNecessary(); operations.buildDirectory(endpoint.getConfiguration().getDirectory(), true); } catch (GenericFileOperationFailedException e) { // log a WARN as we want to start the consumer. log.warn("Error auto creating directory: " + endpoint.getConfiguration().getDirectory() + " due " + e.getMessage() + ". This exception is ignored.", e); } } } finally { if (startScheduler) { setStartScheduler(true); startScheduler(); } } }
@Override public List<ScpFile> listFiles() throws GenericFileOperationFailedException { throw new GenericFileOperationFailedException("Operation 'ls' not supported by the scp: protocol"); }
@Override protected void doStart() throws Exception { // turn off scheduler first, so autoCreate is handled before scheduler starts boolean startScheduler = isStartScheduler(); setStartScheduler(false); try { super.doStart(); if (endpoint.isAutoCreate()) { log.debug("Auto creating directory: {}", endpoint.getConfiguration().getDirectory()); try { connectIfNecessary(); operations.buildDirectory(endpoint.getConfiguration().getDirectory(), true); } catch (GenericFileOperationFailedException e) { // log a WARN as we want to start the consumer. log.warn("Error auto creating directory: " + endpoint.getConfiguration().getDirectory() + " due " + e.getMessage() + ". This exception is ignored.", e); } } } finally { if (startScheduler) { setStartScheduler(true); startScheduler(); } } }
public synchronized void releaseRetrievedFileResources(Exchange exchange) throws GenericFileOperationFailedException { InputStream is = exchange.getIn().getHeader(RemoteFileComponent.REMOTE_FILE_INPUT_STREAM, InputStream.class); if (is != null) { try { is.close(); } catch (IOException e) { throw new GenericFileOperationFailedException(e.getMessage(), e); } } }
public boolean retrieveFile(String name, Exchange exchange, long size) throws GenericFileOperationFailedException { // store the name of the file to download on the listener clientActivityListener.setDownload(true); clientActivityListener.setRemoteFileName(name); clientActivityListener.setRemoteFileSize(size); clientActivityListener.onBeginDownloading(endpoint.getConfiguration().remoteServerInformation(), name); boolean answer; try { log.trace("retrieveFile({})", name); if (ObjectHelper.isNotEmpty(endpoint.getLocalWorkDirectory())) { // local work directory is configured so we should store file content as files in this local directory answer = retrieveFileToFileInLocalWorkDirectory(name, exchange, endpoint.isResumeDownload()); } else { // store file content directory as stream on the body answer = retrieveFileToStreamInBody(name, exchange); } } catch (GenericFileOperationFailedException e) { clientActivityListener.onGeneralError(endpoint.getConfiguration().remoteServerInformation(), e.getMessage()); throw e; } if (answer) { clientActivityListener.onDownloadComplete(endpoint.getConfiguration().remoteServerInformation(), name); } return answer; }
public synchronized String getCurrentDirectory() throws GenericFileOperationFailedException { LOG.trace("getCurrentDirectory()"); try { String answer = channel.pwd(); LOG.trace("Current dir: {}", answer); return answer; } catch (SftpException e) { throw new GenericFileOperationFailedException("Cannot get current directory", e); } }
clientActivityListener.onGeneralError(endpoint.getConfiguration().remoteServerInformation(), e.getMessage()); throw e; } finally {