Skip to content

Commit

Permalink
[BACKLOG-38519] SFTP Put Core To Plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Mandakini1990 committed Sep 15, 2023
1 parent 997a56e commit 6299f7e
Show file tree
Hide file tree
Showing 27 changed files with 951 additions and 165 deletions.
13 changes: 13 additions & 0 deletions assemblies/plugins/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
<excel-plugin.version>${project.version}</excel-plugin.version>
<ldap-plugin.version>${project.version}</ldap-plugin.version>
<ivw-bulk-loader-plugin.version>${project.version}</ivw-bulk-loader-plugin.version>
<sftpput-plugin.version>${project.version}</sftpput-plugin.version>
<edi2xml-plugin.version>${project.version}</edi2xml-plugin.version>
<random-cc-number-generator-plugin.version>${project.version}</random-cc-number-generator-plugin.version>
<credit-card-validator-plugin.version>${project.version}</credit-card-validator-plugin.version>
Expand Down Expand Up @@ -340,6 +341,18 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.pentaho.di.plugins</groupId>
<artifactId>sftpput-plugin</artifactId>
<version>${sftpput-plugin.version}</version>
<type>zip</type>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.pentaho.di.plugins</groupId>
<artifactId>mondrianinput-plugin</artifactId>
Expand Down
1 change: 0 additions & 1 deletion engine/src/main/resources/kettle-steps.xml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@
<step id="ZipFile"> <description>i18n:org.pentaho.di.trans.step:BaseStep.TypeLongDesc.ZipFile</description> <classname>org.pentaho.di.trans.steps.zipfile.ZipFileMeta</classname> <category>i18n:org.pentaho.di.trans.step:BaseStep.Category.Utility</category> <tooltip>i18n:org.pentaho.di.trans.step:BaseStep.TypeTooltipDesc.ZipFile</tooltip> <iconfile>ui/images/ZIP.svg</iconfile> <documentation_url>http://wiki.pentaho.com/display/EAI/Zip+file+%28step%29</documentation_url> <cases_url/> <forum_url/> </step>
<step id="SASInput"> <description>i18n:org.pentaho.di.trans.step:BaseStep.TypeLongDesc.SASInput</description> <classname>org.pentaho.di.trans.steps.sasinput.SasInputMeta</classname> <category>i18n:org.pentaho.di.trans.step:BaseStep.Category.Input</category> <tooltip>i18n:org.pentaho.di.trans.step:BaseStep.TypeTooltipDesc.SASInput</tooltip> <iconfile>ui/images/SASInput.svg</iconfile> <documentation_url>http://wiki.pentaho.com/display/EAI/SAS+Input</documentation_url> <cases_url/> <forum_url/> </step>
<step id="TableCompare"> <description>i18n:org.pentaho.di.trans.step:BaseStep.TypeLongDesc.TableCompare</description> <classname>org.pentaho.di.trans.steps.tablecompare.TableCompareMeta</classname> <category>i18n:org.pentaho.di.trans.step:BaseStep.Category.Utility</category> <tooltip>i18n:org.pentaho.di.trans.step:BaseStep.TypeTooltipDesc.TableCompare</tooltip> <iconfile>ui/images/TBLCMP.svg</iconfile> <documentation_url>http://wiki.pentaho.com/display/EAI/Table+Compare</documentation_url> <cases_url/> <forum_url/> </step>
<step id="SFTPPut"> <description>i18n:org.pentaho.di.trans.step:BaseStep.TypeLongDesc.SFTPPut</description> <classname>org.pentaho.di.trans.steps.sftpput.SFTPPutMeta</classname> <category>i18n:org.pentaho.di.trans.step:BaseStep.Category.Experimental</category> <tooltip>i18n:org.pentaho.di.trans.step:BaseStep.TypeTooltipDesc.SFTPPut</tooltip> <iconfile>ui/images/SFP.svg</iconfile> <documentation_url>http://wiki.pentaho.com/display/EAI/SFTP+Put</documentation_url> <cases_url/> <forum_url/> </step>
<step id="PGPEncryptStream"> <description>i18n:org.pentaho.di.trans.step:BaseStep.TypeLongDesc.PGPEncryptStream</description> <classname>org.pentaho.di.trans.steps.pgpencryptstream.PGPEncryptStreamMeta</classname> <category>i18n:org.pentaho.di.trans.step:BaseStep.Category.Cryptography</category> <tooltip>i18n:org.pentaho.di.trans.step:BaseStep.TypeTooltipDesc.PGPEncryptStream</tooltip> <iconfile>ui/images/GPGEncrypt.svg</iconfile> <documentation_url>http://wiki.pentaho.com/display/EAI/Encrypt+files+with+PGP</documentation_url> <cases_url/> <forum_url/> </step>
<step id="PGPDecryptStream"> <description>i18n:org.pentaho.di.trans.step:BaseStep.TypeLongDesc.PGPDecryptStream</description> <classname>org.pentaho.di.trans.steps.pgpdecryptstream.PGPDecryptStreamMeta</classname> <category>i18n:org.pentaho.di.trans.step:BaseStep.Category.Cryptography</category> <tooltip>i18n:org.pentaho.di.trans.step:BaseStep.TypeTooltipDesc.PGPDecryptStream</tooltip> <iconfile>ui/images/GPGDecrypt.svg</iconfile> <documentation_url>http://wiki.pentaho.com/display/EAI/Decrypt+files+with+PGP</documentation_url> <cases_url/> <forum_url/> </step>
<step id="TransExecutor"> <description>i18n:org.pentaho.di.trans.step:BaseStep.TypeLongDesc.TransExecutor</description> <classname>org.pentaho.di.trans.steps.transexecutor.TransExecutorMeta</classname> <category>i18n:org.pentaho.di.trans.step:BaseStep.Category.Flow</category> <tooltip>i18n:org.pentaho.di.trans.step:BaseStep.TypeTooltipDesc.TransExecutor</tooltip> <iconfile>ui/images/TRNEx.svg</iconfile> <documentation_url>Products/Transformation_Executor</documentation_url> <cases_url/> <forum_url/> </step>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,8 +415,6 @@ BaseStep.Category.DataQuality=Data Quality

