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

can't chmod using ftp outbound Adapter #3026

Closed
joaquinjsb opened this issue Aug 13, 2019 · 8 comments · Fixed by #3030
Closed

can't chmod using ftp outbound Adapter #3026

joaquinjsb opened this issue Aug 13, 2019 · 8 comments · Fixed by #3030

Comments

@joaquinjsb
Copy link
Contributor

joaquinjsb commented Aug 13, 2019

Affects Version(s): 5.2.0.M4


Question

Hello guys, I'm having problems to use chmod with an outbound adapter, how can this be solved?

I gave a look around the code class FileTransferringMessageHandler, seems to be hardcoded
image

my dsl

  return flow -> flow
            .handle(Ftp.outboundGateway(FTPServers.PC_LOCAL.getFactory(), AbstractRemoteFileOutboundGateway.Command.MGET, "payload")
                .fileExistsMode(FileExistsMode.REPLACE)
                .filterFunction(ftpFile -> ftpFile.getName().contains("SCN") || ftpFile.getName().contains("REP") || ftpFile.getName().contains("EL"))
                .localDirectory(new File("/localTmp")))
            .log(Message::getPayload)
            .transform(GenericMessage.class, GenericMessage::getPayload)
            .split()
            .handle(Ftp.outboundAdapter(FTPServers.PC_LOCAL.getFactory(), FileExistsMode.IGNORE)
                .useTemporaryFileName(false)
                .chmod(666)
                .fileNameExpression("headers['" + FileHeaders.REMOTE_FILE + "']")
                .remoteDirectory("/dati/recpv"), e -> e.advice(afterFlow()));
    }
@garyrussell
Copy link
Contributor

garyrussell commented Aug 13, 2019

The FTP protocol does not support changing the file permissions, only SFTP.

The method is overridden in the SFTP message handler.

@Override
public boolean isChmodCapable() {
	return true;
}

@garyrussell garyrussell added the status: waiting-for-reporter Needs a feedback from the reporter label Aug 13, 2019
@joaquinjsb
Copy link
Contributor Author

joaquinjsb commented Aug 13, 2019

Hello,
I'm using FTP protocol, I'm pretty sure that you can chmod using FTP (at least, as far as I know, you can do it with Filezilla), I tried too with ftp command line client on ubuntu and seems to be possible, I think it should be an enhancement?

@garyrussell
Copy link
Contributor

I should have googled it when I implemented it for SFTP; there is no direct support in the Apache FTPClient - but it appears it can be done with a site command:

https://stackoverflow.com/questions/12741938/how-can-i-change-permissions-of-a-file-on-a-ftp-server-using-apache-commons-net

@garyrussell garyrussell added in: sftp type: enhancement and removed status: waiting-for-reporter Needs a feedback from the reporter labels Aug 13, 2019
@garyrussell garyrussell added this to the 5.2.RC1 milestone Aug 13, 2019
@garyrussell
Copy link
Contributor

So yes; we will add it; in the meantime you can use an FtpRemoteFileTempalte to use that command from the session callback.

@joaquinjsb
Copy link
Contributor Author

Thank you!

garyrussell added a commit to garyrussell/spring-integration that referenced this issue Aug 13, 2019
garyrussell added a commit to garyrussell/spring-integration that referenced this issue Aug 13, 2019
garyrussell added a commit to garyrussell/spring-integration that referenced this issue Aug 13, 2019
garyrussell added a commit to garyrussell/spring-integration that referenced this issue Aug 15, 2019
artembilan pushed a commit that referenced this issue Aug 15, 2019
Resolves #3026

* Fix exception messages; remove test TODOs; test works on Windows
artembilan pushed a commit that referenced this issue Aug 15, 2019
Resolves #3026

* Fix exception messages; remove test TODOs; test works on Windows

# Conflicts:
#	spring-integration-ftp/src/test/java/org/springframework/integration/ftp/outbound/FtpServerOutboundTests.java
#	src/reference/asciidoc/whats-new.adoc
@joaquinjsb
Copy link
Contributor Author

Hi guys,
I didn't made it in time to test the library, there's a bug that should be solved for it to work properly.

on the FtpMessageHandlerSpec, the target is still a FileTransferringMessageHandler, you have to use the children class you created FtpMessageHandler so that it can see the override, on my end it isn't working because isChmodCapable still returns false.

image

image

@garyrussell
Copy link
Contributor

Please open a new issue - that was a pre-existing bug - clearly it wouldn't work for SFTP either.

@joaquinjsb
Copy link
Contributor Author

thank you, working on it!

joaquinjsb added a commit to joaquinjsb/spring-integration that referenced this issue Oct 15, 2019
joaquinjsb added a commit to joaquinjsb/spring-integration that referenced this issue Oct 15, 2019
joaquinjsb added a commit to joaquinjsb/spring-integration that referenced this issue Oct 16, 2019
should fix the compilation with Gradle and pass tests
joaquinjsb added a commit to joaquinjsb/spring-integration that referenced this issue Oct 16, 2019
Added FileTransferringMessageHandlerSpec ctor todo
joaquinjsb added a commit to joaquinjsb/spring-integration that referenced this issue Oct 16, 2019
joaquinjsb added a commit to joaquinjsb/spring-integration that referenced this issue Oct 16, 2019
joaquinjsb added a commit to joaquinjsb/spring-integration that referenced this issue Oct 16, 2019
joaquinjsb added a commit to joaquinjsb/spring-integration that referenced this issue Oct 16, 2019
doesn't seems to solve the problem
joaquinjsb added a commit to joaquinjsb/spring-integration that referenced this issue Oct 16, 2019
removed not standard ctors
joaquinjsb added a commit to joaquinjsb/spring-integration that referenced this issue Oct 16, 2019
joaquinjsb pushed a commit to joaquinjsb/spring-integration that referenced this issue Oct 22, 2019
joaquinjsb pushed a commit to joaquinjsb/spring-integration that referenced this issue Oct 29, 2019
removed test that check file permissions for FTP
joaquinjsb pushed a commit to joaquinjsb/spring-integration that referenced this issue Oct 29, 2019
artembilan pushed a commit that referenced this issue Oct 29, 2019
Fixes #3026

**Cherry-pick to `5.1.x`**

* Populate proper `FileTransferringMessageHandler` impl from DSL spec
implementations.
This way we are able to use a provided `chmod` from Java DSL
* Added `FileTransferringMessageHandlerSpec` ctor TODO
* Update SftpTests
* Code cleanup; `@Ignore` `SftpTests.testSftpOutboundFlowWithChmod()`
since it doesn't work properly on Windows
artembilan pushed a commit that referenced this issue Oct 29, 2019
Fixes #3026

**Cherry-pick to `5.1.x`**

* Populate proper `FileTransferringMessageHandler` impl from DSL spec
implementations.
This way we are able to use a provided `chmod` from Java DSL
* Added `FileTransferringMessageHandlerSpec` ctor TODO
* Update SftpTests
* Code cleanup; `@Ignore` `SftpTests.testSftpOutboundFlowWithChmod()`
since it doesn't work properly on Windows

# Conflicts:
#	spring-integration-sftp/src/test/java/org/springframework/integration/sftp/dsl/SftpTests.java
#	spring-integration-sftp/src/test/java/org/springframework/integration/sftp/inbound/SftpInboundRemoteFileSystemSynchronizerTests.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants