diff --git a/plugins/misc/pom.xml b/plugins/misc/pom.xml
index 3e0624b55cc..4c229995a70 100644
--- a/plugins/misc/pom.xml
+++ b/plugins/misc/pom.xml
@@ -38,6 +38,7 @@
reflection
static-schema
testing
+ rest
diff --git a/plugins/misc/rest/pom.xml b/plugins/misc/rest/pom.xml
new file mode 100644
index 00000000000..95c7aca6d8c
--- /dev/null
+++ b/plugins/misc/rest/pom.xml
@@ -0,0 +1,34 @@
+
+
+
+ 4.0.0
+
+ org.apache.hop
+ hop-plugins-misc
+ 2.10.0-SNAPSHOT
+
+
+ rest
+
+
+ 17
+ 17
+ UTF-8
+
+
+
diff --git a/plugins/misc/rest/src/main/java/org/apache/hop/metadata/rest/RestConnection.java b/plugins/misc/rest/src/main/java/org/apache/hop/metadata/rest/RestConnection.java
new file mode 100644
index 00000000000..b4bf06eec38
--- /dev/null
+++ b/plugins/misc/rest/src/main/java/org/apache/hop/metadata/rest/RestConnection.java
@@ -0,0 +1,165 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.hop.metadata.rest;
+
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.client.Invocation;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.Response;
+import org.apache.commons.lang.StringUtils;
+import org.apache.hop.core.exception.HopException;
+import org.apache.hop.metadata.api.HopMetadata;
+import org.apache.hop.metadata.api.HopMetadataBase;
+import org.apache.hop.metadata.api.HopMetadataProperty;
+import org.apache.hop.metadata.api.IHopMetadata;
+
+@HopMetadata(
+ key = "restconnection",
+ name = "i18n::RestConnection.name",
+ description = "i18n::RestConnection.description",
+ image = "",
+ documentationUrl = "")
+public class RestConnection extends HopMetadataBase implements IHopMetadata {
+
+ private ClientBuilder builder;
+ private Client client;
+
+ @HopMetadataProperty(key = "base_url", injectionKey = "BASE_URL")
+ private String baseUrl;
+
+ @HopMetadataProperty(key = "test_url", injectionKey = "TEST_URL")
+ private String testUrl;
+
+ @HopMetadataProperty(key = "auth_header_name", injectionKey = "AUTH_HEADER_NAME")
+ private String authorizationHeaderName;
+
+ @HopMetadataProperty(key = "auth_header_prefix", injectionKey = "AUTH_HEADER_PREFIX")
+ private String authorizationPrefix;
+
+ @HopMetadataProperty(key = "auth_header_value", injectionKey = "AUTH_HEADER_VALUE")
+ private String authorizationHeaderValue;
+
+ public RestConnection() {
+ builder = ClientBuilder.newBuilder();
+ client = builder.build();
+ }
+
+ public RestConnection(RestConnection connection) {
+ this.baseUrl = connection.baseUrl;
+ }
+
+ @Override
+ public String toString() {
+ return name == null ? super.toString() : name;
+ }
+
+ @Override
+ public int hashCode() {
+ return name == null ? super.hashCode() : name.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object object) {
+
+ if (object == this) {
+ return true;
+ }
+ if (!(object instanceof RestConnection)) {
+ return false;
+ }
+
+ RestConnection connection = (RestConnection) object;
+
+ return name != null && name.equalsIgnoreCase(connection.name);
+ }
+
+ /**
+ * Gets name
+ *
+ * @return value of name
+ */
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param name The name to set
+ */
+ @Override
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getBaseUrl() {
+ return baseUrl;
+ }
+
+ public void setBaseUrl(String baseUrl) {
+ this.baseUrl = baseUrl;
+ }
+
+ public String getTestUrl() {
+ return testUrl;
+ }
+
+ public void setTestUrl(String testUrl) {
+ this.testUrl = testUrl;
+ }
+
+ public String getAuthorizationHeaderName() {
+ return authorizationHeaderName;
+ }
+
+ public void setAuthorizationHeaderName(String authorizationHeaderName) {
+ this.authorizationHeaderName = authorizationHeaderName;
+ }
+
+ public String getAuthHeaderPrefix() {
+ return authorizationPrefix;
+ }
+
+ public void setAuthHeaderPrefix(String authHeaderPrefix) {
+ this.authorizationPrefix = authHeaderPrefix;
+ }
+
+ public String getAuthorizationHeaderValue() {
+ return authorizationHeaderValue;
+ }
+
+ public void setAuthorizationHeaderValue(String authorizationHeaderValue) {
+ this.authorizationHeaderValue = authorizationHeaderValue;
+ }
+
+ public void testConnection() throws HopException {
+ WebTarget target = client.target(testUrl);
+ Invocation.Builder invocationBuilder = target.request();
+ if (!StringUtils.isEmpty(authorizationPrefix)) {
+ invocationBuilder.header(
+ authorizationHeaderName, authorizationPrefix + " " + authorizationHeaderValue);
+ } else {
+ invocationBuilder.header(authorizationHeaderName, authorizationHeaderValue);
+ }
+ Response response = invocationBuilder.get();
+ if (response.getStatus() != Response.Status.OK.getStatusCode()) {
+ throw new HopException("Error connecting to " + testUrl + ": " + response.getStatus());
+ }
+ response.close();
+ }
+}
diff --git a/plugins/misc/rest/src/main/java/org/apache/hop/metadata/rest/RestConnectionEditor.java b/plugins/misc/rest/src/main/java/org/apache/hop/metadata/rest/RestConnectionEditor.java
new file mode 100644
index 00000000000..fd14bd28a94
--- /dev/null
+++ b/plugins/misc/rest/src/main/java/org/apache/hop/metadata/rest/RestConnectionEditor.java
@@ -0,0 +1,249 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.hop.metadata.rest;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.hop.core.Const;
+import org.apache.hop.core.variables.IVariables;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.ui.core.PropsUi;
+import org.apache.hop.ui.core.dialog.ErrorDialog;
+import org.apache.hop.ui.core.dialog.MessageBox;
+import org.apache.hop.ui.core.metadata.MetadataEditor;
+import org.apache.hop.ui.core.metadata.MetadataManager;
+import org.apache.hop.ui.core.widget.PasswordTextVar;
+import org.apache.hop.ui.core.widget.TextVar;
+import org.apache.hop.ui.hopgui.HopGui;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+public class RestConnectionEditor extends MetadataEditor {
+ private static final Class> PKG = RestConnectionEditor.class;
+
+ private Text wName;
+
+ private TextVar wBaseUrl;
+ private TextVar wTestUrl;
+ private TextVar wAuthorizationName;
+ private TextVar wAuthorizationPrefix;
+ private PasswordTextVar wAuthorizationValue;
+
+ public RestConnectionEditor(
+ HopGui hopGui, MetadataManager manager, RestConnection restConnection) {
+ super(hopGui, manager, restConnection);
+ }
+
+ @Override
+ public void createControl(Composite composite) {
+ PropsUi props = PropsUi.getInstance();
+
+ int middle = props.getMiddlePct();
+ int margin = props.getMargin();
+
+ IVariables variables = hopGui.getVariables();
+
+ // The name
+ Label wlName = new Label(composite, SWT.RIGHT);
+ PropsUi.setLook(wlName);
+ wlName.setText(BaseMessages.getString(PKG, "RestConnectionEditor.Name"));
+ FormData fdlName = new FormData();
+ fdlName.top = new FormAttachment(0, margin);
+ fdlName.left = new FormAttachment(0, 0); // First one in the left top corner
+ fdlName.right = new FormAttachment(middle, -margin);
+ wlName.setLayoutData(fdlName);
+ wName = new Text(composite, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
+ PropsUi.setLook(wName);
+ FormData fdName = new FormData();
+ fdName.top = new FormAttachment(wlName, 0, SWT.CENTER);
+ fdName.left = new FormAttachment(middle, 0); // To the right of the label
+ fdName.right = new FormAttachment(95, 0);
+ wName.setLayoutData(fdName);
+ Control lastControl = wName;
+
+ Label wlBaseUrl = new Label(composite, SWT.RIGHT);
+ PropsUi.setLook(wlBaseUrl);
+ wlBaseUrl.setText(BaseMessages.getString(PKG, "RestConnectionEditor.BaseUrl"));
+ FormData fdlBaseUrl = new FormData();
+ fdlBaseUrl.top = new FormAttachment(lastControl, margin);
+ fdlBaseUrl.left = new FormAttachment(0, 0);
+ fdlBaseUrl.right = new FormAttachment(middle, -margin);
+ wlBaseUrl.setLayoutData(fdlBaseUrl);
+ wBaseUrl = new TextVar(variables, composite, SWT.SINGLE | SWT.LEFT);
+ PropsUi.setLook(wBaseUrl);
+ FormData fdBaseUrl = new FormData();
+ fdBaseUrl.top = new FormAttachment(wlBaseUrl, 0, SWT.CENTER);
+ fdBaseUrl.left = new FormAttachment(middle, 0);
+ fdBaseUrl.right = new FormAttachment(95, 0);
+ wBaseUrl.setLayoutData(fdBaseUrl);
+ lastControl = wBaseUrl;
+
+ Label wlTestUrl = new Label(composite, SWT.RIGHT);
+ PropsUi.setLook(wlTestUrl);
+ wlTestUrl.setText(BaseMessages.getString(PKG, "RestConnectionEditor.TestUrl"));
+ FormData fdlTestUrl = new FormData();
+ fdlTestUrl.top = new FormAttachment(lastControl, margin);
+ fdlTestUrl.left = new FormAttachment(0, 0);
+ fdlTestUrl.right = new FormAttachment(middle, -margin);
+ wlTestUrl.setLayoutData(fdlTestUrl);
+ wTestUrl = new TextVar(variables, composite, SWT.SINGLE | SWT.LEFT);
+ PropsUi.setLook(wTestUrl);
+ FormData fdTestUrl = new FormData();
+ fdTestUrl.top = new FormAttachment(wlTestUrl, 0, SWT.CENTER);
+ fdTestUrl.left = new FormAttachment(middle, 0);
+ fdTestUrl.right = new FormAttachment(95, 0);
+ wTestUrl.setLayoutData(fdTestUrl);
+ lastControl = wTestUrl;
+
+ Label wlAuthorizationName = new Label(composite, SWT.RIGHT);
+ PropsUi.setLook(wlAuthorizationName);
+ wlAuthorizationName.setText(
+ BaseMessages.getString(PKG, "RestConnectionEditor.AuthorizationName"));
+ FormData fdlAuthorizationName = new FormData();
+ fdlAuthorizationName.top = new FormAttachment(lastControl, margin);
+ fdlAuthorizationName.left = new FormAttachment(0, 0);
+ fdlAuthorizationName.right = new FormAttachment(middle, -margin);
+ wlAuthorizationName.setLayoutData(fdlAuthorizationName);
+ wAuthorizationName = new TextVar(variables, composite, SWT.SINGLE | SWT.LEFT);
+ PropsUi.setLook(wAuthorizationName);
+ FormData fdAuthorizationName = new FormData();
+ fdAuthorizationName.top = new FormAttachment(wlAuthorizationName, 0, SWT.CENTER);
+ fdAuthorizationName.left = new FormAttachment(middle, 0);
+ fdAuthorizationName.right = new FormAttachment(95, 0);
+ wAuthorizationName.setLayoutData(fdAuthorizationName);
+ lastControl = wAuthorizationName;
+
+ Label wlAuthorizationPrefix = new Label(composite, SWT.RIGHT);
+ PropsUi.setLook(wlAuthorizationPrefix);
+ wlAuthorizationPrefix.setText(
+ BaseMessages.getString(PKG, "RestConnectionEditor.AuthorizationPrefix"));
+ FormData fdlAuthorizationPrefix = new FormData();
+ fdlAuthorizationPrefix.top = new FormAttachment(lastControl, margin);
+ fdlAuthorizationPrefix.left = new FormAttachment(0, 0);
+ fdlAuthorizationPrefix.right = new FormAttachment(middle, -margin);
+ wlAuthorizationPrefix.setLayoutData(fdlAuthorizationPrefix);
+
+ wAuthorizationPrefix = new TextVar(variables, composite, SWT.SINGLE | SWT.LEFT);
+ PropsUi.setLook(wAuthorizationPrefix);
+ FormData fdAuthorizationPrefix = new FormData();
+ fdAuthorizationPrefix.top = new FormAttachment(wlAuthorizationPrefix, 0, SWT.CENTER);
+ fdAuthorizationPrefix.left = new FormAttachment(middle, 0);
+ fdAuthorizationPrefix.right = new FormAttachment(95, 0);
+ wAuthorizationPrefix.setLayoutData(fdAuthorizationPrefix);
+ lastControl = wAuthorizationPrefix;
+
+ Label wlAuthorizationValue = new Label(composite, SWT.RIGHT);
+ PropsUi.setLook(wlAuthorizationValue);
+ wlAuthorizationValue.setText(
+ BaseMessages.getString(PKG, "RestConnectionEditor.AuthorizationValue"));
+ FormData fdlAuthorizationValue = new FormData();
+ fdlAuthorizationValue.top = new FormAttachment(lastControl, margin);
+ fdlAuthorizationValue.left = new FormAttachment(0, 0);
+ fdlAuthorizationValue.right = new FormAttachment(middle, -margin);
+ wlAuthorizationValue.setLayoutData(fdlAuthorizationValue);
+ wAuthorizationValue = new PasswordTextVar(variables, composite, SWT.SINGLE | SWT.LEFT);
+ PropsUi.setLook(wAuthorizationValue);
+ FormData fdAuthorizationValue = new FormData();
+ fdAuthorizationValue.top = new FormAttachment(wlAuthorizationValue, 0, SWT.CENTER);
+ fdAuthorizationValue.left = new FormAttachment(middle, 0);
+ fdAuthorizationValue.right = new FormAttachment(95, 0);
+ wAuthorizationValue.setLayoutData(fdAuthorizationValue);
+ lastControl = wAuthorizationValue;
+
+ setWidgetsContent();
+
+ Control[] controls = {wName, wAuthorizationName, wAuthorizationValue, wBaseUrl, wTestUrl};
+ for (Control control : controls) {
+ control.addListener(SWT.Modify, e -> setChanged());
+ control.addListener(SWT.Selection, e -> setChanged());
+ }
+ }
+
+ @Override
+ public Button[] createButtonsForButtonBar(Composite composite) {
+ Button wTest = new Button(composite, SWT.PUSH);
+ wTest.setText(BaseMessages.getString(PKG, "System.Button.Test"));
+ wTest.addListener(SWT.Selection, e -> test());
+
+ return new Button[] {wTest};
+ }
+
+ private void test() {
+ IVariables variables = hopGui.getVariables();
+ RestConnection restConnection = new RestConnection();
+ restConnection.setName(wName.getText());
+ if (StringUtils.isEmpty(wTestUrl.getText())) {
+ restConnection.setTestUrl(wBaseUrl.getText());
+ }
+ restConnection.setBaseUrl(wBaseUrl.getText());
+ restConnection.setTestUrl(wTestUrl.getText());
+ restConnection.setAuthorizationHeaderName(wAuthorizationName.getText());
+ restConnection.setAuthHeaderPrefix(wAuthorizationPrefix.getText());
+ restConnection.setAuthorizationHeaderValue(wAuthorizationValue.getText());
+ try {
+ restConnection.testConnection();
+ MessageBox box = new MessageBox(hopGui.getShell(), SWT.OK);
+ box.setText("OK");
+ String message =
+ BaseMessages.getString(PKG, "RestConnectionEditor.ConnectionTestSuccess") + Const.CR;
+ message += Const.CR;
+ message += "URL : " + wTestUrl.getText();
+ box.setMessage(message);
+ box.open();
+ } catch (Exception e) {
+ new ErrorDialog(
+ hopGui.getShell(), "Error", "Error connecting to REST URL : " + wTestUrl.getText(), e);
+ }
+ }
+
+ @Override
+ public void dispose() {}
+
+ @Override
+ public void setWidgetsContent() {
+ wName.setText(Const.NVL(metadata.getName(), ""));
+ wBaseUrl.setText(Const.NVL(metadata.getBaseUrl(), ""));
+ wTestUrl.setText(Const.NVL(metadata.getTestUrl(), ""));
+ wAuthorizationName.setText(Const.NVL(metadata.getAuthorizationHeaderName(), ""));
+ wAuthorizationPrefix.setText(Const.NVL(metadata.getAuthHeaderPrefix(), ""));
+ wAuthorizationValue.setText(Const.NVL(metadata.getAuthorizationHeaderValue(), ""));
+ }
+
+ @Override
+ public void getWidgetsContent(RestConnection connection) {
+ connection.setName(wName.getText());
+ connection.setBaseUrl(wBaseUrl.getText());
+ connection.setTestUrl(wTestUrl.getText());
+ connection.setAuthorizationHeaderName(wAuthorizationName.getText());
+ connection.setAuthHeaderPrefix(wAuthorizationPrefix.getText());
+ connection.setAuthorizationHeaderValue(wAuthorizationValue.getText());
+ }
+
+ @Override
+ public boolean setFocus() {
+ if (wName == null || wName.isDisposed()) {
+ return false;
+ }
+ return wName.setFocus();
+ }
+}
diff --git a/plugins/misc/rest/src/main/java/org/apache/hop/metadata/rest/ui/RestConnectionLine.java b/plugins/misc/rest/src/main/java/org/apache/hop/metadata/rest/ui/RestConnectionLine.java
new file mode 100644
index 00000000000..28211abe20d
--- /dev/null
+++ b/plugins/misc/rest/src/main/java/org/apache/hop/metadata/rest/ui/RestConnectionLine.java
@@ -0,0 +1,12 @@
+package org.apache.hop.metadata.rest.ui;
+
+import org.eclipse.swt.widgets.Composite;
+
+public class RestConnectionLine extends Composite {
+
+ public RestConnectionLine(Composite parent, int style) {
+ super(parent, style);
+
+
+ }
+}
diff --git a/plugins/misc/rest/src/main/resources/org/apache/hop/metadata/rest/messages/messages_en_US.properties b/plugins/misc/rest/src/main/resources/org/apache/hop/metadata/rest/messages/messages_en_US.properties
new file mode 100644
index 00000000000..762152f1b21
--- /dev/null
+++ b/plugins/misc/rest/src/main/resources/org/apache/hop/metadata/rest/messages/messages_en_US.properties
@@ -0,0 +1,26 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+#
+
+RestConnection.name=Rest Connection
+RestConnection.description=Connects to a REST API
+RestConnectionEditor.Name=REST Connection name
+RestConnectionEditor.BaseUrl=Base URL
+RestConnectionEditor.TestUrl=Test URL
+RestConnectionEditor.AuthorizationName=Authorization header name
+RestConnectionEditor.AuthorizationValue=Authorization header value
+RestConnectionEditor.AuthorizationPrefix=Authorization prefix
+RestConnectionEditor.ConnectionTestSuccess=Successfully connected to
\ No newline at end of file
diff --git a/plugins/misc/rest/src/test/java/org/apache/hop/metadata/rest/RestTest.java b/plugins/misc/rest/src/test/java/org/apache/hop/metadata/rest/RestTest.java
new file mode 100644
index 00000000000..25f4150f661
--- /dev/null
+++ b/plugins/misc/rest/src/test/java/org/apache/hop/metadata/rest/RestTest.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.hop.metadata.rest;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+public class RestTest {
+
+ @Test
+ @Disabled
+ public void testRestConnection() {
+ RestConnection restConnection = new RestConnection();
+ restConnection.setBaseUrl("");
+ restConnection.setTestUrl("");
+ restConnection.setAuthorizationHeaderName("authorization");
+ restConnection.setAuthorizationHeaderValue("Bearer " + "");
+
+ assertDoesNotThrow(restConnection::testConnection);
+ }
+}
diff --git a/plugins/transforms/rest/pom.xml b/plugins/transforms/rest/pom.xml
index 55116f56d98..c1122565d33 100644
--- a/plugins/transforms/rest/pom.xml
+++ b/plugins/transforms/rest/pom.xml
@@ -30,6 +30,11 @@
Hop Plugins Transforms REST
+
+ org.apache.hop
+ rest
+ ${version}
+
org.glassfish.jersey.connectors
jersey-apache-connector
diff --git a/plugins/transforms/rest/src/main/java/org/apache/hop/pipeline/transforms/rest/RestDialog.java b/plugins/transforms/rest/src/main/java/org/apache/hop/pipeline/transforms/rest/RestDialog.java
index 7a1c5253193..b3f0425aafa 100644
--- a/plugins/transforms/rest/src/main/java/org/apache/hop/pipeline/transforms/rest/RestDialog.java
+++ b/plugins/transforms/rest/src/main/java/org/apache/hop/pipeline/transforms/rest/RestDialog.java
@@ -26,6 +26,7 @@
import org.apache.hop.core.util.Utils;
import org.apache.hop.core.variables.IVariables;
import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.metadata.rest.RestConnection;
import org.apache.hop.pipeline.PipelineMeta;
import org.apache.hop.pipeline.transform.TransformMeta;
import org.apache.hop.ui.core.PropsUi;
@@ -34,6 +35,7 @@
import org.apache.hop.ui.core.gui.GuiResource;
import org.apache.hop.ui.core.widget.ColumnInfo;
import org.apache.hop.ui.core.widget.ComboVar;
+import org.apache.hop.ui.core.widget.MetaSelectionLine;
import org.apache.hop.ui.core.widget.PasswordTextVar;
import org.apache.hop.ui.core.widget.TableView;
import org.apache.hop.ui.core.widget.TextVar;
@@ -59,12 +61,16 @@
public class RestDialog extends BaseTransformDialog {
private static final Class> PKG = RestMeta.class;
+ public static final String CONST_ERROR = "Error";
+
private ComboVar wApplicationType;
private Label wlMethod;
+
private ComboVar wMethod;
private Label wlUrl;
+
private TextVar wUrl;
private TextVar wResult;
@@ -76,6 +82,7 @@ public class RestDialog extends BaseTransformDialog {
private Button wUrlInField;
private Label wlUrlField;
+
private ComboVar wUrlField;
private Button wMethodInField;
@@ -83,6 +90,7 @@ public class RestDialog extends BaseTransformDialog {
private Button wPreemptive;
private Label wlMethodField;
+
private ComboVar wMethodField;
private final RestMeta input;
@@ -90,9 +98,11 @@ public class RestDialog extends BaseTransformDialog {
private final List inputFields = new ArrayList<>();
private Label wlBody;
+
private ComboVar wBody;
private ColumnInfo[] colinf;
+
private ColumnInfo[] colinfoparams;
private TextVar wConnectionTimeout;
@@ -108,11 +118,15 @@ public class RestDialog extends BaseTransformDialog {
private TextVar wProxyPort;
private Label wlParameters;
+
private Label wlMatrixParameters;
+
private TableView wParameters;
+
private TableView wMatrixParameters;
private TextVar wResponseTime;
+
private TextVar wResponseHeader;
private TextVar wTrustStorePassword;
@@ -125,6 +139,8 @@ public class RestDialog extends BaseTransformDialog {
private Button wMatrixGet;
+ private MetaSelectionLine wSelectionLine;
+
public RestDialog(
Shell parent, IVariables variables, RestMeta transformMeta, PipelineMeta pipelineMeta) {
super(parent, variables, transformMeta, pipelineMeta);
@@ -180,6 +196,7 @@ public String open() {
Group gSettings = setupSettingGroup(wGeneralComp);
+ setupRestConnectionLine(lsMod, middle, margin, wGeneralComp, gSettings);
setupUrlLine(lsMod, middle, margin, wGeneralComp, gSettings);
setupUrlInFieldLine(middle, margin, gSettings);
setupUrlFieldNameLine(lsMod, middle, margin, gSettings);
@@ -1174,15 +1191,41 @@ public void widgetSelected(SelectionEvent e) {
});
}
+ private void setupRestConnectionLine(
+ ModifyListener lsMod, int middle, int margin, Composite wGeneralComp, Group gSettings) {
+
+ wSelectionLine =
+ new MetaSelectionLine(
+ variables,
+ metadataProvider,
+ RestConnection.class,
+ gSettings,
+ SWT.SINGLE | SWT.LEFT | SWT.BORDER,
+ "REST Connection",
+ "The name of the REST connection to use.");
+ PropsUi.setLook(wSelectionLine);
+ FormData fdSelectionLine = new FormData();
+ fdSelectionLine.left = new FormAttachment(0, 0);
+ fdSelectionLine.top = new FormAttachment(wGeneralComp, margin);
+ fdSelectionLine.right = new FormAttachment(100, -margin);
+ wSelectionLine.setLayoutData(fdSelectionLine);
+ try {
+ wSelectionLine.fillItems();
+ } catch (Exception e) {
+ new ErrorDialog(shell, CONST_ERROR, "Error getting list of REST connections", e);
+ }
+ }
+
private void setupUrlLine(
ModifyListener lsMod, int middle, int margin, Composite wGeneralComp, Group gSettings) {
+
wlUrl = new Label(gSettings, SWT.RIGHT);
wlUrl.setText(BaseMessages.getString(PKG, "RestDialog.URL.Label"));
PropsUi.setLook(wlUrl);
FormData fdlUrl = new FormData();
fdlUrl.left = new FormAttachment(0, 0);
fdlUrl.right = new FormAttachment(middle, -margin);
- fdlUrl.top = new FormAttachment(wGeneralComp, margin * 2);
+ fdlUrl.top = new FormAttachment(wSelectionLine, margin * 2);
wlUrl.setLayoutData(fdlUrl);
wUrl = new TextVar(variables, gSettings, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
@@ -1190,7 +1233,7 @@ private void setupUrlLine(
wUrl.addModifyListener(lsMod);
FormData fdUrl = new FormData();
fdUrl.left = new FormAttachment(middle, 0);
- fdUrl.top = new FormAttachment(wGeneralComp, margin * 2);
+ fdUrl.top = new FormAttachment(wSelectionLine, margin * 2);
fdUrl.right = new FormAttachment(100, 0);
wUrl.setLayoutData(fdUrl);
}