congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
HttpClientUtil
Code IndexAdd Tabnine to your IDE (free)

How to use
HttpClientUtil
in
org.pentaho.di.core.util

Best Java code snippets using org.pentaho.di.core.util.HttpClientUtil (Showing top 20 results out of 315)

origin: pentaho/pentaho-kettle

/**
 * Returns context with AuthCache or null in case of any exception was thrown.
 * Use "http" schema.
 *
 * @param host
 * @param port
 * @param user
 * @param password
 * @return {@link org.apache.http.client.protocol.HttpClientContext HttpClientContext}
 */
public static HttpClientContext createPreemptiveBasicAuthentication( String host, int port, String user,
                                   String password ) {
 return createPreemptiveBasicAuthentication( host, port, user, password, "http" );
}
origin: pentaho/pentaho-kettle

/**
 *
 * @param response the httpresponse for processing
 * @param charset the charset used for getting HttpEntity
 * @return HttpEntity in decoded String representation using provided charset
 * @throws IOException
 */
public static String responseToString( HttpResponse response, Charset charset ) throws IOException {
 return responseToString( response, charset, false );
}
origin: pentaho/pdi-sdk-plugins

public static String sendStartJobRequest( String urlString, String authentication ) throws Exception {
 HttpGet method = new HttpGet( urlString );
 HttpClientContext context = HttpClientUtil.createPreemptiveBasicAuthentication( host, port, user, password );
 //adding authorization token
 if ( authentication != null ) {
  method.addHeader( new BasicHeader( "Authorization", authentication ) );
 }
 //executing method
 HttpClient client = HttpClientManager.getInstance().createDefaultClient();
 HttpResponse httpResponse = context != null ? client.execute( method, context ) : client.execute( method );
 int code = httpResponse.getStatusLine().getStatusCode();
 String response = HttpClientUtil.responseToString( httpResponse );
 method.releaseConnection();
 if ( code >= HttpStatus.SC_BAD_REQUEST ) {
  System.out.println( "Error occurred during starting job." );
  return null;
 }
 return response;
}
origin: pentaho/pdi-sdk-plugins

 public static void sendGetImageRequest( String urlString, String authentication, String fileName ) throws Exception {
  HttpGet method = new HttpGet( urlString );
  HttpClientContext context = HttpClientUtil.createPreemptiveBasicAuthentication( host, port, user, password );
  //adding authorization token
  if ( authentication != null ) {
   method.addHeader( new BasicHeader( "Authorization", authentication ) );
  }

  //executing method
  HttpClient client = HttpClientManager.getInstance().createDefaultClient();
  HttpResponse httpResponse = context != null ? client.execute( method, context ) : client.execute( method );
  int code = httpResponse.getStatusLine().getStatusCode();
  byte[] response = HttpClientUtil.responseToByteArray( httpResponse );
  method.releaseConnection();
  if ( code >= HttpStatus.SC_BAD_REQUEST ) {
   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();
  }
 }
}
origin: pentaho/pdi-sdk-plugins

public static String sendPauseTransRequest( String urlString, String authentication ) throws Exception {
 HttpGet method = new HttpGet( urlString );
 HttpClientContext context = HttpClientUtil.createPreemptiveBasicAuthentication( host, port, user, password );
 //adding authorization token
 if ( authentication != null ) {
  method.addHeader( new BasicHeader( "Authorization", authentication ) );
 }
 //executing method
 HttpClient client = HttpClientManager.getInstance().createDefaultClient();
 HttpResponse httpResponse = context != null ? client.execute( method, context ) : client.execute( method );
 int code = httpResponse.getStatusLine().getStatusCode();
 String response = HttpClientUtil.responseToString( httpResponse );
 method.releaseConnection();
 if ( code >= HttpStatus.SC_BAD_REQUEST ) {
  System.out.println( "Error occurred during pausing transformation." );
  return null;
 }
 return response;
}
origin: pentaho/pdi-sdk-plugins

public static boolean sendGetImageRequest( String urlString, String authentication, String fileName )
 throws Exception {
 HttpGet method = new HttpGet( urlString );
 HttpClientContext context = HttpClientUtil.createPreemptiveBasicAuthentication( host, port, user, password );
 //adding authorization token
 if ( authentication != null ) {
  method.addHeader( new BasicHeader( "Authorization", authentication ) );
 }
 //executing method
 HttpClient client = HttpClientManager.getInstance().createDefaultClient();
 HttpResponse httpResponse = context != null ? client.execute( method, context ) : client.execute( method );
 int code = httpResponse.getStatusLine().getStatusCode();
 byte[] response = HttpClientUtil.responseToByteArray( httpResponse );
 method.releaseConnection();
 if ( code >= HttpStatus.SC_BAD_REQUEST ) {
  System.out.println( "Error occurred during getting job image." );
  return false;
 }
 FileOutputStream fos = null;
 try {
  fos = new FileOutputStream( fileName );
  fos.write( response );
  fos.flush();
 } finally {
  fos.close();
 }
 return true;
}
origin: pentaho/pdi-sdk-plugins

