Commit Graph

298 Commits

Author SHA1 Message Date
Gary Russell
ea4763faa9 INT-4095: Support Limiting (S)FTP Files Fetched
JIRA: https://jira.spring.io/browse/INT-4095

Limit the number of remote files fetched on each poll (when it is necessary to fetch files).

Polishing - PR Comments

Polishing - Decouple MaxFetchSize from Poller

Polishing - PR Comments

Schemas and Docs

More Polishing

* Polishing according PR comments
2016-08-26 13:36:14 -04:00
Gary Russell
04a42f54be Rename Schemas to 5.0
Fix Schema Imports

spring.schemas
2016-08-18 14:40:38 -04:00
Artem Bilan
7124136091 Some Fixes and Improvements
* Fix several typos in log messages. And some test on the matter as well
* Add comment to `AbstractPersistentAcceptOnceFileListFilter.rollback()` to clarify the reason of `rollingBack` variable
* Make `RemoteFileTemplate.StreamHolder` as `static` to avoid extra internal variable to outer class instance
* Replace `MessagingException` with `AbstractInboundFileSynchronizingMessageSource` in `init()` method of some components. It isn't Messaging yet in that phase
* Fix `SubscribableRedisChannel.MessageListenerDelegate` to handle `Object` not `String`, because with the `serializer` injection there is no guaranty that incoming is always `String`
* Move `JSch.setLogger(new JschLogger());` in the `DefaultSftpSessionFactory` to `static` block. It really should be done only once
* Remove `Assert.isTrue(this.port >= 0)` from the `DefaultSftpSessionFactory`. The subsequant `initJschSession()` convert it to default `22` port
* Change in the `JschProxyFactoryBean` `UnsupportedOperationException` to `IllegalArgumentException`. Wrong enum is wrong argument. That isn't a problem of operation
* Simplify `stop()` in the `CuratorFrameworkFactoryBean` and mark it as a `this.running = false`. Otherwise it wasn't able to be restarted
* Expose `leaderEventPublisher` in the `LeaderInitiatorFactoryBean`  and fix `stop(Runnable callback)` with propagation `callback` to delegate.

Fix `SubscribableRedisChannelTests` for new `handleMessage(Object)` signature
2016-08-12 12:47:32 -04:00
Gary Russell
d521031a7d INT-4049: FileSplitter: JSON File Markers
JIRA: https://jira.spring.io/browse/INT-4049

INT-4049: Json FileMarker Namespace Support

* Address PR comments
2016-06-08 22:07:55 -04:00
Artem Bilan
c620438913 INT-4046: Add FtpRemoteFileTemplate.ExistsMode
JIRA: https://jira.spring.io/browse/INT-4046

Since not all FTP servers provide proper `STAT` command implementation,
plus the `NLIST` doesn't work properly for directories cases, introduce the `FtpRemoteFileTemplate.ExistsMode`
to let:
* to perform `STAT` by default (previous) behavior;
* to switch to `NLIST` for `FtpRemoteFileTemplate` internal use;
* perform the full `NLIST` and `FTPClient.changeWorkingDirectory()` algorithm if needed.

* Improve (S)Ftp components to use proper `RemoteFileTemplate` for internal instantiation
* Introduce `FtpMessageHandler` to wrap `FtpRemoteFileTemplate` with the proper `NLIST` `ExistsMode`
* Cover `NLIST` switching from the `FtpOutboundChannelAdapterParser` and `FtpOutboundGatewayParser`
* Document the `FtpRemoteFileTemplate.ExistsMode`

* Fix typo in the recently introduced `RemoteFileOperations.getSession()` method name
* Add JavaDoc to `Session.exists()`
* Add `NLIST` support for the `FtpSession.exists()` to meet the API requirements

**Cherry-pick to 4.2.x and 4.1.x**

Addressing PR comments

Doc Polishing
2016-06-08 14:34:35 -04:00
Gary Russell
8e3622757d File Cleanup - Event to JMX 2016-06-04 11:39:43 -04:00
Artem Bilan
6c774638cc INT-4021: SimpleMessageStore: Disable lazy-load
JIRA: https://jira.spring.io/browse/INT-4021

