From 002f2e485b750a4f41d0fdbf48f6f48a57e5ac11 Mon Sep 17 00:00:00 2001 From: DedunuKarunarathne <46235093+DedunuKarunarathne@users.noreply.github.com> Date: Fri, 19 Apr 2024 14:43:25 +0530 Subject: [PATCH 1/4] Add isMounted query parameter to the destination file object before moving files in VFS Add isMounted query parameter to the destination file object before moving files in VFS Fixes: https://github.com/wso2/micro-integrator/issues/3308 --- .../apache/synapse/transport/vfs/VFSTransportListener.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/transports/core/vfs/src/main/java/org/apache/synapse/transport/vfs/VFSTransportListener.java b/modules/transports/core/vfs/src/main/java/org/apache/synapse/transport/vfs/VFSTransportListener.java index e73a52ae09..3d618230b8 100644 --- a/modules/transports/core/vfs/src/main/java/org/apache/synapse/transport/vfs/VFSTransportListener.java +++ b/modules/transports/core/vfs/src/main/java/org/apache/synapse/transport/vfs/VFSTransportListener.java @@ -51,6 +51,7 @@ import org.apache.commons.vfs2.FileType; import org.apache.commons.vfs2.impl.DefaultFileSystemManager; import org.apache.commons.vfs2.impl.StandardFileSystemManager; +import org.apache.commons.vfs2.provider.UriParser; import org.apache.synapse.commons.vfs.FileObjectDataSource; import org.apache.synapse.commons.vfs.VFSConstants; import org.apache.synapse.commons.vfs.VFSOutTransportInfo; @@ -138,6 +139,7 @@ public class VFSTransportListener extends AbstractPollingTransportListener queryParam = UriParser.extractQueryParams(moveToDirectoryURI); + dest.setIsMounted(Boolean.parseBoolean(queryParam.get(IS_MOUNTED))); + if (log.isDebugEnabled()) { log.debug("Moving to file :" + VFSUtils.maskURLPassword(dest.getName().getURI())); } From b9f4894588bcd033249dc838898dd0c572c6e134 Mon Sep 17 00:00:00 2001 From: DedunuKarunarathne <46235093+DedunuKarunarathne@users.noreply.github.com> Date: Wed, 24 Apr 2024 09:04:16 +0530 Subject: [PATCH 2/4] Check isMounted for source file location --- .../apache/synapse/commons/vfs/VFSConstants.java | 1 + .../transport/vfs/VFSTransportListener.java | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/modules/commons/src/main/java/org/apache/synapse/commons/vfs/VFSConstants.java b/modules/commons/src/main/java/org/apache/synapse/commons/vfs/VFSConstants.java index 764162f69e..57b947b7ab 100644 --- a/modules/commons/src/main/java/org/apache/synapse/commons/vfs/VFSConstants.java +++ b/modules/commons/src/main/java/org/apache/synapse/commons/vfs/VFSConstants.java @@ -43,6 +43,7 @@ public final class VFSConstants { public static final String TRANSPORT_FILE_CONTENT_TYPE = "transport.vfs.ContentType"; public static final String TRANSPORT_FILE_LOCKING = "transport.vfs.Locking"; public static final String UPDATE_LAST_MODIFIED = "transport.vfs.UpdateLastModified"; + public static final String IS_MOUNTED = "transport.vfs.IsMounted"; public static final String TRANSPORT_FILE_LOCKING_ENABLED = "enable"; public static final String TRANSPORT_FILE_LOCKING_DISABLED = "disable"; diff --git a/modules/transports/core/vfs/src/main/java/org/apache/synapse/transport/vfs/VFSTransportListener.java b/modules/transports/core/vfs/src/main/java/org/apache/synapse/transport/vfs/VFSTransportListener.java index 3d618230b8..c54e39b997 100644 --- a/modules/transports/core/vfs/src/main/java/org/apache/synapse/transport/vfs/VFSTransportListener.java +++ b/modules/transports/core/vfs/src/main/java/org/apache/synapse/transport/vfs/VFSTransportListener.java @@ -139,7 +139,6 @@ public class VFSTransportListener extends AbstractPollingTransportListener queryParams = UriParser.extractQueryParams(fileURI); + fileObject.setIsMounted(Boolean.parseBoolean(queryParams.get(VFSConstants.IS_MOUNTED))); + if (fileObject == null) { log.error("fileObject is null"); throw new FileSystemException("fileObject is null"); @@ -283,6 +286,11 @@ protected void scanFileOrDirectory(final PollTableEntry entry, String fileURI) { FileObject[] children = null; try { children = fileObject.getChildren(); + for (FileObject child : children) { + if (fileObject.getIsMounted()) { + child.setIsMounted(fileObject.getIsMounted()); + } + } } catch (FileNotFolderException ignored) { } catch (FileSystemException ex) { closeFileSystem(fileObject); @@ -729,9 +737,9 @@ protected void moveOrDeleteAfterProcessing(final PollTableEntry entry, FileObjec FileObject dest = moveToDirectory.resolveFile( prefix + fileObject.getName().getBaseName()); - // Get transport.vfs.isMounted query parameter - Map queryParam = UriParser.extractQueryParams(moveToDirectoryURI); - dest.setIsMounted(Boolean.parseBoolean(queryParam.get(IS_MOUNTED))); + // Get if the destination location is volume mounted + Map queryParams = UriParser.extractQueryParams(moveToDirectoryURI); + dest.setIsMounted(Boolean.parseBoolean(queryParams.get(VFSConstants.IS_MOUNTED))); if (log.isDebugEnabled()) { log.debug("Moving to file :" + VFSUtils.maskURLPassword(dest.getName().getURI())); From f549db3a7eb32a92fb29f8fa0af378f3ddc85a14 Mon Sep 17 00:00:00 2001 From: DedunuKarunarathne <46235093+DedunuKarunarathne@users.noreply.github.com> Date: Wed, 24 Apr 2024 09:39:17 +0530 Subject: [PATCH 3/4] Code formatting --- .../apache/synapse/transport/vfs/VFSTransportListener.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/modules/transports/core/vfs/src/main/java/org/apache/synapse/transport/vfs/VFSTransportListener.java b/modules/transports/core/vfs/src/main/java/org/apache/synapse/transport/vfs/VFSTransportListener.java index c54e39b997..5e799166e9 100644 --- a/modules/transports/core/vfs/src/main/java/org/apache/synapse/transport/vfs/VFSTransportListener.java +++ b/modules/transports/core/vfs/src/main/java/org/apache/synapse/transport/vfs/VFSTransportListener.java @@ -287,9 +287,7 @@ protected void scanFileOrDirectory(final PollTableEntry entry, String fileURI) { try { children = fileObject.getChildren(); for (FileObject child : children) { - if (fileObject.getIsMounted()) { - child.setIsMounted(fileObject.getIsMounted()); - } + child.setIsMounted(fileObject.getIsMounted()); } } catch (FileNotFolderException ignored) { } catch (FileSystemException ex) { From 47ec51b7ec02b924648e82947b82936ccfbedf9d Mon Sep 17 00:00:00 2001 From: DedunuKarunarathne <46235093+DedunuKarunarathne@users.noreply.github.com> Date: Wed, 24 Apr 2024 09:57:44 +0530 Subject: [PATCH 4/4] Bump synapse version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2aaaf6dc73..ebbcdd1860 100644 --- a/pom.xml +++ b/pom.xml @@ -1490,7 +1490,7 @@ ${version.tomcat}.wso2v1 1.3 1.5.0.wso2v1 - 2.2.0-wso2v17 + 2.2.0-wso2v18 6.6 3.9.0 ${commons.net.version}.wso2v1