[rhq] Branch 'rhq-on-as7' - modules/enterprise

mazz mazz at fedoraproject.org
Fri Aug 3 23:46:47 UTC 2012


 modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/client/Installer.java                       |   58 ++-
 modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/client/gwt/InstallerGWTService.java         |   18 -
 modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/client/shared/ServerDetails.java            |   10 
 modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/client/shared/ServerProperties.java         |  160 +++++++++-
 modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/InstallerGWTServiceImpl.java |  121 +++++++
 modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/ServerInstallUtil.java       |   14 
 modules/enterprise/gui/installer/src/main/resources/org/rhq/enterprise/gui/installer/client/Messages.properties             |    2 
 7 files changed, 332 insertions(+), 51 deletions(-)

New commits:
commit 2797300b5cc92321c226f8f61d96f2559305c1a2
Author: John Mazzitelli <mazz at redhat.com>
Date:   Fri Aug 3 19:46:40 2012 -0400

    more on the new installer

diff --git a/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/client/Installer.java b/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/client/Installer.java
index ca9f9fe..3df3460 100644
--- a/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/client/Installer.java
+++ b/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/client/Installer.java
@@ -55,6 +55,8 @@ import com.smartgwt.client.widgets.grid.ListGrid;
 import com.smartgwt.client.widgets.grid.ListGridField;
 import com.smartgwt.client.widgets.grid.events.EditCompleteEvent;
 import com.smartgwt.client.widgets.grid.events.EditCompleteHandler;
+import com.smartgwt.client.widgets.grid.events.EditorExitEvent;
+import com.smartgwt.client.widgets.grid.events.EditorExitHandler;
 import com.smartgwt.client.widgets.layout.VLayout;
 import com.smartgwt.client.widgets.tab.Tab;
 import com.smartgwt.client.widgets.tab.TabSet;
@@ -200,7 +202,17 @@ public class Installer implements EntryPoint {
         installButton.setDisabled(true); // we can't allow the user to install yet
         installButton.addClickHandler(new ClickHandler() {
             public void onClick(ClickEvent event) {
-                SC.say("TODO: this should start the install");
+                installerService.install(serverProperties.getMap(), new AsyncCallback<Void>() {
+                    @Override
+                    public void onSuccess(Void result) {
+                        SC.say("TODO: the installer should do something");
+                    }
+
+                    @Override
+                    public void onFailure(Throwable caught) {
+                        SC.say("The installation failed - " + caught.toString());
+                    }
+                });
             }
         });
 
@@ -238,22 +250,6 @@ public class Installer implements EntryPoint {
         ToolStrip strip = new ToolStrip();
         strip.setWidth100();
 
-        IButton saveButton = new IButton(MSG.button_save());
-        saveButton.addClickHandler(new ClickHandler() {
-            public void onClick(ClickEvent event) {
-                installerService.saveServerProperties(serverProperties.getMap(), new AsyncCallback<Void>() {
-                    public void onSuccess(Void result) {
-                        originalProperties.clear();
-                        originalProperties.putAll(serverProperties.getMap());
-                        SC.say("Properties saved to server");
-                    }
-
-                    public void onFailure(Throwable caught) {
-                        SC.say("Failed to save properties to server");
-                    }
-                });
-            }
-        });
         IButton resetButton = new IButton(MSG.button_reset());
         resetButton.addClickHandler(new ClickHandler() {
             public void onClick(ClickEvent event) {
@@ -263,7 +259,6 @@ public class Installer implements EntryPoint {
                 forceAnotherTestConnection();
             }
         });
-        strip.addMember(saveButton);
         strip.addMember(resetButton);
         layout.addMember(strip);
 
@@ -281,10 +276,31 @@ public class Installer implements EntryPoint {
 
         advancedPropertyItemGrid.setFields(nameField, valueField);
         advancedPropertyItemGrid.setSortField(ServerPropertyRecordList.PROPERTY_NAME);
-
+        advancedPropertyItemGrid.addEditorExitHandler(new EditorExitHandler() {
+            public void onEditorExit(EditorExitEvent event) {
+                String changedProperty = event.getRecord().getAttribute(ServerPropertyRecordList.PROPERTY_NAME);
+                if (ServerProperties.BOOLEAN_PROPERTIES.contains(changedProperty)) {
+                    String newValue = event.getNewValue().toString();
+                    if (!(newValue.equals("true") || newValue.equals("false"))) {
+                        event.cancel();
+                        advancedPropertyItemGrid.setFieldError(event.getRowNum(),
+                            ServerPropertyRecordList.PROPERTY_VALUE, MSG.message_notValidBoolean());
+                    }
+                } else if (ServerProperties.INTEGER_PROPERTIES.contains(changedProperty)) {
+                    String newValue = event.getNewValue().toString();
+                    try {
+                        Integer.parseInt(newValue);
+                    } catch (NumberFormatException e) {
+                        event.cancel();
+                        advancedPropertyItemGrid.setFieldError(event.getRowNum(),
+                            ServerPropertyRecordList.PROPERTY_VALUE, MSG.message_notValidInteger());
+                    }
+                }
+            }
+        });
         advancedPropertyItemGrid.addEditCompleteHandler(new EditCompleteHandler() {
             public void onEditComplete(EditCompleteEvent event) {
-                String newValue = (String) event.getNewValues().values().iterator().next().toString();
+                String newValue = event.getNewValues().values().iterator().next().toString();
                 String changedProperty = event.getOldRecord().getAttribute(ServerPropertyRecordList.PROPERTY_NAME);
                 serverProperties.getMap().put(changedProperty, newValue); // so this is reflected in the internal map
                 refreshSimpleView();
@@ -426,7 +442,7 @@ public class Installer implements EntryPoint {
                 updateServerProperty(ServerProperties.PROP_QUARTZ_DRIVER_DELEGATE_CLASS, quartzDriverDelegateClass);
                 updateServerProperty(ServerProperties.PROP_QUARTZ_SELECT_WITH_LOCK_SQL, quartzSelectWithLockSQL);
                 updateServerProperty(ServerProperties.PROP_QUARTZ_LOCK_HANDLER_CLASS, quartzLockHandlerClass);
-                updateServerProperty(ServerProperties.PROP_DATABASE_TYPE, newDBType); // this refreshes the advanced view, too
+                updateServerProperty(ServerProperties.PROP_DATABASE_TYPE, newDBType);
             }
         });
 
diff --git a/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/client/gwt/InstallerGWTService.java b/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/client/gwt/InstallerGWTService.java
index c37d923..56c9684 100644
--- a/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/client/gwt/InstallerGWTService.java
+++ b/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/client/gwt/InstallerGWTService.java
@@ -26,11 +26,22 @@ import com.google.gwt.user.client.rpc.RemoteService;
 import org.rhq.enterprise.gui.installer.client.shared.ServerDetails;
 
 /**
+ * Remote RPC API for the GWT Installer.
+ *
  * @author John Mazzitelli
  */
 public interface InstallerGWTService extends RemoteService {
 
     /**
+     * Starts the installation process. Once complete, the installer has nothing more it needs to do.
+     *
+     * @param serverProperties the server's settings to use. These will be persisted to
+     *                         the server's .properties file.
+     * @throws Exception
+     */
+    void install(HashMap<String, String> serverProperties) throws Exception;
+
+    /**
      * Returns a list of all registered servers in the database.
      *
      * @param connectionUrl
@@ -83,13 +94,6 @@ public interface InstallerGWTService extends RemoteService {
     HashMap<String, String> getServerProperties() throws Exception;
 
     /**
-     * Saves the rhq-server.properties with the given values.
-     * @param serverProperties
-     * @throws Exception
-     */
-    void saveServerProperties(HashMap<String, String> serverProperties) throws Exception;
-
-    /**
      * Returns the version string for the app server itself (e.g. "7.1.2.Final").
      * @return version string of app server
      * @throws Exception
diff --git a/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/client/shared/ServerDetails.java b/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/client/shared/ServerDetails.java
index b54e380..7e07073 100644
--- a/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/client/shared/ServerDetails.java
+++ b/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/client/shared/ServerDetails.java
@@ -20,6 +20,12 @@ package org.rhq.enterprise.gui.installer.client.shared;
 
 import java.io.Serializable;
 
+/**
+ * Provides details about the server if it is already a known one (by "known" meaning it is
+ * in the database already).
+ * 
+ * @author John Mazzitelli
+ */
 public class ServerDetails implements Serializable {
     private static final long serialVersionUID = 1L;
 
@@ -109,7 +115,7 @@ public class ServerDetails implements Serializable {
 
     @Override
     public String toString() {
-        return "[name=" + name + " address=" + endpointAddress + " port=" + endpointPort + " secureport="
-            + endpointSecurePort + " affinitygroup=" + affinityGroup + "]";
+        return "[name=" + name + ", address=" + endpointAddress + ", port=" + endpointPort + ", secureport="
+            + endpointSecurePort + ", affinitygroup=" + affinityGroup + "]";
     }
 }
diff --git a/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/client/shared/ServerProperties.java b/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/client/shared/ServerProperties.java
index d92d4ce..0ea750a 100644
--- a/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/client/shared/ServerProperties.java
+++ b/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/client/shared/ServerProperties.java
@@ -18,36 +18,164 @@
  */
 package org.rhq.enterprise.gui.installer.client.shared;
 
+import java.util.HashSet;
+import java.util.Set;
+
 /**
  * Settings found in the rhq-server.properties file that controls the startup configuration of the server.
  *
  * @author John Mazzitelli
  */
 public class ServerProperties {
-    public static final String PREFIX_PROP_DATABASE = "rhq.server.database.";
-    public static final String PROP_DATABASE_TYPE = PREFIX_PROP_DATABASE + "type-mapping";
-    public static final String PROP_DATABASE_CONNECTION_URL = PREFIX_PROP_DATABASE + "connection-url";
-    public static final String PROP_DATABASE_USERNAME = PREFIX_PROP_DATABASE + "user-name";
-    public static final String PROP_DATABASE_PASSWORD = PREFIX_PROP_DATABASE + "password";
-    public static final String PROP_DATABASE_SERVER_NAME = PREFIX_PROP_DATABASE + "server-name";
-    public static final String PROP_DATABASE_PORT = PREFIX_PROP_DATABASE + "port";
-    public static final String PROP_DATABASE_DB_NAME = PREFIX_PROP_DATABASE + "db-name";
+    public static final String PROP_DATABASE_TYPE = "rhq.server.database.type-mapping";
+    public static final String PROP_DATABASE_CONNECTION_URL = "rhq.server.database.connection-url";
+    public static final String PROP_DATABASE_USERNAME = "rhq.server.database.user-name";
+    public static final String PROP_DATABASE_PASSWORD = "rhq.server.database.password";
+    public static final String PROP_DATABASE_SERVER_NAME = "rhq.server.database.server-name";
+    public static final String PROP_DATABASE_PORT = "rhq.server.database.port";
+    public static final String PROP_DATABASE_DB_NAME = "rhq.server.database.db-name";
     public static final String PROP_DATABASE_HIBERNATE_DIALECT = "hibernate.dialect";
+
     public static final String PROP_QUARTZ_DRIVER_DELEGATE_CLASS = "rhq.server.quartz.driverDelegateClass";
     public static final String PROP_QUARTZ_SELECT_WITH_LOCK_SQL = "rhq.server.quartz.selectWithLockSQL";
     public static final String PROP_QUARTZ_LOCK_HANDLER_CLASS = "rhq.server.quartz.lockHandlerClass";
 
-    public static final String PREFIX_PROP_WEB = "rhq.server.startup.web.";
-    public static final String PROP_WEB_HTTP_PORT = PREFIX_PROP_WEB + "http.port";
-    public static final String PROP_WEB_HTTPS_PORT = PREFIX_PROP_WEB + "https.port";
+    public static final String PROP_WEB_HTTP_PORT = "rhq.server.startup.web.http.port";
+    public static final String PROP_WEB_HTTPS_PORT = "rhq.server.startup.web.https.port";
+
+    public static final String PROP_EMBEDDED_AGENT_ENABLED = "rhq.server.embedded-agent.enabled";
+    public static final String PROP_EMBEDDED_AGENT_NAME = "rhq.server.embedded-agent.name";
+    public static final String PROP_EMBEDDED_AGENT_DISABLE_NATIVE = "rhq.server.embedded-agent.disable-native-system";
+    public static final String PROP_EMBEDDED_AGENT_RESET_CONFIGURATION = "rhq.server.embedded-agent.reset-configuration";
+
+    public static final String PROP_EMAIL_SMTP_HOST = "rhq.server.email.smtp-host";
+    public static final String PROP_EMAIL_SMTP_PORT = "rhq.server.email.smtp-port";
+    public static final String PROP_EMAIL_FROM_ADDRESS = "rhq.server.email.from-address";
+
+    public static final String PROP_AUTOINSTALL_ENABLE = "rhq.autoinstall.enabled";
+    public static final String PROP_AUTOINSTALL_DATABASE = "rhq.autoinstall.database";
+    public static final String PROP_AUTOINSTALL_PUBLIC_ADDR = "rhq.autoinstall.public-endpoint-address";
+
+    public static final String PROP_TOMCAT_SECURITY_CLIENT_AUTH_MOD = "rhq.server.tomcat.security.client-auth-mode";
+    public static final String PROP_TOMCAT_SECURITY_SSL_PROTOCOL = "rhq.server.tomcat.security.secure-socket-protocol";
+    public static final String PROP_TOMCAT_SECURITY_ALGORITHM = "rhq.server.tomcat.security.algorithm";
+    public static final String PROP_TOMCAT_SECURITY_KEYSTORE_ALIAS = "rhq.server.tomcat.security.keystore.alias";
+    public static final String PROP_TOMCAT_SECURITY_KEYSTORE_FILENAME = "rhq.server.tomcat.security.keystore.file";
+    public static final String PROP_TOMCAT_SECURITY_KEYSTORE_PASSWORD = "rhq.server.tomcat.security.keystore.password";
+    public static final String PROP_TOMCAT_SECURITY_KEYSTORE_TYPE = "rhq.server.tomcat.security.keystore.type";
+    public static final String PROP_TOMCAT_SECURITY_TRUSTSTORE_FILENAME = "rhq.server.tomcat.security.truststore.file";
+    public static final String PROP_TOMCAT_SECURITY_TRUSTSTORE_PASSWORD = "rhq.server.tomcat.security.truststore.password";
+    public static final String PROP_TOMCAT_SECURITY_TRUSTSTORE_TYPE = "rhq.server.tomcat.security.truststore.type";
+
+    public static final String PROP_CONNECTOR_TRANSPORT = "rhq.communications.connector.transport";
+    public static final String PROP_CONNECTOR_BIND_ADDRESS = "rhq.communications.connector.bind-address";
+    public static final String PROP_CONNECTOR_BIND_PORT = "rhq.communications.connector.bind-port";
+    public static final String PROP_CONNECTOR_TRANSPORT_PARAMS = "rhq.communications.connector.transport-params";
 
-    public static final String PREFIX_PROP_EMBEDDED_AGENT = "rhq.server.embedded-agent.";
-    public static final String PROP_EMBEDDED_AGENT_ENABLED = PREFIX_PROP_EMBEDDED_AGENT + "enabled";
+    public static final String PROP_SECURITY_SERVER_SECURE_SOCKET_PROTOCOL = "rhq.communications.connector.security.secure-socket-protocol";
+    public static final String PROP_SECURITY_SERVER_KEYSTORE_FILE = "rhq.communications.connector.security.keystore.file";
+    public static final String PROP_SECURITY_SERVER_KEYSTORE_ALGORITHM = "rhq.communications.connector.security.keystore.algorithm";
+    public static final String PROP_SECURITY_SERVER_KEYSTORE_TYPE = "rhq.communications.connector.security.keystore.type";
+    public static final String PROP_SECURITY_SERVER_KEYSTORE_PASSWORD = "rhq.communications.connector.security.keystore.password";
+    public static final String PROP_SECURITY_SERVER_KEYSTORE_KEY_PASSWORD = "rhq.communications.connector.security.keystore.key-password";
+    public static final String PROP_SECURITY_SERVER_KEYSTORE_ALIAS = "rhq.communications.connector.security.keystore.alias";
+    public static final String PROP_SECURITY_SERVER_TRUSTSTORE_FILE = "rhq.communications.connector.security.truststore.file";
+    public static final String PROP_SECURITY_SERVER_TRUSTSTORE_ALGORITHM = "rhq.communications.connector.security.truststore.algorithm";
+    public static final String PROP_SECURITY_SERVER_TRUSTSTORE_TYPE = "rhq.communications.connector.security.truststore.type";
+    public static final String PROP_SECURITY_SERVER_TRUSTSTORE_PASSWORD = "rhq.communications.connector.security.truststore.password";
+    public static final String PROP_SECURITY_SERVER_CLIENT_AUTH_MODE = "rhq.communications.connector.security.client-auth-mode";
 
-    public static final String PREFIX_PROP_EMAIL = "rhq.server.email.";
-    public static final String PROP_EMAIL_SMTP_HOST = PREFIX_PROP_EMAIL + "smtp-host";
-    public static final String PROP_EMAIL_FROM_ADDRESS = PREFIX_PROP_EMAIL + "from-address";
+    public static final String PROP_SECURITY_CLIENT_SECURE_SOCKET_PROTOCOL = "rhq.server.client.security.secure-socket-protocol";
+    public static final String PROP_SECURITY_CLIENT_KEYSTORE_FILE = "rhq.server.client.security.keystore.file";
+    public static final String PROP_SECURITY_CLIENT_KEYSTORE_ALGORITHM = "rhq.server.client.security.keystore.algorithm";
+    public static final String PROP_SECURITY_CLIENT_KEYSTORE_TYPE = "rhq.server.client.security.keystore.type";
+    public static final String PROP_SECURITY_CLIENT_KEYSTORE_PASSWORD = "rhq.server.client.security.keystore.password";
+    public static final String PROP_SECURITY_CLIENT_KEYSTORE_KEY_PASSWORD = "rhq.server.client.security.keystore.key-password";
+    public static final String PROP_SECURITY_CLIENT_KEYSTORE_ALIAS = "rhq.server.client.security.keystore.alias";
+    public static final String PROP_SECURITY_CLIENT_TRUSTSTORE_FILE = "rhq.server.client.security.truststore.file";
+    public static final String PROP_SECURITY_CLIENT_TRUSTSTORE_ALGORITHM = "rhq.server.client.security.truststore.algorithm";
+    public static final String PROP_SECURITY_CLIENT_TRUSTSTORE_TYPE = "rhq.server.client.security.truststore.type";
+    public static final String PROP_SECURITY_CLIENT_TRUSTSTORE_PASSWORD = "rhq.server.client.security.truststore.password";
+    public static final String PROP_SECURITY_CLIENT_SERVER_AUTH_MODE_ENABLED = "rhq.server.client.security.server-auth-mode-enabled";
+
+    public static final String PROP_AGENT_MULTICAST_DETECTOR_ENABLED = "rhq.communications.multicast-detector.enabled";
+    public static final String PROP_AGENT_MULTICAST_DETECTOR_BIND_ADDRESS = "rhq.communications.multicast-detector.bind-address";
+    public static final String PROP_AGENT_MULTICAST_DETECTOR_MULTICAST_ADDRESS = "rhq.communications.multicast-detector.multicast-address";
+    public static final String PROP_AGENT_MULTICAST_DETECTOR_PORT = "rhq.communications.multicast-detector.port";
+
+    public static final String PROP_CONCURRENCY_LIMIT_WEBCONNS = "rhq.server.startup.web.max-connections";
+    public static final String PROP_CONCURRENCY_LIMIT_GLOBAL = "rhq.communications.global-concurrency-limit";
+    public static final String PROP_CONCURRENCY_LIMIT_INV_REPORT = "rhq.server.concurrency-limit.inventory-report";
+    public static final String PROP_CONCURRENCY_LIMIT_AVAIL_REPORT = "rhq.server.concurrency-limit.availability-report";
+    public static final String PROP_CONCURRENCY_LIMIT_INV_SYNC = "rhq.server.concurrency-limit.inventory-sync";
+    public static final String PROP_CONCURRENCY_LIMIT_CONTENT_REPORT = "rhq.server.concurrency-limit.content-report";
+    public static final String PROP_CONCURRENCY_LIMIT_CONTENT_DOWNLOAD = "rhq.server.concurrency-limit.content-download";
+    public static final String PROP_CONCURRENCY_LIMIT_MEAS_REPORT = "rhq.server.concurrency-limit.measurement-report";
+    public static final String PROP_CONCURRENCY_LIMIT_MEASSCHED_REQ = "rhq.server.concurrency-limit.measurement-schedule-request";
 
     public static final String PROP_HIGH_AVAILABILITY_NAME = "rhq.server.high-availability.name";
     public static final String PROP_MM_AT_START = "rhq.server.maintenance-mode-at-startup";
+    public static final String PROP_OPERATION_TIMEOUT = "rhq.server.operation-timeout";
+
+    // this list contains all the properties that are to have boolean values (true | false)
+    public static final Set<String> BOOLEAN_PROPERTIES;
+    static {
+        BOOLEAN_PROPERTIES = new HashSet<String>();
+        BOOLEAN_PROPERTIES.add(PROP_SECURITY_CLIENT_SERVER_AUTH_MODE_ENABLED);
+        BOOLEAN_PROPERTIES.add(PROP_EMBEDDED_AGENT_ENABLED);
+        BOOLEAN_PROPERTIES.add(PROP_EMBEDDED_AGENT_DISABLE_NATIVE);
+        BOOLEAN_PROPERTIES.add(PROP_EMBEDDED_AGENT_RESET_CONFIGURATION);
+        BOOLEAN_PROPERTIES.add(PROP_MM_AT_START);
+        BOOLEAN_PROPERTIES.add(PROP_AUTOINSTALL_ENABLE);
+        BOOLEAN_PROPERTIES.add(PROP_AGENT_MULTICAST_DETECTOR_ENABLED);
+    }
+
+    // this list contains all the properties that are to have integer values
+    public static final Set<String> INTEGER_PROPERTIES;
+    static {
+        INTEGER_PROPERTIES = new HashSet<String>();
+        INTEGER_PROPERTIES.add(PROP_WEB_HTTP_PORT);
+        INTEGER_PROPERTIES.add(PROP_WEB_HTTPS_PORT);
+        INTEGER_PROPERTIES.add(PROP_CONNECTOR_BIND_PORT);
+        INTEGER_PROPERTIES.add(PROP_EMAIL_SMTP_PORT);
+        INTEGER_PROPERTIES.add(PROP_OPERATION_TIMEOUT);
+        INTEGER_PROPERTIES.add(PROP_CONCURRENCY_LIMIT_AVAIL_REPORT);
+        INTEGER_PROPERTIES.add(PROP_CONCURRENCY_LIMIT_CONTENT_DOWNLOAD);
+        INTEGER_PROPERTIES.add(PROP_CONCURRENCY_LIMIT_CONTENT_REPORT);
+        INTEGER_PROPERTIES.add(PROP_CONCURRENCY_LIMIT_GLOBAL);
+        INTEGER_PROPERTIES.add(PROP_CONCURRENCY_LIMIT_INV_REPORT);
+        INTEGER_PROPERTIES.add(PROP_CONCURRENCY_LIMIT_INV_SYNC);
+        INTEGER_PROPERTIES.add(PROP_CONCURRENCY_LIMIT_MEAS_REPORT);
+        INTEGER_PROPERTIES.add(PROP_CONCURRENCY_LIMIT_MEASSCHED_REQ);
+        INTEGER_PROPERTIES.add(PROP_CONCURRENCY_LIMIT_WEBCONNS);
+        INTEGER_PROPERTIES.add(PROP_AGENT_MULTICAST_DETECTOR_PORT);
+    }
+
+    public static final Set<String> CLIENT_AUTH_MODES;
+    static {
+        CLIENT_AUTH_MODES = new HashSet<String>();
+        CLIENT_AUTH_MODES.add("none");
+        CLIENT_AUTH_MODES.add("want");
+        CLIENT_AUTH_MODES.add("need");
+    }
+
+    public static final Set<String> TOMCAT_CLIENT_AUTH_MODES;
+    static {
+        TOMCAT_CLIENT_AUTH_MODES = new HashSet<String>();
+        TOMCAT_CLIENT_AUTH_MODES.add("false");
+        TOMCAT_CLIENT_AUTH_MODES.add("want");
+        TOMCAT_CLIENT_AUTH_MODES.add("true");
+    }
+
+    // all of the settings in this list have to be hardcoded to a specific IBM security algorithm
+    // if we are installing a server that is running in an IBM JVM
+    public static final Set<String> IBM_ALGOROTHM_SETTINGS;
+    static {
+        IBM_ALGOROTHM_SETTINGS = new HashSet<String>();
+        IBM_ALGOROTHM_SETTINGS.add(PROP_TOMCAT_SECURITY_ALGORITHM);
+        IBM_ALGOROTHM_SETTINGS.add(PROP_SECURITY_SERVER_KEYSTORE_ALGORITHM);
+        IBM_ALGOROTHM_SETTINGS.add(PROP_SECURITY_SERVER_TRUSTSTORE_ALGORITHM);
+        IBM_ALGOROTHM_SETTINGS.add(PROP_SECURITY_CLIENT_KEYSTORE_ALGORITHM);
+        IBM_ALGOROTHM_SETTINGS.add(PROP_SECURITY_CLIENT_TRUSTSTORE_ALGORITHM);
+    }
 }
\ No newline at end of file
diff --git a/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/InstallerGWTServiceImpl.java b/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/InstallerGWTServiceImpl.java
index 6247168..b390987 100644
--- a/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/InstallerGWTServiceImpl.java
+++ b/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/InstallerGWTServiceImpl.java
@@ -23,6 +23,8 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Properties;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 import javax.servlet.annotation.WebServlet;
 
@@ -33,12 +35,17 @@ import org.jboss.as.controller.client.ModelControllerClient;
 import org.rhq.common.jbossas.client.controller.Address;
 import org.rhq.common.jbossas.client.controller.JBossASClient;
 import org.rhq.common.jbossas.client.controller.SecurityDomainJBossASClient;
+import org.rhq.core.db.DatabaseTypeFactory;
 import org.rhq.core.util.PropertiesFileUpdate;
+import org.rhq.core.util.exception.ThrowableUtil;
 import org.rhq.enterprise.gui.installer.client.gwt.InstallerGWTService;
 import org.rhq.enterprise.gui.installer.client.shared.ServerDetails;
+import org.rhq.enterprise.gui.installer.client.shared.ServerProperties;
 import org.rhq.enterprise.gui.installer.server.service.ManagementService;
 
 /**
+ * Remote RPC API implementation for the GWT Installer.
+ *
  * @author John Mazzitelli
  */
 @WebServlet(value = "/org.rhq.enterprise.gui.installer.Installer/InstallerGWTService")
@@ -49,6 +56,97 @@ public class InstallerGWTServiceImpl extends RemoteServiceServlet implements Ins
     private static final String RHQ_SECURITY_DOMAIN = "RHQDSSecurityDomain";
 
     @Override
+    public void install(HashMap<String, String> serverProperties) throws Exception {
+        // its possible the JDBC URL was changed, clear the factory cache in case the DB version is different now
+        DatabaseTypeFactory.clearDatabaseTypeCache();
+
+        // determine the type of database to connect to
+        String databaseType = serverProperties.get(ServerProperties.PROP_DATABASE_TYPE);
+        if (databaseType == null || databaseType.length() == 0) {
+            throw new Exception("Please indicate the type of database to connect to");
+        }
+
+        boolean isPostgres = databaseType.toLowerCase().indexOf("postgres") > -1;
+        boolean isOracle = databaseType.toLowerCase().indexOf("oracle") > -1;
+
+        if (isPostgres == false && isOracle == false) {
+            throw new IllegalArgumentException("Invalid database type: " + databaseType);
+        }
+
+        // parse the database connection URL to extract the servername/port/dbname; this is needed for the XA datasource
+        try {
+            String url = serverProperties.get(ServerProperties.PROP_DATABASE_CONNECTION_URL);
+            Pattern pattern = null;
+            if (isPostgres) {
+                pattern = Pattern.compile(".*://(.*):([0123456789]+)/(.*)"); // jdbc:postgresql://host.name:5432/rhq
+            } else if (isOracle) {
+                // if we ever find that we'll need these props set, uncomment below and it should all work
+                //pattern = Pattern.compile(".*@(.*):([0123456789]+)[:/](.*)"); // jdbc:oracle:thin:@host.name:1521:rhq (or /rhq)
+            }
+
+            if (pattern != null) {
+                Matcher match = pattern.matcher(url);
+                if (match.find() && (match.groupCount() == 3)) {
+                    String serverName = match.group(1);
+                    String port = match.group(2);
+                    String dbName = match.group(3);
+                    serverProperties.put(ServerProperties.PROP_DATABASE_SERVER_NAME, serverName);
+                    serverProperties.put(ServerProperties.PROP_DATABASE_PORT, port);
+                    serverProperties.put(ServerProperties.PROP_DATABASE_DB_NAME, dbName);
+                } else {
+                    throw new Exception("Cannot get server, port or db name from connection URL: " + url);
+                }
+            } else {
+                serverProperties.put(ServerProperties.PROP_DATABASE_SERVER_NAME, "");
+                serverProperties.put(ServerProperties.PROP_DATABASE_PORT, "");
+                serverProperties.put(ServerProperties.PROP_DATABASE_DB_NAME, "");
+            }
+        } catch (Exception e) {
+            throw new Exception("JDBC connection URL seems to be invalid: " + ThrowableUtil.getAllMessages(e));
+        }
+
+        // make sure the internal database related settings are correct
+        try {
+            String dialect = null;
+            String quartzDriverDelegateClass = "org.quartz.impl.jdbcjobstore.StdJDBCDelegate";
+            String quartzSelectWithLockSQL = "SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE";
+            String quartzLockHandlerClass = "org.quartz.impl.jdbcjobstore.StdRowLockSemaphore";
+
+            if (isPostgres) {
+                dialect = "org.hibernate.dialect.PostgreSQLDialect";
+                quartzDriverDelegateClass = "org.quartz.impl.jdbcjobstore.PostgreSQLDelegate";
+            } else if (isOracle) {
+                dialect = "org.hibernate.dialect.Oracle10gDialect";
+                quartzDriverDelegateClass = "org.quartz.impl.jdbcjobstore.oracle.OracleDelegate";
+            }
+
+            serverProperties.put(ServerProperties.PROP_DATABASE_HIBERNATE_DIALECT, dialect);
+            serverProperties.put(ServerProperties.PROP_QUARTZ_DRIVER_DELEGATE_CLASS, quartzDriverDelegateClass);
+            serverProperties.put(ServerProperties.PROP_QUARTZ_SELECT_WITH_LOCK_SQL, quartzSelectWithLockSQL);
+            serverProperties.put(ServerProperties.PROP_QUARTZ_LOCK_HANDLER_CLASS, quartzLockHandlerClass);
+
+        } catch (Exception e) {
+            throw new Exception("Cannot configure internal database settings: " + ThrowableUtil.getAllMessages(e));
+        }
+
+        // test the connection to make sure everything is OK - note that if we are in auto-install mode,
+        // the password will have been obfuscated, so we need to de-obfucate it in order to use it.
+        String url = serverProperties.get(ServerProperties.PROP_DATABASE_CONNECTION_URL);
+        String user = serverProperties.get(ServerProperties.PROP_DATABASE_USERNAME);
+        String pw = serverProperties.get(ServerProperties.PROP_DATABASE_PASSWORD);
+        if (ServerInstallUtil.isAutoinstallEnabled(serverProperties)) {
+            pw = ServerInstallUtil.deobfuscatePassword(pw);
+        }
+        String testConnectionErrorMessage = testConnection(url, user, pw);
+        if (testConnectionErrorMessage != null) {
+            throw new Exception("Cannot connect to the database: " + testConnectionErrorMessage);
+        }
+
+        // TODO: CONTINUE WITH CONFIGURATION BEAN LINE 712
+        return;
+    }
+
+    @Override
     public ArrayList<String> getServerNames(String connectionUrl, String username, String password) throws Exception {
         try {
             return ServerInstallUtil.getServerNames(connectionUrl, username, password);
@@ -91,6 +189,14 @@ public class InstallerGWTServiceImpl extends RemoteServiceServlet implements Ins
         PropertiesFileUpdate propsFile = new PropertiesFileUpdate(serverPropertiesFile.getAbsolutePath());
         Properties props = propsFile.loadExistingProperties();
 
+        // force some hardcoded defaults for IBM JVMs that must have specific values
+        boolean isIBM = System.getProperty("java.vendor", "").contains("IBM");
+        if (isIBM) {
+            for (String algPropName : ServerProperties.IBM_ALGOROTHM_SETTINGS) {
+                props.setProperty(algPropName, "IbmX509");
+            }
+        }
+
         // GWT can't handle Properties - convert to HashMap
         HashMap<String, String> map = new HashMap<String, String>(props.size());
         for (Object property : props.keySet()) {
@@ -99,12 +205,21 @@ public class InstallerGWTServiceImpl extends RemoteServiceServlet implements Ins
         return map;
     }
 
-    @Override
-    public void saveServerProperties(HashMap<String, String> serverProperties) throws Exception {
+    /**
+     * Save the given properties to the server's .properties file.
+     *
+     * Note that this is private - it is not exposed to the installer UI. It should have no need to save
+     * this data outside of the normal installation process (see {@link #install()}).
+     * 
+     * @param serverProperties the server properties to save
+     * 
+     * @throws Exception if failed to save the properties to the .properties file
+     */
+    private void saveServerProperties(HashMap<String, String> serverProperties) throws Exception {
         File serverPropertiesFile = getServerPropertiesFile();
         PropertiesFileUpdate propsFile = new PropertiesFileUpdate(serverPropertiesFile.getAbsolutePath());
 
-        // GWT can't handle Properties - convert from HashMap
+        // GWT can't handle Properties - so we use HashMap but convert to Properties internally
         Properties props = new Properties();
         for (Map.Entry<String, String> entry : serverProperties.entrySet()) {
             props.setProperty(entry.getKey(), entry.getValue());
diff --git a/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/ServerInstallUtil.java b/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/ServerInstallUtil.java
index 5dbac87..1bbeb81 100644
--- a/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/ServerInstallUtil.java
+++ b/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/ServerInstallUtil.java
@@ -25,6 +25,7 @@ import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
 import java.util.ArrayList;
+import java.util.HashMap;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -34,6 +35,7 @@ import org.rhq.core.db.DatabaseTypeFactory;
 import org.rhq.core.db.DbUtil;
 import org.rhq.core.util.exception.ThrowableUtil;
 import org.rhq.enterprise.gui.installer.client.shared.ServerDetails;
+import org.rhq.enterprise.gui.installer.client.shared.ServerProperties;
 
 /**
  * Provides utility methods necessary to complete the server installation.
@@ -47,6 +49,14 @@ public class ServerInstallUtil {
         OVERWRITE, KEEP, SKIP
     };
 
+    public static boolean isAutoinstallEnabled(HashMap<String, String> serverProperties) {
+        String enableProp = serverProperties.get(ServerProperties.PROP_AUTOINSTALL_ENABLE);
+        if (enableProp != null) {
+            return Boolean.parseBoolean(enableProp);
+        }
+        return false;
+    }
+
     public static boolean isKeepExistingSchema(ExistingSchemaOption existingSchemaOption) {
         return ExistingSchemaOption.KEEP.name().equals(existingSchemaOption)
             || ExistingSchemaOption.SKIP.name().equals(existingSchemaOption);
@@ -279,7 +289,7 @@ public class ServerInstallUtil {
      * @param password the clear text of the password to obfuscate
      * @return the obfuscated password
      */
-    private static String obfuscatePassword(String password) {
+    public static String obfuscatePassword(String password) {
 
         // We need to do some mumbo jumbo, as the interesting method is private
         // in SecureIdentityLoginModule
@@ -304,7 +314,7 @@ public class ServerInstallUtil {
      * @param obfuscatedPasswordd the obfuscated password
      * @return the clear-text password
      */
-    private static String deobfuscatePassword(String obfuscatedPassword) {
+    public static String deobfuscatePassword(String obfuscatedPassword) {
 
         // We need to do some mumbo jumbo, as the interesting method is private
         // in SecureIdentityLoginModule
diff --git a/modules/enterprise/gui/installer/src/main/resources/org/rhq/enterprise/gui/installer/client/Messages.properties b/modules/enterprise/gui/installer/src/main/resources/org/rhq/enterprise/gui/installer/client/Messages.properties
index 5915f40..054b736 100644
--- a/modules/enterprise/gui/installer/src/main/resources/org/rhq/enterprise/gui/installer/client/Messages.properties
+++ b/modules/enterprise/gui/installer/src/main/resources/org/rhq/enterprise/gui/installer/client/Messages.properties
@@ -3,6 +3,8 @@ button_save = Save
 button_startInstallation = Press To Start The Installation Now
 button_testConnection = Test Connection
 help_registeredServers = If you are performing an upgrade or a re-installation then you should select a server from this list of registered servers. If you want to install a new server into the system, select the *New Server* option. (Note that if you are going to overwrite your existing schema, you cannot select an existing registered server since they will be deleted when the overwrite is performed.)
+message_notValidBoolean = That is not a valid boolean (must be "true" or "false").
+message_notValidInteger = That is not a valid number.
 property_name_label = Property
 property_value_label = Value
 schema_update_keep = Keep (Maintain Existing Data)




More information about the rhq-commits mailing list