You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by jb...@apache.org on 2009/02/23 09:23:58 UTC
svn commit: r746921 -
/servicemix/components/bindings/servicemix-file/trunk/src/main/java/org/apache/servicemix/file/FileSenderEndpoint.java
Author: jbonofre
Date: Mon Feb 23 08:23:58 2009
New Revision: 746921
URL: http://svn.apache.org/viewvc?rev=746921&view=rev
Log:
SMXCOMP-55 : if tempFilePrefix and tempFileSuffix are not null, the sender endpoint generate a file using this prefix and suffix.
Modified:
servicemix/components/bindings/servicemix-file/trunk/src/main/java/org/apache/servicemix/file/FileSenderEndpoint.java
Modified: servicemix/components/bindings/servicemix-file/trunk/src/main/java/org/apache/servicemix/file/FileSenderEndpoint.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-file/trunk/src/main/java/org/apache/servicemix/file/FileSenderEndpoint.java?rev=746921&r1=746920&r2=746921&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-file/trunk/src/main/java/org/apache/servicemix/file/FileSenderEndpoint.java (original)
+++ servicemix/components/bindings/servicemix-file/trunk/src/main/java/org/apache/servicemix/file/FileSenderEndpoint.java Mon Feb 23 08:23:58 2009
@@ -63,17 +63,25 @@
throw new DeploymentException("The directory property must be a directory but was: " + directory);
}
}
+
+ protected String getFileName(String name) {
+ String result = tempFilePrefix == null ? name : tempFilePrefix + name;
+ result = tempFileSuffix == null ? result : result + tempFileSuffix;
+ return result;
+ }
protected void processInOnly(MessageExchange exchange, NormalizedMessage in) throws Exception {
OutputStream out = null;
File newFile = null;
+ String fileName = null;
boolean success = false;
try {
String name = marshaler.getOutputName(exchange, in);
if (name == null) {
newFile = File.createTempFile(tempFilePrefix, tempFileSuffix, directory);
} else {
- newFile = new File(directory, name);
+ fileName = this.getFileName(name);
+ newFile = new File(directory, fileName);
}
if (!newFile.getParentFile().exists() && isAutoCreateDirectory()) {
newFile.getParentFile().mkdirs();
@@ -144,11 +152,10 @@
}
/**
- * Specifies a string to prefix to the beginning of generated temporary file
- * names. Temporary file names are generated when the endpoint cannot
- * determine the name of the file from the message.
+ * Specifies a string to prefix to the beginning of generated file
+ * names.
*
- * @param tempFilePrefix a string to prefix to generated file names
+ * @param filePrefix a string to prefix to generated file names
*/
public void setTempFilePrefix(String tempFilePrefix) {
this.tempFilePrefix = tempFilePrefix;
@@ -159,11 +166,9 @@
}
/**
- * Specifies a string to append to generated temporary file names. Temporary
- * file names are generated when the endpoint cannot determine the name of
- * the file from the message.
+ * Specifies a string to append to generated file names.
*
- * @param tempFileSuffix a string to append to generated file names
+ * @param fileSuffix a string to append to generated file names
*/
public void setTempFileSuffix(String tempFileSuffix) {
this.tempFileSuffix = tempFileSuffix;