Previously the `SimpleMessageStore` unconditionally followed with the super class options
and provided the `lazy-load` functionality by default.

* Since `persistent` and `lazy-load` logic does not make sense for the `in-memory` store, disable it in the `SimpleMessageStore`
* Fir `AggregatorTests` for better coverage.
* NOTE: The same message can't be persisted in the Persistent `MessageStore`. The store key is fully based on the `messageId`.
And also we provide the header which indicates that the messages has been stored before. See `JdbcMessageStore.addMessage()` for example:
```
if (message.getHeaders().containsKey(SAVED_KEY)) {
      Message<T> saved = (Message<T>) getMessage(message.getHeaders().getId());
      if (saved != null) {
		if (saved.equals(message)) {
			return message;
		} // We need to save it under its own id
	}
}
```
* Fix (S)FTP Streaming tests to use `AbstractPersistentAcceptOnceFileListFilter` instead of raw `AcceptOnceFileListFilter`,
which relies on the object identity, but neither `FtpFile`, nor  `ChannelSftp.LsEntry` provides good `equals()` and `hashCode()` implementations.
* Make `StompIntegrationTests` as `DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD` because the sporadic failure on the Travis around wrong value from the queue isn't clear (yet).
Looks like some interim event is generated by the Websocket Container on the Tomcat.
2016-05-02 15:11:20 -04:00
Gary Russell
87b1af088f Fix Streaming (S)FTP Tests
https://build.spring.io/browse/INT-B43-190/

Add `AcceptOneFileListFilter`s.
2016-04-30 11:04:54 -04:00
Gary Russell
287d924fc0 INT-4015: Streaming Remote File Inbound Adapter
JIRA: https://jira.spring.io/browse/INT-4015
      https://jira.spring.io/browse/INT-3854

Initial commit.

Reworked to emit an input stream and use the file splitter.

Add StreamTransformer.

Add CLOSABLE_RESOURCE header so we can close the session automatically.

Implement INT-3854, FTP, SFTP

(S)FTP Namespace Changes

Docs - also fixes a PDF overflow

Polishing - PR Comments

checkstyle fixes

Polishing - Add Namespace for StreamParser

Polishing - PR Comments
2016-04-29 13:24:23 -04:00
Gary Russell
57f96bb759 checkstyle Misc Rules
checkstyle Nesting

checkstyle GenericWhitespace

checkstyle MethodParamPad

checkstyle NoWhiteSpace

checkstyle ParenPad Script

checkstyle ParenPad
2016-04-05 17:21:29 -04:00
Gary Russell
05cc7be644 checkstyle WhiteAround
WhiteAroundCheck script
2016-04-05 13:50:11 -04:00
Gary Russell
842aded9a4 checkstyle MutableException
checkstyle EmptyBlock

checkstyle fixRightCurly Script

checkstyle EmptyStatement

checkstyle RightCurly

checkstyle TailingWhite

checkstyle NeedBraces

Fix the line separator in the `fixRightCurly.gradle`
2016-04-05 13:10:33 -04:00
Artem Bilan
c677722208 INT-3591: Upgrade to commons-net-3.4
JIRA: https://jira.spring.io/browse/INT-3591

Modify `TestFtpServer` and `FtpServerOutboundTests` for file with leading whitespace
to confirm the `FtpServerFactory` has been fixed in the `commons-net-3.4`
2016-03-28 17:19:03 -04:00
Artem Bilan
2b0598291c RequireThis rule and fixThis Gradle task
* `gradlew clean check -x test --parallel --continue` - to collect reports
* `gradlew fixThis --parallel` - to fix all possible vulnerabilities. With `-Dfile.encoding=UTF-8` on Windows

Since the `RequireThisCheck` doesn't see parents for anonymous classes (e.g. `Runnable` callback), its report doesn't contains the outer class name with `this.`,
therefore we still have to fix those cases manually.
Thanks to the wrong `replacer` just with `this.` we have uncompilable code enough easy to find problems.
Not so easy to fix for good readability though...

* Upgrade to Grade 2.12
* Upgrade to SonarQube native plugin

The fix contains at about 300 files. So, will be done on merge.

