Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add isMounted query parameter to the destination file object before moving files in VFS #2174

Merged
merged 4 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -235,6 +236,10 @@ protected void scanFileOrDirectory(final PollTableEntry entry, String fileURI) {
retryCount++;
fileObject = getFsManager().resolveFile(fileURI, fso);

// Get if the file location is volume mounted
Map<String,String> 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");
Expand Down Expand Up @@ -281,6 +286,9 @@ protected void scanFileOrDirectory(final PollTableEntry entry, String fileURI) {
FileObject[] children = null;
try {
children = fileObject.getChildren();
for (FileObject child : children) {
child.setIsMounted(fileObject.getIsMounted());
}
} catch (FileNotFolderException ignored) {
} catch (FileSystemException ex) {
closeFileSystem(fileObject);
Expand Down Expand Up @@ -726,6 +734,11 @@ protected void moveOrDeleteAfterProcessing(final PollTableEntry entry, FileObjec
}
FileObject dest = moveToDirectory.resolveFile(
prefix + fileObject.getName().getBaseName());

// Get if the destination location is volume mounted
Map<String,String> 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()));
}
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1490,7 +1490,7 @@
<orbit.version.tomcat>${version.tomcat}.wso2v1</orbit.version.tomcat>
<commons.pool.version>1.3</commons.pool.version>
<commons.pool.wso2.version>1.5.0.wso2v1</commons.pool.wso2.version>
<commons.vfs.version>2.2.0-wso2v17</commons.vfs.version>
<commons.vfs.version>2.2.0-wso2v18</commons.vfs.version>
<truezip.version>6.6</truezip.version>
<commons.net.version>3.9.0</commons.net.version>
<commons.net.wso2.version>${commons.net.version}.wso2v1</commons.net.wso2.version>
Expand Down
Loading