BaseStep.TypeLongDesc.Edi2Xml=EDI to XML
BaseStep.TypeTooltipDesc.Edi2Xml=Converts Edi text to generic XML
BaseStep.TypeLongDesc.SFTPPut=SFTP put
BaseStep.TypeTooltipDesc.SFTPPut=Upload a file or a stream file to remote host via SFTP
BaseStepDialog.WizardConnectionButton.Label=Wizard...
BaseStep.Log.LoadBalancingActivated=Load balancing activated

Expand Down
1 change: 1 addition & 0 deletions plugins/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ __List of the current core plugins:__
* drools
* dummy
* gpload
* sftpput
* hl7
* json
* openerp
Expand Down
1 change: 1 addition & 0 deletions plugins/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
<module>mondrianinput</module>
<module>avro-format</module>
<module>get-repository-names</module>
<module>sftpput</module>
<module>connected-to-repository</module>
</modules>
</profile>
Expand Down
55 changes: 55 additions & 0 deletions plugins/sftpput/assemblies/plugin/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.pentaho.di.plugins</groupId>
<artifactId>sftpput-assemblies</artifactId>
<version>10.1.0.0-SNAPSHOT</version>
</parent>

<artifactId>sftpput-plugin</artifactId>
<version>10.1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>

<name>PDI SFTP put Plugin Distribution</name>
<description></description>

<dependencies>
<dependency>
<groupId>org.pentaho.di.plugins</groupId>
<artifactId>sftpput-plugin-impl</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.pentaho.di.plugins</groupId>
<artifactId>sftpput-plugin-ui</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>add-libs</id>
<phase>generate-resources</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/assembly/lib</outputDirectory>
<includeScope>compile</includeScope>
<excludeArtifactIds>sftpput-plugin-impl,sftpput-plugin-ui</excludeArtifactIds>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
37 changes: 37 additions & 0 deletions plugins/sftpput/assemblies/plugin/src/assembly/assembly.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
<id>sftpput-plugin</id>
<formats>
<format>zip</format>
</formats>
<baseDirectory>sftpput-plugin</baseDirectory>

<files>
<file>
<source>${project.basedir}/src/main/resources/version.xml</source>
<outputDirectory>.</outputDirectory>
<filtered>true</filtered>
</file>
</files>

<fileSets>
<!-- the staging dir -->
<fileSet>
<directory>${project.build.directory}/assembly</directory>
<outputDirectory>.</outputDirectory>
</fileSet>
</fileSets>

