001    package railo.runtime.tag;
002    
003    import java.io.IOException;
004    import java.io.InputStream;
005    import java.io.OutputStream;
006    
007    import org.apache.commons.net.ftp.FTP;
008    import org.apache.commons.net.ftp.FTPClient;
009    import org.apache.commons.net.ftp.FTPFile;
010    import org.apache.commons.net.ftp.FTPReply;
011    
012    import railo.commons.io.IOUtil;
013    import railo.commons.io.res.Resource;
014    import railo.commons.io.res.util.ResourceUtil;
015    import railo.runtime.exp.ApplicationException;
016    import railo.runtime.exp.PageException;
017    import railo.runtime.ext.tag.TagImpl;
018    import railo.runtime.net.ftp.FTPConnection;
019    import railo.runtime.net.ftp.FTPConnectionImpl;
020    import railo.runtime.net.ftp.FTPConstant;
021    import railo.runtime.net.ftp.FTPPath;
022    import railo.runtime.net.ftp.FTPPool;
023    import railo.runtime.op.Caster;
024    import railo.runtime.type.Collection.Key;
025    import railo.runtime.type.KeyImpl;
026    import railo.runtime.type.QueryImpl;
027    import railo.runtime.type.Struct;
028    import railo.runtime.type.StructImpl;
029    import railo.runtime.type.dt.DateTimeImpl;
030    import railo.runtime.type.util.ListUtil;
031    
032    /**
033    * 
034    * Lets users implement File Transfer Protocol (FTP) operations.
035    *
036    *
037    *
038    **/
039    public final class Ftp extends TagImpl {
040        
041        private static final String ASCCI_EXT_LIST="txt;htm;html;cfm;cfml;shtm;shtml;css;asp;asa";
042    
043            private static final Key SUCCEEDED = KeyImpl.intern("succeeded");
044            private static final Key ERROR_CODE = KeyImpl.intern("errorCode");
045            private static final Key ERROR_TEXT = KeyImpl.intern("errorText");
046            private static final Key RETURN_VALUE = KeyImpl.intern("returnValue");
047            private static final Key CFFTP = KeyImpl.intern("cfftp");
048            /*private static final Key  = KeyImpl.getInstance();
049            private static final Key  = KeyImpl.getInstance();
050            private static final Key  = KeyImpl.getInstance();
051            private static final Key  = KeyImpl.getInstance();
052            private static final Key  = KeyImpl.getInstance();
053            private static final Key  = KeyImpl.getInstance();*/
054            
055        private FTPPool pool;
056    
057            private String action;
058            private String username;
059            private String password;
060            private String server;
061            private int timeout=30;
062            private int port=21;
063            private String connectionName;
064            private int retrycount=1;
065            private int count=0;
066            private boolean stoponerror=true;
067            private boolean passive;
068            private String name;
069            private String directory;
070            private String ASCIIExtensionList=ASCCI_EXT_LIST;
071            private short transferMode=FTPConstant.TRANSFER_MODE_AUTO;
072            private String remotefile;
073            private String localfile;
074            private boolean failifexists=true;
075            private String existing;
076            private String _new;
077        private String item;
078        private String result;
079    
080        private String proxyserver;
081            private int proxyport=80;
082            private String proxyuser;
083            private String proxypassword="";
084            
085            //private Struct cfftp=new StructImpl();
086    
087        @Override
088            public void release()   {
089                    super.release();
090                    this.pool=null;
091                    
092                    this.action=null;
093                    this.username=null;
094                    this.password=null;
095                    this.server=null;
096                    this.timeout=30;
097                    this.port=21;
098                    this.connectionName=null;
099                    this.proxyserver=null;
100                    this.proxyport=80;
101                    this.proxyuser=null;
102                    this.proxypassword="";
103                    this.retrycount=1;
104                    this.count=0;
105                    this.stoponerror=true;
106                    this.passive=false;
107                    this.name=null;
108                    this.directory=null;
109                    this.ASCIIExtensionList=ASCCI_EXT_LIST;
110                    this.transferMode=FTPConstant.TRANSFER_MODE_AUTO;
111                    this.remotefile=null;
112                    this.localfile=null;
113                    this.failifexists=true;
114                    this.existing=null;
115                    this._new=null;
116                    this.item=null;
117            this.result=null;
118            }
119    
120            /**
121             * sets the attribute action
122             * @param action
123             */
124            public void setAction(String action) {
125                    this.action=action.trim().toLowerCase();
126            }
127    
128            @Override
129            public int doStartTag() {
130                    return SKIP_BODY;
131            }
132    
133            @Override
134            public int doEndTag() throws PageException      {
135                pool=pageContext.getFTPPool();
136                FTPClient client = null; 
137                
138                
139                // retries
140                do {
141                        try {
142                                if(action.equals("open")) client=actionOpen();
143                                else if(action.equals("close")) client=actionClose();
144                                else if(action.equals("changedir")) client=actionChangeDir();
145                                else if(action.equals("createdir")) client=actionCreateDir();
146                                else if(action.equals("listdir")) client=actionListDir();
147                                else if(action.equals("removedir")) client=actionRemoveDir();
148                                else if(action.equals("getfile")) client=actionGetFile();
149                                else if(action.equals("putfile")) client=actionPutFile();
150                                else if(action.equals("rename")) client=actionRename();
151                                else if(action.equals("remove")) client=actionRemove();
152                                else if(action.equals("getcurrentdir")) client=actionGetCurrentDir();
153                                else if(action.equals("getcurrenturl")) client=actionGetCurrentURL();
154                                else if(action.equals("existsdir")) client=actionExistsDir();
155                                else if(action.equals("existsfile")) client=actionExistsFile();
156                                else if(action.equals("exists")) client=actionExists();
157                                //else if(action.equals("copy")) client=actionCopy();
158                                
159                                 
160                                else throw new ApplicationException(
161                                        "attribute action has an invalid value ["+action+"]",
162                                        "valid values are [open,close,listDir,createDir,removeDir,changeDir,getCurrentDir," +
163                                        "getCurrentURL,existsFile,existsDir,exists,getFile,putFile,rename,remove]");
164    
165                        }
166                        catch(IOException ioe) {
167                            if(count++<retrycount)continue;
168                            throw Caster.toPageException(ioe);
169                        }
170                    
171                        if(client==null || !checkCompletion(client))break;
172                }while(true);
173                
174                    return EVAL_PAGE;
175            }
176    
177        /**
178         * check if a file or directory exists
179         * @return FTPCLient
180         * @throws PageException
181         * @throws IOException
182         */
183        private FTPClient actionExists() throws PageException, IOException {
184            required("item",item); 
185    
186            FTPClient client = getClient();
187            FTPFile file=existsFile(client,item,false);
188            Struct cfftp = writeCfftp(client);
189    
190            cfftp.setEL(RETURN_VALUE,Caster.toBoolean(file!=null));
191            cfftp.setEL(SUCCEEDED,Boolean.TRUE);
192            
193            return client;
194        }
195    
196        /**
197         * check if a directory exists or not
198         * @return FTPCLient
199         * @throws PageException
200         * @throws IOException
201         */
202        private FTPClient actionExistsDir() throws PageException, IOException {
203            required("directory",directory); 
204    
205            FTPClient client = getClient();
206            boolean res = existsDir(client,directory);
207            Struct cfftp = writeCfftp(client);
208    
209            cfftp.setEL(RETURN_VALUE,Caster.toBoolean(res));
210            cfftp.setEL(SUCCEEDED,Boolean.TRUE);
211            
212            stoponerror=false;
213            return client;
214            
215            /*FTPClient client = pool.get(createConnection());
216            FTPFile file=existsFile(client,directory);
217            Struct cfftp = writeCfftp(client);
218    
219            cfftp.setEL(RETURN_VALUE,Caster.toBoolean(file!=null && file.isDirectory()));
220            cfftp.setEL(SUCCEEDED,Boolean.TRUE);
221            
222            stoponerror=false;
223            return client;*/
224        }
225    
226        /**
227         * check if a file exists or not
228         * @return FTPCLient
229         * @throws IOException
230         * @throws PageException
231         */
232        private FTPClient actionExistsFile() throws PageException, IOException {
233            required("remotefile",remotefile); 
234    
235            FTPClient client = getClient();
236            FTPFile file=existsFile(client,remotefile,true);
237            
238            Struct cfftp = writeCfftp(client);
239    
240            cfftp.setEL(RETURN_VALUE,Caster.toBoolean(file!=null && file.isFile()));
241            cfftp.setEL(SUCCEEDED,Boolean.TRUE);
242            
243            stoponerror=false;
244            return client;
245        
246        
247        
248        }
249    
250        
251        
252            
253        /* *
254         * check if file or directory exists if it exists return FTPFile otherwise null
255         * @param client
256         * @param strPath
257         * @return FTPFile or null
258         * @throws IOException
259         * @throws PageException
260         * /
261        private FTPFile exists(FTPClient client, String strPath) throws PageException, IOException {
262            strPath=strPath.trim();
263            
264            // get parent path
265            FTPPath path=new FTPPath(client.printWorkingDirectory(),strPath);
266            String name=path.getName();
267            print.out("path:"+name);
268            
269            // when directory
270            FTPFile[] files=null;
271            try {
272                files = client.listFiles(path.getPath());
273            } catch (IOException e) {}
274            
275            if(files!=null) {
276                for(int i=0;i<files.length;i++) {
277                    if(files[i].getName().equalsIgnoreCase(name)) {
278                        return files[i];
279                    }
280                }
281                
282            }
283            return null;
284        }*/
285        
286        private FTPFile existsFile(FTPClient client, String strPath,boolean isFile) throws PageException, IOException {
287            strPath=strPath.trim();
288            if(strPath.equals("/")) {
289                FTPFile file= new FTPFile();
290                file.setName("/");
291                file.setType(FTPFile.DIRECTORY_TYPE);
292                return file;
293            }
294            
295            // get parent path
296            FTPPath path=new FTPPath(client.printWorkingDirectory(),strPath);
297            String p=path.getPath();
298            String n=path.getName();
299    
300            strPath=p;
301            if("//".equals(p))strPath="/";
302            if(isFile)strPath+=n;
303            
304            // when directory
305            FTPFile[] files=null;
306            try {
307                            files = client.listFiles(strPath);
308                    } catch (IOException e) {}
309            
310            if(files!=null) {
311                for(int i=0;i<files.length;i++) {
312                    if(files[i].getName().equalsIgnoreCase(n)) {
313                        return files[i];
314                    }
315                }
316                
317            }
318            return null;
319        }
320        
321        private boolean existsDir(FTPClient client, String strPath) throws PageException, IOException {
322            strPath=strPath.trim();
323            
324            // get parent path
325            FTPPath path=new FTPPath(client.printWorkingDirectory(),strPath);
326            String p=path.getPath();
327            String n=path.getName();
328    
329            strPath=p+""+n;
330            if("//".equals(p))strPath="/"+n;
331            if(!strPath.endsWith("/"))strPath+="/";
332            
333            String pwd = client.printWorkingDirectory();
334            boolean rc = client.changeWorkingDirectory(directory);
335            client.changeWorkingDirectory(pwd);
336            return rc;
337        }
338    
339        /**
340         * removes a file on the server
341         * @return FTPCLient
342         * @throws IOException
343         * @throws PageException 
344         */
345        private FTPClient actionRemove() throws IOException, PageException {
346            required("item",item);
347            FTPClient client = getClient();
348            client.deleteFile(item);
349            writeCfftp(client);
350            
351            return client;
352        }
353    
354        /**
355         * rename a file on the server
356         * @return FTPCLient
357         * @throws PageException
358         * @throws IOException
359         */
360        private FTPClient actionRename() throws PageException, IOException {
361            required("existing",existing); 
362            required("new",_new);
363            
364            FTPClient client = getClient();
365                    client.rename(existing,_new);
366            writeCfftp(client);
367            
368            return client;
369        }
370    
371        /**
372         * copy a local file to server
373         * @return FTPClient
374         * @throws IOException
375         * @throws PageException
376         */
377        private FTPClient actionPutFile() throws IOException, PageException  {
378            required("remotefile",remotefile); 
379            required("localfile",localfile); 
380            
381                    FTPClient client = getClient();
382                    Resource local=ResourceUtil.toResourceExisting(pageContext ,localfile);//new File(localfile);
383                    //      if(failifexists && local.exists()) throw new ApplicationException("File ["+local+"] already exist, if you want to overwrite, set attribute failIfExists to false");
384                    InputStream is=null;
385                    
386            try {
387                    is=IOUtil.toBufferedInputStream(local.getInputStream());
388                    client.setFileType(getType(local));
389                client.storeFile(remotefile,is);
390            }
391            finally {
392                    IOUtil.closeEL(is);
393            }
394            writeCfftp(client);
395            
396            return client;
397        }
398    
399        /**
400         * gets a file from server and copy it local
401         * @return FTPCLient
402         * @throws PageException
403         * @throws IOException
404         */
405        private FTPClient actionGetFile() throws PageException, IOException {
406            required("remotefile",remotefile); 
407            required("localfile",localfile); 
408                    
409            
410                    FTPClient client = getClient();
411                    Resource local=ResourceUtil.toResourceExistingParent(pageContext ,localfile);//new File(localfile);
412            pageContext.getConfig().getSecurityManager().checkFileLocation(local);
413                    if(failifexists && local.exists()) throw new ApplicationException("File ["+local+"] already exist, if you want to overwrite, set attribute failIfExists to false");
414                    OutputStream fos=null;
415            client.setFileType(getType(local));
416            try {
417                    fos=IOUtil.toBufferedOutputStream(local.getOutputStream());
418                client.retrieveFile(remotefile,fos);
419            }
420            finally {
421                    IOUtil.closeEL(fos);
422            }
423            writeCfftp(client);
424            
425            return client;
426        }
427    
428        /**
429         * get url of the working directory
430         * @return FTPCLient
431         * @throws IOException
432         * @throws PageException
433         */
434        private FTPClient actionGetCurrentURL() throws PageException, IOException {
435            FTPClient client = getClient();
436            String pwd=client.printWorkingDirectory();
437            Struct cfftp = writeCfftp(client); 
438            cfftp.setEL("returnValue","ftp://"+client.getRemoteAddress().getHostName()+pwd);
439            return client;
440        }
441    
442        /**
443         * get path from the working directory
444         * @return FTPCLient
445         * @throws IOException
446         * @throws PageException
447         */
448        private FTPClient actionGetCurrentDir() throws PageException, IOException {
449            FTPClient client = getClient();
450            String pwd=client.printWorkingDirectory();
451            Struct cfftp = writeCfftp(client);
452            cfftp.setEL("returnValue",pwd);
453            return client;
454        }
455    
456        /**
457         * change working directory 
458         * @return FTPCLient
459         * @throws IOException
460         * @throws PageException 
461         */
462        private FTPClient actionChangeDir() throws IOException, PageException {
463            required("directory",directory); 
464    
465            FTPClient client = getClient();
466            client.changeWorkingDirectory(directory);
467            writeCfftp(client);
468            return client;
469        }
470    
471        private FTPClient getClient() throws PageException, IOException {
472            return pool.get(_createConnection());
473            }
474    
475            /**
476         * removes a remote directory on server
477         * @return FTPCLient
478         * @throws IOException
479         * @throws PageException 
480         */
481        private FTPClient actionRemoveDir() throws IOException, PageException {
482            required("directory",directory); 
483    
484            FTPClient client = getClient();
485            client.removeDirectory(directory);
486            writeCfftp(client);
487            return client;
488        }
489    
490        /**
491         * create a remote directory
492         * @return FTPCLient
493         * @throws IOException
494         * @throws PageException 
495         */
496        private FTPClient actionCreateDir() throws IOException, PageException {
497            required("directory",directory); 
498    
499            FTPClient client = getClient();
500            client.makeDirectory(directory);
501            writeCfftp(client);
502            return client;
503        }
504    
505        /**
506         * List data of a ftp connection
507         * @return FTPCLient
508         * @throws PageException
509         * @throws IOException
510         */
511        private FTPClient actionListDir() throws PageException, IOException {
512            required("name",name);
513            required("directory",directory);
514            
515            FTPClient client = getClient();
516            FTPFile[] files = client.listFiles(directory);
517            if(files==null)files=new FTPFile[0];
518            
519            String[] cols = new String[]{"attributes","isdirectory","lastmodified","length","mode","name",
520                    "path","url","type","raw"};
521            String[] types = new String[]{"VARCHAR","BOOLEAN","DATE","DOUBLE","VARCHAR","VARCHAR",
522                    "VARCHAR","VARCHAR","VARCHAR","VARCHAR"};
523            
524            railo.runtime.type.Query query=new QueryImpl(cols,types,0,"query");
525            
526            // translate directory path for display
527            if(directory.length()==0)directory="/";
528            else if(directory.startsWith("./"))directory=directory.substring(1);
529            else if(directory.charAt(0)!='/')directory='/'+directory;
530            if(directory.charAt(directory.length()-1)!='/')directory=directory+'/';
531                    
532            pageContext.setVariable(name,query);
533            int row=0;
534            for(int i=0;i<files.length;i++) {
535                FTPFile file = files[i];
536                if(file.getName().equals(".") || file.getName().equals("..")) continue;
537                query.addRow();
538                row++;
539                query.setAt("attributes",row,"");
540                query.setAt("isdirectory",row,Caster.toBoolean(file.isDirectory()));
541                query.setAt("lastmodified",row,new DateTimeImpl(file.getTimestamp()));
542                query.setAt("length",row,Caster.toDouble(file.getSize()));
543                query.setAt("mode",row,FTPConstant.getPermissionASInteger(file));
544                query.setAt("type",row,FTPConstant.getTypeAsString(file.getType()));
545                //query.setAt("permission",row,FTPConstant.getPermissionASInteger(file));
546                query.setAt("raw",row,file.getRawListing());
547                query.setAt("name",row,file.getName());
548                query.setAt("path",row,directory+file.getName());
549                query.setAt("url",row,"ftp://"+client.getRemoteAddress().getHostName()+""+directory+file.getName());
550            }
551            writeCfftp(client);
552            return client;
553        }
554    
555        /** 
556         * Opens a FTP Connection
557         * @return FTPCLinet
558         * @throws IOException
559         * @throws PageException 
560         */
561        private FTPClient actionOpen() throws IOException, PageException {
562            required("server",server);
563            required("username",username);
564            required("password",password);
565            
566            
567            FTPClient client = getClient();
568            writeCfftp(client);
569            return client;
570        }
571    
572        /**
573         * close a existing ftp connection
574         * @return FTPCLient
575         * @throws PageException 
576         */
577        private FTPClient actionClose() throws PageException {
578            FTPConnection conn = _createConnection();
579            FTPClient client = pool.remove(conn);
580            
581            Struct cfftp = writeCfftp(client);
582            cfftp.setEL("succeeded",Caster.toBoolean(client!=null));
583            return client;
584        }
585    
586            /**
587             * throw a error if the value is empty (null)
588         * @param attributeName
589         * @param atttributValue
590             * @throws ApplicationException
591         */
592        private void required(String attributeName, String atttributValue) throws ApplicationException {
593            if(atttributValue==null)
594                throw new ApplicationException(
595                        "invalid attribute constelation for the tag ftp", 
596                        "attribute ["+attributeName+"] is required, if action is ["+action+"]");
597        }
598    
599        /**
600         * writes cfftp variable
601         * @param client
602         * @return FTPCLient
603         * @throws PageException 
604         */
605        private Struct writeCfftp(FTPClient client) throws PageException  {
606            Struct cfftp=new StructImpl();
607            if(result==null)pageContext.variablesScope().setEL(CFFTP,cfftp);
608            else pageContext.setVariable(result,cfftp);
609            if(client==null) {
610                cfftp.setEL(SUCCEEDED,Boolean.FALSE);
611                cfftp.setEL(ERROR_CODE,new Double(-1));
612                cfftp.setEL(ERROR_TEXT,"");
613                cfftp.setEL(RETURN_VALUE,"");
614                return cfftp;
615            }
616            int repCode = client.getReplyCode();
617            String repStr=client.getReplyString();
618            cfftp.setEL(ERROR_CODE,new Double(repCode));
619            cfftp.setEL(ERROR_TEXT,repStr);
620            
621            cfftp.setEL(SUCCEEDED,Caster.toBoolean(FTPReply.isPositiveCompletion(repCode)));
622            cfftp.setEL(RETURN_VALUE,repStr);
623            return cfftp;
624        }
625    
626        /**
627         * check completion status of the client
628         * @param client
629         * @return FTPCLient
630         * @throws ApplicationException
631         */
632        private boolean checkCompletion(FTPClient client) throws ApplicationException {
633            boolean  isPositiveCompletion=FTPReply.isPositiveCompletion(client.getReplyCode());
634            if(isPositiveCompletion) return false;
635            if(count++<retrycount) return true;
636            if(stoponerror){
637                    throw new railo.runtime.exp.FTPException(action,client);
638            }
639            
640            return false;
641        }
642        
643        /**
644         * get FTP. ... _FILE_TYPE 
645         * @param file
646         * @return type
647         */
648        private int getType(Resource file) {
649            if(transferMode==FTPConstant.TRANSFER_MODE_BINARY) return FTP.BINARY_FILE_TYPE;
650            else if(transferMode==FTPConstant.TRANSFER_MODE_ASCCI) return FTP.ASCII_FILE_TYPE;
651            else {
652                String ext=ResourceUtil.getExtension(file,null);
653                if(ext==null || ListUtil.listContainsNoCase(ASCIIExtensionList,ext,";")==-1)
654                    return FTP.BINARY_FILE_TYPE;
655                    return FTP.ASCII_FILE_TYPE;
656            }
657        }
658        
659        /**
660         * @return return a new FTP Connection Object
661         */
662        private FTPConnection _createConnection() {
663            
664            return new FTPConnectionImpl(connectionName,server,username,password,port,timeout,transferMode,passive,proxyserver,proxyport,proxyuser,proxypassword);
665        }
666        
667        /**
668         * @param password The password to set.
669         */
670        public void setPassword(String password) {
671            this.password = password;
672        }
673        /**
674         * @param username The username to set.
675         */
676        public void setUsername(String username) {
677            this.username = username;
678        }
679        /**
680         * @param server The server to set.
681         */
682        public void setServer(String server) {
683            this.server = server;
684        }
685        /**
686         * @param timeout The timeout to set.
687         */
688        public void setTimeout(double timeout) {
689            this.timeout = (int)timeout;
690        }
691        /**
692         * @param port The port to set.
693         */
694        public void setPort(double port) {
695            this.port = (int)port;
696        }
697        /**
698         * @param connection The connection to set.
699         */
700        public void setConnection(String connection) {
701            this.connectionName = connection;
702        }
703        /**
704         * @param proxyserver The proxyserver to set.
705         */
706        public void setProxyserver(String proxyserver) {
707            this.proxyserver = proxyserver;
708        }
709            
710            /** set the value proxyport
711            *  The port number on the proxy server from which the object is requested. Default is 80. When 
712            *       used with resolveURL, the URLs of retrieved documents that specify a port number are automatically 
713            *       resolved to preserve links in the retrieved document.
714            * @param proxyport value to set
715            **/
716            public void setProxyport(double proxyport)      {
717                    this.proxyport=(int)proxyport;
718            }
719    
720            /** set the value username
721            *  When required by a proxy server, a valid username.
722            * @param proxyuser value to set
723            **/
724            public void setProxyuser(String proxyuser)      {
725                    this.proxyuser=proxyuser;
726            }
727    
728        
729            /** set the value password
730            *  When required by a proxy server, a valid password.
731            * @param proxypassword value to set
732            **/
733            public void setProxypassword(String proxypassword)      {
734                    this.proxypassword=proxypassword;
735            }
736    
737        
738        
739        /**
740         * @param retrycount The retrycount to set.
741         */
742        public void setRetrycount(double retrycount) {
743            this.retrycount = (int)retrycount;
744        }
745        /**
746         * @param stoponerror The stoponerror to set.
747         */
748        public void setStoponerror(boolean stoponerror) {
749            this.stoponerror = stoponerror;
750        }
751        /**
752         * @param passive The passive to set.
753         */
754        public void setPassive(boolean passive) {
755            this.passive = passive;
756        }
757        /**
758         * @param directory The directory to set.
759         */
760        public void setDirectory(String directory) {
761            this.directory = directory;
762        }
763        /**
764         * @param name The name to set.
765         */
766        public void setName(String name) {
767            this.name = name;
768        }
769        /**
770         * @param extensionList The aSCIIExtensionList to set.
771         */
772        public void setAsciiextensionlist(String extensionList) {
773            ASCIIExtensionList = extensionList.toLowerCase().trim();
774        }
775        /**
776         * @param transferMode The transferMode to set.
777         */
778        public void setTransfermode(String transferMode) {
779            transferMode=transferMode.toLowerCase().trim();
780            if(transferMode.equals("binary"))this.transferMode=FTPConstant.TRANSFER_MODE_BINARY;
781            else if(transferMode.equals("ascci"))this.transferMode=FTPConstant.TRANSFER_MODE_ASCCI;
782            else this.transferMode=FTPConstant.TRANSFER_MODE_AUTO;
783        }
784        
785        /**
786         * @param localfile The localfile to set.
787         */
788        public void setLocalfile(String localfile) {
789            this.localfile = localfile;
790        }
791        /**
792         * @param remotefile The remotefile to set.
793         */
794        public void setRemotefile(String remotefile) {
795            this.remotefile = remotefile;
796        }
797        /**
798         * @param failifexists The failifexists to set.
799         */
800        public void setFailifexists(boolean failifexists) {
801            this.failifexists = failifexists;
802        }
803        /**
804         * @param _new The _new to set.
805         */
806        public void setNew(String _new) {
807            this._new = _new;
808        }
809        /**
810         * @param existing The existing to set.
811         */
812        public void setExisting(String existing) {
813            this.existing = existing;
814        }
815        /**
816         * @param item The item to set.
817         */
818        public void setItem(String item) {
819            this.item = item;
820        }
821    
822        /**
823         * @param result The result to set.
824         */
825        public void setResult(String result) {
826            this.result = result;
827        }
828    }