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 2011/09/23 16:15:34 UTC
svn commit: r1174793 - in /camel/branches/camel-2.8.x: ./
components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/
components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/
Author: davsclaus
Date: Fri Sep 23 14:15:33 2011
New Revision: 1174793
URL: http://svn.apache.org/viewvc?rev=1174793&view=rev
Log:
Merged revisions 1174626 via svnmerge from
https://svn.apache.org/repos/asf/camel/trunk
........
r1174626 | davsclaus | 2011-09-23 11:53:05 +0200 (Fri, 23 Sep 2011) | 1 line
CAMEL-4182: Port the minDepth and maxDepth options from file component to ftp component
........
Added:
camel/branches/camel-2.8.x/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpRecursiveDepth2Test.java
- copied unchanged from r1174626, camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpRecursiveDepth2Test.java
camel/branches/camel-2.8.x/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpRecursiveDepth3Test.java
- copied unchanged from r1174626, camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpRecursiveDepth3Test.java
camel/branches/camel-2.8.x/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpRecursiveDepthTest.java
- copied unchanged from r1174626, camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpRecursiveDepthTest.java
Modified:
camel/branches/camel-2.8.x/ (props changed)
camel/branches/camel-2.8.x/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpConsumer.java
camel/branches/camel-2.8.x/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpConsumer.java
Propchange: camel/branches/camel-2.8.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Sep 23 14:15:33 2011
@@ -1 +1 @@
-/camel/trunk:1173732,1173958,1174047,1174129,1174245,1174565,1174745
+/camel/trunk:1173732,1173958,1174047,1174129,1174245,1174565,1174626,1174745
Propchange: camel/branches/camel-2.8.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified: camel/branches/camel-2.8.x/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpConsumer.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpConsumer.java?rev=1174793&r1=1174792&r2=1174793&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpConsumer.java (original)
+++ camel/branches/camel-2.8.x/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpConsumer.java Fri Sep 23 14:15:33 2011
@@ -48,7 +48,7 @@ public class FtpConsumer extends RemoteF
// strip trailing slash
fileName = FileUtil.stripTrailingSeparator(fileName);
- boolean answer = doPollDirectory(fileName, null, fileList);
+ boolean answer = doPollDirectory(fileName, null, fileList, depth);
if (currentDir != null) {
operations.changeCurrentDirectory(currentDir);
}
@@ -56,8 +56,8 @@ public class FtpConsumer extends RemoteF
return answer;
}
- protected boolean pollSubDirectory(String absolutePath, String dirName, List<GenericFile<FTPFile>> fileList) {
- boolean answer = doPollDirectory(absolutePath, dirName, fileList);
+ protected boolean pollSubDirectory(String absolutePath, String dirName, List<GenericFile<FTPFile>> fileList, int depth) {
+ boolean answer = doPollDirectory(absolutePath, dirName, fileList, depth);
// change back to parent directory when finished polling sub directory
if (isStepwise()) {
operations.changeToParentDirectory();
@@ -65,8 +65,11 @@ public class FtpConsumer extends RemoteF
return answer;
}
- protected boolean doPollDirectory(String absolutePath, String dirName, List<GenericFile<FTPFile>> fileList) {
+ protected boolean doPollDirectory(String absolutePath, String dirName, List<GenericFile<FTPFile>> fileList, int depth) {
log.trace("doPollDirectory from absolutePath: {}, dirName: {}", absolutePath, dirName);
+
+ depth++;
+
// remove trailing /
dirName = FileUtil.stripTrailingSeparator(dirName);
@@ -105,18 +108,18 @@ public class FtpConsumer extends RemoteF
if (file.isDirectory()) {
RemoteFile<FTPFile> remote = asRemoteFile(absolutePath, file);
- if (endpoint.isRecursive() && isValidFile(remote, true)) {
+ if (endpoint.isRecursive() && isValidFile(remote, true) && depth < endpoint.getMaxDepth()) {
// recursive scan and add the sub files and folders
String subDirectory = file.getName();
String path = absolutePath + "/" + subDirectory;
- boolean canPollMore = pollSubDirectory(path, subDirectory, fileList);
+ boolean canPollMore = pollSubDirectory(path, subDirectory, fileList, depth);
if (!canPollMore) {
return false;
}
}
} else if (file.isFile()) {
RemoteFile<FTPFile> remote = asRemoteFile(absolutePath, file);
- if (isValidFile(remote, false)) {
+ if (isValidFile(remote, false) && depth >= endpoint.getMinDepth()) {
if (isInProgress(remote)) {
log.trace("Skipping as file is already in progress: {}", remote.getFileName());
} else {
Modified: camel/branches/camel-2.8.x/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpConsumer.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpConsumer.java?rev=1174793&r1=1174792&r2=1174793&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpConsumer.java (original)
+++ camel/branches/camel-2.8.x/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpConsumer.java Fri Sep 23 14:15:33 2011
@@ -47,7 +47,7 @@ public class SftpConsumer extends Remote
// strip trailing slash
fileName = FileUtil.stripTrailingSeparator(fileName);
- boolean answer = doPollDirectory(fileName, null, fileList);
+ boolean answer = doPollDirectory(fileName, null, fileList, depth);
if (currentDir != null) {
operations.changeCurrentDirectory(currentDir);
}
@@ -55,8 +55,8 @@ public class SftpConsumer extends Remote
return answer;
}
- protected boolean pollSubDirectory(String absolutePath, String dirName, List<GenericFile<ChannelSftp.LsEntry>> fileList) {
- boolean answer = doPollDirectory(absolutePath, dirName, fileList);
+ protected boolean pollSubDirectory(String absolutePath, String dirName, List<GenericFile<ChannelSftp.LsEntry>> fileList, int depth) {
+ boolean answer = doPollDirectory(absolutePath, dirName, fileList, depth);
// change back to parent directory when finished polling sub directory
if (isStepwise()) {
operations.changeToParentDirectory();
@@ -64,9 +64,11 @@ public class SftpConsumer extends Remote
return answer;
}
- protected boolean doPollDirectory(String absolutePath, String dirName, List<GenericFile<ChannelSftp.LsEntry>> fileList) {
+ protected boolean doPollDirectory(String absolutePath, String dirName, List<GenericFile<ChannelSftp.LsEntry>> fileList, int depth) {
log.trace("doPollDirectory from absolutePath: {}, dirName: {}", absolutePath, dirName);
+ depth++;
+
// remove trailing /
dirName = FileUtil.stripTrailingSeparator(dirName);
// compute dir depending on stepwise is enabled or not
@@ -103,11 +105,11 @@ public class SftpConsumer extends Remote
if (file.getAttrs().isDir()) {
RemoteFile<ChannelSftp.LsEntry> remote = asRemoteFile(absolutePath, file);
- if (endpoint.isRecursive() && isValidFile(remote, true)) {
+ if (endpoint.isRecursive() && isValidFile(remote, true) && depth < endpoint.getMaxDepth()) {
// recursive scan and add the sub files and folders
String subDirectory = file.getFilename();
String path = absolutePath + "/" + subDirectory;
- boolean canPollMore = pollSubDirectory(path, subDirectory, fileList);
+ boolean canPollMore = pollSubDirectory(path, subDirectory, fileList, depth);
if (!canPollMore) {
return false;
}
@@ -116,7 +118,7 @@ public class SftpConsumer extends Remote
// just assuming its a file we should poll
} else {
RemoteFile<ChannelSftp.LsEntry> remote = asRemoteFile(absolutePath, file);
- if (isValidFile(remote, false)) {
+ if (isValidFile(remote, false) && depth >= endpoint.getMinDepth()) {
if (isInProgress(remote)) {
if (log.isTraceEnabled()) {
log.trace("Skipping as file is already in progress: {}", remote.getFileName());