Source Code Cross Referenced for FTPWorkerThread.java in  » Groupware » hipergate » com » knowgate » dfs » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Groupware » hipergate » com.knowgate.dfs 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.knowgate.dfs;
002:
003:        /**
004:         * <p>Direct piped copy from an FTP source to another FTP target.</p>
005:         * <p>This is an alpha state testing module.</p>
006:         * @author Sergio Montoro Ten
007:         * @version 0.3alpha
008:         */
009:
010:        import java.io.IOException;
011:        import java.io.FileWriter;
012:        import java.io.PrintWriter;
013:        import java.io.PipedInputStream;
014:        import java.io.PipedOutputStream;
015:
016:        import com.enterprisedt.net.ftp.FTPClient;
017:        import com.enterprisedt.net.ftp.FTPException;
018:        import com.enterprisedt.net.ftp.FTPTransferType;
019:        import com.enterprisedt.net.ftp.FTPConnectMode;
020:
021:        import com.knowgate.debug.DebugFile;
022:
023:        public class FTPWorkerThread extends Thread {
024:            private FTPClient oFTPC;
025:            private boolean bLoged;
026:            private PipedOutputStream oOutPipe;
027:            private PipedInputStream oInPipe;
028:            private FileWriter oFW;
029:            private PrintWriter oPW;
030:            private int iCmd;
031:            private String sPar1;
032:            private FileSystem oFileSys;
033:
034:            private int GET_PIPE = 16;
035:            private int PUT_PIPE = 32;
036:            private int MOV_PIPE = 64;
037:
038:            public FTPWorkerThread(String sHost, String sUser, String sPassword)
039:                    throws FTPException, IOException {
040:                bLoged = false;
041:                oFileSys = null;
042:
043:                if (DebugFile.trace)
044:                    DebugFile.writeln("new FTPClient(" + sHost + ")");
045:
046:                oFTPC = new FTPClient(sHost);
047:                oFTPC.debugResponses(DebugFile.trace);
048:
049:                if (DebugFile.trace) {
050:                    oFW = new FileWriter("/tmp/javatrc.txt", true);
051:                    oPW = new PrintWriter(oFW, true);
052:                    oFTPC.setLogStream(oPW);
053:                    DebugFile.writeln("FTPClient.login(" + sUser + ","
054:                            + sPassword + ")");
055:                }
056:
057:                oFTPC.login(sUser, sPassword);
058:                bLoged = true;
059:
060:                oFTPC.setConnectMode(FTPConnectMode.ACTIVE);
061:                oFTPC.setType(FTPTransferType.BINARY);
062:            } // FTPWorkerThread()
063:
064:            //-----------------------------------------------------------
065:
066:            public PipedInputStream getInputPipe() throws IOException {
067:                return oInPipe;
068:            } // getInputPipe()
069:
070:            //-----------------------------------------------------------
071:
072:            public PipedOutputStream getOutputPipe() throws IOException {
073:                return oOutPipe;
074:            } // getOutputPipe()
075:
076:            //-----------------------------------------------------------
077:
078:            public void get(String sFile) throws IOException {
079:                oOutPipe = new PipedOutputStream();
080:                sPar1 = sFile;
081:                iCmd = GET_PIPE;
082:            }
083:
084:            //-----------------------------------------------------------
085:
086:            public void put(String sFile) throws IOException {
087:                oInPipe = new PipedInputStream();
088:                sPar1 = sFile;
089:                iCmd = PUT_PIPE;
090:            } // put()
091:
092:            //-----------------------------------------------------------
093:
094:            public void move(String sFile) throws IOException {
095:                oOutPipe = new PipedOutputStream();
096:                sPar1 = sFile;
097:                iCmd = MOV_PIPE;
098:            }
099:
100:            //-----------------------------------------------------------
101:
102:            public void connect(PipedInputStream oStrm) throws IOException {
103:                if (DebugFile.trace)
104:                    DebugFile
105:                            .writeln("FTPWorkerThread.connect([PipedInputStream])");
106:                oOutPipe.connect(oStrm);
107:            } // connect()
108:
109:            //-----------------------------------------------------------
110:
111:            public void connect(PipedOutputStream oStrm) throws IOException {
112:                if (DebugFile.trace)
113:                    DebugFile
114:                            .writeln("FTPWorkerThread.connect([PipedOutputStream])");
115:                oInPipe.connect(oStrm);
116:            } // connect()
117:
118:            //-----------------------------------------------------------
119:
120:            public void chdir(String sPath) throws FTPException, IOException {
121:                oFTPC.chdir(sPath);
122:            } // chdir()
123:
124:            //-----------------------------------------------------------
125:
126:            public void run() {
127:                try {
128:                    if (GET_PIPE == iCmd) {
129:                        if (DebugFile.trace)
130:                            DebugFile.writeln("oFTPC.get([PipedOutputStream],"
131:                                    + sPar1 + ")");
132:                        oFTPC.get(oOutPipe, sPar1);
133:                        oFTPC.quit();
134:                        bLoged = false;
135:                    } else if (PUT_PIPE == iCmd) {
136:                        if (DebugFile.trace)
137:                            DebugFile.writeln("oFTPC.put([PipedInputStream],"
138:                                    + sPar1 + ")");
139:                        oFTPC.put(oInPipe, sPar1);
140:                        oFTPC.quit();
141:                        bLoged = false;
142:                    } else if (MOV_PIPE == iCmd) {
143:                        if (DebugFile.trace)
144:                            DebugFile.writeln("oFTPC.get([PipedOutputStream],"
145:                                    + sPar1 + ")");
146:                        oFTPC.get(oOutPipe, sPar1);
147:                        if (DebugFile.trace)
148:                            DebugFile
149:                                    .writeln("oFTPC.delete([PipedOutputStream],"
150:                                            + sPar1 + ")");
151:                        oFTPC.delete(sPar1);
152:                        oFTPC.quit();
153:                        bLoged = false;
154:                    }
155:                } catch (FTPException ftpe) {
156:                    if (DebugFile.trace)
157:                        DebugFile.writeln("FTPException:" + ftpe.getMessage());
158:                } catch (IOException ioe) {
159:                    if (DebugFile.trace)
160:                        DebugFile.writeln("IOException:" + ioe.getMessage());
161:                }
162:            } // run()
163:        } // FTPWorkerThread
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.