Commit Graph

28 Commits

Author SHA1 Message Date
Artem Bilan
64b49d1fac Remove applySystemFileSeparator() from SmbTestSupport
Related to: https://github.com/spring-projects/spring-integration/issues/9453

The `SmbSession` does not rely on a system file separator anymore
and just use regular Unix `/` separator all the time.
Therefore, `TestUtils.applySystemFileSeparator()` is wrong from test perspective on Windows

**Auto-cherry-pick to `6.3.x` & `6.2.x`**
2024-09-17 12:20:41 -04:00
pfosser
4cccee7c3a GH-9453: Correct separator when checking smb path
Fixes: #9453
Issue link: https://github.com/spring-projects/spring-integration/issues/9453

On a smb file upload, to detect the need for new remote directories,
the remote path was checked for the local filesystem path separator.
On Windows that is \\ which is never found in a smb path, so the
necessary remote path was not created and the operation failed.

Use the correct separator which was already available as a constant.

**Auto-cherry-pick to `6.3.x` & `6.2.x`**
2024-09-13 15:41:25 -04:00
Artem Bilan
c27cc4b11c GH-9427: Improve nullability for remote path expression (#9434)
Fixes: #9427

Issue link: https://github.com/spring-projects/spring-integration/issues/9427

The `expression` of the `AbstractRemoteFileOutboundGateway` could be `null` and
ignored for some expressions making a DSL factories inconsistent

* Improve `AbstractRemoteFileOutboundGateway` constructor JavaDocs explaining
`expression` argument in more details
* Add `@Nullable` for this `expression` arg in all the `AbstractRemoteFileOutboundGateway` implementations
* Add new DSL factory method for `outboundGateway()` without this `expression` for those commands when it is not needed
2024-08-30 11:52:44 -04:00
Artem Bilan
f2399a4e13 GH-9268: Fix regression in SMB Inbound for sub-dirs
Fixes: #9268

The new `SmbSession.list()` behavior prevents to pull files from sub-folders in inbound channel adapter

* Fix `SmbSession.list()` similar way to `SftpSession`: if `remoteFile.isFile()` then remove it as is.
Otherwise, perform `smbDir.listFiles()` on that sub-dir
* Modify `SmbTests.testSmbInboundFlow()` to poll files from the `smbSource/subSmbSource/`

**Auto-cherry-pick to `6.3.x` & `6.2.x`**
2024-06-24 14:52:13 -04:00
Artem Bilan
91de12c786 GH-9211: Fix SmbSession.get()
Fixes: #9211

The `AbstractRemoteFileOutboundGateway.get()` uses `Session.list()` for the provided remote file name.
The `SmbSession` does not support listing for a single file.

* Add logic into `SmbSession.list()` similar to `SftpSession.list()` to list a single remote file
on the provided path

**Auto-cherry-pick to `6.3.x` & `6.2.x`**
2024-06-05 11:03:32 -04:00
Artem Bilan
c155d5d418 Add EmptyLineSeparator Checkstyle rule
* Support "blank lines around" via `spring-framework.xml` IDEA config
* Fix all the Checkstyle violations
2024-03-27 16:54:25 -04:00
Artem Bilan
c7e3a7c24a GH-8800: Fix SMB Gateway for recursive MGET
Fixes: gh-8800

The `SmbFile.getName()` returns plain file name, not with a
sub-directory as it is expected by the `AbstractRemoteFileOutboundGateway`
for (S)FTP protocols

* Introduce `AbstractRemoteFileOutboundGateway.getFullFileName()`
with dir and file name concatenation by default (as it was before)
and override it in the `SmbOutboundGateway` to return the full path according this protocol.
* Fix `SmbOutboundGateway.enhanceNameWithSubDirectory()` to return an `SmbFile` instance
since it has all the info about remote file, include requested directory
* Fix `SmbOutboundGateway.getFilename()` to remove the trailing `/` in the dir name
since this is not what expected by the `AbstractRemoteFileOutboundGateway` logic

**Cherry-pick to `6.1.x`**
2023-12-06 17:29:28 +01:00
Artem Bilan
44433ed8a1 GH-8745: Add RFT.shouldMarkSessionAsDirty() (#8759)
* GH-8745: Add RFT.shouldMarkSessionAsDirty()

Fixes https://github.com/spring-projects/spring-integration/issues/8745

Not all errors caught in the `RemoteFileTemplate.execute()`
are fatal to mark session as dirty and physically close the target session
in the cache

* Introduce a `RemoteFileTemplate.shouldMarkSessionAsDirty()`
to consult with an exception if it is really a fatal error to close
the session in the end.
* Override `shouldMarkSessionAsDirty()` in the `RemoteFileTemplate`
implementations to check statuses of respective protocol errors

**Cherry-pick to `6.1.x` & `6.0.x`**

* * Fix tests for pool interaction

* * Fix language in Javadocs
* Add more `not dirty` statuses to `SftpRemoteFileTemplate` & `SmbRemoteFileTemplate`
2023-10-11 10:52:48 -04:00
Adama Sorho
73ed3eeebd GH-8691: Add (S)FTP, SMB aged file filters
Fixes https://github.com/spring-projects/spring-integration/issues/8691

* Remove setAge with TimeUnit
Turned out we don't need anymore since we're using Duration for age in FtpLastModifiedFileListFilter and SftpLastModifiedFileListFilter.
* Add changes to the docs
* Introduce AbstractLastModifiedFileListFilter
* Some code readability improvements
* Make language in the docs more official
2023-09-14 12:16:06 -04:00
Christian Tzolov
c38ed96ee9 GH-8643: Replace synchronized with Lock
Fixes https://github.com/spring-projects/spring-integration/issues/8643

* First pass - trivial synchronized blocks
  - Convert the "trivial" `synchronized` block into `ReentrantLock`.

* fix checkstyle

* use blocking lock

* Secon pass - handle multi-lock cases

* javadoc + year

* addres first batch of review suggestions

* fix checkstyle issues

* fix the mqtt parent/child lock monitor sharing

* fix the mqtt parent/child lock monitor sharing, v2

* patch the stomp test
2023-06-21 13:25:45 -04:00
abilan
934e90a110 Revert json-path & Mockito versions
* Remove `mockito-inline` dependency
* Fix deprecations from Spring Security
* Fix `SmbSessionFactoryWithCIFSContextTests` for compatibility with latest `JCIFS`
* Migrate all the SMB tests to Junit Jupiter
2023-04-19 12:11:02 -04:00
abilan
d5181bf0d7 Add Nullability support into Java DSL 2023-04-14 14:16:36 -04:00
Artem Bilan
1bec420fd1 Do not block by default (#8580)
Currently, many timeouts in the project are like `-1` or other negative value
with a meaning to wait indefinitely.

According to distributed systems design and bad demo developing experience
it is not OK to block forever.

* Rework most of the timeouts in the framework to be `30` seconds.
Only one remained as `1` seconds is a `PollingConsumer` where it is
better to not block even for those 30 seconds when no messages in the queue,
but let the polling task be rescheduled.
* Remove the `MessagingGatewaySupport.replyTimeout` propagation down to the
`PollingConsumer` correlator where it was a `-1` before and blocked
the polling thread on the `Queue.poll()`.
This fixed the problem with a single thread in a pool for auto-configured `TaskScheduler`.
Now with 1 seconds wait time we are able to switch to other scheduled tasks
even with only 1 thread in the pool
2023-03-21 17:43:00 -04:00
Artem Bilan
ce9f7f4321 GH-8562: Fix streaming source for remote calls (#8564)
* GH-8562: Fix streaming source for remote calls

Fixes https://github.com/spring-projects/spring-integration/issues/8562

The `AbstractRemoteFileStreamingMessageSource.doReceive()` takes files first from a `toBeReceived` queue.
When `AbstractRemoteFileStreamingMessageSource.remoteFileToMessage()` fails to fetch the file content
because of interim connection issue, we reset this file from a filter and rethrow an exception.
The next `receive()` call will just go ahead to the next entry in the `toBeReceived` queue, but the
file we have just failed for will be retried only on the next list call to the remove directory.
This essentially breaks a possible in-order target application logic.

* Introduce `AbstractRemoteFileStreamingMessageSource.strictOrder` option to clear the `toBeReceived` queue
 when we fail in the `remoteFileToMessage()`, so the next `receive()`
 call would re-fetch files from remote dir, because the filter has been reset for those files.
* Fix `AbstractFileInfo.toString()` to not perform remote calls when we just log this file.
For example, we reset the file for connection failure and log the message about it,
but it fails again because we request `size` of the file which may require a remote connection.

**Cherry-pick to `6.0.x` & `5.5.x`**

* * Revert `AbstractFileInfo` changes
* Override `toString()` in `SmbFileInfo` instead -
exactly the place where connection is used to obtain
file attributes like `size` or `lastModified`
2023-02-28 16:34:19 -05:00
abilan
52d43ea8ed Upgrade dependencies; prepare for release
Fix XML configs for new `Mockito.mock()` factory method
2022-12-20 16:25:06 -05:00
abilan
7864658d01 GH-3686: Apply SF editor config
Fixes https://github.com/spring-projects/spring-integration/issues/3686

* Add `src/idea` with respective editor config for IntelliJ IDEA.
Must be imported into an IDE
* Add `src/eclipse` with respective editor config for Eclipse/STS
* Reformat imports in source code according a new editor config
2022-11-14 10:55:21 -05:00
Artem Bilan
60f453e9ff Upgrade to Jakarta EE 10
* Fix mail module to fit to the latest mail API requirements
* Fix the last Sonar smell in the `SmbShare`
* Remove redundant dependency for `hamcrest-core` in various modules
2022-11-07 17:05:22 -05:00
Artem Bilan
e03a20981a Fix the latest Sonar smells in the SMB module 2022-11-07 12:05:01 -05:00
Artem Bilan
18fcd21137 Fix latest Sonar fixes
* Some code style improvement for SMB classes
* Make an `SmbSessionTests` based on the `SmbTestSupport` for faster execution, but not blocking on fake URL connection attempt
* Remove `AbstractMqttMessageDrivenChannelAdapter.Topic` model in favor of `LinkedHashMap` handling
2022-11-04 16:19:03 -04:00
Artem Vozhdayenko
f349e1a114 GH-3804: Migrate SMB unit tests to Testcontainers
Fixes https://github.com/spring-projects/spring-integration/issues/3804

Instead of manual SMB server setup and preparation, make it all
automated using convenient Testcontainers library and a bit of extra
code executed before tests.

* Change `localhost` to `127.0.0.1` for a proper integration with docker container
* A few new config values to support container environment, like tmpFs,
share permissions and a dynamic port value
* Introduce Testcontainers API for container management
* Few configuration changes to support docker container usage
* Automatic dirs and files layout creation in `@BeforeAll`
* A few bugfixes where the assertion has not been done actually
* Couple of small changes related to assertions readability as well
* Use `warn` as default logging level for the SMB tests
* Refactor an `SmbTests` a bit: moving its `createFilesInSmbShare()` to
the `SmbTestSupport` since that files tree can be useful for any other
similar integration tests in the future
* Use `TestUtils.applySystemFileSeparator()` for cross-platform file paths
2022-07-12 14:27:49 -04:00
Artem Vozhdayenko
53dd050c5b GH-3623: Deprecarte an IntegrationFlows
Fixes https://github.com/spring-projects/spring-integration/issues/3623

* `IntegrationFlow` refactoring
* Apply several code style improvements and good practices
* Code style: no empty lines for methods javadocs
* make deprecated implementation reuse actual one instead of the copy-paste approach
* add whats-new comments
* Fix whats-new page according to standards
2022-07-05 15:47:30 -04:00
Gregory Bragg
7174e8840b Add XSD for new SMB components
* Add namespace handler support for new XSD configs
* Add JUnit tests for outbound gateway XML config
* Add JUnit tests for streaming inbound adapter XML config
* Add Javadoc to new parser classes as per PR feedback
* Some code clean up
2022-05-31 13:32:44 -04:00
Gregory Bragg
0cf1dfee7e Some improvements for SMB module
* Improve permission information returned in `SmbFileInfo`
* Improve documentation for `SmbFileInfo.getPermissions()`
* Add Junit tests to verify all outbound gateway functionality
* Clean test directory of mistakenly migrated SMB extension code
2022-05-26 12:55:37 -04:00
Gregory Bragg
4203a2369f SmbOutboundGateway: Other remote file operations
* Enhanced SmbOutboundGateway with supported remote file operations
* Updated SmbOutboundGateway code based on PR review feedback
* Fully implemented listNames() in SmbSession, added more JUnit tests
* Updated SmbSession code based on PR review comments
2022-05-20 16:37:39 -04:00
Gregory Bragg
ac6af716e1 Add Java DSL for SMB module
* Added supporting classes for DSL, fixed checkstyle build errors
* Added JUnit tests for DSL package
* Updated Java Doc with instructions to setup an external SMB share
* Updated AsciiDoc to include instructions on Java DSL configurations
* Updated implementation based on PR review feedback
* Clean up the code
* Add more info to `whats-new.adoc` for these SMB changes
2022-05-18 15:37:08 -04:00
Artem Bilan
db287cf98f Remove unused import in the SmbMessageHandler 2022-05-10 10:55:27 -04:00
Gregory Bragg
b64e37973e Add documentation for SMB Support
* Updated, polished documentation prior to PR review
* Updated after PR review comments, changed Adapter verbiage to Support
* Add `SmbMessageHandler(SmbRemoteFileTemplate)` ctors
* Clean up `smb.adoc` for extra redundant interim headlines
2022-05-10 10:48:23 -04:00
Gregory Bragg
7ad71d38d9 Migrate SMB extension project to respective module
* Removed deprecated replaceFile and useTempFile session configs
* Refactored to use AssertJ instead of JUnit asserts as per PR feedback
* Code clean up for SMB module
2022-05-06 16:20:43 -04:00