public static String sendStopJobRequest( String urlString, String authentication ) throws Exception {
 HttpGet method = new HttpGet( urlString );
 HttpClientContext context = HttpClientUtil.createPreemptiveBasicAuthentication( host, port, user, password );
 //adding authorization token
 if ( authentication != null ) {
  method.addHeader( new BasicHeader( "Authorization", authentication ) );
 }
 //executing method
 HttpClient client = HttpClientManager.getInstance().createDefaultClient();
 HttpResponse httpResponse = context != null ? client.execute( method, context ) : client.execute( method );
 int code = httpResponse.getStatusLine().getStatusCode();
 String response = HttpClientUtil.responseToString( httpResponse );
 method.releaseConnection();
 if ( code >= HttpStatus.SC_BAD_REQUEST ) {
  System.out.println( "Error occurred during stopping job." );
  return null;
 }
 return response;
}
origin: pentaho/big-data-plugin

 userString = user;
 httpClient = getHttpClient( user, password );
 context = HttpClientUtil.createPreemptiveBasicAuthentication( uri.getHost(), portInt, user, password );
} else {
 httpClient = getHttpClient();
origin: pentaho/pentaho-kettle

/**
 *
 * @param response the httpresponse for processing
 * @return HttpEntity in String representation using "UTF-8" encoding
 * @throws IOException
 */
public static String responseToString( HttpResponse response ) throws IOException {
 return responseToString( response, Charset.forName( StandardCharsets.UTF_8.name() ) );
}
origin: pentaho/pdi-sdk-plugins

public static String sendGetJobStatusRequest( String urlString, String authentication ) throws Exception {
 HttpGet method = new HttpGet( urlString );
 HttpClientContext context = HttpClientUtil.createPreemptiveBasicAuthentication( host, port, user, password );
 //adding authorization token
 if ( authentication != null ) {
  method.addHeader( new BasicHeader( "Authorization", authentication ) );
 }
 //executing method
 HttpClient client = HttpClientManager.getInstance().createDefaultClient();
 HttpResponse httpResponse = context != null ? client.execute( method, context ) : client.execute( method );
 int code = httpResponse.getStatusLine().getStatusCode();
 String response = HttpClientUtil.responseToString( httpResponse );
 method.releaseConnection();
 if ( code >= HttpStatus.SC_BAD_REQUEST ) {
  System.out.println( "Error occurred during getting job status." );
  return null;
 }
 return response;
}
origin: pentaho/pdi-sdk-plugins

public static void allocateServerSocket( String urlString, String authentication ) throws Exception {
 HttpGet method = new HttpGet( urlString );
 HttpClientContext context = HttpClientUtil.createPreemptiveBasicAuthentication( host, port, user, password );
 method.addHeader( new BasicHeader( "Content-Type", "text/xml;charset=UTF-8" ) );
 //adding authorization token
 if ( authentication != null ) {
  method.addHeader( new BasicHeader( "Authorization", authentication ) );
 }
 //executing method
 HttpClient client = HttpClientManager.getInstance().createDefaultClient();
 HttpResponse httpResponse = context != null ? client.execute( method, context ) : client.execute( method );
 int code = httpResponse.getStatusLine().getStatusCode();
 String response = HttpClientUtil.responseToString( httpResponse );
 method.releaseConnection();
 if ( code >= HttpStatus.SC_BAD_REQUEST ) {
  System.out.println( "Error occurred during ports allocation." );
 }
 System.out.println( "Server response:" );
 System.out.println( response );
}
origin: pentaho/pdi-sdk-plugins

public static String sendStartTransRequest( String urlString, String authentication ) throws Exception {
 HttpGet method = new HttpGet( urlString );
 HttpClientContext context = HttpClientUtil.createPreemptiveBasicAuthentication( host, port, user, password );
 //adding authorization token
 if ( authentication != null ) {
  method.addHeader( new BasicHeader( "Authorization", authentication ) );
 }
 //executing method
 HttpClient client = HttpClientManager.getInstance().createDefaultClient();
 HttpResponse httpResponse = context != null ? client.execute( method, context ) : client.execute( method );
 int code = httpResponse.getStatusLine().getStatusCode();
 String response = HttpClientUtil.responseToString( httpResponse );
 method.releaseConnection();
 if ( code >= HttpStatus.SC_BAD_REQUEST ) {
  System.out.println( "Error occurred during starting transformation." );
  return null;
 }
 return response;
}
origin: pentaho/pdi-sdk-plugins

public static String sendPrepareExecutionTransRequest( String urlString, String authentication ) throws Exception {
 HttpGet method = new HttpGet( urlString );
 HttpClientContext context = HttpClientUtil.createPreemptiveBasicAuthentication( host, port, user, password );
 //adding authorization token
 if ( authentication != null ) {
  method.addHeader( new BasicHeader( "Authorization", authentication ) );
 }
 //executing method
 HttpClient client = HttpClientManager.getInstance().createDefaultClient();
 HttpResponse httpResponse = context != null ? client.execute( method, context ) : client.execute( method );
 int code = httpResponse.getStatusLine().getStatusCode();
 String response = HttpClientUtil.responseToString( httpResponse );
 method.releaseConnection();
 if ( code >= HttpStatus.SC_BAD_REQUEST ) {
  System.out.println( "Error occurred during preparing transformation execution." );
  return null;
 }
 return response;
}
origin: pentaho/pdi-sdk-plugins

public static String sendRemoveTransRequest( String urlString, String authentication ) throws Exception {
 HttpGet method = new HttpGet( urlString );
 HttpClientContext context = HttpClientUtil.createPreemptiveBasicAuthentication( host, port, user, password );
 //adding authorization token
 if ( authentication != null ) {
  method.addHeader( new BasicHeader( "Authorization", authentication ) );
 }
 //executing method
 HttpClient client = HttpClientManager.getInstance().createDefaultClient();
 HttpResponse httpResponse = context != null ? client.execute( method, context ) : client.execute( method );
 int code = httpResponse.getStatusLine().getStatusCode();
 String response = HttpClientUtil.responseToString( httpResponse );
 method.releaseConnection();
 if ( code >= HttpStatus.SC_BAD_REQUEST ) {
  System.out.println( "Error occurred during removing transformation." );
  return null;
 }
 return response;
}
origin: pentaho/pdi-sdk-plugins

 public static void sendGetTransStatusRequest( String urlString, String authentication ) throws Exception {
  HttpGet method = new HttpGet( urlString );
  HttpClientContext context = HttpClientUtil.createPreemptiveBasicAuthentication( host, port, user, password );
  //adding authorization token
  if ( authentication != null ) {
   method.addHeader( new BasicHeader( "Authorization", authentication ) );
  }

  //executing method
  HttpClient client = HttpClientManager.getInstance().createDefaultClient();
  HttpResponse httpResponse = context != null ? client.execute( method, context ) : client.execute( method );
  int code = httpResponse.getStatusLine().getStatusCode();
  String response = HttpClientUtil.responseToString( httpResponse );
  method.releaseConnection();
  if ( code >= HttpStatus.SC_BAD_REQUEST ) {
   System.out.println( "Error occurred during getting job status." );
  }
  System.out.println( "Server response:" );
  System.out.println( response );
 }
}
origin: pentaho/pdi-sdk-plugins

 public static void sendExecuteRequest( String urlString, String authentication ) throws Exception {
  HttpGet method = new HttpGet( urlString );
  HttpClientContext context = HttpClientUtil.createPreemptiveBasicAuthentication( host, port, user, password );
  method.addHeader( new BasicHeader( "Content-Type", "text/xml;charset=UTF-8" ) );
  //adding authorization token
  if ( authentication != null ) {
   method.addHeader( new BasicHeader( "Authorization", authentication ) );
  }

  //executing method
  HttpClient client = HttpClientManager.getInstance().createDefaultClient();
  HttpResponse httpResponse = context != null ? client.execute( method, context ) : client.execute( method );
  int code = httpResponse.getStatusLine().getStatusCode();
  String response = HttpClientUtil.responseToString( httpResponse );
  method.releaseConnection();
  if ( code >= HttpStatus.SC_BAD_REQUEST ) {
   System.out.println( "Error occurred during transformation execution." );
  }
  System.out.println( "Server response (expected to be empty):" );
  System.out.println( response );
 }
}
origin: pentaho/pdi-sdk-plugins

