use of org.eclipse.ecf.filetransfer.SendFileTransferException in project ecf by eclipse.
the class AbstractUrlConnectionOutgoingFileTransfer method openStreams.
/*
* (non-Javadoc)
*
* @see org.eclipse.ecf.provider.filetransfer.retrieve.AbstractRetrieveFileTransfer#openStreams()
*/
protected void openStreams() throws SendFileTransferException {
try {
File localFile = getFileTransferInfo().getFile();
// Set input stream from local file
setInputStream(new BufferedInputStream(new FileInputStream(localFile)));
// Then connect
connect();
// Make PUT request
setOutputStream(urlConnection.getOutputStream());
} catch (final Exception e) {
throw new SendFileTransferException(NLS.bind(Messages.UrlConnectionOutgoingFileTransfer_EXCEPTION_COULD_NOT_CONNECT, getRemoteFileURL().toString()), e);
}
}
use of org.eclipse.ecf.filetransfer.SendFileTransferException in project ecf by eclipse.
the class LocalFileOutgoingFileTransfer method openStreams.
/* (non-Javadoc)
* @see org.eclipse.ecf.provider.filetransfer.outgoing.AbstractOutgoingFileTransfer#openStreams()
*/
protected void openStreams() throws SendFileTransferException {
IFileTransferInfo localFileTransferInfo = getFileTransferInfo();
Assert.isNotNull(localFileTransferInfo);
// Setup input file
File inputFile = localFileTransferInfo.getFile();
try {
setInputStream(new BufferedInputStream(new FileInputStream(inputFile)));
} catch (Exception e) {
hardClose();
throw new SendFileTransferException(NLS.bind(Messages.LocalFileOutgoingFileTransfer_EXCEPTION_OPENING_FOR_INPUT, inputFile));
}
URL url = getRemoteFileURL();
Assert.isNotNull(url);
try {
File outputFile = new File(url.getPath());
setOutputStream(new BufferedOutputStream(new FileOutputStream(outputFile)));
} catch (Exception e) {
hardClose();
throw new SendFileTransferException(NLS.bind(Messages.LocalFileOutgoingFileTransfer_EXCEPTION_OPENING_FOR_OUTPUT, url));
}
}
use of org.eclipse.ecf.filetransfer.SendFileTransferException in project ecf by eclipse.
the class XMPPOutgoingFileTransferHelper method sendOutgoingRequest.
public void sendOutgoingRequest(IFileID targetReceiver, IFileTransferInfo localFileToSend, IFileTransferListener progressListener, Map options) throws SendFileTransferException {
if (manager == null)
throw new SendFileTransferException("not connected");
if (!(targetReceiver instanceof XMPPFileID))
throw new SendFileTransferException("target receiver not XMPPFileID type.");
final XMPPFileID fileID = (XMPPFileID) targetReceiver;
int requestTimeout = -1;
if (options != null) {
final Object option = options.get(OUTGOING_REQUEST_TIMEOUT);
if (option != null) {
if (option instanceof String) {
try {
requestTimeout = Integer.valueOf((String) option).intValue();
} catch (final NumberFormatException e) {
// Ignore
}
} else if (option instanceof Integer) {
requestTimeout = ((Integer) option).intValue();
}
}
}
final XMPPOutgoingFileTransfer fileTransfer = new XMPPOutgoingFileTransfer(manager, fileID.getXMPPID(), localFileToSend, progressListener, requestTimeout);
try {
fileTransfer.startSend(localFileToSend.getFile(), localFileToSend.getDescription());
} catch (final XMPPException e) {
throw new SendFileTransferException("Exception sending outgoing file transfer request", e);
}
}
Aggregations