Package unlimited.fc.client.engine
Class HttpClient
- java.lang.Object
-
- unlimited.fc.client.engine.HttpClient
-
public class HttpClient extends java.lang.ObjectTitle: Unlimited FTP Description: Web based FTP client applet Copyright: Copyright (c) 2001 Company: Unlimi-Tech Software Inc.
-
-
Field Summary
Fields Modifier and Type Field Description java.lang.Stringcommandjava.lang.StringservletLocation
-
Constructor Summary
Constructors Constructor Description HttpClient(java.lang.String host, int port, java.lang.String servletLocation, unlimited.core.util.common.logs.LogUtils log)HttpClient(java.lang.String Host, java.lang.String Cgihost, unlimited.core.util.common.logs.LogUtils log)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidabort()Send Abort commandvoidallo(long size)java.io.BufferedWriterappendAscii(java.lang.String filename)APPEND (with create) to a file to the FTP server in Ascii modejava.io.BufferedOutputStreamappendBinary(java.lang.String filename)APPEND (with create) to a file to the FTP server in Binary modebooleanascii()Set transfer type to 'A'booleanbinary()Set transfer type to 'I'voidcd(java.lang.String remoteDirectory)CD to a specific directory on a remote FTP servervoidcdup()voidcloseServer()issue the QUIT command to the FTP server and close the connection.java.io.BufferedOutputStreamconcatenate(java.lang.String filename, int numOfParts)CONCAT a bunch of files on the FTP serverprotected voidconfigureSSLIfNeeded(java.lang.String Cgihost)booleanconnected()java.net.URLconstructURL(java.lang.String cmd, java.lang.String newDir, java.lang.String file, java.lang.String site)java.net.URLconstructURL(java.lang.String cmd, java.lang.String newDir, java.lang.String file, java.lang.String site, boolean reinitIfInvalid)voiddelete(java.lang.String s, boolean stripPath)voiddeleteTempFiles()voiddoesFTPServerSupportResume(boolean usingFC3_8)voidemail(java.lang.String emailAddress, int statusCode, java.lang.String note)voidforceCloseServer()booleanftpResumeSupported()voidfxp(java.lang.String fxpsid, java.lang.String filename, java.lang.String fxpFilename, boolean triangle)java.io.BufferedReadergetAscii(java.lang.String filename)GET a file from the FTP server in Ascii modejava.lang.StringgetBaseURL(java.lang.String concatenatedString)java.io.BufferedInputStreamgetBinary(java.lang.String filename)GET a file from the FTP server in Binary modejava.io.BufferedInputStreamgetBinary(java.lang.String filename, long offset)GET a file from the FTP server in Binary mode and starting at the given offsetjava.io.BufferedInputStreamgetBinary(java.lang.String filename, long offset, long segment)GET a file segment from the FTP server in Binary mode and starting at the given offsetprotected java.io.BufferedReadergetBufferedReader(java.net.URLConnection urlc)This method will try multiple times to open the data connection to the web server if it gets IO exceptions.java.lang.StringgetCertificateInfo()Go up one directory on remots systemjava.lang.StringgetCommand()intgetLastReplyCode()protected intgetMovePercentage(java.lang.String remoteFile)returns true/false if the move is completedjava.lang.StringgetRemoteHost()intgetRemotePort()java.lang.StringgetResponseString()Returns all server response strings.java.lang.StringgetResponseStringNoReset()protected voidgetServletVersion()java.lang.StringgetSid()intgetSoConnectTimeout()intgetSoLinger()intgetSoTimeout()java.net.URLgetURL()java.lang.StringgetWelcomeMessage()booleanisEnableResume()booleanisForceResume()booleanisMac()booleanisNetscapeFour()Deprecated.booleanisPrintSolution()booleanisUseGZip()java.io.BufferedInputStreamlist()java.io.BufferedInputStreamlist(java.lang.String args)voidlogin(java.lang.String username, java.lang.String password)login user to a host with username user and password passwordvoidlogin(java.util.function.Supplier<ClientCredentials> creds)login user to a host with username user and password passwordvoidmkdir(java.lang.String s)Create a directory on the remote systemvoidmoveFilesToServer(java.lang.String remoteFile)java.io.BufferedInputStreamnlist()NLIST files on a remote FTP serverjava.io.BufferedInputStreamnlist(java.lang.String args)NLIST files on a remote FTP servervoidnoop()voidopenServer(java.lang.String host)open a FTP connection to host host.voidopenServer(java.lang.String host, int port)open a FTP connection to host host on port port.java.io.BufferedWriterputAscii(java.lang.String filename)PUT a file to the FTP server in Ascii modejava.io.BufferedOutputStreamputBinary(java.lang.String filename)PUT a file to the FTP server in Binary modejava.io.BufferedOutputStreamputSegmentBinary(java.lang.String filename, long segmentOffset, long segmentSize)PUT a file to the FTP server in Binary modevoidpwd()Get the name of the present working directory on the ftp file systemvoidquote(java.lang.String s)intreadServerResponse()voidreinitSessionIfNeeded()voidrename(java.lang.String oldFile, java.lang.String newFile)Rename a file on the remote servervoidrmdir(java.lang.String s)voidsaveFilesToWebServer()voidsendServer(java.lang.String cmd)Sends command cmd to the server.voidsendWeblink(WeblinkDataContainer linkDO)Streams Our File Listing To The ServerbooleanserverIsOpen()voidsetClientCredentials(java.util.function.Supplier<ClientCredentials> creds)voidsetDebug(boolean debug)voidsetEnableResume(boolean enableResume)voidsetForceResume(boolean forceResume)voidsetMac(boolean mac)protected voidsetMD5HashedLocalIP()voidsetNetscapeFour(boolean netscapeFour)Deprecated.voidsetPassive(boolean mode)Set Passive mode TrasfersvoidsetPrintSolution(boolean printSolution)voidsetSid(java.lang.String sid)voidsetSoConnectTimeout(int i)voidsetSoLinger(int i)voidsetSoTimeout(int i)voidsetupURLConnection(java.net.URLConnection urlc)voidsetUseGZip(boolean useGZip)voidsetWelcomeMessage(java.lang.String welcomeMessage)voidsite(java.lang.String params)Site Commandprotected voidstartMOVE(java.lang.String remoteFile)java.lang.StringtoString()protected voidwriteLog(java.lang.String line)voidzip(java.lang.String zipFilename, java.lang.String filenames, int compLevel, long limit)
-
-
-
Constructor Detail
-
HttpClient
public HttpClient(java.lang.String Host, java.lang.String Cgihost, unlimited.core.util.common.logs.LogUtils log) throws java.io.IOException- Throws:
java.io.IOException
-
HttpClient
public HttpClient(java.lang.String host, int port, java.lang.String servletLocation, unlimited.core.util.common.logs.LogUtils log) throws java.io.IOException- Throws:
java.io.IOException
-
-
Method Detail
-
setMD5HashedLocalIP
protected void setMD5HashedLocalIP()
-
configureSSLIfNeeded
protected void configureSSLIfNeeded(java.lang.String Cgihost)
-
getServletVersion
protected void getServletVersion() throws java.io.IOException, java.net.MalformedURLException- Throws:
java.io.IOExceptionjava.net.MalformedURLException
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
setupURLConnection
public void setupURLConnection(java.net.URLConnection urlc) throws java.io.IOException- Throws:
java.io.IOException
-
getURL
public java.net.URL getURL()
-
setNetscapeFour
@Deprecated public void setNetscapeFour(boolean netscapeFour)
Deprecated.
-
isNetscapeFour
@Deprecated public boolean isNetscapeFour()
Deprecated.
-
setPassive
public void setPassive(boolean mode)
Set Passive mode Trasfers
-
serverIsOpen
public boolean serverIsOpen()
-
readServerResponse
public int readServerResponse() throws java.io.IOException- Throws:
java.io.IOException
-
sendServer
public void sendServer(java.lang.String cmd)
Sends command cmd to the server.
-
connected
public boolean connected()
-
getCommand
public java.lang.String getCommand()
-
getResponseString
public java.lang.String getResponseString()
Returns all server response strings.
-
getLastReplyCode
public int getLastReplyCode()
-
getResponseStringNoReset
public java.lang.String getResponseStringNoReset()
-
closeServer
public void closeServer() throws java.io.IOExceptionissue the QUIT command to the FTP server and close the connection.- Throws:
java.io.IOException
-
fxp
public void fxp(java.lang.String fxpsid, java.lang.String filename, java.lang.String fxpFilename, boolean triangle) throws java.io.IOException, unlimited.core.util.common.exception.FCException- Throws:
java.io.IOExceptionunlimited.core.util.common.exception.FCException
-
forceCloseServer
public void forceCloseServer() throws java.io.IOException- Throws:
java.io.IOException
-
openServer
public void openServer(java.lang.String host) throws java.io.IOException, java.net.UnknownHostExceptionopen a FTP connection to host host.- Throws:
java.io.IOExceptionjava.net.UnknownHostException
-
openServer
public void openServer(java.lang.String host, int port) throws java.io.IOException, java.net.UnknownHostExceptionopen a FTP connection to host host on port port.- Throws:
java.io.IOExceptionjava.net.UnknownHostException
-
login
public void login(java.lang.String username, java.lang.String password) throws java.io.IOException, unlimited.core.util.common.exception.FCExceptionlogin user to a host with username user and password password- Throws:
java.io.IOExceptionunlimited.core.util.common.exception.FCException
-
login
public void login(java.util.function.Supplier<ClientCredentials> creds) throws java.io.IOException, unlimited.core.util.common.exception.FCException
login user to a host with username user and password password- Throws:
java.io.IOExceptionunlimited.core.util.common.exception.FCException
-
doesFTPServerSupportResume
public void doesFTPServerSupportResume(boolean usingFC3_8) throws java.io.IOException- Throws:
java.io.IOException
-
getAscii
public java.io.BufferedReader getAscii(java.lang.String filename) throws java.io.IOExceptionGET a file from the FTP server in Ascii mode- Throws:
java.io.IOException
-
getBinary
public java.io.BufferedInputStream getBinary(java.lang.String filename) throws java.io.IOExceptionGET a file from the FTP server in Binary mode- Throws:
java.io.IOException
-
getBinary
public java.io.BufferedInputStream getBinary(java.lang.String filename, long offset) throws java.io.IOExceptionGET a file from the FTP server in Binary mode and starting at the given offset- Throws:
java.io.IOException
-
getBinary
public java.io.BufferedInputStream getBinary(java.lang.String filename, long offset, long segment) throws java.io.IOExceptionGET a file segment from the FTP server in Binary mode and starting at the given offset- Throws:
java.io.IOException
-
putAscii
public java.io.BufferedWriter putAscii(java.lang.String filename) throws java.io.IOExceptionPUT a file to the FTP server in Ascii mode- Throws:
java.io.IOException
-
moveFilesToServer
public void moveFilesToServer(java.lang.String remoteFile) throws java.io.IOException, unlimited.core.util.common.exception.FCException- Throws:
java.io.IOExceptionunlimited.core.util.common.exception.FCException
-
writeLog
protected void writeLog(java.lang.String line)
-
startMOVE
protected void startMOVE(java.lang.String remoteFile) throws java.net.MalformedURLException, java.io.IOException- Throws:
java.net.MalformedURLExceptionjava.io.IOException
-
getMovePercentage
protected int getMovePercentage(java.lang.String remoteFile) throws java.net.MalformedURLException, java.io.IOExceptionreturns true/false if the move is completed- Returns:
- Throws:
java.net.MalformedURLExceptionjava.io.IOException- if a 500 Error occurred, i.e. HTTP request failed
-
delete
public void delete(java.lang.String s, boolean stripPath) throws java.io.IOException, unlimited.core.util.common.exception.FCException- Throws:
java.io.IOExceptionunlimited.core.util.common.exception.FCException
-
deleteTempFiles
public void deleteTempFiles() throws java.io.IOException, unlimited.core.util.common.exception.FCException- Throws:
java.io.IOExceptionunlimited.core.util.common.exception.FCException
-
saveFilesToWebServer
public void saveFilesToWebServer() throws java.io.IOException, unlimited.core.util.common.exception.FCException- Throws:
java.io.IOExceptionunlimited.core.util.common.exception.FCException
-
ftpResumeSupported
public boolean ftpResumeSupported()
-
concatenate
public java.io.BufferedOutputStream concatenate(java.lang.String filename, int numOfParts) throws java.io.IOExceptionCONCAT a bunch of files on the FTP server- Throws:
java.io.IOException
-
putBinary
public java.io.BufferedOutputStream putBinary(java.lang.String filename) throws java.io.IOExceptionPUT a file to the FTP server in Binary mode- Throws:
java.io.IOException
-
putSegmentBinary
public java.io.BufferedOutputStream putSegmentBinary(java.lang.String filename, long segmentOffset, long segmentSize) throws java.io.IOExceptionPUT a file to the FTP server in Binary mode- Throws:
java.io.IOException
-
appendAscii
public java.io.BufferedWriter appendAscii(java.lang.String filename) throws java.io.IOExceptionAPPEND (with create) to a file to the FTP server in Ascii mode- Throws:
java.io.IOException
-
appendBinary
public java.io.BufferedOutputStream appendBinary(java.lang.String filename) throws java.io.IOExceptionAPPEND (with create) to a file to the FTP server in Binary mode- Throws:
java.io.IOException
-
nlist
public java.io.BufferedInputStream nlist() throws java.io.IOExceptionNLIST files on a remote FTP server- Throws:
java.io.IOException
-
nlist
public java.io.BufferedInputStream nlist(java.lang.String args) throws java.io.IOExceptionNLIST files on a remote FTP server- Throws:
java.io.IOException
-
list
public java.io.BufferedInputStream list() throws java.io.IOException- Throws:
java.io.IOException
-
list
public java.io.BufferedInputStream list(java.lang.String args) throws java.io.IOException- Throws:
java.io.IOException
-
cd
public void cd(java.lang.String remoteDirectory) throws java.io.IOException, unlimited.core.util.common.exception.FCExceptionCD to a specific directory on a remote FTP server- Throws:
java.io.IOExceptionunlimited.core.util.common.exception.FCException
-
rename
public void rename(java.lang.String oldFile, java.lang.String newFile) throws java.io.IOException, unlimited.core.util.common.exception.FCExceptionRename a file on the remote server- Throws:
java.io.IOExceptionunlimited.core.util.common.exception.FCException
-
site
public void site(java.lang.String params) throws java.io.IOException, unlimited.core.util.common.exception.FCExceptionSite Command- Throws:
java.io.IOExceptionunlimited.core.util.common.exception.FCException
-
allo
public void allo(long size) throws java.io.IOException, unlimited.core.util.common.exception.FCException- Throws:
java.io.IOExceptionunlimited.core.util.common.exception.FCException
-
binary
public boolean binary() throws java.io.IOExceptionSet transfer type to 'I'- Throws:
java.io.IOException
-
ascii
public boolean ascii() throws java.io.IOExceptionSet transfer type to 'A'- Throws:
java.io.IOException
-
abort
public void abort() throws java.io.IOExceptionSend Abort command- Throws:
java.io.IOException
-
getCertificateInfo
public java.lang.String getCertificateInfo() throws java.io.IOExceptionGo up one directory on remots system- Throws:
java.io.IOException
-
pwd
public void pwd() throws java.io.IOException, unlimited.core.util.common.exception.FCExceptionGet the name of the present working directory on the ftp file system- Throws:
java.io.IOExceptionunlimited.core.util.common.exception.FCException
-
noop
public void noop() throws java.io.IOException, unlimited.core.util.common.exception.FCException- Throws:
java.io.IOExceptionunlimited.core.util.common.exception.FCException
-
quote
public void quote(java.lang.String s) throws java.io.IOException, unlimited.core.util.common.exception.FCException- Throws:
java.io.IOExceptionunlimited.core.util.common.exception.FCException
-
cdup
public void cdup() throws java.io.IOException, unlimited.core.util.common.exception.FCException- Throws:
java.io.IOExceptionunlimited.core.util.common.exception.FCException
-
zip
public void zip(java.lang.String zipFilename, java.lang.String filenames, int compLevel, long limit) throws java.io.IOException, unlimited.core.util.common.exception.FCException- Throws:
java.io.IOExceptionunlimited.core.util.common.exception.FCException
-
email
public void email(java.lang.String emailAddress, int statusCode, java.lang.String note) throws java.io.IOException, unlimited.core.util.common.exception.FCException- Throws:
java.io.IOExceptionunlimited.core.util.common.exception.FCException
-
mkdir
public void mkdir(java.lang.String s) throws java.io.IOException, unlimited.core.util.common.exception.FCExceptionCreate a directory on the remote system- Throws:
java.io.IOExceptionunlimited.core.util.common.exception.FCException
-
rmdir
public void rmdir(java.lang.String s) throws java.io.IOException, unlimited.core.util.common.exception.FCException- Throws:
java.io.IOExceptionunlimited.core.util.common.exception.FCException
-
sendWeblink
public void sendWeblink(WeblinkDataContainer linkDO) throws java.io.IOException, unlimited.core.util.common.exception.FCException
Streams Our File Listing To The Server- Parameters:
files-- Throws:
java.io.IOExceptionunlimited.core.util.common.exception.FCException
-
getBufferedReader
protected java.io.BufferedReader getBufferedReader(java.net.URLConnection urlc) throws java.io.IOExceptionThis method will try multiple times to open the data connection to the web server if it gets IO exceptions.- Parameters:
urlc-- Returns:
- Throws:
java.io.IOException
-
constructURL
public java.net.URL constructURL(java.lang.String cmd, java.lang.String newDir, java.lang.String file, java.lang.String site) throws java.net.MalformedURLException, java.io.UnsupportedEncodingException, java.io.IOException- Throws:
java.net.MalformedURLExceptionjava.io.UnsupportedEncodingExceptionjava.io.IOException
-
constructURL
public java.net.URL constructURL(java.lang.String cmd, java.lang.String newDir, java.lang.String file, java.lang.String site, boolean reinitIfInvalid) throws java.net.MalformedURLException, java.io.UnsupportedEncodingException, java.io.IOException- Throws:
java.net.MalformedURLExceptionjava.io.UnsupportedEncodingExceptionjava.io.IOException
-
getBaseURL
public java.lang.String getBaseURL(java.lang.String concatenatedString) throws unlimited.core.util.common.exception.FCException, java.io.IOException- Throws:
unlimited.core.util.common.exception.FCExceptionjava.io.IOException
-
setSoConnectTimeout
public void setSoConnectTimeout(int i)
-
setSoTimeout
public void setSoTimeout(int i)
-
setSoLinger
public void setSoLinger(int i)
-
getSoConnectTimeout
public int getSoConnectTimeout()
-
getSoTimeout
public int getSoTimeout()
-
getSoLinger
public int getSoLinger()
-
isPrintSolution
public boolean isPrintSolution()
-
setPrintSolution
public void setPrintSolution(boolean printSolution)
-
isUseGZip
public boolean isUseGZip()
-
setUseGZip
public void setUseGZip(boolean useGZip)
-
setEnableResume
public void setEnableResume(boolean enableResume)
-
isEnableResume
public boolean isEnableResume()
-
setDebug
public void setDebug(boolean debug)
-
setMac
public void setMac(boolean mac)
-
isMac
public boolean isMac()
-
getSid
public java.lang.String getSid()
-
setSid
public void setSid(java.lang.String sid)
-
isForceResume
public boolean isForceResume()
-
setForceResume
public void setForceResume(boolean forceResume)
-
getWelcomeMessage
public java.lang.String getWelcomeMessage()
- Returns:
- the welcomeMessage
-
setWelcomeMessage
public void setWelcomeMessage(java.lang.String welcomeMessage)
- Parameters:
welcomeMessage- the welcomeMessage to set
-
setClientCredentials
public void setClientCredentials(java.util.function.Supplier<ClientCredentials> creds) throws unlimited.core.util.common.exception.FCException
- Throws:
unlimited.core.util.common.exception.FCException
-
getRemoteHost
public java.lang.String getRemoteHost()
-
getRemotePort
public int getRemotePort()
-
reinitSessionIfNeeded
public void reinitSessionIfNeeded() throws unlimited.core.util.common.exception.FCException, java.io.IOException- Throws:
unlimited.core.util.common.exception.FCExceptionjava.io.IOException
-
-