diff --git a/src/com/bpa/pentaho/plugins/AdvancedHTTP.java b/src/com/bpa/pentaho/plugins/AdvancedHTTP.java
index 3c79723..e57956a 100644
--- a/src/com/bpa/pentaho/plugins/AdvancedHTTP.java
+++ b/src/com/bpa/pentaho/plugins/AdvancedHTTP.java
@@ -1,6 +1,7 @@
package com.bpa.pentaho.plugins;
import java.io.InputStream;
+import java.util.Date;
import org.apache.commons.httpclient.Credentials;
import org.apache.commons.httpclient.Header;
@@ -58,9 +59,19 @@ private Object[] execHttp(RowMetaInterface rowMeta, Object[] row) throws KettleE
return callHttpService(rowMeta, row);
}
+ private Object[] makeResponse(RowMetaInterface rowMeta, Object[] rowData, String body, int code, long startTime, long requestTime) {
+ Object [] tmp = rowData;
+ tmp = RowDataUtil.addValueData(tmp, rowMeta.size(), body);
+ tmp = RowDataUtil.addValueData(tmp, rowMeta.size() + 1, new Long(code));
+ tmp = RowDataUtil.addValueData(tmp, rowMeta.size() + 2, new Date(startTime));
+ tmp = RowDataUtil.addValueData(tmp, rowMeta.size() + 3, new Long(requestTime));
+ return tmp;
+ }
+
private Object[] callHttpService(RowMetaInterface rowMeta, Object[] rowData) throws KettleException
{
String url = initUrl(rowMeta, rowData);
+ long start = System.currentTimeMillis();
try
{
if(log.isDetailed()) logDetailed(Messages.getString("AdvancedHTTP.Log.Connecting",url));
@@ -125,10 +136,12 @@ else if (AdvancedHTTPMeta.HTTP_CALL_TYPE_POST_FORM.equals(meta.getHttpCallType()
while ( (c=inputStream.read())!=-1) bodyBuffer.append((char)c);
inputStream.close();
+ long stop = System.currentTimeMillis();
+
String body = bodyBuffer.toString();
if (log.isDebug()) log.logDebug(toString(), "Response body: "+body);
- return RowDataUtil.addValueData(RowDataUtil.addValueData(rowData, rowMeta.size(), body), rowMeta.size() + 1, new Long(result));
+ return makeResponse(rowMeta, rowData, body, result, start, stop-start);
}
finally
{
@@ -142,7 +155,7 @@ else if (AdvancedHTTPMeta.HTTP_CALL_TYPE_POST_FORM.equals(meta.getHttpCallType()
throw new KettleException(Messages.getString("AdvancedHTTP.Log.UnableGetResult",url), e);
}
else {
- return RowDataUtil.addValueData(RowDataUtil.addValueData(rowData, rowMeta.size(), e.getMessage()), rowMeta.size() + 1, new Long(-1));
+ return makeResponse(rowMeta, rowData, e.getMessage(), -1, start, -1);
}
}
}
diff --git a/src/com/bpa/pentaho/plugins/AdvancedHTTPDialog.java b/src/com/bpa/pentaho/plugins/AdvancedHTTPDialog.java
index 7e151b7..dd54272 100644
--- a/src/com/bpa/pentaho/plugins/AdvancedHTTPDialog.java
+++ b/src/com/bpa/pentaho/plugins/AdvancedHTTPDialog.java
@@ -62,6 +62,14 @@ public class AdvancedHTTPDialog extends BaseStepDialog implements StepDialogInte
private Text wHttpReturnCodeFieldName;
private FormData fdlHttpReturnCodeFieldName, fdHttpReturnCodeFieldName;
+ private Label wlHttpStartTimeFieldName;
+ private Text wHttpStartTimeFieldName;
+ private FormData fdlHttpStartTimeFieldName, fdHttpStartTimeFieldName;
+
+ private Label wlHttpRequestTimeFieldName;
+ private Text wHttpRequestTimeFieldName;
+ private FormData fdlHttpRequestTimeFieldName, fdHttpRequestTimeFieldName;
+
private Label wlFields;
private TableView wFields;
private FormData fdlFields, fdFields;
@@ -346,20 +354,56 @@ public void focusGained(org.eclipse.swt.events.FocusEvent e)
fdHttpReturnCodeFieldName.right= new FormAttachment(100, 0);
wHttpReturnCodeFieldName.setLayoutData(fdHttpReturnCodeFieldName);
+ // HttpStartTimeFieldName line...
+ wlHttpStartTimeFieldName=new Label(shell, SWT.RIGHT);
+ wlHttpStartTimeFieldName.setText(Messages.getString("AdvancedHTTPDialog.HttpStartTimeFieldName.Label")); //$NON-NLS-1$
+ props.setLook(wlHttpStartTimeFieldName);
+ fdlHttpStartTimeFieldName=new FormData();
+ fdlHttpStartTimeFieldName.left = new FormAttachment(0, 0);
+ fdlHttpStartTimeFieldName.right= new FormAttachment(middle, -margin);
+ fdlHttpStartTimeFieldName.top = new FormAttachment(wHttpReturnCodeFieldName, margin*2);
+ wlHttpStartTimeFieldName.setLayoutData(fdlHttpStartTimeFieldName);
+ wHttpStartTimeFieldName=new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
+ props.setLook(wHttpStartTimeFieldName);
+ wHttpStartTimeFieldName.addModifyListener(lsMod);
+ fdHttpStartTimeFieldName=new FormData();
+ fdHttpStartTimeFieldName.left = new FormAttachment(middle, 0);
+ fdHttpStartTimeFieldName.top = new FormAttachment(wHttpReturnCodeFieldName, margin*2);
+ fdHttpStartTimeFieldName.right= new FormAttachment(100, 0);
+ wHttpStartTimeFieldName.setLayoutData(fdHttpStartTimeFieldName);
+
+ // HttpRequestTimeFieldName line...
+ wlHttpRequestTimeFieldName=new Label(shell, SWT.RIGHT);
+ wlHttpRequestTimeFieldName.setText(Messages.getString("AdvancedHTTPDialog.HttpRequestTimeFieldName.Label")); //$NON-NLS-1$
+ props.setLook(wlHttpRequestTimeFieldName);
+ fdlHttpRequestTimeFieldName=new FormData();
+ fdlHttpRequestTimeFieldName.left = new FormAttachment(0, 0);
+ fdlHttpRequestTimeFieldName.right= new FormAttachment(middle, -margin);
+ fdlHttpRequestTimeFieldName.top = new FormAttachment(wHttpStartTimeFieldName, margin*2);
+ wlHttpRequestTimeFieldName.setLayoutData(fdlHttpRequestTimeFieldName);
+ wHttpRequestTimeFieldName=new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
+ props.setLook(wHttpRequestTimeFieldName);
+ wHttpRequestTimeFieldName.addModifyListener(lsMod);
+ fdHttpRequestTimeFieldName=new FormData();
+ fdHttpRequestTimeFieldName.left = new FormAttachment(middle, 0);
+ fdHttpRequestTimeFieldName.top = new FormAttachment(wHttpStartTimeFieldName, margin*2);
+ fdHttpRequestTimeFieldName.right= new FormAttachment(100, 0);
+ wHttpRequestTimeFieldName.setLayoutData(fdHttpRequestTimeFieldName);
+
// Use basic auth line
wlUseBasicAuth=new Label(shell, SWT.RIGHT);
wlUseBasicAuth.setText(Messages.getString("AdvancedHTTPDialog.UseBasicAuth.Label"));
props.setLook(wlUseBasicAuth);
fdlUseBasicAuth=new FormData();
fdlUseBasicAuth.left = new FormAttachment(0, 0);
- fdlUseBasicAuth.top = new FormAttachment(wHttpReturnCodeFieldName, margin);
+ fdlUseBasicAuth.top = new FormAttachment(wHttpRequestTimeFieldName, margin);
fdlUseBasicAuth.right= new FormAttachment(middle, -margin);
wlUseBasicAuth.setLayoutData(fdlUseBasicAuth);
wUseBasicAuth=new Button(shell, SWT.CHECK );
props.setLook(wUseBasicAuth);
fdUseBasicAuth=new FormData();
fdUseBasicAuth.left = new FormAttachment(middle, 0);
- fdUseBasicAuth.top = new FormAttachment(wHttpReturnCodeFieldName);
+ fdUseBasicAuth.top = new FormAttachment(wHttpRequestTimeFieldName);
fdUseBasicAuth.right= new FormAttachment(100, 0);
wUseBasicAuth.setLayoutData(fdUseBasicAuth);
wUseBasicAuth.addSelectionListener(new SelectionAdapter()
@@ -493,6 +537,9 @@ public void run()
wUrl.addSelectionListener( lsDef );
wHttpBodyFieldName.addSelectionListener( lsDef );
wHttpReturnCodeFieldName.addSelectionListener( lsDef );
+ wHttpStartTimeFieldName.addSelectionListener( lsDef );
+ wHttpRequestTimeFieldName.addSelectionListener( lsDef );
+
wBasicAuthLogin.addSelectionListener( lsDef );
wBasicAuthPassword.addSelectionListener( lsDef );
@@ -585,6 +632,8 @@ public void getData()
if (input.getHttpBodyFieldName()!=null) wHttpBodyFieldName.setText(input.getHttpBodyFieldName());
if (input.getHttpReturnCodeFieldName()!=null) wHttpReturnCodeFieldName.setText(input.getHttpReturnCodeFieldName());
+ if (input.getHttpStartTimeFieldName()!=null) wHttpStartTimeFieldName.setText(input.getHttpStartTimeFieldName());
+ if (input.getHttpRequestTimeFieldName()!=null) wHttpRequestTimeFieldName.setText(input.getHttpRequestTimeFieldName());
wFields.setRowNums();
wFields.optWidth(true);
@@ -626,6 +675,8 @@ private void ok()
input.setStrictSSLCheck( wStrictSSLCheck.getSelection() );
input.setHttpBodyFieldName( wHttpBodyFieldName.getText() );
input.setHttpReturnCodeFieldName( wHttpReturnCodeFieldName.getText() );
+ input.setHttpStartTimeFieldName( wHttpStartTimeFieldName.getText() );
+ input.setHttpRequestTimeFieldName( wHttpRequestTimeFieldName.getText() );
stepname = wStepname.getText(); // return value
dispose();
diff --git a/src/com/bpa/pentaho/plugins/AdvancedHTTPMeta.java b/src/com/bpa/pentaho/plugins/AdvancedHTTPMeta.java
index 9a55ebf..4d5a53e 100644
--- a/src/com/bpa/pentaho/plugins/AdvancedHTTPMeta.java
+++ b/src/com/bpa/pentaho/plugins/AdvancedHTTPMeta.java
@@ -32,21 +32,20 @@ public class AdvancedHTTPMeta extends BaseStepMeta implements StepMetaInterface
public static String HTTP_CALL_TYPE_GET = "GET";
public static String HTTP_CALL_TYPE_POST_FORM = "POST x-www-form-urlencoded";
- /** URL / service to be called */
private String url;
- /** function arguments : fieldname*/
private String argumentField[];
- /** IN / OUT / INOUT */
private String argumentParameter[];
- /** function bodyFieldName: new value name */
private String httpBodyFieldName;
- /** function bodyFieldName: new value name */
private String httpReturnCodeFieldName;
-
+
+ private String httpStartTimeFieldName;
+
+ private String httpRequestTimeFieldName;
+
private boolean failOnError;
private boolean strictSSLCheck;
@@ -62,7 +61,7 @@ public class AdvancedHTTPMeta extends BaseStepMeta implements StepMetaInterface
private String basicAuthPassword;
private String httpCallType;
-
+
public AdvancedHTTPMeta()
{
super(); // allocate BaseStepMeta
@@ -149,6 +148,34 @@ public void setHttpReturnCodeFieldName(String httpReturnCodeFieldName)
}
/**
+ * @return the httpStartTimeFieldName
+ */
+ public String getHttpStartTimeFieldName() {
+ return httpStartTimeFieldName;
+ }
+
+ /**
+ * @param httpStartTimeFieldName the httpStartTimeFieldName to set
+ */
+ public void setHttpStartTimeFieldName(String httpStartTimeFieldName) {
+ this.httpStartTimeFieldName = httpStartTimeFieldName;
+ }
+
+ /**
+ * @return the httpRequestTimeFieldName
+ */
+ public String getHttpRequestTimeFieldName() {
+ return httpRequestTimeFieldName;
+ }
+
+ /**
+ * @param httpRequestTimeFieldName the httpRequestTimeFieldName to set
+ */
+ public void setHttpRequestTimeFieldName(String httpRequestTimeFieldName) {
+ this.httpRequestTimeFieldName = httpRequestTimeFieldName;
+ }
+
+ /**
* @return Returns fail on error
*/
public boolean isFailOnError() {
@@ -304,6 +331,8 @@ public void setDefault()
httpBodyFieldName = "http_body"; //$NON-NLS-1$
httpReturnCodeFieldName = "http_return_code"; //$NON-NLS-1$
+ httpStartTimeFieldName = "http_start_time"; //$NON-NLS-1$
+ httpRequestTimeFieldName = "http_request_time"; //$NON-NLS-1$
failOnError = true;
strictSSLCheck = true;
@@ -327,6 +356,16 @@ public void getFields(RowMetaInterface inputRowMeta, String name, RowMetaInterfa
v.setPrecision(0);
inputRowMeta.addValueMeta(v);
}
+ if (!Const.isEmpty(httpStartTimeFieldName))
+ {
+ ValueMetaInterface v = new ValueMeta(httpStartTimeFieldName, ValueMeta.TYPE_DATE);
+ inputRowMeta.addValueMeta(v);
+ }
+ if (!Const.isEmpty(httpRequestTimeFieldName))
+ {
+ ValueMetaInterface v = new ValueMeta(httpRequestTimeFieldName, ValueMeta.TYPE_INTEGER);
+ inputRowMeta.addValueMeta(v);
+ }
}
public String getXML()
@@ -354,13 +393,11 @@ public String getXML()
retval.append(" ").append(Const.CR); //$NON-NLS-1$
- retval.append(" ").append(Const.CR); //$NON-NLS-1$
- retval.append(" ").append(XMLHandler.addTagValue("name", httpBodyFieldName)); //$NON-NLS-1$ //$NON-NLS-2$
- retval.append(" ").append(Const.CR); //$NON-NLS-1$
-
- retval.append(" ").append(Const.CR); //$NON-NLS-1$
- retval.append(" ").append(XMLHandler.addTagValue("name", httpReturnCodeFieldName)); //$NON-NLS-1$ //$NON-NLS-2$
- retval.append(" ").append(Const.CR); //$NON-NLS-1$
+
+ retval.append(" "+XMLHandler.addTagValue("httpBodyFieldName", httpBodyFieldName));
+ retval.append(" "+XMLHandler.addTagValue("httpReturnCodeFieldName", httpReturnCodeFieldName));
+ retval.append(" "+XMLHandler.addTagValue("httpStartTimeFieldName", httpStartTimeFieldName));
+ retval.append(" "+XMLHandler.addTagValue("httpRequestTimeFieldName", httpRequestTimeFieldName));
return retval.toString();
}
@@ -394,8 +431,10 @@ private void readData(Node stepnode, List extends SharedObjectInterface> datab
argumentParameter[i] = XMLHandler.getTagValue(anode, "parameter"); //$NON-NLS-1$
}
- httpBodyFieldName = XMLHandler.getTagValue(stepnode, "http_body_field", "name"); // Optional, can be null //$NON-NLS-1$
- httpReturnCodeFieldName = XMLHandler.getTagValue(stepnode, "http_return_code_field", "name"); // Optional, can be null //$NON-NLS-1$
+ httpBodyFieldName = XMLHandler.getTagValue(stepnode, "httpBodyFieldName");
+ httpReturnCodeFieldName = XMLHandler.getTagValue(stepnode, "httpReturnCodeFieldName");
+ httpStartTimeFieldName = XMLHandler.getTagValue(stepnode, "httpStartTimeFieldName");
+ httpRequestTimeFieldName = XMLHandler.getTagValue(stepnode, "httpRequestTimeFieldName");
}
catch (Exception e)
{
@@ -426,8 +465,10 @@ public void readRep(Repository rep, long id_step, List databases,
argumentParameter[i] = rep.getStepAttributeString(id_step, i, "arg_parameter"); //$NON-NLS-1$
}
- httpBodyFieldName = rep.getStepAttributeString(id_step, "http_body_field_name"); //$NON-NLS-1$
- httpReturnCodeFieldName = rep.getStepAttributeString(id_step, "http_return_code_field_name"); //$NON-NLS-1$
+ httpBodyFieldName = rep.getStepAttributeString(id_step, "httpBodyFieldName"); //$NON-NLS-1$
+ httpReturnCodeFieldName = rep.getStepAttributeString(id_step, "httpReturnCodeFieldName"); //$NON-NLS-1$
+ httpStartTimeFieldName = rep.getStepAttributeString(id_step, "httpStartTimeFieldName"); //$NON-NLS-1$
+ httpRequestTimeFieldName = rep.getStepAttributeString(id_step, "httpStartTimeFieldName"); //$NON-NLS-1$
}
catch (Exception e)
{
@@ -455,8 +496,10 @@ public void saveRep(Repository rep, long id_transformation, long id_step) throws
rep.saveStepAttribute(id_transformation, id_step, i, "arg_parameter", argumentParameter[i]); //$NON-NLS-1$
}
- rep.saveStepAttribute(id_transformation, id_step, "http_body_field_name", httpBodyFieldName); //$NON-NLS-1$
- rep.saveStepAttribute(id_transformation, id_step, "http_return_code_field_name", httpReturnCodeFieldName); //$NON-NLS-1$
+ rep.saveStepAttribute(id_transformation, id_step, "httpBodyFieldName", httpBodyFieldName); //$NON-NLS-1$
+ rep.saveStepAttribute(id_transformation, id_step, "httpReturnCodeFieldName", httpReturnCodeFieldName); //$NON-NLS-1$
+ rep.saveStepAttribute(id_transformation, id_step, "httpStartTimeFieldName", httpStartTimeFieldName); //$NON-NLS-1$
+ rep.saveStepAttribute(id_transformation, id_step, "httpRequestTimeFieldName", httpRequestTimeFieldName); //$NON-NLS-1$
}
catch (Exception e)
{
diff --git a/src/com/bpa/pentaho/plugins/messages/messages_en_US.properties b/src/com/bpa/pentaho/plugins/messages/messages_en_US.properties
index e8395c4..c640015 100644
--- a/src/com/bpa/pentaho/plugins/messages/messages_en_US.properties
+++ b/src/com/bpa/pentaho/plugins/messages/messages_en_US.properties
@@ -10,9 +10,11 @@ AdvancedHTTPDialog.StrictSSLCheck.Label=Strict SSL check?
AdvancedHTTPDialog.UseBasicAuth.Label=Use basic auth
AdvancedHTTPDialog.BasicAuthLogin.Label=BasicAuth login
AdvancedHTTPDialog.BasicAuthPassword.Label=BasicAuth Password
-AdvancedHTTPDialog.HttpBodyFieldName.Label=Http Body fieldname
AdvancedHTTPDialog.HttpCallType.Label=Http Call Type
+AdvancedHTTPDialog.HttpBodyFieldName.Label=Http Body fieldname
AdvancedHTTPDialog.HttpReturnCodeFieldName.Label=Http Return code fieldname
+AdvancedHTTPDialog.HttpStartTimeFieldName.Label=Http Start time fieldname
+AdvancedHTTPDialog.HttpRequestTimeFieldName.Label=Http Request time fieldname
AdvancedHTTPDialog.FailedToGetFields.DialogTitle=Get fields failed
AdvancedHTTPDialog.Shell.Title=HTTP web service
AdvancedHTTP.Log.ConnectedToDB=Connected to database...