List of usage examples for org.apache.commons.net.ftp FTPSClient completePendingCommand
public boolean completePendingCommand() throws IOException
From source file:org.mule.transport.ftps.FtpsConnector.java
/** * Well get the output stream (if any) for this type of transport. Typically this * will be called only when Streaming is being used on an outbound endpoint * * @param endpoint the endpoint that releates to this Dispatcher * @param event the current event being processed * @return the output stream to use for this request or null if the transport * does not support streaming/*from ww w.ja va2s . co m*/ */ @Override public OutputStream getOutputStream(OutboundEndpoint endpoint, MuleEvent event) throws MuleException { try { final EndpointURI uri = endpoint.getEndpointURI(); String filename = getFilename(endpoint, event.getMessage()); final FTPSClient client; try { client = this.createFTPSClient(endpoint); } catch (Exception e) { throw new ConnectException(e, this); } try { OutputStream out = client.storeFileStream(filename); if (out == null) { throw new IOException("FTP operation failed: " + client.getReplyString()); } return new CallbackOutputStream(out, new CallbackOutputStream.Callback() { public void onClose() throws Exception { try { if (!client.completePendingCommand()) { client.logout(); client.disconnect(); throw new IOException("FTP Stream failed to complete pending request"); } } finally { releaseFtp(uri, client); } } }); } catch (Exception e) { logger.debug("Error getting output stream: ", e); releaseFtp(uri, client); throw e; } } catch (ConnectException ce) { // Don't wrap a ConnectException, otherwise the retry policy will not go into effect. throw ce; } catch (Exception e) { throw new DispatchException(CoreMessages.streamingFailedNoStream(), event, endpoint, e); } }
From source file:org.mule.transport.ftps.FtpsMessageReceiver.java
protected void postProcess(FTPSClient client, FTPFile file, MuleMessage message) throws Exception { if (!client.deleteFile(file.getName())) { throw new IOException(MessageFormat.format("Failed to delete file {0}. Ftp error: {1}", file.getName(), client.getReplyCode())); }/* w w w . j av a2s .co m*/ if (logger.isDebugEnabled()) { logger.debug("Deleted processed file " + file.getName()); } if (connector.isStreaming()) { if (!client.completePendingCommand()) { throw new IOException(MessageFormat.format( "Failed to complete a pending command. Retrieveing file {0}. Ftp error: {1}", file.getName(), client.getReplyCode())); } } }