<dependencySets>
<dependencySet>
<outputDirectory>.</outputDirectory>
<includes>
<include>org.pentaho.di.plugins:sftpput-plugin-impl:jar</include>
<include>org.pentaho.di.plugins:sftpput-plugin-ui:jar</include>
</includes>
<useProjectArtifact>false</useProjectArtifact>
</dependencySet>
</dependencySets>
</assembly>


Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<version>${project.version}</version>
22 changes: 22 additions & 0 deletions plugins/sftpput/assemblies/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.pentaho.di.plugins</groupId>
<artifactId>sftpput</artifactId>
<version>10.1.0.0-SNAPSHOT</version>
</parent>

<artifactId>sftpput-assemblies</artifactId>
<version>10.1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>

<name>PDI SFTP Put Plugins Assemblies</name>

<modules>
<module>plugin</module>
</modules>
</project>
58 changes: 58 additions & 0 deletions plugins/sftpput/impl/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.pentaho.di.plugins</groupId>
<artifactId>sftpput</artifactId>
<version>10.1.0.0-SNAPSHOT</version>
</parent>

<artifactId>sftpput-plugin-impl</artifactId>
<name>PDI SFTP Put Plugin Impl</name>

<dependencies>
<dependency>
<groupId>pentaho-kettle</groupId>
<artifactId>kettle-core</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>pentaho-kettle</groupId>
<artifactId>kettle-engine</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.healthmarketscience.jackcess</groupId>
<artifactId>jackcess</artifactId>
<scope>compile</scope>
</dependency>

<!-- Test dependencies -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>pentaho-kettle</groupId>
<artifactId>kettle-core</artifactId>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>pentaho-kettle</groupId>
<artifactId>kettle-engine</artifactId>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
/*! ******************************************************************************
*
* Pentaho Data Integration
*
* Copyright (C) 2002-2023 by Hitachi Vantara : http://www.pentaho.com
*
*******************************************************************************
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/

package org.pentaho.di.trans.steps.sftpput;

import com.jcraft.jsch.ChannelSftp;
import com.jcraft.jsch.Session;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.pentaho.di.TestUtilities;
import org.pentaho.di.core.KettleEnvironment;
import org.pentaho.di.job.entries.sftp.SftpServer;
import org.pentaho.di.trans.Trans;

import java.io.ByteArrayOutputStream;

import static org.junit.Assert.assertEquals;

/**
* @author Andrey Khayrutdinov
*/
public class SFTPPutIntegrationIT {

private static TemporaryFolder folder;

private static SftpServer server;

@BeforeClass
public static void startServer() throws Exception {
KettleEnvironment.init();

folder = new TemporaryFolder();
folder.create();

server = SftpServer.createDefaultServer( folder );
server.start();
}

@AfterClass
public static void stopServer() throws Exception {
server.stop();
server = null;

folder.delete();
folder = null;
}


private Session session;
private ChannelSftp channel;

@Before
public void setUp() throws Exception {
session = server.createJschSession();
session.connect();

channel = (ChannelSftp) session.openChannel( "sftp" );
}

@After
public void tearDown() throws Exception {
if ( channel != null && channel.isConnected() ) {
channel.disconnect();
}
channel = null;

if ( session.isConnected() ) {
session.disconnect();
}
session = null;
}


/**
* This case relates to <a href="http://jira.pentaho.com/browse/PDI-13897">PDI-13897</a>.
* It executes a transformation with two steps: data grid and sftp put.
* The latter uploads to an SFTP server a file <tt>pdi-13897/uploaded.txt</tt>, that contains a
* <tt>qwerty</tt> string.<br/>
*
* Parameters of the transformation are:
* <ul>
* <li>server</li>
* <li>port</li>
* <li>username</li>
* <li>password</li>
* </ul>
* @throws Exception
*/
@Test
public void putFileStreamingContentFromField() throws Exception {
// prepare a directory for transformation's execution
channel.connect();
channel.mkdir( "pdi-13897" );

// execute the transformation
Trans trans = TestUtilities.loadAndRunTransformation(
"src/it/resources/org/pentaho/di/trans/steps/sftpput/pdi-13897.ktr",
"server", "localhost",
"port", server.getPort(),
"username", server.getUsername(),
"password", server.getPassword()
);
assertEquals( 0, trans.getErrors() );

// verify the results
ByteArrayOutputStream os = new ByteArrayOutputStream();
channel.cd( "pdi-13897" );
channel.get( "uploaded.txt", os );
String content = new String( os.toByteArray() );
assertEquals( "qwerty", content );
}
}
Loading

0 comments on commit 6299f7e

Please sign in to comment.