Fix `fixThis.gradle` according PR comments

Apply `fixThis` and also `fixModifiers` for test classes.
 Fix some `this.` inner issues manually.
 Make code polishing for long lines after `fixThis`

Fix conflicts and vulnerabilities after the rebase
2016-03-22 20:18:27 -04:00
Artem Bilan
66cd92a6e7 INT-3964: More @EnableIntegration Documentation
JIRA: https://jira.spring.io/browse/INT-3964

Doc Polish

XSD: document classes for element implementations

Fix Redis XSD typo for CDATA
2016-03-22 10:41:07 -04:00
Gary Russell
a2c97ca23b Fix FTP Tests
Incorrect directory and the test didn't verify that files were retrieved.
2016-03-11 16:34:21 -05:00
Artem Bilan
ef40a939cf Add check header rule and fixHeaders task
Add "new line" in the header end

* Optimization for the `fixHeaders.gradle`
* Apply the `fixHeaders` for the affected classes
2016-03-07 15:08:51 -05:00
Gary Russell
5fe827a3dd Checkstyle - Phase I - Unused Imports
I copied the checkstyle config from spring-boot and commented
out most of the rules.

Over time, we should uncomment each rule and fix violations.
2016-03-04 15:50:08 -05:00
Artem Bilan
82c2da8dc4 Move BigMGetTests out of the main
Even it isn't harmful, the one useless class in the `.file.test` package looks confusing.

Move it out to the `test` scope and change the dependant projects respectively.
2016-02-24 16:59:40 -05:00
Artem Bilan
96565cc716 Fix FTP Server test config for file separator 2016-02-16 15:18:27 -05:00
Artem Bilan
7595e4f142 INT-3919: FTP: Allow null for Remote Directory
JIRA: https://jira.spring.io/browse/INT-3919

Since `FtpClient` supports `null` for the `LS` command, treating it as a current `working directory`,
there is no reason to forbid `null` from the FTP adapters end-user perspective.

* Allow `null` for the `FtpSession` `list()` and `listNames()` methods
* Allow `null` in the `remote-directory` for the `<int-ftp:inbound-channel-adapter>`
* Allow `null` in the `expression` for the `FtpOutboundGateway`

Polishing - send error if error on async output

Cover `onFailure()` from `onSuccess()` with the `errorChannel`

Address PR Comments

* Get rid of `null` population for the `remoteDirectoryExpression` in the `AbstractPollingInboundChannelAdapterParser`
* Populate `new LiteralExpression(null)` from the `FtpInboundFileSynchronizer` ctor
* Introduce `buildRemotePath(parent, child)` function in the `AbstractRemoteFileOutboundGateway` with the `null` logic for `parent`
* Rework `mGetWithoutRecursion()` to use `LS` command and allow `null` for the dir.
* Fix tests according the new `mGetWithoutRecursion()` logic

Polishing
2016-02-16 14:45:22 -05:00
Artem Bilan
74cbc58698 INT-3926: Add <poller> for all outbound tags
JIRA: https://jira.spring.io/browse/INT-3926

* Add `<poller>` for all `<outbound-adapter(gateway)>`
* Add/modify tests for `<queue>` as an input channel and particular `<poller>`
* Move XSD from the `xml` package to the `config` level to achieve the consistency throughout the project.
2016-01-07 12:16:40 -05:00
Gary Russell
2f56bb1329 INT-3899: Defer Poller Creation Until start()
JIRA: https://jira.spring.io/browse/INT-3899

Previously, within `AbstractPollingEndpoint`, the `Poller` object was
created from `afterPropertiesSet()` as well as `start()` if previously `stopped()`
(`this.initialized == false`).

This precluded modification of the advice chain (e.g. in tests when using
`autoStartup == false`).

Move the poller creation to `start()` so that it is always created then, and does
not require a previous `stop()` to change the advice chain.
2016-01-05 14:43:28 -05:00
Gary Russell
0fc1f555e7 Test FTP Server - Let OS Choose Port 2015-12-09 11:29:06 -05:00
Gary Russell
051b393ed0 Prepare Master for 4.3
Reference to 4.3

