Source Code Cross Referenced for FileTransfer.java in  » Web-Framework » TURBINE » org » apache » turbine » services » xmlrpc » util » 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 » Web Framework » TURBINE » org.apache.turbine.services.xmlrpc.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.apache.turbine.services.xmlrpc.util;
002:
003:        /*
004:         * Licensed to the Apache Software Foundation (ASF) under one
005:         * or more contributor license agreements.  See the NOTICE file
006:         * distributed with this work for additional information
007:         * regarding copyright ownership.  The ASF licenses this file
008:         * to you under the Apache License, Version 2.0 (the
009:         * "License"); you may not use this file except in compliance
010:         * with the License.  You may obtain a copy of the License at
011:         *
012:         *   http://www.apache.org/licenses/LICENSE-2.0
013:         *
014:         * Unless required by applicable law or agreed to in writing,
015:         * software distributed under the License is distributed on an
016:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017:         * KIND, either express or implied.  See the License for the
018:         * specific language governing permissions and limitations
019:         * under the License.
020:         */
021:
022:        import java.net.URL;
023:        import java.util.Vector;
024:
025:        import org.apache.commons.logging.Log;
026:        import org.apache.commons.logging.LogFactory;
027:        import org.apache.turbine.services.xmlrpc.TurbineXmlRpc;
028:        import org.apache.turbine.util.TurbineException;
029:
030:        /**
031:         * Test class for FileHandler.
032:         *
033:         * @deprecated This is not scope of the Service itself but of an
034:         *             application which uses the service. This class shouldn't
035:         *             be part of Turbine but of an addon application.
036:         * @author <a href="mailto:jvanzyl@periapt.com">Jason van Zyl</a>
037:         * @version $Id: FileTransfer.java 534527 2007-05-02 16:10:59Z tv $
038:         */
039:        public class FileTransfer {
040:            /** Logging */
041:            private static Log log = LogFactory.getLog(FileTransfer.class);
042:
043:            /**
044:             * Method to allow a client to send a file to a server.
045:             *
046:             * @param serverURL
047:             * @param sourceLocationProperty
048:             * @param sourceFileName
049:             * @param destinationLocationProperty
050:             * @param destinationFileName
051:             */
052:            public static void send(String serverURL,
053:                    String sourceLocationProperty, String sourceFileName,
054:                    String destinationLocationProperty,
055:                    String destinationFileName) throws TurbineException {
056:                try {
057:                    Vector params = new Vector();
058:
059:                    /*
060:                     * fileContents
061:                     */
062:                    params.add(FileHandler.readFileContents(
063:                            sourceLocationProperty, sourceFileName));
064:
065:                    /*
066:                     * property in TR.props which refers to the directory
067:                     * where the fileContents should land.
068:                     */
069:                    params.add(destinationLocationProperty);
070:
071:                    /*
072:                     * name to give the file contents.
073:                     */
074:                    params.add(destinationFileName);
075:
076:                    Boolean b = (Boolean) TurbineXmlRpc.executeRpc(new URL(
077:                            serverURL), "file.send", params);
078:
079:                } catch (Exception e) {
080:                    log.error("Error sending file to server:", e);
081:                    throw new TurbineException(e);
082:                }
083:            }
084:
085:            /**
086:             * Method to allow a client to send a file to a server
087:             * that requires a user name and password.
088:             *
089:             * @param serverURL
090:             * @param username
091:             * @param password
092:             * @param sourceLocationProperty
093:             * @param sourceFileName
094:             * @param destinationLocationProperty
095:             * @param destinationFileName
096:             * @throws TurbineException
097:             */
098:            public static void send(String serverURL, String username,
099:                    String password, String sourceLocationProperty,
100:                    String sourceFileName, String destinationLocationProperty,
101:                    String destinationFileName) throws TurbineException {
102:                try {
103:                    Vector params = new Vector();
104:
105:                    /*
106:                     * fileContents
107:                     */
108:                    params.add(FileHandler.readFileContents(
109:                            sourceLocationProperty, sourceFileName));
110:
111:                    /*
112:                     * property in TR.props which refers to the directory
113:                     * where the fileContents should land.
114:                     */
115:                    params.add(destinationLocationProperty);
116:
117:                    /*
118:                     * name to give the file contents.
119:                     */
120:                    params.add(destinationFileName);
121:
122:                    Boolean b = (Boolean) TurbineXmlRpc
123:                            .executeAuthenticatedRpc(new URL(serverURL),
124:                                    username, password, "file.send", params);
125:
126:                } catch (Exception e) {
127:                    log.error("Error sending file to server:", e);
128:                    throw new TurbineException(e);
129:                }
130:            }
131:
132:            /**
133:             * Method to allow a client to get a file to a server.
134:             *
135:             * @param serverURL
136:             * @param sourceLocationProperty
137:             * @param sourceFileName
138:             * @param destinationLocationProperty
139:             * @param destinationFileName
140:             * @throws TurbineException
141:             */
142:            public static void get(String serverURL,
143:                    String sourceLocationProperty, String sourceFileName,
144:                    String destinationLocationProperty,
145:                    String destinationFileName) throws TurbineException {
146:
147:                try {
148:                    Vector params = new Vector();
149:
150:                    /*
151:                     * property in TR.props which refers to the directory
152:                     * where the fileContents should land.
153:                     */
154:                    params.add(sourceLocationProperty);
155:
156:                    /*
157:                     * name to give the file contents.
158:                     */
159:                    params.add(sourceFileName);
160:
161:                    String fileContents = (String) TurbineXmlRpc.executeRpc(
162:                            new URL(serverURL), "file.get", params);
163:
164:                    /*
165:                     * Now we have the file contents, we can write
166:                     * them out to disk.
167:                     */
168:                    FileHandler.writeFileContents(fileContents,
169:                            destinationLocationProperty, destinationFileName);
170:                } catch (Exception e) {
171:                    log.error("Error getting file from server:", e);
172:                    throw new TurbineException(e);
173:                }
174:            }
175:
176:            /**
177:             * Method to allow a client to get a file from a server
178:             * that requires a user name and password.
179:             *
180:             * @param serverURL
181:             * @param username
182:             * @param password
183:             * @param sourceLocationProperty
184:             * @param sourceFileName
185:             * @param destinationLocationProperty
186:             * @param destinationFileName
187:             */
188:            public static void get(String serverURL, String username,
189:                    String password, String sourceLocationProperty,
190:                    String sourceFileName, String destinationLocationProperty,
191:                    String destinationFileName) throws TurbineException {
192:
193:                try {
194:                    Vector params = new Vector();
195:
196:                    /*
197:                     * property in TR.props which refers to the directory
198:                     * where the fileContents should land.
199:                     */
200:                    params.add(sourceLocationProperty);
201:
202:                    /*
203:                     * name to give the file contents.
204:                     */
205:                    params.add(sourceFileName);
206:
207:                    String fileContents = (String) TurbineXmlRpc
208:                            .executeAuthenticatedRpc(new URL(serverURL),
209:                                    username, password, "file.get", params);
210:
211:                    /*
212:                     * Now we have the file contents, we can write
213:                     * them out to disk.
214:                     */
215:                    FileHandler.writeFileContents(fileContents,
216:                            destinationLocationProperty, destinationFileName);
217:                } catch (Exception e) {
218:                    log.error("Error getting file from server:", e);
219:                    throw new TurbineException(e);
220:                }
221:            }
222:
223:            /**
224:             * Method to allow a client to remove a file from
225:             * the server
226:             *
227:             * @param serverURL
228:             * @param sourceLocationProperty
229:             * @param sourceFileName
230:             */
231:            public static void remove(String serverURL,
232:                    String sourceLocationProperty, String sourceFileName)
233:                    throws TurbineException {
234:                try {
235:                    Vector params = new Vector();
236:
237:                    /*
238:                     * property in TR.props which refers to the directory
239:                     * where the fileContents should land.
240:                     */
241:                    params.add(sourceLocationProperty);
242:
243:                    /*
244:                     * name to give the file contents.
245:                     */
246:                    params.add(sourceFileName);
247:
248:                    TurbineXmlRpc.executeRpc(new URL(serverURL), "file.remove",
249:                            params);
250:                } catch (Exception e) {
251:                    log.error("Error removing file from server:", e);
252:                    throw new TurbineException(e);
253:                }
254:            }
255:
256:            /**
257:             * Method to allow a client to remove a file from
258:             * a server that requires a user name and password.
259:             *
260:             * @param serverURL
261:             * @param username
262:             * @param password
263:             * @param sourceLocationProperty
264:             * @param sourceFileName
265:             */
266:            public static void remove(String serverURL, String username,
267:                    String password, String sourceLocationProperty,
268:                    String sourceFileName) throws TurbineException {
269:                try {
270:                    Vector params = new Vector();
271:
272:                    /*
273:                     * property in TR.props which refers to the directory
274:                     * where the fileContents should land.
275:                     */
276:                    params.add(sourceLocationProperty);
277:
278:                    /*
279:                     * name to give the file contents.
280:                     */
281:                    params.add(sourceFileName);
282:
283:                    TurbineXmlRpc.executeAuthenticatedRpc(new URL(serverURL),
284:                            username, password, "file.remove", params);
285:                } catch (Exception e) {
286:                    log.error("Error removing file from server:", e);
287:                    throw new TurbineException(e);
288:                }
289:            }
290:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.