thorhauer 01/06/14 07:17:55
Modified: src/java/org/apache/turbine/services/xmlrpc/util
FileHandler.java
Log:
base64 option was invalid according to the api docs. it should be B (base64)
or Q (Quote Printable).
Revision Changes Path
1.6 +35 -35
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.6
diff -u -r1.5 -r1.6
--- FileHandler.java 2001/03/06 06:13:02 1.5
+++ FileHandler.java 2001/06/14 14:17:53 1.6
@@ -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 [EMAIL PROTECTED]
*
* 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
@@ -97,7 +97,7 @@
public class FileHandler
{
/**
- * Default Constructor
+ * Default Constructor
*/
public FileHandler()
{
@@ -125,13 +125,13 @@
*
* @param fileName: Name to give the file created to store
* the contents.
- *
+ *
* @param targetLocationProperty: storage location of this file
- * is controlled by this property that is specified in
+ * is controlled by this property that is specified in
* the TR.props file or an included properties file.
*/
- public boolean send(String fileContents,
- String targetLocationProperty,
+ public boolean send(String fileContents,
+ String targetLocationProperty,
String fileName)
{
/*
@@ -143,7 +143,7 @@
*/
return writeFileContents(fileContents, targetLocationProperty, fileName);
}
-
+
/**
* The client has indicated that it would like
* to get a file from the server.
@@ -161,9 +161,9 @@
*
* @param fileName: Name to give the file created to store
* the contents.
- *
+ *
* @param targetLocationProperty: storage location of this file
- * is controlled by this property that is specified in
+ * is controlled by this property that is specified in
* the TR.props file or an included properties file.
*
* @return the file contents encoded with base64.
@@ -178,7 +178,7 @@
*/
return readFileContents(targetLocationProperty, fileName);
}
-
+
/**
* Return the content of file encoded for transfer
*
@@ -189,37 +189,37 @@
String fileName)
{
String file = TurbineServlet.getRealPath(
- TurbineResources.getString(targetLocationProperty) +
+ TurbineResources.getString(targetLocationProperty) +
"/" + fileName);
-
+
try
{
/*
* This little routine was borrowed from the
* velocity ContentResource class.
*/
-
+
StringWriter sw = new StringWriter();
-
+
BufferedReader reader = new BufferedReader(
new InputStreamReader(
new FileInputStream(file)));
-
+
char buf[] = new char[1024];
int len = 0;
-
+
while ((len = reader.read(buf, 0, 1024)) != -1)
{
sw.write( buf, 0, len );
}
-
- return MimeUtility.encodeText(sw.toString(), "UTF-8", "base64");
+
+ return MimeUtility.encodeText(sw.toString(), "UTF-8", "B");
}
catch (IOException ioe)
{
Log.error("[FileHandler] Unable to encode the contents " +
"of the request file.", ioe);
-
+
return null;
}
}
@@ -233,7 +233,7 @@
* make the application fully portable. So use the TurbineServlet
* service to map the target location in the webapp space.
*/
-
+
File targetLocation = new File(
TurbineServlet.getRealPath(
TurbineResources.getString(
@@ -246,12 +246,12 @@
* attempt to create the target location and any
* necessary parent directories as well.
*/
-
+
if (targetLocation.mkdirs() == false)
{
- Log.error("[FileHandler] Could not create target location: " +
+ Log.error("[FileHandler] Could not create target location: " +
targetLocation + ". Cannot transfer file from client.");
-
+
return false;
}
else
@@ -259,34 +259,34 @@
Log.info("[FileHandler] Creating target location:" + targetLocation
+
" in order to complete file transfer from client.");
}
- }
-
+ }
+
try
{
/*
* Try to create the target file and write it out
* to the target location.
*/
-
+
FileWriter fileWriter = new FileWriter(
targetLocation + "/" + fileName);
-
+
/*
* It is assumed that the file has been encoded
* and therefore must be decoded before the
* contents of the file are stored to disk.
*/
-
+
fileWriter.write(MimeUtility.decodeText(fileContents));
fileWriter.close();
-
+
return true;
}
catch (IOException ioe)
{
Log.error("[FileHandler] Could not write the decoded file " +
"contents to disk for the following reason.", ioe);
-
+
return false;
}
}
@@ -307,7 +307,7 @@
* make the application fully portable. So use the TurbineServlet
* service to map the target location in the webapp space.
*/
-
+
File sourceFile = new File(
TurbineServlet.getRealPath(
TurbineResources.getString(sourceLocationProperty) +
@@ -318,4 +318,4 @@
sourceFile.delete();
}
}
-}
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]