Refactor `what's new` for 4.3
2015-11-17 12:12:49 -05:00
Artem Bilan
e408331e67 INT-3622: (S)FTP: Add MessageSessionCallback
JIRA: https://jira.spring.io/browse/INT-3622

INT-3622: Polishing
2015-08-11 09:33:34 -04:00
Gary Russell
22ee6586a0 INT-3593: Fix FTP PartialSuccess Tests
JIRA: https://jira.spring.io/browse/INT-3593

Sort the files for the MPUT tests.
2015-07-20 13:28:20 -04:00
Gary Russell
9e0b2fb319 INT-3593: (S)FTP OG Partial Updates (mget/mput)
JIRA: https://jira.spring.io/browse/INT-3593

Throw a `PartialSuccessException` if an exception occurs after partial success (some files transferred).
2015-07-20 12:10:33 -04:00
Gary Russell
c68c7b3412 INT-3763: (S)FTP - Inbound Remote Dir. Expression
JIRA: https://jira.spring.io/browse/INT-3763

Fix `AbstractRemoteFileSynchronizerTests` according to this change.
2015-07-09 18:26:46 -04:00
Artem Bilan
3392d4e1ab INT-3749: Get rid of IECA logic
JIRA: https://jira.spring.io/browse/INT-3749

Since `IntegrationEvaluationContextAware` isn't so "context-free" resource like `BeanFactory`
 and `ApplicationContext`, but just a specific bean in the context, we can't follow with `BeanPostProcessor` logic - bad architecture by level of responsibility.
 Therefore we should follow with standard Dependency Injection mechanism to retrieve `evaluationContext` for the particular component.

 Since we can't rely on the `@Autowired` because SI can be used from the raw XML configuration,
 we use utility method instead. The pattern to get the proper `integrationEvaluationContext` is:
 ```
 @Override
 protected void onInit() throws Exception {
 		super.onInit();
 		this.evaluationContext = ExpressionUtils.createStandardEvaluationContext(getBeanFactory());
 }
 ```
2015-06-24 14:57:00 -04:00
Gary Russell
65d2024937 INT-3737: (S)FTP Outbound Gateway Streaming GET
JIRA: https://jira.spring.io/browse/INT-3737

Support returning an `InputStream` from a GET operation.

This can be used in conjuction with a `<file:splitter/>` to stream a text file.

The user is responsible for releasing the session when the download is complete.

The session object is stored in the message header and `RemoteFileUtils.closeSession()` should be called
to clean up and close the session.

INT-3737: Polishing and Docs

Fix `CachedSession.close()` bug

Preventing `Caused by: java.io.IOException: Previous raw read was not finalized`
when `Session` is returned to the pool, but `readingRaw` hasn't been finalized
because the real `close()` isn't invoked in case of normal return to pool.
2015-06-19 13:39:36 -04:00
Gary Russell
505bfac2f8 INT-3735: (S)FTP Fix Schema Expected Type
JIRA: https://jira.spring.io/browse/INT-3735
2015-06-17 16:12:06 -04:00
Gary Russell
123b38a008 INT-3706: Support FileExistModes in (S)FTP Gateway
JIRA: https://jira.spring.io/browse/INT-3706

Previously, the `mode` attribute on the (S)FTP outbound gateways was ignored.

Take account of the mode on (M)GET and (M)PUT commands.
2015-05-12 13:21:26 +03:00
Gary Russell
c2ee93f9e1 INT-3696: Use StringBuilder in FtpFileInfo
JIRA: https://jira.spring.io/browse/INT-3696
2015-05-11 09:45:03 +01:00
Gary Russell
195ee70568 INT-3632: Sonar Improvements
JIRA: https://jira.spring.io/browse/INT-3632

- Use Map.entrySet()
- Double check locking only works when the field(s) are volatile
- Remove unnecessary instanceof tests
2015-02-10 18:00:07 -05:00
Gary Russell
15eb01169d INT-3581: Support selector-expression on WireTap
JIRA: https://jira.spring.io/browse/INT-3581

Move schemas to 4.2.

Add `selector-expression` to `<wire-tap/>`.

INT-3781: Fix What's New

