This is an automated email from the ASF dual-hosted git repository.

hansva pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/hop.git


The following commit(s) were added to refs/heads/main by this push:
     new 057068f8f8 Add a test button for hop-server to metadata item, fixes 
#2520 (#7554)
057068f8f8 is described below

commit 057068f8f8f4b87572132efb1dab2fc9bc394469
Author: Hans Van Akelyen <[email protected]>
AuthorDate: Fri Jul 17 14:20:07 2026 +0200

    Add a test button for hop-server to metadata item, fixes #2520 (#7554)
---
 .../apache/hop/ui/server/HopServerMetaEditor.java  | 53 +++++++++++++---------
 .../ui/server/messages/messages_en_US.properties   |  5 ++
 2 files changed, 36 insertions(+), 22 deletions(-)

diff --git a/ui/src/main/java/org/apache/hop/ui/server/HopServerMetaEditor.java 
b/ui/src/main/java/org/apache/hop/ui/server/HopServerMetaEditor.java
index 19e6d7fe5b..2d95c2a52b 100644
--- a/ui/src/main/java/org/apache/hop/ui/server/HopServerMetaEditor.java
+++ b/ui/src/main/java/org/apache/hop/ui/server/HopServerMetaEditor.java
@@ -22,15 +22,16 @@ import org.apache.hop.core.Props;
 import org.apache.hop.i18n.BaseMessages;
 import org.apache.hop.server.HopServerMeta;
 import org.apache.hop.ui.core.PropsUi;
-import org.apache.hop.ui.core.dialog.EnterTextDialog;
 import org.apache.hop.ui.core.dialog.ErrorDialog;
+import org.apache.hop.ui.core.dialog.ShowMessageDialog;
 import org.apache.hop.ui.core.gui.GuiResource;
 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.apache.hop.www.RegisterPipelineServlet;
+import org.apache.hop.www.GetStatusServlet;
+import org.apache.hop.www.HopServerStatus;
 import org.apache.hop.www.RemoteHopServer;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.custom.CTabFolder;
@@ -427,6 +428,19 @@ public class HopServerMetaEditor extends 
MetadataEditor<HopServerMeta> {
     return wName.setFocus();
   }
 
+  @Override
+  public Button[] createButtonsForButtonBar(Composite parent) {
+    Button wTest = new Button(parent, SWT.PUSH);
+    wTest.setText(BaseMessages.getString(PKG, "System.Button.Test"));
+    wTest.addListener(SWT.Selection, e -> test());
+
+    return new Button[] {wTest};
+  }
+
+  /**
+   * Ask the server for its status. That covers everything needed to reach it: 
the hostname, the
+   * port, the web app name, the protocol, the proxy and the credentials.
+   */
   public void test() {
 
     HopServerMeta serverMeta = getMetadata();
@@ -434,38 +448,33 @@ public class HopServerMetaEditor extends 
MetadataEditor<HopServerMeta> {
     getWidgetsContent(serverMeta);
 
     RemoteHopServer server = new RemoteHopServer(serverMeta);
+    String url = "";
 
     try {
-      String xml = "<sample/>";
-      String reply =
-          server.sendXml(manager.getVariables(), xml, 
RegisterPipelineServlet.CONTEXT_PATH);
+      url = server.constructUrl(manager.getVariables(), 
GetStatusServlet.CONTEXT_PATH);
+      HopServerStatus status = 
server.requestServerStatus(manager.getVariables());
 
       String message =
-          BaseMessages.getString(PKG, "HopServer.Replay.Info1")
-              + server.constructUrl(manager.getVariables(), 
RegisterPipelineServlet.CONTEXT_PATH)
+          BaseMessages.getString(PKG, 
"HopServer.TestConnection.Success.Message", url)
               + Const.CR
-              + BaseMessages.getString(PKG, "HopServer.Replay.Info2")
               + Const.CR
-              + Const.CR;
-      message += xml;
-      message += Const.CR + Const.CR;
-      message += "Reply was:" + Const.CR + Const.CR;
-      message += reply + Const.CR;
-
-      EnterTextDialog dialog =
-          new EnterTextDialog(
+              + BaseMessages.getString(
+                  PKG,
+                  "HopServer.TestConnection.Success.Status",
+                  Const.NVL(status.getStatusDescription(), ""));
+
+      ShowMessageDialog dialog =
+          new ShowMessageDialog(
               getShell(),
-              "XML",
-              BaseMessages.getString(PKG, "HopServer.RetournedXMLInfo"),
+              SWT.ICON_INFORMATION | SWT.OK | SWT.APPLICATION_MODAL,
+              BaseMessages.getString(PKG, 
"HopServer.TestConnection.Success.Title"),
               message);
       dialog.open();
     } catch (Exception e) {
       new ErrorDialog(
           getShell(),
-          BaseMessages.getString(PKG, "HopServer.ExceptionError"),
-          BaseMessages.getString(PKG, 
"HopServer.ExceptionUnableGetReplay.Error1")
-              + getVariables().resolve(serverMeta.getHostname())
-              + BaseMessages.getString(PKG, 
"HopServer.ExceptionUnableGetReplay.Error2"),
+          BaseMessages.getString(PKG, 
"HopServer.TestConnection.Failure.Title"),
+          BaseMessages.getString(PKG, 
"HopServer.TestConnection.Failure.Message", url),
           e);
     }
   }
diff --git 
a/ui/src/main/resources/org/apache/hop/ui/server/messages/messages_en_US.properties
 
b/ui/src/main/resources/org/apache/hop/ui/server/messages/messages_en_US.properties
index bbb1053c06..0ce0351718 100644
--- 
a/ui/src/main/resources/org/apache/hop/ui/server/messages/messages_en_US.properties
+++ 
b/ui/src/main/resources/org/apache/hop/ui/server/messages/messages_en_US.properties
@@ -22,6 +22,11 @@ HopServer.ExceptionUnableGetReplay.Error2=]
 HopServer.Replay.Info1=Testing reply from server URL:
 HopServer.Replay.Info2=Using content:
 HopServer.RetournedXMLInfo=The XML returned is:
+HopServer.TestConnection.Failure.Message=Unable to reach the Hop server at 
[{0}]
+HopServer.TestConnection.Failure.Title=Connection test failed
+HopServer.TestConnection.Success.Message=The Hop server at [{0}] was reached 
successfully.
+HopServer.TestConnection.Success.Status=The server reports its status as: {0}
+HopServer.TestConnection.Success.Title=Connection test successful
 HopServerDialog.HostIP.Label=Hostname or IP address
 HopServerDialog.IgnoreProxyForHosts.Label=Ignore proxy for hosts: regexp | 
separated
 HopServerDialog.Password.Label=Password

Reply via email to