You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by th...@apache.org on 2001/06/20 15:07:55 UTC
cvs commit: jakarta-turbine/src/java/org/apache/turbine/services/xmlrpc/util AuthenticatedFileHandler.java FileHandler.java FileTransfer.java
thorhauer 01/06/20 06:07:54
Modified: src/java/org/apache/turbine/services/xmlrpc Tag:
T_2_1_BRANCH TurbineXmlRpc.java
TurbineXmlRpcService.java XmlRpcService.java
src/java/org/apache/turbine/services/xmlrpc/util Tag:
T_2_1_BRANCH FileHandler.java FileTransfer.java
Added: src/java/org/apache/turbine/services/xmlrpc/util Tag:
T_2_1_BRANCH AuthenticatedFileHandler.java
Log:
back porting the authenticated file handling changes to xml-rpc server
Revision Changes Path
No revision
No revision
1.8.10.2 +109 -5 jakarta-turbine/src/java/org/apache/turbine/services/xmlrpc/TurbineXmlRpc.java
Index: TurbineXmlRpc.java
===================================================================
RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/services/xmlrpc/TurbineXmlRpc.java,v
retrieving revision 1.8.10.1
retrieving revision 1.8.10.2
diff -u -r1.8.10.1 -r1.8.10.2
--- TurbineXmlRpc.java 2001/05/07 03:06:11 1.8.10.1
+++ TurbineXmlRpc.java 2001/06/20 13:07:22 1.8.10.2
@@ -25,13 +25,13 @@
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
- * 4. The names "Apache" and "Apache Software Foundation" and
- * "Apache Turbine" must not be used to endorse or promote products
- * derived from this software without prior written permission. For
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache Turbine" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
- * "Apache Turbine", nor may "Apache" appear in their name, without
+ * "Apache Turbine", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
@@ -102,6 +102,26 @@
}
/**
+ * Execute a remote procedure call taht requires authentication
+ *
+ * @param url A URL.
+ * @param username The username to try and authenticate with
+ * @param password The password to try and authenticate with
+ * @param methodName A String with the method name.
+ * @param params A Vector with the parameters.
+ * @return An Object.
+ * @exception XmlRpcException.
+ * @exception IOException.
+ */
+ public static Object executeAuthenticatedRpc(URL url, String username,
+ String password,String methodName, Vector params)
+ throws TurbineException
+ {
+ return getService().executeAuthenticatedRpc(url, username, password,
+ methodName, params);
+ }
+
+ /**
* Register an object as a handler for the XmlRpc Server part.
*
* @param handlerName The name under which we want
@@ -199,16 +219,74 @@
destinationFileName);
}
+ /**
+ * Method to allow a client to send a file to a server that
+ * requires authentication
+ *
+ * @param serverURL
+ * @param username
+ * @param password
+ * @param sourceLocationProperty
+ * @param sourceFileName
+ * @param destinationLocationProperty
+ * @param destinationFileName
+ */
+ public static void send(String serverURL,
+ String username,
+ String password,
+ String sourceLocationProperty,
+ String sourceFileName,
+ String destinationLocationProperty,
+ String destinationFileName)
+ throws Exception
+ {
+ getService().send(serverURL,
+ username,
+ password,
+ sourceLocationProperty,
+ sourceFileName,
+ destinationLocationProperty,
+ destinationFileName);
+ }
+
+ /**
+ * Method to allow a client to get a file from a server.
+ *
+ * @param serverURL
+ * @param sourceLocationProperty
+ * @param sourceFileName
+ * @param destinationLocationProperty
+ * @param destinationFileName
+ */
+ public static void get(String serverURL,
+ String sourceLocationProperty,
+ String sourceFileName,
+ String destinationLocationProperty,
+ String destinationFileName)
+ throws Exception
+ {
+ getService().get(serverURL,
+ sourceLocationProperty,
+ sourceFileName,
+ destinationLocationProperty,
+ destinationFileName);
+ }
+
/**
- * Method to allow a client to get a file to a server.
+ * Method to allow a client to get a file to a server that
+ * requires authentication
*
* @param serverURL
+ * @param username
+ * @param password
* @param sourceLocationProperty
* @param sourceFileName
* @param destinationLocationProperty
* @param destinationFileName
*/
public static void get(String serverURL,
+ String username,
+ String password,
String sourceLocationProperty,
String sourceFileName,
String destinationLocationProperty,
@@ -216,6 +294,8 @@
throws Exception
{
getService().get(serverURL,
+ username,
+ password,
sourceLocationProperty,
sourceFileName,
destinationLocationProperty,
@@ -236,6 +316,30 @@
throws Exception
{
getService().remove(serverURL,
+ sourceLocationProperty,
+ sourceFileName);
+ }
+
+ /**
+ * Method to allow a client to remove a file from
+ * a server that requires authentication
+ *
+ * @param serverURL
+ * @param username
+ * @param password
+ * @param sourceLocationProperty
+ * @param sourceFileName
+ */
+ public static void remove(String serverURL,
+ String username,
+ String password,
+ String sourceLocationProperty,
+ String sourceFileName)
+ throws Exception
+ {
+ getService().remove(serverURL,
+ username,
+ password,
sourceLocationProperty,
sourceFileName);
}
1.20.4.3 +139 -48 jakarta-turbine/src/java/org/apache/turbine/services/xmlrpc/TurbineXmlRpcService.java
Index: TurbineXmlRpcService.java
===================================================================
RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/services/xmlrpc/TurbineXmlRpcService.java,v
retrieving revision 1.20.4.2
retrieving revision 1.20.4.3
diff -u -r1.20.4.2 -r1.20.4.3
--- TurbineXmlRpcService.java 2001/06/19 14:22:44 1.20.4.2
+++ TurbineXmlRpcService.java 2001/06/20 13:07:26 1.20.4.3
@@ -25,13 +25,13 @@
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
- * 4. The names "Apache" and "Apache Software Foundation" and
- * "Apache Turbine" must not be used to endorse or promote products
- * derived from this software without prior written permission. For
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache Turbine" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
- * "Apache Turbine", nor may "Apache" appear in their name, without
+ * "Apache Turbine", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
@@ -59,7 +59,6 @@
import helma.xmlrpc.XmlRpcClient;
import helma.xmlrpc.XmlRpcException;
import helma.xmlrpc.XmlRpcServer;
-import helma.xmlrpc.secure.SecureWebServer;
import java.io.IOException;
import java.io.InputStream;
import java.net.InetAddress;
@@ -74,12 +73,11 @@
import org.apache.turbine.services.ServiceBroker;
import org.apache.turbine.services.TurbineBaseService;
import org.apache.turbine.services.TurbineServices;
+import org.apache.turbine.services.resources.ResourceService;
import org.apache.turbine.services.xmlrpc.util.FileTransfer;
import org.apache.turbine.util.Log;
import org.apache.turbine.util.TurbineException;
-import org.apache.velocity.runtime.configuration.Configuration;
-
/**
* This is a service which will make an xml-rpc call to a remote
* server.
@@ -100,7 +98,7 @@
* @author <a href="mailto:Rafal.Krzewski@e-point.pl">Rafal Krzewski</a>
* @author <a href="mailto:jvanzyl@periapt.com">Jason van Zyl</a>
* @author <a href="mailto:dlr@finemaltcoding.com">Daniel Rall</a>
- * @version $Id: TurbineXmlRpcService.java,v 1.20.4.2 2001/06/19 14:22:44 jvanzyl Exp $
+ * @version $Id: TurbineXmlRpcService.java,v 1.20.4.3 2001/06/20 13:07:26 thorhauer Exp $
*/
public class TurbineXmlRpcService
extends TurbineBaseService
@@ -125,63 +123,40 @@
{
try
{
+ ResourceService resources =
+ ((TurbineServices)TurbineServices.getInstance()).
+ getResources(getName());
+
server = new XmlRpcServer();
// Set the port for the service
- port = getConfiguration().getInt("port", 0);
+ port = resources.getInt("port", 0);
if(port != 0)
{
- if (getConfiguration().getBoolean("secure.server", false))
- {
- // Get the values for the JSSE system properties
- // that we must set for use in the SecureWebServer
- // and the URL https connection handler that is
- // used in XmlRpcClient.
-
- Configuration secureServerOptions =
- getConfiguration().subset("secure.server.option");
-
- Iterator i = secureServerOptions.getKeys();
-
- while (i.hasNext())
- {
- String option = (String) i.next();
- String value = secureServerOptions.getString(option);
-
- Log.debug("JSSE option: " + option + " => " + value);
-
- System.setProperty(option, value);
- }
-
- webserver = new SecureWebServer(port);
- }
- else
- {
- webserver = new WebServer(port);
- }
+ webserver = new WebServer(port);
}
// Set the XML driver to the correct SAX parser class
- String saxParserClass = getConfiguration().getString("parser",
+ String saxParserClass = resources.getString("parser",
"org.apache.xerces.parsers.SAXParser");
XmlRpc.setDriver ( saxParserClass );
// Check if there are any handlers to register at startup
- Iterator keys = getConfiguration().getKeys("handler");
+ Iterator keys = resources.getKeys("handler");
while ( keys.hasNext() )
{
String handler = (String)keys.next();
- String handlerName = handler.substring(handler.indexOf(".")+1);
- String handlerClass = getConfiguration().getString(handler);
+ String handlerName = handler.substring(handler.indexOf('.')+1);
+ String handlerClass = resources.getString(handler);
registerHandler(handlerName, handlerClass);
}
/*
* Turn on paranoia for the webserver if requested.
*/
- boolean stateOfParanoia = getConfiguration().getBoolean("paranoid", false);
+ boolean stateOfParanoia = resources.getBoolean("paranoid", false);
if (stateOfParanoia)
{
@@ -200,7 +175,7 @@
* to the xmlrpc server. The accepted client list
* will only be consulted if we are paranoid.
*/
- Vector acceptedClients = getConfiguration().getVector("acceptClient");
+ Vector acceptedClients = resources.getVector("acceptClient");
for (int i = 0; i < acceptedClients.size(); i++)
{
@@ -219,7 +194,7 @@
* to the xmlrpc server. The denied client list
* will only be consulted if we are paranoid.
*/
- Vector deniedClients = getConfiguration().getVector("denyClient");
+ Vector deniedClients = resources.getVector("denyClient");
for (int i = 0; i < deniedClients.size(); i++)
{
@@ -251,8 +226,7 @@
* @exception IOException.
*/
public void registerHandler(Object handler)
- throws XmlRpcException,
- IOException
+ throws XmlRpcException, IOException
{
registerHandler("$default", handler);
}
@@ -267,8 +241,7 @@
*/
public void registerHandler(String handlerName,
Object handler)
- throws XmlRpcException,
- IOException
+ throws XmlRpcException, IOException
{
if(webserver != null)
{
@@ -398,6 +371,40 @@
}
/**
+ * Client's Authenticated interface to XML-RPC.
+ *
+ * The return type is Object which you'll need to cast to
+ * whatever you are expecting.
+ *
+ * @param url A URL.
+ * @param username The username to try and authenticate with
+ * @param password The password to try and authenticate with
+ * @param methodName A String with the method name.
+ * @param params A Vector with the parameters.
+ * @return An Object.
+ * @exception XmlRpcException.
+ * @exception IOException.
+ */
+ public Object executeAuthenticatedRpc(URL url,
+ String username,
+ String password,
+ String methodName,
+ Vector params)
+ throws TurbineException
+ {
+ try
+ {
+ XmlRpcClient client = new XmlRpcClient ( url );
+ client.setBasicAuthentication(username, password);
+ return client.execute(methodName, params);
+ }
+ catch (Exception e)
+ {
+ throw new TurbineException("XML-RPC call failed", e);
+ }
+ }
+
+ /**
* Method to allow a client to send a file to a server.
*
* @param serverURL
@@ -421,15 +428,73 @@
}
/**
- * Method to allow a client to get a file to a server.
+ * Method to allow a client to send a file to a server that
+ * requires authentication
*
* @param serverURL
+ * @param username
+ * @param password
* @param sourceLocationProperty
* @param sourceFileName
* @param destinationLocationProperty
* @param destinationFileName
*/
+ public void send(String serverURL,
+ String username,
+ String password,
+ String sourceLocationProperty,
+ String sourceFileName,
+ String destinationLocationProperty,
+ String destinationFileName)
+ throws Exception
+ {
+ FileTransfer.send(serverURL,
+ username,
+ password,
+ sourceLocationProperty,
+ sourceFileName,
+ destinationLocationProperty,
+ destinationFileName);
+ }
+
+ /**
+ * Method to allow a client to get a file from a server.
+ *
+ * @param serverURL
+ * @param sourceLocationProperty
+ * @param sourceFileName
+ * @param destinationLocationProperty
+ * @param destinationFileName
+ */
+ public void get(String serverURL,
+ String sourceLocationProperty,
+ String sourceFileName,
+ String destinationLocationProperty,
+ String destinationFileName)
+ throws Exception
+ {
+ FileTransfer.get(serverURL,
+ sourceLocationProperty,
+ sourceFileName,
+ destinationLocationProperty,
+ destinationFileName);
+ }
+
+ /**
+ * Method to allow a client to get a file from a server that
+ * requires authentication.
+ *
+ * @param serverURL
+ * @param username
+ * @param password
+ * @param sourceLocationProperty
+ * @param sourceFileName
+ * @param destinationLocationProperty
+ * @param destinationFileName
+ */
public void get(String serverURL,
+ String username,
+ String password,
String sourceLocationProperty,
String sourceFileName,
String destinationLocationProperty,
@@ -437,6 +502,8 @@
throws Exception
{
FileTransfer.get(serverURL,
+ username,
+ password,
sourceLocationProperty,
sourceFileName,
destinationLocationProperty,
@@ -457,6 +524,30 @@
throws Exception
{
FileTransfer.remove(serverURL,
+ sourceLocationProperty,
+ sourceFileName);
+ }
+
+ /**
+ * Method to allow a client to remove a file from
+ * a server that requires authentication.
+ *
+ * @param serverURL
+ * @param username
+ * @param password
+ * @param sourceLocationProperty
+ * @param sourceFileName
+ */
+ public void remove(String serverURL,
+ String username,
+ String password,
+ String sourceLocationProperty,
+ String sourceFileName)
+ throws Exception
+ {
+ FileTransfer.remove(serverURL,
+ username,
+ password,
sourceLocationProperty,
sourceFileName);
}
1.11.10.2 +84 -6 jakarta-turbine/src/java/org/apache/turbine/services/xmlrpc/XmlRpcService.java
Index: XmlRpcService.java
===================================================================
RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/services/xmlrpc/XmlRpcService.java,v
retrieving revision 1.11.10.1
retrieving revision 1.11.10.2
diff -u -r1.11.10.1 -r1.11.10.2
--- XmlRpcService.java 2001/05/07 03:06:13 1.11.10.1
+++ XmlRpcService.java 2001/06/20 13:07:28 1.11.10.2
@@ -25,13 +25,13 @@
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
- * 4. The names "Apache" and "Apache Software Foundation" and
- * "Apache Turbine" must not be used to endorse or promote products
- * derived from this software without prior written permission. For
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache Turbine" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
- * "Apache Turbine", nor may "Apache" appear in their name, without
+ * "Apache Turbine", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
@@ -69,7 +69,7 @@
* @author <a href="mailto:magnus@handtolvur.is">Magn�s ��r Torfason</a>
* @author <a href="mailto:Rafal.Krzewski@e-point.pl">Rafal Krzewski</a>
* @author <a href="jvanzyl@periapt.com">Jason van Zyl</a>
- * @version $Id: XmlRpcService.java,v 1.11.10.1 2001/05/07 03:06:13 jvanzyl Exp $
+ * @version $Id: XmlRpcService.java,v 1.11.10.2 2001/06/20 13:07:28 thorhauer Exp $
*/
public interface XmlRpcService
extends Service
@@ -93,6 +93,26 @@
throws TurbineException;
/**
+ * Execute a remote procedure call taht requires
+ * authentication.
+ *
+ * @param url A URL.
+ * @param username The username to authenticate with
+ * @param password The password to authenticate with
+ * @param methodName A String with the method name.
+ * @param params A Vector with the parameters.
+ * @return An Object.
+ * @exception XmlRpcException.
+ * @exception IOException.
+ */
+ public Object executeAuthenticatedRpc(URL url,
+ String username,
+ String password,
+ String methodName,
+ Vector params)
+ throws TurbineException;
+
+ /**
* Register an object as a handler for the XmlRpc Server part.
*
* @param handlerName The name under which we want
@@ -167,17 +187,58 @@
String destinationLocationProperty,
String destinationFileName)
throws Exception;
+ /**
+ * Method to allow a client to send a file to a server that
+ * requires authentication
+ *
+ * @param serverURL
+ * @param username
+ * @param password
+ * @param sourceLocationProperty
+ * @param sourceFileName
+ * @param destinationLocationProperty
+ * @param destinationFileName
+ */
+ public void send(String serverURL,
+ String username,
+ String password,
+ String sourceLocationProperty,
+ String sourceFileName,
+ String destinationLocationProperty,
+ String destinationFileName)
+ throws Exception;
+
+ /**
+ * Method to allow a client to send a file to a server.
+ *
+ * @param serverURL
+ * @param sourceLocationProperty
+ * @param sourceFileName
+ * @param destinationLocationProperty
+ * @param destinationFileName
+ */
+ public void get(String serverURL,
+ String sourceLocationProperty,
+ String sourceFileName,
+ String destinationLocationProperty,
+ String destinationFileName)
+ throws Exception;
/**
- * Method to allow a client to get a file to a server.
+ * Method to allow a client to send a file to a server that
+ * rewuires authentication
*
* @param serverURL
+ * @param username
+ * @param password
* @param sourceLocationProperty
* @param sourceFileName
* @param destinationLocationProperty
* @param destinationFileName
*/
public void get(String serverURL,
+ String username,
+ String password,
String sourceLocationProperty,
String sourceFileName,
String destinationLocationProperty,
@@ -193,6 +254,23 @@
* @param sourceFileName
*/
public void remove(String serverURL,
+ String sourceLocationProperty,
+ String sourceFileName)
+ throws Exception;
+
+ /**
+ * Method to allow a client to remove a file from
+ * a server that requires authentication
+ *
+ * @param serverURL
+ * @param username
+ * @param password
+ * @param sourceLocationProperty
+ * @param sourceFileName
+ */
+ public void remove(String serverURL,
+ String username,
+ String password,
String sourceLocationProperty,
String sourceFileName)
throws Exception;
No revision
No revision
1.5.10.1 +1 -1 jakarta-turbine/src/java/org/apache/turbine/services/xmlrpc/util/FileHandler.java
Index: FileHandler.java
===================================================================
RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/services/xmlrpc/util/FileHandler.java,v
retrieving revision 1.5
retrieving revision 1.5.10.1
diff -u -r1.5 -r1.5.10.1
--- FileHandler.java 2001/03/06 06:13:02 1.5
+++ FileHandler.java 2001/06/20 13:07:43 1.5.10.1
@@ -213,7 +213,7 @@
sw.write( buf, 0, len );
}
- return MimeUtility.encodeText(sw.toString(), "UTF-8", "base64");
+ return MimeUtility.encodeText(sw.toString(), "UTF-8", "B");
}
catch (IOException ioe)
{
1.6.10.1 +166 -6 jakarta-turbine/src/java/org/apache/turbine/services/xmlrpc/util/FileTransfer.java
Index: FileTransfer.java
===================================================================
RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/services/xmlrpc/util/FileTransfer.java,v
retrieving revision 1.6
retrieving revision 1.6.10.1
diff -u -r1.6 -r1.6.10.1
--- FileTransfer.java 2001/03/06 06:13:03 1.6
+++ FileTransfer.java 2001/06/20 13:07:45 1.6.10.1
@@ -25,13 +25,13 @@
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
- * 4. The names "Apache" and "Apache Software Foundation" and
- * "Apache Turbine" must not be used to endorse or promote products
- * derived from this software without prior written permission. For
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache Turbine" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
- * "Apache Turbine", nor may "Apache" appear in their name, without
+ * "Apache Turbine", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
@@ -65,7 +65,7 @@
* Test class for FileHandler.
*
* @author <a href="mailto:jvanzyl@periapt.com">Jason van Zyl</a>
- * @version $Id: FileTransfer.java,v 1.6 2001/03/06 06:13:03 chrise Exp $
+ * @version $Id: FileTransfer.java,v 1.6.10.1 2001/06/20 13:07:45 thorhauer Exp $
*/
public class FileTransfer
{
@@ -118,6 +118,63 @@
}
/**
+ * Method to allow a client to send a file to a server
+ * that requires a user name and password.
+ *
+ * @param serverURL
+ * @param username
+ * @param password
+ * @param sourceLocationProperty
+ * @param sourceFileName
+ * @param destinationLocationProperty
+ * @param destinationFileName
+ */
+ public static void send(String serverURL,
+ String username,
+ String password,
+ String sourceLocationProperty,
+ String sourceFileName,
+ String destinationLocationProperty,
+ String destinationFileName)
+ throws Exception
+ {
+ try
+ {
+ Vector params = new Vector();
+
+ /*
+ * fileContents
+ */
+ params.add(FileHandler.readFileContents(
+ sourceLocationProperty, sourceFileName));
+
+ /*
+ * property in TR.props which refers to the directory
+ * where the fileContents should land.
+ */
+ params.add(destinationLocationProperty);
+
+ /*
+ * name to give the file contents.
+ */
+ params.add(destinationFileName);
+
+ Boolean b = (Boolean) TurbineXmlRpc.executeAuthenticatedRpc(
+ new URL (serverURL),
+ username,
+ password,
+ "file.send",
+ params);
+
+ }
+ catch (Exception e)
+ {
+ Log.error("Error sending file to server:", e);
+ throw new Exception(e.toString());
+ }
+ }
+
+ /**
* Method to allow a client to get a file to a server.
*
* @param serverURL
@@ -167,6 +224,64 @@
}
/**
+ * Method to allow a client to get a file from a server
+ * that requires a user name and password.
+ *
+ * @param serverURL
+ * @param username
+ * @param password
+ * @param sourceLocationProperty
+ * @param sourceFileName
+ * @param destinationLocationProperty
+ * @param destinationFileName
+ */
+ public static void get(String serverURL,
+ String username,
+ String password,
+ String sourceLocationProperty,
+ String sourceFileName,
+ String destinationLocationProperty,
+ String destinationFileName)
+ throws Exception
+ {
+
+ try
+ {
+ Vector params = new Vector();
+
+ /*
+ * property in TR.props which refers to the directory
+ * where the fileContents should land.
+ */
+ params.add(sourceLocationProperty);
+
+ /*
+ * name to give the file contents.
+ */
+ params.add(sourceFileName);
+
+ String fileContents = (String) TurbineXmlRpc.executeAuthenticatedRpc(
+ new URL (serverURL),
+ username,
+ password,
+ "file.get",
+ params);
+
+ /*
+ * Now we have the file contents, we can write
+ * them out to disk.
+ */
+ FileHandler.writeFileContents(fileContents,
+ destinationLocationProperty, destinationFileName);
+ }
+ catch (Exception e)
+ {
+ Log.error("Error getting file from server:", e);
+ throw new Exception(e.toString());
+ }
+ }
+
+ /**
* Method to allow a client to remove a file from
* the server
*
@@ -201,5 +316,50 @@
Log.error("Error removing file from server:", e);
throw new Exception(e.toString());
}
+ }
+
+ /**
+ * Method to allow a client to remove a file from
+ * a server that requires a user name and password.
+ *
+ * @param serverURL
+ * @param username
+ * @param password
+ * @param sourceLocationProperty
+ * @param sourceFileName
+ */
+ public static void remove(String serverURL,
+ String username,
+ String password,
+ String sourceLocationProperty,
+ String sourceFileName)
+ throws Exception
+ {
+ try
+ {
+ Vector params = new Vector();
+
+ /*
+ * property in TR.props which refers to the directory
+ * where the fileContents should land.
+ */
+ params.add(sourceLocationProperty);
+
+ /*
+ * name to give the file contents.
+ */
+ params.add(sourceFileName);
+
+ TurbineXmlRpc.executeAuthenticatedRpc(new URL (serverURL),
+ username,
+ password,
+ "file.remove",
+ params);
+ }
+ catch (Exception e)
+ {
+ Log.error("Error removing file from server:", e);
+ throw new Exception(e.toString());
+ }
}
-}
+}
\ No newline at end of file
No revision
No revision
1.1.2.1 +5 -2 jakarta-turbine/src/java/org/apache/turbine/services/xmlrpc/util/AuthenticatedFileHandler.java
Index: AuthenticatedFileHandler.java
===================================================================
RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/services/xmlrpc/util/AuthenticatedFileHandler.java,v
retrieving revision 1.1
retrieving revision 1.1.2.1
diff -u -r1.1 -r1.1.2.1
--- AuthenticatedFileHandler.java 2001/06/08 02:51:54 1.1
+++ AuthenticatedFileHandler.java 2001/06/20 13:07:41 1.1.2.1
@@ -66,9 +66,12 @@
/**
* An authenticated Handler for use with the XML-RPC service that will deal
* with clients sending file to the server (Turbine application)
- * and clients getting files from the server (Turbine application). See the
- * FileHandler class for further documentation.
+ * and clients getting files from the server (Turbine application).
*
+ * usage in TurbineResources.properties is:
+ * services.XmlRpcService.handler.file = org.apache.turbine.services.xmlrpc.util.AuthenticatedFileHandler
+ *
+ * See the FileHandler class for further documentation.
*
* @author <a href="mailto:john@zenplex.com">John Thorhauer</a>
*/
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org