public class HttpRequestStep extends java.lang.Object implements ISimpleStep
GET, POST, PUT, DELETE
).
This is an example implementation of ISimpleStep
that
executes the specified HTTP request.
BASIC authentication is supported, as well as the specification of an HTTP proxy. This step could be useful for interacting with any REST-ful web service.
The parameters "URL Template" and "Content Template" allow input field substitution
by using curly braces. For example, http://my.server.com?id={ID}
will substitute
the value of the input field called "ID" into the URL used for the request.
Note: The plugin examples are included in the Data Management Platform Java™ Plugin jar and as such have a package name that represents that location. Therefore, modifying the examples requires placing the modified source, including the package statement, in a new Java™ compilation unit.
Constructor and Description |
---|
HttpRequestStep() |
Modifier and Type | Method and Description |
---|---|
int |
getOutputFieldCount()
Return the number of output fields provided by this step.
|
FieldInformation |
getOutputFieldInformation(int index)
Return the information about an output field provided by this step.
|
java.lang.Object |
getOutputFieldValue(int index)
Return the value of an output field in the current row.
|
int |
getParameterCount()
Return the number of parameters this step requires.
|
java.lang.String |
getParameterName(int index)
Get the name of a parameter required by this step.
|
void |
postExec()
Execution of the job is complete.
|
void |
preExec(boolean previewMode)
Prepare for execution.
|
void |
processRow()
Process a row of data.
|
void |
release()
Release resources.
|
void |
setInputFieldCount(int count)
Set the number of fields provided by the parent step.
|
void |
setInputFieldInformation(int index,
java.lang.String name,
DataType type,
int length)
Set the input field information provided by the parent step.
|
void |
setInputFieldValue(int index,
java.lang.Object value)
Set the value of an input field.
|
void |
setParameterValue(int index,
java.lang.String value)
Set the value of a parameter required by this step.
|
void |
validateInputs()
Validate input field information.
|
public HttpRequestStep() throws StepException
StepException
public int getOutputFieldCount()
ISimpleStep
If you want to "pass-through" any fields from the parent, you must include those fields in this count.
getOutputFieldCount
in interface ISimpleStep
public FieldInformation getOutputFieldInformation(int index) throws java.lang.IndexOutOfBoundsException
ISimpleStep
This method must return a valid instance of FieldInformation
.
getOutputFieldInformation
in interface ISimpleStep
index
- The 0-based index of the output field.java.lang.IndexOutOfBoundsException
- If the index argument is out of bounds.public java.lang.Object getOutputFieldValue(int index) throws java.lang.IndexOutOfBoundsException
ISimpleStep
The Data Management Platform will always pass a index
that
is in bounds.
getOutputFieldValue
in interface ISimpleStep
index
- The 0-based index of the output fieldnull
.java.lang.IndexOutOfBoundsException
- If the index argument is out of bounds.public int getParameterCount()
StepParameters
getParameterCount
in interface StepParameters
public java.lang.String getParameterName(int index) throws java.lang.IndexOutOfBoundsException
StepParameters
getParameterName
in interface StepParameters
index
- The 0-based index of the parameter name to retrievejava.lang.IndexOutOfBoundsException
- if the index argument is out of boundspublic void postExec()
ISimpleStep
The plugin step should release any resources used during execution.
postExec
in interface ISimpleStep
public void preExec(boolean previewMode) throws StepException
ISimpleStep
Called after all parameters are set and all input fields from the parent have been specified, but before execution of the job begins. The plugin should prepare to accept input rows.
preExec
in interface ISimpleStep
previewMode
- true
if the job is being previewed.StepException
- If anything goes wrong or the plugin cannot begin
to process rows.public void processRow() throws StepException
ISimpleStep
Called after all of the fields of an input row have been passed in. Process the row and make output fields available. Throw an exception to signal an error.
processRow
in interface ISimpleStep
StepException
- If an error occurs during row processing.public void release()
ISimpleStep
The plugin step should release any resources, such as file handles, here.
Called immediately before the plugin is released for garbage collection. This usually happens when the process running a job shuts down, although it can also happen when a node is deleted from a job.
release
in interface ISimpleStep
public void setInputFieldCount(int count)
ISimpleStep
setInputFieldCount
in interface ISimpleStep
count
- The number of fields provided by the parent step.public void setInputFieldInformation(int index, java.lang.String name, DataType type, int length)
ISimpleStep
The Data Management Platform will always pass a index
that
is in bounds.
setInputFieldInformation
in interface ISimpleStep
index
- The 0-based index of the input field.name
- The name of the input field.type
- The data type of the input field.length
- The maximum character length of the input field. This only
applies for string fields.public void setInputFieldValue(int index, java.lang.Object value)
ISimpleStep
The value being set is provided by the parent step.
The Data Management Platform will always pass a index
that
is in bounds.
setInputFieldValue
in interface ISimpleStep
index
- The 0-based index of the input field.value
- The value of the input field.public void setParameterValue(int index, java.lang.String value) throws java.lang.IndexOutOfBoundsException, javax.crypto.IllegalBlockSizeException, java.io.IOException
StepParameters
setParameterValue
in interface StepParameters
index
- The 0-based index of the parametervalue
- The value of the parameterjava.lang.IndexOutOfBoundsException
- if the index argument is out of boundsjavax.crypto.IllegalBlockSizeException
java.io.IOException
public void validateInputs() throws StepException
ISimpleStep
Called after all parameters are set and all input field information from the parent has been specified.
validateInputs
in interface ISimpleStep
StepException
- If the inputs are not valid.Copyright © 2012 SAS Institute Inc. All Rights Reserved.