You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2009/01/26 10:28:27 UTC
svn commit: r737658 - in /camel/trunk/camel-core/src:
main/java/org/apache/camel/component/file/
main/java/org/apache/camel/component/file/strategy/
test/java/org/apache/camel/component/file/
Author: davsclaus
Date: Mon Jan 26 09:28:26 2009
New Revision: 737658
URL: http://svn.apache.org/viewvc?rev=737658&view=rev
Log:
CAMEL-1241: More work on the VFS in camel-core (work in progress).
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFile.java
camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileBinding.java
camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileConsumer.java
camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileDefaultBinding.java
camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java
camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileOperations.java
camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileProducer.java
camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/NewFileBinding.java
camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/NewFileComponent.java
camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/NewFileEndpoint.java
camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/NewFileOperations.java
camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/NewFileLockExclusiveReadLockStrategy.java
camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/NewMarkerFileExclusiveReadLockStrategy.java
camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerFailureHandledTest.java
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFile.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFile.java?rev=737658&r1=737657&r2=737658&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFile.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFile.java Mon Jan 26 09:28:26 2009
@@ -30,8 +30,7 @@
private long fileLength;
private long lastModified;
private T file;
- private Object body;
- private GenericFileBinding<T> binding = new GenericFileDefaultBinding();
+ private GenericFileBinding<T> binding;
@Override
public GenericFile<T> clone() {
@@ -138,18 +137,25 @@
}
public Object getBody() {
- return binding.getBody(this);
+ return getBinding().getBody(this);
}
public void setBody(Object os) {
- binding.setBody(this, os);
+ getBinding().setBody(this, os);
}
public String getParent() {
- return getAbsoluteFileName().substring(0, getAbsoluteFileName().lastIndexOf("/"));
+ if (getAbsoluteFileName().lastIndexOf("/") > 0) {
+ return getAbsoluteFileName().substring(0, getAbsoluteFileName().lastIndexOf("/"));
+ } else {
+ return "";
+ }
}
public GenericFileBinding<T> getBinding() {
+ if (binding == null) {
+ binding = new GenericFileDefaultBinding();
+ }
return binding;
}
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileBinding.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileBinding.java?rev=737658&r1=737657&r2=737658&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileBinding.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileBinding.java Mon Jan 26 09:28:26 2009
@@ -21,7 +21,19 @@
*/
public interface GenericFileBinding<T> {
- public Object getBody(GenericFile<T> file);
+ /**
+ * Gets the body of the file
+ *
+ * @param file the file
+ * @return the body
+ */
+ Object getBody(GenericFile<T> file);
- public void setBody(GenericFile<T> file, Object body);
+ /**
+ * Sets the body from the given file
+ *
+ * @param file the file
+ * @param body the body
+ */
+ void setBody(GenericFile<T> file, Object body);
}
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileConsumer.java?rev=737658&r1=737657&r2=737658&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileConsumer.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileConsumer.java Mon Jan 26 09:28:26 2009
@@ -100,7 +100,7 @@
* Override if required. Perform some checks (and perhaps actions) before we
* poll
*/
- protected void prePollCheck() {
+ protected void prePollCheck() throws Exception {
}
/**
@@ -153,7 +153,7 @@
log.trace("Retreiving file: " + name + " from: " + endpoint);
}
- operations.retrieveFile(target.getFile(), name, exchange);
+ operations.retrieveFile(name, exchange);
if (log.isTraceEnabled()) {
log.trace("Retrieved file: " + name + " from: " + endpoint);
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileDefaultBinding.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileDefaultBinding.java?rev=737658&r1=737657&r2=737658&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileDefaultBinding.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileDefaultBinding.java Mon Jan 26 09:28:26 2009
@@ -1,3 +1,19 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.camel.component.file;
/**
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java?rev=737658&r1=737657&r2=737658&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java Mon Jan 26 09:28:26 2009
@@ -106,13 +106,8 @@
public abstract GenericFileExchange<T> createExchange(GenericFile<T> file);
-
- /**
- * Returns the first portion of the "protocol" in use. We use this so we can
- * look back into the META-INF protocol file to locate the default strategy
- */
- protected abstract String getUriProtocol();
-
+ public abstract String getScheme();
+
/**
* Return the file name that will be auto-generated for the given message if
* none is provided
@@ -142,7 +137,7 @@
Class<?> factory = null;
try {
FactoryFinder finder = getCamelContext().createFactoryFinder("META-INF/services/org/apache/camel/component/");
- factory = finder.findClass(getUriProtocol(), "strategy.factory.");
+ factory = finder.findClass(getScheme(), "strategy.factory.");
} catch (ClassNotFoundException e) {
log.debug("'strategy.factory.class' not found", e);
} catch (IOException e) {
@@ -426,7 +421,7 @@
* Configures the given message with the file which sets the body to the
* file object and sets the {@link FileComponent#HEADER_FILE_NAME} header.
*/
- public void configureMessage(GenericFile file, Message message) {
+ public void configureMessage(GenericFile<T> file, Message message) {
message.setBody(file);
message.setHeader(FileComponent.HEADER_FILE_NAME, file.getRelativeFileName());
}
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileOperations.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileOperations.java?rev=737658&r1=737657&r2=737658&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileOperations.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileOperations.java Mon Jan 26 09:28:26 2009
@@ -18,12 +18,10 @@
import java.util.List;
-import org.apache.camel.Exchange;
-
public interface GenericFileOperations<T> {
/**
- * Deletes the file from the remote server
+ * Deletes the file name by name, relative to the current directory
*
* @param name name of the file
* @return true if deleted, false if not
@@ -33,7 +31,7 @@
boolean deleteFile(String name) throws GenericFileOperationFailedException;
/**
- * Renames the file on the remote server
+ * Renames the file
*
* @param from original name
* @param to the new name
@@ -44,7 +42,7 @@
boolean renameFile(String from, String to) throws GenericFileOperationFailedException;
/**
- * Builds the directory structure on the remote server. Will test if the
+ * Builds the directory structure. Will test if the
* folder already exists.
*
* @param directory the directory path to build
@@ -56,26 +54,26 @@
boolean buildDirectory(String directory) throws GenericFileOperationFailedException;
/**
- * Retrieves the remote file (download)
+ * Retrieves the file
*
- * @param name name of the file
- * @param exchange stream to write the content of the file into
+ * @param name name of the file
+ * @param exchange stream to write the content of the file into
* @return true if file has been retrieved, false if not
* @throws GenericFileOperationFailedException
* can be thrown
*/
- boolean retrieveFile(T file, String name, Exchange exchange) throws GenericFileOperationFailedException;
+ boolean retrieveFile(String name, GenericFileExchange<T> exchange) throws GenericFileOperationFailedException;
/**
* Stores the content as a new remote file (upload)
*
- * @param name name of new file
+ * @param name name of new file
* @param exchange with the content content of the file
* @return true if the file was stored, false if not
* @throws GenericFileOperationFailedException
* can be thrown
*/
- boolean storeFile(String name, Exchange exchange) throws GenericFileOperationFailedException;
+ boolean storeFile(String name, GenericFileExchange<T> exchange) throws GenericFileOperationFailedException;
/**
* Gets the current remote directory
@@ -84,7 +82,7 @@
* @throws GenericFileOperationFailedException
* can be thrown
*/
- String getCurrentDirectory(T file) throws GenericFileOperationFailedException;
+ String getCurrentDirectory() throws GenericFileOperationFailedException;
/**
* Change the current remote directory
@@ -93,16 +91,16 @@
* @throws GenericFileOperationFailedException
* can be thrown
*/
- T changeCurrentDirectory(T file, String path) throws GenericFileOperationFailedException;
+ void changeCurrentDirectory(String path) throws GenericFileOperationFailedException;
/**
- * List the files in the current remote directory
+ * List the files in the current directory
*
* @return a list of backing objects representing the files
* @throws GenericFileOperationFailedException
* can be thrown
*/
- List<T> listFiles(T file) throws GenericFileOperationFailedException;
+ List<T> listFiles() throws GenericFileOperationFailedException;
/**
* List the files in the given remote directory
@@ -112,6 +110,6 @@
* @throws GenericFileOperationFailedException
* can be thrown
*/
- List<T> listFiles(T file, String path) throws GenericFileOperationFailedException;
+ List<T> listFiles(String path) throws GenericFileOperationFailedException;
}
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileProducer.java?rev=737658&r1=737657&r2=737658&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileProducer.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileProducer.java Mon Jan 26 09:28:26 2009
@@ -16,7 +16,7 @@
*/
package org.apache.camel.component.file;
-import java.io.File;
+import java.io.InputStream;
import org.apache.camel.Exchange;
import org.apache.camel.Expression;
@@ -63,55 +63,85 @@
log.trace("Processing " + exchange);
}
- String target = createFileName(exchange);
+ try {
+ String target = createFileName(exchange);
- // should we write to a temporary name and then afterwards rename to real target
- boolean writeAsTempAndRename = ObjectHelper.isNotEmpty(getGenericFileEndpoint().getTempPrefix());
- String tempTarget = null;
- if (writeAsTempAndRename) {
- // compute temporary name with the temp prefix
- tempTarget = createTempFileName(target);
- }
-
- // upload the file
- writeFile(exchange, tempTarget != null ? tempTarget : target);
-
- // if we did write to a temporary name then rename it to the real
- // name after we have written the file
- if (tempTarget != null) {
- if (log.isTraceEnabled()) {
- log.trace("Renaming file: " + tempTarget + " to: " + target);
- }
- boolean renamed = operations.renameFile(tempTarget, target);
- if (!renamed) {
- throw new GenericFileOperationFailedException("Cannot rename file from: " + tempTarget + " to: " + target);
+ preWriteCheck();
+
+ // should we write to a temporary name and then afterwards rename to real target
+ boolean writeAsTempAndRename = ObjectHelper.isNotEmpty(getGenericFileEndpoint().getTempPrefix());
+ String tempTarget = null;
+ if (writeAsTempAndRename) {
+ // compute temporary name with the temp prefix
+ tempTarget = createTempFileName(target);
+ }
+
+ // upload the file
+ writeFile(exchange, tempTarget != null ? tempTarget : target);
+
+ // if we did write to a temporary name then rename it to the real
+ // name after we have written the file
+ if (tempTarget != null) {
+ if (log.isTraceEnabled()) {
+ log.trace("Renaming file: [" + tempTarget + "] to: [" + target + "]");
+ }
+ boolean renamed = getOperations().renameFile(tempTarget, target);
+ if (!renamed) {
+ throw new GenericFileOperationFailedException("Cannot rename file from: " + tempTarget + " to: " + target);
+ }
}
+
+ // lets store the name we really used in the header, so end-users
+ // can retrieve it
+ exchange.getIn().setHeader(FileComponent.HEADER_FILE_NAME_PRODUCED, target);
+ } catch (Exception e) {
+ handleFailedWrite(exchange, e);
}
+ }
- // lets store the name we really used in the header, so end-users can retrieve it
- exchange.getIn().setHeader(FileComponent.HEADER_FILE_NAME_PRODUCED, target);
+ /**
+ * If we fail writing out a file, we will call this method. This hook is
+ * provided to disconnect from servers or clean up files we created (if needed).
+ */
+ protected void handleFailedWrite(GenericFileExchange<T> exchange, Exception exception) throws Exception {
+ throw exception;
}
/**
* Perform any actions that need to occur before we write Such as connecting
* to an FTP server etc.
*/
- protected void preWriteCheck() {
+ protected void preWriteCheck() throws Exception {
}
- protected void writeFile(Exchange exchange, String fileName) throws GenericFileOperationFailedException {
- // build directory
- int lastPathIndex = fileName.lastIndexOf('/');
- if (lastPathIndex != -1) {
- String directory = fileName.substring(0, lastPathIndex);
- if (!operations.buildDirectory(directory)) {
- log.debug("Can not build directory: " + directory + " (could be because of denied permissions)");
+ protected void writeFile(GenericFileExchange<T> exchange, String fileName) throws GenericFileOperationFailedException {
+ InputStream payload = exchange.getIn().getBody(InputStream.class);
+ try {
+ // build directory
+ int lastPathIndex = fileName.lastIndexOf('/');
+ if (lastPathIndex != -1) {
+ String directory = fileName.substring(0, lastPathIndex);
+ if (!getOperations().buildDirectory(directory)) {
+ log.debug("Couldn't build directory [" + directory + "] (could be because of denied permissions)");
+ }
}
+ // upload
+ if (log.isTraceEnabled()) {
+ log.trace("About to write [" + fileName + "] to [" + getEndpoint() + "] from exchange [" + exchange + "]");
+ }
+
+ boolean success = getOperations().storeFile(fileName, exchange);
+ if (!success) {
+ throw new GenericFileOperationFailedException("Error writing file [" + fileName + "]");
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("Wrote [" + fileName + "] to [" + getEndpoint() + "]");
+ }
+
+ } finally {
+ ObjectHelper.close(payload, "Closing payload", log);
}
- boolean success = operations.storeFile(fileName, exchange);
- if (!success) {
- throw new GenericFileOperationFailedException("Error writing file: " + fileName);
- }
+
}
protected String createFileName(Exchange exchange) {
@@ -174,20 +204,12 @@
}
}
- @Override
- protected void doStart() throws Exception {
- if (log.isDebugEnabled()) {
- log.debug("Starting");
- }
- super.doStart();
+ /**
+ * @return the operations
+ */
+ public GenericFileOperations<T> getOperations() {
+ return operations;
}
- @Override
- protected void doStop() throws Exception {
- if (log.isDebugEnabled()) {
- log.debug("Stopping");
- }
- super.doStop();
- }
}
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/NewFileBinding.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/NewFileBinding.java?rev=737658&r1=737657&r2=737658&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/NewFileBinding.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/NewFileBinding.java Mon Jan 26 09:28:26 2009
@@ -1,3 +1,19 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.camel.component.file;
import java.io.File;
@@ -17,7 +33,7 @@
return new File(file.getAbsoluteFileName());
}
- public void setBody(GenericFile<File> GenericFile, Object body) {
+ public void setBody(GenericFile<File> file, Object body) {
// noop
}
}
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/NewFileComponent.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/NewFileComponent.java?rev=737658&r1=737657&r2=737658&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/NewFileComponent.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/NewFileComponent.java Mon Jan 26 09:28:26 2009
@@ -42,7 +42,7 @@
result.setConfiguration(config);
- NewFileOperations operations = new NewFileOperations(result);
+ NewFileOperations operations = new NewFileOperations(result, file);
result.setOperations(operations);
return result;
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/NewFileEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/NewFileEndpoint.java?rev=737658&r1=737657&r2=737658&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/NewFileEndpoint.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/NewFileEndpoint.java Mon Jan 26 09:28:26 2009
@@ -21,6 +21,7 @@
import org.apache.camel.Component;
import org.apache.camel.Processor;
import org.apache.camel.processor.idempotent.MemoryIdempotentRepository;
+import org.apache.camel.util.ObjectHelper;
/**
*
@@ -38,6 +39,9 @@
}
public NewFileConsumer createConsumer(Processor processor) throws Exception {
+ ObjectHelper.notNull(operations, "operations");
+ ObjectHelper.notNull(file, "file");
+
NewFileConsumer result = new NewFileConsumer(this, processor, operations);
if (isDelete() && (getMoveNamePrefix() != null || getMoveNamePostfix() != null || getExpression() != null)) {
@@ -61,6 +65,7 @@
}
public GenericFileProducer<File> createProducer() throws Exception {
+ ObjectHelper.notNull(operations, "operations");
return new GenericFileProducer<File>(this, operations);
}
@@ -74,11 +79,6 @@
return new GenericFileExchange(getCamelContext());
}
- protected String getUriProtocol() {
- // TODO: should be "file" when its ready
- return "newfile";
- }
-
public NewFileOperations getOperations() {
return operations;
}
@@ -94,4 +94,10 @@
public void setFile(File file) {
this.file = file;
}
+
+ @Override
+ public String getScheme() {
+ // TODO change to file when this is ready
+ return "newfile";
+ }
}
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/NewFileOperations.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/NewFileOperations.java?rev=737658&r1=737657&r2=737658&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/NewFileOperations.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/NewFileOperations.java Mon Jan 26 09:28:26 2009
@@ -27,7 +27,6 @@
import java.util.Arrays;
import java.util.List;
-import org.apache.camel.Exchange;
import org.apache.camel.InvalidPayloadException;
import org.apache.camel.util.ExchangeHelper;
import org.apache.camel.util.ObjectHelper;
@@ -42,8 +41,12 @@
private static final transient Log LOG = LogFactory.getLog(NewFileOperations.class);
private final NewFileEndpoint endpoint;
- public NewFileOperations(final NewFileEndpoint endpoint) {
+ // this is our filehandle to the filesystem
+ private File currentFile;
+
+ public NewFileOperations(final NewFileEndpoint endpoint, File fileHandle) {
this.endpoint = endpoint;
+ this.currentFile = fileHandle;
}
public boolean deleteFile(String name) throws GenericFileOperationFailedException {
@@ -73,6 +76,15 @@
return new File(path);
}
+
+ public List<File> listFiles() throws GenericFileOperationFailedException {
+ return Arrays.asList(this.currentFile.listFiles());
+ }
+
+ public List<File> listFiles(String path) throws GenericFileOperationFailedException {
+ return Arrays.asList(new File(this.currentFile, path).listFiles());
+ }
+
public List<File> listFiles(File file) throws GenericFileOperationFailedException {
return Arrays.asList(file.listFiles());
}
@@ -81,11 +93,11 @@
return listFiles(new File(path));
}
- public boolean retrieveFile(File file, String name, Exchange exchange) throws GenericFileOperationFailedException {
+ public boolean retrieveFile(String name, GenericFileExchange<File> exchange) throws GenericFileOperationFailedException {
return false;
}
- public boolean storeFile(String name, Exchange exchange) throws GenericFileOperationFailedException {
+ public boolean storeFile(String name, GenericFileExchange<File> exchange) throws GenericFileOperationFailedException {
File file = new File(name);
try {
boolean fileSource = exchange.getIn().getBody() instanceof File;
@@ -165,4 +177,12 @@
return out;
}
+ public void changeCurrentDirectory(String path) throws GenericFileOperationFailedException {
+ this.currentFile = new File(this.currentFile, path).getAbsoluteFile();
+ }
+
+ public String getCurrentDirectory() throws GenericFileOperationFailedException {
+ return currentFile.getAbsolutePath();
+ }
+
}
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/NewFileLockExclusiveReadLockStrategy.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/NewFileLockExclusiveReadLockStrategy.java?rev=737658&r1=737657&r2=737658&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/NewFileLockExclusiveReadLockStrategy.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/NewFileLockExclusiveReadLockStrategy.java Mon Jan 26 09:28:26 2009
@@ -132,4 +132,4 @@
this.timeout = timeout;
}
- }
\ No newline at end of file
+}
\ No newline at end of file
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/NewMarkerFileExclusiveReadLockStrategy.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/NewMarkerFileExclusiveReadLockStrategy.java?rev=737658&r1=737657&r2=737658&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/NewMarkerFileExclusiveReadLockStrategy.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/NewMarkerFileExclusiveReadLockStrategy.java Mon Jan 26 09:28:26 2009
@@ -1,10 +1,26 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.camel.component.file.strategy;
import java.io.File;
+import org.apache.camel.component.file.GenericFile;
import org.apache.camel.component.file.GenericFileExclusiveReadLockStrategy;
import org.apache.camel.component.file.GenericFileOperations;
-import org.apache.camel.component.file.GenericFile;
/**
*
@@ -12,7 +28,7 @@
public class NewMarkerFileExclusiveReadLockStrategy implements GenericFileExclusiveReadLockStrategy<File> {
public boolean acquireExclusiveReadLock(GenericFileOperations<File> fileGenericFileOperations, GenericFile<File> fileGenericFile) {
- // create the .camelFile
+ // TODO create the .camelFile
return false;
}
Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerFailureHandledTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerFailureHandledTest.java?rev=737658&r1=737657&r2=737658&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerFailureHandledTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerFailureHandledTest.java Mon Jan 26 09:28:26 2009
@@ -48,7 +48,7 @@
mock.assertIsSatisfied();
// sleep otherwise the file assertions below could fail
- Thread.sleep(100);
+ Thread.sleep(200);
asserFiles("paris.txt");
}
@@ -64,7 +64,7 @@
mock.assertIsSatisfied();
// sleep otherwise the file assertions below could fail
- Thread.sleep(100);
+ Thread.sleep(200);
asserFiles("london.txt");
}
@@ -80,7 +80,7 @@
mock.assertIsSatisfied();
// sleep otherwise the file assertions below could fail
- Thread.sleep(100);
+ Thread.sleep(200);
asserFiles("madrid.txt");
}