Bump Namespace Version to 4.2
2015-01-13 15:32:06 -05:00
Gary Russell
2581388cc2 INT-3606: Implement Closeable/Flushable
JIRA: https://jira.spring.io/browse/INT-3606

Close the store when an (S)FTP synchronizing MessageSource is stopped.

Will need another commit on 4.2.WIP to change to `Lifecycle`.

Add dirty Flag to Properties MetadataStore

Avoid unnecessary persists.

Remove unnecessary implementation of `AbstractInboundFileSynchronizingMessageSource#getComponentType()`
2015-01-13 15:35:58 +02:00
Gary Russell
91e7d78884 INT-3592: Fix (S)FTP Gateway CTOR Visibility
JIRA: https://jira.spring.io/browse/INT-3592

CTORs were incorrectly `private` which is ok for XML
configuration, but not for DSL/Java Config.
2015-01-05 14:20:45 +02:00
Artem Bilan
41dcd8a453 INT-3573: Fix EEvalSplitter for Iterator
JIRA: https://jira.spring.io/browse/INT-3573

Fix `seen` `Queue` `NPE` for `(S)FtpInboundRemoteFileSystemSynchronizerTests`:
https://build.spring.io/browse/INT-B41-JOB1-164/test/case/155357717

**Cherry-pick to 4.0.x**
2014-12-09 22:48:18 +02:00
Gary Russell
e4f1ee14aa INT-3537 RemoteFileTemplate Close Stream
JIRA: https://jira.spring.io/browse/INT-3537

Stream not closed if session cannot be created.

Add `try {} finally {}`.

__cherry-pick to 4.0.x, 3.0.x__
2014-10-22 12:26:08 +03:00
Gary Russell
403c91801d INT-3412 (S)FTP Append, rmdir, Client Access
JIRA: https://jira.spring.io/browse/INT-3412

Initial commit - review only.

TODO:
- SFTP Tests
- Namespace/Adapter support for file append
- Docs

INT-3412 Polishing

- Addressed PR comments
- Completed SFTP implementation
- Added namespace/parser support for `FileExistsMode` (append, etc)
- Added SFTP Tests
- Created Embedded SFTP server for tests (similar to FTP)
- Converted tests that needed a real server to use the embedded server

INT-3412 Docs and Polish (PR Comments)
2014-08-04 15:08:34 +03:00
Gary Russell
eff1c7b7d8 INT-3464 Fix Test Filenames 2014-07-24 10:55:35 -04:00
Gary Russell
a20fa9a029 INT-3464 Exceptions and AcceptOnceFileListFilter
JIRA: https://jira.spring.io/browse/INT-3464

Previously, if an IO exeption occurred while synchronizing
files, and an AcceptOnceFileListFilter is being used, files that were
not transferred would not be fetched next time.

Add strategy `ReversibleFileListFilter` that can rollback previously
accepted files.

Implement this interface on `AcceptOnceFileListFilter` and
`AbstractPersistentAcceptOnceFileListFilter`.

Add test cases.

Polishing
2014-07-24 16:56:38 +03:00
Artem Bilan
be362f90c6 INT-3462: Polishing (s)ftp XSD
JIRA: https://jira.spring.io/browse/INT-3462
2014-07-07 15:11:09 -04:00
Artem Bilan
f5145f531b INT-3418: Final Phase: Cleanup
INT-3418: use versioned XSDs for XSD import
2014-06-09 10:08:30 -04:00
Artem Bilan
77b31f58fd INT-3418: xsd-4.0 -> 4.1 2014-06-05 13:34:52 +03:00
Artem Bilan
c0ab912c49 INT-3418: xsd-3.0 -> 4.0 2014-06-05 13:34:41 +03:00
Artem Bilan
9e5e7514e0 INT-3418: xsd-2.2 -> 3.0 2014-06-05 13:34:30 +03:00
Artem Bilan
9bd441c8d0 INT-3418: xsd-2.1 -> 2.2 2014-06-05 13:34:19 +03:00
Artem Bilan
af1cd16027 INT-3418: xsd-2.0 -> 2.1 2014-06-05 13:33:57 +03:00