Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from kolinus/BACKLOG-1314
BACKLOG-1314 - Document the REST calls for Carte (Kettle Path) Part 2
- Loading branch information
Showing
15 changed files
with
1,146 additions
and
0 deletions.
There are no files selected for viewing
76 changes: 76 additions & 0 deletions
76
kettle-sdk-embedding-samples/src/org/pentaho/di/sdk/samples/carte/GetStatusSample.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/*! ****************************************************************************** | ||
* | ||
* Pentaho Data Integration | ||
* | ||
* Copyright (C) 2002-2013 by Pentaho : 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.sdk.samples.carte; | ||
|
||
import org.apache.commons.codec.binary.Base64; | ||
import org.apache.commons.httpclient.Header; | ||
import org.apache.commons.httpclient.HttpClient; | ||
import org.apache.commons.httpclient.methods.GetMethod; | ||
import org.pentaho.di.core.Const; | ||
import org.pentaho.di.www.GetStatusServlet; | ||
|
||
|
||
public class GetStatusSample { | ||
|
||
public static void main( String[] args ) throws Exception { | ||
if ( args.length < 4 ) { | ||
System.out.println( " You must specify the following parameters Carte_host Carte_port " | ||
+ "Carte_login Carte_password" ); | ||
System.out.println( " For example 127.0.0.1 8088 cluster cluster" ); | ||
System.exit( 1 ); | ||
} | ||
// building target url | ||
String realHostname = args[0]; | ||
String port = args[1]; | ||
|
||
String urlString = "http://" + realHostname + ":" + port + GetStatusServlet.CONTEXT_PATH | ||
+ "?xml=Y"; | ||
urlString = Const.replace( urlString, " ", "%20" ); | ||
|
||
//building auth token | ||
String plainAuth = args[2] + ":" + args[3]; | ||
String auth = "Basic " + Base64.encodeBase64String( plainAuth.getBytes() ); | ||
|
||
sendGetStatusRequest( urlString, auth ); | ||
} | ||
|
||
public static void sendGetStatusRequest( String urlString, String authentication ) throws Exception { | ||
GetMethod method = new GetMethod( urlString ); | ||
method.setDoAuthentication( true ); | ||
//adding authorization token | ||
if ( authentication != null ) { | ||
method.addRequestHeader( new Header( "Authorization", authentication ) ); | ||
} | ||
|
||
//executing method | ||
HttpClient client = new HttpClient( ); | ||
int code = client.executeMethod( method ); | ||
String response = method.getResponseBodyAsString(); | ||
method.releaseConnection(); | ||
if ( code >= 400 ) { | ||
System.out.println( "Error occurred during getting server status." ); | ||
} | ||
System.out.println( "Server response:" ); | ||
System.out.println( response ); | ||
} | ||
} |
81 changes: 81 additions & 0 deletions
81
kettle-sdk-embedding-samples/src/org/pentaho/di/sdk/samples/carte/GetTransImageSample.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/*! ****************************************************************************** | ||
* | ||
* Pentaho Data Integration | ||
* | ||
* Copyright (C) 2002-2013 by Pentaho : 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.sdk.samples.carte; | ||
|
||
import java.io.FileOutputStream; | ||
|
||
import org.apache.commons.codec.binary.Base64; | ||
import org.apache.commons.httpclient.Header; | ||
import org.apache.commons.httpclient.HttpClient; | ||
import org.apache.commons.httpclient.methods.GetMethod; | ||
import org.pentaho.di.core.Const; | ||
import org.pentaho.di.www.GetTransImageServlet; | ||
|
||
|
||
public class GetTransImageSample { | ||
public static void main( String[] args ) throws Exception { | ||
if ( args.length < 6 ) { | ||
System.out.println( " You must specify the following parameters Carte_host Carte_port " | ||
+ "Carte_login Carte_password job_name full_ouput_filepath" ); | ||
System.out.println( " For example 127.0.0.1 8088 cluster cluster dummy_job d:\\1.png" ); | ||
System.exit( 1 ); | ||
} | ||
// building target url | ||
String realHostname = args[0]; | ||
String port = args[1]; | ||
String urlString = "http://" + realHostname + ":" + port + GetTransImageServlet.CONTEXT_PATH + "?name=" + args[4]; | ||
urlString = Const.replace( urlString, " ", "%20" ); | ||
|
||
//building auth token | ||
String plainAuth = args[2] + ":" + args[3]; | ||
String auth = "Basic " + Base64.encodeBase64String( plainAuth.getBytes() ); | ||
|
||
sendGetImageRequest( urlString, auth, args[5] ); | ||
} | ||
|
||
public static void sendGetImageRequest( String urlString, String authentication, String fileName ) throws Exception { | ||
GetMethod method = new GetMethod( urlString ); | ||
method.setDoAuthentication( true ); | ||
//adding authorization token | ||
if ( authentication != null ) { | ||
method.addRequestHeader( new Header( "Authorization", authentication ) ); | ||
} | ||
//executing method | ||
HttpClient client = new HttpClient( ); | ||
int code = client.executeMethod( method ); | ||
byte[] response = method.getResponseBody(); | ||
method.releaseConnection(); | ||
if ( code >= 400 ) { | ||
System.out.println( "Error occurred during getting transformation image." ); | ||
} | ||
System.out.println( "Image was stored to " + fileName ); | ||
FileOutputStream fos = null; | ||
try { | ||
fos = new FileOutputStream( fileName ); | ||
fos.write( response ); | ||
fos.flush(); | ||
} finally { | ||
fos.close(); | ||
} | ||
} | ||
} |
76 changes: 76 additions & 0 deletions
76
kettle-sdk-embedding-samples/src/org/pentaho/di/sdk/samples/carte/GetTransStatusSample.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/*! ****************************************************************************** | ||
* | ||
* Pentaho Data Integration | ||
* | ||
* Copyright (C) 2002-2013 by Pentaho : 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.sdk.samples.carte; | ||
|
||
import org.apache.commons.codec.binary.Base64; | ||
import org.apache.commons.httpclient.Header; | ||
import org.apache.commons.httpclient.HttpClient; | ||
import org.apache.commons.httpclient.methods.GetMethod; | ||
import org.pentaho.di.core.Const; | ||
import org.pentaho.di.www.GetTransStatusServlet; | ||
|
||
|
||
public class GetTransStatusSample { | ||
|
||
public static void main( String[] args ) throws Exception { | ||
if ( args.length < 5 ) { | ||
System.out.println( " You must specify the following parameters Carte_host Carte_port " | ||
+ "Carte_login Carte_password job_name" ); | ||
System.out.println( " For example 127.0.0.1 8088 cluster cluster my_job" ); | ||
System.exit( 1 ); | ||
} | ||
// building target url | ||
String realHostname = args[0]; | ||
String port = args[1]; | ||
|
||
String urlString = "http://" + realHostname + ":" + port + GetTransStatusServlet.CONTEXT_PATH | ||
+ "?xml=Y&name=" + args[4]; | ||
urlString = Const.replace( urlString, " ", "%20" ); | ||
|
||
//building auth token | ||
String plainAuth = args[2] + ":" + args[3]; | ||
String auth = "Basic " + Base64.encodeBase64String( plainAuth.getBytes() ); | ||
|
||
sendGetTransStatusRequest( urlString, auth ); | ||
} | ||
|
||
public static void sendGetTransStatusRequest( String urlString, String authentication ) throws Exception { | ||
GetMethod method = new GetMethod( urlString ); | ||
method.setDoAuthentication( true ); | ||
//adding authorization token | ||
if ( authentication != null ) { | ||
method.addRequestHeader( new Header( "Authorization", authentication ) ); | ||
} | ||
|
||
//executing method | ||
HttpClient client = new HttpClient( ); | ||
int code = client.executeMethod( method ); | ||
String response = method.getResponseBodyAsString(); | ||
method.releaseConnection(); | ||
if ( code >= 400 ) { | ||
System.out.println( "Error occurred during getting job status." ); | ||
} | ||
System.out.println( "Server response:" ); | ||
System.out.println( response ); | ||
} | ||
} |
74 changes: 74 additions & 0 deletions
74
...k-embedding-samples/src/org/pentaho/di/sdk/samples/carte/PrepareExecutionTransSample.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/*! ****************************************************************************** | ||
* | ||
* Pentaho Data Integration | ||
* | ||
* Copyright (C) 2002-2013 by Pentaho : 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.sdk.samples.carte; | ||
|
||
import org.apache.commons.codec.binary.Base64; | ||
import org.apache.commons.httpclient.Header; | ||
import org.apache.commons.httpclient.HttpClient; | ||
import org.apache.commons.httpclient.methods.GetMethod; | ||
import org.pentaho.di.core.Const; | ||
import org.pentaho.di.www.PrepareExecutionTransServlet; | ||
|
||
|
||
public class PrepareExecutionTransSample { | ||
public static void main( String[] args ) throws Exception { | ||
if ( args.length < 5 ) { | ||
System.out.println( " You must specify the following parameters Carte_host Carte_port " | ||
+ "Carte_login Carte_password trans_name" ); | ||
System.out.println( " For example 127.0.0.1 8088 cluster cluster dummy_trans" ); | ||
System.exit( 1 ); | ||
} | ||
// building target url | ||
String realHostname = args[0]; | ||
String port = args[1]; | ||
String urlString = "http://" + realHostname + ":" + port + PrepareExecutionTransServlet.CONTEXT_PATH + "/?" | ||
+ "xml=Y&name=" + args[4]; | ||
urlString = Const.replace( urlString, " ", "%20" ); | ||
|
||
//building auth token | ||
String plainAuth = args[2] + ":" + args[3]; | ||
String auth = "Basic " + Base64.encodeBase64String( plainAuth.getBytes() ); | ||
|
||
sendPrepareExecutionTransRequest( urlString, auth ); | ||
} | ||
|
||
public static void sendPrepareExecutionTransRequest( String urlString, String authentication ) throws Exception { | ||
GetMethod method = new GetMethod( urlString ); | ||
method.setDoAuthentication( true ); | ||
//adding authorization token | ||
if ( authentication != null ) { | ||
method.addRequestHeader( new Header( "Authorization", authentication ) ); | ||
} | ||
|
||
//executing method | ||
HttpClient client = new HttpClient( ); | ||
int code = client.executeMethod( method ); | ||
String response = method.getResponseBodyAsString(); | ||
method.releaseConnection(); | ||
if ( code >= 400 ) { | ||
System.out.println( "Error occurred during preparing transformation execution." ); | ||
} | ||
System.out.println( "Server response:" ); | ||
System.out.println( response ); | ||
} | ||
} |
Oops, something went wrong.