Class DefaultFileTransferManager
- java.lang.Object
-
- org.jivesoftware.openfire.container.BasicModule
-
- org.jivesoftware.openfire.filetransfer.DefaultFileTransferManager
-
- All Implemented Interfaces:
Module
,FileTransferManager
public class DefaultFileTransferManager extends BasicModule implements FileTransferManager
Provides several utility methods for file transfer manager implementations to utilize.- Author:
- Alexander Wenckus
-
-
Field Summary
-
Fields inherited from interface org.jivesoftware.openfire.filetransfer.FileTransferManager
NAMESPACE_BYTESTREAMS, NAMESPACE_SI, NAMESPACE_SI_FILETRANSFER
-
-
Constructor Summary
Constructors Constructor Description DefaultFileTransferManager()
Default constructor creates the cache.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
acceptIncomingFileTransferRequest(FileTransfer transfer)
Checks an incoming file transfer request to see if it should be accepted or rejected.void
addListener(FileTransferEventListener eventListener)
Registers an event listener that will be notified of file transfer related events.protected void
cacheFileTransfer(String key, FileTransfer transfer)
void
fireFileTransferCompleted(String sid, boolean wasSuccessful)
InvokesFileTransferEventListener.fileTransferComplete(FileTransfer, boolean)
for all registered event listeners.void
fireFileTransferStart(String sid, boolean isReady)
InvokesFileTransferEventListener.fileTransferStart(FileTransfer, boolean)
for all registered event listeners.protected static org.dom4j.Element
getChildElement(org.dom4j.Element element, String namespace)
boolean
isMatchProxyTransfer()
Returns true if the proxy transfer should be matched to an existing file transfer in the system.void
registerProxyTransfer(String transferDigest, ProxyTransfer proxyTransfer)
Registers that a transfer has begun through the proxy connected to the server.void
removeListener(FileTransferEventListener eventListener)
Unregisters an event listener from the list of event listeners that are notified of file transfer related events.protected FileTransfer
retrieveFileTransfer(String key)
-
Methods inherited from class org.jivesoftware.openfire.container.BasicModule
destroy, getName, initialize, start, stop
-
-
-
-
Method Detail
-
isMatchProxyTransfer
public boolean isMatchProxyTransfer()
Returns true if the proxy transfer should be matched to an existing file transfer in the system.- Returns:
- Returns true if the proxy transfer should be matched to an existing file transfer in the system.
-
cacheFileTransfer
protected void cacheFileTransfer(String key, FileTransfer transfer)
-
retrieveFileTransfer
protected FileTransfer retrieveFileTransfer(String key)
-
getChildElement
protected static org.dom4j.Element getChildElement(org.dom4j.Element element, String namespace)
-
acceptIncomingFileTransferRequest
public boolean acceptIncomingFileTransferRequest(FileTransfer transfer) throws FileTransferRejectedException
Description copied from interface:FileTransferManager
Checks an incoming file transfer request to see if it should be accepted or rejected. If it is accepted true will be returned and if it is rejected false will be returned.- Specified by:
acceptIncomingFileTransferRequest
in interfaceFileTransferManager
- Parameters:
transfer
- the transfer to test for acceptance- Returns:
- true if it should be accepted false if it should not.
- Throws:
FileTransferRejectedException
- if the request was rejected (can this ever happen?)
-
registerProxyTransfer
public void registerProxyTransfer(String transferDigest, ProxyTransfer proxyTransfer) throws UnauthorizedException
Description copied from interface:FileTransferManager
Registers that a transfer has begun through the proxy connected to the server.- Specified by:
registerProxyTransfer
in interfaceFileTransferManager
- Parameters:
transferDigest
- the digest of the initiator + target + sessionID that uniquely identifies a file transferproxyTransfer
- the related proxy transfer.- Throws:
UnauthorizedException
- when in the current server configuration this transfer should not be permitted.
-
addListener
public void addListener(FileTransferEventListener eventListener)
Description copied from interface:FileTransferManager
Registers an event listener that will be notified of file transfer related events.- Specified by:
addListener
in interfaceFileTransferManager
- Parameters:
eventListener
- an event listener (cannot be null).
-
removeListener
public void removeListener(FileTransferEventListener eventListener)
Description copied from interface:FileTransferManager
Unregisters an event listener from the list of event listeners that are notified of file transfer related events.- Specified by:
removeListener
in interfaceFileTransferManager
- Parameters:
eventListener
- an event listener (cannot be null).
-
fireFileTransferStart
public void fireFileTransferStart(String sid, boolean isReady) throws FileTransferRejectedException
Description copied from interface:FileTransferManager
InvokesFileTransferEventListener.fileTransferStart(FileTransfer, boolean)
for all registered event listeners.- Specified by:
fireFileTransferStart
in interfaceFileTransferManager
- Parameters:
sid
- The session id of the file transfer that is being intercepted (cannot be null).isReady
- true if the transfer is ready to commence or false if this is related to the initial file transfer request. An exception at this point will cause the transfer to not go through.- Throws:
FileTransferRejectedException
- When at least one of the listeners aborts the file transfer.
-
fireFileTransferCompleted
public void fireFileTransferCompleted(String sid, boolean wasSuccessful)
Description copied from interface:FileTransferManager
InvokesFileTransferEventListener.fileTransferComplete(FileTransfer, boolean)
for all registered event listeners.- Specified by:
fireFileTransferCompleted
in interfaceFileTransferManager
- Parameters:
sid
- The session id of the file transfer that is being intercepted (cannot be null).wasSuccessful
- false when an exception was thrown during file transfer, otherwise true.
-
-