Skip to content

Commit 7ad71d3

Browse files
GregBraggartembilan
authored andcommitted
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
1 parent 392455e commit 7ad71d3

File tree

46 files changed

+3785
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+3785
-0
lines changed

build.gradle

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ ext {
7070
h2Version = '2.1.210'
7171
jacksonVersion = '2.13.2'
7272
jaxbVersion = '3.0.2'
73+
jcifsVersion = '2.1.29'
7374
jeroMqVersion = '0.5.2'
7475
jmsApiVersion = '3.0.0'
7576
jpaApiVersion = '3.0.2'
@@ -874,6 +875,16 @@ project('spring-integration-sftp') {
874875
}
875876
}
876877

878+
project('spring-integration-smb') {
879+
description = 'Spring Integration SMB Support'
880+
dependencies {
881+
api project(':spring-integration-file')
882+
api "org.codelibs:jcifs:$jcifsVersion"
883+
884+
testImplementation project(':spring-integration-file').sourceSets.test.output
885+
}
886+
}
887+
877888
project('spring-integration-stomp') {
878889
description = 'Spring Integration STOMP Support'
879890
dependencies {
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* Copyright 2012-2022 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.integration.smb.config;
18+
19+
import org.springframework.integration.file.config.AbstractRemoteFileInboundChannelAdapterParser;
20+
import org.springframework.integration.file.filters.AbstractPersistentAcceptOnceFileListFilter;
21+
import org.springframework.integration.file.filters.FileListFilter;
22+
import org.springframework.integration.file.remote.synchronizer.InboundFileSynchronizer;
23+
import org.springframework.integration.smb.filters.SmbPersistentAcceptOnceFileListFilter;
24+
import org.springframework.integration.smb.filters.SmbRegexPatternFileListFilter;
25+
import org.springframework.integration.smb.filters.SmbSimplePatternFileListFilter;
26+
import org.springframework.integration.smb.inbound.SmbInboundFileSynchronizer;
27+
import org.springframework.integration.smb.inbound.SmbInboundFileSynchronizingMessageSource;
28+
29+
/**
30+
* Parser for the SMB 'inbound-channel-adapter' element.
31+
*
32+
* @author Markus Spann
33+
* @author Artem Bilan
34+
* @author Prafull Kumar Soni
35+
*
36+
* @since 6.0
37+
*/
38+
public class SmbInboundChannelAdapterParser extends AbstractRemoteFileInboundChannelAdapterParser {
39+
40+
@Override
41+
protected String getMessageSourceClassname() {
42+
return SmbInboundFileSynchronizingMessageSource.class.getName();
43+
}
44+
45+
@Override
46+
protected Class<? extends InboundFileSynchronizer> getInboundFileSynchronizerClass() {
47+
return SmbInboundFileSynchronizer.class;
48+
}
49+
50+
@Override
51+
protected Class<? extends FileListFilter<?>> getSimplePatternFileListFilterClass() {
52+
return SmbSimplePatternFileListFilter.class;
53+
}
54+
55+
@Override
56+
protected Class<? extends FileListFilter<?>> getRegexPatternFileListFilterClass() {
57+
return SmbRegexPatternFileListFilter.class;
58+
}
59+
60+
@Override
61+
protected Class<? extends AbstractPersistentAcceptOnceFileListFilter<?>> getPersistentAcceptOnceFileListFilterClass() {
62+
return SmbPersistentAcceptOnceFileListFilter.class;
63+
}
64+
65+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright 2012-2022 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.integration.smb.config;
18+
19+
import org.springframework.integration.config.xml.AbstractIntegrationNamespaceHandler;
20+
21+
/**
22+
* Provides namespace support for using SMB.
23+
*
24+
* @author Markus Spann
25+
* @author Artem Bilan
26+
*
27+
* @since 6.0
28+
*/
29+
public class SmbNamespaceHandler extends AbstractIntegrationNamespaceHandler {
30+
31+
public void init() {
32+
registerBeanDefinitionParser("inbound-channel-adapter", new SmbInboundChannelAdapterParser());
33+
registerBeanDefinitionParser("outbound-channel-adapter", new SmbOutboundChannelAdapterParser());
34+
}
35+
36+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright 2017-2022 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.integration.smb.config;
18+
19+
import org.springframework.integration.file.config.RemoteFileOutboundChannelAdapterParser;
20+
import org.springframework.integration.file.remote.RemoteFileOperations;
21+
import org.springframework.integration.smb.session.SmbRemoteFileTemplate;
22+
23+
/**
24+
* The parser for {@code <Int-smb:outbound-channel-adapter>}.
25+
*
26+
* @author Artem Bilan
27+
*
28+
* @since 6.0
29+
*/
30+
public class SmbOutboundChannelAdapterParser extends RemoteFileOutboundChannelAdapterParser {
31+
32+
@Override
33+
protected Class<? extends RemoteFileOperations<?>> getTemplateClass() {
34+
return SmbRemoteFileTemplate.class;
35+
}
36+
37+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/**
2+
* SMB-specific file list filter classes.
3+
*/
4+
package org.springframework.integration.smb.config;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Copyright 2018-2022 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.integration.smb.filters;
18+
19+
import org.springframework.integration.file.filters.AbstractPersistentAcceptOnceFileListFilter;
20+
import org.springframework.integration.metadata.ConcurrentMetadataStore;
21+
22+
import jcifs.smb.SmbFile;
23+
24+
/**
25+
* Implementation of {@link AbstractPersistentAcceptOnceFileListFilter} for SMB.
26+
*
27+
* @author Prafull Kumar Soni
28+
*
29+
* @since 6.0
30+
*/
31+
public class SmbPersistentAcceptOnceFileListFilter extends AbstractPersistentAcceptOnceFileListFilter<SmbFile> {
32+
33+
34+
public SmbPersistentAcceptOnceFileListFilter(ConcurrentMetadataStore store, String prefix) {
35+
super(store, prefix);
36+
}
37+
38+
@Override
39+
protected long modified(SmbFile file) {
40+
return file.getLastModified();
41+
}
42+
43+
@Override
44+
protected String fileName(SmbFile file) {
45+
return file.getName();
46+
}
47+
48+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
* Copyright 2012-2022 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.integration.smb.filters;
18+
19+
import java.io.UncheckedIOException;
20+
import java.util.regex.Pattern;
21+
22+
import org.springframework.integration.file.filters.AbstractRegexPatternFileListFilter;
23+
24+
import jcifs.smb.SmbException;
25+
import jcifs.smb.SmbFile;
26+
27+
/**
28+
* Implementation of {@link AbstractRegexPatternFileListFilter} for SMB.
29+
*
30+
* @author Markus Spann
31+
* @author Prafull Kumar Soni
32+
*
33+
* @since 6.0
34+
*/
35+
public class SmbRegexPatternFileListFilter extends AbstractRegexPatternFileListFilter<SmbFile> {
36+
37+
public SmbRegexPatternFileListFilter(String pattern) {
38+
this(Pattern.compile(pattern));
39+
}
40+
41+
public SmbRegexPatternFileListFilter(Pattern pattern) {
42+
super(pattern);
43+
}
44+
45+
/**
46+
* Gets the specified SMB file's name.
47+
* @param file SMB file object
48+
* @return file name
49+
* @see AbstractRegexPatternFileListFilter#getFilename(java.lang.Object)
50+
*/
51+
@Override
52+
protected String getFilename(SmbFile file) {
53+
return (file != null ? file.getName() : null);
54+
}
55+
56+
@Override
57+
protected boolean isDirectory(SmbFile file) {
58+
try {
59+
return file.isDirectory();
60+
}
61+
catch (SmbException e) {
62+
throw new UncheckedIOException(e);
63+
}
64+
}
65+
66+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
* Copyright 2018-2022 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.integration.smb.filters;
18+
19+
import java.io.UncheckedIOException;
20+
21+
import org.springframework.integration.file.filters.AbstractSimplePatternFileListFilter;
22+
23+
import jcifs.smb.SmbException;
24+
import jcifs.smb.SmbFile;
25+
26+
/**
27+
* Implementation of {@link AbstractSimplePatternFileListFilter} for SMB.
28+
*
29+
* @author Markus Spann
30+
* @author Prafull Kumar Soni
31+
*
32+
* @since 6.0
33+
*/
34+
public class SmbSimplePatternFileListFilter extends AbstractSimplePatternFileListFilter<SmbFile> {
35+
36+
public SmbSimplePatternFileListFilter(String pathPattern) {
37+
super(pathPattern);
38+
}
39+
40+
/**
41+
* Gets the specified SMB file's name.
42+
* @param file SMB file object
43+
* @return file name
44+
* @see AbstractSimplePatternFileListFilter#getFilename(java.lang.Object)
45+
*/
46+
@Override
47+
protected String getFilename(SmbFile file) {
48+
return (file != null) ? file.getName() : null;
49+
}
50+
51+
52+
@Override
53+
protected boolean isDirectory(SmbFile file) {
54+
try {
55+
return file.isDirectory();
56+
}
57+
catch (SmbException e) {
58+
throw new UncheckedIOException(e);
59+
}
60+
}
61+
62+
}

0 commit comments

Comments
 (0)