dlr 01/11/18 11:59:19
Modified: src/services/java/org/apache/fulcrum/xmlrpc
TurbineXmlRpc.java
src/services/java/org/apache/fulcrum/xmlrpc/util
FileHandler.java
Log:
Potential fix for Bugzilla #4907: xml-rpc FileHandler constructor causes double
service initialization
Revision Changes Path
1.2 +16 -0
jakarta-turbine-fulcrum/src/services/java/org/apache/fulcrum/xmlrpc/TurbineXmlRpc.java
Index: TurbineXmlRpc.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-fulcrum/src/services/java/org/apache/fulcrum/xmlrpc/TurbineXmlRpc.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -u -r1.1 -r1.2
--- TurbineXmlRpc.java 2001/08/01 15:51:25 1.1
+++ TurbineXmlRpc.java 2001/11/18 19:59:19 1.2
@@ -380,4 +380,20 @@
{
getService().denyClient(address);
}
+
+ /**
+ * @see org.apache.fulcrum.Service#getRealPath(String)
+ */
+ public static String getRealPath(String path)
+ {
+ return getService().getRealPath(path);
+ }
+
+ /**
+ * Gets the named property.
+ */
+ public static String getProperty(String property)
+ {
+ return getService().getConfiguration().getString(property);
+ }
}
1.4 +24 -26
jakarta-turbine-fulcrum/src/services/java/org/apache/fulcrum/xmlrpc/util/FileHandler.java
Index: FileHandler.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-fulcrum/src/services/java/org/apache/fulcrum/xmlrpc/util/FileHandler.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -u -r1.3 -r1.4
--- FileHandler.java 2001/10/19 16:44:24 1.3
+++ FileHandler.java 2001/11/18 19:59:19 1.4
@@ -61,10 +61,10 @@
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.StringWriter;
-
import javax.mail.internet.MimeUtility;
-import org.apache.fulcrum.TurbineServices;
-import org.apache.fulcrum.xmlrpc.XmlRpcService;
+
+import org.apache.fulcrum.xmlrpc.TurbineXmlRpc;
+import org.apache.log4j.Category;
/**
* A Handler for use with the XML-RPC service that will deal
@@ -93,15 +93,17 @@
*/
public class FileHandler
{
- protected XmlRpcService service;
+ /**
+ * The logger.
+ */
+ private static Category category =
+ Category.getInstance(FileHandler.class.getName());
/**
* Default Constructor
*/
public FileHandler()
{
- service = (XmlRpcService)TurbineServices.getInstance()
- .getService(XmlRpcService.SERVICE_NAME);
}
/**
@@ -189,9 +191,9 @@
public String readFileContents(String targetLocationProperty,
String fileName)
{
- String file = service.getRealPath(
- service.getConfiguration().getString(targetLocationProperty) +
- "/" + fileName);
+ String file = TurbineXmlRpc.getRealPath(
+ TurbineXmlRpc.getProperty(targetLocationProperty) +
+ '/' + fileName);
StringWriter sw = null;
BufferedReader reader = null;
@@ -220,10 +222,8 @@
}
catch (IOException ioe)
{
- service.getCategory().error(
- "[FileHandler] Unable to encode the contents " +
- "of the request file.", ioe);
-
+ category.error("Unable to encode the contents of the request file",
+ ioe);
return null;
}
finally
@@ -233,9 +233,8 @@
sw.close();
reader.close();
}
- catch (Exception e)
+ catch (Exception ignored)
{
-
}
}
}
@@ -251,9 +250,8 @@
*/
File targetLocation = new File(
- service.getRealPath(
- service.getConfiguration().getString(
- targetLocationProperty)));
+ TurbineXmlRpc.getRealPath(
+ TurbineXmlRpc.getProperty(targetLocationProperty)));
if (targetLocation.exists() == false)
{
@@ -265,16 +263,16 @@
if (targetLocation.mkdirs() == false)
{
- service.getCategory().error(
- "[FileHandler] Could not create target location: " +
+ category.error(
+ "Could not create target location: " +
targetLocation + ". Cannot transfer file from client.");
return false;
}
else
{
- service.getCategory().info(
- "[FileHandler] Creating target location:" + targetLocation +
+ category.info(
+ "Creating target location: " + targetLocation +
" in order to complete file transfer from client.");
}
}
@@ -302,8 +300,8 @@
}
catch (IOException ioe)
{
- service.getCategory().error(
- "[FileHandler] Could not write the decoded file " +
+ category.error(
+ "Could not write the decoded file " +
"contents to disk for the following reason.", ioe);
return false;
@@ -328,8 +326,8 @@
*/
File sourceFile = new File(
- service.getRealPath(
- service.getConfiguration().getString(sourceLocationProperty) +
+ TurbineXmlRpc.getRealPath(
+ TurbineXmlRpc.getProperty(sourceLocationProperty) +
"/" + sourceFileName));
if (sourceFile.exists())
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>