public static void sendGetSlavesRequest( String urlString, String authentication ) throws Exception {
 HttpGet method = new HttpGet( urlString );
 HttpClientContext context = HttpClientUtil.createPreemptiveBasicAuthentication( host, port, user, password );
 //adding authorization token
 if ( authentication != null ) {
  method.addHeader( new BasicHeader( "Authorization", authentication ) );
 }
 //executing method
 HttpClient client = HttpClientManager.getInstance().createDefaultClient();
 HttpResponse httpResponse = context != null ? client.execute( method, context ) : client.execute( method );
 int code = httpResponse.getStatusLine().getStatusCode();
 String response = HttpClientUtil.responseToString( httpResponse );
 method.releaseConnection();
 if ( code >= HttpStatus.SC_BAD_REQUEST ) {
  System.out.println( "Error occurred during getting slave servers." );
 }
 System.out.println( "Server response:" );
 System.out.println( response );
}
origin: pentaho/pdi-sdk-plugins

public static void addPackageToServlet( String urlString, InputStream is, String authentication ) throws Exception {
 HttpPost method = new HttpPost( urlString );
 method.setEntity( new InputStreamEntity( is ) );
 HttpClientContext context = HttpClientUtil.createPreemptiveBasicAuthentication( host, port, user, password );
 method.addHeader( new BasicHeader( "Content-Type", "binary/zip" ) );
 //adding authorization token
 if ( authentication != null ) {
  method.addHeader( new BasicHeader( "Authorization", authentication ) );
 }
 //executing method
 HttpClient client = HttpClientManager.getInstance().createDefaultClient();
 HttpResponse httpResponse = context != null ? client.execute( method, context ) : client.execute( method );
 int code = httpResponse.getStatusLine().getStatusCode();
 String response = HttpClientUtil.responseToString( httpResponse );
 method.releaseConnection();
 if ( code >= HttpStatus.SC_BAD_REQUEST ) {
  System.out.println( "Error occurred during export submission." );
 }
 System.out.println( "Server response:" );
 System.out.println( response );
}
origin: pentaho/pdi-sdk-plugins

public static String sendStopTransRequest( String urlString, String authentication ) throws Exception {
 HttpGet method = new HttpGet( urlString );
 HttpClientContext context = HttpClientUtil.createPreemptiveBasicAuthentication( host, port, user, password );
 //adding authorization token
 if ( authentication != null ) {
  method.addHeader( new BasicHeader( "Authorization", authentication ) );
 }
 //executing method
 HttpClient client = HttpClientManager.getInstance().createDefaultClient();
 HttpResponse httpResponse = context != null ? client.execute( method, context ) : client.execute( method );
 int code = httpResponse.getStatusLine().getStatusCode();
 String response = HttpClientUtil.responseToString( httpResponse );
 method.releaseConnection();
 if ( code >= HttpStatus.SC_BAD_REQUEST ) {
  System.out.println( "Error occurred during stopping transformation." );
  return null;
 }
 return response;
}
origin: pentaho/pdi-sdk-plugins

public static String sendSniffStepRequest( String urlString, String authentication ) throws Exception {
 HttpGet method = new HttpGet( urlString );
 HttpClientContext context = HttpClientUtil.createPreemptiveBasicAuthentication( host, port, user, password );
 //adding authorization token
 if ( authentication != null ) {
  method.addHeader( new BasicHeader( "Authorization", authentication ) );
 }
 //executing method
 HttpClient client = HttpClientManager.getInstance().createDefaultClient();
 HttpResponse httpResponse = context != null ? client.execute( method, context ) : client.execute( method );
 int code = httpResponse.getStatusLine().getStatusCode();
 String response = HttpClientUtil.responseToString( httpResponse );
 method.releaseConnection();
 if ( code >= HttpStatus.SC_BAD_REQUEST ) {
  System.out.println( "Error occurred during starting job." );
  return null;
 }
 return response;
}
org.pentaho.di.core.utilHttpClientUtil

Javadoc

Utility class contained useful methods while working with org.apache.http.client.HttpClient

Most used methods

  • createPreemptiveBasicAuthentication
    Returns context with AuthCache or null in case of any exception was thrown.
  • responseToString
  • responseToByteArray

Popular in Java

  • Making http requests using okhttp
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • getContentResolver (Context)
  • notifyDataSetChanged (ArrayAdapter)
  • IOException (java.io)
    Signals a general, I/O-related error. Error details may be specified when calling the constructor, a
  • Timestamp (java.sql)
    A Java representation of the SQL TIMESTAMP type. It provides the capability of representing the SQL
  • LinkedList (java.util)
    Doubly-linked list implementation of the List and Dequeinterfaces. Implements all optional list oper
  • Timer (java.util)
    Timers schedule one-shot or recurring TimerTask for execution. Prefer java.util.concurrent.Scheduled
  • ZipFile (java.util.zip)
    This class provides random read access to a zip file. You pay more to read the zip file's central di
  • HttpServlet (javax.servlet.http)
    Provides an abstract class to be subclassed to create an HTTP servlet suitable for a Web site. A sub
  • Top 15 Vim Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now