.classpath | 30 .gitignore | 2 etc/apt/pom.xml | 199 + etc/apt/src/main/java/org/rhq/plugins/apt/AptSourcesComponent.java | 144 + etc/apt/src/main/java/org/rhq/plugins/apt/AptSourcesDiscoveryComponent.java | 50 etc/apt/src/main/resources/META-INF/rhq-plugin.xml | 48 etc/apt/src/test/java/org/rhq/plugins/apt/AptSourcesComponentTest.java | 93 etc/apt/src/test/resources/log4j.xml | 32 etc/eclipse-tools/maven/RHQ | 22 etc/eclipse-tools/templates/schema.xmlcatalog | 22 etc/m2/settings-linux-config.xml | 54 etc/m2/settings-rawconfig.xml | 1 etc/m2/settings.xml | 15 etc/samples/perspectives/sample-perspective/app/pom.xml | 143 + etc/samples/perspectives/sample-perspective/app/src/main/webapp/WEB-INF/web.xml | 12 etc/samples/perspectives/sample-perspective/app/src/main/webapp/images/create.png |binary etc/samples/perspectives/sample-perspective/app/src/main/webapp/images/jboss.png |binary etc/samples/perspectives/sample-perspective/app/src/main/webapp/index.html | 14 etc/samples/perspectives/sample-perspective/perspective/pom.xml | 159 + etc/samples/perspectives/sample-perspective/perspective/src/main/resources/META-INF/rhq-serverplugin.xml | 127 + etc/samples/perspectives/sample-perspective/pom.xml | 45 etc/samples/simplereport-serverplugin/pom.xml | 158 + etc/samples/simplereport-serverplugin/src/main/java/org/custom/SimpleReportsPluginComponent.java | 277 ++ etc/samples/simplereport-serverplugin/src/main/resources/META-INF/rhq-serverplugin.xml | 81 modules/core/client-api/pom.xml | 20 modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/configuration/ConfigurationAgentService.java | 20 modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/ConfigurationMetadataParser.java | 21 modules/core/client-api/src/main/java/org/rhq/core/clientapi/descriptor/PluginTransformException.java | 48 modules/core/client-api/src/main/java/org/rhq/core/clientapi/descriptor/PluginTransformer.java | 131 + modules/core/client-api/src/main/resources/rhq-configuration.xsd | 10 modules/core/client-api/src/test/groovy/org/rhq/core/clientapi/agent/metadata/PluginMetadataParserTest.groovy | 392 +++ modules/core/client-api/src/test/java/org/rhq/core/clientapi/descriptor/PluginTransformerTest.java | 318 ++ modules/core/dbutils/pom.xml | 50 modules/core/dbutils/pom.xml.orig | 279 ++ modules/core/dbutils/src/main/scripts/dbsetup/alert-schema.xml | 13 modules/core/dbutils/src/main/scripts/dbsetup/config-schema.xml | 3 modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml | 268 +- modules/core/domain/src/main/java/META-INF/MANIFEST.MF | 4 modules/core/domain/src/main/java/org/rhq/core/domain/alert/Alert.java | 56 modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java | 48 modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/EmailNotification.java | 3 modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/NotificationTemplate.java | 123 + modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/RoleNotification.java | 3 modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/SnmpNotification.java | 3 modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/SubjectNotification.java | 3 modules/core/domain/src/main/java/org/rhq/core/domain/configuration/AbstractConfigurationUpdate.java | 6 modules/core/domain/src/main/java/org/rhq/core/domain/configuration/AbstractResourceConfigurationUpdate.java | 3 modules/core/domain/src/main/java/org/rhq/core/domain/configuration/Configuration.java | 70 modules/core/domain/src/main/java/org/rhq/core/domain/configuration/RawConfiguration.java | 17 modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/ConfigurationDefinition.java | 29 modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/ConfigurationFormat.java | 49 modules/core/domain/src/main/java/org/rhq/core/domain/measurement/MeasurementDefinition.java | 17 modules/core/domain/src/main/java/org/rhq/core/domain/plugin/Plugin.java | 10 modules/core/domain/src/main/java/org/rhq/core/domain/plugin/ServerPlugin.java | 85 modules/core/domain/src/main/java/org/rhq/core/domain/util/EntitySerializer.java | 2 modules/core/domain/src/test/java/org/rhq/core/domain/configuration/AbstractConfigurationUpdateTest.java | 114 + modules/core/domain/src/test/java/org/rhq/core/domain/configuration/ConfigurationTest.java | 258 ++ modules/core/domain/src/test/java/org/rhq/core/domain/configuration/PluginConfigurationUpdateTest.java | 67 modules/core/domain/src/test/java/org/rhq/core/domain/configuration/RawConfigurationTest.java | 12 modules/core/domain/src/test/java/org/rhq/core/domain/configuration/ResourceConfigurationUpdateTest.java | 67 modules/core/domain/src/test/java/org/rhq/core/domain/configuration/TestUtil.java | 45 modules/core/domain/src/test/java/org/rhq/core/domain/configuration/group/GroupPluginConfigurationUpdateTest.java | 51 modules/core/domain/src/test/java/org/rhq/core/domain/configuration/group/GroupResourceConfigurationUpdateTest.java | 51 modules/core/domain/src/test/java/org/rhq/core/domain/configuration/test/ConfigurationDefinitionTest.java | 2 modules/core/domain/src/test/java/org/rhq/core/domain/resource/test/PluginTest.java | 9 modules/core/domain/src/test/java/org/rhq/core/domain/resource/test/ServerPluginTest.java | 13 modules/core/gui/src/main/java/org/rhq/core/gui/configuration/AbstractConfigurationComponent.java | 2 modules/core/gui/src/main/java/org/rhq/core/gui/configuration/ConfigRenderer.java | 3 modules/core/native-system/src/main/java/org/rhq/core/system/NativeSystemInfo.java | 3 modules/core/native-system/src/main/java/org/rhq/core/system/ProcessInfo.java | 107 modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/configuration/ConfigurationFacet.java | 2 modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/configuration/ConfigurationFacetSupport.java | 27 modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/configuration/ResourceConfigurationFacet.java | 49 modules/core/plugin-container/pom.xml | 7 modules/core/plugin-container/src/main/java/org/rhq/core/pc/PluginContainer.java | 6 modules/core/plugin-container/src/main/java/org/rhq/core/pc/PluginContainerConfiguration.java | 16 modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigManagement.java | 48 modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigManagementFactory.java | 32 modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigManagementFactoryImpl.java | 89 modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigManagementSupport.java | 82 modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigurationManager.java | 199 + modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigurationManagerInitializer.java | 41 modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigurationUpdateException.java | 55 modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigurationUtilityService.java | 37 modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigurationUtilityServiceImpl.java | 42 modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/LegacyConfigManagement.java | 102 modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/RawConfigManagement.java | 74 modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/StructuredAndRawConfigManagement.java | 95 modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/StructuredConfigManagement.java | 75 modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/UpdateInProgressException.java | 43 modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/UpdateResourceConfigurationRunner.java | 100 modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/AutoDiscoveryExecutor.java | 9 modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java | 4 modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/PluginLifecycleListenerManager.java | 73 modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/PluginLifecycleListenerManagerImpl.java | 115 + modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/PluginManager.java | 132 - modules/core/plugin-container/src/main/java/org/rhq/core/pc/util/ComponentService.java | 39 modules/core/plugin-container/src/main/java/org/rhq/core/pc/util/ComponentServiceImpl.java | 51 modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/ConfigManagementFactoryImplTest.java | 269 ++ modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/ConfigManagementTest.java | 141 + modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/ConfigurationManagerTest.java | 431 ++- modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/LegacyConfigManagementTest.java | 212 + modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/RawConfigManagementTest.java | 158 + modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/StructuredAndRawConfigManagementTest.java | 211 + modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/StructuredConfigManagementTest.java | 139 + modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/UpdateResourceConfigurationRunnerTest.java | 307 ++ modules/core/plugin-container/src/test/java/org/rhq/core/pc/plugin/PluginManagerTest.java | 370 +++ modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/PluginUpdate.java | 3 modules/enterprise/gui/perspectives/pom.xml | 33 modules/enterprise/gui/perspectives/sample-perspective-war/pom.xml | 143 - modules/enterprise/gui/perspectives/sample-perspective-war/src/main/webapp/WEB-INF/web.xml | 12 modules/enterprise/gui/perspectives/sample-perspective-war/src/main/webapp/index.html | 14 modules/enterprise/gui/pom.xml | 3 modules/enterprise/gui/portal-war/pom.xml | 10 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/config/SystemConfigForm.java | 205 - modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/plugin/AbstractPluginConfigurationUIBean.java | 97 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/plugin/EditPluginConfigurationUIBean.java | 149 + modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/plugin/InstalledPluginComponent.java | 86 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/plugin/InstalledPluginsSessionUIBean.java | 51 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/plugin/InstalledPluginsUIBean.java | 145 + modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/plugin/PluginConfigurationUIBean.java | 102 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/plugin/PluginFactory.java | 63 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/GenericAlertStuffUIBean.java | 99 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/ListNotificationsUIBean.java | 191 + modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/tabbar/AbstractTabComponent.java | 8 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/AbstractConfigurationUIBean.java | 16 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/AbstractResourceConfigurationUIBean.java | 47 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java | 344 +++ modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/RawConfigCollection.java | 209 - modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/CreateNewConfigurationChildResourceUIBean.java | 4 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/ResourceUIBean.java | 9 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/ParamConstants.java | 2 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/alerts/config/PortalAction.java | 27 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/alerts/config/SnmpTrapForm.java | 67 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/alerts/config/SnmpTrapFormAction.java | 121 - modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/alerts/config/SnmpTrapFormPrepareAction.java | 81 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeStateAdvisor.java | 3 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/perspectives/PerspectivesMenuUIBean.java | 77 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/startup/StartupServlet.java | 13 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/util/EnterpriseFacesContextUtility.java | 8 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/util/WebUtility.java | 5 modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/classes/messages.properties | 19 modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-managed-beans/admin-beans.xml | 19 modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-managed-beans/alert-beans.xml | 4 modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-managed-beans/configuration-beans.xml | 6 modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-managed-beans/perspectives-beans.xml | 19 modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/admin-navigation.xml | 76 modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/configuration-navigation.xml | 41 modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/struts-config.xml | 20 modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/tiles/events-def.xml | 50 modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/validation/validation.xml | 68 modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/web.xml | 1 modules/enterprise/gui/portal-war/src/main/webapp/admin/config/EditServerConfig.jsp | 3 modules/enterprise/gui/portal-war/src/main/webapp/admin/config/SNMPForm.jsp | 171 - modules/enterprise/gui/portal-war/src/main/webapp/admin/test/control.jsp | 6 modules/enterprise/gui/portal-war/src/main/webapp/images/save.png |binary modules/enterprise/gui/portal-war/src/main/webapp/js/iframeSSI.js | 77 modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/alerts/config/SnmpActionProps.jsp | 34 modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/alerts/config/ViewDefinition.jsp | 5 modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/alerts/config/ViewDefinitionNotifications.jsp | 24 modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/alerts/config/ViewDefinitionNotificationsTabs.jsp | 41 modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/plugin/plugin-config.xhtml | 62 modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/plugin/plugin-details-edit.xhtml | 24 modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/plugin/plugin-details-view.xhtml | 28 modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/plugin/plugin-details.xhtml | 11 modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/plugin/plugin-edit-add-map.xhtml | 32 modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/plugin/plugin-edit-map.xhtml | 57 modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/plugin/plugin-edit-update-map.xhtml | 33 modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/plugin/plugin-edit-view-map.xhtml | 26 modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/plugin/plugin-edit.xhtml | 68 modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/plugin/plugin-list.xhtml | 77 modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/menu/menu.xhtml | 832 ++----- modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/menu/menuitem.xhtml | 255 ++ modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/perspective-main.xhtml | 42 modules/enterprise/gui/portal-war/src/main/webapp/rhq/empty.xhtml | 7 modules/enterprise/gui/portal-war/src/main/webapp/rhq/layout/main-layout.xhtml | 8 modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/notif/listAlertSender.xhtml | 144 + modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/download.jsp | 11 modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit-raw-full.xhtml | 38 modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit-raw.xhtml | 126 - modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml | 16 modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/upload.xhtml | 55 modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view-map.xhtml | 4 modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view-raw-full.xhtml | 38 modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view-raw.xhtml | 113 + modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml | 221 + modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/layout/main.xhtml | 72 modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/perspective/index.xhtml | 6 modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/utility/ScriptUtil.java | 14 modules/enterprise/remoting/scripts/src/main/script/configuration/config_util.js | 287 ++ modules/enterprise/remoting/scripts/src/test/script/org/rhq/enterprise/remoting/cli/test_ConfigurationManager.js | 237 +- modules/enterprise/server/container/pom.xml | 7 modules/enterprise/server/container/src/main/scripts/rhq-container.build.xml | 5 modules/enterprise/server/ear/pom.xml | 933 ++++---- modules/enterprise/server/jar/pom.xml | 5 modules/enterprise/server/jar/src/main/java/META-INF/MANIFEST.MF | 14 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/RHQConstants.java | 18 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerBean.java | 144 - modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerLocal.java | 30 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java | 168 + modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerLocal.java | 68 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/SnmpTrapSender.java | 789 ------- modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java | 122 - modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerLocal.java | 13 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerRemote.java | 12 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationUpdateNotSupportedException.java | 42 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/TranslationNotSupportedException.java | 48 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/RepoManagerBean.java | 3 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/plugin/AgentPluginScanner.java | 2 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/plugin/PluginDeploymentScanner.java | 19 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/plugin/ProductPluginDeployer.java | 16 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/plugin/ServerPluginScanner.java | 413 +-- modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerBean.java | 176 + modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/MenuItem.java | 46 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/PerspectiveException.java | 40 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/PerspectiveManagerBean.java | 326 ++ modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/PerspectiveManagerHelper.java | 42 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/PerspectiveManagerLocal.java | 30 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/Tab.java | 167 + modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsBean.java | 313 +- modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsLocal.java | 91 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/AbstractJobWrapper.java | 4 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/AbstractTypeServerPluginContainer.java | 78 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ClassLoaderManager.java | 36 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/MasterServerPluginContainer.java | 70 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ServerPluginManager.java | 169 + modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ServerPluginValidator.java | 59 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ServerPluginValidatorUtil.java | 310 ++ modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/AlertBackingBean.java | 34 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/AlertPluginValidator.java | 90 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/AlertSender.java | 60 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/AlertSenderInfo.java | 78 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/AlertSenderPluginManager.java | 240 ++ modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/AlertServerPluginContainer.java | 8 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/ResultState.java | 31 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/SenderResult.java | 103 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/ContentPluginValidator.java | 30 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/generic/GenericPluginValidator.java | 30 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/perspective/PerspectivePluginValidator.java | 30 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/perspective/PerspectiveServerPluginContainer.java | 10 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/perspective/PerspectiveServerPluginManager.java | 220 + modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/perspective/metadata/PerspectivePluginMetadataManager.java | 467 ++++ modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java | 30 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerLocal.java | 6 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerRemote.java | 20 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBean.java | 46 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java | 17 modules/enterprise/server/jar/src/main/resources/perspectives/admin.xml | 5 modules/enterprise/server/jar/src/main/resources/perspectives/content.xml | 29 modules/enterprise/server/jar/src/main/resources/perspectives/middleware.xml | 5 modules/enterprise/server/jar/src/main/resources/perspectives/root.xml | 5 modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBeanTest.java | 10 modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBeanUnitTest.java | 559 +++++ modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/ServerPluginsBeanTest.java | 22 modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/pc/generic/GenericServerPluginTest.java | 2 modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/TestAgentClient.java | 10 modules/enterprise/server/license-gen/jar/pom.xml | 2 modules/enterprise/server/license-gen/maven-plugin/pom.xml | 2 modules/enterprise/server/plugins/alert-email/pom.xml | 137 + modules/enterprise/server/plugins/alert-email/src/main/java/org/rhq/enterprise/server/plugins/alertEmail/EmailAlertComponent.java | 50 modules/enterprise/server/plugins/alert-email/src/main/java/org/rhq/enterprise/server/plugins/alertEmail/EmailSender.java | 83 modules/enterprise/server/plugins/alert-email/src/main/resources/META-INF/rhq-serverplugin.xml | 51 modules/enterprise/server/plugins/alert-irc/pom.xml | 195 + modules/enterprise/server/plugins/alert-irc/src/main/java/org/rhq/enterprise/server/plugins/alertIrc/IrcAlertComponent.java | 169 + modules/enterprise/server/plugins/alert-irc/src/main/java/org/rhq/enterprise/server/plugins/alertIrc/IrcSender.java | 72 modules/enterprise/server/plugins/alert-irc/src/main/resources/META-INF/rhq-serverplugin.xml | 49 modules/enterprise/server/plugins/alert-microblog/pom.xml | 196 + modules/enterprise/server/plugins/alert-microblog/src/main/java/org/rhq/enterprise/server/plugins/alertMicroblog/MicroblogSender.java | 73 modules/enterprise/server/plugins/alert-microblog/src/main/resources/META-INF/rhq-serverplugin.xml | 40 modules/enterprise/server/plugins/alert-mobicents/pom.xml | 130 + modules/enterprise/server/plugins/alert-mobicents/src/main/java/org/rhq/enterprise/server/plugins/alertMobicents/MobiKind.java | 30 modules/enterprise/server/plugins/alert-mobicents/src/main/java/org/rhq/enterprise/server/plugins/alertMobicents/MobicentsSender.java | 169 + modules/enterprise/server/plugins/alert-mobicents/src/main/resources/META-INF/rhq-serverplugin.xml | 53 modules/enterprise/server/plugins/alert-roles/pom.xml | 159 + modules/enterprise/server/plugins/alert-roles/src/main/java/org/rhq/enterprise/server/plugins/alertRoles/RolesBackingBean.java | 68 modules/enterprise/server/plugins/alert-roles/src/main/java/org/rhq/enterprise/server/plugins/alertRoles/RolesSender.java | 44 modules/enterprise/server/plugins/alert-roles/src/main/resources/META-INF/rhq-serverplugin.xml | 34 modules/enterprise/server/plugins/alert-roles/src/main/resources/roles.xhtml | 34 modules/enterprise/server/plugins/alert-snmp/pom.xml | 162 + modules/enterprise/server/plugins/alert-snmp/src/main/java/org/rhq/enterprise/server/plugins/alertSnmp/SnmpSender.java | 88 modules/enterprise/server/plugins/alert-snmp/src/main/java/org/rhq/enterprise/server/plugins/alertSnmp/SnmpTrapSender.java | 794 +++++++ modules/enterprise/server/plugins/alert-snmp/src/main/resources/META-INF/rhq-serverplugin.xml | 84 modules/enterprise/server/plugins/disk/src/main/java/org/rhq/enterprise/server/plugins/disk/DiskSource.java | 157 - modules/enterprise/server/plugins/disk/src/main/resources/META-INF/rhq-serverplugin.xml | 62 modules/enterprise/server/plugins/jboss-software/src/main/resources/META-INF/rhq-serverplugin.xml | 4 modules/enterprise/server/plugins/perspectives/core/perspective/pom.xml | 123 + modules/enterprise/server/plugins/perspectives/core/perspective/src/main/resources/META-INF/rhq-serverplugin.xml | 889 ++++++++ modules/enterprise/server/plugins/perspectives/core/pom.xml | 44 modules/enterprise/server/plugins/pom.xml | 76 modules/enterprise/server/plugins/url/src/main/resources/META-INF/rhq-serverplugin.xml | 12 modules/enterprise/server/plugins/validate-all-serverplugins/pom.xml | 70 modules/enterprise/server/plugins/yum/src/main/resources/META-INF/rhq-serverplugin.xml | 4 modules/enterprise/server/pom.xml | 2 modules/enterprise/server/xml-schemas/src/main/java/org/rhq/enterprise/server/xmlschema/ServerPluginDescriptorMetadataParser.java | 57 modules/enterprise/server/xml-schemas/src/main/java/org/rhq/enterprise/server/xmlschema/ServerPluginDescriptorUtil.java | 6 modules/enterprise/server/xml-schemas/src/main/resources/rhq-serverplugin-alert.xsd | 66 modules/enterprise/server/xml-schemas/src/main/resources/rhq-serverplugin-perspective.xsd | 1106 +++++++++- modules/enterprise/server/xml-schemas/src/test/java/org/rhq/enterprise/server/xmlschema/ServerPluginDescriptorUtilTest.java | 15 modules/enterprise/server/xml-schemas/src/test/resources/test-serverplugin-alert.xml | 4 modules/enterprise/server/xml-schemas/src/test/resources/test-serverplugin-perspective.xml | 14 modules/helpers/pluginGen/pom.xml | 2 modules/plugins/JBossOSGi/jopr-jbossOsgi-plugin.iml | 74 modules/plugins/apt/pom.xml | 199 - modules/plugins/apt/src/main/java/org/rhq/plugins/apt/AptSourcesComponent.java | 144 - modules/plugins/apt/src/main/java/org/rhq/plugins/apt/AptSourcesDiscoveryComponent.java | 50 modules/plugins/apt/src/main/resources/META-INF/rhq-plugin.xml | 48 modules/plugins/apt/src/test/java/org/rhq/plugins/apt/AptSourcesComponentTest.java | 93 modules/plugins/apt/src/test/resources/log4j.xml | 32 modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java | 5 modules/plugins/cron/pom.xml | 1 modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronComponent.java | 8 modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronTabComponent.java | 6 modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronTabDiscoveryComponent.java | 10 modules/plugins/cron/src/test/java/org/rhq/plugins/cron/test/CronComponentTest.java | 116 + modules/plugins/cron/src/test/java/org/rhq/plugins/cron/test/CronTabComponentTest.java | 151 + modules/plugins/cron/src/test/resources/etc/cron.d/another-crontab | 4 modules/plugins/cron/src/test/resources/etc/crontab | 2 modules/plugins/hardware/pom.xml | 3 modules/plugins/irc/pom.xml | 5 modules/plugins/jboss-as-5/pom.xml | 2 modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JBossInstanceInfo.java | 10 modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/helper/JBossInstanceInfo.java | 222 -- modules/plugins/jboss-cache-v3/pom.xml | 7 modules/plugins/jira/pom.xml | 4 modules/plugins/onewire/pom.xml | 3 modules/plugins/pom.xml | 6 modules/plugins/postfix/src/main/java/org/rhq/plugins/postfix/PostfixAccessComponent.java | 61 modules/plugins/postfix/src/main/java/org/rhq/plugins/postfix/PostfixAccessDiscoveryComponent.java | 50 modules/plugins/postfix/src/main/java/org/rhq/plugins/postfix/PostfixServerComponent.java | 74 modules/plugins/postfix/src/main/resources/META-INF/rhq-plugin.xml | 34 modules/plugins/postfix/src/test/java/org/rhq/plugins/postfix/PostfixComponentTest.java | 87 modules/plugins/postfix/src/test/resources/etc/postfix/main.cf | 11 modules/plugins/raw-config-test/pom.xml | 165 + modules/plugins/raw-config-test/src/main/groovy/org/rhq/plugins/test/rawconfig/LegacyServer.groovy | 12 modules/plugins/raw-config-test/src/main/groovy/org/rhq/plugins/test/rawconfig/RawDiscoveryComponent.groovy | 22 modules/plugins/raw-config-test/src/main/groovy/org/rhq/plugins/test/rawconfig/RawServer.groovy | 89 modules/plugins/raw-config-test/src/main/groovy/org/rhq/plugins/test/rawconfig/StructuredAndRawDiscoveryComponent.groovy | 23 modules/plugins/raw-config-test/src/main/groovy/org/rhq/plugins/test/rawconfig/StructuredAndRawServer.groovy | 168 + modules/plugins/raw-config-test/src/main/groovy/org/rhq/plugins/test/rawconfig/StructuredDiscoveryComponent.groovy | 24 modules/plugins/raw-config-test/src/main/groovy/org/rhq/plugins/test/rawconfig/StructuredServer.groovy | 97 modules/plugins/raw-config-test/src/main/resources/META-INF/rhq-plugin.xml | 45 modules/plugins/raw-config-test/src/test/groovy/org/rhq/plugins/test/rawconfig/RawConfigServerTest.groovy | 12 modules/plugins/raw-config-test/src/test/groovy/org/rhq/plugins/test/rawconfig/RawServerTest.groovy | 29 modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaServerComponent.java | 38 modules/plugins/samba/src/main/resources/META-INF/rhq-plugin.xml | 22 modules/plugins/samba/src/test/java/org/rhq/plugins/samba/SambaComponentTest.java | 11 modules/plugins/script2/pom.xml | 195 + modules/plugins/script2/src/main/java/org/rhq/modules/plugins/script2/ScriptComponent.java | 214 + modules/plugins/script2/src/main/java/org/rhq/modules/plugins/script2/ScriptDiscovery.java | 59 modules/plugins/script2/src/main/resources/META-INF/rhq-plugin.xml | 45 modules/plugins/snmptrapd/src/main/java/org/rhq/plugins/snmptrapd/SnmpTrapdDiscovery.java | 33 modules/plugins/snmptrapd/src/main/resources/META-INF/rhq-plugin.xml | 3 modules/plugins/validate-all-plugins/pom.xml | 1 modules/pom.xml | 28 modules/test-utils/pom.xml | 32 modules/test-utils/src/main/java/org/rhq/test/AssertUtils.java | 71 modules/test-utils/src/main/java/org/rhq/test/CollectionEqualsChecker.java | 91 modules/test-utils/src/main/java/org/rhq/test/EqualsResult.java | 44 modules/test-utils/src/main/java/org/rhq/test/JMockTest.java | 51 modules/test-utils/src/main/java/org/rhq/test/MatchResult.java | 44 modules/test-utils/src/main/java/org/rhq/test/PropertyMatchException.java | 43 modules/test-utils/src/main/java/org/rhq/test/PropertyMatcher.java | 88 modules/test-utils/src/main/java/org/rhq/test/jmock/PropertyMatcher.java | 56 pom.xml | 36 temp-testng-customsuite.xml | 8 365 files changed, 24785 insertions(+), 5935 deletions(-)
New commits: commit ec319f6e6e6181fb69efc15db81142e39c1f4845 Merge: c095978... 32b5c0f... Author: John Sanda john@localhost.localdomain Date: Tue Dec 29 08:53:20 2009 -0500
Merge branch 'master' into altlang-plugin
diff --cc modules/plugins/pom.xml index 062f5dc,6e7d53e..207fc6e --- a/modules/plugins/pom.xml +++ b/modules/plugins/pom.xml @@@ -121,9 -120,11 +120,12 @@@ <module>snmptrapd</module> <module>sshd</module> <module>twitter</module> + <module>alt-lang</module> <!--<module>virt</module>-->
+ <!-- this is just for testing raw config --> + <module>raw-config-test</module> + <!-- make this the last - it will validate all the plugins --> <module>validate-all-plugins</module> </modules>
commit 32b5c0f365c765461041b3df40bc01b45e91d9f6 Author: John Sanda john@localhost.localdomain Date: Mon Dec 21 16:24:12 2009 -0500
[BZ 537891] Adding fix for edge case in which id parameter was not passed when leaving raw edit page.
When editing a structured config (that also supports raw) and navigating to the raw edit page via the switch to raw link, the resource id parameter was not getting passed properly. As a result, when navigating to another tab for that resource from the raw edit page would result in an exception since the id parameter was null. Adding a navigation rule so that the parameter is passed.
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java index b6aa356..fd89fab 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java @@ -393,7 +393,7 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI current = null; setConfiguration(configuration);
- return "/rhq/resource/configuration/edit-raw.xhtml?currentResourceId=" + getResourceId(); + return SUCCESS_OUTCOME; }
void dumpProperties(Configuration conf, Log log) { @@ -423,7 +423,6 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI current = null; setConfiguration(configuration);
-// return "/rhq/resource/configuration/edit.xhtml?currentResourceId=" + getResourceId(); return SUCCESS_OUTCOME; }
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/configuration-navigation.xml b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/configuration-navigation.xml index 8f0749c..3c21035 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/configuration-navigation.xml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/configuration-navigation.xml @@ -29,6 +29,12 @@ <to-view-id>/rhq/resource/configuration/edit.xhtml?id=#{param.id}</to-view-id> <redirect/> </navigation-case> + + <navigation-case> + <from-action>#{ExistingResourceConfigurationUIBean.switchToraw}</from-action> + <to-view-id>/rhq/resource/configuration/edit-raw.xhtml?id=#{param.id}</to-view-id> + <redirect/> + </navigation-case>
</navigation-rule>
commit 41b03df6aecd682b79b1e725e3b3e2c615afb20b Author: John Sanda john@localhost.localdomain Date: Mon Dec 21 15:44:00 2009 -0500
Removing files from merge that were committed by accident
diff --git a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockServletContext.java.BACKUP.72367.java b/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockServletContext.java.BACKUP.72367.java deleted file mode 100644 index 8740aca..0000000 --- a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockServletContext.java.BACKUP.72367.java +++ /dev/null @@ -1,167 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2009 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -package org.rhq.core.gui.configuration; - -import java.io.InputStream; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; -import java.util.Set; - -import javax.servlet.RequestDispatcher; -import javax.servlet.Servlet; -import javax.servlet.ServletContext; -import javax.servlet.ServletException; - -import com.sun.faces.config.WebConfiguration; - -final class MockServletContext implements ServletContext { - public void setAttribute(String arg0, Object arg1) { - this.attributeMap.put(arg0, arg1); - - } - - public void removeAttribute(String arg0) { - attributeMap.remove(arg0); - - } - - public void log(String arg0, Throwable arg1) { - throw new RuntimeException("Function not implemented"); - - } - - public void log(Exception arg0, String arg1) { - throw new RuntimeException("Function not implemented"); - - } - - public void log(String arg0) { - throw new RuntimeException("Function not implemented"); - - } - - public Enumeration getServlets() { - throw new RuntimeException("Function not implemented"); - - } - - public Enumeration getServletNames() { - throw new RuntimeException("Function not implemented"); - - } - - public String getServletContextName() { - return MockServletContext.class.getSimpleName(); - - } - - public Servlet getServlet(String arg0) throws ServletException { - throw new RuntimeException("Function not implemented"); - - } - - public String getServerInfo() { - throw new RuntimeException("Function not implemented"); - - } - - public Set getResourcePaths(String arg0) { - throw new RuntimeException("Function not implemented"); - - } - - public InputStream getResourceAsStream(String arg0) { - throw new RuntimeException("Function not implemented"); - - } - - public URL getResource(String arg0) throws MalformedURLException { - throw new RuntimeException("Function not implemented"); - - } - - public RequestDispatcher getRequestDispatcher(String arg0) { - throw new RuntimeException("Function not implemented"); - - } - - public String getRealPath(String arg0) { - throw new RuntimeException("Function not implemented"); - - } - - public RequestDispatcher getNamedDispatcher(String arg0) { - throw new RuntimeException("Function not implemented"); - - } - - public int getMinorVersion() { - return 4; - } - - public String getMimeType(String arg0) { - throw new RuntimeException("Function not implemented"); - - } - - public int getMajorVersion() { - return 2; - - } - - Properties initParams = new Properties(); - - public Enumeration getInitParameterNames() { - return initParams.elements(); - - } - - public String getInitParameter(String key) { - return initParams.getProperty(key); - - } - - public ServletContext getContext(String arg0) { - throw new RuntimeException("Function not implemented"); - - } - - public Enumeration getAttributeNames() { - throw new RuntimeException("Function not implemented"); - - } - - Map<String, Object> attributeMap; - - public Object getAttribute(String key) { - if (null == attributeMap) { - attributeMap = new HashMap<String, Object>(); - WebConfiguration wc = WebConfiguration.getInstance(this); - - attributeMap.put("com.sun.faces.config.WebConfiguration", wc); - } - - return attributeMap.get(key); - } -} \ No newline at end of file diff --git a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockServletContext.java.BASE.72367.java b/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockServletContext.java.BASE.72367.java deleted file mode 100644 index f604d00..0000000 --- a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockServletContext.java.BASE.72367.java +++ /dev/null @@ -1,166 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2009 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -package org.rhq.core.gui.configuration; - -import java.io.InputStream; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; -import java.util.Set; - -import javax.servlet.RequestDispatcher; -import javax.servlet.Servlet; -import javax.servlet.ServletContext; -import javax.servlet.ServletException; - -import com.sun.faces.config.WebConfiguration; -final class MockServletContext implements ServletContext { - public void setAttribute(String arg0, Object arg1) { - this.attributeMap.put(arg0, arg1); - - } - - public void removeAttribute(String arg0) { - attributeMap.remove(arg0); - - } - - public void log(String arg0, Throwable arg1) { - throw new RuntimeException("Function not implemented"); - - } - - public void log(Exception arg0, String arg1) { - throw new RuntimeException("Function not implemented"); - - } - - public void log(String arg0) { - throw new RuntimeException("Function not implemented"); - - } - - public Enumeration getServlets() { - throw new RuntimeException("Function not implemented"); - - } - - public Enumeration getServletNames() { - throw new RuntimeException("Function not implemented"); - - } - - public String getServletContextName() { - return MockServletContext.class.getSimpleName(); - - } - - public Servlet getServlet(String arg0) throws ServletException { - throw new RuntimeException("Function not implemented"); - - } - - public String getServerInfo() { - throw new RuntimeException("Function not implemented"); - - } - - public Set getResourcePaths(String arg0) { - throw new RuntimeException("Function not implemented"); - - } - - public InputStream getResourceAsStream(String arg0) { - throw new RuntimeException("Function not implemented"); - - } - - public URL getResource(String arg0) throws MalformedURLException { - throw new RuntimeException("Function not implemented"); - - } - - public RequestDispatcher getRequestDispatcher(String arg0) { - throw new RuntimeException("Function not implemented"); - - } - - public String getRealPath(String arg0) { - throw new RuntimeException("Function not implemented"); - - } - - public RequestDispatcher getNamedDispatcher(String arg0) { - throw new RuntimeException("Function not implemented"); - - } - - public int getMinorVersion() { - return 4; - } - - public String getMimeType(String arg0) { - throw new RuntimeException("Function not implemented"); - - } - - public int getMajorVersion() { - return 2; - - } - - Properties initParams = new Properties(); - - public Enumeration getInitParameterNames() { - return initParams.elements(); - - } - - public String getInitParameter(String key) { - return initParams.getProperty(key); - - } - - public ServletContext getContext(String arg0) { - throw new RuntimeException("Function not implemented"); - - } - - public Enumeration getAttributeNames() { - throw new RuntimeException("Function not implemented"); - - } - - Map<String, Object> attributeMap; - - public Object getAttribute(String key) { - if (null == attributeMap) { - attributeMap = new HashMap<String, Object>(); - WebConfiguration wc = WebConfiguration.getInstance(this); - - attributeMap.put("com.sun.faces.config.WebConfiguration", wc); - } - - return attributeMap.get(key); - } -} \ No newline at end of file diff --git a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockServletContext.java.REMOTE.72367.java b/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockServletContext.java.REMOTE.72367.java deleted file mode 100644 index 8740aca..0000000 --- a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockServletContext.java.REMOTE.72367.java +++ /dev/null @@ -1,167 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2009 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -package org.rhq.core.gui.configuration; - -import java.io.InputStream; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; -import java.util.Set; - -import javax.servlet.RequestDispatcher; -import javax.servlet.Servlet; -import javax.servlet.ServletContext; -import javax.servlet.ServletException; - -import com.sun.faces.config.WebConfiguration; - -final class MockServletContext implements ServletContext { - public void setAttribute(String arg0, Object arg1) { - this.attributeMap.put(arg0, arg1); - - } - - public void removeAttribute(String arg0) { - attributeMap.remove(arg0); - - } - - public void log(String arg0, Throwable arg1) { - throw new RuntimeException("Function not implemented"); - - } - - public void log(Exception arg0, String arg1) { - throw new RuntimeException("Function not implemented"); - - } - - public void log(String arg0) { - throw new RuntimeException("Function not implemented"); - - } - - public Enumeration getServlets() { - throw new RuntimeException("Function not implemented"); - - } - - public Enumeration getServletNames() { - throw new RuntimeException("Function not implemented"); - - } - - public String getServletContextName() { - return MockServletContext.class.getSimpleName(); - - } - - public Servlet getServlet(String arg0) throws ServletException { - throw new RuntimeException("Function not implemented"); - - } - - public String getServerInfo() { - throw new RuntimeException("Function not implemented"); - - } - - public Set getResourcePaths(String arg0) { - throw new RuntimeException("Function not implemented"); - - } - - public InputStream getResourceAsStream(String arg0) { - throw new RuntimeException("Function not implemented"); - - } - - public URL getResource(String arg0) throws MalformedURLException { - throw new RuntimeException("Function not implemented"); - - } - - public RequestDispatcher getRequestDispatcher(String arg0) { - throw new RuntimeException("Function not implemented"); - - } - - public String getRealPath(String arg0) { - throw new RuntimeException("Function not implemented"); - - } - - public RequestDispatcher getNamedDispatcher(String arg0) { - throw new RuntimeException("Function not implemented"); - - } - - public int getMinorVersion() { - return 4; - } - - public String getMimeType(String arg0) { - throw new RuntimeException("Function not implemented"); - - } - - public int getMajorVersion() { - return 2; - - } - - Properties initParams = new Properties(); - - public Enumeration getInitParameterNames() { - return initParams.elements(); - - } - - public String getInitParameter(String key) { - return initParams.getProperty(key); - - } - - public ServletContext getContext(String arg0) { - throw new RuntimeException("Function not implemented"); - - } - - public Enumeration getAttributeNames() { - throw new RuntimeException("Function not implemented"); - - } - - Map<String, Object> attributeMap; - - public Object getAttribute(String key) { - if (null == attributeMap) { - attributeMap = new HashMap<String, Object>(); - WebConfiguration wc = WebConfiguration.getInstance(this); - - attributeMap.put("com.sun.faces.config.WebConfiguration", wc); - } - - return attributeMap.get(key); - } -} \ No newline at end of file
commit 960639d36e208c1d4a872bf9b441842746a73ca2 Merge: a8ff3e9... cfef08f... Author: John Sanda john@localhost.localdomain Date: Mon Dec 21 14:44:31 2009 -0500
Merge branch 'master' into raw-config
Conflicts: modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
diff --cc modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml index 5256543,ccca4f1..b1e873a --- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml +++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml @@@ -2029,8 -1980,18 +1987,18 @@@
<schemaSpec version="2.63"> <schema-addColumn table="RHQ_REPO" column="IS_CANDIDATE" columnType="BOOLEAN"/> + + <schema-directSQL> + <statement targetDBVendor="postgresql"> + UPDATE RHQ_REPO SET IS_CANDIDATE = FALSE + </statement> + <statement targetDBVendor="oracle"> + UPDATE RHQ_REPO SET IS_CANDIDATE = 0 + </statement> + </schema-directSQL> + <schema-alterColumn table="RHQ_REPO" column="IS_CANDIDATE" nullable="false" /> - </schemaSpec> + </schemaSpec>
<!-- Generic tagging support --> <schemaSpec version="2.64">
commit a8ff3e996cc73ed811d88127f8b34076a5ef1137 Author: John Sanda john@localhost.localdomain Date: Sun Dec 20 15:54:53 2009 -0500
Refactoring facelets code so that the appropriate ui is rendered for the config type
Refactoring view.xhtml to support both structured and raw. With these changes, we now only see structured UI for a config that supports only structured, we only see the raw ui for a config that supports only raw, and we see both structured and raw for a config that supports that both.
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java index 3189d79..b6aa356 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java @@ -311,11 +311,17 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI }
public boolean isRawSupported() { - return getConfigurationFormat().isRawSupported(); +// return getConfigurationFormat().isRawSupported(); + return getConfigurationDefinition().getConfigurationFormat() == ConfigurationFormat.RAW; }
public boolean isStructuredSupported() { - return getConfigurationFormat().isStructuredSupported(); +// return getConfigurationFormat().isStructuredSupported(); + return getConfigurationDefinition().getConfigurationFormat() == ConfigurationFormat.STRUCTURED; + } + + public boolean isStructuredAndRawSupported() { + return getConfigurationDefinition().getConfigurationFormat() == ConfigurationFormat.STRUCTURED_AND_RAW; }
void nullify() { diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeStateAdvisor.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeStateAdvisor.java index 1ed9f52..6fee523 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeStateAdvisor.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeStateAdvisor.java @@ -118,7 +118,8 @@ public class ResourceTreeStateAdvisor implements TreeStateAdvisor { || (path.startsWith("/rhq/resource/events") && !facets.isEvent())) { // This resource doesn't support those facets path = fallbackPath; - } else if (path.startsWith("/rhq/resource/configuration/edit.xhtml") + } else if ((path.startsWith("/rhq/resource/configuration/edit.xhtml") || + path.startsWith("/rhq/resource/configuration/edit-raw.xhtml")) && facets.isConfiguration()) { path = "/rhq/resource/configuration/view.xhtml"; } else if (!path.startsWith("/rhq/resource/content/view.xhtml") diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/configuration-navigation.xml b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/configuration-navigation.xml index 302fdff..8f0749c 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/configuration-navigation.xml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/configuration-navigation.xml @@ -14,7 +14,7 @@ </navigation-case>
<navigation-case> - <from-action>#{ExistingResourceConfigurationUIBean.editRawConfiguration}</from-action> + <from-action>#{ExistingResourceConfigurationViewUIBean.editRawConfiguration}</from-action> <to-view-id>/rhq/resource/configuration/edit-raw.xhtml?id=#{param.id}</to-view-id> <redirect/> </navigation-case> @@ -39,7 +39,7 @@ <to-view-id>/rhq/resource/configuration/edit-raw.xhtml?id=#{param.id}</to-view-id> </navigation-case> </navigation-rule> - + <navigation-rule>
<from-view-id>/rhq/resource/configuration/edit-raw.xhtml</from-view-id> @@ -50,11 +50,10 @@ <to-view-id>/rhq/resource/configuration/history.xhtml?id=#{param.id}</to-view-id> <redirect/> </navigation-case> - - - </navigation-rule>
+ </navigation-rule> + <navigation-rule>
<from-view-id>/rhq/resource/configuration/edit.xhtml</from-view-id> diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit-raw.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit-raw.xhtml index bf05c9b..d2b8dac 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit-raw.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit-raw.xhtml @@ -33,9 +33,9 @@ } </script> <a4j:form id="editResourceConfigurationForm"> - - <h:outputText value="#{messages.youareviewingraw}" /> - <h:panelGroup rendered="#{ExistingResourceConfigurationUIBean.structuredSupported}"> + + <h:outputText value="#{messages.youareviewingraw}" /> + <h:panelGroup rendered="#{ExistingResourceConfigurationUIBean.structuredAndRawSupported}"> <h:outputText value=" #{messages.switch2}" /> <h:commandLink action="#{ExistingResourceConfigurationUIBean.switchTostructured}"> <f:param name="conversationId" value="#{conversation.id}"/> diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml index d067d8a..9a8dec6 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml @@ -30,7 +30,7 @@ THIS TEXT WILL BE REMOVED.
<h:outputText value="#{messages.youareviewingstructured}" /> - <h:panelGroup rendered="#{ExistingResourceConfigurationUIBean.rawSupported}" > + <h:panelGroup rendered="#{ExistingResourceConfigurationUIBean.structuredAndRawSupported}" > <h:outputText value=" #{messages.switch2}" /> <h:commandLink action="#{ExistingResourceConfigurationUIBean.switchToraw}" > <f:param name="conversationId" value="#{conversation.id}"/> @@ -58,7 +58,6 @@ THIS TEXT WILL BE REMOVED. <h:panelGroup layout="block" styleClass="InfoBlock" rendered="#{ExistingResourceConfigurationUIBean.updateInProgress}"> <b>${msg['note']}</b> ${msg['resource.config.Current.updateInProgress']} </h:panelGroup> - </ui:define>
</ui:composition> diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml index 72da244..8a39f83 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml @@ -1,75 +1,188 @@ <?xml version="1.0"?>
<!DOCTYPE html - PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd%22%3E
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:c="http://java.sun.com/jstl/core" - xmlns:onc="http://jboss.org/on/component%22%3E + xmlns:onc="http://jboss.org/on/component" + xmlns:s="http://jboss.com/products/seam/taglib%22%3E
THIS TEXT WILL BE REMOVED.
<ui:composition template="/rhq/resource/layout/main.xhtml">
- THIS TEXT WILL BE REMOVED AS WELL. - - <ui:param name="pageTitle" value="#{ResourceUIBean.resourceType.name} '#{ResourceUIBean.name}' - View Configuration"/> - - <ui:param name="selectedTabName" value="Configuration.Current"/> - - <ui:define name="content"> - - <h:panelGroup layout="block" styleClass="InfoBlock" rendered="#{ExistingResourceConfigurationUIBean.updateInProgress}"> - <b>${msg['note']}</b> ${msg['resource.config.Current.updateInProgress']} - </h:panelGroup> - - <h:outputText value="#{messages.youareviewingstructured}" /> - <h:panelGroup rendered="#{ExistingResourceConfigurationUIBean.rawSupported}" > - <h:outputText value=" #{messages.switch2}" /> - <h:outputLink value="view-raw.xhtml"> - <f:param name="id" value="#{ResourceUIBean.id}" /> - <h:outputText value=" #{messages.raw}" /> - </h:outputLink> - </h:panelGroup> - - <h:outputText value=" #{messages.nopermissionedit}" rendered="#{!ResourceUIBean.permissions.configure}"/> - - <h:form id="viewResourceConfigurationForm"> - <!-- TODO remove the id version --> - <input type="hidden" name="id" value="#{ResourceUIBean.id}"/> - - <h:panelGrid columns="2" styleClass="buttons-table" columnClasses="button-cell" - rendered="#{ExistingResourceConfigurationViewUIBean.configuration != null and !ExistingResourceConfigurationViewUIBean.updateInProgress}"> - - <h:commandButton value="#{messages.editstructured}" action="#{ExistingResourceConfigurationViewUIBean.editConfiguration}" - title="Edit this Configuration" styleClass="buttonmed" - rendered="${ResourceUIBean.permissions.configure and ExistingResourceConfigurationViewUIBean.structuredSupported and !ExistingResourceConfigurationViewUIBean.updateInProgress}" /> - <h:commandButton value="#{messages.editraw}" action="#{ExistingResourceConfigurationUIBean.editRawConfiguration}" - title="Advanced Mode Edit of Raw Configuration Files" styleClass="buttonmed" - rendered="${ResourceUIBean.permissions.configure and ExistingResourceConfigurationViewUIBean.rawSupported and !ExistingResourceConfigurationViewUIBean.updateInProgress}" /> - </h:panelGrid> - - <onc:config configurationDefinition="#{ExistingResourceConfigurationViewUIBean.configurationDefinition}" - configuration="#{ExistingResourceConfigurationViewUIBean.configuration}" - accessMapActionExpression="#{ExistingResourceConfigurationViewUIBean.accessMap}" - readOnly="true" - nullConfigurationDefinitionMessage="#{ExistingResourceConfigurationViewUIBean.nullConfigurationDefinitionMessage}" - nullConfigurationMessage="#{ExistingResourceConfigurationViewUIBean.nullConfigurationMessage}" - prevalidate="true"/> - - </h:form> - - <h:panelGroup layout="block" styleClass="InfoBlock" rendered="#{ExistingResourceConfigurationViewUIBean.updateInProgress}"> - <b>${msg['note']}</b> ${msg['resource.config.Current.updateInProgress']} - </h:panelGroup> - - - </ui:define> + THIS TEXT WILL BE REMOVED AS WELL. + + <ui:param name="pageTitle" + value="#{ResourceUIBean.resourceType.name} '#{ResourceUIBean.name}' - View Configuration"/> + + <ui:param name="selectedTabName" value="Configuration.Current"/> + + <ui:define name="content"> + <h:panelGroup layout="block" styleClass="InfoBlock" + rendered="#{ExistingResourceConfigurationUIBean.updateInProgress}"> + <b>${msg['note']}</b> ${msg['resource.config.Current.updateInProgress']} + </h:panelGroup> + + <c:choose> + <c:when test="${ExistingResourceConfigurationViewUIBean.rawSupported}"> + <script> + window.onbeforeunload = confirmExit; + + function confirmExit() { + } + </script> + + <h:outputText value="#{messages.youareviewingraw}"/> + <h:outputText value=" #{messages.nopermissionedit}" + rendered="#{!ResourceUIBean.permissions.configure}"/> + <h:form id="viewResourceConfigurationFormRaw"> + <input type="hidden" name="id" value="#{ResourceUIBean.id}"/> + + <h:panelGrid columns="2" + styleClass="buttons-table" + columnClasses="button-cell" + rendered="#{ExistingResourceConfigurationViewUIBean.configuration != null and !ExistingResourceConfigurationViewUIBean.updateInProgress}"> + + <h:commandButton value="#{messages.editraw}" + action="#{ExistingResourceConfigurationViewUIBean.editRawConfiguration}" + title="Advanced Mode Edit of Raw Configuration Files" styleClass="buttonmed" + rendered="${ResourceUIBean.permissions.configure and !ExistingResourceConfigurationUIBean.updateInProgress}"/> + </h:panelGrid> + </h:form> + + <table class="summary-props-table" style=""> + <tr> + <td bgcolor="#a4b2b9" width="25%" valign="top">Files + <h:panelGroup id="changedFiles" layout="vertical"> + <h:form> + <input type="hidden" name="id" value="#{ResourceUIBean.id}"/> + <ui:repeat value="#{ExistingResourceConfigurationViewUIBean.paths}" var="path"> + <div> + <h:commandLink + action="#{ExistingResourceConfigurationViewUIBean.select(path)}" + value="#{path}" + rendered="#{path != ExistingResourceConfigurationViewUIBean.current.path}"> + <f:param name="currentPath" value="#{path}"/> + </h:commandLink> + <h:outputText value="#{path}" + rendered="#{path == ExistingResourceConfigurationViewUIBean.current.path}"/> + </div> + </ui:repeat> + </h:form> + </h:panelGroup> + <div>______________________________________</div> + <div>* File contains uncommitted changes.</div> + </td> + <td> + <div> + Current File: + <h:outputText value="#{ExistingResourceConfigurationViewUIBean.current.path}" + styleClass="outhello"/> + </div> + <h:outputLink value="view-raw-full.xhtml" action="navigateToUpload"> + <img src="/images/viewfullscreen.png"/> + <h:outputText value=" Full Screen "/> + <f:param name="id" value="#{ResourceUIBean.id}"/> + </h:outputLink> + <s:link action="#{ExistingResourceConfigurationViewUIBean.download}"> + <img src="/images/download.png"/> + <h:outputText value=" Download "/> + <f:param name="id" value="#{ResourceUIBean.id}"/> + </s:link> + <div> + <pre><h:outputText + value="#{ExistingResourceConfigurationViewUIBean.currentContents}"/></pre> + </div> + </td> + </tr> + </table> + </c:when> + <c:when test="${ExistingResourceConfigurationViewUIBean.structuredSupported}"> + <h:outputText value="#{messages.youareviewingstructured}"/> + <h:outputText value=" #{messages.nopermissionedit}" + rendered="#{!ResourceUIBean.permissions.configure}"/> + <h:form id="viewResourceConfigurationFormStructured"> + <!-- TODO remove the id version --> + <input type="hidden" name="id" value="#{ResourceUIBean.id}"/> + + <h:panelGrid columns="2" + styleClass="buttons-table" + columnClasses="button-cell" + rendered="#{ExistingResourceConfigurationViewUIBean.configuration != null and !ExistingResourceConfigurationViewUIBean.updateInProgress}"> + + <h:commandButton value="#{messages.editstructured}" + action="#{ExistingResourceConfigurationViewUIBean.editConfiguration}" + title="Edit this Configuration" + styleClass="buttonmed" + rendered="${ResourceUIBean.permissions.configure and !ExistingResourceConfigurationViewUIBean.updateInProgress}"/> + </h:panelGrid> + + <onc:config + configurationDefinition="#{ExistingResourceConfigurationViewUIBean.configurationDefinition}" + configuration="#{ExistingResourceConfigurationViewUIBean.configuration}" + accessMapActionExpression="#{ExistingResourceConfigurationViewUIBean.accessMap}" + readOnly="true" + nullConfigurationDefinitionMessage="#{ExistingResourceConfigurationViewUIBean.nullConfigurationDefinitionMessage}" + nullConfigurationMessage="#{ExistingResourceConfigurationViewUIBean.nullConfigurationMessage}" + prevalidate="true"/> + + </h:form> + </c:when> + <c:when test="${ExistingResourceConfigurationViewUIBean.structuredAndRawSupported}"> + <h:outputText value="#{messages.youareviewingstructured}"/> + <h:panelGroup rendered="#{ExistingResourceConfigurationUIBean.rawSupported}"> + <h:outputText value=" #{messages.switch2}"/> + <h:outputLink value="view-raw.xhtml"> + <f:param name="id" value="#{ResourceUIBean.id}"/> + <h:outputText value=" #{messages.raw}"/> + </h:outputLink> + </h:panelGroup> + <h:outputText value=" #{messages.nopermissionedit}" + rendered="#{!ResourceUIBean.permissions.configure}"/> + <h:form id="viewResourceConfigurationFormStructuredAndRaw"> + <!-- TODO remove the id version --> + <input type="hidden" name="id" value="#{ResourceUIBean.id}"/> + + <h:panelGrid columns="2" styleClass="buttons-table" columnClasses="button-cell" + rendered="#{ExistingResourceConfigurationViewUIBean.configuration != null and !ExistingResourceConfigurationViewUIBean.updateInProgress}"> + + <h:commandButton value="#{messages.editstructured}" + action="#{ExistingResourceConfigurationViewUIBean.editConfiguration}" + title="Edit this Configuration" styleClass="buttonmed" + rendered="${ResourceUIBean.permissions.configure and !ExistingResourceConfigurationViewUIBean.updateInProgress}"/> + <h:commandButton value="#{messages.editraw}" + action="#{ExistingResourceConfigurationViewUIBean.editRawConfiguration}" + title="Advanced Mode Edit of Raw Configuration Files" styleClass="buttonmed" + rendered="${ResourceUIBean.permissions.configure and !ExistingResourceConfigurationViewUIBean.updateInProgress}"/> + </h:panelGrid> + + <onc:config + configurationDefinition="#{ExistingResourceConfigurationViewUIBean.configurationDefinition}" + configuration="#{ExistingResourceConfigurationViewUIBean.configuration}" + accessMapActionExpression="#{ExistingResourceConfigurationViewUIBean.accessMap}" + readOnly="true" + nullConfigurationDefinitionMessage="#{ExistingResourceConfigurationViewUIBean.nullConfigurationDefinitionMessage}" + nullConfigurationMessage="#{ExistingResourceConfigurationViewUIBean.nullConfigurationMessage}" + prevalidate="true"/> + + </h:form> + </c:when> + </c:choose> + + <h:panelGroup layout="block" styleClass="InfoBlock" + rendered="#{ExistingResourceConfigurationViewUIBean.updateInProgress}"> + <b>${msg['note']}</b> ${msg['resource.config.Current.updateInProgress']} + </h:panelGroup> + + + </ui:define>
</ui:composition>
commit b150dcc1c85be1b4df9b3fba3b4849ee3f60b520 Author: John Sanda john@localhost.localdomain Date: Fri Dec 18 16:48:22 2009 -0500
Reverting back to previous functionality (for now)
diff --git a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/ConfigRenderer.java b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/ConfigRenderer.java index 2ebbc53..87bd52c 100644 --- a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/ConfigRenderer.java +++ b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/ConfigRenderer.java @@ -249,16 +249,14 @@ public class ConfigRenderer extends Renderer { // No index specified means we should add a new map to the list. configurationComponent.setListIndex(addNewMap(configurationComponent)); } - - addListMemberProperty(configurationComponent); - } else { - addConfiguration(configurationComponent); - } - - String id = getInitInputsJavaScriptComponentId(configurationComponent); - PropertyRenderingUtility.addInitInputsJavaScript(configurationComponent, id, configurationComponent - .isFullyEditable(), false); + addListMemberProperty(configurationComponent); + } else { + addConfiguration(configurationComponent); } + + String id = getInitInputsJavaScriptComponentId(configurationComponent); + PropertyRenderingUtility.addInitInputsJavaScript(configurationComponent, id, configurationComponent + .isFullyEditable(), false); }
private void addListMemberProperty(AbstractConfigurationComponent configurationComponent) { diff --git a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockServletContext.java.BACKUP.72367.java b/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockServletContext.java.BACKUP.72367.java new file mode 100644 index 0000000..8740aca --- /dev/null +++ b/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockServletContext.java.BACKUP.72367.java @@ -0,0 +1,167 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2009 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +package org.rhq.core.gui.configuration; + +import java.io.InputStream; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; +import java.util.Set; + +import javax.servlet.RequestDispatcher; +import javax.servlet.Servlet; +import javax.servlet.ServletContext; +import javax.servlet.ServletException; + +import com.sun.faces.config.WebConfiguration; + +final class MockServletContext implements ServletContext { + public void setAttribute(String arg0, Object arg1) { + this.attributeMap.put(arg0, arg1); + + } + + public void removeAttribute(String arg0) { + attributeMap.remove(arg0); + + } + + public void log(String arg0, Throwable arg1) { + throw new RuntimeException("Function not implemented"); + + } + + public void log(Exception arg0, String arg1) { + throw new RuntimeException("Function not implemented"); + + } + + public void log(String arg0) { + throw new RuntimeException("Function not implemented"); + + } + + public Enumeration getServlets() { + throw new RuntimeException("Function not implemented"); + + } + + public Enumeration getServletNames() { + throw new RuntimeException("Function not implemented"); + + } + + public String getServletContextName() { + return MockServletContext.class.getSimpleName(); + + } + + public Servlet getServlet(String arg0) throws ServletException { + throw new RuntimeException("Function not implemented"); + + } + + public String getServerInfo() { + throw new RuntimeException("Function not implemented"); + + } + + public Set getResourcePaths(String arg0) { + throw new RuntimeException("Function not implemented"); + + } + + public InputStream getResourceAsStream(String arg0) { + throw new RuntimeException("Function not implemented"); + + } + + public URL getResource(String arg0) throws MalformedURLException { + throw new RuntimeException("Function not implemented"); + + } + + public RequestDispatcher getRequestDispatcher(String arg0) { + throw new RuntimeException("Function not implemented"); + + } + + public String getRealPath(String arg0) { + throw new RuntimeException("Function not implemented"); + + } + + public RequestDispatcher getNamedDispatcher(String arg0) { + throw new RuntimeException("Function not implemented"); + + } + + public int getMinorVersion() { + return 4; + } + + public String getMimeType(String arg0) { + throw new RuntimeException("Function not implemented"); + + } + + public int getMajorVersion() { + return 2; + + } + + Properties initParams = new Properties(); + + public Enumeration getInitParameterNames() { + return initParams.elements(); + + } + + public String getInitParameter(String key) { + return initParams.getProperty(key); + + } + + public ServletContext getContext(String arg0) { + throw new RuntimeException("Function not implemented"); + + } + + public Enumeration getAttributeNames() { + throw new RuntimeException("Function not implemented"); + + } + + Map<String, Object> attributeMap; + + public Object getAttribute(String key) { + if (null == attributeMap) { + attributeMap = new HashMap<String, Object>(); + WebConfiguration wc = WebConfiguration.getInstance(this); + + attributeMap.put("com.sun.faces.config.WebConfiguration", wc); + } + + return attributeMap.get(key); + } +} \ No newline at end of file diff --git a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockServletContext.java.BASE.72367.java b/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockServletContext.java.BASE.72367.java new file mode 100644 index 0000000..f604d00 --- /dev/null +++ b/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockServletContext.java.BASE.72367.java @@ -0,0 +1,166 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2009 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +package org.rhq.core.gui.configuration; + +import java.io.InputStream; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; +import java.util.Set; + +import javax.servlet.RequestDispatcher; +import javax.servlet.Servlet; +import javax.servlet.ServletContext; +import javax.servlet.ServletException; + +import com.sun.faces.config.WebConfiguration; +final class MockServletContext implements ServletContext { + public void setAttribute(String arg0, Object arg1) { + this.attributeMap.put(arg0, arg1); + + } + + public void removeAttribute(String arg0) { + attributeMap.remove(arg0); + + } + + public void log(String arg0, Throwable arg1) { + throw new RuntimeException("Function not implemented"); + + } + + public void log(Exception arg0, String arg1) { + throw new RuntimeException("Function not implemented"); + + } + + public void log(String arg0) { + throw new RuntimeException("Function not implemented"); + + } + + public Enumeration getServlets() { + throw new RuntimeException("Function not implemented"); + + } + + public Enumeration getServletNames() { + throw new RuntimeException("Function not implemented"); + + } + + public String getServletContextName() { + return MockServletContext.class.getSimpleName(); + + } + + public Servlet getServlet(String arg0) throws ServletException { + throw new RuntimeException("Function not implemented"); + + } + + public String getServerInfo() { + throw new RuntimeException("Function not implemented"); + + } + + public Set getResourcePaths(String arg0) { + throw new RuntimeException("Function not implemented"); + + } + + public InputStream getResourceAsStream(String arg0) { + throw new RuntimeException("Function not implemented"); + + } + + public URL getResource(String arg0) throws MalformedURLException { + throw new RuntimeException("Function not implemented"); + + } + + public RequestDispatcher getRequestDispatcher(String arg0) { + throw new RuntimeException("Function not implemented"); + + } + + public String getRealPath(String arg0) { + throw new RuntimeException("Function not implemented"); + + } + + public RequestDispatcher getNamedDispatcher(String arg0) { + throw new RuntimeException("Function not implemented"); + + } + + public int getMinorVersion() { + return 4; + } + + public String getMimeType(String arg0) { + throw new RuntimeException("Function not implemented"); + + } + + public int getMajorVersion() { + return 2; + + } + + Properties initParams = new Properties(); + + public Enumeration getInitParameterNames() { + return initParams.elements(); + + } + + public String getInitParameter(String key) { + return initParams.getProperty(key); + + } + + public ServletContext getContext(String arg0) { + throw new RuntimeException("Function not implemented"); + + } + + public Enumeration getAttributeNames() { + throw new RuntimeException("Function not implemented"); + + } + + Map<String, Object> attributeMap; + + public Object getAttribute(String key) { + if (null == attributeMap) { + attributeMap = new HashMap<String, Object>(); + WebConfiguration wc = WebConfiguration.getInstance(this); + + attributeMap.put("com.sun.faces.config.WebConfiguration", wc); + } + + return attributeMap.get(key); + } +} \ No newline at end of file diff --git a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockServletContext.java.REMOTE.72367.java b/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockServletContext.java.REMOTE.72367.java new file mode 100644 index 0000000..8740aca --- /dev/null +++ b/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockServletContext.java.REMOTE.72367.java @@ -0,0 +1,167 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2009 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +package org.rhq.core.gui.configuration; + +import java.io.InputStream; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; +import java.util.Set; + +import javax.servlet.RequestDispatcher; +import javax.servlet.Servlet; +import javax.servlet.ServletContext; +import javax.servlet.ServletException; + +import com.sun.faces.config.WebConfiguration; + +final class MockServletContext implements ServletContext { + public void setAttribute(String arg0, Object arg1) { + this.attributeMap.put(arg0, arg1); + + } + + public void removeAttribute(String arg0) { + attributeMap.remove(arg0); + + } + + public void log(String arg0, Throwable arg1) { + throw new RuntimeException("Function not implemented"); + + } + + public void log(Exception arg0, String arg1) { + throw new RuntimeException("Function not implemented"); + + } + + public void log(String arg0) { + throw new RuntimeException("Function not implemented"); + + } + + public Enumeration getServlets() { + throw new RuntimeException("Function not implemented"); + + } + + public Enumeration getServletNames() { + throw new RuntimeException("Function not implemented"); + + } + + public String getServletContextName() { + return MockServletContext.class.getSimpleName(); + + } + + public Servlet getServlet(String arg0) throws ServletException { + throw new RuntimeException("Function not implemented"); + + } + + public String getServerInfo() { + throw new RuntimeException("Function not implemented"); + + } + + public Set getResourcePaths(String arg0) { + throw new RuntimeException("Function not implemented"); + + } + + public InputStream getResourceAsStream(String arg0) { + throw new RuntimeException("Function not implemented"); + + } + + public URL getResource(String arg0) throws MalformedURLException { + throw new RuntimeException("Function not implemented"); + + } + + public RequestDispatcher getRequestDispatcher(String arg0) { + throw new RuntimeException("Function not implemented"); + + } + + public String getRealPath(String arg0) { + throw new RuntimeException("Function not implemented"); + + } + + public RequestDispatcher getNamedDispatcher(String arg0) { + throw new RuntimeException("Function not implemented"); + + } + + public int getMinorVersion() { + return 4; + } + + public String getMimeType(String arg0) { + throw new RuntimeException("Function not implemented"); + + } + + public int getMajorVersion() { + return 2; + + } + + Properties initParams = new Properties(); + + public Enumeration getInitParameterNames() { + return initParams.elements(); + + } + + public String getInitParameter(String key) { + return initParams.getProperty(key); + + } + + public ServletContext getContext(String arg0) { + throw new RuntimeException("Function not implemented"); + + } + + public Enumeration getAttributeNames() { + throw new RuntimeException("Function not implemented"); + + } + + Map<String, Object> attributeMap; + + public Object getAttribute(String key) { + if (null == attributeMap) { + attributeMap = new HashMap<String, Object>(); + WebConfiguration wc = WebConfiguration.getInstance(this); + + attributeMap.put("com.sun.faces.config.WebConfiguration", wc); + } + + return attributeMap.get(key); + } +} \ No newline at end of file diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/configuration-navigation.xml b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/configuration-navigation.xml index bd0f1bf..302fdff 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/configuration-navigation.xml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/configuration-navigation.xml @@ -8,7 +8,7 @@
<navigation-case> - <from-action>#{ExistingResourceConfigurationUIBean.editConfiguration}</from-action> + <from-action>#{ExistingResourceConfigurationViewUIBean.editConfiguration}</from-action> <to-view-id>/rhq/resource/configuration/edit.xhtml?id=#{param.id}</to-view-id> <redirect/> </navigation-case> @@ -35,7 +35,7 @@ <navigation-rule> <from-view-id>/rhq/resource/configuration/edit-raw-full.xhtml</from-view-id> <navigation-case> - <from-action> #{RawConfigCollection.update}</from-action> + <from-action>#{RawConfigCollection.update}</from-action> <to-view-id>/rhq/resource/configuration/edit-raw.xhtml?id=#{param.id}</to-view-id> </navigation-case> </navigation-rule>
commit cbf7ccd26f442f75741d246fe4cc476d5bbc89d1 Author: John Sanda john@localhost.localdomain Date: Fri Dec 18 15:35:04 2009 -0500
Removing check for config property definitions in findResourceConfigurationUpdates()
The check does not really make sense in light of adding raw config. With a resource that supports raw config, the config does not have to have any properties.
Conflicts:
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java index fb82e6e..fbae47d 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java @@ -842,10 +842,6 @@ public class ConfigurationManagerBean implements ConfigurationManagerLocal, Conf }
Resource resource = entityManager.find(Resource.class, resourceId); - if (resource.getResourceType().getResourceConfigurationDefinition() == null - || resource.getResourceType().getResourceConfigurationDefinition().getPropertyDefinitions().isEmpty()) { - return new PageList<ResourceConfigurationUpdate>(pc); - }
pc.initDefaultOrderingField("cu.id", PageOrdering.DESC);
commit e101f7c1b57be786bd882aac8a9562d8e1e7634a Author: John Sanda jsanda@redhat.com Date: Tue Dec 15 07:36:52 2009 -0500
[BZ 537891] Fixing bug in which required query parameter was not getted appended to url
The resource id is expected to be a parameter in the request. When on edit-raw.xhtml and clicking the link to go back to structured, the resource id basically gets dropped and then navigating to any other page, tab, etc. that expects the id parameter results in an exception. I added a new navigation rule similar to one already defined for edit.xhtml (structured edit page) that adds the id to the request and does a server side redirect.
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java index bb93d81..3189d79 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java @@ -417,7 +417,8 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI current = null; setConfiguration(configuration);
- return "/rhq/resource/configuration/edit.xhtml?currentResourceId=" + getResourceId(); +// return "/rhq/resource/configuration/edit.xhtml?currentResourceId=" + getResourceId(); + return SUCCESS_OUTCOME; }
void populateRaws() { @@ -450,4 +451,4 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI TreeMap<String, RawConfiguration> modified = new TreeMap<String, RawConfiguration>(); RawConfiguration current = null;
-} \ No newline at end of file +} diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/configuration-navigation.xml b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/configuration-navigation.xml index 4443b36..bd0f1bf 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/configuration-navigation.xml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/configuration-navigation.xml @@ -23,6 +23,12 @@ <from-action>#{ConfigHelperUIBean.accessMap}</from-action> <to-view-id>/rhq/resource/configuration/view-map.xhtml</to-view-id> </navigation-case> + + <navigation-case> + <from-action>#{ExistingResourceConfigurationUIBean.switchTostructured}</from-action> + <to-view-id>/rhq/resource/configuration/edit.xhtml?id=#{param.id}</to-view-id> + <redirect/> + </navigation-case>
</navigation-rule>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit-raw.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit-raw.xhtml index c01694e..bf05c9b 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit-raw.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit-raw.xhtml @@ -35,10 +35,10 @@ <a4j:form id="editResourceConfigurationForm"> <h:outputText value="#{messages.youareviewingraw}" /> - <h:panelGroup rendered="#{ExistingResourceConfigurationUIBean.structuredSupported}"> + <h:panelGroup rendered="#{ExistingResourceConfigurationUIBean.structuredSupported}"> <h:outputText value=" #{messages.switch2}" /> <h:commandLink action="#{ExistingResourceConfigurationUIBean.switchTostructured}"> - <s:conversationId /> + <f:param name="conversationId" value="#{conversation.id}"/> <f:param name="id" value="#{ResourceUIBean.id}" /> <h:outputText value=" #{messages.structured}" /> </h:commandLink>
commit 321252a12867598044449a02a9b9982a0d662b9c Author: John Sanda jsanda@redhat.com Date: Mon Dec 14 22:34:48 2009 -0500
[BZ 538088] Reverting back to using the view ui bean which only has a request scope.
view.xhtml in several places in the JSF code was making calls to ExistingResourceConfigurationUIBean which has session scope. As a result, external config updagtes were not immediately visible because the configuration objects were getting cached for the duration of the session, whereas ExistingResourceConfigurationViewUIBean has a scope of request so every request for the view page results in fetching the latest configuration for the resource.
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml index 0d4899f..72da244 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml @@ -44,27 +44,27 @@ THIS TEXT WILL BE REMOVED. <input type="hidden" name="id" value="#{ResourceUIBean.id}"/>
<h:panelGrid columns="2" styleClass="buttons-table" columnClasses="button-cell" - rendered="#{ExistingResourceConfigurationUIBean.configuration != null and !ExistingResourceConfigurationUIBean.updateInProgress}"> + rendered="#{ExistingResourceConfigurationViewUIBean.configuration != null and !ExistingResourceConfigurationViewUIBean.updateInProgress}">
- <h:commandButton value="#{messages.editstructured}" action="#{ExistingResourceConfigurationUIBean.editConfiguration}" + <h:commandButton value="#{messages.editstructured}" action="#{ExistingResourceConfigurationViewUIBean.editConfiguration}" title="Edit this Configuration" styleClass="buttonmed" - rendered="${ResourceUIBean.permissions.configure and ExistingResourceConfigurationUIBean.structuredSupported and !ExistingResourceConfigurationUIBean.updateInProgress}" /> + rendered="${ResourceUIBean.permissions.configure and ExistingResourceConfigurationViewUIBean.structuredSupported and !ExistingResourceConfigurationViewUIBean.updateInProgress}" /> <h:commandButton value="#{messages.editraw}" action="#{ExistingResourceConfigurationUIBean.editRawConfiguration}" title="Advanced Mode Edit of Raw Configuration Files" styleClass="buttonmed" - rendered="${ResourceUIBean.permissions.configure and ExistingResourceConfigurationUIBean.rawSupported and !ExistingResourceConfigurationUIBean.updateInProgress}" /> + rendered="${ResourceUIBean.permissions.configure and ExistingResourceConfigurationViewUIBean.rawSupported and !ExistingResourceConfigurationViewUIBean.updateInProgress}" /> </h:panelGrid>
- <onc:config configurationDefinition="#{ExistingResourceConfigurationUIBean.configurationDefinition}" - configuration="#{ExistingResourceConfigurationUIBean.configuration}" - accessMapActionExpression="#{ExistingResourceConfigurationUIBean.accessMap}" + <onc:config configurationDefinition="#{ExistingResourceConfigurationViewUIBean.configurationDefinition}" + configuration="#{ExistingResourceConfigurationViewUIBean.configuration}" + accessMapActionExpression="#{ExistingResourceConfigurationViewUIBean.accessMap}" readOnly="true" - nullConfigurationDefinitionMessage="#{ExistingResourceConfigurationUIBean.nullConfigurationDefinitionMessage}" - nullConfigurationMessage="#{ExistingResourceConfigurationUIBean.nullConfigurationMessage}" + nullConfigurationDefinitionMessage="#{ExistingResourceConfigurationViewUIBean.nullConfigurationDefinitionMessage}" + nullConfigurationMessage="#{ExistingResourceConfigurationViewUIBean.nullConfigurationMessage}" prevalidate="true"/>
</h:form>
- <h:panelGroup layout="block" styleClass="InfoBlock" rendered="#{ExistingResourceConfigurationUIBean.updateInProgress}"> + <h:panelGroup layout="block" styleClass="InfoBlock" rendered="#{ExistingResourceConfigurationViewUIBean.updateInProgress}"> <b>${msg['note']}</b> ${msg['resource.config.Current.updateInProgress']} </h:panelGroup>
commit 40d8d126507fd024140f71a2e043eea0346b3ea1 Author: John Sanda jsanda@redhat.com Date: Fri Dec 11 11:14:36 2009 -0500
Renaming script to something more logical
diff --git a/modules/enterprise/remoting/scripts/src/main/script/configuration/config_util.js b/modules/enterprise/remoting/scripts/src/main/script/configuration/config_util.js new file mode 100644 index 0000000..54c39a9 --- /dev/null +++ b/modules/enterprise/remoting/scripts/src/main/script/configuration/config_util.js @@ -0,0 +1,287 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2008 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +var waitInterval = 100; +var structured = true; +var raw = false; + +loadResourceTypes(); + +function loadResourceTypes() { + var resourceTypes = context.getAttribute('resourceTypes'); + if (resourceTypes != null && !resourceTypes.isEmpty()) { + return; + } + + var criteria = ResourceTypeCriteria(); + criteria.fetchResourceConfigurationDefinition(true); + + resourceTypes = ResourceTypeManager.findResourceTypesByCriteria(criteria); + context.setAttribute('resourceTypes', resourceTypes, javax.script.ScriptContext.ENGINE_SCOPE); +} + +function ConfigUtil(resourceName) { + var util = this; + + this.resource = findServer(resourceName); + + this.getLatestConfiguration = function () { + var latestUpdate = ConfigurationManager.getLatestResourceConfigurationUpdate(this.resource.id); + + Assert.assertNotNull( + latestUpdate, + "Failed to load the latest resource configuration update for " + this.resource.name + ); + Assert.assertNotNull( + latestUpdate.configuration, + "No configuration is attached to the latest config update object." + ); + + return latestUpdate.configuration; + } + + this.printLatestConfiguration = function() { + var configuration = this.getLatestConfiguration(); + printConfiguration(configuration); + } + + function printConfiguration(configuration) { + pretty.print(configuration); + + if (util.isRawSupported() || util.isStructuredAndRawSupported()) { + println("\nRaw configuration files:"); + var rawConfigs = java.util.ArrayList(configuration.rawConfigurations); + for (i = 0; i < rawConfigs.size(); i++) { + var rawConfig = rawConfigs.get(i); + println("\n[" + rawConfig.path + "]"); + println(java.lang.String(rawConfig.contents) + "\n\n---------------------"); + } + } + } + + this.translateToRaw = function(update) { + doTranslation(update, true); + } + + this.translateToStructured = function(update) { + doTranslation(update, false); + } + + function doTranslation(update, doStructured) { + println("Loading latest configuration for " + util.resource.name); + var configuration = util.getLatestConfiguration(); + + printConfiguration(configuration) + println(''); + + if (doStructured) { + doStructuredUpdate(util.resource, configuration, update); + } + else { + doRawUpdate(util.resource, configuration, update); + } + + println("Modified configuration..."); + printConfiguration(configuration) + println(''); + + var translatedConfig = ConfigurationManager.translateResourceConfiguration(util.resource.id, configuration, + doStructured); + + println("Translated configuration..."); + printConfiguration(translatedConfig); + println(''); + } + + this.updateConfiguration = function(update, doStructured) { + println("Loading latest configuration for " + this.resource.name); + var configuration = this.getLatestConfiguration(); + + printConfiguration(configuration); + println(''); + + if (this.isStructuredSupported()) { + applyStructuredUpdate(this.resource, configuration, update); + } + else if (this.isRawSupported()) { + applyRawUpdate(this.resource, configuration, update); + } + else if (this.isStructuredAndRawSupported()) { + if (doStructured == null) { + throw "\nMust specify structured or raw when updating a configuration that supports both " + + "structured and raw. Update will abort."; + } + + if (doStructured) { + applyStructuredUpdate(this.resource, configuration, update); + } + else { + applyRawUpdate(this.resource, configuration, update); + } + } + + this.waitForResourceConfigurationUpdateToComplete(); + println("Configuration update has completed."); + + println("Loading latest, updated configuration"); + this.printLatestConfiguration(); + } + + this.waitForResourceConfigurationUpdateToComplete = function() { + print("Waiting for configuration update to complete...") + while (ConfigurationManager.isResourceConfigurationUpdateInProgress(this.resource.id)) { + print("."); + java.lang.Thread.sleep(waitInterval); + } + println(''); + } + + this.isRawSupported = function() { + var configFormat = this.resource.resourceType.resourceConfigurationDefinition.configurationFormat; + return ConfigurationFormat.RAW == configFormat; + } + + this.isStructuredSupported = function() { + var configFormat = this.resource.resourceType.resourceConfigurationDefinition.configurationFormat; + return ConfigurationFormat.STRUCTURED == configFormat; + } + + this.isStructuredAndRawSupported = function() { + var configFormat = this.resource.resourceType.resourceConfigurationDefinition.configurationFormat; + return ConfigurationFormat.STRUCTURED_AND_RAW == configFormat; + } + + function verifyPropertyToUpdateExists(configuration) { + if (!isDefined('propertyName')) { + throw "\nThe 'propertyName' variable must be defined. Update will abort."; + } + + if (!isDefined('propertyValue')) { + throw "\nThe 'propertyValue' variable must be defined. Update will abort."; + } + + if(configuration.getSimple(propertyName) == null) { + throw "\nThe property '" + propertyName + "' is undefined. Update will abort."; + } + } + + function verifyRawContentExists() { + if (!isDefined('contents')) { + throw "\n'contents' argument is required when updating " + serverName; + } + } + + function applyStructuredUpdate(resource, configuration, update) { + println("Applying resource configuration update..."); + doStructuredUpdate(resource, configuration, update); + ConfigurationManager.updateStructuredOrRawConfiguration(resource.id, configuration, structured); + } + + function doStructuredUpdate(resource, configuration, update) { + for (key in update) { + var property = configuration.getSimple(key.toString()); + if (property == null) { + throw "\nThe property '" + key + "' does not exist in the configuration. Update will abort."; + } + property.stringValue = update[key]; + } + } + + function applyRawUpdate(resource, configuration, update) { + println("Applying resource configuration update..."); + doRawUpdate(resource, configuration, update); + ConfigurationManager.updateStructuredOrRawConfiguration(resource.id, configuration, raw); + } + + function doRawUpdate(resourcec, configuration) { + var updates = 0; + var rawConfigs = java.util.ArrayList(configuration.rawConfigurations); + for (path in update) { + var rawConfig = findRawConfig(path, rawConfigs); + if (rawConfig == null) { + println("Failed to find raw config with path ending with " + path); + } + else { + configuration.rawConfigurations.remove(rawConfig); + var contents = java.lang.String(update[path]); + rawConfig.contents = contents.bytes; + configuration.rawConfigurations.add(rawConfig); + updates++; + } + } + + if (updates == 0) { + throw "\nNo matching paths were found. Update will abort."; + } + } + + function findRawConfig(path, rawConfigs) { + for (i = 0; i < rawConfigs.size(); i++) { + var rawConfig = rawConfigs.get(i); + if (rawConfig.path.endsWith(path.toString())) { + return rawConfig; + } + } + return null; + } + +} + +function findServer(name) { + var criteria = ResourceCriteria(); + criteria.strict = true; + criteria.addFilterName(name); + criteria.fetchResourceType(true); + + var resources = ResourceManager.findResourcesByCriteria(criteria); + + Assert.assertTrue(resources.size() == 1, "Expected to get back one resource but got back " + resources.size()); + + var resource = resources.get(0); + var resourceType = findResourceType(resource); + + if (resourceType == null) { + resourceType = loadResourceType(resource); + + if (resourceType == null) { + throw "Failed to initialize resource type for " + resource.name; + } + } + resource.resourceType = resourceType; + + return resource; +} + +function loadResourceType(resource) { + return ResourceTypeManager.getResourceTypeById(resource.resourceType.id); +} + +function findResourceType(resource) { + for (i = 0; i < resourceTypes.size(); i++) { + var resourceType = resourceTypes.get(i); + if (resourceType.id == resource.resourceType.id) { + return resourceType; + } + } + return null; +} diff --git a/modules/enterprise/remoting/scripts/src/main/script/configuration/update_structured.js b/modules/enterprise/remoting/scripts/src/main/script/configuration/update_structured.js deleted file mode 100644 index 54c39a9..0000000 --- a/modules/enterprise/remoting/scripts/src/main/script/configuration/update_structured.js +++ /dev/null @@ -1,287 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2, as - * published by the Free Software Foundation, and/or the GNU Lesser - * General Public License, version 2.1, also as published by the Free - * Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License and the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License - * and the GNU Lesser General Public License along with this program; - * if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -var waitInterval = 100; -var structured = true; -var raw = false; - -loadResourceTypes(); - -function loadResourceTypes() { - var resourceTypes = context.getAttribute('resourceTypes'); - if (resourceTypes != null && !resourceTypes.isEmpty()) { - return; - } - - var criteria = ResourceTypeCriteria(); - criteria.fetchResourceConfigurationDefinition(true); - - resourceTypes = ResourceTypeManager.findResourceTypesByCriteria(criteria); - context.setAttribute('resourceTypes', resourceTypes, javax.script.ScriptContext.ENGINE_SCOPE); -} - -function ConfigUtil(resourceName) { - var util = this; - - this.resource = findServer(resourceName); - - this.getLatestConfiguration = function () { - var latestUpdate = ConfigurationManager.getLatestResourceConfigurationUpdate(this.resource.id); - - Assert.assertNotNull( - latestUpdate, - "Failed to load the latest resource configuration update for " + this.resource.name - ); - Assert.assertNotNull( - latestUpdate.configuration, - "No configuration is attached to the latest config update object." - ); - - return latestUpdate.configuration; - } - - this.printLatestConfiguration = function() { - var configuration = this.getLatestConfiguration(); - printConfiguration(configuration); - } - - function printConfiguration(configuration) { - pretty.print(configuration); - - if (util.isRawSupported() || util.isStructuredAndRawSupported()) { - println("\nRaw configuration files:"); - var rawConfigs = java.util.ArrayList(configuration.rawConfigurations); - for (i = 0; i < rawConfigs.size(); i++) { - var rawConfig = rawConfigs.get(i); - println("\n[" + rawConfig.path + "]"); - println(java.lang.String(rawConfig.contents) + "\n\n---------------------"); - } - } - } - - this.translateToRaw = function(update) { - doTranslation(update, true); - } - - this.translateToStructured = function(update) { - doTranslation(update, false); - } - - function doTranslation(update, doStructured) { - println("Loading latest configuration for " + util.resource.name); - var configuration = util.getLatestConfiguration(); - - printConfiguration(configuration) - println(''); - - if (doStructured) { - doStructuredUpdate(util.resource, configuration, update); - } - else { - doRawUpdate(util.resource, configuration, update); - } - - println("Modified configuration..."); - printConfiguration(configuration) - println(''); - - var translatedConfig = ConfigurationManager.translateResourceConfiguration(util.resource.id, configuration, - doStructured); - - println("Translated configuration..."); - printConfiguration(translatedConfig); - println(''); - } - - this.updateConfiguration = function(update, doStructured) { - println("Loading latest configuration for " + this.resource.name); - var configuration = this.getLatestConfiguration(); - - printConfiguration(configuration); - println(''); - - if (this.isStructuredSupported()) { - applyStructuredUpdate(this.resource, configuration, update); - } - else if (this.isRawSupported()) { - applyRawUpdate(this.resource, configuration, update); - } - else if (this.isStructuredAndRawSupported()) { - if (doStructured == null) { - throw "\nMust specify structured or raw when updating a configuration that supports both " + - "structured and raw. Update will abort."; - } - - if (doStructured) { - applyStructuredUpdate(this.resource, configuration, update); - } - else { - applyRawUpdate(this.resource, configuration, update); - } - } - - this.waitForResourceConfigurationUpdateToComplete(); - println("Configuration update has completed."); - - println("Loading latest, updated configuration"); - this.printLatestConfiguration(); - } - - this.waitForResourceConfigurationUpdateToComplete = function() { - print("Waiting for configuration update to complete...") - while (ConfigurationManager.isResourceConfigurationUpdateInProgress(this.resource.id)) { - print("."); - java.lang.Thread.sleep(waitInterval); - } - println(''); - } - - this.isRawSupported = function() { - var configFormat = this.resource.resourceType.resourceConfigurationDefinition.configurationFormat; - return ConfigurationFormat.RAW == configFormat; - } - - this.isStructuredSupported = function() { - var configFormat = this.resource.resourceType.resourceConfigurationDefinition.configurationFormat; - return ConfigurationFormat.STRUCTURED == configFormat; - } - - this.isStructuredAndRawSupported = function() { - var configFormat = this.resource.resourceType.resourceConfigurationDefinition.configurationFormat; - return ConfigurationFormat.STRUCTURED_AND_RAW == configFormat; - } - - function verifyPropertyToUpdateExists(configuration) { - if (!isDefined('propertyName')) { - throw "\nThe 'propertyName' variable must be defined. Update will abort."; - } - - if (!isDefined('propertyValue')) { - throw "\nThe 'propertyValue' variable must be defined. Update will abort."; - } - - if(configuration.getSimple(propertyName) == null) { - throw "\nThe property '" + propertyName + "' is undefined. Update will abort."; - } - } - - function verifyRawContentExists() { - if (!isDefined('contents')) { - throw "\n'contents' argument is required when updating " + serverName; - } - } - - function applyStructuredUpdate(resource, configuration, update) { - println("Applying resource configuration update..."); - doStructuredUpdate(resource, configuration, update); - ConfigurationManager.updateStructuredOrRawConfiguration(resource.id, configuration, structured); - } - - function doStructuredUpdate(resource, configuration, update) { - for (key in update) { - var property = configuration.getSimple(key.toString()); - if (property == null) { - throw "\nThe property '" + key + "' does not exist in the configuration. Update will abort."; - } - property.stringValue = update[key]; - } - } - - function applyRawUpdate(resource, configuration, update) { - println("Applying resource configuration update..."); - doRawUpdate(resource, configuration, update); - ConfigurationManager.updateStructuredOrRawConfiguration(resource.id, configuration, raw); - } - - function doRawUpdate(resourcec, configuration) { - var updates = 0; - var rawConfigs = java.util.ArrayList(configuration.rawConfigurations); - for (path in update) { - var rawConfig = findRawConfig(path, rawConfigs); - if (rawConfig == null) { - println("Failed to find raw config with path ending with " + path); - } - else { - configuration.rawConfigurations.remove(rawConfig); - var contents = java.lang.String(update[path]); - rawConfig.contents = contents.bytes; - configuration.rawConfigurations.add(rawConfig); - updates++; - } - } - - if (updates == 0) { - throw "\nNo matching paths were found. Update will abort."; - } - } - - function findRawConfig(path, rawConfigs) { - for (i = 0; i < rawConfigs.size(); i++) { - var rawConfig = rawConfigs.get(i); - if (rawConfig.path.endsWith(path.toString())) { - return rawConfig; - } - } - return null; - } - -} - -function findServer(name) { - var criteria = ResourceCriteria(); - criteria.strict = true; - criteria.addFilterName(name); - criteria.fetchResourceType(true); - - var resources = ResourceManager.findResourcesByCriteria(criteria); - - Assert.assertTrue(resources.size() == 1, "Expected to get back one resource but got back " + resources.size()); - - var resource = resources.get(0); - var resourceType = findResourceType(resource); - - if (resourceType == null) { - resourceType = loadResourceType(resource); - - if (resourceType == null) { - throw "Failed to initialize resource type for " + resource.name; - } - } - resource.resourceType = resourceType; - - return resource; -} - -function loadResourceType(resource) { - return ResourceTypeManager.getResourceTypeById(resource.resourceType.id); -} - -function findResourceType(resource) { - for (i = 0; i < resourceTypes.size(); i++) { - var resourceType = resourceTypes.get(i); - if (resourceType.id == resource.resourceType.id) { - return resourceType; - } - } - return null; -}
commit ab2d09793f5f45cf66ba5a88e589a88a76d7cf0e Author: John Sanda john@localhost.localdomain Date: Fri Dec 18 15:03:13 2009 -0500
Revert "Renaming script to something more logical"
This reverts commit d10220faf2c617cd75b242a4077cc47422ab9a72.
diff --git a/modules/enterprise/remoting/scripts/src/main/script/configuration/config_util.js b/modules/enterprise/remoting/scripts/src/main/script/configuration/config_util.js deleted file mode 100644 index 54c39a9..0000000 --- a/modules/enterprise/remoting/scripts/src/main/script/configuration/config_util.js +++ /dev/null @@ -1,287 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2, as - * published by the Free Software Foundation, and/or the GNU Lesser - * General Public License, version 2.1, also as published by the Free - * Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License and the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License - * and the GNU Lesser General Public License along with this program; - * if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -var waitInterval = 100; -var structured = true; -var raw = false; - -loadResourceTypes(); - -function loadResourceTypes() { - var resourceTypes = context.getAttribute('resourceTypes'); - if (resourceTypes != null && !resourceTypes.isEmpty()) { - return; - } - - var criteria = ResourceTypeCriteria(); - criteria.fetchResourceConfigurationDefinition(true); - - resourceTypes = ResourceTypeManager.findResourceTypesByCriteria(criteria); - context.setAttribute('resourceTypes', resourceTypes, javax.script.ScriptContext.ENGINE_SCOPE); -} - -function ConfigUtil(resourceName) { - var util = this; - - this.resource = findServer(resourceName); - - this.getLatestConfiguration = function () { - var latestUpdate = ConfigurationManager.getLatestResourceConfigurationUpdate(this.resource.id); - - Assert.assertNotNull( - latestUpdate, - "Failed to load the latest resource configuration update for " + this.resource.name - ); - Assert.assertNotNull( - latestUpdate.configuration, - "No configuration is attached to the latest config update object." - ); - - return latestUpdate.configuration; - } - - this.printLatestConfiguration = function() { - var configuration = this.getLatestConfiguration(); - printConfiguration(configuration); - } - - function printConfiguration(configuration) { - pretty.print(configuration); - - if (util.isRawSupported() || util.isStructuredAndRawSupported()) { - println("\nRaw configuration files:"); - var rawConfigs = java.util.ArrayList(configuration.rawConfigurations); - for (i = 0; i < rawConfigs.size(); i++) { - var rawConfig = rawConfigs.get(i); - println("\n[" + rawConfig.path + "]"); - println(java.lang.String(rawConfig.contents) + "\n\n---------------------"); - } - } - } - - this.translateToRaw = function(update) { - doTranslation(update, true); - } - - this.translateToStructured = function(update) { - doTranslation(update, false); - } - - function doTranslation(update, doStructured) { - println("Loading latest configuration for " + util.resource.name); - var configuration = util.getLatestConfiguration(); - - printConfiguration(configuration) - println(''); - - if (doStructured) { - doStructuredUpdate(util.resource, configuration, update); - } - else { - doRawUpdate(util.resource, configuration, update); - } - - println("Modified configuration..."); - printConfiguration(configuration) - println(''); - - var translatedConfig = ConfigurationManager.translateResourceConfiguration(util.resource.id, configuration, - doStructured); - - println("Translated configuration..."); - printConfiguration(translatedConfig); - println(''); - } - - this.updateConfiguration = function(update, doStructured) { - println("Loading latest configuration for " + this.resource.name); - var configuration = this.getLatestConfiguration(); - - printConfiguration(configuration); - println(''); - - if (this.isStructuredSupported()) { - applyStructuredUpdate(this.resource, configuration, update); - } - else if (this.isRawSupported()) { - applyRawUpdate(this.resource, configuration, update); - } - else if (this.isStructuredAndRawSupported()) { - if (doStructured == null) { - throw "\nMust specify structured or raw when updating a configuration that supports both " + - "structured and raw. Update will abort."; - } - - if (doStructured) { - applyStructuredUpdate(this.resource, configuration, update); - } - else { - applyRawUpdate(this.resource, configuration, update); - } - } - - this.waitForResourceConfigurationUpdateToComplete(); - println("Configuration update has completed."); - - println("Loading latest, updated configuration"); - this.printLatestConfiguration(); - } - - this.waitForResourceConfigurationUpdateToComplete = function() { - print("Waiting for configuration update to complete...") - while (ConfigurationManager.isResourceConfigurationUpdateInProgress(this.resource.id)) { - print("."); - java.lang.Thread.sleep(waitInterval); - } - println(''); - } - - this.isRawSupported = function() { - var configFormat = this.resource.resourceType.resourceConfigurationDefinition.configurationFormat; - return ConfigurationFormat.RAW == configFormat; - } - - this.isStructuredSupported = function() { - var configFormat = this.resource.resourceType.resourceConfigurationDefinition.configurationFormat; - return ConfigurationFormat.STRUCTURED == configFormat; - } - - this.isStructuredAndRawSupported = function() { - var configFormat = this.resource.resourceType.resourceConfigurationDefinition.configurationFormat; - return ConfigurationFormat.STRUCTURED_AND_RAW == configFormat; - } - - function verifyPropertyToUpdateExists(configuration) { - if (!isDefined('propertyName')) { - throw "\nThe 'propertyName' variable must be defined. Update will abort."; - } - - if (!isDefined('propertyValue')) { - throw "\nThe 'propertyValue' variable must be defined. Update will abort."; - } - - if(configuration.getSimple(propertyName) == null) { - throw "\nThe property '" + propertyName + "' is undefined. Update will abort."; - } - } - - function verifyRawContentExists() { - if (!isDefined('contents')) { - throw "\n'contents' argument is required when updating " + serverName; - } - } - - function applyStructuredUpdate(resource, configuration, update) { - println("Applying resource configuration update..."); - doStructuredUpdate(resource, configuration, update); - ConfigurationManager.updateStructuredOrRawConfiguration(resource.id, configuration, structured); - } - - function doStructuredUpdate(resource, configuration, update) { - for (key in update) { - var property = configuration.getSimple(key.toString()); - if (property == null) { - throw "\nThe property '" + key + "' does not exist in the configuration. Update will abort."; - } - property.stringValue = update[key]; - } - } - - function applyRawUpdate(resource, configuration, update) { - println("Applying resource configuration update..."); - doRawUpdate(resource, configuration, update); - ConfigurationManager.updateStructuredOrRawConfiguration(resource.id, configuration, raw); - } - - function doRawUpdate(resourcec, configuration) { - var updates = 0; - var rawConfigs = java.util.ArrayList(configuration.rawConfigurations); - for (path in update) { - var rawConfig = findRawConfig(path, rawConfigs); - if (rawConfig == null) { - println("Failed to find raw config with path ending with " + path); - } - else { - configuration.rawConfigurations.remove(rawConfig); - var contents = java.lang.String(update[path]); - rawConfig.contents = contents.bytes; - configuration.rawConfigurations.add(rawConfig); - updates++; - } - } - - if (updates == 0) { - throw "\nNo matching paths were found. Update will abort."; - } - } - - function findRawConfig(path, rawConfigs) { - for (i = 0; i < rawConfigs.size(); i++) { - var rawConfig = rawConfigs.get(i); - if (rawConfig.path.endsWith(path.toString())) { - return rawConfig; - } - } - return null; - } - -} - -function findServer(name) { - var criteria = ResourceCriteria(); - criteria.strict = true; - criteria.addFilterName(name); - criteria.fetchResourceType(true); - - var resources = ResourceManager.findResourcesByCriteria(criteria); - - Assert.assertTrue(resources.size() == 1, "Expected to get back one resource but got back " + resources.size()); - - var resource = resources.get(0); - var resourceType = findResourceType(resource); - - if (resourceType == null) { - resourceType = loadResourceType(resource); - - if (resourceType == null) { - throw "Failed to initialize resource type for " + resource.name; - } - } - resource.resourceType = resourceType; - - return resource; -} - -function loadResourceType(resource) { - return ResourceTypeManager.getResourceTypeById(resource.resourceType.id); -} - -function findResourceType(resource) { - for (i = 0; i < resourceTypes.size(); i++) { - var resourceType = resourceTypes.get(i); - if (resourceType.id == resource.resourceType.id) { - return resourceType; - } - } - return null; -} diff --git a/modules/enterprise/remoting/scripts/src/main/script/configuration/update_structured.js b/modules/enterprise/remoting/scripts/src/main/script/configuration/update_structured.js new file mode 100644 index 0000000..54c39a9 --- /dev/null +++ b/modules/enterprise/remoting/scripts/src/main/script/configuration/update_structured.js @@ -0,0 +1,287 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2008 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +var waitInterval = 100; +var structured = true; +var raw = false; + +loadResourceTypes(); + +function loadResourceTypes() { + var resourceTypes = context.getAttribute('resourceTypes'); + if (resourceTypes != null && !resourceTypes.isEmpty()) { + return; + } + + var criteria = ResourceTypeCriteria(); + criteria.fetchResourceConfigurationDefinition(true); + + resourceTypes = ResourceTypeManager.findResourceTypesByCriteria(criteria); + context.setAttribute('resourceTypes', resourceTypes, javax.script.ScriptContext.ENGINE_SCOPE); +} + +function ConfigUtil(resourceName) { + var util = this; + + this.resource = findServer(resourceName); + + this.getLatestConfiguration = function () { + var latestUpdate = ConfigurationManager.getLatestResourceConfigurationUpdate(this.resource.id); + + Assert.assertNotNull( + latestUpdate, + "Failed to load the latest resource configuration update for " + this.resource.name + ); + Assert.assertNotNull( + latestUpdate.configuration, + "No configuration is attached to the latest config update object." + ); + + return latestUpdate.configuration; + } + + this.printLatestConfiguration = function() { + var configuration = this.getLatestConfiguration(); + printConfiguration(configuration); + } + + function printConfiguration(configuration) { + pretty.print(configuration); + + if (util.isRawSupported() || util.isStructuredAndRawSupported()) { + println("\nRaw configuration files:"); + var rawConfigs = java.util.ArrayList(configuration.rawConfigurations); + for (i = 0; i < rawConfigs.size(); i++) { + var rawConfig = rawConfigs.get(i); + println("\n[" + rawConfig.path + "]"); + println(java.lang.String(rawConfig.contents) + "\n\n---------------------"); + } + } + } + + this.translateToRaw = function(update) { + doTranslation(update, true); + } + + this.translateToStructured = function(update) { + doTranslation(update, false); + } + + function doTranslation(update, doStructured) { + println("Loading latest configuration for " + util.resource.name); + var configuration = util.getLatestConfiguration(); + + printConfiguration(configuration) + println(''); + + if (doStructured) { + doStructuredUpdate(util.resource, configuration, update); + } + else { + doRawUpdate(util.resource, configuration, update); + } + + println("Modified configuration..."); + printConfiguration(configuration) + println(''); + + var translatedConfig = ConfigurationManager.translateResourceConfiguration(util.resource.id, configuration, + doStructured); + + println("Translated configuration..."); + printConfiguration(translatedConfig); + println(''); + } + + this.updateConfiguration = function(update, doStructured) { + println("Loading latest configuration for " + this.resource.name); + var configuration = this.getLatestConfiguration(); + + printConfiguration(configuration); + println(''); + + if (this.isStructuredSupported()) { + applyStructuredUpdate(this.resource, configuration, update); + } + else if (this.isRawSupported()) { + applyRawUpdate(this.resource, configuration, update); + } + else if (this.isStructuredAndRawSupported()) { + if (doStructured == null) { + throw "\nMust specify structured or raw when updating a configuration that supports both " + + "structured and raw. Update will abort."; + } + + if (doStructured) { + applyStructuredUpdate(this.resource, configuration, update); + } + else { + applyRawUpdate(this.resource, configuration, update); + } + } + + this.waitForResourceConfigurationUpdateToComplete(); + println("Configuration update has completed."); + + println("Loading latest, updated configuration"); + this.printLatestConfiguration(); + } + + this.waitForResourceConfigurationUpdateToComplete = function() { + print("Waiting for configuration update to complete...") + while (ConfigurationManager.isResourceConfigurationUpdateInProgress(this.resource.id)) { + print("."); + java.lang.Thread.sleep(waitInterval); + } + println(''); + } + + this.isRawSupported = function() { + var configFormat = this.resource.resourceType.resourceConfigurationDefinition.configurationFormat; + return ConfigurationFormat.RAW == configFormat; + } + + this.isStructuredSupported = function() { + var configFormat = this.resource.resourceType.resourceConfigurationDefinition.configurationFormat; + return ConfigurationFormat.STRUCTURED == configFormat; + } + + this.isStructuredAndRawSupported = function() { + var configFormat = this.resource.resourceType.resourceConfigurationDefinition.configurationFormat; + return ConfigurationFormat.STRUCTURED_AND_RAW == configFormat; + } + + function verifyPropertyToUpdateExists(configuration) { + if (!isDefined('propertyName')) { + throw "\nThe 'propertyName' variable must be defined. Update will abort."; + } + + if (!isDefined('propertyValue')) { + throw "\nThe 'propertyValue' variable must be defined. Update will abort."; + } + + if(configuration.getSimple(propertyName) == null) { + throw "\nThe property '" + propertyName + "' is undefined. Update will abort."; + } + } + + function verifyRawContentExists() { + if (!isDefined('contents')) { + throw "\n'contents' argument is required when updating " + serverName; + } + } + + function applyStructuredUpdate(resource, configuration, update) { + println("Applying resource configuration update..."); + doStructuredUpdate(resource, configuration, update); + ConfigurationManager.updateStructuredOrRawConfiguration(resource.id, configuration, structured); + } + + function doStructuredUpdate(resource, configuration, update) { + for (key in update) { + var property = configuration.getSimple(key.toString()); + if (property == null) { + throw "\nThe property '" + key + "' does not exist in the configuration. Update will abort."; + } + property.stringValue = update[key]; + } + } + + function applyRawUpdate(resource, configuration, update) { + println("Applying resource configuration update..."); + doRawUpdate(resource, configuration, update); + ConfigurationManager.updateStructuredOrRawConfiguration(resource.id, configuration, raw); + } + + function doRawUpdate(resourcec, configuration) { + var updates = 0; + var rawConfigs = java.util.ArrayList(configuration.rawConfigurations); + for (path in update) { + var rawConfig = findRawConfig(path, rawConfigs); + if (rawConfig == null) { + println("Failed to find raw config with path ending with " + path); + } + else { + configuration.rawConfigurations.remove(rawConfig); + var contents = java.lang.String(update[path]); + rawConfig.contents = contents.bytes; + configuration.rawConfigurations.add(rawConfig); + updates++; + } + } + + if (updates == 0) { + throw "\nNo matching paths were found. Update will abort."; + } + } + + function findRawConfig(path, rawConfigs) { + for (i = 0; i < rawConfigs.size(); i++) { + var rawConfig = rawConfigs.get(i); + if (rawConfig.path.endsWith(path.toString())) { + return rawConfig; + } + } + return null; + } + +} + +function findServer(name) { + var criteria = ResourceCriteria(); + criteria.strict = true; + criteria.addFilterName(name); + criteria.fetchResourceType(true); + + var resources = ResourceManager.findResourcesByCriteria(criteria); + + Assert.assertTrue(resources.size() == 1, "Expected to get back one resource but got back " + resources.size()); + + var resource = resources.get(0); + var resourceType = findResourceType(resource); + + if (resourceType == null) { + resourceType = loadResourceType(resource); + + if (resourceType == null) { + throw "Failed to initialize resource type for " + resource.name; + } + } + resource.resourceType = resourceType; + + return resource; +} + +function loadResourceType(resource) { + return ResourceTypeManager.getResourceTypeById(resource.resourceType.id); +} + +function findResourceType(resource) { + for (i = 0; i < resourceTypes.size(); i++) { + var resourceType = resourceTypes.get(i); + if (resourceType.id == resource.resourceType.id) { + return resourceType; + } + } + return null; +}
commit 94eb322b31c661d5d7b94c27864ecf9aaba831bc Author: John Sanda john@localhost.localdomain Date: Fri Dec 18 14:42:21 2009 -0500
Revert "Cleaned up icons and sidebar navigation, toggles between edit in view"
This reverts commit c02a8fe5b89142966494cf564e15a9ed10d77591.
Conflicts:
modules/core/gui/src/main/java/org/rhq/core/gui/configuration/AbstractConfigurationComponent.java modules/core/gui/src/main/java/org/rhq/core/gui/configuration/ConfigRenderer.java modules/core/gui/src/main/java/org/rhq/core/gui/configuration/RawConfigUIComponent.java modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
diff --git a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/AbstractConfigurationComponent.java b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/AbstractConfigurationComponent.java index 3cda4bd..91185e6 100644 --- a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/AbstractConfigurationComponent.java +++ b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/AbstractConfigurationComponent.java @@ -213,4 +213,4 @@ public abstract class AbstractConfigurationComponent extends UIComponentBase imp this.isGroup = (Boolean) this.stateValues[6]; }
-} \ No newline at end of file +} diff --git a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/ConfigRenderer.java b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/ConfigRenderer.java index 20abbcd..2ebbc53 100644 --- a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/ConfigRenderer.java +++ b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/ConfigRenderer.java @@ -250,14 +250,15 @@ public class ConfigRenderer extends Renderer { configurationComponent.setListIndex(addNewMap(configurationComponent)); }
- addListMemberProperty(configurationComponent); - } else { - addConfiguration(configurationComponent); - } + addListMemberProperty(configurationComponent); + } else { + addConfiguration(configurationComponent); + }
- String id = getInitInputsJavaScriptComponentId(configurationComponent); - PropertyRenderingUtility.addInitInputsJavaScript(configurationComponent, id, configurationComponent - .isFullyEditable(), false); + String id = getInitInputsJavaScriptComponentId(configurationComponent); + PropertyRenderingUtility.addInitInputsJavaScript(configurationComponent, id, configurationComponent + .isFullyEditable(), false); + } }
private void addListMemberProperty(AbstractConfigurationComponent configurationComponent) {
commit e19f91fda6b797c9422b5d9e4736ae0854828453 Author: John Sanda john@localhost.localdomain Date: Fri Dec 18 14:36:36 2009 -0500
Revert "started pushing the decode and encode stuff into the appropriate portion of the jsf lifecycle."
This reverts commit 6cbb7df18da1585103d5b819f80c1b00ad019aab.
Conflicts:
modules/core/gui/src/main/java/org/rhq/core/gui/configuration/ConfigRenderer.java modules/core/gui/src/main/java/org/rhq/core/gui/configuration/RawConfigUIComponent.java modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
diff --git a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/ConfigRenderer.java b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/ConfigRenderer.java index b5e67a3..20abbcd 100644 --- a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/ConfigRenderer.java +++ b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/ConfigRenderer.java @@ -615,4 +615,4 @@ public class ConfigRenderer extends Renderer { } throw new IllegalStateException("Unable to determine index of component " + component); } -} \ No newline at end of file +}
commit 49b83ff2cb4ca990a2ca82a32ae8e1cdd34693af Author: John Sanda john@localhost.localdomain Date: Fri Dec 18 14:27:11 2009 -0500
Revert "[BZ 544136] Fixing bug that prevented see history for raw config updates"
This reverts commit c73d40ce3406a3cc904fb34429b9248b48f8e531.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java index 586d603..fb82e6e 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java @@ -842,9 +842,8 @@ public class ConfigurationManagerBean implements ConfigurationManagerLocal, Conf }
Resource resource = entityManager.find(Resource.class, resourceId); - ConfigurationDefinition configDef = resource.getResourceType().getResourceConfigurationDefinition(); - if ((configDef == null || configDef.getPropertyDefinitions().isEmpty()) - && configDef.getConfigurationFormat() == ConfigurationFormat.STRUCTURED) { + if (resource.getResourceType().getResourceConfigurationDefinition() == null + || resource.getResourceType().getResourceConfigurationDefinition().getPropertyDefinitions().isEmpty()) { return new PageList<ResourceConfigurationUpdate>(pc); }
commit 1bdffa21a58116ee0dcd086408c0098e2709e7e8 Author: John Sanda john@localhost.localdomain Date: Fri Dec 18 14:26:48 2009 -0500
Revert "[BZ 538088] Reverting back to using the view ui bean which only has a request scope."
This reverts commit cb18055cfd528342fda2ddeed570ef5b15fd4183.
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml index 72da244..0d4899f 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml @@ -44,27 +44,27 @@ THIS TEXT WILL BE REMOVED. <input type="hidden" name="id" value="#{ResourceUIBean.id}"/>
<h:panelGrid columns="2" styleClass="buttons-table" columnClasses="button-cell" - rendered="#{ExistingResourceConfigurationViewUIBean.configuration != null and !ExistingResourceConfigurationViewUIBean.updateInProgress}"> + rendered="#{ExistingResourceConfigurationUIBean.configuration != null and !ExistingResourceConfigurationUIBean.updateInProgress}">
- <h:commandButton value="#{messages.editstructured}" action="#{ExistingResourceConfigurationViewUIBean.editConfiguration}" + <h:commandButton value="#{messages.editstructured}" action="#{ExistingResourceConfigurationUIBean.editConfiguration}" title="Edit this Configuration" styleClass="buttonmed" - rendered="${ResourceUIBean.permissions.configure and ExistingResourceConfigurationViewUIBean.structuredSupported and !ExistingResourceConfigurationViewUIBean.updateInProgress}" /> + rendered="${ResourceUIBean.permissions.configure and ExistingResourceConfigurationUIBean.structuredSupported and !ExistingResourceConfigurationUIBean.updateInProgress}" /> <h:commandButton value="#{messages.editraw}" action="#{ExistingResourceConfigurationUIBean.editRawConfiguration}" title="Advanced Mode Edit of Raw Configuration Files" styleClass="buttonmed" - rendered="${ResourceUIBean.permissions.configure and ExistingResourceConfigurationViewUIBean.rawSupported and !ExistingResourceConfigurationViewUIBean.updateInProgress}" /> + rendered="${ResourceUIBean.permissions.configure and ExistingResourceConfigurationUIBean.rawSupported and !ExistingResourceConfigurationUIBean.updateInProgress}" /> </h:panelGrid>
- <onc:config configurationDefinition="#{ExistingResourceConfigurationViewUIBean.configurationDefinition}" - configuration="#{ExistingResourceConfigurationViewUIBean.configuration}" - accessMapActionExpression="#{ExistingResourceConfigurationViewUIBean.accessMap}" + <onc:config configurationDefinition="#{ExistingResourceConfigurationUIBean.configurationDefinition}" + configuration="#{ExistingResourceConfigurationUIBean.configuration}" + accessMapActionExpression="#{ExistingResourceConfigurationUIBean.accessMap}" readOnly="true" - nullConfigurationDefinitionMessage="#{ExistingResourceConfigurationViewUIBean.nullConfigurationDefinitionMessage}" - nullConfigurationMessage="#{ExistingResourceConfigurationViewUIBean.nullConfigurationMessage}" + nullConfigurationDefinitionMessage="#{ExistingResourceConfigurationUIBean.nullConfigurationDefinitionMessage}" + nullConfigurationMessage="#{ExistingResourceConfigurationUIBean.nullConfigurationMessage}" prevalidate="true"/>
</h:form>
- <h:panelGroup layout="block" styleClass="InfoBlock" rendered="#{ExistingResourceConfigurationViewUIBean.updateInProgress}"> + <h:panelGroup layout="block" styleClass="InfoBlock" rendered="#{ExistingResourceConfigurationUIBean.updateInProgress}"> <b>${msg['note']}</b> ${msg['resource.config.Current.updateInProgress']} </h:panelGroup>
commit 830710ae0069b34325aae5eaaca595bb8d1c9db8 Author: John Sanda john@localhost.localdomain Date: Fri Dec 18 14:26:30 2009 -0500
Revert "[BZ 537891] Fixing bug in which required query parameter was not getted appended to url"
This reverts commit 4e7f1939c4cc1388d3cf9a5b35647684a3d7b033.
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java index 3189d79..bb93d81 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java @@ -417,8 +417,7 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI current = null; setConfiguration(configuration);
-// return "/rhq/resource/configuration/edit.xhtml?currentResourceId=" + getResourceId(); - return SUCCESS_OUTCOME; + return "/rhq/resource/configuration/edit.xhtml?currentResourceId=" + getResourceId(); }
void populateRaws() { @@ -451,4 +450,4 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI TreeMap<String, RawConfiguration> modified = new TreeMap<String, RawConfiguration>(); RawConfiguration current = null;
-} +} \ No newline at end of file diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/configuration-navigation.xml b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/configuration-navigation.xml index bd0f1bf..4443b36 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/configuration-navigation.xml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/configuration-navigation.xml @@ -23,12 +23,6 @@ <from-action>#{ConfigHelperUIBean.accessMap}</from-action> <to-view-id>/rhq/resource/configuration/view-map.xhtml</to-view-id> </navigation-case> - - <navigation-case> - <from-action>#{ExistingResourceConfigurationUIBean.switchTostructured}</from-action> - <to-view-id>/rhq/resource/configuration/edit.xhtml?id=#{param.id}</to-view-id> - <redirect/> - </navigation-case>
</navigation-rule>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit-raw.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit-raw.xhtml index bf05c9b..c01694e 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit-raw.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit-raw.xhtml @@ -35,10 +35,10 @@ <a4j:form id="editResourceConfigurationForm"> <h:outputText value="#{messages.youareviewingraw}" /> - <h:panelGroup rendered="#{ExistingResourceConfigurationUIBean.structuredSupported}"> + <h:panelGroup rendered="#{ExistingResourceConfigurationUIBean.structuredSupported}"> <h:outputText value=" #{messages.switch2}" /> <h:commandLink action="#{ExistingResourceConfigurationUIBean.switchTostructured}"> - <f:param name="conversationId" value="#{conversation.id}"/> + <s:conversationId /> <f:param name="id" value="#{ResourceUIBean.id}" /> <h:outputText value=" #{messages.structured}" /> </h:commandLink>
commit 53055b7f043746f3c2fb596e02d9c727182ae07e Author: John Sanda john@localhost.localdomain Date: Fri Dec 18 14:26:02 2009 -0500
Revert "Removing check for config property definitions in findResourceConfigurationUpdates()"
This reverts commit 0050ae7cdf3e8e226f728b1d64f9effde315fa76.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java index fbae47d..586d603 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java @@ -842,6 +842,11 @@ public class ConfigurationManagerBean implements ConfigurationManagerLocal, Conf }
Resource resource = entityManager.find(Resource.class, resourceId); + ConfigurationDefinition configDef = resource.getResourceType().getResourceConfigurationDefinition(); + if ((configDef == null || configDef.getPropertyDefinitions().isEmpty()) + && configDef.getConfigurationFormat() == ConfigurationFormat.STRUCTURED) { + return new PageList<ResourceConfigurationUpdate>(pc); + }
pc.initDefaultOrderingField("cu.id", PageOrdering.DESC);
commit 156dce2a3eeeb7e6e56ec354db55a30e76c3d65f Author: John Sanda john@localhost.localdomain Date: Fri Dec 18 14:25:46 2009 -0500
Revert "removed temporary file."
This reverts commit ed7ba67209643e53b1fcd94fbb1a9c74e89bb80a.
diff --git a/temp-testng-customsuite.xml b/temp-testng-customsuite.xml new file mode 100644 index 0000000..b4645bb --- /dev/null +++ b/temp-testng-customsuite.xml @@ -0,0 +1,8 @@ +<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"> +<suite name="rhq" parallel=""> + <test verbose="2" name="org.rhq.core.gui.configuration.ConfigRendererTest" annotations="JDK"> + <classes> + <class name="org.rhq.core.gui.configuration.ConfigRendererTest"/> + </classes> + </test> +</suite>
commit 74f91f74d5b6f7ab5219a280cde3a3b849bd37b6 Author: John Sanda john@localhost.localdomain Date: Fri Dec 18 14:25:25 2009 -0500
Revert "Merge of current raw work with remote branch"
This reverts commit 2d4e562f32814f683a754eabe829531b0b8e40df, reversing changes made to 0050ae7cdf3e8e226f728b1d64f9effde315fa76.
diff --git a/.classpath b/.classpath index 27f5303..4ae348c 100644 --- a/.classpath +++ b/.classpath @@ -1,7 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" path="modules/common/jboss-as/src/main/java"/> - <classpathentry kind="src" path="modules/test-utils/src/main/java"/> <classpathentry kind="src" path="modules/common/jboss-as/src/test/java"/> <classpathentry kind="src" path="modules/plugins/jboss-as/src/main/java"/> <classpathentry kind="src" path="modules/plugins/jboss-as/src/test/java"/> @@ -14,9 +13,7 @@ <classpathentry kind="src" path="modules/plugins/tomcat/src/test/java"/> <classpathentry kind="src" path="modules/plugins/jboss-cache/src/main/java"/> <classpathentry kind="src" path="modules/plugins/jboss-cache-v3/src/main/java"/> - <classpathentry kind="src" path="modules/plugins/antlr-config/src/main/java"/> - <classpathentry kind="src" path="modules/core/gui/src/test/java"/> - <classpathentry kind="src" path="modules/plugins/antlr-config/target/generated-sources/antlr3"/> + <classpathentry excluding="org/rhq/plugins/antlrconfig/" kind="src" path="modules/plugins/antlr-config/src/main/java"/> <classpathentry kind="var" path="M2_REPO/org/jboss/integration/jboss-profileservice-spi/5.1.0.SP1/jboss-profileservice-spi-5.1.0.SP1.jar"/> <classpathentry kind="var" path="M2_REPO/org/jboss/man/jboss-managed/2.1.1.GA/jboss-managed-2.1.1.GA.jar"/> <classpathentry kind="var" path="M2_REPO/org/jboss/man/jboss-metatype/2.1.1.GA/jboss-metatype-2.1.1.GA.jar"/> @@ -105,6 +102,7 @@ <classpathentry kind="src" path="modules/plugins/snmptrapd/src/main/java"/> <classpathentry kind="src" path="modules/plugins/script/src/main/java"/> <classpathentry kind="src" path="modules/plugins/antlr-config/src/main/antlr3"/> + <classpathentry kind="src" path="modules/plugins/antlr-config/target/generated-sources/antlr3"/> <classpathentry kind="src" path="modules/helpers/rtfilter/src/main/java"/> <classpathentry kind="src" path="modules/helpers/pluginAnnotations/src/main/java"/> <classpathentry kind="src" path="modules/helpers/pluginGen/src/main/java"/> @@ -205,8 +203,5 @@ <classpathentry exported="true" kind="var" path="M2_REPO/commons-digester/commons-digester/1.8/commons-digester-1.8.jar"/> <classpathentry exported="true" kind="var" path="M2_REPO/commons-codec/commons-codec/1.4/commons-codec-1.4.jar"/> <classpathentry exported="true" kind="lib" path="modules/enterprise/remoting/webservices/target/rhq-remoting-webservices-1.4.0-SNAPSHOT/wsconsume-output"/> - <classpathentry kind="var" path="M2_REPO/org/jmock/jmock/2.5.1/jmock-2.5.1.jar" sourcepath="/M2_REPO/org/jmock/jmock/2.5.1/jmock-2.5.1-sources.jar"/> - <classpathentry kind="var" path="M2_REPO/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1.jar" sourcepath="/M2_REPO/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1-sources.jar"/> - <classpathentry kind="var" path="M2_REPO/org/hamcrest/hamcrest-library/1.1/hamcrest-library-1.1.jar" sourcepath="M2_REPO/org/hamcrest/hamcrest-library/1.1/hamcrest-library-1.1-sources.jar"/> <classpathentry kind="output" path="eclipse-classes"/> </classpath> diff --git a/.gitignore b/.gitignore index bca5c45..1d53abe 100644 --- a/.gitignore +++ b/.gitignore @@ -18,4 +18,3 @@ dev-container dev-agent antlr-generated/ *.tokens -test-output/* diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/RawConfiguration.java b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/RawConfiguration.java index 069ca34..1bb27c9 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/RawConfiguration.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/RawConfiguration.java @@ -23,7 +23,7 @@
package org.rhq.core.domain.configuration;
-import java.io.Serializable; +import org.rhq.core.util.MessageDigestGenerator;
import javax.persistence.Column; import javax.persistence.Entity; @@ -36,8 +36,7 @@ import javax.persistence.PrePersist; import javax.persistence.PreUpdate; import javax.persistence.SequenceGenerator; import javax.persistence.Table; - -import org.rhq.core.util.MessageDigestGenerator; +import java.io.Serializable;
/** * Resources support structured configuration as well as raw configuration which is represented by this class. A raw @@ -123,14 +122,6 @@ public class RawConfiguration implements Serializable, DeepCopyable<RawConfigura updateSha256(); }
- public String getContentString() { - return new String(getContents()); - } - - public void setContentString(String newValue) { - setContents(newValue.getBytes()); - } - private byte[] copy(byte[] original) { byte[] copy = new byte[original.length]; for (int i = 0; i < original.length; ++i) { @@ -215,7 +206,7 @@ public class RawConfiguration implements Serializable, DeepCopyable<RawConfigura if (this.path == null && that.path == null) { return true; } - if ((this.path != null && that.path != null) && this.path.equals(that.path)) { + if ((this.path !=null && that.path != null) && this.path.equals(that.path)) { return true; } } @@ -239,9 +230,14 @@ public class RawConfiguration implements Serializable, DeepCopyable<RawConfigura
@Override public String toString() { - return new StringBuilder().append(getClass().getSimpleName()).append("[id=").append(id).append(", path=") - .append(path).append(", sha256=").append(sha256).append(", configuration=").append(configuration).append( - "]").toString(); + return new StringBuilder() + .append(getClass().getSimpleName()) + .append("[id=").append(id) + .append(", path=").append(path) + .append(", sha256=").append(sha256) + .append(", configuration=").append(configuration) + .append("]") + .toString(); }
public RawConfiguration deepCopy(boolean keepId) { @@ -251,7 +247,7 @@ public class RawConfiguration implements Serializable, DeepCopyable<RawConfigura }
copy.path = this.path; - + if (this.contents != null) { copy.setContents(this.getContents()); } @@ -260,3 +256,4 @@ public class RawConfiguration implements Serializable, DeepCopyable<RawConfigura }
} + diff --git a/modules/core/gui/pom.xml b/modules/core/gui/pom.xml index eaddceb..96a3212 100644 --- a/modules/core/gui/pom.xml +++ b/modules/core/gui/pom.xml @@ -138,14 +138,6 @@ </exclusions> </dependency>
- - <dependency> - <groupId>javax.faces</groupId> - <artifactId>jsf-impl</artifactId> - <scope>provided</scope> - </dependency> - - </dependencies>
<repositories> @@ -229,4 +221,4 @@
</profiles>
-</project> +</project> \ No newline at end of file diff --git a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/AbstractConfigurationComponent.java b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/AbstractConfigurationComponent.java index 2fe72ee..3cda4bd 100644 --- a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/AbstractConfigurationComponent.java +++ b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/AbstractConfigurationComponent.java @@ -29,11 +29,9 @@ import javax.faces.context.FacesContext;
import org.rhq.core.domain.configuration.Configuration; import org.rhq.core.domain.configuration.definition.ConfigurationDefinition; -import org.rhq.core.domain.configuration.definition.ConfigurationFormat; import org.rhq.core.gui.configuration.propset.ConfigurationSetComponent; import org.rhq.core.gui.util.FacesComponentIdFactory; import org.rhq.core.gui.util.FacesComponentUtility; -import org.rhq.core.gui.util.FacesContextUtility;
/** * An abstract base class for the {@link ConfigUIComponent} and the {@link ConfigurationSetComponent} JSF component @@ -52,7 +50,7 @@ public abstract class AbstractConfigurationComponent extends UIComponentBase imp private static final String READ_ONLY_ATTRIBUTE = "readOnly"; private static final String FULLY_EDITABLE_ATTRIBUTE = "fullyEditable";
- private Boolean readOnly = true; + private Boolean readOnly; private Boolean fullyEditable; private String listName; private Integer listIndex; @@ -215,19 +213,4 @@ public abstract class AbstractConfigurationComponent extends UIComponentBase imp this.isGroup = (Boolean) this.stateValues[6]; }
- public boolean getShouldShowRaw() { - return Boolean.valueOf(FacesContextUtility.getOptionalRequestParameter("showRaw", String.class, "unset")) - || (this.getConfigurationDefinition().getConfigurationFormat().equals(ConfigurationFormat.RAW)); - } - - RawConfigUIComponent rawConfigUIComponent; - - RawConfigUIComponent getRawConfigUIComponent() { - if (null == rawConfigUIComponent) { - rawConfigUIComponent = new RawConfigUIComponent(getConfiguration(), getConfigurationDefinition(), this, - isReadOnly()); - } - return rawConfigUIComponent; - } - } \ No newline at end of file diff --git a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/ConfigRenderer.java b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/ConfigRenderer.java index e3f0c16..b5e67a3 100644 --- a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/ConfigRenderer.java +++ b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/ConfigRenderer.java @@ -31,10 +31,7 @@ import javax.faces.application.FacesMessage; import javax.faces.component.UIComponent; import javax.faces.component.UIForm; import javax.faces.component.UIInput; -import javax.faces.component.UIOutput; -import javax.faces.component.UIPanel; import javax.faces.component.UIParameter; -import javax.faces.component.html.HtmlCommandLink; import javax.faces.component.html.HtmlForm; import javax.faces.component.html.HtmlOutputLink; import javax.faces.component.html.HtmlPanelGrid; @@ -57,7 +54,6 @@ import org.rhq.core.domain.configuration.Property; import org.rhq.core.domain.configuration.PropertyList; import org.rhq.core.domain.configuration.PropertyMap; import org.rhq.core.domain.configuration.PropertySimple; -import org.rhq.core.domain.configuration.definition.ConfigurationFormat; import org.rhq.core.domain.configuration.definition.PropertyDefinition; import org.rhq.core.domain.configuration.definition.PropertyDefinitionMap; import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple; @@ -88,7 +84,7 @@ public class ConfigRenderer extends Renderer { protected static final String GROUP_DESCRIPTION_PANEL_STYLE_CLASS = "group-description-panel"; protected static final String GROUP_DESCRIPTION_TEXT_PANEL_STYLE_CLASS = "group-description-text-panel";
- private static final Log LOG = LogFactory.getLog(ConfigRenderer.class); + private final Log LOG = LogFactory.getLog(ConfigRenderer.class); private static final String INIT_INPUTS_JAVA_SCRIPT_COMPONENT_ID_SUFFIX = "-initInputsJavaScript";
/** @@ -121,20 +117,6 @@ public class ConfigRenderer extends Renderer { .isFullyEditable(), true); } } - - Boolean readOnly = Boolean.valueOf(FacesContextUtility.getOptionalRequestParameter("readOnly")); - Boolean save = Boolean.valueOf(FacesContextUtility.getOptionalRequestParameter("save")); - configurationComponent.setReadOnly(readOnly); - - if (component.getChildCount() == 0) - addChildComponents(configurationComponent); - for (UIComponent kid : configurationComponent.getChildren()) { - if (kid instanceof RawConfigUIComponent) { - kid.decode(facesContext); - } - - } - }
/** @@ -213,16 +195,12 @@ public class ConfigRenderer extends Renderer { writer.writeText("\n", component, null); writer.endElement("div"); writer.writeComment("********** End of " + component.getClass().getSimpleName() + " component **********"); - - component.getChildren().clear(); }
public void addChildComponents(AbstractConfigurationComponent configurationComponent) { - if ((configurationComponent.getConfigurationDefinition() == null) || ((configurationComponent.getConfiguration() != null) && configurationComponent.getConfiguration() - .getMap().isEmpty()) - && !configurationComponent.getConfigurationDefinition().getConfigurationFormat().isRawSupported()) { + .getMap().isEmpty())) { if (configurationComponent.getNullConfigurationDefinitionMessage() != null) { String styleClass = (configurationComponent.getNullConfigurationStyle() == null) ? "ErrorBlock" : configurationComponent.getNullConfigurationStyle(); @@ -263,43 +241,6 @@ public class ConfigRenderer extends Renderer { } }
- Boolean shouldShowRawNow = configurationComponent.getShouldShowRaw(); - - if (shouldShowRawNow) { - configurationComponent.getChildren().add( - new RawConfigUIComponent(configurationComponent.getConfiguration(), configurationComponent - .getConfigurationDefinition(), configurationComponent, configurationComponent.isReadOnly())); - } else { - addStructuredConfig(configurationComponent); - } - } - - private void addStructuredConfig(AbstractConfigurationComponent configurationComponent) { - UIPanel toolbarPanel = FacesComponentUtility.addBlockPanel(configurationComponent, configurationComponent, - "summary-props-table"); - if (configurationComponent.isReadOnly()) { - HtmlCommandLink editLink = FacesComponentUtility.addCommandLink(toolbarPanel, configurationComponent); - FacesComponentUtility.addGraphicImage(editLink, configurationComponent, "/images/edit.png", "Edit"); - FacesComponentUtility.addOutputText(editLink, configurationComponent, "Edit", ""); - FacesComponentUtility.addParameter(editLink, configurationComponent, "readOnly", Boolean.toString(false)); - - } else { - HtmlCommandLink saveLink = FacesComponentUtility.addCommandLink(toolbarPanel, configurationComponent); - FacesComponentUtility.addGraphicImage(saveLink, configurationComponent, "/images/save.png", "Save"); - FacesComponentUtility.addOutputText(saveLink, configurationComponent, "Save", ""); - FacesComponentUtility.addParameter(saveLink, configurationComponent, "save", Boolean.toString(true)); - FacesComponentUtility.addParameter(saveLink, configurationComponent, "readOnly", Boolean.toString(true)); - } - - if (configurationComponent.getConfigurationDefinition().getConfigurationFormat().isRawSupported()) { - HtmlCommandLink toRawLink = FacesComponentUtility.addCommandLink(toolbarPanel, configurationComponent); - FacesComponentUtility.addGraphicImage(toRawLink, configurationComponent, "/images/raw.png", "showRaw"); - FacesComponentUtility.addOutputText(toRawLink, configurationComponent, "showRaw", ""); - FacesComponentUtility.addParameter(toRawLink, configurationComponent, "showRaw", Boolean.TRUE.toString()); - FacesComponentUtility.addParameter(toRawLink, configurationComponent, "readOnly", Boolean - .toString(configurationComponent.isReadOnly())); - } - if (!configurationComponent.isReadOnly()) addRequiredNotationsKey(configurationComponent);
@@ -319,27 +260,6 @@ public class ConfigRenderer extends Renderer { .isFullyEditable(), false); }
- private void addStructuredRawToggle(AbstractConfigurationComponent configurationComponent, boolean showRaw) { - if (configurationComponent.getConfigurationDefinition().getConfigurationFormat().equals( - ConfigurationFormat.STRUCTURED_AND_RAW)) { - - HtmlPanelGroup toRawLinkPanel = FacesComponentUtility.addBlockPanel(configurationComponent, - configurationComponent, UNGROUPED_PROPERTIES_STYLE_CLASS); - - FacesComponentUtility.addOutputText(toRawLinkPanel, configurationComponent, - "internationalized Message goes here", UNGROUPED_PROPERTIES_STYLE_CLASS); - - HtmlCommandLink commandLink = FacesComponentUtility.addCommandLink(toRawLinkPanel, configurationComponent); - - UIOutput output = new UIOutput(); - output.setValue(showRaw ? "Show Structured" : " Show Raw"); - commandLink.getChildren().add(output); - //output.setParent(commandLink); - FacesComponentUtility.addParameter(commandLink, configurationComponent, "showRaw", Boolean - .toString(!showRaw)); - } - } - private void addListMemberProperty(AbstractConfigurationComponent configurationComponent) { // Update member Configurations if this is a group config. if (configurationComponent instanceof ConfigurationSetComponent) { @@ -458,7 +378,7 @@ public class ConfigRenderer extends Renderer { + mapName + "'."); }
- private static void addRequiredNotationsKey(AbstractConfigurationComponent config) { + private void addRequiredNotationsKey(AbstractConfigurationComponent config) { addDebug(config, true, ".addNotePanel()"); HtmlPanelGroup footnotesPanel = FacesComponentUtility.addBlockPanel(config, config, NOTE_PANEL_STYLE_CLASS); FacesComponentUtility.addOutputText(footnotesPanel, config, "*", REQUIRED_MARKER_TEXT_STYLE_CLASS); @@ -573,11 +493,11 @@ public class ConfigRenderer extends Renderer { * @param start true if this is the "START" comment, false if it is the "END" comment * @param methodName the name of the method this is calling from */ - private static void addDebug(UIComponent component, boolean start, String methodName) { + private void addDebug(UIComponent component, boolean start, String methodName) { if (LOG.isDebugEnabled()) { StringBuilder msg = new StringBuilder("\n<!--"); msg.append(start ? " START " : " END "); - msg.append(ConfigRenderer.class.getSimpleName()); + msg.append(this.getClass().getSimpleName()); msg.append(methodName); msg.append(" -->\n "); FacesComponentUtility.addVerbatimText(component, msg); diff --git a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/RawConfigUIComponent.java b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/RawConfigUIComponent.java deleted file mode 100644 index ce42a54..0000000 --- a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/RawConfigUIComponent.java +++ /dev/null @@ -1,209 +0,0 @@ -package org.rhq.core.gui.configuration; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.Vector; - -import javax.faces.component.UIComponent; -import javax.faces.component.UIComponentBase; -import javax.faces.component.UIPanel; -import javax.faces.component.UIParameter; -import javax.faces.component.html.HtmlCommandLink; -import javax.faces.component.html.HtmlInputTextarea; -import javax.faces.component.html.HtmlOutputLink; -import javax.faces.component.html.HtmlPanelGrid; -import javax.faces.context.FacesContext; - -import org.rhq.core.domain.configuration.Configuration; -import org.rhq.core.domain.configuration.RawConfiguration; -import org.rhq.core.domain.configuration.definition.ConfigurationDefinition; -import org.rhq.core.gui.util.FacesComponentIdFactory; -import org.rhq.core.gui.util.FacesComponentUtility; -import org.rhq.core.gui.util.FacesContextUtility; - -public class RawConfigUIComponent extends UIComponentBase { - - private boolean readOnly; - private boolean showRaw; - - @Override - public void decode(FacesContext context) { - super.decode(context); - setSelectedPath(FacesContextUtility.getOptionalRequestParameter("path")); - readOnly = Boolean.valueOf(FacesContextUtility.getOptionalRequestParameter("readOnly")); - - } - - @Override - public String getFamily() { - return "rhq"; - } - - private Configuration configuration; - private ConfigurationDefinition configurationDefinition; - private FacesComponentIdFactory idFactory; - private String selectedPath; - private HtmlInputTextarea inputTextarea; - private Map<String, RawConfiguration> rawMap; - - public String getSelectedPath() { - if (null == selectedPath) { - if (configuration.getRawConfigurations().iterator().hasNext()) { - selectedPath = configuration.getRawConfigurations().iterator().next().getPath(); - } else { - selectedPath = ""; - } - } - return selectedPath; - } - - public void setSelectedPath(String selectedPath) { - if (selectedPath == null) - return; - for (RawConfiguration raw : configuration.getRawConfigurations()) { - if (raw.getPath().equals(selectedPath)) { - this.selectedPath = selectedPath; - } - } - } - - @Override - public boolean getRendersChildren() { - return true; - } - - @Override - public void encodeChildren(FacesContext context) throws IOException { - for (UIComponent kid : getChildren()) { - kid.encodeAll(context); - } - } - - @Override - public boolean isTransient() { - return true; - } - - Vector<UIParameter> readOnlyParms = new Vector<UIParameter>(); - - public RawConfigUIComponent(Configuration configuration, ConfigurationDefinition configurationDefinition, - FacesComponentIdFactory componentIdFactory, boolean readOnly) { - - this.configuration = configuration; - this.configurationDefinition = configurationDefinition; - this.idFactory = componentIdFactory; - this.readOnly = readOnly; - - UIPanel rawPanel = FacesComponentUtility.addBlockPanel(this, idFactory, ""); - - addToolbar(configurationDefinition, rawPanel); - - HtmlPanelGrid grid = FacesComponentUtility.addPanelGrid(rawPanel, idFactory, "summary-props-table"); - grid.setParent(this); - grid.setColumns(2); - grid.setColumnClasses("raw-config-table"); - - HtmlPanelGrid panelLeft = FacesComponentUtility.addPanelGrid(grid, idFactory, "summary-props-table"); - panelLeft.setBgcolor("#a4b2b9"); - panelLeft.setColumns(1); - - FacesComponentUtility.addOutputText(panelLeft, idFactory, "Raw Configurations Paths", ""); - - int rawCount = 0; - - ArrayList<String> configPathList = new ArrayList<String>(); - - rawMap = new HashMap<String, RawConfiguration>(); - - for (RawConfiguration raw : configuration.getRawConfigurations()) { - configPathList.add(raw.getPath()); - rawMap.put(raw.getPath(), raw); - } - Collections.sort(configPathList); - String oldDirname = ""; - for (String s : configPathList) { - RawConfiguration raw = rawMap.get(s); - String dirname = raw.getPath().substring(0, raw.getPath().lastIndexOf("/") + 1); - String basename = raw.getPath().substring(raw.getPath().lastIndexOf("/") + 1, raw.getPath().length()); - if (!dirname.equals(oldDirname)) { - FacesComponentUtility.addOutputText(panelLeft, idFactory, dirname, ""); - oldDirname = dirname; - } - UIPanel nextPath = FacesComponentUtility.addBlockPanel(panelLeft, idFactory, ""); - HtmlCommandLink link = FacesComponentUtility.addCommandLink(nextPath, idFactory); - FacesComponentUtility.addOutputText(link, idFactory, "[]" + basename, ""); - FacesComponentUtility.addParameter(link, idFactory, "path", raw.getPath()); - FacesComponentUtility.addParameter(link, idFactory, "whichRaw", Integer.toString(rawCount++)); - FacesComponentUtility.addParameter(link, idFactory, "showRaw", Boolean.TRUE.toString()); - readOnlyParms.add(FacesComponentUtility.addParameter(link, idFactory, "readOnly", Boolean - .toString(readOnly))); - - } - - UIPanel panelRight = FacesComponentUtility.addBlockPanel(grid, idFactory, "summary-props-table"); - - UIPanel editPanel = FacesComponentUtility.addBlockPanel(panelRight, idFactory, "summary-props-table"); - inputTextarea = new HtmlInputTextarea(); - editPanel.getChildren().add(inputTextarea); - inputTextarea.setParent(editPanel); - inputTextarea.setCols(80); - inputTextarea.setRows(40); - inputTextarea.setValue(rawMap.get(getSelectedPath()).getContentString()); - inputTextarea.setReadonly(readOnly); - } - - private void addToolbar(ConfigurationDefinition configurationDefinition, UIPanel parent) { - UIPanel toolbarPanel = FacesComponentUtility.addBlockPanel(parent, idFactory, "config-toolbar"); - if (readOnly) { - HtmlCommandLink editLink = FacesComponentUtility.addCommandLink(toolbarPanel, idFactory); - FacesComponentUtility.addGraphicImage(editLink, idFactory, "/images/edit.png", "Edit"); - FacesComponentUtility.addOutputText(editLink, idFactory, "Edit", ""); - FacesComponentUtility.addParameter(editLink, idFactory, "showStructured", Boolean.FALSE.toString()); - } else { - HtmlCommandLink saveLink = FacesComponentUtility.addCommandLink(toolbarPanel, idFactory); - FacesComponentUtility.addGraphicImage(saveLink, idFactory, "/images/save.png", "Save"); - FacesComponentUtility.addOutputText(saveLink, idFactory, "Save", ""); - FacesComponentUtility.addParameter(saveLink, idFactory, "showStructured", Boolean.FALSE.toString()); - } - { - HtmlCommandLink saveCommandLink = FacesComponentUtility.addCommandLink(toolbarPanel, idFactory); - FacesComponentUtility.addGraphicImage(saveCommandLink, idFactory, "/images/viewfullscreen.png", - "FullScreen"); - FacesComponentUtility.addOutputText(saveCommandLink, idFactory, "Full Screen", ""); - } - if (!readOnly) { - HtmlOutputLink uploadLink = FacesComponentUtility.addOutputLink(toolbarPanel, idFactory, "upload.xhtml"); - FacesComponentUtility.addGraphicImage(uploadLink, idFactory, "/images/upload.png", "Upload"); - FacesComponentUtility.addOutputText(uploadLink, idFactory, "Upload", ""); - } - { - HtmlOutputLink downloadLink = FacesComponentUtility - .addOutputLink(toolbarPanel, idFactory, "download.xhtml"); - FacesComponentUtility.addGraphicImage(downloadLink, idFactory, "/images/download.png", "download"); - FacesComponentUtility.addOutputText(downloadLink, idFactory, "Download", ""); - } - if (configurationDefinition.getConfigurationFormat().isStructuredSupported()) { - HtmlCommandLink toStructureLink = FacesComponentUtility.addCommandLink(toolbarPanel, idFactory); - FacesComponentUtility.addGraphicImage(toStructureLink, idFactory, "/images/structured.png", - "showStructured"); - FacesComponentUtility.addOutputText(toStructureLink, idFactory, "showStructured", ""); - FacesComponentUtility.addParameter(toStructureLink, idFactory, "showRaw", Boolean.FALSE.toString()); - readOnlyParms.add(FacesComponentUtility.addParameter(toStructureLink, idFactory, "readOnly", Boolean - .toString(readOnly))); - } - } - - @Override - public void encodeBegin(FacesContext context) throws IOException { - // TODO Auto-generated method stub - super.encodeBegin(context); - inputTextarea.setValue(rawMap.get(getSelectedPath()).getContentString()); - for (UIParameter param : readOnlyParms) { - param.setValue(Boolean.toString(readOnly)); - } - - } -} diff --git a/modules/core/gui/src/main/java/org/rhq/core/gui/util/FacesComponentUtility.java b/modules/core/gui/src/main/java/org/rhq/core/gui/util/FacesComponentUtility.java index ad2274b..a3c2257 100644 --- a/modules/core/gui/src/main/java/org/rhq/core/gui/util/FacesComponentUtility.java +++ b/modules/core/gui/src/main/java/org/rhq/core/gui/util/FacesComponentUtility.java @@ -1,25 +1,25 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2, as - * published by the Free Software Foundation, and/or the GNU Lesser - * General Public License, version 2.1, also as published by the Free - * Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License and the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License - * and the GNU Lesser General Public License along with this program; - * if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ + /* + * RHQ Management Platform + * Copyright (C) 2005-2008 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ package org.rhq.core.gui.util;
import java.util.ArrayList; @@ -32,10 +32,10 @@ import java.util.UUID; import javax.el.ValueExpression; import javax.faces.application.Application; import javax.faces.component.UIComponent; -import javax.faces.component.UIForm; import javax.faces.component.UIInput; import javax.faces.component.UIOutput; import javax.faces.component.UIParameter; +import javax.faces.component.UIForm; import javax.faces.component.UIViewRoot; import javax.faces.component.html.HtmlColumn; import javax.faces.component.html.HtmlCommandButton; @@ -50,17 +50,16 @@ import javax.faces.component.html.HtmlOutputText; import javax.faces.component.html.HtmlPanelGrid; import javax.faces.component.html.HtmlPanelGroup; import javax.faces.context.FacesContext; - import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.richfaces.component.html.HtmlSeparator; import org.richfaces.component.html.HtmlSimpleTogglePanel;
-/** -* A set of utility methods for working with JSF {@link UIComponent}s. -* -* @author Ian Springer -*/ + /** + * A set of utility methods for working with JSF {@link UIComponent}s. + * + * @author Ian Springer + */ public abstract class FacesComponentUtility { public static final String NO_STYLE_CLASS = null;
@@ -78,31 +77,16 @@ public abstract class FacesComponentUtility { }
@NotNull - public static HtmlPanelGrid createPanelGrid(FacesComponentIdFactory idFactory, String styleClass) { - HtmlPanelGrid panel = createComponent(HtmlPanelGrid.class, idFactory); - panel.setStyleClass(styleClass); - return panel; - } - - @NotNull - public static HtmlPanelGroup addBlockPanel(@NotNull UIComponent parent, FacesComponentIdFactory idFactory, - String styleClass) { + public static HtmlPanelGroup addBlockPanel(@NotNull + UIComponent parent, FacesComponentIdFactory idFactory, String styleClass) { HtmlPanelGroup panel = createBlockPanel(idFactory, styleClass); parent.getChildren().add(panel); return panel; }
@NotNull - public static HtmlPanelGrid addPanelGrid(@NotNull UIComponent parent, FacesComponentIdFactory idFactory, - String styleClass) { - HtmlPanelGrid panel = createPanelGrid(idFactory, styleClass); - parent.getChildren().add(panel); - return panel; - } - - @NotNull - public static HtmlPanelGroup addInlinePanel(@NotNull UIComponent parent, FacesComponentIdFactory idFactory, - String styleClass) { + public static HtmlPanelGroup addInlinePanel(@NotNull + UIComponent parent, FacesComponentIdFactory idFactory, String styleClass) { HtmlPanelGroup panel = createComponent(HtmlPanelGroup.class, idFactory); panel.setStyleClass(styleClass); parent.getChildren().add(panel); @@ -110,8 +94,8 @@ public abstract class FacesComponentUtility { }
@NotNull - public static HtmlSimpleTogglePanel addSimpleTogglePanel(@NotNull UIComponent parent, - FacesComponentIdFactory idFactory, String label) { + public static HtmlSimpleTogglePanel addSimpleTogglePanel(@NotNull + UIComponent parent, FacesComponentIdFactory idFactory, String label) { HtmlSimpleTogglePanel panel = createComponent(HtmlSimpleTogglePanel.class, idFactory); panel.setLabel(label);
@@ -122,15 +106,16 @@ public abstract class FacesComponentUtility { }
@NotNull - public static HtmlSeparator addSeparator(@NotNull UIComponent parent, FacesComponentIdFactory idFactory) { + public static HtmlSeparator addSeparator(@NotNull + UIComponent parent, FacesComponentIdFactory idFactory) { HtmlSeparator separator = createComponent(HtmlSeparator.class, idFactory); parent.getChildren().add(separator); return separator; }
@NotNull - public static HtmlOutputText addOutputText(@NotNull UIComponent parent, FacesComponentIdFactory idFactory, - CharSequence value, String styleClass) { + public static HtmlOutputText addOutputText(@NotNull + UIComponent parent, FacesComponentIdFactory idFactory, CharSequence value, String styleClass) { HtmlOutputText text = createComponent(HtmlOutputText.class, idFactory); text.setValue(value); text.setStyleClass(styleClass); @@ -150,8 +135,8 @@ public abstract class FacesComponentUtility { }
@NotNull - public static HtmlColumn addColumn(@NotNull UIComponent parent, FacesComponentIdFactory idFactory, - CharSequence headerText, String headerStyle) { + public static HtmlColumn addColumn(@NotNull + UIComponent parent, FacesComponentIdFactory idFactory, CharSequence headerText, String headerStyle) { HtmlColumn column = createComponent(HtmlColumn.class, idFactory); HtmlOutputText header = new HtmlOutputText(); header.setValue(headerText); @@ -162,7 +147,8 @@ public abstract class FacesComponentUtility { }
@NotNull - public static HtmlOutputText addVerbatimText(@NotNull UIComponent parent, CharSequence html) { + public static HtmlOutputText addVerbatimText(@NotNull + UIComponent parent, CharSequence html) { HtmlOutputText outputText = createComponent(HtmlOutputText.class, null); outputText.setEscape(false); outputText.setValue(html); @@ -177,8 +163,10 @@ public abstract class FacesComponentUtility { }
@NotNull - public static UIOutput addJavaScript(@NotNull UIComponent parent, FacesComponentIdFactory idFactory, - @Nullable CharSequence src, @Nullable CharSequence script) { + public static UIOutput addJavaScript(@NotNull + UIComponent parent, FacesComponentIdFactory idFactory, @Nullable + CharSequence src, @Nullable + CharSequence script) { UIOutput output = createComponent(UIOutput.class, idFactory); output.getAttributes().put("escape", Boolean.FALSE); StringBuilder value = new StringBuilder(); @@ -232,8 +220,8 @@ public abstract class FacesComponentUtility { }
@NotNull - public static HtmlOutputLabel addLabel(@NotNull UIComponent parent, FacesComponentIdFactory idFactory, - UIInput associatedInput, String value, String styleClass) { + public static HtmlOutputLabel addLabel(@NotNull + UIComponent parent, FacesComponentIdFactory idFactory, UIInput associatedInput, String value, String styleClass) { HtmlOutputLabel label = createComponent(HtmlOutputLabel.class, idFactory); label.setFor(associatedInput.getId()); label.setValue(value); @@ -243,8 +231,8 @@ public abstract class FacesComponentUtility { }
@NotNull - public static HtmlGraphicImage addGraphicImage(@NotNull UIComponent parent, FacesComponentIdFactory idFactory, - String url, String alt) { + public static HtmlGraphicImage addGraphicImage(@NotNull + UIComponent parent, FacesComponentIdFactory idFactory, String url, String alt) { HtmlGraphicImage image = FacesComponentUtility.createComponent(HtmlGraphicImage.class, idFactory); image.setUrl(url); image.setAlt(alt); @@ -254,8 +242,8 @@ public abstract class FacesComponentUtility { }
@NotNull - public static HtmlOutputLink addOutputLink(@NotNull UIComponent parent, FacesComponentIdFactory idFactory, - String value) { + public static HtmlOutputLink addOutputLink(@NotNull + UIComponent parent, FacesComponentIdFactory idFactory, String value) { HtmlOutputLink link = FacesComponentUtility.createComponent(HtmlOutputLink.class, idFactory); link.setValue(value); parent.getChildren().add(link); @@ -263,8 +251,8 @@ public abstract class FacesComponentUtility { }
@NotNull - public static UIParameter addParameter(@NotNull UIComponent parent, FacesComponentIdFactory idFactory, String name, - String value) { + public static UIParameter addParameter(@NotNull + UIComponent parent, FacesComponentIdFactory idFactory, String name, String value) { UIParameter parameter = createComponent(UIParameter.class, idFactory); parameter.setName(name); parameter.setValue(value); @@ -273,7 +261,8 @@ public abstract class FacesComponentUtility { }
@NotNull - public static HtmlForm addForm(@NotNull UIComponent parent, FacesComponentIdFactory idFactory) { + public static HtmlForm addForm(@NotNull + UIComponent parent, FacesComponentIdFactory idFactory) { HtmlForm form = createComponent(HtmlForm.class, idFactory); form.setPrependId(false); parent.getChildren().add(form); @@ -281,8 +270,8 @@ public abstract class FacesComponentUtility { }
@NotNull - public static HtmlCommandButton addCommandButton(@NotNull UIComponent parent, FacesComponentIdFactory idFactory, - String value, String styleClass) { + public static HtmlCommandButton addCommandButton(@NotNull + UIComponent parent, FacesComponentIdFactory idFactory, String value, String styleClass) { HtmlCommandButton button = createComponent(HtmlCommandButton.class, idFactory); button.setValue(value); button.setStyleClass(styleClass); @@ -291,15 +280,16 @@ public abstract class FacesComponentUtility { }
@NotNull - public static HtmlCommandLink addCommandLink(@NotNull UIComponent parent, FacesComponentIdFactory idFactory) { + public static HtmlCommandLink addCommandLink(@NotNull + UIComponent parent, FacesComponentIdFactory idFactory) { HtmlCommandLink link = FacesComponentUtility.createComponent(HtmlCommandLink.class, idFactory); parent.getChildren().add(link); return link; }
@NotNull - public static HtmlMessage addMessage(@NotNull UIComponent parent, FacesComponentIdFactory idFactory, - String associatedComponentId, String styleClass) { + public static HtmlMessage addMessage(@NotNull + UIComponent parent, FacesComponentIdFactory idFactory, String associatedComponentId, String styleClass) { HtmlMessage message = FacesComponentUtility.createComponent(HtmlMessage.class, idFactory); message.setFor(associatedComponentId); message.setShowDetail(true); @@ -312,8 +302,8 @@ public abstract class FacesComponentUtility { }
@NotNull - public static HtmlPanelGrid addPanelGrid(@NotNull UIComponent parent, FacesComponentIdFactory idFactory, - int columns, String styleClass) { + public static HtmlPanelGrid addPanelGrid(@NotNull + UIComponent parent, FacesComponentIdFactory idFactory, int columns, String styleClass) { HtmlPanelGrid panelGrid = FacesComponentUtility.createComponent(HtmlPanelGrid.class, idFactory); panelGrid.setColumns(columns); panelGrid.setStyleClass(styleClass); @@ -322,8 +312,8 @@ public abstract class FacesComponentUtility { }
@NotNull - public static HtmlDataTable addDataTable(@NotNull UIComponent parent, FacesComponentIdFactory idFactory, - String styleClass) { + public static HtmlDataTable addDataTable(@NotNull + UIComponent parent, FacesComponentIdFactory idFactory, String styleClass) { HtmlDataTable dataTable = FacesComponentUtility.createComponent(HtmlDataTable.class, idFactory); dataTable.setStyleClass(styleClass); parent.getChildren().add(dataTable); @@ -331,13 +321,17 @@ public abstract class FacesComponentUtility { }
@Nullable - public static String getExpressionAttribute(@NotNull UIComponent component, @NotNull String attribName) { + public static String getExpressionAttribute(@NotNull + UIComponent component, @NotNull + String attribName) { return getExpressionAttribute(component, attribName, String.class); }
@Nullable - public static <T> T getExpressionAttribute(@NotNull UIComponent component, @NotNull String attribName, - @NotNull Class<T> expectedType) { + public static <T> T getExpressionAttribute(@NotNull + UIComponent component, @NotNull + String attribName, @NotNull + Class<T> expectedType) { ValueExpression valueExpression = component.getValueExpression(attribName); T attribValue = (valueExpression != null) ? FacesExpressionUtility.getValue(valueExpression, expectedType) : null; @@ -345,7 +339,8 @@ public abstract class FacesComponentUtility { }
@NotNull - public static Map<String, String> getParameters(@NotNull UIComponent component) { + public static Map<String, String> getParameters(@NotNull + UIComponent component) { // Use a LinkedHashMap, so the order of the parameters is maintained. Map<String, String> params = new LinkedHashMap<String, String>(); List<UIComponent> children = component.getChildren(); @@ -380,8 +375,8 @@ public abstract class FacesComponentUtility { * @return a {@link UIComponent} of the specified type */ @SuppressWarnings("unchecked") - public static <T extends UIComponent> T createComponent(Class<T> componentClass, - @Nullable FacesComponentIdFactory idFactory) { + public static <T extends UIComponent> T createComponent(Class<T> componentClass, @Nullable + FacesComponentIdFactory idFactory) { Application application = FacesContext.getCurrentInstance().getApplication(); String componentType = getComponentType(componentClass); T component = (T) application.createComponent(componentType); @@ -505,20 +500,25 @@ public abstract class FacesComponentUtility { * @throws IllegalArgumentException if more than one UIForm is found in the component's ancestry */ @Nullable - public static UIForm getEnclosingForm(UIComponent component) throws IllegalArgumentException { - UIForm ret = null; - while (component != null) { - if (component instanceof UIForm) { - if (ret != null) { - // Cannot have a doubly-nested form! - throw new IllegalArgumentException(); - } - ret = (UIForm) component; - } - component = component.getParent(); - } - return ret; - } + public static UIForm getEnclosingForm(UIComponent component) + throws IllegalArgumentException + { + UIForm ret = null; + while (component != null) + { + if (component instanceof UIForm) + { + if (ret != null) + { + // Cannot have a doubly-nested form! + throw new IllegalArgumentException(); + } + ret = (UIForm) component; + } + component = component.getParent(); + } + return ret; + }
private static <T extends UIComponent> String getComponentType(Class<T> componentClass) { String componentType; @@ -531,8 +531,9 @@ public abstract class FacesComponentUtility { return componentType; }
- private static class DefaultFacesComponentIdFactory implements FacesComponentIdFactory { - public String createUniqueId() { + private static class DefaultFacesComponentIdFactory implements FacesComponentIdFactory { + public String createUniqueId() + { // NOTE: Our id's *must* begin with UIViewRoot.UNIQUE_ID_PREFIX ("j_id") to prevent HtmlOutputText // components from being rendered as SPAN elements // (see com.sun.faces.renderkit.html_basic.TextRenderer#getEndTextToRender()). diff --git a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/ConfigRendererTest.java b/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/ConfigRendererTest.java deleted file mode 100644 index d3db839..0000000 --- a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/ConfigRendererTest.java +++ /dev/null @@ -1,165 +0,0 @@ -package org.rhq.core.gui.configuration; - -import java.io.IOException; -import java.io.StringWriter; -import java.util.HashMap; - -import javax.faces.FactoryFinder; -import javax.faces.component.UIForm; -import javax.faces.context.FacesContext; -import javax.faces.lifecycle.Lifecycle; - -import com.sun.faces.context.FacesContextImpl; - -import org.ajax4jsf.context.AjaxContext; -import org.testng.Assert; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import org.rhq.core.domain.configuration.Configuration; -import org.rhq.core.domain.configuration.Property; -import org.rhq.core.domain.configuration.RawConfiguration; -import org.rhq.core.domain.configuration.definition.ConfigurationDefinition; -import org.rhq.core.domain.configuration.definition.ConfigurationFormat; - -public class ConfigRendererTest { - - ConfigUIComponent configUIComponent; - ConfigRenderer configRenderer; - FacesContext facesContext; - MockExternalContext externalContext; - AjaxContext ajaxContext; - MockResponseWriter mockResponseWriter; - Lifecycle lifecycle; - ConfigurationDefinition configurationDefinition; - private Configuration configuration; - - @BeforeMethod - protected void setUp() throws Exception { - //Order is pretty important here - FactoryFinder.setFactory(FactoryFinder.RENDER_KIT_FACTORY, MockRenderKitFactory.class.getName()); - FactoryFinder.setFactory(FactoryFinder.APPLICATION_FACTORY, MockApplicationFactory.class.getName()); - - externalContext = new MockExternalContext(); - lifecycle = new MockLifecycle(); - mockResponseWriter = new MockResponseWriter(); - configUIComponent = new ConfigUIComponent(); - configRenderer = new ConfigRenderer(); - - FacesContextImpl impl = new FacesContextImpl(externalContext, lifecycle); - HashMap<Object, Object> map = new HashMap<Object, Object>(); - map.put("com.sun.faces.FacesContextImpl", impl); - - //Whichever one gets created last wins the - //"I'm registered with thread local storage and you are not" game - facesContext = new MockFacesContext(externalContext, mockResponseWriter); - facesContext.getExternalContext().getRequestMap().put("com.sun.faces.util.RequestStateManager", map); - ajaxContext = AjaxContext.getCurrentInstance(facesContext); - - configUIComponent.setId("ID"); - configuration = new Configuration(); - configUIComponent.setValueExpression("configuration", new MockValueExpression(configuration)); - configUIComponent.setValueExpression("configurationDefinition", - new MockValueExpression(buildConfigDefinition())); - configUIComponent.setRendererType(ConfigRenderer.class.getName()); - - } - - private ConfigurationDefinition buildConfigDefinition() { - ConfigurationDefinition def = new ConfigurationDefinition("MockDef", "Mock Configuration definition"); - - return def; - } - - //@Test - public void testUIComponentDecode() { - configUIComponent.setRendererType(ConfigRenderer.class.getName()); - configUIComponent.decode(facesContext); - } - - @Test - public void testUIComponentEncode() throws IOException { - Property value; - value = new Property(); - value.setName("test1"); - value.setConfiguration(configuration); - value.setId(3); - - configuration.getMap().put(value.getName(), value); - configuration.getRawConfigurations().add(buildMockRawConfig()); - - Assert.assertNotNull(configUIComponent.getConfigurationDefinition()); - - UIForm form = new UIForm(); - form.setId("form"); - form.getChildren().add(configUIComponent); - configUIComponent.setParent(form); - - configUIComponent.getConfigurationDefinition().setConfigurationFormat(ConfigurationFormat.STRUCTURED_AND_RAW); - - Assert.assertNotNull(configUIComponent.getConfigurationDefinition().getConfigurationFormat()); - Assert.assertTrue(configUIComponent.getConfigurationDefinition().getConfigurationFormat().isRawSupported()); - Assert.assertTrue(configUIComponent.getConfigurationDefinition().getConfigurationFormat() - .isStructuredSupported()); - - externalContext.requestParameterMap.put("showRaw", "true"); - - configUIComponent.encodeAll(facesContext); - - String s2 = mockResponseWriter.stringWriter.getBuffer().toString(); - - System.out.println(s2); - - } - - private RawConfiguration buildMockRawConfig() { - RawConfiguration raw = new RawConfiguration(); - - raw.setContents("a=1".getBytes()); - return raw; - } - - //@Test - public void testDecode() { - configUIComponent.setReadOnly(false); - Assert.assertNotNull(configUIComponent.getConfiguration()); - configRenderer.decode(facesContext, configUIComponent); - } - - //@Test - public void testEncode() throws IOException { - configUIComponent.setReadOnly(true); - configUIComponent.setPrevalidate(false); - /* - <onc:config - configurationDefinition="#{ExistingResourceConfigurationUIBean.configurationDefinition}" - configuration="#{ExistingResourceConfigurationUIBean.configuration}" - accessMapActionExpression="#{ExistingResourceConfigurationUIBean.accessMap}" - readOnly="true" - nullConfigurationDefinitionMessage="#{ExistingResourceConfigurationUIBean.nullConfigurationDefinitionMessage}" - nullConfigurationMessage="#{ExistingResourceConfigurationUIBean.nullConfigurationMessage}" - prevalidate="true"/> - */ - - configRenderer.encodeBegin(this.facesContext, configUIComponent); - configRenderer.encodeChildren(facesContext, configUIComponent); - configRenderer.encodeEnd(facesContext, configUIComponent); - String s1 = mockResponseWriter.stringWriter.getBuffer().toString(); - - mockResponseWriter.stringWriter = new StringWriter(); - - configUIComponent.setReadOnly(false); - configUIComponent.setPrevalidate(false); - - configRenderer.encodeBegin(this.facesContext, configUIComponent); - configRenderer.encodeChildren(facesContext, configUIComponent); - configRenderer.encodeEnd(facesContext, configUIComponent); - String s2 = mockResponseWriter.stringWriter.getBuffer().toString(); - - Assert.assertTrue(!s1.equals(s2)); - - System.out.println(s1); - - } - -} diff --git a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockApplication.java b/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockApplication.java deleted file mode 100644 index 94f5bc8..0000000 --- a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockApplication.java +++ /dev/null @@ -1,269 +0,0 @@ -package org.rhq.core.gui.configuration; - -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Locale; -import java.util.Map; - -import javax.faces.FacesException; -import javax.faces.application.Application; -import javax.faces.application.NavigationHandler; -import javax.faces.application.StateManager; -import javax.faces.application.ViewHandler; -import javax.faces.component.UIComponent; -import javax.faces.component.UIParameter; -import javax.faces.component.html.HtmlCommandLink; -import javax.faces.component.html.HtmlGraphicImage; -import javax.faces.component.html.HtmlOutputFormat; -import javax.faces.component.html.HtmlOutputText; -import javax.faces.component.html.HtmlPanelGrid; -import javax.faces.component.html.HtmlPanelGroup; -import javax.faces.context.FacesContext; -import javax.faces.convert.Converter; -import javax.faces.el.MethodBinding; -import javax.faces.el.PropertyResolver; -import javax.faces.el.ReferenceSyntaxException; -import javax.faces.el.ValueBinding; -import javax.faces.el.VariableResolver; -import javax.faces.event.ActionListener; -import javax.faces.validator.Validator; - -public class MockApplication extends Application { - - Map<String, Class> componentTypeMap; - - @Override - public void addComponent(String componentType, String componentClass) { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public void addConverter(Class targetClass, String converterClass) { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public void addConverter(String converterId, String converterClass) { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public void addValidator(String validatorId, String validatorClass) { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public UIComponent createComponent(String componentType) throws FacesException { - try { - return (UIComponent) getComponentTypeMap().get(componentType).newInstance(); - } catch (Exception e) { - e.printStackTrace(); - throw new FacesException("can't create component " + componentType); - } - - } - - @Override - public UIComponent createComponent(ValueBinding componentBinding, FacesContext context, String componentType) - throws FacesException { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public Converter createConverter(Class targetClass) { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public Converter createConverter(String converterId) { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public MethodBinding createMethodBinding(String ref, Class[] params) throws ReferenceSyntaxException { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public Validator createValidator(String validatorId) throws FacesException { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public ValueBinding createValueBinding(String ref) throws ReferenceSyntaxException { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public ActionListener getActionListener() { - throw new RuntimeException("Function not implemented"); - - } - - Map<String, Class> getComponentTypeMap() { - if (null == componentTypeMap) { - - componentTypeMap = new HashMap<String, Class>(); - componentTypeMap.put("javax.faces.HtmlOutputText", HtmlOutputText.class); - componentTypeMap.put("javax.faces.HtmlPanelGroup", HtmlPanelGroup.class); - componentTypeMap.put("javax.faces.Output", HtmlOutputFormat.class); - componentTypeMap.put("javax.faces.HtmlCommandLink", HtmlCommandLink.class); - componentTypeMap.put("javax.faces.Parameter", UIParameter.class); - componentTypeMap.put("javax.faces.HtmlGraphicImage", HtmlGraphicImage.class); - componentTypeMap.put("javax.faces.HtmlPanelGrid", HtmlPanelGrid.class); - } - return componentTypeMap; - } - - @Override - public Iterator<String> getComponentTypes() { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public Iterator<String> getConverterIds() { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public Iterator<Class> getConverterTypes() { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public Locale getDefaultLocale() { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public String getDefaultRenderKitId() { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public String getMessageBundle() { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public NavigationHandler getNavigationHandler() { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public PropertyResolver getPropertyResolver() { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public StateManager getStateManager() { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public Iterator<Locale> getSupportedLocales() { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public Iterator<String> getValidatorIds() { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public VariableResolver getVariableResolver() { - throw new RuntimeException("Function not implemented"); - - } - - MockViewHandler mockViewHandler = new MockViewHandler(); - - @Override - public ViewHandler getViewHandler() { - return mockViewHandler; - - } - - @Override - public void setActionListener(ActionListener listener) { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public void setDefaultLocale(Locale locale) { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public void setDefaultRenderKitId(String renderKitId) { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public void setMessageBundle(String bundle) { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public void setNavigationHandler(NavigationHandler handler) { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public void setPropertyResolver(PropertyResolver resolver) { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public void setStateManager(StateManager manager) { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public void setSupportedLocales(Collection<Locale> locales) { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public void setVariableResolver(VariableResolver resolver) { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public void setViewHandler(ViewHandler handler) { - throw new RuntimeException("Function not implemented"); - - } - -} diff --git a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockApplicationFactory.java b/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockApplicationFactory.java deleted file mode 100644 index ba180a3..0000000 --- a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockApplicationFactory.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.rhq.core.gui.configuration; - -import javax.faces.application.Application; -import javax.faces.application.ApplicationFactory; - -public class MockApplicationFactory extends ApplicationFactory { - - Application application = new MockApplication(); - - @Override - public Application getApplication() { - return application; - } - - @Override - public void setApplication(Application application) { - this.application = application; - } - -} diff --git a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockExternalContext.java b/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockExternalContext.java deleted file mode 100644 index ed0af06..0000000 --- a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockExternalContext.java +++ /dev/null @@ -1,235 +0,0 @@ -package org.rhq.core.gui.configuration; - -import java.io.IOException; -import java.io.InputStream; -import java.net.MalformedURLException; -import java.net.URL; -import java.security.Principal; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Locale; -import java.util.Map; -import java.util.Set; - -import javax.faces.context.ExternalContext; - -import com.sun.faces.application.ApplicationImpl; - -public class MockExternalContext extends ExternalContext { - - @Override - public void dispatch(String path) throws IOException { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public String encodeActionURL(String url) { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public String encodeNamespace(String name) { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public String encodeResourceURL(String url) { - - return "encodedUrl:" + url; - - } - - public Map<String, Object> applicationMap; - - @Override - public Map<String, Object> getApplicationMap() { - if (null == applicationMap) { - applicationMap = new HashMap<String, Object>(); - applicationMap.put("com.sun.faces.ApplicationImpl", new ApplicationImpl()); - applicationMap.put("com.sun.faces.sunJsfJs", "Javascript goes here".toCharArray()); - } - - return applicationMap; - } - - @Override - public String getAuthType() { - throw new RuntimeException("Function not implemented"); - - } - - MockServletContext servletContext = new MockServletContext(); - - @Override - public Object getContext() { - return servletContext; - } - - @Override - public String getInitParameter(String name) { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public Map getInitParameterMap() { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public String getRemoteUser() { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public Object getRequest() { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public String getRequestContextPath() { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public Map<String, Object> getRequestCookieMap() { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public Map<String, String> getRequestHeaderMap() { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public Map<String, String[]> getRequestHeaderValuesMap() { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public Locale getRequestLocale() { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public Iterator<Locale> getRequestLocales() { - throw new RuntimeException("Function not implemented"); - - } - - Map<String, Object> requestMap = new HashMap<String, Object>(); - - @Override - public Map<String, Object> getRequestMap() { - return requestMap; - } - - public Map<String, String> requestParameterMap = new HashMap<String, String>(); - - @Override - public Map<String, String> getRequestParameterMap() { - return requestParameterMap; - } - - @Override - public Iterator<String> getRequestParameterNames() { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public Map<String, String[]> getRequestParameterValuesMap() { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public String getRequestPathInfo() { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public String getRequestServletPath() { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public URL getResource(String path) throws MalformedURLException { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public InputStream getResourceAsStream(String path) { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public Set<String> getResourcePaths(String path) { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public Object getResponse() { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public Object getSession(boolean create) { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public Map<String, Object> getSessionMap() { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public Principal getUserPrincipal() { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public boolean isUserInRole(String role) { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public void log(String message) { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public void log(String message, Throwable exception) { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public void redirect(String url) throws IOException { - throw new RuntimeException("Function not implemented"); - - } - -} diff --git a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockFacesContext.java b/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockFacesContext.java deleted file mode 100644 index c61465d..0000000 --- a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockFacesContext.java +++ /dev/null @@ -1,150 +0,0 @@ -package org.rhq.core.gui.configuration; - -import java.util.Iterator; - -import javax.faces.application.Application; -import javax.faces.application.FacesMessage; -import javax.faces.application.FacesMessage.Severity; -import javax.faces.component.UIViewRoot; -import javax.faces.context.ExternalContext; -import javax.faces.context.FacesContext; -import javax.faces.context.ResponseStream; -import javax.faces.context.ResponseWriter; -import javax.faces.render.RenderKit; - -import com.sun.faces.renderkit.RenderKitImpl; - -public class MockFacesContext extends FacesContext { - - private ExternalContext externalContext; - private MockResponseWriter responseWriter; - - public MockFacesContext(ExternalContext externalContext, MockResponseWriter responseWriter) { - this.externalContext = externalContext; - this.responseWriter = responseWriter; - FacesContext.setCurrentInstance(this); - } - - @Override - public void addMessage(String clientId, FacesMessage message) { - throw new RuntimeException("Function not implemented"); - } - - MockApplication mockApp; - - @Override - public Application getApplication() { - if (null == mockApp) { - mockApp = new MockApplication(); - } - return mockApp; - } - - @Override - public Iterator<String> getClientIdsWithMessages() { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public ExternalContext getExternalContext() { - return externalContext; - - } - - @Override - public Severity getMaximumSeverity() { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public Iterator<FacesMessage> getMessages() { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public Iterator<FacesMessage> getMessages(String clientId) { - throw new RuntimeException("Function not implemented"); - - } - - RenderKit renderKit = new MockRenderKit(); - - @Override - public RenderKit getRenderKit() { - if (null == renderKit) { - renderKit = new RenderKitImpl(); - renderKit.addRenderer("rhq", ConfigRenderer.class.getName(), new ConfigRenderer()); - } - return renderKit; - } - - @Override - public boolean getRenderResponse() { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public boolean getResponseComplete() { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public ResponseStream getResponseStream() { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public ResponseWriter getResponseWriter() { - return responseWriter; - } - - @Override - public UIViewRoot getViewRoot() { - return null; - //throw new RuntimeException("Function not implemented"); - - } - - @Override - public void release() { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public void renderResponse() { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public void responseComplete() { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public void setResponseStream(ResponseStream responseStream) { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public void setResponseWriter(ResponseWriter responseWriter) { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public void setViewRoot(UIViewRoot root) { - throw new RuntimeException("Function not implemented"); - - } - -} diff --git a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockLifecycle.java b/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockLifecycle.java deleted file mode 100644 index c48708d..0000000 --- a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockLifecycle.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.rhq.core.gui.configuration; - -import javax.faces.FacesException; -import javax.faces.context.FacesContext; -import javax.faces.event.PhaseListener; -import javax.faces.lifecycle.Lifecycle; - -public class MockLifecycle extends Lifecycle { - - @Override - public void addPhaseListener(PhaseListener listener) { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public void execute(FacesContext context) throws FacesException { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public PhaseListener[] getPhaseListeners() { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public void removePhaseListener(PhaseListener listener) { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public void render(FacesContext context) throws FacesException { - throw new RuntimeException("Function not implemented"); - - } - -} diff --git a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockRenderKit.java b/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockRenderKit.java deleted file mode 100644 index 2d1981f..0000000 --- a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockRenderKit.java +++ /dev/null @@ -1,88 +0,0 @@ -package org.rhq.core.gui.configuration; - -import java.io.OutputStream; -import java.io.Writer; -import java.util.HashMap; -import java.util.HashSet; - -import javax.faces.context.ResponseStream; -import javax.faces.context.ResponseWriter; -import javax.faces.render.RenderKit; -import javax.faces.render.Renderer; -import javax.faces.render.ResponseStateManager; - -import com.sun.faces.renderkit.html_basic.GroupRenderer; -import com.sun.faces.renderkit.html_basic.OutputMessageRenderer; -import com.sun.faces.renderkit.html_basic.TextRenderer; - -public class MockRenderKit extends RenderKit { - - @Override - public void addRenderer(String family, String rendererType, Renderer renderer) { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public ResponseStream createResponseStream(OutputStream out) { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public ResponseWriter createResponseWriter(Writer writer, String contentTypeList, String characterEncoding) { - throw new RuntimeException("Function not implemented"); - - } - - HashSet<String> noRendererSet; - - public HashSet<String> getNoRendererSet() { - if (null == noRendererSet) { - noRendererSet = new HashSet<String>(); - noRendererSet.add("javax.faces.HtmlCommandLink"); - noRendererSet.add("javax.faces.Form"); - noRendererSet.add("javax.faces.Textarea"); - } - return noRendererSet; - } - - HashMap<String, Class> rendererMap; - - @Override - public Renderer getRenderer(String family, String rendererType) { - - if (getNoRendererSet().contains(rendererType)) - return null; - - try { - if (null == rendererMap) { - rendererMap = new HashMap<String, Class>(); - rendererMap.put("javax.faces.Text", TextRenderer.class); - rendererMap.put("javax.faces.Format", OutputMessageRenderer.class); - rendererMap.put("javax.faces.Group", GroupRenderer.class); - rendererMap.put(ConfigRenderer.class.getName(), ConfigRenderer.class); - rendererMap.put("javax.faces.Link", com.sun.faces.renderkit.html_basic.CommandLinkRenderer.class); - rendererMap.put("javax.faces.Image", com.sun.faces.renderkit.html_basic.ImageRenderer.class); - rendererMap.put("javax.faces.Grid", com.sun.faces.renderkit.html_basic.GridRenderer.class); - - } - Class c = rendererMap.get(rendererType); - if (c == null) { - System.out.println("MockRenderKit request for unsupported type " + rendererType); - } - return (Renderer) c.newInstance(); - - } catch (Exception e) { - throw new RuntimeException(e); - } - - } - - @Override - public ResponseStateManager getResponseStateManager() { - throw new RuntimeException("Function not implemented"); - - } - -} diff --git a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockRenderKitFactory.java b/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockRenderKitFactory.java deleted file mode 100644 index 760e703..0000000 --- a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockRenderKitFactory.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.rhq.core.gui.configuration; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -import javax.faces.context.FacesContext; -import javax.faces.render.RenderKit; -import javax.faces.render.RenderKitFactory; - -public class MockRenderKitFactory extends RenderKitFactory { - - Map<String, RenderKit> kits = new HashMap<String, RenderKit>(); - - @Override - public void addRenderKit(String renderKitId, RenderKit renderKit) { - kits.put(renderKitId, renderKit); - } - - @Override - public RenderKit getRenderKit(FacesContext context, String renderKitId) { - return kits.get(renderKitId); - - } - - @Override - public Iterator<String> getRenderKitIds() { - return kits.keySet().iterator(); - } - -} diff --git a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockResponseWriter.java b/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockResponseWriter.java deleted file mode 100644 index 85247fb..0000000 --- a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockResponseWriter.java +++ /dev/null @@ -1,99 +0,0 @@ -package org.rhq.core.gui.configuration; - -import java.io.IOException; -import java.io.StringWriter; -import java.io.Writer; - -import javax.faces.component.UIComponent; -import javax.faces.context.ResponseWriter; - -public class MockResponseWriter extends ResponseWriter { - - public StringWriter stringWriter = new StringWriter(); - - @Override - public ResponseWriter cloneWithWriter(Writer writer) { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public void endDocument() throws IOException { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public void endElement(String name) throws IOException { - stringWriter.write("end element:" + name + "\n"); - - } - - @Override - public void flush() throws IOException { - - stringWriter.flush(); - - } - - @Override - public String getCharacterEncoding() { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public String getContentType() { - return "contenttype:"; - } - - @Override - public void startDocument() throws IOException { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public void startElement(String name, UIComponent component) throws IOException { - stringWriter.write("startElement: " + name + ": component:" - + (component != null ? component.getId() : "componenet is null") + "\n"); - } - - @Override - public void writeAttribute(String name, Object value, String property) throws IOException { - stringWriter.write("attribute:" + name + " value = " + value.toString() + " property = " + property + "\n"); - - } - - @Override - public void writeComment(Object comment) throws IOException { - stringWriter.write("comment:" + comment + "\n"); - - } - - @Override - public void writeText(Object text, String property) throws IOException { - stringWriter.write("text:" + text + ":" + property + "\n"); - } - - @Override - public void writeText(char[] text, int off, int len) throws IOException { - write(text, off, len); - } - - @Override - public void writeURIAttribute(String name, Object value, String property) throws IOException { - stringWriter.write("attributename:" + name + ", value:" + value.toString() + ", property:" + property); - } - - @Override - public void close() throws IOException { - //stringWriter.close(); - } - - @Override - public void write(char[] cbuf, int off, int len) throws IOException { - stringWriter.write(cbuf, off, len); - } - -} diff --git a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockServletContext.java b/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockServletContext.java deleted file mode 100644 index f604d00..0000000 --- a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockServletContext.java +++ /dev/null @@ -1,166 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2009 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -package org.rhq.core.gui.configuration; - -import java.io.InputStream; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; -import java.util.Set; - -import javax.servlet.RequestDispatcher; -import javax.servlet.Servlet; -import javax.servlet.ServletContext; -import javax.servlet.ServletException; - -import com.sun.faces.config.WebConfiguration; -final class MockServletContext implements ServletContext { - public void setAttribute(String arg0, Object arg1) { - this.attributeMap.put(arg0, arg1); - - } - - public void removeAttribute(String arg0) { - attributeMap.remove(arg0); - - } - - public void log(String arg0, Throwable arg1) { - throw new RuntimeException("Function not implemented"); - - } - - public void log(Exception arg0, String arg1) { - throw new RuntimeException("Function not implemented"); - - } - - public void log(String arg0) { - throw new RuntimeException("Function not implemented"); - - } - - public Enumeration getServlets() { - throw new RuntimeException("Function not implemented"); - - } - - public Enumeration getServletNames() { - throw new RuntimeException("Function not implemented"); - - } - - public String getServletContextName() { - return MockServletContext.class.getSimpleName(); - - } - - public Servlet getServlet(String arg0) throws ServletException { - throw new RuntimeException("Function not implemented"); - - } - - public String getServerInfo() { - throw new RuntimeException("Function not implemented"); - - } - - public Set getResourcePaths(String arg0) { - throw new RuntimeException("Function not implemented"); - - } - - public InputStream getResourceAsStream(String arg0) { - throw new RuntimeException("Function not implemented"); - - } - - public URL getResource(String arg0) throws MalformedURLException { - throw new RuntimeException("Function not implemented"); - - } - - public RequestDispatcher getRequestDispatcher(String arg0) { - throw new RuntimeException("Function not implemented"); - - } - - public String getRealPath(String arg0) { - throw new RuntimeException("Function not implemented"); - - } - - public RequestDispatcher getNamedDispatcher(String arg0) { - throw new RuntimeException("Function not implemented"); - - } - - public int getMinorVersion() { - return 4; - } - - public String getMimeType(String arg0) { - throw new RuntimeException("Function not implemented"); - - } - - public int getMajorVersion() { - return 2; - - } - - Properties initParams = new Properties(); - - public Enumeration getInitParameterNames() { - return initParams.elements(); - - } - - public String getInitParameter(String key) { - return initParams.getProperty(key); - - } - - public ServletContext getContext(String arg0) { - throw new RuntimeException("Function not implemented"); - - } - - public Enumeration getAttributeNames() { - throw new RuntimeException("Function not implemented"); - - } - - Map<String, Object> attributeMap; - - public Object getAttribute(String key) { - if (null == attributeMap) { - attributeMap = new HashMap<String, Object>(); - WebConfiguration wc = WebConfiguration.getInstance(this); - - attributeMap.put("com.sun.faces.config.WebConfiguration", wc); - } - - return attributeMap.get(key); - } -} \ No newline at end of file diff --git a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockValueExpression.java b/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockValueExpression.java deleted file mode 100644 index cb3dc63..0000000 --- a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockValueExpression.java +++ /dev/null @@ -1,71 +0,0 @@ -package org.rhq.core.gui.configuration; - -import javax.el.ELContext; -import javax.el.ValueExpression; - -public class MockValueExpression extends ValueExpression { - - /** - * - */ - private static final long serialVersionUID = 1L; - - public MockValueExpression(Object value) { - this.value = value; - } - - public Object value; - - public boolean literalText = false; - - @Override - public boolean equals(Object arg0) { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public Class<?> getExpectedType() { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public String getExpressionString() { - return "#{" + value.getClass().getSimpleName() + "}"; - } - - @Override - public Class<?> getType(ELContext arg0) { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public Object getValue(ELContext arg0) { - return value; - } - - @Override - public int hashCode() { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public boolean isLiteralText() { - return literalText; - } - - @Override - public boolean isReadOnly(ELContext arg0) { - throw new RuntimeException("Function not implemented"); - - } - - @Override - public void setValue(ELContext arg0, Object arg1) { - this.value = arg1; - } - -} diff --git a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockViewHandler.java b/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockViewHandler.java deleted file mode 100644 index 0074169..0000000 --- a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockViewHandler.java +++ /dev/null @@ -1,53 +0,0 @@ -package org.rhq.core.gui.configuration; - -import java.io.IOException; -import java.util.Locale; - -import javax.faces.FacesException; -import javax.faces.application.ViewHandler; -import javax.faces.component.UIViewRoot; -import javax.faces.context.FacesContext; - -public class MockViewHandler extends ViewHandler { - - @Override - public Locale calculateLocale(FacesContext context) { - throw new RuntimeException("Function not implemented"); - } - - @Override - public String calculateRenderKitId(FacesContext context) { - throw new RuntimeException("Function not implemented"); - } - - @Override - public UIViewRoot createView(FacesContext context, String viewId) { - throw new RuntimeException("Function not implemented"); - } - - @Override - public String getActionURL(FacesContext context, String viewId) { - throw new RuntimeException("Function not implemented"); - } - - @Override - public String getResourceURL(FacesContext context, String path) { - return "uri://" + path; - } - - @Override - public void renderView(FacesContext context, UIViewRoot viewToRender) throws IOException, FacesException { - throw new RuntimeException("Function not implemented"); - } - - @Override - public UIViewRoot restoreView(FacesContext context, String viewId) { - throw new RuntimeException("Function not implemented"); - } - - @Override - public void writeState(FacesContext context) throws IOException { - throw new RuntimeException("Function not implemented"); - } - -} diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java index 2f11e11..3189d79 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java @@ -51,20 +51,16 @@ import org.rhq.enterprise.server.util.LookupUtil; /** * @author Ian Springer */ +//@ Name(value = "ExistingResourceConfigurationUIBean") +//@ Scope(ScopeType.PAGE) public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUIBean { public static final String MANAGED_BEAN_NAME = "ExistingResourceConfigurationUIBean";
- private String selectedPath; - private TreeMap<String, RawConfiguration> raws; - private TreeMap<String, RawConfiguration> modified = new TreeMap<String, RawConfiguration>(); - private RawConfiguration current = null; - // =========== actions ===========
public ExistingResourceConfigurationUIBean() { removeSessionScopedBeanIfInView("/rhq/resource/configuration/view.xhtml", ExistingResourceConfigurationUIBean.class); - }
public String editConfiguration() { @@ -85,9 +81,6 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI }
public String updateConfiguration() { - - modified = null; - return updateConfiguration(true);
} @@ -101,9 +94,9 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI ConfigurationMaskingUtility.unmaskConfiguration(getConfiguration(), getConfigurationDefinition()); int resourceId = EnterpriseFacesContextUtility.getResource().getId();
- AbstractResourceConfigurationUpdate updateRequest = this.configurationManager - .updateStructuredOrRawConfiguration(EnterpriseFacesContextUtility.getSubject(), resourceId, - getMergedConfiguration(), fromStructured); + AbstractResourceConfigurationUpdate updateRequest = + this.configurationManager.updateStructuredOrRawConfiguration(EnterpriseFacesContextUtility.getSubject(), + resourceId, getMergedConfiguration(), fromStructured); if (updateRequest != null) { switch (updateRequest.getStatus()) { case SUCCESS: @@ -190,6 +183,9 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI private Configuration getMergedConfiguration() { for (RawConfiguration raw : getModified().values()) { getRaws().put(raw.getPath(), raw); + log.error("Just merged in raw path =[" + raw.getPath() + "]"); + log.error(" file =[" + new String(raw.getContents()) + "]"); + } getConfiguration().getRawConfigurations().clear(); getConfiguration().getRawConfigurations().addAll(getRaws().values()); @@ -203,6 +199,7 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
public void fileUploadListener(UploadEvent event) throws Exception { File uploadFile; + log.error("fileUploadListener called"); uploadFile = event.getUploadItem().getFile(); if (uploadFile != null) { log.debug("fileUploadListener got file named " + event.getUploadItem().getFileName()); @@ -227,6 +224,27 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI return getConfiguration().getId(); }
+ /* + public Configuration getConfiguration() { + if (null == configuration) { + + Subject subject = EnterpriseFacesContextUtility.getSubject(); + int resourceId = EnterpriseFacesContextUtility.getResource().getId(); + AbstractResourceConfigurationUpdate configurationUpdate = LookupUtil.getConfigurationManager() + .getLatestResourceConfigurationUpdate(subject, resourceId); + Configuration configuration = (configurationUpdate != null) ? configurationUpdate.getConfiguration() : null; + if (configuration != null) { + //ConfigurationMaskingUtility.maskConfiguration(configuration, getConfigurationDefinition()); + } + + return configuration; + + } + return configuration; + + } + */ + private ConfigurationFormat getConfigurationFormat() { return getConfigurationDefinition().getConfigurationFormat(); } @@ -315,10 +333,10 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
public void setCurrentContents(String updated) {
- String original = getCurrent().getContentString(); + String original = new String(getCurrent().getContents()); if (!updated.equals(original)) { current = current.deepCopy(false); - current.setContentString(updated); + current.setContents(updated.getBytes()); //TODO update other values like MD5 getModified().put(current.getPath(), current); } @@ -340,6 +358,14 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
/** * This is a no-op, since the upload work was done by upload file + * But is kept as a target for the "save" icon from the full screen page + */ + public String update() { + return "/rhq/resource/configuration/edit-raw.xhtml?currentResourceId=" + getResourceId(); + } + + /** + * This is a no-op, since the upload work was done by upload file * But is kept as a target for the "action" value */ public String upload() { @@ -347,8 +373,12 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI }
public String switchToraw() { + log.error("switch2raw called"); + dumpProperties(getConfiguration(), log); Configuration configuration = LookupUtil.getConfigurationManager().translateResourceConfiguration( EnterpriseFacesContextUtility.getSubject(), getResourceId(), getMergedConfiguration(), true); + log.error("switch2raw post merge"); + dumpProperties(getConfiguration(), log);
setConfiguration(configuration); for (RawConfiguration raw : configuration.getRawConfigurations()) { @@ -360,10 +390,21 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI return "/rhq/resource/configuration/edit-raw.xhtml?currentResourceId=" + getResourceId(); }
+ void dumpProperties(Configuration conf, Log log) { + for (String key : conf.getAllProperties().keySet()) { + log.error("property=" + conf.getAllProperties().get(key)); + } + } + public String switchTostructured() { + log.error("switch2structured called");
+ dumpProperties(getConfiguration(), log); Configuration configuration = LookupUtil.getConfigurationManager().translateResourceConfiguration( EnterpriseFacesContextUtility.getSubject(), getResourceId(), getMergedConfiguration(), false); + log.error("switch2structured post merge"); + + dumpProperties(configuration, log);
for (Property property : configuration.getAllProperties().values()) { property.setConfiguration(configuration); @@ -402,4 +443,12 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI return raws; }
+ /** + * + */ + String selectedPath; + private TreeMap<String, RawConfiguration> raws; + TreeMap<String, RawConfiguration> modified = new TreeMap<String, RawConfiguration>(); + RawConfiguration current = null; + } diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/configuration-navigation.xml b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/configuration-navigation.xml index b6767e4..bd0f1bf 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/configuration-navigation.xml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/configuration-navigation.xml @@ -6,6 +6,7 @@
<navigation-rule>
+ <navigation-case> <from-action>#{ExistingResourceConfigurationUIBean.editConfiguration}</from-action> <to-view-id>/rhq/resource/configuration/edit.xhtml?id=#{param.id}</to-view-id> @@ -31,6 +32,13 @@
</navigation-rule>
+ <navigation-rule> + <from-view-id>/rhq/resource/configuration/edit-raw-full.xhtml</from-view-id> + <navigation-case> + <from-action> #{RawConfigCollection.update}</from-action> + <to-view-id>/rhq/resource/configuration/edit-raw.xhtml?id=#{param.id}</to-view-id> + </navigation-case> + </navigation-rule>
<navigation-rule>
@@ -42,7 +50,8 @@ <to-view-id>/rhq/resource/configuration/history.xhtml?id=#{param.id}</to-view-id> <redirect/> </navigation-case> - + + </navigation-rule>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/images/edit.png b/modules/enterprise/gui/portal-war/src/main/webapp/images/edit.png deleted file mode 100644 index b1c3c61..0000000 Binary files a/modules/enterprise/gui/portal-war/src/main/webapp/images/edit.png and /dev/null differ diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/images/raw.png b/modules/enterprise/gui/portal-war/src/main/webapp/images/raw.png deleted file mode 100644 index 9ccae0e..0000000 Binary files a/modules/enterprise/gui/portal-war/src/main/webapp/images/raw.png and /dev/null differ diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/images/structured.png b/modules/enterprise/gui/portal-war/src/main/webapp/images/structured.png deleted file mode 100644 index 94fcf83..0000000 Binary files a/modules/enterprise/gui/portal-war/src/main/webapp/images/structured.png and /dev/null differ diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml index a85f409..d067d8a 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml @@ -22,12 +22,6 @@ THIS TEXT WILL BE REMOVED. <ui:param name="selectedTabName" value="Configuration.Current"/>
<ui:define name="content"> - <style type="text/css"> - td.raw-config-table { - vertical-align: top; - valign: top; - } - </style>
<h:form id="editResourceConfigurationForm" onsubmit="prepareInputsForSubmission(this)" rendered="#{!ViewResourceConfigurationUIBean.updateInProgress}">
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml index d0cfa5c..72da244 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml @@ -24,40 +24,47 @@ THIS TEXT WILL BE REMOVED.
<ui:define name="content">
- -<style type="text/css"> - td.raw-config-table { - vertical-align: top; - valign: top; - } - config-toolbar{ - float: right; - } -</style> - - <h:panelGroup layout="block" styleClass="InfoBlock" rendered="#{ExistingResourceConfigurationUIBean.updateInProgress}"> <b>${msg['note']}</b> ${msg['resource.config.Current.updateInProgress']} </h:panelGroup>
+ <h:outputText value="#{messages.youareviewingstructured}" /> + <h:panelGroup rendered="#{ExistingResourceConfigurationUIBean.rawSupported}" > + <h:outputText value=" #{messages.switch2}" /> + <h:outputLink value="view-raw.xhtml"> + <f:param name="id" value="#{ResourceUIBean.id}" /> + <h:outputText value=" #{messages.raw}" /> + </h:outputLink> + </h:panelGroup>
<h:outputText value=" #{messages.nopermissionedit}" rendered="#{!ResourceUIBean.permissions.configure}"/>
<h:form id="viewResourceConfigurationForm"> <!-- TODO remove the id version --> <input type="hidden" name="id" value="#{ResourceUIBean.id}"/> + + <h:panelGrid columns="2" styleClass="buttons-table" columnClasses="button-cell" + rendered="#{ExistingResourceConfigurationViewUIBean.configuration != null and !ExistingResourceConfigurationViewUIBean.updateInProgress}"> + + <h:commandButton value="#{messages.editstructured}" action="#{ExistingResourceConfigurationViewUIBean.editConfiguration}" + title="Edit this Configuration" styleClass="buttonmed" + rendered="${ResourceUIBean.permissions.configure and ExistingResourceConfigurationViewUIBean.structuredSupported and !ExistingResourceConfigurationViewUIBean.updateInProgress}" /> + <h:commandButton value="#{messages.editraw}" action="#{ExistingResourceConfigurationUIBean.editRawConfiguration}" + title="Advanced Mode Edit of Raw Configuration Files" styleClass="buttonmed" + rendered="${ResourceUIBean.permissions.configure and ExistingResourceConfigurationViewUIBean.rawSupported and !ExistingResourceConfigurationViewUIBean.updateInProgress}" /> + </h:panelGrid>
- <onc:config configurationDefinition="#{ExistingResourceConfigurationUIBean.configurationDefinition}" - configuration="#{ExistingResourceConfigurationUIBean.configuration}" - accessMapActionExpression="#{ExistingResourceConfigurationUIBean.accessMap}" - nullConfigurationDefinitionMessage="#{ExistingResourceConfigurationUIBean.nullConfigurationDefinitionMessage}" - nullConfigurationMessage="#{ExistingResourceConfigurationUIBean.nullConfigurationMessage}" + <onc:config configurationDefinition="#{ExistingResourceConfigurationViewUIBean.configurationDefinition}" + configuration="#{ExistingResourceConfigurationViewUIBean.configuration}" + accessMapActionExpression="#{ExistingResourceConfigurationViewUIBean.accessMap}" + readOnly="true" + nullConfigurationDefinitionMessage="#{ExistingResourceConfigurationViewUIBean.nullConfigurationDefinitionMessage}" + nullConfigurationMessage="#{ExistingResourceConfigurationViewUIBean.nullConfigurationMessage}" prevalidate="true"/> - <input type="hidden" name="id" value="#{ResourceUIBean.id}"/>
</h:form>
- <h:panelGroup layout="block" styleClass="InfoBlock" rendered="#{ExistingResourceConfigurationUIBean.updateInProgress}"> + <h:panelGroup layout="block" styleClass="InfoBlock" rendered="#{ExistingResourceConfigurationViewUIBean.updateInProgress}"> <b>${msg['note']}</b> ${msg['resource.config.Current.updateInProgress']} </h:panelGroup>
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java index 8703ae0..88858cf 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java @@ -287,7 +287,7 @@ public class WebservicesManagerBean implements WebservicesRemote { return repoManager.findPackageVersionsInRepoByCriteria(subject, criteria); }
- //@Override + @Override public int synchronizeRepos(Subject subject, Integer[] repoIds) { return repoManager.synchronizeRepos(subject, repoIds); } @@ -372,8 +372,8 @@ public class WebservicesManagerBean implements WebservicesRemote { }
public ResourceConfigurationUpdate updateStructuredOrRawConfiguration(Subject subject, int resourceId, - Configuration newConfiguration, boolean fromStructured) throws ResourceNotFoundException, - ConfigurationUpdateStillInProgressException { + Configuration newConfiguration, boolean fromStructured) + throws ResourceNotFoundException, ConfigurationUpdateStillInProgressException { return configurationManager.updateStructuredOrRawConfiguration(subject, resourceId, newConfiguration, fromStructured); } diff --git a/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/xmlrpc/ApacheXmlRpcExecutor.java b/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/xmlrpc/ApacheXmlRpcExecutor.java index 004608a..f3c75e2 100644 --- a/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/xmlrpc/ApacheXmlRpcExecutor.java +++ b/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/xmlrpc/ApacheXmlRpcExecutor.java @@ -32,10 +32,12 @@ public class ApacheXmlRpcExecutor implements XmlRpcExecutor { this.client = clientIn; }
+ @Override public Object execute(String methodName, Object[] params) throws XmlRpcException { return client.execute(methodName, params); }
+ @Override public Object execute(String pMethodName, List pParams) throws XmlRpcException { return client.execute(pMethodName, pParams); } diff --git a/modules/enterprise/server/plugins/rhnhosted/src/test/java/org/rhq/enterprise/server/plugins/rhnhosted/xmlrpc/MockRhnXmlRpcExecutor.java b/modules/enterprise/server/plugins/rhnhosted/src/test/java/org/rhq/enterprise/server/plugins/rhnhosted/xmlrpc/MockRhnXmlRpcExecutor.java index 9a033d5..bcdfe41 100644 --- a/modules/enterprise/server/plugins/rhnhosted/src/test/java/org/rhq/enterprise/server/plugins/rhnhosted/xmlrpc/MockRhnXmlRpcExecutor.java +++ b/modules/enterprise/server/plugins/rhnhosted/src/test/java/org/rhq/enterprise/server/plugins/rhnhosted/xmlrpc/MockRhnXmlRpcExecutor.java @@ -70,7 +70,7 @@ public class MockRhnXmlRpcExecutor implements XmlRpcExecutor { /* (non-Javadoc) * @see org.rhq.enterprise.server.plugins.rhnhosted.xmlrpc.XmlRpcExecutor#execute(java.lang.String, java.lang.Object[]) */ - //@Override + @Override public Object execute(String methodName, Object[] params) throws XmlRpcException { //for (Object object : params) { // System.out.println("parm: " + object); @@ -242,7 +242,7 @@ public class MockRhnXmlRpcExecutor implements XmlRpcExecutor {
}
- //@Override + @Override public Object execute(String pMethodName, List pParams) throws XmlRpcException { return execute(pMethodName, pParams.toArray()); } diff --git a/modules/plugins/augeas/src/test/java/README b/modules/plugins/augeas/src/test/java/README deleted file mode 100644 index db73645..0000000 --- a/modules/plugins/augeas/src/test/java/README +++ /dev/null @@ -1 +0,0 @@ -Delete this file once there is source in this tree
commit e7727d0343e19d467e4e591cfa0205f9b8e8c2b3 Author: John Sanda john@localhost.localdomain Date: Fri Dec 18 14:24:54 2009 -0500
Revert " ability to turn off toolbar. Read only is set from render. replaced some String literals with symbolic constants."
This reverts commit 5d7c13ae3bbbdce1ebd05796fc7c6528537efe29.
diff --git a/.classpath b/.classpath index a3aef1e..27f5303 100644 --- a/.classpath +++ b/.classpath @@ -92,8 +92,8 @@ <classpathentry kind="src" path="modules/plugins/samba/src/test/java"/> <classpathentry kind="src" path="modules/plugins/sudoers/src/main/java"/> <classpathentry kind="src" path="modules/plugins/sudoers/src/test/java"/> - <classpathentry kind="src" path="modules/plugins/postfix/src/main/java"/> - <classpathentry kind="src" path="modules/plugins/postfix/src/test/java"/> + <classpathentry kind="src" path="modules/plugins/postfix/src/main/java"/> + <classpathentry kind="src" path="modules/plugins/postfix/src/test/java"/> <classpathentry kind="src" path="modules/plugins/cron/src/main/java"/> <classpathentry kind="src" path="modules/plugins/hudson/src/main/java"/> <classpathentry kind="src" path="modules/plugins/platform/src/test/java"/> @@ -165,8 +165,8 @@ <classpathentry exported="true" kind="var" path="M2_REPO/commons-lang/commons-lang/2.4/commons-lang-2.4.jar"/> <classpathentry exported="true" kind="var" path="M2_REPO/javax/faces/jsf-api/1.2_12/jsf-api-1.2_12.jar" sourcepath="/M2_REPO/javax/faces/jsf-api/1.2_12/jsf-api-1.2_12-sources.jar"/> <classpathentry exported="true" kind="var" path="M2_REPO/javax/faces/jsf-impl/1.2_12/jsf-impl-1.2_12.jar" sourcepath="/M2_REPO/javax/faces/jsf-impl/1.2_12/jsf-impl-1.2_12-sources.jar"/> - <classpathentry exported="true" kind="var" path="M2_REPO/javax/el/el-api/1.0/el-api-1.0.jar" sourcepath="/M2_REPO/javax/el/el-api/1.0/el-api-1.0-sources.jar"/> - <classpathentry exported="true" kind="var" path="M2_REPO/com/sun/facelets/jsf-facelets/1.1.14/jsf-facelets-1.1.14.jar" sourcepath="/M2_REPO/com/sun/facelets/jsf-facelets/1.1.14/jsf-facelets-1.1.14-sources.jar"/> + <classpathentry exported="true" kind="var" path="M2_REPO/javax/el/el-api/1.0/el-api-1.0.jar"/> + <classpathentry exported="true" kind="var" path="M2_REPO/com/sun/facelets/jsf-facelets/1.1.14/jsf-facelets-1.1.14.jar" sourcepath="/M2_REPO/com/sun/facelets/jsf-facelets/1.1.13/jsf-facelets-1.1.13-sources.jar"/> <classpathentry exported="true" kind="var" path="M2_REPO/mc4j/org-mc4j-ems/1.2.11/org-mc4j-ems-1.2.11.jar" sourcepath="/M2_REPO/mc4j/org-mc4j-ems/1.2.11/org-mc4j-ems-1.2.11-sources.jar"/> <classpathentry exported="true" kind="var" path="M2_REPO/org/opensymphony/quartz/quartz/1.6.5/quartz-1.6.5.jar" sourcepath="/M2_REPO/org/opensymphony/quartz/quartz/1.6.5/quartz-1.6.5-sources.jar"/> <classpathentry exported="true" kind="var" path="M2_REPO/javax/mail/mail/1.3.1/mail-1.3.1.jar"/> diff --git a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/AbstractConfigurationComponent.java b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/AbstractConfigurationComponent.java index e49ead1..2fe72ee 100644 --- a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/AbstractConfigurationComponent.java +++ b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/AbstractConfigurationComponent.java @@ -24,7 +24,6 @@ package org.rhq.core.gui.configuration;
import java.util.UUID;
-import javax.faces.component.UIComponent; import javax.faces.component.UIComponentBase; import javax.faces.context.FacesContext;
@@ -50,30 +49,18 @@ public abstract class AbstractConfigurationComponent extends UIComponentBase imp private static final String NULL_CONFIGURATION_STYLE_ATTRIBUTE = "nullConfigurationStyle"; private static final String LIST_NAME_ATTRIBUTE = "listName"; private static final String LIST_INDEX_ATTRIBUTE = "listIndex"; - public static final String READ_ONLY_ATTRIBUTE = "readOnly"; - public static final String SHOW_TOOLBAR_ATTRIBUTE = "readOnly"; + private static final String READ_ONLY_ATTRIBUTE = "readOnly"; private static final String FULLY_EDITABLE_ATTRIBUTE = "fullyEditable";
- private Boolean showToolbar; - private Boolean readOnly; + private Boolean readOnly = true; private Boolean fullyEditable; private String listName; private Integer listIndex; - - public UIComponent getToolbar() { - return toolbar; - } - - public void setToolbar(UIComponent toolbar) { - this.toolbar = toolbar; - } - private String nullConfigurationDefinitionMessage; private String nullConfigurationMessage; private String nullConfigurationStyle; private boolean prevalidate; private boolean isGroup; - private UIComponent toolbar;
public String getFamily() { return COMPONENT_FAMILY; @@ -106,21 +93,6 @@ public abstract class AbstractConfigurationComponent extends UIComponentBase imp this.readOnly = readOnly; }
- public Boolean getShowToolbar() { - if (this.showToolbar == null) { - this.showToolbar = FacesComponentUtility - .getExpressionAttribute(this, SHOW_TOOLBAR_ATTRIBUTE, Boolean.class); - } - if (this.showToolbar == null) { - this.showToolbar = false; - } - return showToolbar; - } - - public void setShowToolbar(Boolean showToolbar) { - this.showToolbar = showToolbar; - } - public boolean isFullyEditable() { if (this.fullyEditable == null) { this.fullyEditable = FacesComponentUtility.getExpressionAttribute(this, FULLY_EDITABLE_ATTRIBUTE, @@ -218,7 +190,7 @@ public abstract class AbstractConfigurationComponent extends UIComponentBase imp @Override public Object saveState(FacesContext facesContext) { if (this.stateValues == null) { - this.stateValues = new Object[8]; + this.stateValues = new Object[7]; }
this.stateValues[0] = super.saveState(facesContext); @@ -228,7 +200,6 @@ public abstract class AbstractConfigurationComponent extends UIComponentBase imp this.stateValues[4] = this.listIndex; this.stateValues[5] = this.prevalidate; this.stateValues[6] = this.isGroup; - this.stateValues[7] = this.getShowToolbar(); return this.stateValues; }
@@ -242,7 +213,6 @@ public abstract class AbstractConfigurationComponent extends UIComponentBase imp this.listIndex = (Integer) this.stateValues[4]; this.prevalidate = (Boolean) this.stateValues[5]; this.isGroup = (Boolean) this.stateValues[6]; - this.showToolbar = (Boolean) this.stateValues[7]; }
public boolean getShouldShowRaw() { diff --git a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/ConfigRenderer.java b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/ConfigRenderer.java index 278d619..e3f0c16 100644 --- a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/ConfigRenderer.java +++ b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/ConfigRenderer.java @@ -26,7 +26,6 @@ import java.io.IOException; import java.util.List; import java.util.Map;
-import javax.el.MethodExpression; import javax.el.ValueExpression; import javax.faces.application.FacesMessage; import javax.faces.component.UIComponent; @@ -123,12 +122,9 @@ public class ConfigRenderer extends Renderer { } }
- String readOnly = FacesContextUtility.getOptionalRequestParameter("readOnly"); - if (null != readOnly) { - configurationComponent.setReadOnly(Boolean.valueOf(readOnly)); - } - + Boolean readOnly = Boolean.valueOf(FacesContextUtility.getOptionalRequestParameter("readOnly")); Boolean save = Boolean.valueOf(FacesContextUtility.getOptionalRequestParameter("save")); + configurationComponent.setReadOnly(readOnly);
if (component.getChildCount() == 0) addChildComponents(configurationComponent); @@ -182,9 +178,6 @@ public class ConfigRenderer extends Renderer { // Only create the child components the first time around (i.e. once per JSF lifecycle). if (component.getChildCount() == 0) addChildComponents(configurationComponent); - if (configurationComponent.getToolbar() != null) { - configurationComponent.getToolbar().setRendered(configurationComponent.getShowToolbar()); - } }
private boolean isAjaxRefresh(AbstractConfigurationComponent configurationComponent) { @@ -282,39 +275,29 @@ public class ConfigRenderer extends Renderer { }
private void addStructuredConfig(AbstractConfigurationComponent configurationComponent) { - { - UIPanel toolbarPanel = FacesComponentUtility.addBlockPanel(configurationComponent, configurationComponent, - "summary-props-table"); - if (configurationComponent.isReadOnly()) { - HtmlOutputLink editLink = FacesComponentUtility.addOutputLink(toolbarPanel, configurationComponent, - "edit.xhtml"); - FacesComponentUtility.addGraphicImage(editLink, configurationComponent, "/images/edit.png", "Edit"); - FacesComponentUtility.addOutputText(editLink, configurationComponent, "Edit", ""); - FacesComponentUtility.addParameter(editLink, configurationComponent, "readOnly", Boolean - .toString(false)); - FacesComponentUtility.addParameter(editLink, configurationComponent, "id", FacesContextUtility - .getRequiredRequestParameter("id")); - } else { - HtmlCommandLink saveLink = FacesComponentUtility.addCommandLink(toolbarPanel, configurationComponent); - FacesComponentUtility.addGraphicImage(saveLink, configurationComponent, "/images/save.png", "Save"); - FacesComponentUtility.addOutputText(saveLink, configurationComponent, "Save", ""); - FacesComponentUtility.addParameter(saveLink, configurationComponent, "save", Boolean.toString(true)); - FacesComponentUtility - .addParameter(saveLink, configurationComponent, "readOnly", Boolean.toString(true)); - - saveLink.setActionExpression(getSaveActionExpression()); + UIPanel toolbarPanel = FacesComponentUtility.addBlockPanel(configurationComponent, configurationComponent, + "summary-props-table"); + if (configurationComponent.isReadOnly()) { + HtmlCommandLink editLink = FacesComponentUtility.addCommandLink(toolbarPanel, configurationComponent); + FacesComponentUtility.addGraphicImage(editLink, configurationComponent, "/images/edit.png", "Edit"); + FacesComponentUtility.addOutputText(editLink, configurationComponent, "Edit", ""); + FacesComponentUtility.addParameter(editLink, configurationComponent, "readOnly", Boolean.toString(false));
- } - if (configurationComponent.getConfigurationDefinition().getConfigurationFormat().isRawSupported()) { - HtmlCommandLink toRawLink = FacesComponentUtility.addCommandLink(toolbarPanel, configurationComponent); - FacesComponentUtility.addGraphicImage(toRawLink, configurationComponent, "/images/raw.png", "showRaw"); - FacesComponentUtility.addOutputText(toRawLink, configurationComponent, "showRaw", ""); - FacesComponentUtility.addParameter(toRawLink, configurationComponent, "showRaw", Boolean.TRUE - .toString()); - FacesComponentUtility.addParameter(toRawLink, configurationComponent, "readOnly", Boolean - .toString(configurationComponent.isReadOnly())); - } - configurationComponent.setToolbar(toolbarPanel); + } else { + HtmlCommandLink saveLink = FacesComponentUtility.addCommandLink(toolbarPanel, configurationComponent); + FacesComponentUtility.addGraphicImage(saveLink, configurationComponent, "/images/save.png", "Save"); + FacesComponentUtility.addOutputText(saveLink, configurationComponent, "Save", ""); + FacesComponentUtility.addParameter(saveLink, configurationComponent, "save", Boolean.toString(true)); + FacesComponentUtility.addParameter(saveLink, configurationComponent, "readOnly", Boolean.toString(true)); + } + + if (configurationComponent.getConfigurationDefinition().getConfigurationFormat().isRawSupported()) { + HtmlCommandLink toRawLink = FacesComponentUtility.addCommandLink(toolbarPanel, configurationComponent); + FacesComponentUtility.addGraphicImage(toRawLink, configurationComponent, "/images/raw.png", "showRaw"); + FacesComponentUtility.addOutputText(toRawLink, configurationComponent, "showRaw", ""); + FacesComponentUtility.addParameter(toRawLink, configurationComponent, "showRaw", Boolean.TRUE.toString()); + FacesComponentUtility.addParameter(toRawLink, configurationComponent, "readOnly", Boolean + .toString(configurationComponent.isReadOnly())); }
if (!configurationComponent.isReadOnly()) @@ -336,13 +319,6 @@ public class ConfigRenderer extends Renderer { .isFullyEditable(), false); }
- private MethodExpression getSaveActionExpression() { - - MethodExpression actionExpression = null; - - return actionExpression; - } - private void addStructuredRawToggle(AbstractConfigurationComponent configurationComponent, boolean showRaw) { if (configurationComponent.getConfigurationDefinition().getConfigurationFormat().equals( ConfigurationFormat.STRUCTURED_AND_RAW)) { diff --git a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/RawConfigUIComponent.java b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/RawConfigUIComponent.java index 2c9a1be..ce42a54 100644 --- a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/RawConfigUIComponent.java +++ b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/RawConfigUIComponent.java @@ -138,8 +138,8 @@ public class RawConfigUIComponent extends UIComponentBase { FacesComponentUtility.addParameter(link, idFactory, "path", raw.getPath()); FacesComponentUtility.addParameter(link, idFactory, "whichRaw", Integer.toString(rawCount++)); FacesComponentUtility.addParameter(link, idFactory, "showRaw", Boolean.TRUE.toString()); - readOnlyParms.add(FacesComponentUtility.addParameter(link, idFactory, - AbstractConfigurationComponent.READ_ONLY_ATTRIBUTE, Boolean.toString(readOnly))); + readOnlyParms.add(FacesComponentUtility.addParameter(link, idFactory, "readOnly", Boolean + .toString(readOnly)));
}
@@ -155,32 +155,24 @@ public class RawConfigUIComponent extends UIComponentBase { inputTextarea.setReadonly(readOnly); }
- private HtmlOutputLink fullscreenLink; - private UIParameter fullScreenResourceIdParam; - private void addToolbar(ConfigurationDefinition configurationDefinition, UIPanel parent) { UIPanel toolbarPanel = FacesComponentUtility.addBlockPanel(parent, idFactory, "config-toolbar"); if (readOnly) { HtmlCommandLink editLink = FacesComponentUtility.addCommandLink(toolbarPanel, idFactory); FacesComponentUtility.addGraphicImage(editLink, idFactory, "/images/edit.png", "Edit"); FacesComponentUtility.addOutputText(editLink, idFactory, "Edit", ""); - FacesComponentUtility.addParameter(editLink, idFactory, "showRaw", Boolean.TRUE.toString()); - FacesComponentUtility.addParameter(editLink, idFactory, AbstractConfigurationComponent.READ_ONLY_ATTRIBUTE, - Boolean.FALSE.toString()); + FacesComponentUtility.addParameter(editLink, idFactory, "showStructured", Boolean.FALSE.toString()); } else { HtmlCommandLink saveLink = FacesComponentUtility.addCommandLink(toolbarPanel, idFactory); FacesComponentUtility.addGraphicImage(saveLink, idFactory, "/images/save.png", "Save"); FacesComponentUtility.addOutputText(saveLink, idFactory, "Save", ""); - FacesComponentUtility.addParameter(saveLink, idFactory, "showRaw", Boolean.FALSE.toString()); - FacesComponentUtility.addParameter(saveLink, idFactory, AbstractConfigurationComponent.READ_ONLY_ATTRIBUTE, - Boolean.TRUE.toString()); + FacesComponentUtility.addParameter(saveLink, idFactory, "showStructured", Boolean.FALSE.toString()); } { - fullscreenLink = FacesComponentUtility.addOutputLink(toolbarPanel, idFactory, "view-full.xhtml"); - FacesComponentUtility - .addGraphicImage(fullscreenLink, idFactory, "/images/viewfullscreen.png", "FullScreen"); - FacesComponentUtility.addOutputText(fullscreenLink, idFactory, "Full Screen", ""); - fullScreenResourceIdParam = FacesComponentUtility.addParameter(fullscreenLink, idFactory, "id", ""); + HtmlCommandLink saveCommandLink = FacesComponentUtility.addCommandLink(toolbarPanel, idFactory); + FacesComponentUtility.addGraphicImage(saveCommandLink, idFactory, "/images/viewfullscreen.png", + "FullScreen"); + FacesComponentUtility.addOutputText(saveCommandLink, idFactory, "Full Screen", ""); } if (!readOnly) { HtmlOutputLink uploadLink = FacesComponentUtility.addOutputLink(toolbarPanel, idFactory, "upload.xhtml"); @@ -208,23 +200,10 @@ public class RawConfigUIComponent extends UIComponentBase { public void encodeBegin(FacesContext context) throws IOException { // TODO Auto-generated method stub super.encodeBegin(context); - inputTextarea.setValue(rawMap.get(getSelectedPath()).getContentString()); for (UIParameter param : readOnlyParms) { param.setValue(Boolean.toString(readOnly)); }
- String resourceId = FacesContextUtility.getOptionalRequestParameter("id"); - - if (null == resourceId) { - if (fullscreenLink != null) { - fullscreenLink.setRendered(false); - } - } else { - if (fullScreenResourceIdParam != null) { - fullScreenResourceIdParam.setValue(resourceId); - } - } - } } diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml index dffd02b..a85f409 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml @@ -49,10 +49,7 @@ THIS TEXT WILL BE REMOVED. configuration="#{ExistingResourceConfigurationUIBean.configuration}" nullConfigurationDefinitionMessage="#{ExistingResourceConfigurationUIBean.nullConfigurationDefinitionMessage}" nullConfigurationMessage="#{ExistingResourceConfigurationUIBean.nullConfigurationMessage}" - prevalidate="true" - showToolbar="true" - readOnly="false" - /> + prevalidate="true"/>
<h:panelGrid columns="2" styleClass="buttons-table" columnClasses="button-cell" rendered="#{ExistingResourceConfigurationUIBean.configuration != null}"> <h:commandButton value="SAVE" action="#{ExistingResourceConfigurationUIBean.updateConfiguration}" diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view-full.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view-full.xhtml deleted file mode 100644 index 0491cf8..0000000 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view-full.xhtml +++ /dev/null @@ -1,48 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<html xmlns="http://www.w3.org/1999/xhtml" - xmlns:h="http://java.sun.com/jsf/html" - xmlns:f="http://java.sun.com/jsf/core" - xmlns:ui="http://java.sun.com/jsf/facelets" - xmlns:c="http://java.sun.com/jstl/core" - xmlns:onc="http://jboss.org/on/component" - xmlns:a4j="http://richfaces.org/a4j" - xmlns:rich="http://richfaces.ajax4jsf.org/rich" - xmlns:s="http://jboss.com/products/seam/taglib%22%3E - -<ui:composition template="/rhq/layout/main.xhtml"> -<ui:param name="pageTitle" value="TODO Internationalize this"/> - -<ui:define name="breadcrumbs" > -<h:outputLink value="view.xhtml" action="navigateToUpload" > - <h:outputText value=" Back " /> - <f:param name="id" value="#{ResourceUIBean.id}" /> -</h:outputLink> - -</ui:define> - -<ui:define name="body"> - -<h:form id="editResourceConfigurationForm" > -<input type="hidden" name="id" value="#{ResourceUIBean.id}" /> - - <onc:config configurationDefinition="#{ExistingResourceConfigurationUIBean.configurationDefinition}" - configuration="#{ExistingResourceConfigurationUIBean.configuration}" - accessMapActionExpression="#{ExistingResourceConfigurationUIBean.accessMap}" - nullConfigurationDefinitionMessage="#{ExistingResourceConfigurationUIBean.nullConfigurationDefinitionMessage}" - nullConfigurationMessage="#{ExistingResourceConfigurationUIBean.nullConfigurationMessage}" - readOnly="true" - showToolbar="true" - prevalidate="true" - showRaw="true" - fullscreen="true" /> - - -</h:form> -</ui:define> - -</ui:composition> - -</html> - - diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view-raw-full.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view-raw-full.xhtml new file mode 100644 index 0000000..e9e8c1a --- /dev/null +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view-raw-full.xhtml @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<html xmlns="http://www.w3.org/1999/xhtml" + xmlns:h="http://java.sun.com/jsf/html" + xmlns:f="http://java.sun.com/jsf/core" + xmlns:ui="http://java.sun.com/jsf/facelets" + xmlns:c="http://java.sun.com/jstl/core" + xmlns:onc="http://jboss.org/on/component" + xmlns:a4j="http://richfaces.org/a4j" + xmlns:rich="http://richfaces.ajax4jsf.org/rich" + xmlns:s="http://jboss.com/products/seam/taglib%22%3E + +<ui:composition template="/rhq/layout/main.xhtml"> +<ui:param name="pageTitle" value="TODO Internationalize this"/> + +<ui:define name="breadcrumbs" > +<h:outputLink value="view-raw.xhtml" action="navigateToUpload" > + <h:outputText value=" Back " /> + <f:param name="id" value="#{ResourceUIBean.id}" /> +</h:outputLink> + +</ui:define> + +<ui:define name="body"> + +<h:form id="editResourceConfigurationForm" > +<input type="hidden" name="id" value="#{ResourceUIBean.id}" /> +<div> +<pre><h:outputText value="#{ExistingResourceConfigurationUIBean.currentContents}" /></pre> +</div> +</h:form> +</ui:define> + +</ui:composition> + +</html> + + diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml index 40a917d..d0cfa5c 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml @@ -47,14 +47,12 @@ THIS TEXT WILL BE REMOVED. <!-- TODO remove the id version --> <input type="hidden" name="id" value="#{ResourceUIBean.id}"/>
- <onc:config configurationDefinition="#{ExistingResourceConfigurationViewUIBean.configurationDefinition}" - configuration="#{ExistingResourceConfigurationViewUIBean.configuration}" - accessMapActionExpression="#{ExistingResourceConfigurationViewUIBean.accessMap}" - nullConfigurationDefinitionMessage="#{ExistingResourceConfigurationViewUIBean.nullConfigurationDefinitionMessage}" - nullConfigurationMessage="#{ExistingResourceConfigurationViewUIBean.nullConfigurationMessage}" - readOnly="true" - showToolbar="true" - prevalidate="true"/> + <onc:config configurationDefinition="#{ExistingResourceConfigurationUIBean.configurationDefinition}" + configuration="#{ExistingResourceConfigurationUIBean.configuration}" + accessMapActionExpression="#{ExistingResourceConfigurationUIBean.accessMap}" + nullConfigurationDefinitionMessage="#{ExistingResourceConfigurationUIBean.nullConfigurationDefinitionMessage}" + nullConfigurationMessage="#{ExistingResourceConfigurationUIBean.nullConfigurationMessage}" + prevalidate="true"/> <input type="hidden" name="id" value="#{ResourceUIBean.id}"/>
</h:form>
commit 7a7504dc9e3f49340bc8418b36fdc18b537c8533 Author: John Sanda john@localhost.localdomain Date: Fri Dec 18 14:24:31 2009 -0500
Revert "Still broken. Major refactroing of the config renderer so that the structured config is contained inside a panel. Might have broken something not visible from the test. Still working on re-enabling the save."
This reverts commit 30d9312e87182ebcc711428585ba51da3c64f3c9.
diff --git a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/StructuredConfigUIComponent.java b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/StructuredConfigUIComponent.java deleted file mode 100644 index c7aa459..0000000 --- a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/StructuredConfigUIComponent.java +++ /dev/null @@ -1,146 +0,0 @@ -package org.rhq.core.gui.configuration; - -import java.util.List; - -import javax.faces.component.UIComponent; -import javax.faces.component.UIPanel; -import javax.faces.component.html.HtmlPanelGroup; - -import org.richfaces.component.html.HtmlSimpleTogglePanel; - -import org.rhq.core.domain.configuration.definition.PropertyGroupDefinition; -import org.rhq.core.gui.configuration.helper.PropertyRenderingUtility; -import org.rhq.core.gui.configuration.propset.ConfigurationSetComponent; -import org.rhq.core.gui.util.FacesComponentIdFactory; -import org.rhq.core.gui.util.FacesComponentUtility; - -public class StructuredConfigUIComponent extends UIPanel { - - FacesComponentIdFactory idFactory; - boolean isGroup; - - public StructuredConfigUIComponent(AbstractConfigurationComponent configurationComponent) { - super(); - this.idFactory = configurationComponent; - this.isGroup = configurationComponent.isGroup(); - if (!configurationComponent.isReadOnly()) - addRequiredNotationsKey(); - - if (configurationComponent.getListName() != null) { - if (configurationComponent.getListIndex() == null) { - // No index specified means we should add a new map to the list. - configurationComponent.setListIndex(ConfigRenderer.addNewMap(configurationComponent)); - } - // Update member Configurations if this is a group config. - updateGroupMemberConfigurations(configurationComponent); - addListMemberProperty(configurationComponent, configurationComponent.getListIndex()); - } else { - addNonGroupedProperties(configurationComponent); - addGroupedProperties(configurationComponent); - } - String id = ConfigRenderer.getInitInputsJavaScriptComponentId(configurationComponent); - PropertyRenderingUtility.addInitInputsJavaScript(this, id, configurationComponent.isFullyEditable(), false); - } - - public void addRequiredNotationsKey() { - ConfigRenderer.addDebug(this, true, ".addNotePanel()"); - HtmlPanelGroup footnotesPanel = FacesComponentUtility.addBlockPanel(this, idFactory, - ConfigRenderer.NOTE_PANEL_STYLE_CLASS); - FacesComponentUtility.addOutputText(footnotesPanel, idFactory, "*", - ConfigRenderer.REQUIRED_MARKER_TEXT_STYLE_CLASS); - FacesComponentUtility.addOutputText(footnotesPanel, idFactory, " denotes a required field.", - FacesComponentUtility.NO_STYLE_CLASS); - if (isGroup) { - HtmlPanelGroup overridePanel = FacesComponentUtility.addBlockPanel(this, idFactory, - ConfigRenderer.NOTE_PANEL_STYLE_CLASS); - FacesComponentUtility.addOutputText(overridePanel, idFactory, - "note: if override is not checked, that property will not be altered on any group members", - FacesComponentUtility.NO_STYLE_CLASS); - } - ConfigRenderer.addDebug(this, false, ".addNotePanel()"); - } - - @Override - public String getFamily() { - // TODO Auto-generated method stub - return "rhq"; - } - - private void addListMemberProperty(AbstractConfigurationComponent configurationComponent, Integer listIndex) { - HtmlPanelGroup propertiesPanel = FacesComponentUtility.addBlockPanel(this, idFactory, - ConfigRenderer.UNGROUPED_PROPERTIES_STYLE_CLASS); - propertiesPanel.getChildren() - .add( - new MapInListUIComponentTreeFactory(configurationComponent, configurationComponent.getListName(), - listIndex).createUIComponentTree(null)); - } - - private void updateGroupMemberConfigurations(AbstractConfigurationComponent configurationComponent) { - if (configurationComponent instanceof ConfigurationSetComponent) { - ConfigurationSetComponent configurationSetComponent = ((ConfigurationSetComponent) configurationComponent); - configurationSetComponent.getConfigurationSet().applyGroupConfiguration(); - } - } - - void addGroupedProperties(AbstractConfigurationComponent config) { - ConfigRenderer.addDebug(config, true, ".addGroupedProperties()"); - List<PropertyGroupDefinition> groups = config.getConfigurationDefinition().getGroupDefinitions(); - for (PropertyGroupDefinition group : groups) { - HtmlSimpleTogglePanel groupPanel = addGroupPanel(group); - AbstractPropertyBagUIComponentTreeFactory propertyListUIComponentTreeFactory = new GroupUIComponentTreeFactory( - config, group.getName()); - groupPanel.getChildren().add(propertyListUIComponentTreeFactory.createUIComponentTree(null)); - } - - ConfigRenderer.addDebug(config, false, ".addGroupedProperties()"); - } - - void addNonGroupedProperties(AbstractConfigurationComponent config) { - - ConfigRenderer.addDebug(this, true, ".addNonGroupedProperties()"); - HtmlPanelGroup propertiesPanel = FacesComponentUtility.addBlockPanel(this, idFactory, - ConfigRenderer.UNGROUPED_PROPERTIES_STYLE_CLASS); - AbstractPropertyBagUIComponentTreeFactory propertyListUIComponentTreeFactory = new GroupUIComponentTreeFactory( - config, GroupUIComponentTreeFactory.NO_GROUP); - - UIComponent createUIComponentTree = propertyListUIComponentTreeFactory.createUIComponentTree(null); - propertiesPanel.getChildren().add(createUIComponentTree); - - ConfigRenderer.addDebug(this, false, ".addNonGroupedProperties()"); - } - - HtmlSimpleTogglePanel addGroupPanel(PropertyGroupDefinition group) { - ConfigRenderer.addDebug(this, true, ".addGroupPanel()"); - HtmlSimpleTogglePanel groupPanel = FacesComponentUtility.addSimpleTogglePanel(this, idFactory, null); - // TODO: On AJAX requests, set "opened" attribute to its previous state. - groupPanel.setOpened(!group.isDefaultHidden()); - groupPanel.setHeaderClass(ConfigRenderer.PROPERTY_GROUP_HEADER_STYLE_CLASS); - groupPanel.setBodyClass(ConfigRenderer.PROPERTY_GROUP_BODY_STYLE_CLASS); - - // Custom header that includes the name and description - HtmlPanelGroup headerPanel = FacesComponentUtility.createBlockPanel(idFactory, null); - FacesComponentUtility.addOutputText(headerPanel, idFactory, group.getDisplayName(), null); - FacesComponentUtility.addOutputText(headerPanel, idFactory, group.getDescription(), - "group-description-text-panel"); - groupPanel.getFacets().put("header", headerPanel); - - // custom "close" widget - HtmlPanelGroup closePanel = FacesComponentUtility.createBlockPanel(idFactory, null); - closePanel.setStyle("text-align: right; font-weight: normal; font-size: 0.8em; whitespace: nowrap;"); - FacesComponentUtility - .addGraphicImage(closePanel, idFactory, "/images/ico_trigger_wht_collapse.gif", "collapse"); - FacesComponentUtility.addOutputText(closePanel, idFactory, " Collapse", null); - groupPanel.getFacets().put("closeMarker", closePanel); - - // custom "open" widget - HtmlPanelGroup openPanel = FacesComponentUtility.createBlockPanel(idFactory, null); - openPanel.setStyle("text-align: right; font-weight: normal; font-size: 0.8em; whitespace: nowrap;"); - FacesComponentUtility.addGraphicImage(openPanel, idFactory, "/images/ico_trigger_wht_expand.gif", "expand"); - FacesComponentUtility.addOutputText(openPanel, idFactory, " Expand", null); - groupPanel.getFacets().put("openMarker", openPanel); - ConfigRenderer.addDebug(this, true, ".addGroupPanel()"); - - return groupPanel; - } - -} diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/test/RawTestConfigurationUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/test/RawTestConfigurationUIBean.java deleted file mode 100644 index 919a4ad..0000000 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/test/RawTestConfigurationUIBean.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package org.rhq.enterprise.gui.configuration.test; - -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; - -import javax.faces.application.FacesMessage; - -import org.rhq.core.domain.configuration.Configuration; -import org.rhq.core.domain.configuration.Property; -import org.rhq.core.domain.configuration.PropertySimple; -import org.rhq.core.domain.configuration.RawConfiguration; -import org.rhq.core.domain.configuration.definition.ConfigurationFormat; -import org.rhq.core.gui.configuration.propset.ConfigurationSet; -import org.rhq.core.gui.configuration.propset.ConfigurationSetMember; -import org.rhq.core.gui.util.FacesContextUtility; -import org.rhq.enterprise.gui.common.Outcomes; - -/** - * @author Ian Springer - */ -public class RawTestConfigurationUIBean extends AbstractTestConfigurationUIBean { - public RawTestConfigurationUIBean() { - setConfigurationDefinition(TestConfigurationFactory.createConfigurationDefinition()); - setConfiguration(TestConfigurationFactory.createConfiguration()); - List<ConfigurationSetMember> members = new ArrayList(GROUP_SIZE); - for (int i = 0; i < GROUP_SIZE; i++) { - Configuration configuration = getConfiguration().deepCopy(true); - configuration.setId(i + 1); - configuration.getSimple("String1").setStringValue(UUID.randomUUID().toString()); - configuration.getSimple("Integer").setStringValue(String.valueOf(i + 1)); - configuration.getSimple("Boolean").setStringValue(String.valueOf(i % 2 == 0)); - if (i == 0) - configuration.getMap("OpenMapOfSimples").put(new PropertySimple("PROCESSOR_CORES", "4")); - ConfigurationSetMember memberInfo = new ConfigurationSetMember(LABELS[GROUP_SIZE % LABELS.length], - configuration); - members.add(memberInfo); - } - setConfigurationSet(new ConfigurationSet(getConfigurationDefinition(), members)); - // Unwrap the Hibernate proxy objects, which Facelets appears not to be able to handle. - setProperties(new ArrayList<Property>(this.getConfiguration().getProperties())); - - getConfigurationDefinition().setConfigurationFormat(ConfigurationFormat.STRUCTURED_AND_RAW); - - RawConfiguration rawConfiguration = new RawConfiguration(); - rawConfiguration.setPath("/tmp/nowhere.txt"); - rawConfiguration.setContents("A=1".getBytes()); - getConfiguration().addRawConfiguration(rawConfiguration); - - } - - public static final String MANAGED_BEAN_NAME = RawTestConfigurationUIBean.class.getSimpleName(); - protected static final String SUCCESS_OUTCOME = "success"; - protected static final String FAILURE_OUTCOME = "failure"; - - public String updateConfiguration() { - // Any values changed in the group config (i.e. via the inputs on the main page) need to be - // applied to all member configs before persisting them. - //getConfigurationSet().applyGroupConfiguration(); - // TODO (low priority): Persist the test config somewhere. - FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO, "Configuration updated."); - return Outcomes.SUCCESS; - } -} \ No newline at end of file diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/edit.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/edit.xhtml deleted file mode 100644 index 1e4c156..0000000 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/edit.xhtml +++ /dev/null @@ -1,51 +0,0 @@ -<?xml version="1.0"?> - -<!DOCTYPE html - PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> - -<html xmlns="http://www.w3.org/1999/xhtml" - xmlns:h="http://java.sun.com/jsf/html" - xmlns:f="http://java.sun.com/jsf/core" - xmlns:ui="http://java.sun.com/jsf/facelets" - xmlns:rich="http://richfaces.ajax4jsf.org/rich" - xmlns:onc="http://jboss.org/on/component%22%3E - -THIS TEXT WILL BE REMOVED. - -<ui:composition template="/rhq/layout/main.xhtml"> - - THIS TEXT WILL BE REMOVED AS WELL. - - <ui:param name="pageTitle" value="Test Raw Configuration"/> - - <ui:define name="body"> - - <h:messages showSummary="true" - showDetail="true" - errorClass="ErrorBlock" - warnClass="ErrorBlock" - infoClass="ConfirmationBlock" - globalOnly="true" - layout="table" - width="100%"/> - - <h:form id="viewTestConfigurationForm"> - - <onc:config configurationDefinition="#{RawTestConfigurationUIBean.configurationDefinition}" - configuration="#{RawTestConfigurationUIBean.configuration}" - accessMapActionExpression="#{RawTestConfigurationUIBean.accessMap}" - readOnly="true" /> - <h:panelGrid columns="1" styleClass="buttons-table" columnClasses="button-cell"> - <h:commandButton type="submit" action="#{RawTestConfigurationUIBean.editConfiguration}" - value="Edit this Configuration"/> - </h:panelGrid> - </h:form> - - </ui:define> - -</ui:composition> - -THIS TEXT WILL BE REMOVED AS WELL. - -</html> diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/view.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/view.xhtml deleted file mode 100644 index c543ca7..0000000 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/view.xhtml +++ /dev/null @@ -1,52 +0,0 @@ -<?xml version="1.0"?> - -<!DOCTYPE html - PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> - -<html xmlns="http://www.w3.org/1999/xhtml" - xmlns:h="http://java.sun.com/jsf/html" - xmlns:f="http://java.sun.com/jsf/core" - xmlns:ui="http://java.sun.com/jsf/facelets" - xmlns:rich="http://richfaces.ajax4jsf.org/rich" - xmlns:onc="http://jboss.org/on/component%22%3E - -THIS TEXT WILL BE REMOVED. - -<ui:composition template="/rhq/layout/main.xhtml"> - - THIS TEXT WILL BE REMOVED AS WELL. - - <ui:param name="pageTitle" value="Test Raw Configuration"/> - - <ui:define name="body"> - - <h:messages showSummary="true" - showDetail="true" - errorClass="ErrorBlock" - warnClass="ErrorBlock" - infoClass="ConfirmationBlock" - globalOnly="true" - layout="table" - width="100%"/> - - <h:form id="viewTestConfigurationForm"> - - <onc:config configurationDefinition="#{RawTestConfigurationUIBean.configurationDefinition}" - configuration="#{RawTestConfigurationUIBean.configuration}" - accessMapActionExpression="#{RawTestConfigurationUIBean.accessMap}" - readOnly="true" - showToolbar="true" /> - <h:panelGrid columns="1" styleClass="buttons-table" columnClasses="button-cell"> - <h:commandButton type="submit" action="#{RawTestConfigurationUIBean.editConfiguration}" - value="Edit this Configuration"/> - </h:panelGrid> - </h:form> - - </ui:define> - -</ui:composition> - -THIS TEXT WILL BE REMOVED AS WELL. - -</html>
commit 3eb729e227a8424b50635d7eaaf244c230fc1277 Author: John Sanda john@localhost.localdomain Date: Fri Dec 18 14:24:14 2009 -0500
Revert "added toolbar in xhtml, removed it from tests, still broken"
This reverts commit 8215954aefb1a23e492cbcaee04d628d247349ec.
diff --git a/.classpath b/.classpath index e53c4a4..a3aef1e 100644 --- a/.classpath +++ b/.classpath @@ -189,7 +189,7 @@ <classpathentry exported="true" kind="var" path="M2_REPO/org/json/json/20080701/json-20080701.jar"/> <classpathentry exported="true" kind="var" path="M2_REPO/com/sun/jna/jna/3.0.1/jna-3.0.1.jar"/> <classpathentry exported="true" kind="var" path="M2_REPO/org/freemarker/freemarker/2.3.11/freemarker-2.3.11.jar"/> - <classpathentry exported="true" kind="var" path="M2_REPO/org/jboss/seam/jboss-seam/2.1.0.SP1/jboss-seam-2.1.0.SP1.jar" sourcepath="/M2_REPO/org/jboss/seam/jboss-seam/2.1.0.SP1/jboss-seam-2.1.0.SP1-sources.jar"/> + <classpathentry exported="true" kind="var" path="M2_REPO/org/jboss/seam/jboss-seam/2.1.0.SP1/jboss-seam-2.1.0.SP1.jar"/> <classpathentry exported="true" kind="var" path="M2_REPO/org/jboss/seam/jboss-seam-ui/2.1.0.SP1/jboss-seam-ui-2.1.0.SP1.jar"/> <classpathentry exported="true" kind="var" path="M2_REPO/hibernate/hibernate3/3.2.r14201-2/hibernate3-3.2.r14201-2.jar"/> <classpathentry exported="true" kind="var" path="M2_REPO/jline/jline/0.9.94/jline-0.9.94.jar"/> diff --git a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/AbstractConfigurationComponent.java b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/AbstractConfigurationComponent.java index 5d5f894..e49ead1 100644 --- a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/AbstractConfigurationComponent.java +++ b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/AbstractConfigurationComponent.java @@ -24,7 +24,6 @@ package org.rhq.core.gui.configuration;
import java.util.UUID;
-import javax.el.ValueExpression; import javax.faces.component.UIComponent; import javax.faces.component.UIComponentBase; import javax.faces.context.FacesContext; @@ -60,7 +59,6 @@ public abstract class AbstractConfigurationComponent extends UIComponentBase imp private Boolean fullyEditable; private String listName; private Integer listIndex; - RawConfigUIComponent rawConfigUIComponent;
public UIComponent getToolbar() { return toolbar; @@ -89,16 +87,6 @@ public abstract class AbstractConfigurationComponent extends UIComponentBase imp
public abstract String getConfigurationExpressionString();
- private ValueExpression saveValueExpression; - - public ValueExpression getSaveValueExpression() { - return saveValueExpression; - } - - public void setSaveValueExpression(ValueExpression saveValueExpression) { - this.saveValueExpression = saveValueExpression; - } - public String createUniqueId() { return UNIQUE_ID_PREFIX + UUID.randomUUID(); } @@ -227,12 +215,10 @@ public abstract class AbstractConfigurationComponent extends UIComponentBase imp
private Object[] stateValues;
- public StructuredConfigUIComponent structuredConfig; - @Override public Object saveState(FacesContext facesContext) { if (this.stateValues == null) { - this.stateValues = new Object[12]; + this.stateValues = new Object[8]; }
this.stateValues[0] = super.saveState(facesContext); @@ -243,12 +229,6 @@ public abstract class AbstractConfigurationComponent extends UIComponentBase imp this.stateValues[5] = this.prevalidate; this.stateValues[6] = this.isGroup; this.stateValues[7] = this.getShowToolbar(); - if (rawConfigUIComponent != null) { - this.stateValues[8] = this.rawConfigUIComponent; - this.stateValues[9] = structuredConfig; - this.stateValues[10] = this.rawConfigUIComponent.saveState(facesContext); - this.stateValues[11] = this.structuredConfig.saveState(facesContext); - } return this.stateValues; }
@@ -263,33 +243,20 @@ public abstract class AbstractConfigurationComponent extends UIComponentBase imp this.prevalidate = (Boolean) this.stateValues[5]; this.isGroup = (Boolean) this.stateValues[6]; this.showToolbar = (Boolean) this.stateValues[7]; - - this.rawConfigUIComponent = (RawConfigUIComponent) this.stateValues[8]; - this.structuredConfig = (StructuredConfigUIComponent) this.stateValues[9]; - - if (this.rawConfigUIComponent != null) { - this.rawConfigUIComponent.restoreState(facesContext, this.stateValues[10]); - } - if (this.structuredConfig != null) { - this.structuredConfig.restoreState(facesContext, this.stateValues[11]); - } - - //getChildren().add(structuredConfig); - //getChildren().add(rawConfigUIComponent); - }
public boolean getShouldShowRaw() { return Boolean.valueOf(FacesContextUtility.getOptionalRequestParameter("showRaw", String.class, "unset")) - && (!this.getConfigurationDefinition().getConfigurationFormat().equals(ConfigurationFormat.STRUCTURED)); + || (this.getConfigurationDefinition().getConfigurationFormat().equals(ConfigurationFormat.RAW)); }
+ RawConfigUIComponent rawConfigUIComponent; + RawConfigUIComponent getRawConfigUIComponent() { if (null == rawConfigUIComponent) { rawConfigUIComponent = new RawConfigUIComponent(getConfiguration(), getConfigurationDefinition(), this, isReadOnly()); } - return rawConfigUIComponent; }
diff --git a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/ConfigRenderer.java b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/ConfigRenderer.java index be2feac..278d619 100644 --- a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/ConfigRenderer.java +++ b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/ConfigRenderer.java @@ -26,12 +26,16 @@ import java.io.IOException; import java.util.List; import java.util.Map;
+import javax.el.MethodExpression; import javax.el.ValueExpression; import javax.faces.application.FacesMessage; import javax.faces.component.UIComponent; import javax.faces.component.UIForm; import javax.faces.component.UIInput; +import javax.faces.component.UIOutput; +import javax.faces.component.UIPanel; import javax.faces.component.UIParameter; +import javax.faces.component.html.HtmlCommandLink; import javax.faces.component.html.HtmlForm; import javax.faces.component.html.HtmlOutputLink; import javax.faces.component.html.HtmlPanelGrid; @@ -47,15 +51,18 @@ import org.ajax4jsf.context.AjaxContext; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.richfaces.component.html.HtmlModalPanel; +import org.richfaces.component.html.HtmlSimpleTogglePanel;
import org.rhq.core.clientapi.agent.configuration.ConfigurationUtility; import org.rhq.core.domain.configuration.Property; import org.rhq.core.domain.configuration.PropertyList; import org.rhq.core.domain.configuration.PropertyMap; import org.rhq.core.domain.configuration.PropertySimple; +import org.rhq.core.domain.configuration.definition.ConfigurationFormat; import org.rhq.core.domain.configuration.definition.PropertyDefinition; import org.rhq.core.domain.configuration.definition.PropertyDefinitionMap; import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple; +import org.rhq.core.domain.configuration.definition.PropertyGroupDefinition; import org.rhq.core.gui.RequestParameterNameConstants; import org.rhq.core.gui.configuration.helper.PropertyRenderingUtility; import org.rhq.core.gui.configuration.propset.ConfigurationSetComponent; @@ -177,9 +184,7 @@ public class ConfigRenderer extends Renderer { addChildComponents(configurationComponent); if (configurationComponent.getToolbar() != null) { configurationComponent.getToolbar().setRendered(configurationComponent.getShowToolbar()); - } - }
private boolean isAjaxRefresh(AbstractConfigurationComponent configurationComponent) { @@ -265,20 +270,113 @@ public class ConfigRenderer extends Renderer { } }
- configurationComponent.rawConfigUIComponent = new RawConfigUIComponent(configurationComponent - .getConfiguration(), configurationComponent.getConfigurationDefinition(), configurationComponent, - configurationComponent.isReadOnly()); + Boolean shouldShowRawNow = configurationComponent.getShouldShowRaw(); + + if (shouldShowRawNow) { + configurationComponent.getChildren().add( + new RawConfigUIComponent(configurationComponent.getConfiguration(), configurationComponent + .getConfigurationDefinition(), configurationComponent, configurationComponent.isReadOnly())); + } else { + addStructuredConfig(configurationComponent); + } + }
- configurationComponent.getChildren().add(configurationComponent.rawConfigUIComponent); + private void addStructuredConfig(AbstractConfigurationComponent configurationComponent) { + { + UIPanel toolbarPanel = FacesComponentUtility.addBlockPanel(configurationComponent, configurationComponent, + "summary-props-table"); + if (configurationComponent.isReadOnly()) { + HtmlOutputLink editLink = FacesComponentUtility.addOutputLink(toolbarPanel, configurationComponent, + "edit.xhtml"); + FacesComponentUtility.addGraphicImage(editLink, configurationComponent, "/images/edit.png", "Edit"); + FacesComponentUtility.addOutputText(editLink, configurationComponent, "Edit", ""); + FacesComponentUtility.addParameter(editLink, configurationComponent, "readOnly", Boolean + .toString(false)); + FacesComponentUtility.addParameter(editLink, configurationComponent, "id", FacesContextUtility + .getRequiredRequestParameter("id")); + } else { + HtmlCommandLink saveLink = FacesComponentUtility.addCommandLink(toolbarPanel, configurationComponent); + FacesComponentUtility.addGraphicImage(saveLink, configurationComponent, "/images/save.png", "Save"); + FacesComponentUtility.addOutputText(saveLink, configurationComponent, "Save", ""); + FacesComponentUtility.addParameter(saveLink, configurationComponent, "save", Boolean.toString(true)); + FacesComponentUtility + .addParameter(saveLink, configurationComponent, "readOnly", Boolean.toString(true)); + + saveLink.setActionExpression(getSaveActionExpression());
- configurationComponent.structuredConfig = new StructuredConfigUIComponent(configurationComponent); + } + if (configurationComponent.getConfigurationDefinition().getConfigurationFormat().isRawSupported()) { + HtmlCommandLink toRawLink = FacesComponentUtility.addCommandLink(toolbarPanel, configurationComponent); + FacesComponentUtility.addGraphicImage(toRawLink, configurationComponent, "/images/raw.png", "showRaw"); + FacesComponentUtility.addOutputText(toRawLink, configurationComponent, "showRaw", ""); + FacesComponentUtility.addParameter(toRawLink, configurationComponent, "showRaw", Boolean.TRUE + .toString()); + FacesComponentUtility.addParameter(toRawLink, configurationComponent, "readOnly", Boolean + .toString(configurationComponent.isReadOnly())); + } + configurationComponent.setToolbar(toolbarPanel); + }
- configurationComponent.getChildren().add(configurationComponent.structuredConfig); + if (!configurationComponent.isReadOnly()) + addRequiredNotationsKey(configurationComponent);
- Boolean shouldShowRawNow = configurationComponent.getShouldShowRaw(); + if (configurationComponent.getListName() != null) { + if (configurationComponent.getListIndex() == null) { + // No index specified means we should add a new map to the list. + configurationComponent.setListIndex(addNewMap(configurationComponent)); + }
- configurationComponent.rawConfigUIComponent.setRendered(shouldShowRawNow); - configurationComponent.structuredConfig.setRendered(!shouldShowRawNow); + addListMemberProperty(configurationComponent); + } else { + addConfiguration(configurationComponent); + } + + String id = getInitInputsJavaScriptComponentId(configurationComponent); + PropertyRenderingUtility.addInitInputsJavaScript(configurationComponent, id, configurationComponent + .isFullyEditable(), false); + } + + private MethodExpression getSaveActionExpression() { + + MethodExpression actionExpression = null; + + return actionExpression; + } + + private void addStructuredRawToggle(AbstractConfigurationComponent configurationComponent, boolean showRaw) { + if (configurationComponent.getConfigurationDefinition().getConfigurationFormat().equals( + ConfigurationFormat.STRUCTURED_AND_RAW)) { + + HtmlPanelGroup toRawLinkPanel = FacesComponentUtility.addBlockPanel(configurationComponent, + configurationComponent, UNGROUPED_PROPERTIES_STYLE_CLASS); + + FacesComponentUtility.addOutputText(toRawLinkPanel, configurationComponent, + "internationalized Message goes here", UNGROUPED_PROPERTIES_STYLE_CLASS); + + HtmlCommandLink commandLink = FacesComponentUtility.addCommandLink(toRawLinkPanel, configurationComponent); + + UIOutput output = new UIOutput(); + output.setValue(showRaw ? "Show Structured" : " Show Raw"); + commandLink.getChildren().add(output); + //output.setParent(commandLink); + FacesComponentUtility.addParameter(commandLink, configurationComponent, "showRaw", Boolean + .toString(!showRaw)); + } + } + + private void addListMemberProperty(AbstractConfigurationComponent configurationComponent) { + // Update member Configurations if this is a group config. + if (configurationComponent instanceof ConfigurationSetComponent) { + ConfigurationSetComponent configurationSetComponent = ((ConfigurationSetComponent) configurationComponent); + configurationSetComponent.getConfigurationSet().applyGroupConfiguration(); + } + + // Now add a new component to the JSF component tree. + AbstractPropertyBagUIComponentTreeFactory propertyListUIComponentTreeFactory = new MapInListUIComponentTreeFactory( + configurationComponent, configurationComponent.getListName(), configurationComponent.getListIndex()); + HtmlPanelGroup propertiesPanel = FacesComponentUtility.addBlockPanel(configurationComponent, + configurationComponent, UNGROUPED_PROPERTIES_STYLE_CLASS); + propertiesPanel.getChildren().add(propertyListUIComponentTreeFactory.createUIComponentTree(null)); }
private void deleteListMemberProperty(AbstractConfigurationComponent configurationComponent) { @@ -384,6 +482,83 @@ public class ConfigRenderer extends Renderer { + mapName + "'."); }
+ private static void addRequiredNotationsKey(AbstractConfigurationComponent config) { + addDebug(config, true, ".addNotePanel()"); + HtmlPanelGroup footnotesPanel = FacesComponentUtility.addBlockPanel(config, config, NOTE_PANEL_STYLE_CLASS); + FacesComponentUtility.addOutputText(footnotesPanel, config, "*", REQUIRED_MARKER_TEXT_STYLE_CLASS); + FacesComponentUtility.addOutputText(footnotesPanel, config, " denotes a required field.", + FacesComponentUtility.NO_STYLE_CLASS); + if (config.isGroup()) { + HtmlPanelGroup overridePanel = FacesComponentUtility.addBlockPanel(config, config, NOTE_PANEL_STYLE_CLASS); + FacesComponentUtility.addOutputText(overridePanel, config, + "note: if override is not checked, that property will not be altered on any group members", + FacesComponentUtility.NO_STYLE_CLASS); + } + + addDebug(config, false, ".addNotePanel()"); + } + + private void addConfiguration(AbstractConfigurationComponent config) { + addNonGroupedProperties(config); + addGroupedProperties(config); + } + + private void addNonGroupedProperties(AbstractConfigurationComponent config) { + addDebug(config, true, ".addNonGroupedProperties()"); + HtmlPanelGroup propertiesPanel = FacesComponentUtility.addBlockPanel(config, config, + UNGROUPED_PROPERTIES_STYLE_CLASS); + AbstractPropertyBagUIComponentTreeFactory propertyListUIComponentTreeFactory = new GroupUIComponentTreeFactory( + config, GroupUIComponentTreeFactory.NO_GROUP); + propertiesPanel.getChildren().add(propertyListUIComponentTreeFactory.createUIComponentTree(null)); + addDebug(config, false, ".addNonGroupedProperties()"); + } + + private void addGroupedProperties(AbstractConfigurationComponent config) { + addDebug(config, true, ".addGroupedProperties()"); + List<PropertyGroupDefinition> groups = config.getConfigurationDefinition().getGroupDefinitions(); + for (PropertyGroupDefinition group : groups) { + HtmlSimpleTogglePanel groupPanel = addGroupPanel(config, group); + AbstractPropertyBagUIComponentTreeFactory propertyListUIComponentTreeFactory = new GroupUIComponentTreeFactory( + config, group.getName()); + groupPanel.getChildren().add(propertyListUIComponentTreeFactory.createUIComponentTree(null)); + } + + addDebug(config, false, ".addGroupedProperties()"); + } + + private HtmlSimpleTogglePanel addGroupPanel(AbstractConfigurationComponent config, PropertyGroupDefinition group) { + addDebug(config, true, ".addGroupPanel()"); + HtmlSimpleTogglePanel groupPanel = FacesComponentUtility.addSimpleTogglePanel(config, config, null); + // TODO: On AJAX requests, set "opened" attribute to its previous state. + groupPanel.setOpened(!group.isDefaultHidden()); + groupPanel.setHeaderClass(PROPERTY_GROUP_HEADER_STYLE_CLASS); + groupPanel.setBodyClass(PROPERTY_GROUP_BODY_STYLE_CLASS); + + // Custom header that includes the name and description + HtmlPanelGroup headerPanel = FacesComponentUtility.createBlockPanel(config, null); + FacesComponentUtility.addOutputText(headerPanel, config, group.getDisplayName(), null); + FacesComponentUtility + .addOutputText(headerPanel, config, group.getDescription(), "group-description-text-panel"); + groupPanel.getFacets().put("header", headerPanel); + + // custom "close" widget + HtmlPanelGroup closePanel = FacesComponentUtility.createBlockPanel(config, null); + closePanel.setStyle("text-align: right; font-weight: normal; font-size: 0.8em; whitespace: nowrap;"); + FacesComponentUtility.addGraphicImage(closePanel, config, "/images/ico_trigger_wht_collapse.gif", "collapse"); + FacesComponentUtility.addOutputText(closePanel, config, " Collapse", null); + groupPanel.getFacets().put("closeMarker", closePanel); + + // custom "open" widget + HtmlPanelGroup openPanel = FacesComponentUtility.createBlockPanel(config, null); + openPanel.setStyle("text-align: right; font-weight: normal; font-size: 0.8em; whitespace: nowrap;"); + FacesComponentUtility.addGraphicImage(openPanel, config, "/images/ico_trigger_wht_expand.gif", "expand"); + FacesComponentUtility.addOutputText(openPanel, config, " Expand", null); + groupPanel.getFacets().put("openMarker", openPanel); + addDebug(config, true, ".addGroupPanel()"); + + return groupPanel; + } + private void validateAttributes(AbstractConfigurationComponent configurationComponent) { // TODO: Add back attribute validation - remember config and configSet components require different attributes. /*if (configurationComponent.getValueExpression("configurationDefinition") == null) { @@ -397,7 +572,7 @@ public class ConfigRenderer extends Renderer { }*/ }
- static int addNewMap(AbstractConfigurationComponent config) { + private int addNewMap(AbstractConfigurationComponent config) { String listName = config.getListName(); PropertyDefinitionMap mapDefinition = (PropertyDefinitionMap) config.getConfigurationDefinition() .getPropertyDefinitionList(listName).getMemberDefinition(); @@ -422,7 +597,7 @@ public class ConfigRenderer extends Renderer { * @param start true if this is the "START" comment, false if it is the "END" comment * @param methodName the name of the method this is calling from */ - static void addDebug(UIComponent component, boolean start, String methodName) { + private static void addDebug(UIComponent component, boolean start, String methodName) { if (LOG.isDebugEnabled()) { StringBuilder msg = new StringBuilder("\n<!--"); msg.append(start ? " START " : " END "); @@ -433,7 +608,7 @@ public class ConfigRenderer extends Renderer { } }
- static String getInitInputsJavaScriptComponentId(AbstractConfigurationComponent configUIComponent) { + private String getInitInputsJavaScriptComponentId(AbstractConfigurationComponent configUIComponent) { return configUIComponent.getId() + INIT_INPUTS_JAVA_SCRIPT_COMPONENT_ID_SUFFIX; }
diff --git a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/RawConfigUIComponent.java b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/RawConfigUIComponent.java index 5b86352..2c9a1be 100644 --- a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/RawConfigUIComponent.java +++ b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/RawConfigUIComponent.java @@ -34,7 +34,7 @@ public class RawConfigUIComponent extends UIComponentBase { super.decode(context); setSelectedPath(FacesContextUtility.getOptionalRequestParameter("path")); readOnly = Boolean.valueOf(FacesContextUtility.getOptionalRequestParameter("readOnly")); - this.inputTextarea.decode(context); + }
@Override @@ -99,7 +99,7 @@ public class RawConfigUIComponent extends UIComponentBase {
UIPanel rawPanel = FacesComponentUtility.addBlockPanel(this, idFactory, "");
- //addToolbar(configurationDefinition, rawPanel); + addToolbar(configurationDefinition, rawPanel);
HtmlPanelGrid grid = FacesComponentUtility.addPanelGrid(rawPanel, idFactory, "summary-props-table"); grid.setParent(this); @@ -122,14 +122,6 @@ public class RawConfigUIComponent extends UIComponentBase { configPathList.add(raw.getPath()); rawMap.put(raw.getPath(), raw); } - - if (rawMap.isEmpty()) { - RawConfiguration raw = new RawConfiguration(); - raw.setContentString(""); - raw.setPath(""); - rawMap.put("", raw); - } - Collections.sort(configPathList); String oldDirname = ""; for (String s : configPathList) { @@ -148,11 +140,12 @@ public class RawConfigUIComponent extends UIComponentBase { FacesComponentUtility.addParameter(link, idFactory, "showRaw", Boolean.TRUE.toString()); readOnlyParms.add(FacesComponentUtility.addParameter(link, idFactory, AbstractConfigurationComponent.READ_ONLY_ATTRIBUTE, Boolean.toString(readOnly))); + }
UIPanel panelRight = FacesComponentUtility.addBlockPanel(grid, idFactory, "summary-props-table");
- editPanel = FacesComponentUtility.addBlockPanel(panelRight, idFactory, "summary-props-table"); + UIPanel editPanel = FacesComponentUtility.addBlockPanel(panelRight, idFactory, "summary-props-table"); inputTextarea = new HtmlInputTextarea(); editPanel.getChildren().add(inputTextarea); inputTextarea.setParent(editPanel); @@ -164,8 +157,52 @@ public class RawConfigUIComponent extends UIComponentBase {
private HtmlOutputLink fullscreenLink; private UIParameter fullScreenResourceIdParam; - public HtmlCommandLink saveLink; - private UIPanel editPanel; + + private void addToolbar(ConfigurationDefinition configurationDefinition, UIPanel parent) { + UIPanel toolbarPanel = FacesComponentUtility.addBlockPanel(parent, idFactory, "config-toolbar"); + if (readOnly) { + HtmlCommandLink editLink = FacesComponentUtility.addCommandLink(toolbarPanel, idFactory); + FacesComponentUtility.addGraphicImage(editLink, idFactory, "/images/edit.png", "Edit"); + FacesComponentUtility.addOutputText(editLink, idFactory, "Edit", ""); + FacesComponentUtility.addParameter(editLink, idFactory, "showRaw", Boolean.TRUE.toString()); + FacesComponentUtility.addParameter(editLink, idFactory, AbstractConfigurationComponent.READ_ONLY_ATTRIBUTE, + Boolean.FALSE.toString()); + } else { + HtmlCommandLink saveLink = FacesComponentUtility.addCommandLink(toolbarPanel, idFactory); + FacesComponentUtility.addGraphicImage(saveLink, idFactory, "/images/save.png", "Save"); + FacesComponentUtility.addOutputText(saveLink, idFactory, "Save", ""); + FacesComponentUtility.addParameter(saveLink, idFactory, "showRaw", Boolean.FALSE.toString()); + FacesComponentUtility.addParameter(saveLink, idFactory, AbstractConfigurationComponent.READ_ONLY_ATTRIBUTE, + Boolean.TRUE.toString()); + } + { + fullscreenLink = FacesComponentUtility.addOutputLink(toolbarPanel, idFactory, "view-full.xhtml"); + FacesComponentUtility + .addGraphicImage(fullscreenLink, idFactory, "/images/viewfullscreen.png", "FullScreen"); + FacesComponentUtility.addOutputText(fullscreenLink, idFactory, "Full Screen", ""); + fullScreenResourceIdParam = FacesComponentUtility.addParameter(fullscreenLink, idFactory, "id", ""); + } + if (!readOnly) { + HtmlOutputLink uploadLink = FacesComponentUtility.addOutputLink(toolbarPanel, idFactory, "upload.xhtml"); + FacesComponentUtility.addGraphicImage(uploadLink, idFactory, "/images/upload.png", "Upload"); + FacesComponentUtility.addOutputText(uploadLink, idFactory, "Upload", ""); + } + { + HtmlOutputLink downloadLink = FacesComponentUtility + .addOutputLink(toolbarPanel, idFactory, "download.xhtml"); + FacesComponentUtility.addGraphicImage(downloadLink, idFactory, "/images/download.png", "download"); + FacesComponentUtility.addOutputText(downloadLink, idFactory, "Download", ""); + } + if (configurationDefinition.getConfigurationFormat().isStructuredSupported()) { + HtmlCommandLink toStructureLink = FacesComponentUtility.addCommandLink(toolbarPanel, idFactory); + FacesComponentUtility.addGraphicImage(toStructureLink, idFactory, "/images/structured.png", + "showStructured"); + FacesComponentUtility.addOutputText(toStructureLink, idFactory, "showStructured", ""); + FacesComponentUtility.addParameter(toStructureLink, idFactory, "showRaw", Boolean.FALSE.toString()); + readOnlyParms.add(FacesComponentUtility.addParameter(toStructureLink, idFactory, "readOnly", Boolean + .toString(readOnly))); + } + }
@Override public void encodeBegin(FacesContext context) throws IOException { diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java index 44d005a..2f11e11 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java @@ -54,30 +54,6 @@ import org.rhq.enterprise.server.util.LookupUtil; public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUIBean { public static final String MANAGED_BEAN_NAME = "ExistingResourceConfigurationUIBean";
- Boolean showRawConfig; - - public Boolean getShowRawConfig() { - if (null == showRawConfig) { - showRawConfig = this.getConfigurationDefinition().getConfigurationFormat().equals(ConfigurationFormat.RAW); - } - - return showRawConfig; - } - - public void setShowRawConfig(Boolean showRawConfig) { - this.showRawConfig = showRawConfig; - } - - public Boolean getShowRawButton() { - return !getShowRawConfig(); - //&& getConfigurationDefinition().getConfigurationFormat().equals(ConfigurationFormat.STRUCTURED_AND_RAW); - } - - public Boolean getShowStructuredButton() { - return getShowRawConfig(); - //&& getConfigurationDefinition().getConfigurationFormat().equals(ConfigurationFormat.STRUCTURED_AND_RAW); - } - private String selectedPath; private TreeMap<String, RawConfiguration> raws; private TreeMap<String, RawConfiguration> modified = new TreeMap<String, RawConfiguration>(); @@ -99,6 +75,15 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI return SUCCESS_OUTCOME; }
+ public String switchToRaw() { + ConfigurationMaskingUtility.unmaskConfiguration(getConfiguration(), getConfigurationDefinition()); + int resourceId = EnterpriseFacesContextUtility.getResource().getId(); + this.configurationManager.translateResourceConfiguration(EnterpriseFacesContextUtility.getSubject(), + resourceId, getConfiguration(), true); + + return SUCCESS_OUTCOME; + } + public String updateConfiguration() {
modified = null; @@ -358,53 +343,41 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI * But is kept as a target for the "action" value */ public String upload() { - return "/rhq/resource/configuration/edit.xhtml?currentResourceId=" + getResourceId(); + return "/rhq/resource/configuration/edit-raw.xhtml?currentResourceId=" + getResourceId(); }
- public String switchToRaw() { - - try { - Configuration configuration; - configuration = LookupUtil.getConfigurationManager().translateResourceConfiguration( - EnterpriseFacesContextUtility.getSubject(), getResourceId(), getMergedConfiguration(), true); + public String switchToraw() { + Configuration configuration = LookupUtil.getConfigurationManager().translateResourceConfiguration( + EnterpriseFacesContextUtility.getSubject(), getResourceId(), getMergedConfiguration(), true);
- setConfiguration(configuration); - for (RawConfiguration raw : configuration.getRawConfigurations()) { - getRaws().put(raw.getPath(), raw); - } - current = null; - setConfiguration(configuration); - - setShowRawConfig(true); - - return "edit.xhtml?showRaw="true"&id=" + getResourceId(); - } catch (Exception e) { - return "overview.xhtml"; + setConfiguration(configuration); + for (RawConfiguration raw : configuration.getRawConfigurations()) { + getRaws().put(raw.getPath(), raw); } + current = null; + setConfiguration(configuration); + + return "/rhq/resource/configuration/edit-raw.xhtml?currentResourceId=" + getResourceId(); }
- public String switchToStructured() { - try { - Configuration configuration = LookupUtil.getConfigurationManager().translateResourceConfiguration( - EnterpriseFacesContextUtility.getSubject(), getResourceId(), getMergedConfiguration(), false); + public String switchTostructured() {
- for (Property property : configuration.getAllProperties().values()) { - property.setConfiguration(configuration); - } + Configuration configuration = LookupUtil.getConfigurationManager().translateResourceConfiguration( + EnterpriseFacesContextUtility.getSubject(), getResourceId(), getMergedConfiguration(), false);
- for (RawConfiguration raw : configuration.getRawConfigurations()) { - getRaws().put(raw.getPath(), raw); - setConfiguration(configuration); - } - current = null; - setConfiguration(configuration); - setShowRawConfig(false); + for (Property property : configuration.getAllProperties().values()) { + property.setConfiguration(configuration); + }
- return "edit.xhtml?id=" + getResourceId(); - } catch (Exception e) { - return "overview.xhtml"; + for (RawConfiguration raw : configuration.getRawConfigurations()) { + getRaws().put(raw.getPath(), raw); + setConfiguration(configuration); } + current = null; + setConfiguration(configuration);
+// return "/rhq/resource/configuration/edit.xhtml?currentResourceId=" + getResourceId(); + return SUCCESS_OUTCOME; }
void populateRaws() { diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/test/AbstractTestConfigurationUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/test/AbstractTestConfigurationUIBean.java index f1ff041..4bbd064 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/test/AbstractTestConfigurationUIBean.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/test/AbstractTestConfigurationUIBean.java @@ -24,7 +24,6 @@ import java.util.UUID;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; - import org.rhq.core.domain.configuration.Configuration; import org.rhq.core.domain.configuration.Property; import org.rhq.core.domain.configuration.PropertySimple; @@ -37,8 +36,7 @@ import org.rhq.enterprise.gui.common.Outcomes; * @author Ian Springer */ public abstract class AbstractTestConfigurationUIBean { - public static final String[] LABELS = new String[] { "AAA", "ZZZ", "BBB", "YYY", "AAA", "AAA", "ZZZ", "ZZZ", "YYY", - "BBB" }; + public static final String [] LABELS = new String[] { "AAA", "ZZZ", "BBB", "YYY","AAA", "AAA", "ZZZ", "ZZZ", "YYY", "BBB"};
public static final int GROUP_SIZE = 100;
@@ -47,7 +45,8 @@ public abstract class AbstractTestConfigurationUIBean { private List<Property> properties; private ConfigurationSet configurationSet;
- protected AbstractTestConfigurationUIBean() { + protected AbstractTestConfigurationUIBean() + { this.configurationDefinition = TestConfigurationFactory.createConfigurationDefinition(); this.configuration = TestConfigurationFactory.createConfiguration(); List<ConfigurationSetMember> members = new ArrayList(GROUP_SIZE); @@ -59,8 +58,8 @@ public abstract class AbstractTestConfigurationUIBean { configuration.getSimple("Boolean").setStringValue(String.valueOf(i % 2 == 0)); if (i == 0) configuration.getMap("OpenMapOfSimples").put(new PropertySimple("PROCESSOR_CORES", "4")); - ConfigurationSetMember memberInfo = new ConfigurationSetMember(LABELS[GROUP_SIZE % LABELS.length], - configuration); + ConfigurationSetMember memberInfo = + new ConfigurationSetMember(LABELS[GROUP_SIZE % LABELS.length], configuration); members.add(memberInfo); } this.configurationSet = new ConfigurationSet(this.configurationDefinition, members); @@ -77,7 +76,8 @@ public abstract class AbstractTestConfigurationUIBean { return this.configurationDefinition; }
- public void setConfigurationDefinition(@NotNull ConfigurationDefinition configurationDefinition) { + public void setConfigurationDefinition(@NotNull + ConfigurationDefinition configurationDefinition) { this.configurationDefinition = configurationDefinition; }
@@ -86,26 +86,26 @@ public abstract class AbstractTestConfigurationUIBean { return this.configuration; }
- public void setConfiguration(@NotNull Configuration configuration) { + public void setConfiguration(@NotNull + Configuration configuration) { this.configuration = configuration; }
- public ConfigurationSet getConfigurationSet() { + public ConfigurationSet getConfigurationSet() + { return configurationSet; }
- public void setConfigurationSet(ConfigurationSet configurationSet) { + public void setConfigurationSet(ConfigurationSet configurationSet) + { this.configurationSet = configurationSet; }
- public List<Property> getProperties() { + public List<Property> getProperties() + { return this.properties; }
- public void setProperties(@NotNull List<Property> properties) { - this.properties = properties; - } - public String getNullConfigurationDefinitionMessage() { return "Test config def is null (should never happen)."; } diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-managed-beans/test-beans.xml b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-managed-beans/test-beans.xml index fbfad37..3ec6058 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-managed-beans/test-beans.xml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-managed-beans/test-beans.xml @@ -17,14 +17,6 @@ </managed-bean>
<managed-bean> - <managed-bean-name>RawTestConfigurationUIBean</managed-bean-name> - <managed-bean-class>org.rhq.enterprise.gui.configuration.test.RawTestConfigurationUIBean</managed-bean-class> - <managed-bean-scope>session</managed-bean-scope> - </managed-bean> - - - - <managed-bean> <managed-bean-name>AddNewOpenMapMemberPropertyToTestConfigurationUIBean</managed-bean-name> <managed-bean-class> org.rhq.enterprise.gui.configuration.test.EditTestConfigurationAddNewOpenMapMemberPropertyUIBean diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml index 228e612..dffd02b 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml @@ -31,47 +31,19 @@ THIS TEXT WILL BE REMOVED.
<h:form id="editResourceConfigurationForm" onsubmit="prepareInputsForSubmission(this)" rendered="#{!ViewResourceConfigurationUIBean.updateInProgress}">
- <input type="hidden" name="id" value="#{ResourceUIBean.id}"/> - - <h:panelGroup> - <h:commandLink action="#{ExistingResourceConfigurationUIBean.updateConfiguration}"> - <h:graphicImage value="Save" url="/images/save.png" /> - <h:outputText value="Save Junk" /> - <f:param name="showRaw" value="true"/> - </h:commandLink> - - <h:commandLink rendered="#{ExistingResourceConfigurationUIBean.showRawButton}" action="#{ExistingResourceConfigurationUIBean.switchToRaw}" > - <h:graphicImage value="Raw" url="/images/raw.png" /> - <h:outputText value="Raw " /> - </h:commandLink> - - <h:commandLink rendered="#{ExistingResourceConfigurationUIBean.showStructuredButton}" action="#{ExistingResourceConfigurationUIBean.switchToStructured}"> - <h:graphicImage value="Structured" url="/images/structured.png" /> - <h:outputText value="Structured " /> - <f:param name="showRaw" value="false"/> - </h:commandLink> - - <h:outputLink value="fullscreen.xhtml"> - <h:graphicImage value="Full Screen" url="/images/viewfullscreen.png" /> - <h:outputText value="Full Screen" /> - <f:param name="showRaw" value="true"/> - </h:outputLink> - - <h:outputLink value="download.xhtml"> - <h:graphicImage value="Download" url="/images/download.png" /> - <h:outputText value="Download " /> - <f:param name="showRaw" value="false"/> - </h:outputLink> - - <h:outputLink value="upload.xhtml" rendered="#{!showReadOnly}"> - <h:graphicImage value="Upload" url="/images/upload.png" /> - <h:outputText value="Upload " /> - <f:param name="showRaw" value="false"/> - </h:outputLink> - - - </h:panelGroup> - + + <input type="hidden" name="id" value="#{ResourceUIBean.id}"/> + + <h:outputText value="#{messages.youareviewingstructured}" /> + + <h:panelGroup rendered="#{ExistingResourceConfigurationUIBean.rawSupported}" > + <h:outputText value=" #{messages.switch2}" /> + <h:commandLink action="#{ExistingResourceConfigurationUIBean.switchToraw}" > + <f:param name="conversationId" value="#{conversation.id}"/> + <f:param name="id" value="#{ResourceUIBean.id}"/> + <h:outputText value=" files mode"/> + </h:commandLink> + </h:panelGroup> <onc:config configurationDefinition="#{ExistingResourceConfigurationUIBean.configurationDefinition}" configuration="#{ExistingResourceConfigurationUIBean.configuration}" @@ -80,7 +52,6 @@ THIS TEXT WILL BE REMOVED. prevalidate="true" showToolbar="true" readOnly="false" - action="#{ExistingResourceConfigurationUIBean.updateRawConfiguration}" />
<h:panelGrid columns="2" styleClass="buttons-table" columnClasses="button-cell" rendered="#{ExistingResourceConfigurationUIBean.configuration != null}"> diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml index ea44edd..40a917d 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml @@ -41,56 +41,20 @@ THIS TEXT WILL BE REMOVED. </h:panelGroup>
+ <h:outputText value=" #{messages.nopermissionedit}" rendered="#{!ResourceUIBean.permissions.configure}"/> + <h:form id="viewResourceConfigurationForm"> <!-- TODO remove the id version --> <input type="hidden" name="id" value="#{ResourceUIBean.id}"/> - - <ui:include src="/WEB-INF/fragments/config-view-toolbar.xhtml" /> - - <h:panelGroup> - <h:outputLink value="edit.xhtml"> - <h:graphicImage value="Edit" url="/images/edit.png" /> - <h:outputText value="Edit " /> - <f:param name="showRaw" value="#{showRawConfig}"/> - <f:param name="id" value="#{ResourceUIBean.id}"/> - </h:outputLink> - - <h:commandLink rendered="#{ExistingResourceConfigurationViewUIBean.showRawButton}"> - <h:graphicImage value="Raw" url="/images/raw.png" /> - <h:outputText value="Raw " /> - <f:param name="showRaw" value="true"/> - </h:commandLink> - - <h:commandLink rendered="#{ExistingResourceConfigurationViewUIBean.showStructuredButton}"> - <h:graphicImage value="Structured" url="/images/structured.png" /> - <h:outputText value="Structured " /> - <f:param name="showRaw" value="false"/> - </h:commandLink> - - <h:commandLink rendered="#{showRawConfig}"> - <h:graphicImage value="Full Screen" url="/images/viewfullscreen.png" /> - <h:outputText value="Full Screen" /> - <f:param name="showRaw" value="true"/> - </h:commandLink> - - <h:outputLink value="download.xhtml" rendered="#{showRawConfig}"> - <h:graphicImage value="Download" url="/images/download.png" /> - <h:outputText value="Download " /> - </h:outputLink> - - </h:panelGroup> - - - - + <onc:config configurationDefinition="#{ExistingResourceConfigurationViewUIBean.configurationDefinition}" configuration="#{ExistingResourceConfigurationViewUIBean.configuration}" accessMapActionExpression="#{ExistingResourceConfigurationViewUIBean.accessMap}" nullConfigurationDefinitionMessage="#{ExistingResourceConfigurationViewUIBean.nullConfigurationDefinitionMessage}" nullConfigurationMessage="#{ExistingResourceConfigurationViewUIBean.nullConfigurationMessage}" readOnly="true" - prevalidate="true" - /> + showToolbar="true" + prevalidate="true"/> <input type="hidden" name="id" value="#{ResourceUIBean.id}"/>
</h:form> diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/edit.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/edit.xhtml index da51088..1e4c156 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/edit.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/edit.xhtml @@ -37,7 +37,7 @@ THIS TEXT WILL BE REMOVED. accessMapActionExpression="#{RawTestConfigurationUIBean.accessMap}" readOnly="true" /> <h:panelGrid columns="1" styleClass="buttons-table" columnClasses="button-cell"> - <h:commandButton type="submit" action="#{RawTestConfigurationUIBean.updateConfiguration}" + <h:commandButton type="submit" action="#{RawTestConfigurationUIBean.editConfiguration}" value="Edit this Configuration"/> </h:panelGrid> </h:form>
commit 8215954aefb1a23e492cbcaee04d628d247349ec Author: Adam Young ayoung@redhat.com Date: Fri Dec 18 10:37:49 2009 -0500
added toolbar in xhtml, removed it from tests, still broken
diff --git a/.classpath b/.classpath index a3aef1e..e53c4a4 100644 --- a/.classpath +++ b/.classpath @@ -189,7 +189,7 @@ <classpathentry exported="true" kind="var" path="M2_REPO/org/json/json/20080701/json-20080701.jar"/> <classpathentry exported="true" kind="var" path="M2_REPO/com/sun/jna/jna/3.0.1/jna-3.0.1.jar"/> <classpathentry exported="true" kind="var" path="M2_REPO/org/freemarker/freemarker/2.3.11/freemarker-2.3.11.jar"/> - <classpathentry exported="true" kind="var" path="M2_REPO/org/jboss/seam/jboss-seam/2.1.0.SP1/jboss-seam-2.1.0.SP1.jar"/> + <classpathentry exported="true" kind="var" path="M2_REPO/org/jboss/seam/jboss-seam/2.1.0.SP1/jboss-seam-2.1.0.SP1.jar" sourcepath="/M2_REPO/org/jboss/seam/jboss-seam/2.1.0.SP1/jboss-seam-2.1.0.SP1-sources.jar"/> <classpathentry exported="true" kind="var" path="M2_REPO/org/jboss/seam/jboss-seam-ui/2.1.0.SP1/jboss-seam-ui-2.1.0.SP1.jar"/> <classpathentry exported="true" kind="var" path="M2_REPO/hibernate/hibernate3/3.2.r14201-2/hibernate3-3.2.r14201-2.jar"/> <classpathentry exported="true" kind="var" path="M2_REPO/jline/jline/0.9.94/jline-0.9.94.jar"/> diff --git a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/AbstractConfigurationComponent.java b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/AbstractConfigurationComponent.java index e49ead1..5d5f894 100644 --- a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/AbstractConfigurationComponent.java +++ b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/AbstractConfigurationComponent.java @@ -24,6 +24,7 @@ package org.rhq.core.gui.configuration;
import java.util.UUID;
+import javax.el.ValueExpression; import javax.faces.component.UIComponent; import javax.faces.component.UIComponentBase; import javax.faces.context.FacesContext; @@ -59,6 +60,7 @@ public abstract class AbstractConfigurationComponent extends UIComponentBase imp private Boolean fullyEditable; private String listName; private Integer listIndex; + RawConfigUIComponent rawConfigUIComponent;
public UIComponent getToolbar() { return toolbar; @@ -87,6 +89,16 @@ public abstract class AbstractConfigurationComponent extends UIComponentBase imp
public abstract String getConfigurationExpressionString();
+ private ValueExpression saveValueExpression; + + public ValueExpression getSaveValueExpression() { + return saveValueExpression; + } + + public void setSaveValueExpression(ValueExpression saveValueExpression) { + this.saveValueExpression = saveValueExpression; + } + public String createUniqueId() { return UNIQUE_ID_PREFIX + UUID.randomUUID(); } @@ -215,10 +227,12 @@ public abstract class AbstractConfigurationComponent extends UIComponentBase imp
private Object[] stateValues;
+ public StructuredConfigUIComponent structuredConfig; + @Override public Object saveState(FacesContext facesContext) { if (this.stateValues == null) { - this.stateValues = new Object[8]; + this.stateValues = new Object[12]; }
this.stateValues[0] = super.saveState(facesContext); @@ -229,6 +243,12 @@ public abstract class AbstractConfigurationComponent extends UIComponentBase imp this.stateValues[5] = this.prevalidate; this.stateValues[6] = this.isGroup; this.stateValues[7] = this.getShowToolbar(); + if (rawConfigUIComponent != null) { + this.stateValues[8] = this.rawConfigUIComponent; + this.stateValues[9] = structuredConfig; + this.stateValues[10] = this.rawConfigUIComponent.saveState(facesContext); + this.stateValues[11] = this.structuredConfig.saveState(facesContext); + } return this.stateValues; }
@@ -243,20 +263,33 @@ public abstract class AbstractConfigurationComponent extends UIComponentBase imp this.prevalidate = (Boolean) this.stateValues[5]; this.isGroup = (Boolean) this.stateValues[6]; this.showToolbar = (Boolean) this.stateValues[7]; + + this.rawConfigUIComponent = (RawConfigUIComponent) this.stateValues[8]; + this.structuredConfig = (StructuredConfigUIComponent) this.stateValues[9]; + + if (this.rawConfigUIComponent != null) { + this.rawConfigUIComponent.restoreState(facesContext, this.stateValues[10]); + } + if (this.structuredConfig != null) { + this.structuredConfig.restoreState(facesContext, this.stateValues[11]); + } + + //getChildren().add(structuredConfig); + //getChildren().add(rawConfigUIComponent); + }
public boolean getShouldShowRaw() { return Boolean.valueOf(FacesContextUtility.getOptionalRequestParameter("showRaw", String.class, "unset")) - || (this.getConfigurationDefinition().getConfigurationFormat().equals(ConfigurationFormat.RAW)); + && (!this.getConfigurationDefinition().getConfigurationFormat().equals(ConfigurationFormat.STRUCTURED)); }
- RawConfigUIComponent rawConfigUIComponent; - RawConfigUIComponent getRawConfigUIComponent() { if (null == rawConfigUIComponent) { rawConfigUIComponent = new RawConfigUIComponent(getConfiguration(), getConfigurationDefinition(), this, isReadOnly()); } + return rawConfigUIComponent; }
diff --git a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/ConfigRenderer.java b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/ConfigRenderer.java index 278d619..be2feac 100644 --- a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/ConfigRenderer.java +++ b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/ConfigRenderer.java @@ -26,16 +26,12 @@ import java.io.IOException; import java.util.List; import java.util.Map;
-import javax.el.MethodExpression; import javax.el.ValueExpression; import javax.faces.application.FacesMessage; import javax.faces.component.UIComponent; import javax.faces.component.UIForm; import javax.faces.component.UIInput; -import javax.faces.component.UIOutput; -import javax.faces.component.UIPanel; import javax.faces.component.UIParameter; -import javax.faces.component.html.HtmlCommandLink; import javax.faces.component.html.HtmlForm; import javax.faces.component.html.HtmlOutputLink; import javax.faces.component.html.HtmlPanelGrid; @@ -51,18 +47,15 @@ import org.ajax4jsf.context.AjaxContext; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.richfaces.component.html.HtmlModalPanel; -import org.richfaces.component.html.HtmlSimpleTogglePanel;
import org.rhq.core.clientapi.agent.configuration.ConfigurationUtility; import org.rhq.core.domain.configuration.Property; import org.rhq.core.domain.configuration.PropertyList; import org.rhq.core.domain.configuration.PropertyMap; import org.rhq.core.domain.configuration.PropertySimple; -import org.rhq.core.domain.configuration.definition.ConfigurationFormat; import org.rhq.core.domain.configuration.definition.PropertyDefinition; import org.rhq.core.domain.configuration.definition.PropertyDefinitionMap; import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple; -import org.rhq.core.domain.configuration.definition.PropertyGroupDefinition; import org.rhq.core.gui.RequestParameterNameConstants; import org.rhq.core.gui.configuration.helper.PropertyRenderingUtility; import org.rhq.core.gui.configuration.propset.ConfigurationSetComponent; @@ -184,7 +177,9 @@ public class ConfigRenderer extends Renderer { addChildComponents(configurationComponent); if (configurationComponent.getToolbar() != null) { configurationComponent.getToolbar().setRendered(configurationComponent.getShowToolbar()); + } + }
private boolean isAjaxRefresh(AbstractConfigurationComponent configurationComponent) { @@ -270,113 +265,20 @@ public class ConfigRenderer extends Renderer { } }
- Boolean shouldShowRawNow = configurationComponent.getShouldShowRaw(); - - if (shouldShowRawNow) { - configurationComponent.getChildren().add( - new RawConfigUIComponent(configurationComponent.getConfiguration(), configurationComponent - .getConfigurationDefinition(), configurationComponent, configurationComponent.isReadOnly())); - } else { - addStructuredConfig(configurationComponent); - } - } - - private void addStructuredConfig(AbstractConfigurationComponent configurationComponent) { - { - UIPanel toolbarPanel = FacesComponentUtility.addBlockPanel(configurationComponent, configurationComponent, - "summary-props-table"); - if (configurationComponent.isReadOnly()) { - HtmlOutputLink editLink = FacesComponentUtility.addOutputLink(toolbarPanel, configurationComponent, - "edit.xhtml"); - FacesComponentUtility.addGraphicImage(editLink, configurationComponent, "/images/edit.png", "Edit"); - FacesComponentUtility.addOutputText(editLink, configurationComponent, "Edit", ""); - FacesComponentUtility.addParameter(editLink, configurationComponent, "readOnly", Boolean - .toString(false)); - FacesComponentUtility.addParameter(editLink, configurationComponent, "id", FacesContextUtility - .getRequiredRequestParameter("id")); - } else { - HtmlCommandLink saveLink = FacesComponentUtility.addCommandLink(toolbarPanel, configurationComponent); - FacesComponentUtility.addGraphicImage(saveLink, configurationComponent, "/images/save.png", "Save"); - FacesComponentUtility.addOutputText(saveLink, configurationComponent, "Save", ""); - FacesComponentUtility.addParameter(saveLink, configurationComponent, "save", Boolean.toString(true)); - FacesComponentUtility - .addParameter(saveLink, configurationComponent, "readOnly", Boolean.toString(true)); - - saveLink.setActionExpression(getSaveActionExpression()); - - } - if (configurationComponent.getConfigurationDefinition().getConfigurationFormat().isRawSupported()) { - HtmlCommandLink toRawLink = FacesComponentUtility.addCommandLink(toolbarPanel, configurationComponent); - FacesComponentUtility.addGraphicImage(toRawLink, configurationComponent, "/images/raw.png", "showRaw"); - FacesComponentUtility.addOutputText(toRawLink, configurationComponent, "showRaw", ""); - FacesComponentUtility.addParameter(toRawLink, configurationComponent, "showRaw", Boolean.TRUE - .toString()); - FacesComponentUtility.addParameter(toRawLink, configurationComponent, "readOnly", Boolean - .toString(configurationComponent.isReadOnly())); - } - configurationComponent.setToolbar(toolbarPanel); - } - - if (!configurationComponent.isReadOnly()) - addRequiredNotationsKey(configurationComponent); - - if (configurationComponent.getListName() != null) { - if (configurationComponent.getListIndex() == null) { - // No index specified means we should add a new map to the list. - configurationComponent.setListIndex(addNewMap(configurationComponent)); - } - - addListMemberProperty(configurationComponent); - } else { - addConfiguration(configurationComponent); - } - - String id = getInitInputsJavaScriptComponentId(configurationComponent); - PropertyRenderingUtility.addInitInputsJavaScript(configurationComponent, id, configurationComponent - .isFullyEditable(), false); - } - - private MethodExpression getSaveActionExpression() { - - MethodExpression actionExpression = null; - - return actionExpression; - } - - private void addStructuredRawToggle(AbstractConfigurationComponent configurationComponent, boolean showRaw) { - if (configurationComponent.getConfigurationDefinition().getConfigurationFormat().equals( - ConfigurationFormat.STRUCTURED_AND_RAW)) { + configurationComponent.rawConfigUIComponent = new RawConfigUIComponent(configurationComponent + .getConfiguration(), configurationComponent.getConfigurationDefinition(), configurationComponent, + configurationComponent.isReadOnly());
- HtmlPanelGroup toRawLinkPanel = FacesComponentUtility.addBlockPanel(configurationComponent, - configurationComponent, UNGROUPED_PROPERTIES_STYLE_CLASS); + configurationComponent.getChildren().add(configurationComponent.rawConfigUIComponent);
- FacesComponentUtility.addOutputText(toRawLinkPanel, configurationComponent, - "internationalized Message goes here", UNGROUPED_PROPERTIES_STYLE_CLASS); + configurationComponent.structuredConfig = new StructuredConfigUIComponent(configurationComponent);
- HtmlCommandLink commandLink = FacesComponentUtility.addCommandLink(toRawLinkPanel, configurationComponent); + configurationComponent.getChildren().add(configurationComponent.structuredConfig);
- UIOutput output = new UIOutput(); - output.setValue(showRaw ? "Show Structured" : " Show Raw"); - commandLink.getChildren().add(output); - //output.setParent(commandLink); - FacesComponentUtility.addParameter(commandLink, configurationComponent, "showRaw", Boolean - .toString(!showRaw)); - } - } - - private void addListMemberProperty(AbstractConfigurationComponent configurationComponent) { - // Update member Configurations if this is a group config. - if (configurationComponent instanceof ConfigurationSetComponent) { - ConfigurationSetComponent configurationSetComponent = ((ConfigurationSetComponent) configurationComponent); - configurationSetComponent.getConfigurationSet().applyGroupConfiguration(); - } + Boolean shouldShowRawNow = configurationComponent.getShouldShowRaw();
- // Now add a new component to the JSF component tree. - AbstractPropertyBagUIComponentTreeFactory propertyListUIComponentTreeFactory = new MapInListUIComponentTreeFactory( - configurationComponent, configurationComponent.getListName(), configurationComponent.getListIndex()); - HtmlPanelGroup propertiesPanel = FacesComponentUtility.addBlockPanel(configurationComponent, - configurationComponent, UNGROUPED_PROPERTIES_STYLE_CLASS); - propertiesPanel.getChildren().add(propertyListUIComponentTreeFactory.createUIComponentTree(null)); + configurationComponent.rawConfigUIComponent.setRendered(shouldShowRawNow); + configurationComponent.structuredConfig.setRendered(!shouldShowRawNow); }
private void deleteListMemberProperty(AbstractConfigurationComponent configurationComponent) { @@ -482,83 +384,6 @@ public class ConfigRenderer extends Renderer { + mapName + "'."); }
- private static void addRequiredNotationsKey(AbstractConfigurationComponent config) { - addDebug(config, true, ".addNotePanel()"); - HtmlPanelGroup footnotesPanel = FacesComponentUtility.addBlockPanel(config, config, NOTE_PANEL_STYLE_CLASS); - FacesComponentUtility.addOutputText(footnotesPanel, config, "*", REQUIRED_MARKER_TEXT_STYLE_CLASS); - FacesComponentUtility.addOutputText(footnotesPanel, config, " denotes a required field.", - FacesComponentUtility.NO_STYLE_CLASS); - if (config.isGroup()) { - HtmlPanelGroup overridePanel = FacesComponentUtility.addBlockPanel(config, config, NOTE_PANEL_STYLE_CLASS); - FacesComponentUtility.addOutputText(overridePanel, config, - "note: if override is not checked, that property will not be altered on any group members", - FacesComponentUtility.NO_STYLE_CLASS); - } - - addDebug(config, false, ".addNotePanel()"); - } - - private void addConfiguration(AbstractConfigurationComponent config) { - addNonGroupedProperties(config); - addGroupedProperties(config); - } - - private void addNonGroupedProperties(AbstractConfigurationComponent config) { - addDebug(config, true, ".addNonGroupedProperties()"); - HtmlPanelGroup propertiesPanel = FacesComponentUtility.addBlockPanel(config, config, - UNGROUPED_PROPERTIES_STYLE_CLASS); - AbstractPropertyBagUIComponentTreeFactory propertyListUIComponentTreeFactory = new GroupUIComponentTreeFactory( - config, GroupUIComponentTreeFactory.NO_GROUP); - propertiesPanel.getChildren().add(propertyListUIComponentTreeFactory.createUIComponentTree(null)); - addDebug(config, false, ".addNonGroupedProperties()"); - } - - private void addGroupedProperties(AbstractConfigurationComponent config) { - addDebug(config, true, ".addGroupedProperties()"); - List<PropertyGroupDefinition> groups = config.getConfigurationDefinition().getGroupDefinitions(); - for (PropertyGroupDefinition group : groups) { - HtmlSimpleTogglePanel groupPanel = addGroupPanel(config, group); - AbstractPropertyBagUIComponentTreeFactory propertyListUIComponentTreeFactory = new GroupUIComponentTreeFactory( - config, group.getName()); - groupPanel.getChildren().add(propertyListUIComponentTreeFactory.createUIComponentTree(null)); - } - - addDebug(config, false, ".addGroupedProperties()"); - } - - private HtmlSimpleTogglePanel addGroupPanel(AbstractConfigurationComponent config, PropertyGroupDefinition group) { - addDebug(config, true, ".addGroupPanel()"); - HtmlSimpleTogglePanel groupPanel = FacesComponentUtility.addSimpleTogglePanel(config, config, null); - // TODO: On AJAX requests, set "opened" attribute to its previous state. - groupPanel.setOpened(!group.isDefaultHidden()); - groupPanel.setHeaderClass(PROPERTY_GROUP_HEADER_STYLE_CLASS); - groupPanel.setBodyClass(PROPERTY_GROUP_BODY_STYLE_CLASS); - - // Custom header that includes the name and description - HtmlPanelGroup headerPanel = FacesComponentUtility.createBlockPanel(config, null); - FacesComponentUtility.addOutputText(headerPanel, config, group.getDisplayName(), null); - FacesComponentUtility - .addOutputText(headerPanel, config, group.getDescription(), "group-description-text-panel"); - groupPanel.getFacets().put("header", headerPanel); - - // custom "close" widget - HtmlPanelGroup closePanel = FacesComponentUtility.createBlockPanel(config, null); - closePanel.setStyle("text-align: right; font-weight: normal; font-size: 0.8em; whitespace: nowrap;"); - FacesComponentUtility.addGraphicImage(closePanel, config, "/images/ico_trigger_wht_collapse.gif", "collapse"); - FacesComponentUtility.addOutputText(closePanel, config, " Collapse", null); - groupPanel.getFacets().put("closeMarker", closePanel); - - // custom "open" widget - HtmlPanelGroup openPanel = FacesComponentUtility.createBlockPanel(config, null); - openPanel.setStyle("text-align: right; font-weight: normal; font-size: 0.8em; whitespace: nowrap;"); - FacesComponentUtility.addGraphicImage(openPanel, config, "/images/ico_trigger_wht_expand.gif", "expand"); - FacesComponentUtility.addOutputText(openPanel, config, " Expand", null); - groupPanel.getFacets().put("openMarker", openPanel); - addDebug(config, true, ".addGroupPanel()"); - - return groupPanel; - } - private void validateAttributes(AbstractConfigurationComponent configurationComponent) { // TODO: Add back attribute validation - remember config and configSet components require different attributes. /*if (configurationComponent.getValueExpression("configurationDefinition") == null) { @@ -572,7 +397,7 @@ public class ConfigRenderer extends Renderer { }*/ }
- private int addNewMap(AbstractConfigurationComponent config) { + static int addNewMap(AbstractConfigurationComponent config) { String listName = config.getListName(); PropertyDefinitionMap mapDefinition = (PropertyDefinitionMap) config.getConfigurationDefinition() .getPropertyDefinitionList(listName).getMemberDefinition(); @@ -597,7 +422,7 @@ public class ConfigRenderer extends Renderer { * @param start true if this is the "START" comment, false if it is the "END" comment * @param methodName the name of the method this is calling from */ - private static void addDebug(UIComponent component, boolean start, String methodName) { + static void addDebug(UIComponent component, boolean start, String methodName) { if (LOG.isDebugEnabled()) { StringBuilder msg = new StringBuilder("\n<!--"); msg.append(start ? " START " : " END "); @@ -608,7 +433,7 @@ public class ConfigRenderer extends Renderer { } }
- private String getInitInputsJavaScriptComponentId(AbstractConfigurationComponent configUIComponent) { + static String getInitInputsJavaScriptComponentId(AbstractConfigurationComponent configUIComponent) { return configUIComponent.getId() + INIT_INPUTS_JAVA_SCRIPT_COMPONENT_ID_SUFFIX; }
diff --git a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/RawConfigUIComponent.java b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/RawConfigUIComponent.java index 2c9a1be..5b86352 100644 --- a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/RawConfigUIComponent.java +++ b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/RawConfigUIComponent.java @@ -34,7 +34,7 @@ public class RawConfigUIComponent extends UIComponentBase { super.decode(context); setSelectedPath(FacesContextUtility.getOptionalRequestParameter("path")); readOnly = Boolean.valueOf(FacesContextUtility.getOptionalRequestParameter("readOnly")); - + this.inputTextarea.decode(context); }
@Override @@ -99,7 +99,7 @@ public class RawConfigUIComponent extends UIComponentBase {
UIPanel rawPanel = FacesComponentUtility.addBlockPanel(this, idFactory, "");
- addToolbar(configurationDefinition, rawPanel); + //addToolbar(configurationDefinition, rawPanel);
HtmlPanelGrid grid = FacesComponentUtility.addPanelGrid(rawPanel, idFactory, "summary-props-table"); grid.setParent(this); @@ -122,6 +122,14 @@ public class RawConfigUIComponent extends UIComponentBase { configPathList.add(raw.getPath()); rawMap.put(raw.getPath(), raw); } + + if (rawMap.isEmpty()) { + RawConfiguration raw = new RawConfiguration(); + raw.setContentString(""); + raw.setPath(""); + rawMap.put("", raw); + } + Collections.sort(configPathList); String oldDirname = ""; for (String s : configPathList) { @@ -140,12 +148,11 @@ public class RawConfigUIComponent extends UIComponentBase { FacesComponentUtility.addParameter(link, idFactory, "showRaw", Boolean.TRUE.toString()); readOnlyParms.add(FacesComponentUtility.addParameter(link, idFactory, AbstractConfigurationComponent.READ_ONLY_ATTRIBUTE, Boolean.toString(readOnly))); - }
UIPanel panelRight = FacesComponentUtility.addBlockPanel(grid, idFactory, "summary-props-table");
- UIPanel editPanel = FacesComponentUtility.addBlockPanel(panelRight, idFactory, "summary-props-table"); + editPanel = FacesComponentUtility.addBlockPanel(panelRight, idFactory, "summary-props-table"); inputTextarea = new HtmlInputTextarea(); editPanel.getChildren().add(inputTextarea); inputTextarea.setParent(editPanel); @@ -157,52 +164,8 @@ public class RawConfigUIComponent extends UIComponentBase {
private HtmlOutputLink fullscreenLink; private UIParameter fullScreenResourceIdParam; - - private void addToolbar(ConfigurationDefinition configurationDefinition, UIPanel parent) { - UIPanel toolbarPanel = FacesComponentUtility.addBlockPanel(parent, idFactory, "config-toolbar"); - if (readOnly) { - HtmlCommandLink editLink = FacesComponentUtility.addCommandLink(toolbarPanel, idFactory); - FacesComponentUtility.addGraphicImage(editLink, idFactory, "/images/edit.png", "Edit"); - FacesComponentUtility.addOutputText(editLink, idFactory, "Edit", ""); - FacesComponentUtility.addParameter(editLink, idFactory, "showRaw", Boolean.TRUE.toString()); - FacesComponentUtility.addParameter(editLink, idFactory, AbstractConfigurationComponent.READ_ONLY_ATTRIBUTE, - Boolean.FALSE.toString()); - } else { - HtmlCommandLink saveLink = FacesComponentUtility.addCommandLink(toolbarPanel, idFactory); - FacesComponentUtility.addGraphicImage(saveLink, idFactory, "/images/save.png", "Save"); - FacesComponentUtility.addOutputText(saveLink, idFactory, "Save", ""); - FacesComponentUtility.addParameter(saveLink, idFactory, "showRaw", Boolean.FALSE.toString()); - FacesComponentUtility.addParameter(saveLink, idFactory, AbstractConfigurationComponent.READ_ONLY_ATTRIBUTE, - Boolean.TRUE.toString()); - } - { - fullscreenLink = FacesComponentUtility.addOutputLink(toolbarPanel, idFactory, "view-full.xhtml"); - FacesComponentUtility - .addGraphicImage(fullscreenLink, idFactory, "/images/viewfullscreen.png", "FullScreen"); - FacesComponentUtility.addOutputText(fullscreenLink, idFactory, "Full Screen", ""); - fullScreenResourceIdParam = FacesComponentUtility.addParameter(fullscreenLink, idFactory, "id", ""); - } - if (!readOnly) { - HtmlOutputLink uploadLink = FacesComponentUtility.addOutputLink(toolbarPanel, idFactory, "upload.xhtml"); - FacesComponentUtility.addGraphicImage(uploadLink, idFactory, "/images/upload.png", "Upload"); - FacesComponentUtility.addOutputText(uploadLink, idFactory, "Upload", ""); - } - { - HtmlOutputLink downloadLink = FacesComponentUtility - .addOutputLink(toolbarPanel, idFactory, "download.xhtml"); - FacesComponentUtility.addGraphicImage(downloadLink, idFactory, "/images/download.png", "download"); - FacesComponentUtility.addOutputText(downloadLink, idFactory, "Download", ""); - } - if (configurationDefinition.getConfigurationFormat().isStructuredSupported()) { - HtmlCommandLink toStructureLink = FacesComponentUtility.addCommandLink(toolbarPanel, idFactory); - FacesComponentUtility.addGraphicImage(toStructureLink, idFactory, "/images/structured.png", - "showStructured"); - FacesComponentUtility.addOutputText(toStructureLink, idFactory, "showStructured", ""); - FacesComponentUtility.addParameter(toStructureLink, idFactory, "showRaw", Boolean.FALSE.toString()); - readOnlyParms.add(FacesComponentUtility.addParameter(toStructureLink, idFactory, "readOnly", Boolean - .toString(readOnly))); - } - } + public HtmlCommandLink saveLink; + private UIPanel editPanel;
@Override public void encodeBegin(FacesContext context) throws IOException { diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java index 2f11e11..44d005a 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java @@ -54,6 +54,30 @@ import org.rhq.enterprise.server.util.LookupUtil; public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUIBean { public static final String MANAGED_BEAN_NAME = "ExistingResourceConfigurationUIBean";
+ Boolean showRawConfig; + + public Boolean getShowRawConfig() { + if (null == showRawConfig) { + showRawConfig = this.getConfigurationDefinition().getConfigurationFormat().equals(ConfigurationFormat.RAW); + } + + return showRawConfig; + } + + public void setShowRawConfig(Boolean showRawConfig) { + this.showRawConfig = showRawConfig; + } + + public Boolean getShowRawButton() { + return !getShowRawConfig(); + //&& getConfigurationDefinition().getConfigurationFormat().equals(ConfigurationFormat.STRUCTURED_AND_RAW); + } + + public Boolean getShowStructuredButton() { + return getShowRawConfig(); + //&& getConfigurationDefinition().getConfigurationFormat().equals(ConfigurationFormat.STRUCTURED_AND_RAW); + } + private String selectedPath; private TreeMap<String, RawConfiguration> raws; private TreeMap<String, RawConfiguration> modified = new TreeMap<String, RawConfiguration>(); @@ -75,15 +99,6 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI return SUCCESS_OUTCOME; }
- public String switchToRaw() { - ConfigurationMaskingUtility.unmaskConfiguration(getConfiguration(), getConfigurationDefinition()); - int resourceId = EnterpriseFacesContextUtility.getResource().getId(); - this.configurationManager.translateResourceConfiguration(EnterpriseFacesContextUtility.getSubject(), - resourceId, getConfiguration(), true); - - return SUCCESS_OUTCOME; - } - public String updateConfiguration() {
modified = null; @@ -343,41 +358,53 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI * But is kept as a target for the "action" value */ public String upload() { - return "/rhq/resource/configuration/edit-raw.xhtml?currentResourceId=" + getResourceId(); + return "/rhq/resource/configuration/edit.xhtml?currentResourceId=" + getResourceId(); }
- public String switchToraw() { - Configuration configuration = LookupUtil.getConfigurationManager().translateResourceConfiguration( - EnterpriseFacesContextUtility.getSubject(), getResourceId(), getMergedConfiguration(), true); + public String switchToRaw() {
- setConfiguration(configuration); - for (RawConfiguration raw : configuration.getRawConfigurations()) { - getRaws().put(raw.getPath(), raw); - } - current = null; - setConfiguration(configuration); + try { + Configuration configuration; + configuration = LookupUtil.getConfigurationManager().translateResourceConfiguration( + EnterpriseFacesContextUtility.getSubject(), getResourceId(), getMergedConfiguration(), true);
- return "/rhq/resource/configuration/edit-raw.xhtml?currentResourceId=" + getResourceId(); - } - - public String switchTostructured() { + setConfiguration(configuration); + for (RawConfiguration raw : configuration.getRawConfigurations()) { + getRaws().put(raw.getPath(), raw); + } + current = null; + setConfiguration(configuration);
- Configuration configuration = LookupUtil.getConfigurationManager().translateResourceConfiguration( - EnterpriseFacesContextUtility.getSubject(), getResourceId(), getMergedConfiguration(), false); + setShowRawConfig(true);
- for (Property property : configuration.getAllProperties().values()) { - property.setConfiguration(configuration); + return "edit.xhtml?showRaw="true"&id=" + getResourceId(); + } catch (Exception e) { + return "overview.xhtml"; } + }
- for (RawConfiguration raw : configuration.getRawConfigurations()) { - getRaws().put(raw.getPath(), raw); + public String switchToStructured() { + try { + Configuration configuration = LookupUtil.getConfigurationManager().translateResourceConfiguration( + EnterpriseFacesContextUtility.getSubject(), getResourceId(), getMergedConfiguration(), false); + + for (Property property : configuration.getAllProperties().values()) { + property.setConfiguration(configuration); + } + + for (RawConfiguration raw : configuration.getRawConfigurations()) { + getRaws().put(raw.getPath(), raw); + setConfiguration(configuration); + } + current = null; setConfiguration(configuration); + setShowRawConfig(false); + + return "edit.xhtml?id=" + getResourceId(); + } catch (Exception e) { + return "overview.xhtml"; } - current = null; - setConfiguration(configuration);
-// return "/rhq/resource/configuration/edit.xhtml?currentResourceId=" + getResourceId(); - return SUCCESS_OUTCOME; }
void populateRaws() { diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/test/AbstractTestConfigurationUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/test/AbstractTestConfigurationUIBean.java index 4bbd064..f1ff041 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/test/AbstractTestConfigurationUIBean.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/test/AbstractTestConfigurationUIBean.java @@ -24,6 +24,7 @@ import java.util.UUID;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; + import org.rhq.core.domain.configuration.Configuration; import org.rhq.core.domain.configuration.Property; import org.rhq.core.domain.configuration.PropertySimple; @@ -36,7 +37,8 @@ import org.rhq.enterprise.gui.common.Outcomes; * @author Ian Springer */ public abstract class AbstractTestConfigurationUIBean { - public static final String [] LABELS = new String[] { "AAA", "ZZZ", "BBB", "YYY","AAA", "AAA", "ZZZ", "ZZZ", "YYY", "BBB"}; + public static final String[] LABELS = new String[] { "AAA", "ZZZ", "BBB", "YYY", "AAA", "AAA", "ZZZ", "ZZZ", "YYY", + "BBB" };
public static final int GROUP_SIZE = 100;
@@ -45,8 +47,7 @@ public abstract class AbstractTestConfigurationUIBean { private List<Property> properties; private ConfigurationSet configurationSet;
- protected AbstractTestConfigurationUIBean() - { + protected AbstractTestConfigurationUIBean() { this.configurationDefinition = TestConfigurationFactory.createConfigurationDefinition(); this.configuration = TestConfigurationFactory.createConfiguration(); List<ConfigurationSetMember> members = new ArrayList(GROUP_SIZE); @@ -58,8 +59,8 @@ public abstract class AbstractTestConfigurationUIBean { configuration.getSimple("Boolean").setStringValue(String.valueOf(i % 2 == 0)); if (i == 0) configuration.getMap("OpenMapOfSimples").put(new PropertySimple("PROCESSOR_CORES", "4")); - ConfigurationSetMember memberInfo = - new ConfigurationSetMember(LABELS[GROUP_SIZE % LABELS.length], configuration); + ConfigurationSetMember memberInfo = new ConfigurationSetMember(LABELS[GROUP_SIZE % LABELS.length], + configuration); members.add(memberInfo); } this.configurationSet = new ConfigurationSet(this.configurationDefinition, members); @@ -76,8 +77,7 @@ public abstract class AbstractTestConfigurationUIBean { return this.configurationDefinition; }
- public void setConfigurationDefinition(@NotNull - ConfigurationDefinition configurationDefinition) { + public void setConfigurationDefinition(@NotNull ConfigurationDefinition configurationDefinition) { this.configurationDefinition = configurationDefinition; }
@@ -86,26 +86,26 @@ public abstract class AbstractTestConfigurationUIBean { return this.configuration; }
- public void setConfiguration(@NotNull - Configuration configuration) { + public void setConfiguration(@NotNull Configuration configuration) { this.configuration = configuration; }
- public ConfigurationSet getConfigurationSet() - { + public ConfigurationSet getConfigurationSet() { return configurationSet; }
- public void setConfigurationSet(ConfigurationSet configurationSet) - { + public void setConfigurationSet(ConfigurationSet configurationSet) { this.configurationSet = configurationSet; }
- public List<Property> getProperties() - { + public List<Property> getProperties() { return this.properties; }
+ public void setProperties(@NotNull List<Property> properties) { + this.properties = properties; + } + public String getNullConfigurationDefinitionMessage() { return "Test config def is null (should never happen)."; } diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-managed-beans/test-beans.xml b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-managed-beans/test-beans.xml index 3ec6058..fbfad37 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-managed-beans/test-beans.xml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-managed-beans/test-beans.xml @@ -17,6 +17,14 @@ </managed-bean>
<managed-bean> + <managed-bean-name>RawTestConfigurationUIBean</managed-bean-name> + <managed-bean-class>org.rhq.enterprise.gui.configuration.test.RawTestConfigurationUIBean</managed-bean-class> + <managed-bean-scope>session</managed-bean-scope> + </managed-bean> + + + + <managed-bean> <managed-bean-name>AddNewOpenMapMemberPropertyToTestConfigurationUIBean</managed-bean-name> <managed-bean-class> org.rhq.enterprise.gui.configuration.test.EditTestConfigurationAddNewOpenMapMemberPropertyUIBean diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml index dffd02b..228e612 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml @@ -31,19 +31,47 @@ THIS TEXT WILL BE REMOVED.
<h:form id="editResourceConfigurationForm" onsubmit="prepareInputsForSubmission(this)" rendered="#{!ViewResourceConfigurationUIBean.updateInProgress}">
- - <input type="hidden" name="id" value="#{ResourceUIBean.id}"/> - - <h:outputText value="#{messages.youareviewingstructured}" /> - - <h:panelGroup rendered="#{ExistingResourceConfigurationUIBean.rawSupported}" > - <h:outputText value=" #{messages.switch2}" /> - <h:commandLink action="#{ExistingResourceConfigurationUIBean.switchToraw}" > - <f:param name="conversationId" value="#{conversation.id}"/> - <f:param name="id" value="#{ResourceUIBean.id}"/> - <h:outputText value=" files mode"/> - </h:commandLink> - </h:panelGroup> + <input type="hidden" name="id" value="#{ResourceUIBean.id}"/> + + <h:panelGroup> + <h:commandLink action="#{ExistingResourceConfigurationUIBean.updateConfiguration}"> + <h:graphicImage value="Save" url="/images/save.png" /> + <h:outputText value="Save Junk" /> + <f:param name="showRaw" value="true"/> + </h:commandLink> + + <h:commandLink rendered="#{ExistingResourceConfigurationUIBean.showRawButton}" action="#{ExistingResourceConfigurationUIBean.switchToRaw}" > + <h:graphicImage value="Raw" url="/images/raw.png" /> + <h:outputText value="Raw " /> + </h:commandLink> + + <h:commandLink rendered="#{ExistingResourceConfigurationUIBean.showStructuredButton}" action="#{ExistingResourceConfigurationUIBean.switchToStructured}"> + <h:graphicImage value="Structured" url="/images/structured.png" /> + <h:outputText value="Structured " /> + <f:param name="showRaw" value="false"/> + </h:commandLink> + + <h:outputLink value="fullscreen.xhtml"> + <h:graphicImage value="Full Screen" url="/images/viewfullscreen.png" /> + <h:outputText value="Full Screen" /> + <f:param name="showRaw" value="true"/> + </h:outputLink> + + <h:outputLink value="download.xhtml"> + <h:graphicImage value="Download" url="/images/download.png" /> + <h:outputText value="Download " /> + <f:param name="showRaw" value="false"/> + </h:outputLink> + + <h:outputLink value="upload.xhtml" rendered="#{!showReadOnly}"> + <h:graphicImage value="Upload" url="/images/upload.png" /> + <h:outputText value="Upload " /> + <f:param name="showRaw" value="false"/> + </h:outputLink> + + + </h:panelGroup> + <onc:config configurationDefinition="#{ExistingResourceConfigurationUIBean.configurationDefinition}" configuration="#{ExistingResourceConfigurationUIBean.configuration}" @@ -52,6 +80,7 @@ THIS TEXT WILL BE REMOVED. prevalidate="true" showToolbar="true" readOnly="false" + action="#{ExistingResourceConfigurationUIBean.updateRawConfiguration}" />
<h:panelGrid columns="2" styleClass="buttons-table" columnClasses="button-cell" rendered="#{ExistingResourceConfigurationUIBean.configuration != null}"> diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml index 40a917d..ea44edd 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml @@ -41,20 +41,56 @@ THIS TEXT WILL BE REMOVED. </h:panelGroup>
- <h:outputText value=" #{messages.nopermissionedit}" rendered="#{!ResourceUIBean.permissions.configure}"/> - <h:form id="viewResourceConfigurationForm"> <!-- TODO remove the id version --> <input type="hidden" name="id" value="#{ResourceUIBean.id}"/> - + + <ui:include src="/WEB-INF/fragments/config-view-toolbar.xhtml" /> + + <h:panelGroup> + <h:outputLink value="edit.xhtml"> + <h:graphicImage value="Edit" url="/images/edit.png" /> + <h:outputText value="Edit " /> + <f:param name="showRaw" value="#{showRawConfig}"/> + <f:param name="id" value="#{ResourceUIBean.id}"/> + </h:outputLink> + + <h:commandLink rendered="#{ExistingResourceConfigurationViewUIBean.showRawButton}"> + <h:graphicImage value="Raw" url="/images/raw.png" /> + <h:outputText value="Raw " /> + <f:param name="showRaw" value="true"/> + </h:commandLink> + + <h:commandLink rendered="#{ExistingResourceConfigurationViewUIBean.showStructuredButton}"> + <h:graphicImage value="Structured" url="/images/structured.png" /> + <h:outputText value="Structured " /> + <f:param name="showRaw" value="false"/> + </h:commandLink> + + <h:commandLink rendered="#{showRawConfig}"> + <h:graphicImage value="Full Screen" url="/images/viewfullscreen.png" /> + <h:outputText value="Full Screen" /> + <f:param name="showRaw" value="true"/> + </h:commandLink> + + <h:outputLink value="download.xhtml" rendered="#{showRawConfig}"> + <h:graphicImage value="Download" url="/images/download.png" /> + <h:outputText value="Download " /> + </h:outputLink> + + </h:panelGroup> + + + + <onc:config configurationDefinition="#{ExistingResourceConfigurationViewUIBean.configurationDefinition}" configuration="#{ExistingResourceConfigurationViewUIBean.configuration}" accessMapActionExpression="#{ExistingResourceConfigurationViewUIBean.accessMap}" nullConfigurationDefinitionMessage="#{ExistingResourceConfigurationViewUIBean.nullConfigurationDefinitionMessage}" nullConfigurationMessage="#{ExistingResourceConfigurationViewUIBean.nullConfigurationMessage}" readOnly="true" - showToolbar="true" - prevalidate="true"/> + prevalidate="true" + /> <input type="hidden" name="id" value="#{ResourceUIBean.id}"/>
</h:form> diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/edit.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/edit.xhtml index 1e4c156..da51088 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/edit.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/edit.xhtml @@ -37,7 +37,7 @@ THIS TEXT WILL BE REMOVED. accessMapActionExpression="#{RawTestConfigurationUIBean.accessMap}" readOnly="true" /> <h:panelGrid columns="1" styleClass="buttons-table" columnClasses="button-cell"> - <h:commandButton type="submit" action="#{RawTestConfigurationUIBean.editConfiguration}" + <h:commandButton type="submit" action="#{RawTestConfigurationUIBean.updateConfiguration}" value="Edit this Configuration"/> </h:panelGrid> </h:form>
commit 30d9312e87182ebcc711428585ba51da3c64f3c9 Author: Adam Young ayoung@redhat.com Date: Thu Dec 17 21:25:09 2009 -0500
Still broken. Major refactroing of the config renderer so that the structured config is contained inside a panel. Might have broken something not visible from the test. Still working on re-enabling the save.
diff --git a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/StructuredConfigUIComponent.java b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/StructuredConfigUIComponent.java new file mode 100644 index 0000000..c7aa459 --- /dev/null +++ b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/StructuredConfigUIComponent.java @@ -0,0 +1,146 @@ +package org.rhq.core.gui.configuration; + +import java.util.List; + +import javax.faces.component.UIComponent; +import javax.faces.component.UIPanel; +import javax.faces.component.html.HtmlPanelGroup; + +import org.richfaces.component.html.HtmlSimpleTogglePanel; + +import org.rhq.core.domain.configuration.definition.PropertyGroupDefinition; +import org.rhq.core.gui.configuration.helper.PropertyRenderingUtility; +import org.rhq.core.gui.configuration.propset.ConfigurationSetComponent; +import org.rhq.core.gui.util.FacesComponentIdFactory; +import org.rhq.core.gui.util.FacesComponentUtility; + +public class StructuredConfigUIComponent extends UIPanel { + + FacesComponentIdFactory idFactory; + boolean isGroup; + + public StructuredConfigUIComponent(AbstractConfigurationComponent configurationComponent) { + super(); + this.idFactory = configurationComponent; + this.isGroup = configurationComponent.isGroup(); + if (!configurationComponent.isReadOnly()) + addRequiredNotationsKey(); + + if (configurationComponent.getListName() != null) { + if (configurationComponent.getListIndex() == null) { + // No index specified means we should add a new map to the list. + configurationComponent.setListIndex(ConfigRenderer.addNewMap(configurationComponent)); + } + // Update member Configurations if this is a group config. + updateGroupMemberConfigurations(configurationComponent); + addListMemberProperty(configurationComponent, configurationComponent.getListIndex()); + } else { + addNonGroupedProperties(configurationComponent); + addGroupedProperties(configurationComponent); + } + String id = ConfigRenderer.getInitInputsJavaScriptComponentId(configurationComponent); + PropertyRenderingUtility.addInitInputsJavaScript(this, id, configurationComponent.isFullyEditable(), false); + } + + public void addRequiredNotationsKey() { + ConfigRenderer.addDebug(this, true, ".addNotePanel()"); + HtmlPanelGroup footnotesPanel = FacesComponentUtility.addBlockPanel(this, idFactory, + ConfigRenderer.NOTE_PANEL_STYLE_CLASS); + FacesComponentUtility.addOutputText(footnotesPanel, idFactory, "*", + ConfigRenderer.REQUIRED_MARKER_TEXT_STYLE_CLASS); + FacesComponentUtility.addOutputText(footnotesPanel, idFactory, " denotes a required field.", + FacesComponentUtility.NO_STYLE_CLASS); + if (isGroup) { + HtmlPanelGroup overridePanel = FacesComponentUtility.addBlockPanel(this, idFactory, + ConfigRenderer.NOTE_PANEL_STYLE_CLASS); + FacesComponentUtility.addOutputText(overridePanel, idFactory, + "note: if override is not checked, that property will not be altered on any group members", + FacesComponentUtility.NO_STYLE_CLASS); + } + ConfigRenderer.addDebug(this, false, ".addNotePanel()"); + } + + @Override + public String getFamily() { + // TODO Auto-generated method stub + return "rhq"; + } + + private void addListMemberProperty(AbstractConfigurationComponent configurationComponent, Integer listIndex) { + HtmlPanelGroup propertiesPanel = FacesComponentUtility.addBlockPanel(this, idFactory, + ConfigRenderer.UNGROUPED_PROPERTIES_STYLE_CLASS); + propertiesPanel.getChildren() + .add( + new MapInListUIComponentTreeFactory(configurationComponent, configurationComponent.getListName(), + listIndex).createUIComponentTree(null)); + } + + private void updateGroupMemberConfigurations(AbstractConfigurationComponent configurationComponent) { + if (configurationComponent instanceof ConfigurationSetComponent) { + ConfigurationSetComponent configurationSetComponent = ((ConfigurationSetComponent) configurationComponent); + configurationSetComponent.getConfigurationSet().applyGroupConfiguration(); + } + } + + void addGroupedProperties(AbstractConfigurationComponent config) { + ConfigRenderer.addDebug(config, true, ".addGroupedProperties()"); + List<PropertyGroupDefinition> groups = config.getConfigurationDefinition().getGroupDefinitions(); + for (PropertyGroupDefinition group : groups) { + HtmlSimpleTogglePanel groupPanel = addGroupPanel(group); + AbstractPropertyBagUIComponentTreeFactory propertyListUIComponentTreeFactory = new GroupUIComponentTreeFactory( + config, group.getName()); + groupPanel.getChildren().add(propertyListUIComponentTreeFactory.createUIComponentTree(null)); + } + + ConfigRenderer.addDebug(config, false, ".addGroupedProperties()"); + } + + void addNonGroupedProperties(AbstractConfigurationComponent config) { + + ConfigRenderer.addDebug(this, true, ".addNonGroupedProperties()"); + HtmlPanelGroup propertiesPanel = FacesComponentUtility.addBlockPanel(this, idFactory, + ConfigRenderer.UNGROUPED_PROPERTIES_STYLE_CLASS); + AbstractPropertyBagUIComponentTreeFactory propertyListUIComponentTreeFactory = new GroupUIComponentTreeFactory( + config, GroupUIComponentTreeFactory.NO_GROUP); + + UIComponent createUIComponentTree = propertyListUIComponentTreeFactory.createUIComponentTree(null); + propertiesPanel.getChildren().add(createUIComponentTree); + + ConfigRenderer.addDebug(this, false, ".addNonGroupedProperties()"); + } + + HtmlSimpleTogglePanel addGroupPanel(PropertyGroupDefinition group) { + ConfigRenderer.addDebug(this, true, ".addGroupPanel()"); + HtmlSimpleTogglePanel groupPanel = FacesComponentUtility.addSimpleTogglePanel(this, idFactory, null); + // TODO: On AJAX requests, set "opened" attribute to its previous state. + groupPanel.setOpened(!group.isDefaultHidden()); + groupPanel.setHeaderClass(ConfigRenderer.PROPERTY_GROUP_HEADER_STYLE_CLASS); + groupPanel.setBodyClass(ConfigRenderer.PROPERTY_GROUP_BODY_STYLE_CLASS); + + // Custom header that includes the name and description + HtmlPanelGroup headerPanel = FacesComponentUtility.createBlockPanel(idFactory, null); + FacesComponentUtility.addOutputText(headerPanel, idFactory, group.getDisplayName(), null); + FacesComponentUtility.addOutputText(headerPanel, idFactory, group.getDescription(), + "group-description-text-panel"); + groupPanel.getFacets().put("header", headerPanel); + + // custom "close" widget + HtmlPanelGroup closePanel = FacesComponentUtility.createBlockPanel(idFactory, null); + closePanel.setStyle("text-align: right; font-weight: normal; font-size: 0.8em; whitespace: nowrap;"); + FacesComponentUtility + .addGraphicImage(closePanel, idFactory, "/images/ico_trigger_wht_collapse.gif", "collapse"); + FacesComponentUtility.addOutputText(closePanel, idFactory, " Collapse", null); + groupPanel.getFacets().put("closeMarker", closePanel); + + // custom "open" widget + HtmlPanelGroup openPanel = FacesComponentUtility.createBlockPanel(idFactory, null); + openPanel.setStyle("text-align: right; font-weight: normal; font-size: 0.8em; whitespace: nowrap;"); + FacesComponentUtility.addGraphicImage(openPanel, idFactory, "/images/ico_trigger_wht_expand.gif", "expand"); + FacesComponentUtility.addOutputText(openPanel, idFactory, " Expand", null); + groupPanel.getFacets().put("openMarker", openPanel); + ConfigRenderer.addDebug(this, true, ".addGroupPanel()"); + + return groupPanel; + } + +} diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/test/RawTestConfigurationUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/test/RawTestConfigurationUIBean.java new file mode 100644 index 0000000..919a4ad --- /dev/null +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/test/RawTestConfigurationUIBean.java @@ -0,0 +1,82 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2008 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +package org.rhq.enterprise.gui.configuration.test; + +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +import javax.faces.application.FacesMessage; + +import org.rhq.core.domain.configuration.Configuration; +import org.rhq.core.domain.configuration.Property; +import org.rhq.core.domain.configuration.PropertySimple; +import org.rhq.core.domain.configuration.RawConfiguration; +import org.rhq.core.domain.configuration.definition.ConfigurationFormat; +import org.rhq.core.gui.configuration.propset.ConfigurationSet; +import org.rhq.core.gui.configuration.propset.ConfigurationSetMember; +import org.rhq.core.gui.util.FacesContextUtility; +import org.rhq.enterprise.gui.common.Outcomes; + +/** + * @author Ian Springer + */ +public class RawTestConfigurationUIBean extends AbstractTestConfigurationUIBean { + public RawTestConfigurationUIBean() { + setConfigurationDefinition(TestConfigurationFactory.createConfigurationDefinition()); + setConfiguration(TestConfigurationFactory.createConfiguration()); + List<ConfigurationSetMember> members = new ArrayList(GROUP_SIZE); + for (int i = 0; i < GROUP_SIZE; i++) { + Configuration configuration = getConfiguration().deepCopy(true); + configuration.setId(i + 1); + configuration.getSimple("String1").setStringValue(UUID.randomUUID().toString()); + configuration.getSimple("Integer").setStringValue(String.valueOf(i + 1)); + configuration.getSimple("Boolean").setStringValue(String.valueOf(i % 2 == 0)); + if (i == 0) + configuration.getMap("OpenMapOfSimples").put(new PropertySimple("PROCESSOR_CORES", "4")); + ConfigurationSetMember memberInfo = new ConfigurationSetMember(LABELS[GROUP_SIZE % LABELS.length], + configuration); + members.add(memberInfo); + } + setConfigurationSet(new ConfigurationSet(getConfigurationDefinition(), members)); + // Unwrap the Hibernate proxy objects, which Facelets appears not to be able to handle. + setProperties(new ArrayList<Property>(this.getConfiguration().getProperties())); + + getConfigurationDefinition().setConfigurationFormat(ConfigurationFormat.STRUCTURED_AND_RAW); + + RawConfiguration rawConfiguration = new RawConfiguration(); + rawConfiguration.setPath("/tmp/nowhere.txt"); + rawConfiguration.setContents("A=1".getBytes()); + getConfiguration().addRawConfiguration(rawConfiguration); + + } + + public static final String MANAGED_BEAN_NAME = RawTestConfigurationUIBean.class.getSimpleName(); + protected static final String SUCCESS_OUTCOME = "success"; + protected static final String FAILURE_OUTCOME = "failure"; + + public String updateConfiguration() { + // Any values changed in the group config (i.e. via the inputs on the main page) need to be + // applied to all member configs before persisting them. + //getConfigurationSet().applyGroupConfiguration(); + // TODO (low priority): Persist the test config somewhere. + FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO, "Configuration updated."); + return Outcomes.SUCCESS; + } +} \ No newline at end of file diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/edit.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/edit.xhtml new file mode 100644 index 0000000..1e4c156 --- /dev/null +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/edit.xhtml @@ -0,0 +1,51 @@ +<?xml version="1.0"?> + +<!DOCTYPE html + PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<html xmlns="http://www.w3.org/1999/xhtml" + xmlns:h="http://java.sun.com/jsf/html" + xmlns:f="http://java.sun.com/jsf/core" + xmlns:ui="http://java.sun.com/jsf/facelets" + xmlns:rich="http://richfaces.ajax4jsf.org/rich" + xmlns:onc="http://jboss.org/on/component%22%3E + +THIS TEXT WILL BE REMOVED. + +<ui:composition template="/rhq/layout/main.xhtml"> + + THIS TEXT WILL BE REMOVED AS WELL. + + <ui:param name="pageTitle" value="Test Raw Configuration"/> + + <ui:define name="body"> + + <h:messages showSummary="true" + showDetail="true" + errorClass="ErrorBlock" + warnClass="ErrorBlock" + infoClass="ConfirmationBlock" + globalOnly="true" + layout="table" + width="100%"/> + + <h:form id="viewTestConfigurationForm"> + + <onc:config configurationDefinition="#{RawTestConfigurationUIBean.configurationDefinition}" + configuration="#{RawTestConfigurationUIBean.configuration}" + accessMapActionExpression="#{RawTestConfigurationUIBean.accessMap}" + readOnly="true" /> + <h:panelGrid columns="1" styleClass="buttons-table" columnClasses="button-cell"> + <h:commandButton type="submit" action="#{RawTestConfigurationUIBean.editConfiguration}" + value="Edit this Configuration"/> + </h:panelGrid> + </h:form> + + </ui:define> + +</ui:composition> + +THIS TEXT WILL BE REMOVED AS WELL. + +</html> diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/view.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/view.xhtml new file mode 100644 index 0000000..c543ca7 --- /dev/null +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/view.xhtml @@ -0,0 +1,52 @@ +<?xml version="1.0"?> + +<!DOCTYPE html + PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<html xmlns="http://www.w3.org/1999/xhtml" + xmlns:h="http://java.sun.com/jsf/html" + xmlns:f="http://java.sun.com/jsf/core" + xmlns:ui="http://java.sun.com/jsf/facelets" + xmlns:rich="http://richfaces.ajax4jsf.org/rich" + xmlns:onc="http://jboss.org/on/component%22%3E + +THIS TEXT WILL BE REMOVED. + +<ui:composition template="/rhq/layout/main.xhtml"> + + THIS TEXT WILL BE REMOVED AS WELL. + + <ui:param name="pageTitle" value="Test Raw Configuration"/> + + <ui:define name="body"> + + <h:messages showSummary="true" + showDetail="true" + errorClass="ErrorBlock" + warnClass="ErrorBlock" + infoClass="ConfirmationBlock" + globalOnly="true" + layout="table" + width="100%"/> + + <h:form id="viewTestConfigurationForm"> + + <onc:config configurationDefinition="#{RawTestConfigurationUIBean.configurationDefinition}" + configuration="#{RawTestConfigurationUIBean.configuration}" + accessMapActionExpression="#{RawTestConfigurationUIBean.accessMap}" + readOnly="true" + showToolbar="true" /> + <h:panelGrid columns="1" styleClass="buttons-table" columnClasses="button-cell"> + <h:commandButton type="submit" action="#{RawTestConfigurationUIBean.editConfiguration}" + value="Edit this Configuration"/> + </h:panelGrid> + </h:form> + + </ui:define> + +</ui:composition> + +THIS TEXT WILL BE REMOVED AS WELL. + +</html>
commit cfef08f3e2709d21eff761d8079bb5e587e78346 Merge: f33274d... a100923... Author: Justin Harris jharris@redhat.com Date: Thu Dec 17 12:37:45 2009 -0500
Merge branch 'alertPlugin'
commit a100923bbf28491cad34f211e34a7f85cdad070e Author: John Mazzitelli mazz@redhat.com Date: Thu Dec 17 01:22:00 2009 -0500
loadPlugin now throws exception if there is something wrong with the plugin it also only validates the plugin when enabled is true - disabled plugins do not need to validate since they won't be started reuse the superclass' instantiatePluginClass
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/AlertSenderPluginManager.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/AlertSenderPluginManager.java index dbfb1f3..acd9550 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/AlertSenderPluginManager.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/AlertSenderPluginManager.java @@ -63,81 +63,89 @@ public class AlertSenderPluginManager extends ServerPluginManager { * in the super class. * Here we verify that the passed <plugin-class> is valid and build the * list of plugins that can be queried by the UI etc. + * * @param env the environment of the plugin to be loaded - * - * @throws Exception + * @param enabled if <code>true</code>, the plugin is to be enabled and will be started soon + * + * @throws Exception if the alert plugin could not be loaded due to errors such as the alert class being invalid */ @Override - public void loadPlugin(ServerPluginEnvironment env, boolean enable) throws Exception { - log.debug("Start loading alert plugin " + env.getPluginKey().getPluginName()); - super.loadPlugin(env, enable); + public void loadPlugin(ServerPluginEnvironment env, boolean enabled) throws Exception {
- AlertPluginDescriptorType type = (AlertPluginDescriptorType) env.getPluginDescriptor(); + super.loadPlugin(env, enabled);
- String className = type.getPluginClass(); - try { - loadPluginClass(env, className, false); - } catch (Exception e) { - log.error("Can't find pluginClass [" + className + "]. Plugin [" + env.getPluginKey().getPluginName() - + "] will be ignored. Cause: " + ThrowableUtil.getAllMessages(e)); - try { - unloadPlugin(env.getPluginKey().getPluginName()); - } catch (Throwable t) { - log.warn(" +--> unload failed too. Cause: " + ThrowableUtil.getAllMessages(t)); - } - return; - } - - // The short name is basically the key into the plugin - String shortName = type.getShortName(); - pluginClassByName.put(shortName, className); - - // - // Ok, we have a valid plugin class, so we can look for other things - // and store the info - // + if (enabled) {
- String uiSnippetPath; - URL uiSnippetUrl = null; - CustomUi customUI = type.getCustomUi(); - if (customUI != null) { - uiSnippetPath = customUI.getUiSnippetName(); + AlertPluginDescriptorType type = (AlertPluginDescriptorType) env.getPluginDescriptor();
+ // make sure the alert sender class name is valid + String className = type.getPluginClass(); try { - uiSnippetUrl = env.getPluginClassLoader().getResource(uiSnippetPath); - log.info("Alert plugin UI snipped for [" + shortName + "] is at: " + uiSnippetUrl); + loadPluginClass(env, className, false); } catch (Exception e) { - log.error("No valid ui snippet provided, but <custom-ui> given for sender plugin " + shortName - + "Error is " + e.getMessage()); - log.error("Plugin will be ignored"); - return; + log.error("Alert sender class [" + className + "] defined in plugin [" + + env.getPluginKey().getPluginName() + "] is invalid and will be ignored. Cause: " + + ThrowableUtil.getAllMessages(e)); + try { + unloadPlugin(env.getPluginKey().getPluginName()); + } catch (Throwable t) { + log.warn(" +--> unload failed too. Cause: " + ThrowableUtil.getAllMessages(t)); + } + throw e; }
- // Get the backing bean class - className = customUI.getBackingBeanName(); - if (!className.contains(".")) { - className = type.getPackage() + "." + className; + // + // Ok, we have a valid plugin class, so we can look for other things and store the info + // + + // The short name is basically the key into the plugin + String shortName = type.getShortName(); + pluginClassByName.put(shortName, className); + + // UI snippet path allows the plugin to inject user interface fragments to the alert pages + String uiSnippetPath; + URL uiSnippetUrl = null; + CustomUi customUI = type.getCustomUi(); + if (customUI != null) { + uiSnippetPath = customUI.getUiSnippetName(); + + try { + uiSnippetUrl = env.getPluginClassLoader().getResource(uiSnippetPath); + if (uiSnippetUrl == null) { + throw new Exception("plugin is missing alert ui snippet named [" + uiSnippetPath + "]"); + } + log.debug("Alert plugin UI snippet for [" + shortName + "] is at: " + uiSnippetUrl); + } catch (Exception e) { + log.error("Invalid alert UI snippet provided inside <custom-ui> for alert plugin [" + shortName + + "]. Plugin will be ignored. Cause: " + ThrowableUtil.getAllMessages(e)); + throw e; + } + + // Get the backing bean class + className = customUI.getBackingBeanName(); + try { + loadPluginClass(env, className, true); // TODO how make this available to Seam and the Web-CL ? + backingBeanByName.put(shortName, className); + } catch (Throwable t) { + String errMsg = "Backing bean [" + className + "] not found for plugin [" + shortName + ']'; + log.error(errMsg); + throw new Exception(errMsg, t); + } } - try { - loadPluginClass(env, className, true); // TODO how make this available to Seam and the Web-CL ? - backingBeanByName.put(shortName, className); - } catch (Throwable t) { - log.error("Backing bean [" + className + "] not found for plugin [" + shortName + ']'); - } - } - - AlertSenderInfo info = new AlertSenderInfo(shortName, type.getDescription(), env.getPluginKey()); - info.setUiSnippetUrl(uiSnippetUrl); - senderInfoByName.put(shortName, info);
- pluginEnvByName.put(shortName, env); + AlertSenderInfo info = new AlertSenderInfo(shortName, type.getDescription(), env.getPluginKey()); + info.setUiSnippetUrl(uiSnippetUrl); + senderInfoByName.put(shortName, info);
+ pluginEnvByName.put(shortName, env); + } }
@Override protected void unloadPlugin(String pluginName) throws Exception { - log.info("Unloading plugin " + pluginName); + super.unloadPlugin(pluginName); + String shortName = null; for (AlertSenderInfo info : senderInfoByName.values()) { if (info.getPluginName().equals(pluginName)) { @@ -145,10 +153,13 @@ public class AlertSenderPluginManager extends ServerPluginManager { break; } } - pluginClassByName.remove(shortName); - senderInfoByName.remove(shortName); - pluginEnvByName.remove(shortName); - backingBeanByName.remove(shortName); + + if (shortName != null) { + pluginClassByName.remove(shortName); + senderInfoByName.remove(shortName); + pluginEnvByName.remove(shortName); + backingBeanByName.remove(shortName); + } }
/** @@ -163,29 +174,18 @@ public class AlertSenderPluginManager extends ServerPluginManager { String senderName = notification.getSenderName(); String className = pluginClassByName.get(senderName); if (className == null) { - log.error("getAlertSender: No pluginClass found for sender: " + senderName); + log.error("getAlertSenderForNotification: No pluginClass found for sender: " + senderName); return null; } ServerPluginEnvironment env = pluginEnvByName.get(senderName); - Class<?> clazz; + AlertSender sender; try { - clazz = loadPluginClass(env, className, true); + sender = (AlertSender) instantiatePluginClass(env, className); } catch (Exception e) { log.error(e); // TODO return null; }
- AlertSender sender; - try { - sender = (AlertSender) clazz.newInstance(); - } catch (InstantiationException e) { - e.printStackTrace(); // TODO: Customise this generated block - return null; - } catch (IllegalAccessException e) { - e.printStackTrace(); // TODO: Customise this generated block - return null; - } - // We have no entityManager lying around here, which means // Configuration is an uninitialized Proxy and we'd get a LazyInit // Exception later. @@ -227,20 +227,13 @@ public class AlertSenderPluginManager extends ServerPluginManager { }
public AlertBackingBean getBackingBeanForSender(String shortName) { - String name = backingBeanByName.get(shortName); + String className = backingBeanByName.get(shortName); ServerPluginEnvironment env = pluginEnvByName.get(shortName); - Class<?> clazz; - try { - clazz = loadPluginClass(env, name, true); - } catch (Exception e) { - log.error("Can't load class " + name + ": " + e.getMessage()); - return null; - } AlertBackingBean bean = null; try { - bean = (AlertBackingBean) clazz.newInstance(); + bean = (AlertBackingBean) instantiatePluginClass(env, className); } catch (Exception e) { - log.error("Can't instantiate " + name + ": " + e.getMessage()); + log.error("Can't instantiate alert sender backing bean [" + className + "]. Cause: " + e.getMessage()); } return bean; }
commit fc2c98d30c7dc532cd9cbc0ef5b213d1f6a567a6 Author: John Mazzitelli mazz@redhat.com Date: Thu Dec 17 01:17:39 2009 -0500
remove the unnecessary delegate methods - don't think we need them right now
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/AlertServerPluginContainer.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/AlertServerPluginContainer.java index b7e65a0..c4aca5e 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/AlertServerPluginContainer.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/AlertServerPluginContainer.java @@ -42,32 +42,6 @@ public class AlertServerPluginContainer extends AbstractTypeServerPluginContaine }
@Override - public ServerPluginManager getPluginManager() { - return super.getPluginManager(); // TODO: Customise this generated block - } - - @Override - public void initialize() throws Exception { - super.initialize(); // TODO: Customise this generated block - } - - @Override - public void start() { - super.start(); // TODO: Customise this generated block - } - - @Override - public synchronized void stop() { - super.stop(); // TODO: Customise this generated block - } - - @Override - public void shutdown() { - //getPluginManager().un - super.shutdown(); // TODO: Customise this generated block - } - - @Override protected ServerPluginManager createPluginManager() { return new AlertSenderPluginManager(this); }
commit 23ddc6a48e3bb4112226feeb6711b4a3b22cb6e6 Author: John Mazzitelli mazz@redhat.com Date: Thu Dec 17 00:29:27 2009 -0500
workaround what is probably a bug or poor defensive programming in the irc 3rd party lib if the irc bot failed to connect, some internal fields are still null thus causing an NPE if you call dispose. wrap the call to dispose to catch any exception in order to complete our shutdown method
diff --git a/modules/enterprise/server/plugins/alert-irc/src/main/java/org/rhq/enterprise/server/plugins/alertIrc/IrcAlertComponent.java b/modules/enterprise/server/plugins/alert-irc/src/main/java/org/rhq/enterprise/server/plugins/alertIrc/IrcAlertComponent.java index 13c910b..7f43570 100644 --- a/modules/enterprise/server/plugins/alert-irc/src/main/java/org/rhq/enterprise/server/plugins/alertIrc/IrcAlertComponent.java +++ b/modules/enterprise/server/plugins/alert-irc/src/main/java/org/rhq/enterprise/server/plugins/alertIrc/IrcAlertComponent.java @@ -23,9 +23,11 @@ package org.rhq.enterprise.server.plugins.alertIrc;
import java.util.Arrays; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jibble.pircbot.PircBot; + import org.rhq.core.domain.configuration.Configuration; import org.rhq.enterprise.server.plugin.pc.ServerPluginComponent; import org.rhq.enterprise.server.plugin.pc.ServerPluginContext; @@ -88,8 +90,13 @@ public class IrcAlertComponent implements ServerPluginComponent { }
public void shutdown() { - this.ircBot.dispose(); - this.ircBot = null; + try { + this.ircBot.dispose(); + } catch (Exception e) { + log.warn("Failed to dispose of the IRC bot object: " + e.getMessage()); + } finally { + this.ircBot = null; + } }
/** @@ -116,7 +123,7 @@ public class IrcAlertComponent implements ServerPluginComponent { this.ircBot.joinChannel(channel); }
- return new String[]{channel}; + return new String[] { channel }; } else { return this.ircBot.getChannels(); } @@ -148,8 +155,7 @@ public class IrcAlertComponent implements ServerPluginComponent { * @param message */ @Override - public void onMessage(String channel, String sender, String login, - String hostname, String message) { + public void onMessage(String channel, String sender, String login, String hostname, String message) {
if (this.response != null && message.startsWith(nick)) { if (channel != null && channel.length() > 0) {
commit 25b8d852aee2d361ad322b86dfb47e589b4c4ab2 Author: John Mazzitelli mazz@redhat.com Date: Thu Dec 17 00:27:32 2009 -0500
trivial - just stub out delegator method for stop
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/AlertServerPluginContainer.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/AlertServerPluginContainer.java index 3de6d0d..b7e65a0 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/AlertServerPluginContainer.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/AlertServerPluginContainer.java @@ -43,23 +43,28 @@ public class AlertServerPluginContainer extends AbstractTypeServerPluginContaine
@Override public ServerPluginManager getPluginManager() { - return super.getPluginManager(); // TODO: Customise this generated block + return super.getPluginManager(); // TODO: Customise this generated block }
@Override public void initialize() throws Exception { - super.initialize(); // TODO: Customise this generated block + super.initialize(); // TODO: Customise this generated block }
@Override public void start() { - super.start(); // TODO: Customise this generated block + super.start(); // TODO: Customise this generated block + } + + @Override + public synchronized void stop() { + super.stop(); // TODO: Customise this generated block }
@Override public void shutdown() { //getPluginManager().un - super.shutdown(); // TODO: Customise this generated block + super.shutdown(); // TODO: Customise this generated block }
@Override
commit 102d91c377a1b6f48bcefa34a0c47a63dac56d29 Author: John Mazzitelli mazz@redhat.com Date: Thu Dec 17 00:10:46 2009 -0500
add alert server plugin sources and deps to eclipse classpath
diff --git a/.classpath b/.classpath index 8844225..d9f559e 100644 --- a/.classpath +++ b/.classpath @@ -54,6 +54,12 @@ <classpathentry kind="src" path="modules/enterprise/server/plugins/rhnhosted/src/main/java"/> <classpathentry kind="src" path="modules/enterprise/server/plugins/rhnhosted/src/test/java"/> <classpathentry kind="src" path="modules/enterprise/server/plugins/rhnhosted/target/classes/generated-source"/> + <classpathentry kind="src" path="modules/enterprise/server/plugins/alert-email/src/main/java"/> + <classpathentry kind="src" path="modules/enterprise/server/plugins/alert-roles/src/main/java"/> + <classpathentry kind="src" path="modules/enterprise/server/plugins/alert-snmp/src/main/java"/> + <classpathentry kind="src" path="modules/enterprise/server/plugins/alert-irc/src/main/java"/> + <classpathentry kind="src" path="modules/enterprise/server/plugins/alert-microblog/src/main/java"/> + <classpathentry kind="src" path="modules/enterprise/server/plugins/alert-mobicents/src/main/java"/> <classpathentry kind="src" path="modules/enterprise/gui/portal-war/src/main/java"/> <classpathentry kind="src" path="modules/enterprise/gui/portal-war/src/test/java"/> <classpathentry kind="src" path="modules/enterprise/gui/installer-war/src/main/java"/> @@ -89,8 +95,8 @@ <classpathentry kind="src" path="modules/plugins/samba/src/test/java"/> <classpathentry kind="src" path="modules/plugins/sudoers/src/main/java"/> <classpathentry kind="src" path="modules/plugins/sudoers/src/test/java"/> - <classpathentry kind="src" path="modules/plugins/postfix/src/main/java"/> - <classpathentry kind="src" path="modules/plugins/postfix/src/test/java"/> + <classpathentry kind="src" path="modules/plugins/postfix/src/main/java"/> + <classpathentry kind="src" path="modules/plugins/postfix/src/test/java"/> <classpathentry kind="src" path="modules/plugins/cron/src/main/java"/> <classpathentry kind="src" path="modules/plugins/hudson/src/main/java"/> <classpathentry kind="src" path="modules/plugins/platform/src/test/java"/> @@ -103,11 +109,11 @@ <classpathentry kind="src" path="modules/plugins/script/src/main/java"/> <classpathentry kind="src" path="modules/plugins/antlr-config/src/main/antlr3"/> <classpathentry kind="src" path="modules/plugins/antlr-config/target/generated-sources/antlr3"/> + <classpathentry kind="src" path="modules/plugins/augeas/src/main/java"/> + <classpathentry kind="src" path="modules/plugins/augeas/src/test/java"/> <classpathentry kind="src" path="modules/helpers/rtfilter/src/main/java"/> <classpathentry kind="src" path="modules/helpers/pluginAnnotations/src/main/java"/> <classpathentry kind="src" path="modules/helpers/pluginGen/src/main/java"/> - <classpathentry kind="src" path="modules/plugins/augeas/src/main/java"/> - <classpathentry kind="src" path="modules/plugins/augeas/src/test/java"/> <classpathentry kind="src" path="etc/samples/skeleton-plugin/src/main/java"/> <classpathentry kind="src" path="etc/samples/custom-serverplugin/src/main/java"/> <classpathentry kind="src" path="etc/samples/simplereport-serverplugin/src/main/java"/> @@ -202,6 +208,8 @@ <classpathentry exported="true" kind="var" path="M2_REPO/org/antlr/antlr-runtime/3.2/antlr-runtime-3.2.jar"/> <classpathentry exported="true" kind="var" path="M2_REPO/commons-digester/commons-digester/1.8/commons-digester-1.8.jar"/> <classpathentry exported="true" kind="var" path="M2_REPO/commons-codec/commons-codec/1.4/commons-codec-1.4.jar"/> + <classpathentry exported="true" kind="var" path="M2_REPO/pircbot/pircbot/1.4.2/pircbot-1.4.2.jar"/> + <classpathentry exported="true" kind="var" path="M2_REPO/net/homeip/yusuke/twitter4j/2.0.9/twitter4j-2.0.9.jar"/> <classpathentry exported="true" kind="lib" path="modules/enterprise/remoting/webservices/target/rhq-remoting-webservices-1.4.0-SNAPSHOT/wsconsume-output"/> <classpathentry kind="output" path="eclipse-classes"/> </classpath>
commit 962cb01970b9d2238624f4cb7068ac04fa2cd2a3 Author: John Mazzitelli mazz@redhat.com Date: Wed Dec 16 23:49:47 2009 -0500
add method to load plugin class for subclasses to use
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ServerPluginManager.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ServerPluginManager.java index e86e687..768162f 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ServerPluginManager.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ServerPluginManager.java @@ -184,7 +184,7 @@ public class ServerPluginManager { Thread.currentThread().setContextClassLoader(env.getPluginClassLoader()); component.initialize(context); } catch (Throwable t) { - throw new Exception("Plugin component failed to initialize server plugin", t); + throw new Exception("Plugin component failed to initialize server plugin [" + pluginName + "]", t); } finally { Thread.currentThread().setContextClassLoader(originalContextClassLoader); } @@ -284,13 +284,13 @@ public class ServerPluginManager { // tell the plugin we are unloading it ServerPluginComponent component = this.pluginComponentCache.get(pluginName); if (component != null) { - log.debug("Shutting down plugin componentfor server plugin [" + pluginName + "]"); + log.debug("Shutting down plugin component for server plugin [" + pluginName + "]"); ClassLoader originalContextClassLoader = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(env.getPluginClassLoader()); component.shutdown(); } catch (Throwable t) { - throw new Exception("Plugin plugin componentfailed to initialize plugin", t); + throw new Exception("Plugin component failed to shutdown server plugin [" + pluginName + "]", t); } finally { Thread.currentThread().setContextClassLoader(originalContextClassLoader); this.pluginComponentCache.remove(pluginName); @@ -512,6 +512,38 @@ public class ServerPluginManager { }
/** + * Loads a class with the given name within the given environment's classloader. + * The class will only be initialized if <code>initialize</code> is <code>true</code>. + * + * @param environment the environment that has the classloader where the class will be loaded + * @param className the class to load + * @param initialize whether the class must be initialized + * @return the new class that has been loaded + * @throws Exception if failed to load the class + */ + protected Class<?> loadPluginClass(ServerPluginEnvironment environment, String className, boolean initialize) + throws Exception { + + ClassLoader loader = environment.getPluginClassLoader(); + + ServerPluginDescriptorType descriptor = environment.getPluginDescriptor(); + className = ServerPluginDescriptorMetadataParser.getFullyQualifiedClassName(descriptor, className); + + log.debug("Loading server plugin class [" + className + "]..."); + + try { + Class<?> clazz = Class.forName(className, initialize, loader); + log.debug("Loaded server plugin class [" + clazz + "]. initialized=[" + initialize + ']'); + return clazz; + } catch (ClassNotFoundException e) { + throw new Exception("Could not find plugin class [" + className + "] from plugin environment [" + + environment + "]", e); + } catch (NullPointerException npe) { + throw new Exception("Plugin class was 'null' in plugin environment [" + environment + "]", npe); + } + } + + /** * Instantiates a class with the given name within the given environment's classloader using * the class' no-arg constructor. * @@ -521,14 +553,9 @@ public class ServerPluginManager { * @throws Exception if failed to instantiate the class */ protected Object instantiatePluginClass(ServerPluginEnvironment environment, String className) throws Exception { - - ClassLoader loader = environment.getPluginClassLoader(); - - log.debug("Loading server plugin class [" + className + "]..."); - try { - Class<?> clazz = Class.forName(className, true, loader); - log.debug("Loaded server plugin class [" + clazz + "]."); + Class<?> clazz = loadPluginClass(environment, className, true); + log.debug("Instantiating server plugin class [" + clazz + "]"); return clazz.newInstance(); } catch (InstantiationException e) { throw new Exception("Could not instantiate plugin class [" + className + "] from plugin environment [" @@ -536,11 +563,6 @@ public class ServerPluginManager { } catch (IllegalAccessException e) { throw new Exception("Could not access plugin class [" + className + "] from plugin environment [" + environment + "]", e); - } catch (ClassNotFoundException e) { - throw new Exception("Could not find plugin class [" + className + "] from plugin environment [" - + environment + "]", e); - } catch (NullPointerException npe) { - throw new Exception("Plugin class was 'null' in plugin environment [" + environment + "]", npe); } } } diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/AlertSenderPluginManager.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/AlertSenderPluginManager.java index cd4e072..dbfb1f3 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/AlertSenderPluginManager.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/AlertSenderPluginManager.java @@ -30,6 +30,7 @@ import org.rhq.core.domain.alert.notification.AlertNotification; import org.rhq.core.domain.configuration.Configuration; import org.rhq.core.domain.plugin.PluginKey; import org.rhq.core.domain.plugin.ServerPlugin; +import org.rhq.core.util.exception.ThrowableUtil; import org.rhq.enterprise.server.alert.AlertNotificationManagerLocal; import org.rhq.enterprise.server.plugin.ServerPluginsLocal; import org.rhq.enterprise.server.plugin.pc.AbstractTypeServerPluginContainer; @@ -68,24 +69,21 @@ public class AlertSenderPluginManager extends ServerPluginManager { */ @Override public void loadPlugin(ServerPluginEnvironment env, boolean enable) throws Exception { - log.info("Start loading alert plugin " + env.getPluginKey().getPluginName()); + log.debug("Start loading alert plugin " + env.getPluginKey().getPluginName()); super.loadPlugin(env, enable);
AlertPluginDescriptorType type = (AlertPluginDescriptorType) env.getPluginDescriptor();
String className = type.getPluginClass(); - if (!className.contains(".")) { - className = type.getPackage() + "." + className; - } try { - Class.forName(className, false, env.getPluginClassLoader()); + loadPluginClass(env, className, false); } catch (Exception e) { - log.error("Can't find pluginClass " + className + ". Plugin " + env.getPluginKey().getPluginName() - + " will be ignored"); + log.error("Can't find pluginClass [" + className + "]. Plugin [" + env.getPluginKey().getPluginName() + + "] will be ignored. Cause: " + ThrowableUtil.getAllMessages(e)); try { unloadPlugin(env.getPluginKey().getPluginName()); } catch (Throwable t) { - log.warn(" +--> unload failed too " + t.getMessage()); + log.warn(" +--> unload failed too. Cause: " + ThrowableUtil.getAllMessages(t)); } return; } @@ -107,7 +105,7 @@ public class AlertSenderPluginManager extends ServerPluginManager {
try { uiSnippetUrl = env.getPluginClassLoader().getResource(uiSnippetPath); - log.info("UI snipped for " + shortName + " is at " + uiSnippetUrl); + log.info("Alert plugin UI snipped for [" + shortName + "] is at: " + uiSnippetUrl); } catch (Exception e) { log.error("No valid ui snippet provided, but <custom-ui> given for sender plugin " + shortName + "Error is " + e.getMessage()); @@ -121,10 +119,10 @@ public class AlertSenderPluginManager extends ServerPluginManager { className = type.getPackage() + "." + className; } try { - Class.forName(className, true, env.getPluginClassLoader()); // TODO how make this available to Seam and the Web-CL ? + loadPluginClass(env, className, true); // TODO how make this available to Seam and the Web-CL ? backingBeanByName.put(shortName, className); } catch (Throwable t) { - log.error("Backing bean " + className + " not found for plugin " + shortName); + log.error("Backing bean [" + className + "] not found for plugin [" + shortName + ']'); } }
@@ -169,9 +167,9 @@ public class AlertSenderPluginManager extends ServerPluginManager { return null; } ServerPluginEnvironment env = pluginEnvByName.get(senderName); - Class clazz; + Class<?> clazz; try { - clazz = Class.forName(className, true, env.getPluginClassLoader()); + clazz = loadPluginClass(env, className, true); } catch (Exception e) { log.error(e); // TODO return null; @@ -231,9 +229,9 @@ public class AlertSenderPluginManager extends ServerPluginManager { public AlertBackingBean getBackingBeanForSender(String shortName) { String name = backingBeanByName.get(shortName); ServerPluginEnvironment env = pluginEnvByName.get(shortName); - Class clazz; + Class<?> clazz; try { - clazz = Class.forName(name, true, env.getPluginClassLoader()); + clazz = loadPluginClass(env, name, true); } catch (Exception e) { log.error("Can't load class " + name + ": " + e.getMessage()); return null;
commit 3f95647a3db1bf733540e4646d1cad511248c66d Author: John Mazzitelli mazz@redhat.com Date: Wed Dec 16 17:00:22 2009 -0500
when a server plugin is updated, retain the original data. note: problems may occur if metadata changed, should probably try to fix that in the future
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsBean.java index f3ac46b..35f3fec 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsBean.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsBean.java @@ -422,6 +422,11 @@ public class ServerPluginsBean implements ServerPluginsLocal { } ServerPlugin obsolete = ServerPluginDescriptorUtil.determineObsoletePlugin(plugin, existingPlugin); if (obsolete == existingPlugin) { // yes use == for reference equality + + // in order to keep the same configuration that the old plugin had, let's set the new plugin's config objects + // TODO: what happens if the plugin's metadata changes? we should clean the old config of old properties. + plugin.setPluginConfiguration(existingPlugin.getPluginConfiguration()); + plugin.setScheduledJobsConfiguration(existingPlugin.getScheduledJobsConfiguration()); newOrUpdated = true; } plugin.setId(existingPlugin.getId());
commit 23bf08f5d43f9a29ff25300dbc6887098874dcf7 Author: John Mazzitelli mazz@redhat.com Date: Wed Dec 16 16:56:13 2009 -0500
fix the plugin config ui 1) be able to get back to the details page from any selected tree node 2) do not enable a plugin after changing config - in HA mode this won't work as you'd expect 3) put the edit button at the top in addition to the bottom so its easy to get to
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/plugin/EditPluginConfigurationUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/plugin/EditPluginConfigurationUIBean.java index f85269f..34b24a6 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/plugin/EditPluginConfigurationUIBean.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/plugin/EditPluginConfigurationUIBean.java @@ -21,7 +21,9 @@ package org.rhq.enterprise.gui.admin.plugin; import java.io.Serializable; import java.util.ArrayList; import java.util.List; + import javax.faces.application.FacesMessage; + import org.jboss.seam.ScopeType; import org.jboss.seam.annotations.Create; import org.jboss.seam.annotations.In; @@ -30,6 +32,7 @@ import org.jboss.seam.annotations.Name; import org.jboss.seam.annotations.Scope; import org.jboss.seam.annotations.web.RequestParameter; import org.jboss.seam.log.Log; + import org.rhq.core.domain.auth.Subject; import org.rhq.core.domain.configuration.Configuration; import org.rhq.core.domain.configuration.definition.ConfigurationDefinition; @@ -105,17 +108,27 @@ public class EditPluginConfigurationUIBean extends AbstractPluginConfigurationUI try { ServerPluginsLocal serverPlugins = LookupUtil.getServerPlugins(); Subject subject = EnterpriseFacesContextUtility.getSubject(); - serverPlugins.updateServerPluginExceptContent(subject, getPlugin());
- // rekick the updated plugin so that any config changes take effect - serverPlugins.disableServerPlugins(subject, getPluginIdList()); - serverPlugins.enableServerPlugins(subject, getPluginIdList()); + ServerPlugin plugin = serverPlugins.updateServerPluginExceptContent(subject, getPlugin()); + setPlugin(plugin); + + // the config has changed. we would like to restart the plugin, but we would need to ensure + // ALL servers in the rhq server cloud restart. today we have no easy way to inform all servers + // that they should do this. So, for now, disable the plugin (since if it is running, it is doing + // so with a now-invalid configuration. Let the user go in and re-enable the plugin later. + // TODO: right now, if the user re-enables the plugin too fast, some of the other servers + // will not have seen the state change and won't restart the plugin. Need a way to do this... + // perhaps use the mtime column to denote that state changed (this would affect whether or not + // the plugin needs to be upgraded, so we need to be careful re-using the mtime column for this purpose). + if (plugin.isEnabled()) { + serverPlugins.disableServerPlugins(subject, getPluginIdList()); + }
FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO, "Configuration settings saved."); } catch (Exception e) { log.error("Error updating the plugin configurations.", e); FacesContextUtility.addMessage(FacesMessage.SEVERITY_ERROR, - "There was an error changing the configuration settings.", e); + "There was an error changing the configuration settings.", e);
return null; } diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/plugin/plugin-config.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/plugin/plugin-config.xhtml index f0cca1b..8bf0a28 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/plugin/plugin-config.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/plugin/plugin-config.xhtml @@ -30,6 +30,10 @@ <h:outputText value="Server Settings"/> </h:outputLink> > + <h:outputLink value="plugin-list.xhtml" > + ${msg["manage-plugins.installed-plugins.breadcrumb"]} + </h:outputLink> + > <h:outputLink value="plugin-config.xhtml"> <h:outputText value="Server Plugins Configuration"/> </h:outputLink> @@ -76,6 +80,36 @@ </rich:panel>
<h:panelGroup id="pluginConfig"> + <rich:panel id="detailsLink" + style="background: #EEEEEE;" + rendered="#{pluginConfigUIBean.plugin != null}" > + <h:outputText value="See the " /> + <h:outputLink value="/rhq/admin/plugin/plugin-details.xhtml"> + <f:param name="plugin" value="#{pluginConfigUIBean.plugin.name}"/> + <f:param name="deployment" value="#{pluginConfigUIBean.plugin.deployment}"/> + <f:param name="pluginType" value="#{pluginConfigUIBean.plugin.type}"/> + <h:outputText value="'#{pluginConfigUIBean.plugin.displayName}' details page"/> + </h:outputLink> + <h:outputText value=" for more plugin information." /> + </rich:panel> + + <rich:panel id="noConfigMessage" + style="background: #EEEEEE;" + rendered="#{not pluginConfigUIBean.editable and pluginConfigUIBean.plugin != null}" > + <h:outputText escape="true" value="Plugin '#{pluginConfigUIBean.plugin.displayName}' has no configuration." /> + </rich:panel> + + <rich:panel id="pluginButtonsTopPanel" rendered="#{pluginConfigUIBean.editable}"> + <h:panelGroup id="pluginButtonsTop"> + <h:outputLink value="/rhq/admin/plugin/plugin-edit.xhtml" styleClass="buttonmed"> + <f:param name="plugin" value="#{pluginConfigUIBean.plugin.name}"/> + <f:param name="deployment" value="#{pluginConfigUIBean.plugin.deployment}"/> + <f:param name="pluginType" value="#{pluginConfigUIBean.plugin.type}"/> + <h:outputText value="EDIT"/> + </h:outputLink> + </h:panelGroup> + </rich:panel> + <rich:panel rendered="#{pluginConfigUIBean.plugin.pluginConfiguration != null}"> <f:facet name="header"> <h:outputText value="Plugin Configuration"/> @@ -94,30 +128,17 @@ readOnly="true" /> </rich:panel>
- <rich:panel id="noConfigMessage" - rendered="#{not pluginConfigUIBean.editable and pluginConfigUIBean.plugin != null}" - style="background: #EEEEEE;"> - <h:outputText escape="true" value="#{pluginConfigUIBean.plugin.displayName} has no configuration. " /> - <br /> - <br /> - <h:outputText value="See the " /> - <h:outputLink value="/rhq/admin/plugin/plugin-details.xhtml"> - <f:param name="plugin" value="#{pluginConfigUIBean.plugin.name}"/> - <f:param name="deployment" value="#{pluginConfigUIBean.plugin.deployment}"/> - <f:param name="pluginType" value="#{pluginConfigUIBean.plugin.type}"/> - <h:outputText value="#{pluginConfigUIBean.plugin.displayName} details page"/> - </h:outputLink> - <h:outputText value=" for more plugin information." /> + <rich:panel id="pluginButtonsBottomPanel" rendered="#{pluginConfigUIBean.editable}"> + <h:panelGroup id="pluginButtonsBottom"> + <h:outputLink value="/rhq/admin/plugin/plugin-edit.xhtml" styleClass="buttonmed"> + <f:param name="plugin" value="#{pluginConfigUIBean.plugin.name}"/> + <f:param name="deployment" value="#{pluginConfigUIBean.plugin.deployment}"/> + <f:param name="pluginType" value="#{pluginConfigUIBean.plugin.type}"/> + <h:outputText value="EDIT"/> + </h:outputLink> + </h:panelGroup> </rich:panel>
- <h:panelGroup id="pluginButtons" rendered="#{pluginConfigUIBean.editable}"> - <h:outputLink value="/rhq/admin/plugin/plugin-edit.xhtml" styleClass="buttonmed"> - <f:param name="plugin" value="#{pluginConfigUIBean.plugin.name}"/> - <f:param name="deployment" value="#{pluginConfigUIBean.plugin.deployment}"/> - <f:param name="pluginType" value="#{pluginConfigUIBean.plugin.type}"/> - <h:outputText value="EDIT"/> - </h:outputLink> - </h:panelGroup> </h:panelGroup> </h:panelGrid> </h:form>
commit e6eda24d7b38af940a7f9f4dd1c01c9695c87f29 Author: John Mazzitelli mazz@redhat.com Date: Wed Dec 16 15:33:37 2009 -0500
fix the error checking code for scanning dropbox
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/plugin/PluginDeploymentScanner.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/plugin/PluginDeploymentScanner.java index 7ec0020..9f22d2c 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/plugin/PluginDeploymentScanner.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/plugin/PluginDeploymentScanner.java @@ -204,21 +204,25 @@ public class PluginDeploymentScanner implements PluginDeploymentScannerMBean { File destinationDirectory; if (file.getName().endsWith(".jar")) { try { - AgentPluginDescriptorUtil.loadPluginDescriptorFromUrl(file.toURI().toURL()); + if (null == AgentPluginDescriptorUtil.loadPluginDescriptorFromUrl(file.toURI().toURL())) { + throw new NullPointerException("no xml descriptor found in jar"); + } destinationDirectory = getAgentPluginDir(); } catch (Exception e) { try { log.debug("[" + file.getAbsolutePath() + "] is not an agent plugin jar (Cause: " + ThrowableUtil.getAllMessages(e) + "). Will see if its a server plugin jar");
- ServerPluginDescriptorUtil.loadPluginDescriptorFromUrl(file.toURI().toURL()); + if (null == ServerPluginDescriptorUtil.loadPluginDescriptorFromUrl(file.toURI().toURL())) { + throw new NullPointerException("no xml descriptor found in jar"); + } destinationDirectory = getServerPluginDir(); } catch (Exception e1) { // skip it, doesn't look like a valid plugin jar File fixmeFile = new File(file.getAbsolutePath() + ".fixme"); boolean renamed = file.renameTo(fixmeFile); log.warn("Does not look like [" + (renamed ? fixmeFile : file).getAbsolutePath() - + "] is a plugin jar -(Cause: " + ThrowableUtil.getAllMessages(e) + + "] is a plugin jar -(Cause: " + ThrowableUtil.getAllMessages(e1) + "). It will be ignored. Please fix that file or remove it."); continue; }
commit 7b8e679d0d7007e9322b528087071bdbfe805abd Author: Heiko W. Rupp pilhuhn@fedorapeople.org Date: Wed Dec 16 21:15:07 2009 +0100
Return the status id for a successful status update.
diff --git a/modules/enterprise/server/plugins/alert-microblog/src/main/java/org/rhq/enterprise/server/plugins/alertMicroblog/MicroblogSender.java b/modules/enterprise/server/plugins/alert-microblog/src/main/java/org/rhq/enterprise/server/plugins/alertMicroblog/MicroblogSender.java index e95b6f0..cf7136b 100644 --- a/modules/enterprise/server/plugins/alert-microblog/src/main/java/org/rhq/enterprise/server/plugins/alertMicroblog/MicroblogSender.java +++ b/modules/enterprise/server/plugins/alert-microblog/src/main/java/org/rhq/enterprise/server/plugins/alertMicroblog/MicroblogSender.java @@ -18,6 +18,7 @@ */ package org.rhq.enterprise.server.plugins.alertMicroblog;
+import twitter4j.Status; import twitter4j.Twitter; import twitter4j.TwitterException;
@@ -61,8 +62,8 @@ public class MicroblogSender extends AlertSender {
SenderResult result ; try { - twitter.updateStatus(b.toString()); - result = new SenderResult(ResultState.SUCCESS,"Send notification to " + baseUrl + " as user " + user); + Status status = twitter.updateStatus(b.toString()); + result = new SenderResult(ResultState.SUCCESS,"Send notification to " + baseUrl + " as user " + user + " id: " + status.getId()); } catch (TwitterException e) { log.warn("Notification via Microblog failed: ", e); result = new SenderResult(ResultState.FAILURE,"Sending failed :" + e.getMessage());
commit 7969a2e17abd15898ad4cb598490dda50cc045b6 Merge: 989b5a2... b68a663... Author: Heiko W. Rupp pilhuhn@fedorapeople.org Date: Wed Dec 16 21:14:16 2009 +0100
Merge branch 'alertPlugin' of ssh://git.fedorahosted.org/git/rhq/rhq into alertPlugin
commit b68a66338f9b216c525851df7aa638c6f113a89a Author: John Mazzitelli mazz@redhat.com Date: Wed Dec 16 15:10:02 2009 -0500
opps.. show not show the link if plugin is undeployed, but still show if its just disabled
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/plugin/plugin-list.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/plugin/plugin-list.xhtml index bca336f..230098e 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/plugin/plugin-list.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/plugin/plugin-list.xhtml @@ -162,13 +162,13 @@ <h:outputText styleClass="headerText" value="Name"/> </f:facet>
- <h:outputLink value="/rhq/admin/plugin/plugin-details-view.xhtml" rendered="#{serverPlugin.enabled}"> + <h:outputLink value="/rhq/admin/plugin/plugin-details-view.xhtml" rendered="#{serverPlugin.status eq 'INSTALLED'}"> <f:param name="plugin" value="#{serverPlugin.name}"/> <f:param name="deployment" value="SERVER"/> <f:param name="pluginType" value="#{serverPlugin.type}"/> <h:outputText value="#{serverPlugin.displayName}"/> </h:outputLink> - <h:outputText value="#{serverPlugin.displayName}" rendered="#{!serverPlugin.enabled}"/> + <h:outputText value="#{serverPlugin.displayName}" rendered="#{serverPlugin.status ne 'INSTALLED'}"/>
</rich:column>
commit f33274d83b86b881088cbb6ffe93578714153497 Author: Partha Aji paji@redhat.com Date: Wed Dec 16 13:04:48 2009 -0500
Remote apt dependencies from maven pom's since apt got moved to /etc
diff --git a/modules/enterprise/server/ear/pom.xml b/modules/enterprise/server/ear/pom.xml index a622266..92d255c 100644 --- a/modules/enterprise/server/ear/pom.xml +++ b/modules/enterprise/server/ear/pom.xml @@ -232,12 +232,6 @@
<artifactItem> <groupId>org.rhq</groupId> - <artifactId>rhq-apt-plugin</artifactId> - <version>${project.version}</version> - </artifactItem> - - <artifactItem> - <groupId>org.rhq</groupId> <artifactId>rhq-augeas-plugin</artifactId> <version>${project.version}</version> </artifactItem> diff --git a/modules/plugins/validate-all-plugins/pom.xml b/modules/plugins/validate-all-plugins/pom.xml index e668600..287ccd1 100644 --- a/modules/plugins/validate-all-plugins/pom.xml +++ b/modules/plugins/validate-all-plugins/pom.xml @@ -39,7 +39,6 @@ <classpath> <pathelement path="${test.classpath}" /> <pathelement location="../apache/target/rhq-apache-plugin-${project.version}.jar" /> - <pathelement location="../apt/target/rhq-apt-plugin-${project.version}.jar" /> <pathelement location="../augeas/target/rhq-augeas-plugin-${project.version}.jar" /> <pathelement location="../database/target/rhq-database-plugin-${project.version}.jar" /> <pathelement location="../grub/target/rhq-grub-plugin-${project.version}.jar" />
commit 3375f7f7725d2a25beac33cbd43277e622623ef8 Author: John Mazzitelli mazz@redhat.com Date: Wed Dec 16 13:00:18 2009 -0500
indent to match the rest of the file
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml index 53a8895..ccca4f1 100644 --- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml +++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml @@ -2162,43 +2162,44 @@ <!-- add the new column that indicates what type of plugin this is (e.g. alert, generic, content) - for server plugins only --> <schema-addColumn table="RHQ_PLUGIN" column="PTYPE" columnType="VARCHAR2" precision="200"/> </schemaSpec> - <schemaSpec version="2.70"> - <schema-addColumn table="RHQ_ALERT" column="ACK_TIME" columnType="LONG" /> - <schema-addColumn table="RHQ_ALERT" column="ACK_BY_ID" columnType="INTEGER" /> - <schema-directSQL> - <statement> - ALTER TABLE RHQ_ALERT - ADD CONSTRAINT RHQ_ALERT_SUBJECT_ID_FKEY - FOREIGN KEY (ACK_BY_ID) - REFERENCES RHQ_SUBJECT(ID) - </statement> - </schema-directSQL> - <schema-addColumn table="RHQ_ALERT_NOTIFICATION" column="ALERT_SENDER_NAME" columnType="VARCHAR2"/> - <schema-addColumn table="RHQ_ALERT_NOTIFICATION" column="ALERT_CONFIG_ID" columnType="INTEGER"/> - <schema-directSQL> - <statement> - ALTER TABLE RHQ_ALERT_NOTIFICATION - ADD CONSTRAINT RHQ_ALERT_CONFIG_ID_FKEY - FOREIGN KEY (ALERT_CONFIG_ID) - REFERENCES RHQ_CONFIG(ID) - </statement> - </schema-directSQL> - - </schemaSpec> - <schemaSpec version="2.70.1"> - <schema-directSQL> - <statement> - CREATE TABLE RHQ_ALERT_NOTIF_TEMPL ( ID INTEGER ) - </statement> - <statement> - ALTER TABLE RHQ_ALERT_NOTIF_TEMPL - ADD CONSTRAINT RHQ_ALERT_NOTIF_TEMPL_KEY - PRIMARY KEY ( ID ) - </statement> - </schema-directSQL> - <schema-addColumn table="RHQ_ALERT_NOTIF_TEMPL" column="NAME" columnType="VARCHAR2"/> - <schema-addColumn table="RHQ_ALERT_NOTIF_TEMPL" column="DESCRIPTION" columnType="VARCHAR2"/> - </schemaSpec> + + <schemaSpec version="2.70"> + <schema-addColumn table="RHQ_ALERT" column="ACK_TIME" columnType="LONG" /> + <schema-addColumn table="RHQ_ALERT" column="ACK_BY_ID" columnType="INTEGER" /> + <schema-directSQL> + <statement> + ALTER TABLE RHQ_ALERT + ADD CONSTRAINT RHQ_ALERT_SUBJECT_ID_FKEY + FOREIGN KEY (ACK_BY_ID) + REFERENCES RHQ_SUBJECT(ID) + </statement> + </schema-directSQL> + <schema-addColumn table="RHQ_ALERT_NOTIFICATION" column="ALERT_SENDER_NAME" columnType="VARCHAR2"/> + <schema-addColumn table="RHQ_ALERT_NOTIFICATION" column="ALERT_CONFIG_ID" columnType="INTEGER"/> + <schema-directSQL> + <statement> + ALTER TABLE RHQ_ALERT_NOTIFICATION + ADD CONSTRAINT RHQ_ALERT_CONFIG_ID_FKEY + FOREIGN KEY (ALERT_CONFIG_ID) + REFERENCES RHQ_CONFIG(ID) + </statement> + </schema-directSQL> + </schemaSpec> + + <schemaSpec version="2.70.1"> + <schema-directSQL> + <statement> + CREATE TABLE RHQ_ALERT_NOTIF_TEMPL ( ID INTEGER ) + </statement> + <statement> + ALTER TABLE RHQ_ALERT_NOTIF_TEMPL + ADD CONSTRAINT RHQ_ALERT_NOTIF_TEMPL_KEY + PRIMARY KEY ( ID ) + </statement> + </schema-directSQL> + <schema-addColumn table="RHQ_ALERT_NOTIF_TEMPL" column="NAME" columnType="VARCHAR2"/> + <schema-addColumn table="RHQ_ALERT_NOTIF_TEMPL" column="DESCRIPTION" columnType="VARCHAR2"/> + </schemaSpec>
</dbupgrade> </target>
commit 9157fa4cc332f16f736a21c714d04d91b3eb7303 Author: John Mazzitelli mazz@redhat.com Date: Wed Dec 16 12:57:23 2009 -0500
fixing dbsetup - need to set version in pom
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml index 0ab3e72..271beee 100644 --- a/modules/core/dbutils/pom.xml +++ b/modules/core/dbutils/pom.xml @@ -22,7 +22,7 @@
<properties> <scm.module.path>modules/core/dbutils/</scm.module.path> - <db.schema.version>2.70</db.schema.version> + <db.schema.version>2.70.1</db.schema.version> </properties>
<dependencies>
commit e3804770fa5096454f514cd5682722e60b0b7e72 Merge: dee3640... d79070a... Author: John Mazzitelli mazz@redhat.com Date: Wed Dec 16 12:01:10 2009 -0500
Merge branch 'master' into alertPlugin
commit 989b5a2029a35786878edfcf4c242cc3e2fabde8 Author: Heiko W. Rupp pilhuhn@fedorapeople.org Date: Wed Dec 16 17:42:43 2009 +0100
Don't refresh() as this loses the notification logs
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerBean.java index 20fa9c8..7f4477f 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerBean.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerBean.java @@ -777,7 +777,6 @@ public class AlertManagerBean implements AlertManagerLocal, AlertManagerRemote { * @return human readable condition log */ public String prettyPrintAlertConditions(Alert alert) { - entityManager.refresh(alert); return prettyPrintAlertConditions(alert.getConditionLogs()); }
commit dee3640e72f92ec0c4f537be07812db8a704f519 Author: John Mazzitelli mazz@redhat.com Date: Wed Dec 16 10:29:36 2009 -0500
fix misspelling in "backinBean"
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/AlertSenderPluginManager.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/AlertSenderPluginManager.java index 5d1a125..cd4e072 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/AlertSenderPluginManager.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/AlertSenderPluginManager.java @@ -24,9 +24,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map;
- import org.apache.commons.logging.Log; -import org.w3c.dom.Element;
import org.rhq.core.domain.alert.notification.AlertNotification; import org.rhq.core.domain.configuration.Configuration; @@ -50,10 +48,10 @@ import org.rhq.enterprise.server.xmlschema.generated.serverplugin.alert.CustomUi public class AlertSenderPluginManager extends ServerPluginManager {
private final Log log = getLog(); - private Map<String,String> pluginClassByName = new HashMap<String, String>(); - private Map<String,ServerPluginEnvironment> pluginEnvByName = new HashMap<String, ServerPluginEnvironment>(); - private Map<String,AlertSenderInfo> senderInfoByName = new HashMap<String, AlertSenderInfo>(); - private Map<String,String> backinBeanByName = new HashMap<String, String>(); + private Map<String, String> pluginClassByName = new HashMap<String, String>(); + private Map<String, ServerPluginEnvironment> pluginEnvByName = new HashMap<String, ServerPluginEnvironment>(); + private Map<String, AlertSenderInfo> senderInfoByName = new HashMap<String, AlertSenderInfo>(); + private Map<String, String> backingBeanByName = new HashMap<String, String>();
public AlertSenderPluginManager(AbstractTypeServerPluginContainer pc) { super(pc); @@ -69,9 +67,9 @@ public class AlertSenderPluginManager extends ServerPluginManager { * @throws Exception */ @Override - public void loadPlugin(ServerPluginEnvironment env,boolean enable) throws Exception { + public void loadPlugin(ServerPluginEnvironment env, boolean enable) throws Exception { log.info("Start loading alert plugin " + env.getPluginKey().getPluginName()); - super.loadPlugin(env,enable); + super.loadPlugin(env, enable);
AlertPluginDescriptorType type = (AlertPluginDescriptorType) env.getPluginDescriptor();
@@ -80,14 +78,13 @@ public class AlertSenderPluginManager extends ServerPluginManager { className = type.getPackage() + "." + className; } try { - Class.forName(className,false,env.getPluginClassLoader()); - } - catch (Exception e) { - log.error("Can't find pluginClass " + className + ". Plugin " + env.getPluginKey().getPluginName() + " will be ignored"); + Class.forName(className, false, env.getPluginClassLoader()); + } catch (Exception e) { + log.error("Can't find pluginClass " + className + ". Plugin " + env.getPluginKey().getPluginName() + + " will be ignored"); try { unloadPlugin(env.getPluginKey().getPluginName()); - } - catch (Throwable t) { + } catch (Throwable t) { log.warn(" +--> unload failed too " + t.getMessage()); } return; @@ -95,7 +92,7 @@ public class AlertSenderPluginManager extends ServerPluginManager {
// The short name is basically the key into the plugin String shortName = type.getShortName(); - pluginClassByName.put(shortName,className); + pluginClassByName.put(shortName, className);
// // Ok, we have a valid plugin class, so we can look for other things @@ -105,15 +102,15 @@ public class AlertSenderPluginManager extends ServerPluginManager { String uiSnippetPath; URL uiSnippetUrl = null; CustomUi customUI = type.getCustomUi(); - if (customUI!=null) { + if (customUI != null) { uiSnippetPath = customUI.getUiSnippetName();
try { uiSnippetUrl = env.getPluginClassLoader().getResource(uiSnippetPath); log.info("UI snipped for " + shortName + " is at " + uiSnippetUrl); - } - catch (Exception e) { - log.error("No valid ui snippet provided, but <custom-ui> given for sender plugin " + shortName + "Error is "+ e.getMessage()); + } catch (Exception e) { + log.error("No valid ui snippet provided, but <custom-ui> given for sender plugin " + shortName + + "Error is " + e.getMessage()); log.error("Plugin will be ignored"); return; } @@ -124,10 +121,9 @@ public class AlertSenderPluginManager extends ServerPluginManager { className = type.getPackage() + "." + className; } try { - Class.forName(className,true,env.getPluginClassLoader()); // TODO how make this available to Seam and the Web-CL ? - backinBeanByName.put(shortName,className); - } - catch (Throwable t ) { + Class.forName(className, true, env.getPluginClassLoader()); // TODO how make this available to Seam and the Web-CL ? + backingBeanByName.put(shortName, className); + } catch (Throwable t) { log.error("Backing bean " + className + " not found for plugin " + shortName); } } @@ -136,16 +132,16 @@ public class AlertSenderPluginManager extends ServerPluginManager { info.setUiSnippetUrl(uiSnippetUrl); senderInfoByName.put(shortName, info);
- pluginEnvByName.put(shortName,env); + pluginEnvByName.put(shortName, env);
}
@Override protected void unloadPlugin(String pluginName) throws Exception { - log.info("Unloading plugin " + pluginName ); + log.info("Unloading plugin " + pluginName); super.unloadPlugin(pluginName); - String shortName=null; - for (AlertSenderInfo info: senderInfoByName.values()) { + String shortName = null; + for (AlertSenderInfo info : senderInfoByName.values()) { if (info.getPluginName().equals(pluginName)) { shortName = info.getShortName(); break; @@ -154,7 +150,7 @@ public class AlertSenderPluginManager extends ServerPluginManager { pluginClassByName.remove(shortName); senderInfoByName.remove(shortName); pluginEnvByName.remove(shortName); - backinBeanByName.remove(shortName); + backingBeanByName.remove(shortName); }
/** @@ -168,16 +164,15 @@ public class AlertSenderPluginManager extends ServerPluginManager {
String senderName = notification.getSenderName(); String className = pluginClassByName.get(senderName); - if (className==null) { + if (className == null) { log.error("getAlertSender: No pluginClass found for sender: " + senderName); return null; } ServerPluginEnvironment env = pluginEnvByName.get(senderName); Class clazz; try { - clazz = Class.forName(className,true,env.getPluginClassLoader()); - } - catch (Exception e) { + clazz = Class.forName(className, true, env.getPluginClassLoader()); + } catch (Exception e) { log.error(e); // TODO return null; } @@ -186,10 +181,10 @@ public class AlertSenderPluginManager extends ServerPluginManager { try { sender = (AlertSender) clazz.newInstance(); } catch (InstantiationException e) { - e.printStackTrace(); // TODO: Customise this generated block + e.printStackTrace(); // TODO: Customise this generated block return null; } catch (IllegalAccessException e) { - e.printStackTrace(); // TODO: Customise this generated block + e.printStackTrace(); // TODO: Customise this generated block return null; }
@@ -212,7 +207,7 @@ public class AlertSenderPluginManager extends ServerPluginManager { plugin = pluginsMgr.getServerPluginRelationships(plugin);
sender.preferences = plugin.getPluginConfiguration(); - if (sender.preferences==null) { + if (sender.preferences == null) { sender.preferences = new Configuration(); // Safety measure }
@@ -234,21 +229,19 @@ public class AlertSenderPluginManager extends ServerPluginManager { }
public AlertBackingBean getBackingBeanForSender(String shortName) { - String name = backinBeanByName.get(shortName); + String name = backingBeanByName.get(shortName); ServerPluginEnvironment env = pluginEnvByName.get(shortName); Class clazz; try { - clazz = Class.forName(name,true,env.getPluginClassLoader()); - } - catch (Exception e) { + clazz = Class.forName(name, true, env.getPluginClassLoader()); + } catch (Exception e) { log.error("Can't load class " + name + ": " + e.getMessage()); return null; } - AlertBackingBean bean = null ; + AlertBackingBean bean = null; try { bean = (AlertBackingBean) clazz.newInstance(); - } - catch (Exception e) { + } catch (Exception e) { log.error("Can't instantiate " + name + ": " + e.getMessage()); } return bean;
commit d79070afb50423de65d6d0af0fdc92f3ea1a8e65 Author: John Mazzitelli mazz@redhat.com Date: Wed Dec 16 10:08:15 2009 -0500
new eclipse tool
diff --git a/etc/eclipse-tools/maven/RHQ Maven Build - Dev Profile Full Enterprise with DBSetup.launch b/etc/eclipse-tools/maven/RHQ Maven Build - Dev Profile Full Enterprise with DBSetup.launch new file mode 100644 index 0000000..1b1ed7c --- /dev/null +++ b/etc/eclipse-tools/maven/RHQ Maven Build - Dev Profile Full Enterprise with DBSetup.launch @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<launchConfiguration type="org.eclipse.ui.externaltools.ProgramLaunchConfigurationType"> +<stringAttribute key="bad_container_name" value="\rhq\etc\eclipse-tools\maven"/> +<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/> +<listAttribute key="org.eclipse.debug.ui.favoriteGroups"> +<listEntry value="org.eclipse.ui.externaltools.launchGroup"/> +</listAttribute> +<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${env_var:M2_HOME}/bin/${MAVEN_EXE}"/> +<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="-o -Dmaven.test.skip=true -Pdev,enterprise -Ddbsetup install"/> +<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/rhq}"/> +</launchConfiguration>
commit 58839f7f625020099761b0b64fa247b45568d1fb Author: John Mazzitelli mazz@redhat.com Date: Wed Dec 16 10:04:27 2009 -0500
fix log message format
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ServerPluginManager.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ServerPluginManager.java index acef4cf..e86e687 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ServerPluginManager.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ServerPluginManager.java @@ -534,10 +534,10 @@ public class ServerPluginManager { throw new Exception("Could not instantiate plugin class [" + className + "] from plugin environment [" + environment + "]", e); } catch (IllegalAccessException e) { - throw new Exception("Could not access plugin class " + className + "] from plugin environment [" + throw new Exception("Could not access plugin class [" + className + "] from plugin environment [" + environment + "]", e); } catch (ClassNotFoundException e) { - throw new Exception("Could not find plugin class " + className + "] from plugin environment [" + throw new Exception("Could not find plugin class [" + className + "] from plugin environment [" + environment + "]", e); } catch (NullPointerException npe) { throw new Exception("Plugin class was 'null' in plugin environment [" + environment + "]", npe);
commit 5d7c13ae3bbbdce1ebd05796fc7c6528537efe29 Author: Adam Young ayoung@redhat.com Date: Wed Dec 16 09:15:33 2009 -0500
ability to turn off toolbar. Read only is set from render. replaced some String literals with symbolic constants.
diff --git a/.classpath b/.classpath index 27f5303..a3aef1e 100644 --- a/.classpath +++ b/.classpath @@ -92,8 +92,8 @@ <classpathentry kind="src" path="modules/plugins/samba/src/test/java"/> <classpathentry kind="src" path="modules/plugins/sudoers/src/main/java"/> <classpathentry kind="src" path="modules/plugins/sudoers/src/test/java"/> - <classpathentry kind="src" path="modules/plugins/postfix/src/main/java"/> - <classpathentry kind="src" path="modules/plugins/postfix/src/test/java"/> + <classpathentry kind="src" path="modules/plugins/postfix/src/main/java"/> + <classpathentry kind="src" path="modules/plugins/postfix/src/test/java"/> <classpathentry kind="src" path="modules/plugins/cron/src/main/java"/> <classpathentry kind="src" path="modules/plugins/hudson/src/main/java"/> <classpathentry kind="src" path="modules/plugins/platform/src/test/java"/> @@ -165,8 +165,8 @@ <classpathentry exported="true" kind="var" path="M2_REPO/commons-lang/commons-lang/2.4/commons-lang-2.4.jar"/> <classpathentry exported="true" kind="var" path="M2_REPO/javax/faces/jsf-api/1.2_12/jsf-api-1.2_12.jar" sourcepath="/M2_REPO/javax/faces/jsf-api/1.2_12/jsf-api-1.2_12-sources.jar"/> <classpathentry exported="true" kind="var" path="M2_REPO/javax/faces/jsf-impl/1.2_12/jsf-impl-1.2_12.jar" sourcepath="/M2_REPO/javax/faces/jsf-impl/1.2_12/jsf-impl-1.2_12-sources.jar"/> - <classpathentry exported="true" kind="var" path="M2_REPO/javax/el/el-api/1.0/el-api-1.0.jar"/> - <classpathentry exported="true" kind="var" path="M2_REPO/com/sun/facelets/jsf-facelets/1.1.14/jsf-facelets-1.1.14.jar" sourcepath="/M2_REPO/com/sun/facelets/jsf-facelets/1.1.13/jsf-facelets-1.1.13-sources.jar"/> + <classpathentry exported="true" kind="var" path="M2_REPO/javax/el/el-api/1.0/el-api-1.0.jar" sourcepath="/M2_REPO/javax/el/el-api/1.0/el-api-1.0-sources.jar"/> + <classpathentry exported="true" kind="var" path="M2_REPO/com/sun/facelets/jsf-facelets/1.1.14/jsf-facelets-1.1.14.jar" sourcepath="/M2_REPO/com/sun/facelets/jsf-facelets/1.1.14/jsf-facelets-1.1.14-sources.jar"/> <classpathentry exported="true" kind="var" path="M2_REPO/mc4j/org-mc4j-ems/1.2.11/org-mc4j-ems-1.2.11.jar" sourcepath="/M2_REPO/mc4j/org-mc4j-ems/1.2.11/org-mc4j-ems-1.2.11-sources.jar"/> <classpathentry exported="true" kind="var" path="M2_REPO/org/opensymphony/quartz/quartz/1.6.5/quartz-1.6.5.jar" sourcepath="/M2_REPO/org/opensymphony/quartz/quartz/1.6.5/quartz-1.6.5-sources.jar"/> <classpathentry exported="true" kind="var" path="M2_REPO/javax/mail/mail/1.3.1/mail-1.3.1.jar"/> diff --git a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/AbstractConfigurationComponent.java b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/AbstractConfigurationComponent.java index 2fe72ee..e49ead1 100644 --- a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/AbstractConfigurationComponent.java +++ b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/AbstractConfigurationComponent.java @@ -24,6 +24,7 @@ package org.rhq.core.gui.configuration;
import java.util.UUID;
+import javax.faces.component.UIComponent; import javax.faces.component.UIComponentBase; import javax.faces.context.FacesContext;
@@ -49,18 +50,30 @@ public abstract class AbstractConfigurationComponent extends UIComponentBase imp private static final String NULL_CONFIGURATION_STYLE_ATTRIBUTE = "nullConfigurationStyle"; private static final String LIST_NAME_ATTRIBUTE = "listName"; private static final String LIST_INDEX_ATTRIBUTE = "listIndex"; - private static final String READ_ONLY_ATTRIBUTE = "readOnly"; + public static final String READ_ONLY_ATTRIBUTE = "readOnly"; + public static final String SHOW_TOOLBAR_ATTRIBUTE = "readOnly"; private static final String FULLY_EDITABLE_ATTRIBUTE = "fullyEditable";
- private Boolean readOnly = true; + private Boolean showToolbar; + private Boolean readOnly; private Boolean fullyEditable; private String listName; private Integer listIndex; + + public UIComponent getToolbar() { + return toolbar; + } + + public void setToolbar(UIComponent toolbar) { + this.toolbar = toolbar; + } + private String nullConfigurationDefinitionMessage; private String nullConfigurationMessage; private String nullConfigurationStyle; private boolean prevalidate; private boolean isGroup; + private UIComponent toolbar;
public String getFamily() { return COMPONENT_FAMILY; @@ -93,6 +106,21 @@ public abstract class AbstractConfigurationComponent extends UIComponentBase imp this.readOnly = readOnly; }
+ public Boolean getShowToolbar() { + if (this.showToolbar == null) { + this.showToolbar = FacesComponentUtility + .getExpressionAttribute(this, SHOW_TOOLBAR_ATTRIBUTE, Boolean.class); + } + if (this.showToolbar == null) { + this.showToolbar = false; + } + return showToolbar; + } + + public void setShowToolbar(Boolean showToolbar) { + this.showToolbar = showToolbar; + } + public boolean isFullyEditable() { if (this.fullyEditable == null) { this.fullyEditable = FacesComponentUtility.getExpressionAttribute(this, FULLY_EDITABLE_ATTRIBUTE, @@ -190,7 +218,7 @@ public abstract class AbstractConfigurationComponent extends UIComponentBase imp @Override public Object saveState(FacesContext facesContext) { if (this.stateValues == null) { - this.stateValues = new Object[7]; + this.stateValues = new Object[8]; }
this.stateValues[0] = super.saveState(facesContext); @@ -200,6 +228,7 @@ public abstract class AbstractConfigurationComponent extends UIComponentBase imp this.stateValues[4] = this.listIndex; this.stateValues[5] = this.prevalidate; this.stateValues[6] = this.isGroup; + this.stateValues[7] = this.getShowToolbar(); return this.stateValues; }
@@ -213,6 +242,7 @@ public abstract class AbstractConfigurationComponent extends UIComponentBase imp this.listIndex = (Integer) this.stateValues[4]; this.prevalidate = (Boolean) this.stateValues[5]; this.isGroup = (Boolean) this.stateValues[6]; + this.showToolbar = (Boolean) this.stateValues[7]; }
public boolean getShouldShowRaw() { diff --git a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/ConfigRenderer.java b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/ConfigRenderer.java index e3f0c16..278d619 100644 --- a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/ConfigRenderer.java +++ b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/ConfigRenderer.java @@ -26,6 +26,7 @@ import java.io.IOException; import java.util.List; import java.util.Map;
+import javax.el.MethodExpression; import javax.el.ValueExpression; import javax.faces.application.FacesMessage; import javax.faces.component.UIComponent; @@ -122,9 +123,12 @@ public class ConfigRenderer extends Renderer { } }
- Boolean readOnly = Boolean.valueOf(FacesContextUtility.getOptionalRequestParameter("readOnly")); + String readOnly = FacesContextUtility.getOptionalRequestParameter("readOnly"); + if (null != readOnly) { + configurationComponent.setReadOnly(Boolean.valueOf(readOnly)); + } + Boolean save = Boolean.valueOf(FacesContextUtility.getOptionalRequestParameter("save")); - configurationComponent.setReadOnly(readOnly);
if (component.getChildCount() == 0) addChildComponents(configurationComponent); @@ -178,6 +182,9 @@ public class ConfigRenderer extends Renderer { // Only create the child components the first time around (i.e. once per JSF lifecycle). if (component.getChildCount() == 0) addChildComponents(configurationComponent); + if (configurationComponent.getToolbar() != null) { + configurationComponent.getToolbar().setRendered(configurationComponent.getShowToolbar()); + } }
private boolean isAjaxRefresh(AbstractConfigurationComponent configurationComponent) { @@ -275,29 +282,39 @@ public class ConfigRenderer extends Renderer { }
private void addStructuredConfig(AbstractConfigurationComponent configurationComponent) { - UIPanel toolbarPanel = FacesComponentUtility.addBlockPanel(configurationComponent, configurationComponent, - "summary-props-table"); - if (configurationComponent.isReadOnly()) { - HtmlCommandLink editLink = FacesComponentUtility.addCommandLink(toolbarPanel, configurationComponent); - FacesComponentUtility.addGraphicImage(editLink, configurationComponent, "/images/edit.png", "Edit"); - FacesComponentUtility.addOutputText(editLink, configurationComponent, "Edit", ""); - FacesComponentUtility.addParameter(editLink, configurationComponent, "readOnly", Boolean.toString(false)); - - } else { - HtmlCommandLink saveLink = FacesComponentUtility.addCommandLink(toolbarPanel, configurationComponent); - FacesComponentUtility.addGraphicImage(saveLink, configurationComponent, "/images/save.png", "Save"); - FacesComponentUtility.addOutputText(saveLink, configurationComponent, "Save", ""); - FacesComponentUtility.addParameter(saveLink, configurationComponent, "save", Boolean.toString(true)); - FacesComponentUtility.addParameter(saveLink, configurationComponent, "readOnly", Boolean.toString(true)); - } + { + UIPanel toolbarPanel = FacesComponentUtility.addBlockPanel(configurationComponent, configurationComponent, + "summary-props-table"); + if (configurationComponent.isReadOnly()) { + HtmlOutputLink editLink = FacesComponentUtility.addOutputLink(toolbarPanel, configurationComponent, + "edit.xhtml"); + FacesComponentUtility.addGraphicImage(editLink, configurationComponent, "/images/edit.png", "Edit"); + FacesComponentUtility.addOutputText(editLink, configurationComponent, "Edit", ""); + FacesComponentUtility.addParameter(editLink, configurationComponent, "readOnly", Boolean + .toString(false)); + FacesComponentUtility.addParameter(editLink, configurationComponent, "id", FacesContextUtility + .getRequiredRequestParameter("id")); + } else { + HtmlCommandLink saveLink = FacesComponentUtility.addCommandLink(toolbarPanel, configurationComponent); + FacesComponentUtility.addGraphicImage(saveLink, configurationComponent, "/images/save.png", "Save"); + FacesComponentUtility.addOutputText(saveLink, configurationComponent, "Save", ""); + FacesComponentUtility.addParameter(saveLink, configurationComponent, "save", Boolean.toString(true)); + FacesComponentUtility + .addParameter(saveLink, configurationComponent, "readOnly", Boolean.toString(true)); + + saveLink.setActionExpression(getSaveActionExpression());
- if (configurationComponent.getConfigurationDefinition().getConfigurationFormat().isRawSupported()) { - HtmlCommandLink toRawLink = FacesComponentUtility.addCommandLink(toolbarPanel, configurationComponent); - FacesComponentUtility.addGraphicImage(toRawLink, configurationComponent, "/images/raw.png", "showRaw"); - FacesComponentUtility.addOutputText(toRawLink, configurationComponent, "showRaw", ""); - FacesComponentUtility.addParameter(toRawLink, configurationComponent, "showRaw", Boolean.TRUE.toString()); - FacesComponentUtility.addParameter(toRawLink, configurationComponent, "readOnly", Boolean - .toString(configurationComponent.isReadOnly())); + } + if (configurationComponent.getConfigurationDefinition().getConfigurationFormat().isRawSupported()) { + HtmlCommandLink toRawLink = FacesComponentUtility.addCommandLink(toolbarPanel, configurationComponent); + FacesComponentUtility.addGraphicImage(toRawLink, configurationComponent, "/images/raw.png", "showRaw"); + FacesComponentUtility.addOutputText(toRawLink, configurationComponent, "showRaw", ""); + FacesComponentUtility.addParameter(toRawLink, configurationComponent, "showRaw", Boolean.TRUE + .toString()); + FacesComponentUtility.addParameter(toRawLink, configurationComponent, "readOnly", Boolean + .toString(configurationComponent.isReadOnly())); + } + configurationComponent.setToolbar(toolbarPanel); }
if (!configurationComponent.isReadOnly()) @@ -319,6 +336,13 @@ public class ConfigRenderer extends Renderer { .isFullyEditable(), false); }
+ private MethodExpression getSaveActionExpression() { + + MethodExpression actionExpression = null; + + return actionExpression; + } + private void addStructuredRawToggle(AbstractConfigurationComponent configurationComponent, boolean showRaw) { if (configurationComponent.getConfigurationDefinition().getConfigurationFormat().equals( ConfigurationFormat.STRUCTURED_AND_RAW)) { diff --git a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/RawConfigUIComponent.java b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/RawConfigUIComponent.java index ce42a54..2c9a1be 100644 --- a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/RawConfigUIComponent.java +++ b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/RawConfigUIComponent.java @@ -138,8 +138,8 @@ public class RawConfigUIComponent extends UIComponentBase { FacesComponentUtility.addParameter(link, idFactory, "path", raw.getPath()); FacesComponentUtility.addParameter(link, idFactory, "whichRaw", Integer.toString(rawCount++)); FacesComponentUtility.addParameter(link, idFactory, "showRaw", Boolean.TRUE.toString()); - readOnlyParms.add(FacesComponentUtility.addParameter(link, idFactory, "readOnly", Boolean - .toString(readOnly))); + readOnlyParms.add(FacesComponentUtility.addParameter(link, idFactory, + AbstractConfigurationComponent.READ_ONLY_ATTRIBUTE, Boolean.toString(readOnly)));
}
@@ -155,24 +155,32 @@ public class RawConfigUIComponent extends UIComponentBase { inputTextarea.setReadonly(readOnly); }
+ private HtmlOutputLink fullscreenLink; + private UIParameter fullScreenResourceIdParam; + private void addToolbar(ConfigurationDefinition configurationDefinition, UIPanel parent) { UIPanel toolbarPanel = FacesComponentUtility.addBlockPanel(parent, idFactory, "config-toolbar"); if (readOnly) { HtmlCommandLink editLink = FacesComponentUtility.addCommandLink(toolbarPanel, idFactory); FacesComponentUtility.addGraphicImage(editLink, idFactory, "/images/edit.png", "Edit"); FacesComponentUtility.addOutputText(editLink, idFactory, "Edit", ""); - FacesComponentUtility.addParameter(editLink, idFactory, "showStructured", Boolean.FALSE.toString()); + FacesComponentUtility.addParameter(editLink, idFactory, "showRaw", Boolean.TRUE.toString()); + FacesComponentUtility.addParameter(editLink, idFactory, AbstractConfigurationComponent.READ_ONLY_ATTRIBUTE, + Boolean.FALSE.toString()); } else { HtmlCommandLink saveLink = FacesComponentUtility.addCommandLink(toolbarPanel, idFactory); FacesComponentUtility.addGraphicImage(saveLink, idFactory, "/images/save.png", "Save"); FacesComponentUtility.addOutputText(saveLink, idFactory, "Save", ""); - FacesComponentUtility.addParameter(saveLink, idFactory, "showStructured", Boolean.FALSE.toString()); + FacesComponentUtility.addParameter(saveLink, idFactory, "showRaw", Boolean.FALSE.toString()); + FacesComponentUtility.addParameter(saveLink, idFactory, AbstractConfigurationComponent.READ_ONLY_ATTRIBUTE, + Boolean.TRUE.toString()); } { - HtmlCommandLink saveCommandLink = FacesComponentUtility.addCommandLink(toolbarPanel, idFactory); - FacesComponentUtility.addGraphicImage(saveCommandLink, idFactory, "/images/viewfullscreen.png", - "FullScreen"); - FacesComponentUtility.addOutputText(saveCommandLink, idFactory, "Full Screen", ""); + fullscreenLink = FacesComponentUtility.addOutputLink(toolbarPanel, idFactory, "view-full.xhtml"); + FacesComponentUtility + .addGraphicImage(fullscreenLink, idFactory, "/images/viewfullscreen.png", "FullScreen"); + FacesComponentUtility.addOutputText(fullscreenLink, idFactory, "Full Screen", ""); + fullScreenResourceIdParam = FacesComponentUtility.addParameter(fullscreenLink, idFactory, "id", ""); } if (!readOnly) { HtmlOutputLink uploadLink = FacesComponentUtility.addOutputLink(toolbarPanel, idFactory, "upload.xhtml"); @@ -200,10 +208,23 @@ public class RawConfigUIComponent extends UIComponentBase { public void encodeBegin(FacesContext context) throws IOException { // TODO Auto-generated method stub super.encodeBegin(context); + inputTextarea.setValue(rawMap.get(getSelectedPath()).getContentString()); for (UIParameter param : readOnlyParms) { param.setValue(Boolean.toString(readOnly)); }
+ String resourceId = FacesContextUtility.getOptionalRequestParameter("id"); + + if (null == resourceId) { + if (fullscreenLink != null) { + fullscreenLink.setRendered(false); + } + } else { + if (fullScreenResourceIdParam != null) { + fullScreenResourceIdParam.setValue(resourceId); + } + } + } } diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml index a85f409..dffd02b 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml @@ -49,7 +49,10 @@ THIS TEXT WILL BE REMOVED. configuration="#{ExistingResourceConfigurationUIBean.configuration}" nullConfigurationDefinitionMessage="#{ExistingResourceConfigurationUIBean.nullConfigurationDefinitionMessage}" nullConfigurationMessage="#{ExistingResourceConfigurationUIBean.nullConfigurationMessage}" - prevalidate="true"/> + prevalidate="true" + showToolbar="true" + readOnly="false" + />
<h:panelGrid columns="2" styleClass="buttons-table" columnClasses="button-cell" rendered="#{ExistingResourceConfigurationUIBean.configuration != null}"> <h:commandButton value="SAVE" action="#{ExistingResourceConfigurationUIBean.updateConfiguration}" diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view-full.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view-full.xhtml new file mode 100644 index 0000000..0491cf8 --- /dev/null +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view-full.xhtml @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<html xmlns="http://www.w3.org/1999/xhtml" + xmlns:h="http://java.sun.com/jsf/html" + xmlns:f="http://java.sun.com/jsf/core" + xmlns:ui="http://java.sun.com/jsf/facelets" + xmlns:c="http://java.sun.com/jstl/core" + xmlns:onc="http://jboss.org/on/component" + xmlns:a4j="http://richfaces.org/a4j" + xmlns:rich="http://richfaces.ajax4jsf.org/rich" + xmlns:s="http://jboss.com/products/seam/taglib%22%3E + +<ui:composition template="/rhq/layout/main.xhtml"> +<ui:param name="pageTitle" value="TODO Internationalize this"/> + +<ui:define name="breadcrumbs" > +<h:outputLink value="view.xhtml" action="navigateToUpload" > + <h:outputText value=" Back " /> + <f:param name="id" value="#{ResourceUIBean.id}" /> +</h:outputLink> + +</ui:define> + +<ui:define name="body"> + +<h:form id="editResourceConfigurationForm" > +<input type="hidden" name="id" value="#{ResourceUIBean.id}" /> + + <onc:config configurationDefinition="#{ExistingResourceConfigurationUIBean.configurationDefinition}" + configuration="#{ExistingResourceConfigurationUIBean.configuration}" + accessMapActionExpression="#{ExistingResourceConfigurationUIBean.accessMap}" + nullConfigurationDefinitionMessage="#{ExistingResourceConfigurationUIBean.nullConfigurationDefinitionMessage}" + nullConfigurationMessage="#{ExistingResourceConfigurationUIBean.nullConfigurationMessage}" + readOnly="true" + showToolbar="true" + prevalidate="true" + showRaw="true" + fullscreen="true" /> + + +</h:form> +</ui:define> + +</ui:composition> + +</html> + + diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view-raw-full.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view-raw-full.xhtml deleted file mode 100644 index e9e8c1a..0000000 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view-raw-full.xhtml +++ /dev/null @@ -1,38 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<html xmlns="http://www.w3.org/1999/xhtml" - xmlns:h="http://java.sun.com/jsf/html" - xmlns:f="http://java.sun.com/jsf/core" - xmlns:ui="http://java.sun.com/jsf/facelets" - xmlns:c="http://java.sun.com/jstl/core" - xmlns:onc="http://jboss.org/on/component" - xmlns:a4j="http://richfaces.org/a4j" - xmlns:rich="http://richfaces.ajax4jsf.org/rich" - xmlns:s="http://jboss.com/products/seam/taglib%22%3E - -<ui:composition template="/rhq/layout/main.xhtml"> -<ui:param name="pageTitle" value="TODO Internationalize this"/> - -<ui:define name="breadcrumbs" > -<h:outputLink value="view-raw.xhtml" action="navigateToUpload" > - <h:outputText value=" Back " /> - <f:param name="id" value="#{ResourceUIBean.id}" /> -</h:outputLink> - -</ui:define> - -<ui:define name="body"> - -<h:form id="editResourceConfigurationForm" > -<input type="hidden" name="id" value="#{ResourceUIBean.id}" /> -<div> -<pre><h:outputText value="#{ExistingResourceConfigurationUIBean.currentContents}" /></pre> -</div> -</h:form> -</ui:define> - -</ui:composition> - -</html> - - diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml index d0cfa5c..40a917d 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml @@ -47,12 +47,14 @@ THIS TEXT WILL BE REMOVED. <!-- TODO remove the id version --> <input type="hidden" name="id" value="#{ResourceUIBean.id}"/>
- <onc:config configurationDefinition="#{ExistingResourceConfigurationUIBean.configurationDefinition}" - configuration="#{ExistingResourceConfigurationUIBean.configuration}" - accessMapActionExpression="#{ExistingResourceConfigurationUIBean.accessMap}" - nullConfigurationDefinitionMessage="#{ExistingResourceConfigurationUIBean.nullConfigurationDefinitionMessage}" - nullConfigurationMessage="#{ExistingResourceConfigurationUIBean.nullConfigurationMessage}" - prevalidate="true"/> + <onc:config configurationDefinition="#{ExistingResourceConfigurationViewUIBean.configurationDefinition}" + configuration="#{ExistingResourceConfigurationViewUIBean.configuration}" + accessMapActionExpression="#{ExistingResourceConfigurationViewUIBean.accessMap}" + nullConfigurationDefinitionMessage="#{ExistingResourceConfigurationViewUIBean.nullConfigurationDefinitionMessage}" + nullConfigurationMessage="#{ExistingResourceConfigurationViewUIBean.nullConfigurationMessage}" + readOnly="true" + showToolbar="true" + prevalidate="true"/> <input type="hidden" name="id" value="#{ResourceUIBean.id}"/>
</h:form>
commit d2c4a2d3799f627a61f006c73b5b51ba0e0550b2 Author: John Mazzitelli mazz@redhat.com Date: Tue Dec 15 15:36:57 2009 -0500
add some error messages to make it clear what's happening
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/plugin/PluginDeploymentScanner.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/plugin/PluginDeploymentScanner.java index 641d90e..7ec0020 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/plugin/PluginDeploymentScanner.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/plugin/PluginDeploymentScanner.java @@ -208,11 +208,18 @@ public class PluginDeploymentScanner implements PluginDeploymentScannerMBean { destinationDirectory = getAgentPluginDir(); } catch (Exception e) { try { + log.debug("[" + file.getAbsolutePath() + "] is not an agent plugin jar (Cause: " + + ThrowableUtil.getAllMessages(e) + "). Will see if its a server plugin jar"); + ServerPluginDescriptorUtil.loadPluginDescriptorFromUrl(file.toURI().toURL()); destinationDirectory = getServerPluginDir(); } catch (Exception e1) { // skip it, doesn't look like a valid plugin jar - log.warn("Does not look like [" + file.getAbsolutePath() + "] is a plugin jar - ignoring"); + File fixmeFile = new File(file.getAbsolutePath() + ".fixme"); + boolean renamed = file.renameTo(fixmeFile); + log.warn("Does not look like [" + (renamed ? fixmeFile : file).getAbsolutePath() + + "] is a plugin jar -(Cause: " + ThrowableUtil.getAllMessages(e) + + "). It will be ignored. Please fix that file or remove it."); continue; } }
commit 2d4e562f32814f683a754eabe829531b0b8e40df Merge: ed7ba67... 0050ae7... Author: Adam Young ayoung@redhat.com Date: Tue Dec 15 12:07:24 2009 -0500
Merge of current raw work with remote branch
diff --cc modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java index c6d9b18,3189d79..2f11e11 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java @@@ -401,4 -443,12 +402,4 @@@ public class ExistingResourceConfigurat return raws; }
- } - /** - * - */ - String selectedPath; - private TreeMap<String, RawConfiguration> raws; - TreeMap<String, RawConfiguration> modified = new TreeMap<String, RawConfiguration>(); - RawConfiguration current = null; - + }
commit ed7ba67209643e53b1fcd94fbb1a9c74e89bb80a Author: Adam Young ayoung@redhat.com Date: Tue Dec 15 10:48:47 2009 -0500
removed temporary file.
diff --git a/temp-testng-customsuite.xml b/temp-testng-customsuite.xml deleted file mode 100644 index b4645bb..0000000 --- a/temp-testng-customsuite.xml +++ /dev/null @@ -1,8 +0,0 @@ -<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"> -<suite name="rhq" parallel=""> - <test verbose="2" name="org.rhq.core.gui.configuration.ConfigRendererTest" annotations="JDK"> - <classes> - <class name="org.rhq.core.gui.configuration.ConfigRendererTest"/> - </classes> - </test> -</suite>
commit 0050ae7cdf3e8e226f728b1d64f9effde315fa76 Author: John Sanda jsanda@redhat.com Date: Tue Dec 15 10:16:43 2009 -0500
Removing check for config property definitions in findResourceConfigurationUpdates()
The check does not really make sense in light of adding raw config. With a resource that supports raw config, the config does not have to have any properties.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java index 586d603..fbae47d 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java @@ -842,11 +842,6 @@ public class ConfigurationManagerBean implements ConfigurationManagerLocal, Conf }
Resource resource = entityManager.find(Resource.class, resourceId); - ConfigurationDefinition configDef = resource.getResourceType().getResourceConfigurationDefinition(); - if ((configDef == null || configDef.getPropertyDefinitions().isEmpty()) - && configDef.getConfigurationFormat() == ConfigurationFormat.STRUCTURED) { - return new PageList<ResourceConfigurationUpdate>(pc); - }
pc.initDefaultOrderingField("cu.id", PageOrdering.DESC);
commit b9d47ee5c181247093123b4ad79b316cf28bc5bf Merge: 1ceec65... c5c871b... Author: Heiko W. Rupp pilhuhn@fedorapeople.org Date: Tue Dec 15 13:50:42 2009 +0100
Merge branch 'master' into alertPlugin
commit c5c871b003308b19ffbfd1b49dd65acb6d4e55e5 Author: Heiko W. Rupp pilhuhn@fedorapeople.org Date: Tue Dec 15 13:49:41 2009 +0100
Evaluate the script on each call to prevent issues with multi-threading.
diff --git a/modules/plugins/script2/src/main/java/org/rhq/modules/plugins/script2/ScriptComponent.java b/modules/plugins/script2/src/main/java/org/rhq/modules/plugins/script2/ScriptComponent.java index e388595..1df7f29 100644 --- a/modules/plugins/script2/src/main/java/org/rhq/modules/plugins/script2/ScriptComponent.java +++ b/modules/plugins/script2/src/main/java/org/rhq/modules/plugins/script2/ScriptComponent.java @@ -5,7 +5,7 @@ import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.Reader; -import java.util.HashSet; +import java.io.StringWriter; import java.util.Set;
import javax.script.Invocable; @@ -18,7 +18,6 @@ import org.apache.commons.logging.LogFactory;
import org.rhq.core.domain.configuration.Configuration; import org.rhq.core.domain.measurement.DataType; -import org.rhq.core.domain.measurement.MeasurementData; import org.rhq.core.domain.measurement.MeasurementDataTrait; import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException; import org.rhq.core.domain.measurement.AvailabilityType; @@ -32,17 +31,21 @@ import org.rhq.core.pluginapi.operation.OperationContext; import org.rhq.core.pluginapi.operation.OperationFacet; import org.rhq.core.pluginapi.operation.OperationResult;
- +/** + * Run the show for the script2 plugin. + * + * We eval() the script for each call to getAvailability and getValues , as + * otherwise we may see failures, when evaluated script was evaluated on + * a different thread than the execution of invokeFunction. + * + * @author Heiko W. Rupp + */ public class ScriptComponent implements ResourceComponent, MeasurementFacet, OperationFacet { private final Log log = LogFactory.getLog(this.getClass());
- private static final int CHANGEME = 1; // TODO remove or change this - - private String scriptName; ScriptEngine engine; - Object scriptObject; - + private String theScript;
@@ -52,11 +55,10 @@ public class ScriptComponent implements ResourceComponent, MeasurementFacet, Ope */ public AvailabilityType getAvailability() {
- Object ret = null; - try { + engine.eval(theScript); Invocable inv = (Invocable) engine; - ret = inv.invokeFunction("avail"); + Object ret = inv.invokeFunction("avail"); if (ret instanceof Number) { int tmp = ((Number)ret).intValue(); if (tmp>0) @@ -78,7 +80,6 @@ public class ScriptComponent implements ResourceComponent, MeasurementFacet, Ope public void start(ResourceContext context) throws InvalidPluginConfigurationException, Exception {
Configuration conf = context.getPluginConfiguration(); - // TODO add code to start the resource / connection to it
String engineName = conf.getSimpleValue("language",null); if (engineName==null) @@ -87,8 +88,8 @@ public class ScriptComponent implements ResourceComponent, MeasurementFacet, Ope ScriptEngineManager seMgr = new ScriptEngineManager(); engine = seMgr.getEngineByName(engineName);
- scriptName = conf.getSimpleValue("scriptName",null); - if (scriptName==null) + String scriptName = conf.getSimpleValue("scriptName", null); + if (scriptName ==null) throw new InvalidPluginConfigurationException("No (valid) script name given");
File dataDir = context.getDataDirectory(); @@ -96,15 +97,23 @@ public class ScriptComponent implements ResourceComponent, MeasurementFacet, Ope if (!scriptFile.exists()) throw new InvalidPluginConfigurationException("Script does not exist at " + scriptFile.getAbsolutePath());
+ Reader reader; try { - Reader reader = new BufferedReader(new FileReader(scriptFile)); - engine.eval(reader); -// scriptObject = engine.get("new MyClass"); + reader = new BufferedReader(new FileReader(scriptFile)); + StringWriter writer = new StringWriter(); + int tmp; + while ((tmp=reader.read())!=-1) + writer.write(tmp); + + reader.close(); + theScript = writer.toString(); + writer.close(); + + engine.eval(theScript); } catch (ScriptException se) { throw new InvalidPluginConfigurationException(se.getMessage()); } - }
@@ -125,6 +134,15 @@ public class ScriptComponent implements ResourceComponent, MeasurementFacet, Ope */ public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> metrics) throws Exception {
+ try { + engine.eval(theScript); + } + catch (ScriptException se) { + log.debug(se.getMessage()); + return; + } + + for (MeasurementScheduleRequest req : metrics) {
Invocable inv = (Invocable) engine;
commit 4e7f1939c4cc1388d3cf9a5b35647684a3d7b033 Author: John Sanda jsanda@redhat.com Date: Tue Dec 15 07:36:52 2009 -0500
[BZ 537891] Fixing bug in which required query parameter was not getted appended to url
The resource id is expected to be a parameter in the request. When on edit-raw.xhtml and clicking the link to go back to structured, the resource id basically gets dropped and then navigating to any other page, tab, etc. that expects the id parameter results in an exception. I added a new navigation rule similar to one already defined for edit.xhtml (structured edit page) that adds the id to the request and does a server side redirect.
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java index bb93d81..3189d79 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java @@ -417,7 +417,8 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI current = null; setConfiguration(configuration);
- return "/rhq/resource/configuration/edit.xhtml?currentResourceId=" + getResourceId(); +// return "/rhq/resource/configuration/edit.xhtml?currentResourceId=" + getResourceId(); + return SUCCESS_OUTCOME; }
void populateRaws() { @@ -450,4 +451,4 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI TreeMap<String, RawConfiguration> modified = new TreeMap<String, RawConfiguration>(); RawConfiguration current = null;
-} \ No newline at end of file +} diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/configuration-navigation.xml b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/configuration-navigation.xml index 4443b36..bd0f1bf 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/configuration-navigation.xml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/configuration-navigation.xml @@ -23,6 +23,12 @@ <from-action>#{ConfigHelperUIBean.accessMap}</from-action> <to-view-id>/rhq/resource/configuration/view-map.xhtml</to-view-id> </navigation-case> + + <navigation-case> + <from-action>#{ExistingResourceConfigurationUIBean.switchTostructured}</from-action> + <to-view-id>/rhq/resource/configuration/edit.xhtml?id=#{param.id}</to-view-id> + <redirect/> + </navigation-case>
</navigation-rule>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit-raw.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit-raw.xhtml index c01694e..bf05c9b 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit-raw.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit-raw.xhtml @@ -35,10 +35,10 @@ <a4j:form id="editResourceConfigurationForm"> <h:outputText value="#{messages.youareviewingraw}" /> - <h:panelGroup rendered="#{ExistingResourceConfigurationUIBean.structuredSupported}"> + <h:panelGroup rendered="#{ExistingResourceConfigurationUIBean.structuredSupported}"> <h:outputText value=" #{messages.switch2}" /> <h:commandLink action="#{ExistingResourceConfigurationUIBean.switchTostructured}"> - <s:conversationId /> + <f:param name="conversationId" value="#{conversation.id}"/> <f:param name="id" value="#{ResourceUIBean.id}" /> <h:outputText value=" #{messages.structured}" /> </h:commandLink>
commit bb02829fa61a25af1c848480482581cf260a8f36 Author: Heiko W. Rupp pilhuhn@fedorapeople.org Date: Tue Dec 15 12:31:32 2009 +0100
Prevent NPE on stop() if Augeas is not present on a system.
diff --git a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java index a47423e..fa4e00a 100644 --- a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java +++ b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java @@ -89,7 +89,7 @@ public class AugeasConfigurationComponent<T extends ResourceComponent> implement private Augeas augeas; private AugeasNode resourceConfigRootNode; private String augeasRootPath; - + public void start(ResourceContext<T> resourceContext) throws InvalidPluginConfigurationException, Exception { this.resourceContext = resourceContext; this.resourceDescription = this.resourceContext.getResourceType() + " Resource with key [" @@ -112,7 +112,8 @@ public class AugeasConfigurationComponent<T extends ResourceComponent> implement }
public void stop() { - this.augeas.close(); + if (this.augeas!=null) + this.augeas.close(); }
public AvailabilityType getAvailability() {
commit 1ceec6560585faec09cda809f41cca543462a786 Author: Heiko W. Rupp pilhuhn@fedorapeople.org Date: Tue Dec 15 11:25:26 2009 +0100
More support for custom UI snippets and a custom backing bean of them. Still WIP
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/GenericAlertStuffUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/GenericAlertStuffUIBean.java new file mode 100644 index 0000000..4ec8173 --- /dev/null +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/GenericAlertStuffUIBean.java @@ -0,0 +1,99 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2009 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +package org.rhq.enterprise.gui.alert; + +import java.util.HashMap; +import java.util.Map; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import org.jboss.seam.ScopeType; +import org.jboss.seam.annotations.Name; +import org.jboss.seam.annotations.Scope; +import org.jboss.seam.annotations.web.RequestParameter; + +import org.rhq.core.domain.alert.notification.AlertNotificationLog; +import org.rhq.enterprise.server.alert.AlertNotificationManagerLocal; +import org.rhq.enterprise.server.plugin.pc.alert.AlertBackingBean; +import org.rhq.enterprise.server.plugin.pc.alert.AlertSenderPluginManager; +import org.rhq.enterprise.server.util.LookupUtil; + +/** + * // TODO: Document this + * @author Heiko W. Rupp + */ +@Name("GenericAlertStuffUIBean") +//@Scope(ScopeType.STATELESS) +public class GenericAlertStuffUIBean { + + private final Log log = LogFactory.getLog(GenericAlertStuffUIBean.class); + + + @RequestParameter("sender") + String sender; + String value; + + public GenericAlertStuffUIBean() { + } + + public Map<String,String> getTheMap() { + + AlertNotificationManagerLocal mgr = LookupUtil.getAlertNotificationManager(); + AlertBackingBean bean = mgr.getBackingBeanForSender("Roles"); + Map<String, String> map ; + if (bean!=null) + map = bean.getMap(); + else + map = new HashMap<String,String>(); + + return map; + } + + + public String getTheString() { + + AlertNotificationManagerLocal mgr = LookupUtil.getAlertNotificationManager(); + AlertBackingBean bean = mgr.getBackingBeanForSender("Roles"); + + String res = ""; + if (bean !=null) + res = bean.getString(); + + return res; + } + + public String submitForm() { + + AlertNotificationManagerLocal mgr = LookupUtil.getAlertNotificationManager(); + AlertBackingBean bean = mgr.getBackingBeanForSender("Roles"); + + bean.submit(); + + return "OK"; + } + + public String getTheValue() { + return value; + } + + public void setTheValue(String value) { + this.value = value; + } +} diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java index 89d1cc1..9763b17 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java @@ -61,6 +61,7 @@ import org.rhq.enterprise.server.authz.RoleManagerLocal; import org.rhq.enterprise.server.configuration.ConfigurationManagerLocal; import org.rhq.enterprise.server.configuration.metadata.ConfigurationMetadataManagerLocal; import org.rhq.enterprise.server.plugin.ServerPluginsLocal; +import org.rhq.enterprise.server.plugin.pc.alert.AlertBackingBean; import org.rhq.enterprise.server.plugin.pc.alert.AlertSenderInfo; import org.rhq.enterprise.server.plugin.pc.alert.AlertSenderPluginManager; import org.rhq.enterprise.server.xmlschema.generated.serverplugin.ServerPluginDescriptorType; @@ -486,6 +487,19 @@ public class AlertNotificationManagerBean implements AlertNotificationManagerLoc return info; }
+ + /** + * Return the backing bean for the AlertSender with the passed shortNama + * @param shortName name of a sender + * @return an initialized BackingBean or null in case of error + */ + public AlertBackingBean getBackingBeanForSender(String shortName) { + AlertSenderPluginManager pluginmanager = alertManager.getAlertPluginManager(); + AlertBackingBean bean = pluginmanager.getBackingBeanForSender(shortName); + return bean; + + } + /** * Add a new AlertNotification to the passed definition * @param user subject of the caller diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerLocal.java index 7c458f4..c0b5ff2 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerLocal.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerLocal.java @@ -35,6 +35,7 @@ import org.rhq.core.domain.configuration.Configuration; import org.rhq.core.domain.configuration.definition.ConfigurationDefinition; import org.rhq.core.domain.util.PageControl; import org.rhq.core.domain.util.PageList; +import org.rhq.enterprise.server.plugin.pc.alert.AlertBackingBean; import org.rhq.enterprise.server.plugin.pc.alert.AlertSenderInfo;
/** @@ -119,4 +120,11 @@ public interface AlertNotificationManagerLocal { * @param removeOldNotifications Shall old Notifications on the Definition be removed? */ void applyNotificationTemplateToAlertDefinition(NotificationTemplate template, AlertDefinition def, boolean removeOldNotifications); + + /** + * Return the backing bean for the AlertSender with the passed shortNama + * @param shortName name of a sender + * @return an initialized BackingBean or null in case of error + */ + AlertBackingBean getBackingBeanForSender(String shortName); } \ No newline at end of file diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/AlertBackingBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/AlertBackingBean.java new file mode 100644 index 0000000..523190d --- /dev/null +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/AlertBackingBean.java @@ -0,0 +1,34 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2009 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +package org.rhq.enterprise.server.plugin.pc.alert; + +import java.util.Map; + +/** + * Interface that backing beans for AlertSender custom UI need to implement + * @author Heiko W. Rupp + */ +public interface AlertBackingBean { + + public String getString() ; + + public Map<String,String>getMap(); + + public void submit(); +} diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/AlertSenderPluginManager.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/AlertSenderPluginManager.java index e29e9b5..5d1a125 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/AlertSenderPluginManager.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/AlertSenderPluginManager.java @@ -53,6 +53,7 @@ public class AlertSenderPluginManager extends ServerPluginManager { private Map<String,String> pluginClassByName = new HashMap<String, String>(); private Map<String,ServerPluginEnvironment> pluginEnvByName = new HashMap<String, ServerPluginEnvironment>(); private Map<String,AlertSenderInfo> senderInfoByName = new HashMap<String, AlertSenderInfo>(); + private Map<String,String> backinBeanByName = new HashMap<String, String>();
public AlertSenderPluginManager(AbstractTypeServerPluginContainer pc) { super(pc); @@ -124,6 +125,7 @@ public class AlertSenderPluginManager extends ServerPluginManager { } try { Class.forName(className,true,env.getPluginClassLoader()); // TODO how make this available to Seam and the Web-CL ? + backinBeanByName.put(shortName,className); } catch (Throwable t ) { log.error("Backing bean " + className + " not found for plugin " + shortName); @@ -152,6 +154,7 @@ public class AlertSenderPluginManager extends ServerPluginManager { pluginClassByName.remove(shortName); senderInfoByName.remove(shortName); pluginEnvByName.remove(shortName); + backinBeanByName.remove(shortName); }
/** @@ -229,4 +232,25 @@ public class AlertSenderPluginManager extends ServerPluginManager { public AlertSenderInfo getAlertSenderInfo(String shortName) { return senderInfoByName.get(shortName); } + + public AlertBackingBean getBackingBeanForSender(String shortName) { + String name = backinBeanByName.get(shortName); + ServerPluginEnvironment env = pluginEnvByName.get(shortName); + Class clazz; + try { + clazz = Class.forName(name,true,env.getPluginClassLoader()); + } + catch (Exception e) { + log.error("Can't load class " + name + ": " + e.getMessage()); + return null; + } + AlertBackingBean bean = null ; + try { + bean = (AlertBackingBean) clazz.newInstance(); + } + catch (Exception e) { + log.error("Can't instantiate " + name + ": " + e.getMessage()); + } + return bean; + } } diff --git a/modules/enterprise/server/plugins/alert-mobicents/src/main/java/org/rhq/enterprise/server/plugins/alertMobicents/MobicentsSender.java b/modules/enterprise/server/plugins/alert-mobicents/src/main/java/org/rhq/enterprise/server/plugins/alertMobicents/MobicentsSender.java index 6111d7e..7444052 100644 --- a/modules/enterprise/server/plugins/alert-mobicents/src/main/java/org/rhq/enterprise/server/plugins/alertMobicents/MobicentsSender.java +++ b/modules/enterprise/server/plugins/alert-mobicents/src/main/java/org/rhq/enterprise/server/plugins/alertMobicents/MobicentsSender.java @@ -150,6 +150,7 @@ public class MobicentsSender extends AlertSender { code = conn.getResponseCode(); } catch (Exception e) { log.warn("Notification via VoIP failed: " + e); + return new SenderResult(ResultState.FAILURE,"Sending failed " + e.getMessage()); } finally { if (conn!=null) diff --git a/modules/enterprise/server/plugins/alert-roles/pom.xml b/modules/enterprise/server/plugins/alert-roles/pom.xml index 5747fe2..b572a53 100644 --- a/modules/enterprise/server/plugins/alert-roles/pom.xml +++ b/modules/enterprise/server/plugins/alert-roles/pom.xml @@ -69,6 +69,14 @@ <!-- needed for referenced domain entities that use Hibernate annotations --> </dependency>
+ <dependency> + <groupId>jboss.jboss-embeddable-ejb3</groupId> + <artifactId>jboss-ejb3-all</artifactId> + <version>1.0.0.Alpha9</version> + <scope>compile</scope> + </dependency> + + </dependencies>
<build> @@ -148,4 +156,4 @@
-</project> \ No newline at end of file +</project> diff --git a/modules/enterprise/server/plugins/alert-roles/src/main/java/org/rhq/enterprise/server/plugins/alertRoles/RolesBackingBean.java b/modules/enterprise/server/plugins/alert-roles/src/main/java/org/rhq/enterprise/server/plugins/alertRoles/RolesBackingBean.java index a83c9cf..f0a7b96 100644 --- a/modules/enterprise/server/plugins/alert-roles/src/main/java/org/rhq/enterprise/server/plugins/alertRoles/RolesBackingBean.java +++ b/modules/enterprise/server/plugins/alert-roles/src/main/java/org/rhq/enterprise/server/plugins/alertRoles/RolesBackingBean.java @@ -18,21 +18,51 @@ */ package org.rhq.enterprise.server.plugins.alertRoles;
+import java.util.HashMap; +import java.util.Map; + +import javax.annotation.PostConstruct; +import javax.ejb.Stateless; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory;
import org.jboss.seam.annotations.Name;
+import org.rhq.core.domain.authz.Role; +import org.rhq.core.domain.util.PageControl; +import org.rhq.core.domain.util.PageList; +import org.rhq.enterprise.server.authz.RoleManagerLocal; +import org.rhq.enterprise.server.plugin.pc.alert.AlertBackingBean; +import org.rhq.enterprise.server.util.LookupUtil; + /** * // TODO: Document this * @author Heiko W. Rupp */ -@Name("RolesBackingBean") -public class RolesBackingBean { +public class RolesBackingBean implements AlertBackingBean {
private final Log log = LogFactory.getLog(RolesBackingBean.class);
- public String getMessage() { + public String getString() { return "Hello BackingBean"; } + + public Map<String,String> getMap() { + Map<String,String> map = new HashMap(); + + RoleManagerLocal mgr = LookupUtil.getRoleManager(); + PageList<Role> roles = mgr.findRoles(new PageControl()); + + for (Role role : roles) { + map.put(role.getName(),role.getName()); + } + return map; + } + + public void submit() { + + System.out.println("In Submit"); + // TODO: Customise this generated block + } } diff --git a/modules/enterprise/server/plugins/alert-roles/src/main/resources/roles.xhtml b/modules/enterprise/server/plugins/alert-roles/src/main/resources/roles.xhtml index 49dcf0b..2a90ab9 100644 --- a/modules/enterprise/server/plugins/alert-roles/src/main/resources/roles.xhtml +++ b/modules/enterprise/server/plugins/alert-roles/src/main/resources/roles.xhtml @@ -9,8 +9,26 @@ xmlns:a4j="https://richfaces.org/a4j" xmlns:rich="http://richfaces.ajax4jsf.org/rich%22%3E
- <h:outputText value="Hello New Facelet roles world"/> + <h:outputText value="Hello New Facelet roles world: #{ListNotificationsUIBean.selectedSender}"/> + +
<br/> - <h:outputText value="#{RolesBackingBean.message}"/> + <h:outputText value="#{GenericAlertStuffUIBean.theString}"> + <f:param name="sender" value="Roles"/> + </h:outputText> + + <p/> + Select a user:<br/> + <h:selectOneMenu id="mySenderList" value="#{GenericAlertStuffUIBean.theValue}"> + <f:selectItems value="#{GenericAlertStuffUIBean.theMap}"/> + </h:selectOneMenu> + + <h:commandButton + id="roles_submit" + value="Add them" + type="submit" + action="#{GenericAlertStuffUIBean.submitForm}" + /> + </html> \ No newline at end of file
commit cb18055cfd528342fda2ddeed570ef5b15fd4183 Author: John Sanda jsanda@redhat.com Date: Mon Dec 14 22:34:48 2009 -0500
[BZ 538088] Reverting back to using the view ui bean which only has a request scope.
view.xhtml in several places in the JSF code was making calls to ExistingResourceConfigurationUIBean which has session scope. As a result, external config updagtes were not immediately visible because the configuration objects were getting cached for the duration of the session, whereas ExistingResourceConfigurationViewUIBean has a scope of request so every request for the view page results in fetching the latest configuration for the resource.
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml index 0d4899f..72da244 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml @@ -44,27 +44,27 @@ THIS TEXT WILL BE REMOVED. <input type="hidden" name="id" value="#{ResourceUIBean.id}"/>
<h:panelGrid columns="2" styleClass="buttons-table" columnClasses="button-cell" - rendered="#{ExistingResourceConfigurationUIBean.configuration != null and !ExistingResourceConfigurationUIBean.updateInProgress}"> + rendered="#{ExistingResourceConfigurationViewUIBean.configuration != null and !ExistingResourceConfigurationViewUIBean.updateInProgress}">
- <h:commandButton value="#{messages.editstructured}" action="#{ExistingResourceConfigurationUIBean.editConfiguration}" + <h:commandButton value="#{messages.editstructured}" action="#{ExistingResourceConfigurationViewUIBean.editConfiguration}" title="Edit this Configuration" styleClass="buttonmed" - rendered="${ResourceUIBean.permissions.configure and ExistingResourceConfigurationUIBean.structuredSupported and !ExistingResourceConfigurationUIBean.updateInProgress}" /> + rendered="${ResourceUIBean.permissions.configure and ExistingResourceConfigurationViewUIBean.structuredSupported and !ExistingResourceConfigurationViewUIBean.updateInProgress}" /> <h:commandButton value="#{messages.editraw}" action="#{ExistingResourceConfigurationUIBean.editRawConfiguration}" title="Advanced Mode Edit of Raw Configuration Files" styleClass="buttonmed" - rendered="${ResourceUIBean.permissions.configure and ExistingResourceConfigurationUIBean.rawSupported and !ExistingResourceConfigurationUIBean.updateInProgress}" /> + rendered="${ResourceUIBean.permissions.configure and ExistingResourceConfigurationViewUIBean.rawSupported and !ExistingResourceConfigurationViewUIBean.updateInProgress}" /> </h:panelGrid>
- <onc:config configurationDefinition="#{ExistingResourceConfigurationUIBean.configurationDefinition}" - configuration="#{ExistingResourceConfigurationUIBean.configuration}" - accessMapActionExpression="#{ExistingResourceConfigurationUIBean.accessMap}" + <onc:config configurationDefinition="#{ExistingResourceConfigurationViewUIBean.configurationDefinition}" + configuration="#{ExistingResourceConfigurationViewUIBean.configuration}" + accessMapActionExpression="#{ExistingResourceConfigurationViewUIBean.accessMap}" readOnly="true" - nullConfigurationDefinitionMessage="#{ExistingResourceConfigurationUIBean.nullConfigurationDefinitionMessage}" - nullConfigurationMessage="#{ExistingResourceConfigurationUIBean.nullConfigurationMessage}" + nullConfigurationDefinitionMessage="#{ExistingResourceConfigurationViewUIBean.nullConfigurationDefinitionMessage}" + nullConfigurationMessage="#{ExistingResourceConfigurationViewUIBean.nullConfigurationMessage}" prevalidate="true"/>
</h:form>
- <h:panelGroup layout="block" styleClass="InfoBlock" rendered="#{ExistingResourceConfigurationUIBean.updateInProgress}"> + <h:panelGroup layout="block" styleClass="InfoBlock" rendered="#{ExistingResourceConfigurationViewUIBean.updateInProgress}"> <b>${msg['note']}</b> ${msg['resource.config.Current.updateInProgress']} </h:panelGroup>
commit c73d40ce3406a3cc904fb34429b9248b48f8e531 Author: John Sanda jsanda@redhat.com Date: Mon Dec 14 22:17:14 2009 -0500
[BZ 544136] Fixing bug that prevented see history for raw config updates
The UI code, ListConfigurationUpdateUIBean, calls ConfigurationManagerBean.findResourceConfigurationUpdates(). That method has logic which checks that the configuration definition actually supports updates. It does this by checking that there exists property definitions. If none exists, the method returns immediately. That logic of course applies to structured only configurations. It has been modified for raw.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java index fb82e6e..586d603 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java @@ -842,8 +842,9 @@ public class ConfigurationManagerBean implements ConfigurationManagerLocal, Conf }
Resource resource = entityManager.find(Resource.class, resourceId); - if (resource.getResourceType().getResourceConfigurationDefinition() == null - || resource.getResourceType().getResourceConfigurationDefinition().getPropertyDefinitions().isEmpty()) { + ConfigurationDefinition configDef = resource.getResourceType().getResourceConfigurationDefinition(); + if ((configDef == null || configDef.getPropertyDefinitions().isEmpty()) + && configDef.getConfigurationFormat() == ConfigurationFormat.STRUCTURED) { return new PageList<ResourceConfigurationUpdate>(pc); }
commit 6f448b4bcfb4f9aef80221b9fee3b10f15a7b291 Merge: 313a721... 10dbcf9... Author: Jay Shaughnessy jshaughn@redhat.com Date: Mon Dec 14 22:05:07 2009 -0500
Merge branch 'master-dev'
commit 10dbcf9a05766c2d2cfda7040176d51655e22c16 Author: Jay Shaughnessy jshaughn@redhat.com Date: Mon Dec 14 22:04:01 2009 -0500
Several changes to 2.61 for logic/sql. Also 2.63 and 2.68. Now runs to completion and is hopefully correct. But, the content team should review to ensure it's matching the results of dbsetup.
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml index f70f2fa..c84b55e 100644 --- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml +++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml @@ -1867,12 +1867,34 @@ </schemaSpec>
<schemaSpec version="2.61"> - <schema-directSQL> + <schema-directSQL> + <statement> + CREATE TABLE RHQ_DISTRIBUTION_TYPE ( ID INTEGER PRIMARY KEY ) + </statement> + </schema-directSQL> + <schema-alterColumn table="RHQ_DISTRIBUTION_TYPE" column="ID" nullable="false" /> + <schema-addColumn table="RHQ_DISTRIBUTION_TYPE" column="NAME" precision="200" columnType="VARCHAR2" /> + <schema-alterColumn table="RHQ_DISTRIBUTION_TYPE" column="NAME" nullable="false" /> + <schema-addColumn table="RHQ_DISTRIBUTION_TYPE" column="DESCRIPTION" precision="500" columnType="VARCHAR2" /> + <schema-directSQL> + <statement> + INSERT INTO + RHQ_DISTRIBUTION_TYPE ( ID, NAME, DESCRIPTION ) + VALUES ( 1, 'kickstart', 'Linux kickstart distribution' ) + </statement> + <statement> + INSERT INTO + RHQ_DISTRIBUTION_TYPE ( ID, NAME, DESCRIPTION ) + VALUES ( 2, 'jumpstart', 'solaris jumpstart distribution' ) + </statement> + </schema-directSQL> + + <schema-directSQL> <statement desc="Creating table RHQ_DISTRIBUTION"> CREATE TABLE RHQ_DISTRIBUTION ( ID INTEGER PRIMARY KEY ) </statement> </schema-directSQL> - <schema-addColumn table="RHQ_DISTRIBUTION" column="DISTRIBUTION_TYPE_ID" nullable="false" columnType="INTEGER"/> + <schema-addColumn table="RHQ_DISTRIBUTION" column="DISTRIBUTION_TYPE_ID" columnType="INTEGER"/> <schema-alterColumn table="RHQ_DISTRIBUTION" column="DISTRIBUTION_TYPE_ID" nullable="false"/> <schema-addColumn table="RHQ_DISTRIBUTION" column="LABEL" precision="64" columnType="VARCHAR2" /> <schema-alterColumn table="RHQ_DISTRIBUTION" column="LABEL" nullable="false" /> @@ -1885,19 +1907,20 @@ CREATE UNIQUE INDEX RHQ_DISTRIBUTION_IDX ON RHQ_DISTRIBUTION ( LABEL, BASE_PATH ) </statement> </schema-directSQL> - <statement targetDBVendor="postgresql"> - ALTER TABLE RHQ_DISTRIBUTION - ADD CONSTRAINT RHQ_DIST_TYPE_FKEY - FOREIGN KEY ( DISTRIBUTION_TYPE_ID ) - REFERENCES RHQ_DISTRIBUTION_TYPE ( ID ) - </statement> - <statement targetDBVendor="oracle"> - ALTER TABLE RHQ_DISTRIBUTION - ADD FOREIGN KEY ( DISTRIBUTION_TYPE_ID ) - REFERENCES RHQ_DISTRIBUTION_TYPE ( ID ) - </statement> - - + <schema-directSQL> + <statement targetDBVendor="postgresql"> + ALTER TABLE RHQ_DISTRIBUTION + ADD CONSTRAINT RHQ_DIST_TYPE_FKEY + FOREIGN KEY ( DISTRIBUTION_TYPE_ID ) + REFERENCES RHQ_DISTRIBUTION_TYPE ( ID ) + </statement> + <statement targetDBVendor="oracle"> + ALTER TABLE RHQ_DISTRIBUTION + ADD FOREIGN KEY ( DISTRIBUTION_TYPE_ID ) + REFERENCES RHQ_DISTRIBUTION_TYPE ( ID ) + </statement> + </schema-directSQL> + <schema-directSQL> <statement desc="Creating table RHQ_REPO_DISTRIBUTION"> CREATE TABLE RHQ_REPO_DISTRIBUTION ( REPO_ID INTEGER ) @@ -1910,13 +1933,13 @@ <schema-alterColumn table="RHQ_REPO_DISTRIBUTION" column="LAST_MODIFIED" nullable="false" /> <schema-directSQL> <statement> - ALTER TABLE RHQ_REPO_DISTRIBUTION - ADD CONSTRAINT RHQ_REPO_DIST_MAP_KEY + ALTER TABLE RHQ_REPO_DISTRIBUTION ADD CONSTRAINT RHQ_REPO_DIST_MAP_KEY PRIMARY KEY ( REPO_ID, DISTRIBUTION_ID ) </statement> - <statement targetDBVendor="postgresql"> + + <statement targetDBVendor="postgresql"> ALTER TABLE RHQ_REPO_DISTRIBUTION - ADD CONSTRAINT RHQ_DIST_REPO_ID_FKEY + ADD CONSTRAINT RHQ_REPO_DIST_REPO_ID_FKEY FOREIGN KEY ( REPO_ID ) REFERENCES RHQ_REPO ( ID ) </statement> @@ -1924,56 +1947,20 @@ ALTER TABLE RHQ_REPO_DISTRIBUTION ADD FOREIGN KEY ( REPO_ID ) REFERENCES RHQ_REPO ( ID ) - </statement> + </statement> + <statement targetDBVendor="postgresql"> ALTER TABLE RHQ_REPO_DISTRIBUTION - ADD CONSTRAINT RHQ_REPO_DIST_ID_FKEY + ADD CONSTRAINT RHQ_REPO_DIST_DIST_ID_FKEY FOREIGN KEY ( DISTRIBUTION_ID ) REFERENCES RHQ_DISTRIBUTION ( ID ) - </statement> + </statement> <statement targetDBVendor="oracle"> ALTER TABLE RHQ_REPO_DISTRIBUTION ADD FOREIGN KEY ( DISTRIBUTION_ID ) REFERENCES RHQ_DISTRIBUTION ( ID ) </statement> </schema-directSQL> - - <schema-directSQL> - <statement> - CREATE TABLE RHQ_DISTRIBUTION_TYPE ( ID INTEGER PRIMARY KEY ) - </statement> - </schema-directSQL> - <schema-alterColumn table="RHQ_DISTRIBUTION_TYPE" column="ID" nullable="false" /> - <schema-addColumn table="RHQ_DISTRIBUTION_TYPE" column="NAME" precision="200" columnType="VARCHAR2" /> - <schema-alterColumn table="RHQ_DISTRIBUTION_TYPE" column="NAME" nullable="false" /> - <schema-addColumn table="RHQ_DISTRIBUTION_TYPE" column="DESCRIPTION" precision="500" columnType="VARCHAR2" /> - <schema-directSQL> - <statement> - INSERT INTO - RHQ_DISTRIBUTION_TYPE ( ID, NAME, DESCRIPTION ) - VALUES ( 1, 'kickstart', 'Linux kickstart distribution' ) - </statement> - <statement> - INSERT INTO - RHQ_DISTRIBUTION_TYPE ( ID, NAME, DESCRIPTION ) - VALUES ( 2, 'jumpstart', 'solaris jumpstart distribution' ) - </statement> - </schema-directSQL> - - <schema-directSQL> - <statement targetDBVendor="oracle"> - ALTER TABLE RHQ_DISTRIBUTION - ADD CONSTRAINT RHQ_DIST_FKEY - FOREIGN KEY ( DISTRIBUTION_TYPE_ID) - REFERENCES RHQ_DISTRIBUTION_TYPE ( ID ) - </statement> - <statement targetDBVendor="postgresql"> - ALTER TABLE RHQ_DISTRIBUTION - ADD CONSTRAINT RHQ_DIST_FKEY - FOREIGN KEY ( DISTRIBUTION_TYPE_ID) - REFERENCES RHQ_DISTRIBUTION_TYPE ( ID ) - </statement> - </schema-directSQL> </schemaSpec>
<schemaSpec version="2.62"> @@ -1993,6 +1980,16 @@
<schemaSpec version="2.63"> <schema-addColumn table="RHQ_REPO" column="IS_CANDIDATE" columnType="BOOLEAN"/> + + <schema-directSQL> + <statement targetDBVendor="postgresql"> + UPDATE RHQ_REPO SET IS_CANDIDATE = FALSE + </statement> + <statement targetDBVendor="oracle"> + UPDATE RHQ_REPO SET IS_CANDIDATE = 0 + </statement> + </schema-directSQL> + <schema-alterColumn table="RHQ_REPO" column="IS_CANDIDATE" nullable="false" /> </schemaSpec>
@@ -2092,12 +2089,7 @@ </schemaSpec>
<schemaSpec version="2.68"> - <schema-createSequence name="RHQ_DISTRIBUTION_FILE_SEQ" initial="10001" /> - <schema-directSQL> - <statement> - ALTER TABLE RHQ_DISTRIBUTION_FILE DROP CONSTRAINT RHQ_DISTRIBUTION_FILE_PKEY - </statement> - </schema-directSQL> + <schema-createSequence name="RHQ_DISTRIBUTION_FILE_ID_SEQ" initial="10001" />
<schema-addColumn table="RHQ_DISTRIBUTION_FILE" column="ID" columnType="INTEGER" /> <schema-alterColumn table="RHQ_DISTRIBUTION_FILE" column="ID" nullable="false" />
commit 7aa739874e164edff47e01d4ff390ff8ac7f26a6 Author: Jay Shaughnessy jshaughn@redhat.com Date: Mon Dec 14 18:27:04 2009 -0500
Multiple changes to try and repair 2.61. Removing unnecessary steps and invalid syntax.
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml index cfab5a8..f70f2fa 100644 --- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml +++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml @@ -1868,68 +1868,76 @@
<schemaSpec version="2.61"> <schema-directSQL> - <statement desc="Creating table RHQ_KICKSTARTABLE_TREE"> - CREATE TABLE RHQ_KICKSTARTABLE_TREE ( ID INTEGER PRIMARY KEY ) - </statement> - </schema-directSQL> - <schema-alterColumn table="RHQ_KICKSTARTABLE_TREE" column="ID" nullable="false" columnType="INTEGER"/> - <schema-addColumn table="RHQ_KICKSTARTABLE_TREE" column="LABEL" precision="64" columnType="VARCHAR2" /> - <schema-alterColumn table="RHQ_KICKSTARTABLE_TREE" column="LABEL" nullable="false" /> - <schema-addColumn table="RHQ_KICKSTARTABLE_TREE" column="BASE_PATH" precision="256" columnType="VARCHAR2" /> - <schema-alterColumn table="RHQ_KICKSTARTABLE_TREE" column="BASE_PATH" nullable="false" /> - <schema-addColumn table="RHQ_KICKSTARTABLE_TREE" column="LAST_MODIFIED" columnType="LONG" /> - <schema-alterColumn table="RHQ_KICKSTARTABLE_TREE" column="LAST_MODIFIED" nullable="false" /> - <schema-directSQL> - <statement targetDBVendor="postgresql"> - CREATE UNIQUE INDEX RHQ_KICKSTART_IDX - ON RHQ_KICKSTARTABLE_TREE ( LABEL, BASE_PATH ) - </statement> - <statement targetDBVendor="oracle"> - CREATE UNIQUE INDEX RHQ_KICKSTART_IDX - ON RHQ_KICKSTARTABLE_TREE ( LABEL, BASE_PATH ) - </statement> - </schema-directSQL> + <statement desc="Creating table RHQ_DISTRIBUTION"> + CREATE TABLE RHQ_DISTRIBUTION ( ID INTEGER PRIMARY KEY ) + </statement> + </schema-directSQL> + <schema-addColumn table="RHQ_DISTRIBUTION" column="DISTRIBUTION_TYPE_ID" nullable="false" columnType="INTEGER"/> + <schema-alterColumn table="RHQ_DISTRIBUTION" column="DISTRIBUTION_TYPE_ID" nullable="false"/> + <schema-addColumn table="RHQ_DISTRIBUTION" column="LABEL" precision="64" columnType="VARCHAR2" /> + <schema-alterColumn table="RHQ_DISTRIBUTION" column="LABEL" nullable="false" /> + <schema-addColumn table="RHQ_DISTRIBUTION" column="BASE_PATH" precision="256" columnType="VARCHAR2" /> + <schema-alterColumn table="RHQ_DISTRIBUTION" column="BASE_PATH" nullable="false" /> + <schema-addColumn table="RHQ_DISTRIBUTION" column="LAST_MODIFIED" columnType="LONG" /> + <schema-alterColumn table="RHQ_DISTRIBUTION" column="LAST_MODIFIED" nullable="false" /> + <schema-directSQL> + <statement> + CREATE UNIQUE INDEX RHQ_DISTRIBUTION_IDX ON RHQ_DISTRIBUTION ( LABEL, BASE_PATH ) + </statement> + </schema-directSQL> + <statement targetDBVendor="postgresql"> + ALTER TABLE RHQ_DISTRIBUTION + ADD CONSTRAINT RHQ_DIST_TYPE_FKEY + FOREIGN KEY ( DISTRIBUTION_TYPE_ID ) + REFERENCES RHQ_DISTRIBUTION_TYPE ( ID ) + </statement> + <statement targetDBVendor="oracle"> + ALTER TABLE RHQ_DISTRIBUTION + ADD FOREIGN KEY ( DISTRIBUTION_TYPE_ID ) + REFERENCES RHQ_DISTRIBUTION_TYPE ( ID ) + </statement>
- <schema-directSQL> - <statement desc="Creating table RHQ_REPO_KS_TREE"> - CREATE TABLE RHQ_REPO_KS_TREE ( REPO_ID INTEGER ) + + <schema-directSQL> + <statement desc="Creating table RHQ_REPO_DISTRIBUTION"> + CREATE TABLE RHQ_REPO_DISTRIBUTION ( REPO_ID INTEGER ) </statement> </schema-directSQL> - - <schema-alterColumn table="RHQ_REPO_KS_TREE" column="REPO_ID" nullable="false" columnType="INTEGER"/> - <schema-addColumn table="RHQ_REPO_KS_TREE" column="KICKSTART_TREE_ID" columnType="INTEGER" /> - <schema-alterColumn table="RHQ_REPO_KS_TREE" column="KICKSTART_TREE_ID" nullable="false" /> - <schema-addColumn table="RHQ_REPO_KS_TREE" column="LAST_MODIFIED" columnType="LONG" /> - <schema-alterColumn table="RHQ_REPO_KS_TREE" column="LAST_MODIFIED" nullable="false" /> + <schema-alterColumn table="RHQ_REPO_DISTRIBUTION" column="REPO_ID" nullable="false"/> + <schema-addColumn table="RHQ_REPO_DISTRIBUTION" column="DISTRIBUTION_ID" columnType="INTEGER" /> + <schema-alterColumn table="RHQ_REPO_DISTRIBUTION" column="DISTRIBUTION_ID" nullable="false" /> + <schema-addColumn table="RHQ_REPO_DISTRIBUTION" column="LAST_MODIFIED" columnType="LONG" /> + <schema-alterColumn table="RHQ_REPO_DISTRIBUTION" column="LAST_MODIFIED" nullable="false" /> <schema-directSQL> <statement> - ALTER TABLE RHQ_REPO_KS_TREE - ADD CONSTRAINT RHQ_REPO_KS_MAP_KEY - PRIMARY KEY ( REPO_ID, KICKSTART_TREE_ID ) - </statement> + ALTER TABLE RHQ_REPO_DISTRIBUTION + ADD CONSTRAINT RHQ_REPO_DIST_MAP_KEY + PRIMARY KEY ( REPO_ID, DISTRIBUTION_ID ) + </statement> <statement targetDBVendor="postgresql"> - ALTER TABLE RHQ_REPO_KS_TREE - ADD CONSTRAINT RHQ_KS_REPO_ID_FKEY + ALTER TABLE RHQ_REPO_DISTRIBUTION + ADD CONSTRAINT RHQ_DIST_REPO_ID_FKEY FOREIGN KEY ( REPO_ID ) REFERENCES RHQ_REPO ( ID ) - </statement> + </statement> <statement targetDBVendor="oracle"> - ALTER TABLE RHQ_REPO_KS_TREE + ALTER TABLE RHQ_REPO_DISTRIBUTION ADD FOREIGN KEY ( REPO_ID ) REFERENCES RHQ_REPO ( ID ) - </statement> + </statement> <statement targetDBVendor="postgresql"> - ALTER TABLE RHQ_REPO_KS_TREE - ADD CONSTRAINT RHQ_REPO_KS_TREE_ID_FKEY - FOREIGN KEY ( KICKSTART_TREE_ID ) - REFERENCES RHQ_KICKSTARTABLE_TREE ( ID ) - </statement> + ALTER TABLE RHQ_REPO_DISTRIBUTION + ADD CONSTRAINT RHQ_REPO_DIST_ID_FKEY + FOREIGN KEY ( DISTRIBUTION_ID ) + REFERENCES RHQ_DISTRIBUTION ( ID ) + </statement> <statement targetDBVendor="oracle"> - ALTER TABLE RHQ_REPO_KS_TREE - ADD FOREIGN KEY ( KICKSTART_TREE_ID ) - REFERENCES RHQ_KICKSTARTABLE_TREE ( ID ) - </statement> + ALTER TABLE RHQ_REPO_DISTRIBUTION + ADD FOREIGN KEY ( DISTRIBUTION_ID ) + REFERENCES RHQ_DISTRIBUTION ( ID ) + </statement> </schema-directSQL> + <schema-directSQL> <statement> CREATE TABLE RHQ_DISTRIBUTION_TYPE ( ID INTEGER PRIMARY KEY ) @@ -1940,7 +1948,6 @@ <schema-alterColumn table="RHQ_DISTRIBUTION_TYPE" column="NAME" nullable="false" /> <schema-addColumn table="RHQ_DISTRIBUTION_TYPE" column="DESCRIPTION" precision="500" columnType="VARCHAR2" /> <schema-directSQL> - <statement> INSERT INTO RHQ_DISTRIBUTION_TYPE ( ID, NAME, DESCRIPTION ) @@ -1952,42 +1959,6 @@ VALUES ( 2, 'jumpstart', 'solaris jumpstart distribution' ) </statement> </schema-directSQL> - <schema-directSQL> - <statement targetDBVendor="oracle"> - ALTER TABLE RHQ_REPO_KS_TREE RENAME TO RHQ_REPO_DISTRIBUTION - </statement> - <statement targetDBVendor="postgresql"> - ALTER TABLE RHQ_REPO_KS_TREE RENAME TO RHQ_REPO_DISTRIBUTION - </statement> - <statement targetDBVendor="oracle"> - ALTER TABLE RHQ_KICKSTARTABLE_TREE RENAME TO RHQ_DISTRIBUTION - </statement> - <statement targetDBVendor="postgresql"> - ALTER TABLE RHQ_KICKSTARTABLE_TREE RENAME TO RHQ_DISTRIBUTION - </statement> - <statement targetDBVendor="oracle"> - ALTER TABLE RHQ_REPO_DISTRIBUTION RENAME CONSTRAINT - RHQ_REPO_KS_TREE_ID_FKEY TO RHQ_REPO_DIST_ID_FKEY - </statement> - <statement targetDBVendor="postgresql"> - ALTER TABLE RHQ_REPO_DISTRIBUTION RENAME CONSTRAINT - RHQ_REPO_KS_TREE_ID_FKEY TO RHQ_REPO_DIST_ID_FKEY - </statement> - <statement targetDBVendor="oracle"> - ALTER TABLE RHQ_REPO_DISTRIBUTION RENAME CONSTRAINT - RHQ_REPO_KS_MAP_KEY TO RHQ_REPO_DIST_MAP_KEY - </statement> - <statement targetDBVendor="postgresql"> - ALTER TABLE RHQ_REPO_DISTRIBUTION RENAME CONSTRAINT - RHQ_REPO_KS_MAP_KEY TO RHQ_REPO_DIST_MAP_KEY - </statement> - <statement targetDBVendor="oracle"> - ALTER INDEX RHQ_KICKSTART_IDX RENAME TO RHQ_DISTRIBUTION_IDX - </statement> - <statement targetDBVendor="postgresql"> - ALTER INDEX RHQ_KICKSTART_IDX RENAME TO RHQ_DISTRIBUTION_IDX - </statement> - </schema-directSQL>
<schema-directSQL> <statement targetDBVendor="oracle">
commit 6cbb7df18da1585103d5b819f80c1b00ad019aab Author: Adam Young ayoung@redhat.com Date: Mon Dec 14 17:48:32 2009 -0500
started pushing the decode and encode stuff into the appropriate portion of the jsf lifecycle.
diff --git a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/ConfigRenderer.java b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/ConfigRenderer.java index b4f76f1..e3f0c16 100644 --- a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/ConfigRenderer.java +++ b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/ConfigRenderer.java @@ -88,7 +88,7 @@ public class ConfigRenderer extends Renderer { protected static final String GROUP_DESCRIPTION_PANEL_STYLE_CLASS = "group-description-panel"; protected static final String GROUP_DESCRIPTION_TEXT_PANEL_STYLE_CLASS = "group-description-text-panel";
- private final Log LOG = LogFactory.getLog(ConfigRenderer.class); + private static final Log LOG = LogFactory.getLog(ConfigRenderer.class); private static final String INIT_INPUTS_JAVA_SCRIPT_COMPONENT_ID_SUFFIX = "-initInputsJavaScript";
/** @@ -264,7 +264,7 @@ public class ConfigRenderer extends Renderer { }
Boolean shouldShowRawNow = configurationComponent.getShouldShowRaw(); - //addStructuredRawToggle(configurationComponent, shouldShowRawNow); + if (shouldShowRawNow) { configurationComponent.getChildren().add( new RawConfigUIComponent(configurationComponent.getConfiguration(), configurationComponent @@ -458,7 +458,7 @@ public class ConfigRenderer extends Renderer { + mapName + "'."); }
- private void addRequiredNotationsKey(AbstractConfigurationComponent config) { + private static void addRequiredNotationsKey(AbstractConfigurationComponent config) { addDebug(config, true, ".addNotePanel()"); HtmlPanelGroup footnotesPanel = FacesComponentUtility.addBlockPanel(config, config, NOTE_PANEL_STYLE_CLASS); FacesComponentUtility.addOutputText(footnotesPanel, config, "*", REQUIRED_MARKER_TEXT_STYLE_CLASS); @@ -573,11 +573,11 @@ public class ConfigRenderer extends Renderer { * @param start true if this is the "START" comment, false if it is the "END" comment * @param methodName the name of the method this is calling from */ - private void addDebug(UIComponent component, boolean start, String methodName) { + private static void addDebug(UIComponent component, boolean start, String methodName) { if (LOG.isDebugEnabled()) { StringBuilder msg = new StringBuilder("\n<!--"); msg.append(start ? " START " : " END "); - msg.append(this.getClass().getSimpleName()); + msg.append(ConfigRenderer.class.getSimpleName()); msg.append(methodName); msg.append(" -->\n "); FacesComponentUtility.addVerbatimText(component, msg); diff --git a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/RawConfigUIComponent.java b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/RawConfigUIComponent.java index 5280cb0..ce42a54 100644 --- a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/RawConfigUIComponent.java +++ b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/RawConfigUIComponent.java @@ -5,12 +5,15 @@ import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.Map; +import java.util.Vector;
import javax.faces.component.UIComponent; import javax.faces.component.UIComponentBase; import javax.faces.component.UIPanel; +import javax.faces.component.UIParameter; import javax.faces.component.html.HtmlCommandLink; import javax.faces.component.html.HtmlInputTextarea; +import javax.faces.component.html.HtmlOutputLink; import javax.faces.component.html.HtmlPanelGrid; import javax.faces.context.FacesContext;
@@ -24,11 +27,13 @@ import org.rhq.core.gui.util.FacesContextUtility; public class RawConfigUIComponent extends UIComponentBase {
private boolean readOnly; + private boolean showRaw;
@Override public void decode(FacesContext context) { super.decode(context); setSelectedPath(FacesContextUtility.getOptionalRequestParameter("path")); + readOnly = Boolean.valueOf(FacesContextUtility.getOptionalRequestParameter("readOnly"));
}
@@ -82,6 +87,8 @@ public class RawConfigUIComponent extends UIComponentBase { return true; }
+ Vector<UIParameter> readOnlyParms = new Vector<UIParameter>(); + public RawConfigUIComponent(Configuration configuration, ConfigurationDefinition configurationDefinition, FacesComponentIdFactory componentIdFactory, boolean readOnly) {
@@ -91,7 +98,8 @@ public class RawConfigUIComponent extends UIComponentBase { this.readOnly = readOnly;
UIPanel rawPanel = FacesComponentUtility.addBlockPanel(this, idFactory, ""); - addToolbarIcons(rawPanel, configurationDefinition.getConfigurationFormat().isStructuredSupported()); + + addToolbar(configurationDefinition, rawPanel);
HtmlPanelGrid grid = FacesComponentUtility.addPanelGrid(rawPanel, idFactory, "summary-props-table"); grid.setParent(this); @@ -130,6 +138,9 @@ public class RawConfigUIComponent extends UIComponentBase { FacesComponentUtility.addParameter(link, idFactory, "path", raw.getPath()); FacesComponentUtility.addParameter(link, idFactory, "whichRaw", Integer.toString(rawCount++)); FacesComponentUtility.addParameter(link, idFactory, "showRaw", Boolean.TRUE.toString()); + readOnlyParms.add(FacesComponentUtility.addParameter(link, idFactory, "readOnly", Boolean + .toString(readOnly))); + }
UIPanel panelRight = FacesComponentUtility.addBlockPanel(grid, idFactory, "summary-props-table"); @@ -144,8 +155,8 @@ public class RawConfigUIComponent extends UIComponentBase { inputTextarea.setReadonly(readOnly); }
- private void addToolbarIcons(UIPanel toolbarPanel, boolean supportsStructured) { - + private void addToolbar(ConfigurationDefinition configurationDefinition, UIPanel parent) { + UIPanel toolbarPanel = FacesComponentUtility.addBlockPanel(parent, idFactory, "config-toolbar"); if (readOnly) { HtmlCommandLink editLink = FacesComponentUtility.addCommandLink(toolbarPanel, idFactory); FacesComponentUtility.addGraphicImage(editLink, idFactory, "/images/edit.png", "Edit"); @@ -157,24 +168,31 @@ public class RawConfigUIComponent extends UIComponentBase { FacesComponentUtility.addOutputText(saveLink, idFactory, "Save", ""); FacesComponentUtility.addParameter(saveLink, idFactory, "showStructured", Boolean.FALSE.toString()); } - HtmlCommandLink saveCommandLink = FacesComponentUtility.addCommandLink(toolbarPanel, idFactory); - FacesComponentUtility.addGraphicImage(saveCommandLink, idFactory, "/images/viewfullscreen.png", "FullScreen"); - FacesComponentUtility.addOutputText(saveCommandLink, idFactory, "Full Screen", ""); - - HtmlCommandLink uploadCommandLink = FacesComponentUtility.addCommandLink(toolbarPanel, idFactory); - FacesComponentUtility.addGraphicImage(uploadCommandLink, idFactory, "/images/upload.png", "Upload"); - FacesComponentUtility.addOutputText(uploadCommandLink, idFactory, "Upload", ""); - - HtmlCommandLink downloadCommandLink = FacesComponentUtility.addCommandLink(toolbarPanel, idFactory); - FacesComponentUtility.addGraphicImage(downloadCommandLink, idFactory, "/images/download.png", "download"); - FacesComponentUtility.addOutputText(downloadCommandLink, idFactory, "Download", ""); - - if (supportsStructured) { + { + HtmlCommandLink saveCommandLink = FacesComponentUtility.addCommandLink(toolbarPanel, idFactory); + FacesComponentUtility.addGraphicImage(saveCommandLink, idFactory, "/images/viewfullscreen.png", + "FullScreen"); + FacesComponentUtility.addOutputText(saveCommandLink, idFactory, "Full Screen", ""); + } + if (!readOnly) { + HtmlOutputLink uploadLink = FacesComponentUtility.addOutputLink(toolbarPanel, idFactory, "upload.xhtml"); + FacesComponentUtility.addGraphicImage(uploadLink, idFactory, "/images/upload.png", "Upload"); + FacesComponentUtility.addOutputText(uploadLink, idFactory, "Upload", ""); + } + { + HtmlOutputLink downloadLink = FacesComponentUtility + .addOutputLink(toolbarPanel, idFactory, "download.xhtml"); + FacesComponentUtility.addGraphicImage(downloadLink, idFactory, "/images/download.png", "download"); + FacesComponentUtility.addOutputText(downloadLink, idFactory, "Download", ""); + } + if (configurationDefinition.getConfigurationFormat().isStructuredSupported()) { HtmlCommandLink toStructureLink = FacesComponentUtility.addCommandLink(toolbarPanel, idFactory); FacesComponentUtility.addGraphicImage(toStructureLink, idFactory, "/images/structured.png", "showStructured"); FacesComponentUtility.addOutputText(toStructureLink, idFactory, "showStructured", ""); - FacesComponentUtility.addParameter(toStructureLink, idFactory, "showStructured", Boolean.FALSE.toString()); + FacesComponentUtility.addParameter(toStructureLink, idFactory, "showRaw", Boolean.FALSE.toString()); + readOnlyParms.add(FacesComponentUtility.addParameter(toStructureLink, idFactory, "readOnly", Boolean + .toString(readOnly))); } }
@@ -183,6 +201,9 @@ public class RawConfigUIComponent extends UIComponentBase { // TODO Auto-generated method stub super.encodeBegin(context); inputTextarea.setValue(rawMap.get(getSelectedPath()).getContentString()); + for (UIParameter param : readOnlyParms) { + param.setValue(Boolean.toString(readOnly)); + }
} } diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml index dabda7e..d0cfa5c 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml @@ -30,6 +30,9 @@ THIS TEXT WILL BE REMOVED. vertical-align: top; valign: top; } + config-toolbar{ + float: right; + } </style>
commit 313a721af141da069e9441398b12ef2cb09a9cb6 Merge: e420319... feb99dc... Author: John Mazzitelli mazz@redhat.com Date: Mon Dec 14 17:26:37 2009 -0500
Merge branch 'mazz'
commit feb99dcf385d61c3ddc09e7b032b6755063d5b3b Author: John Mazzitelli mazz@redhat.com Date: Mon Dec 14 17:25:15 2009 -0500
if a plugin was undeployed, enabled or disabled on another server in the cloud, all other servers will update themselves within a few minutes.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/plugin/AgentPluginScanner.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/plugin/AgentPluginScanner.java index 5112347..6beb1f7 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/plugin/AgentPluginScanner.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/plugin/AgentPluginScanner.java @@ -154,7 +154,7 @@ public class AgentPluginScanner { for (File filesystemPluginFile : pluginJars) { if (cachedPluginFile.equals(filesystemPluginFile)) { existsOnFileSystem = true; - continue; // our cached jar still exists on the file system + break; // our cached jar still exists on the file system } } if (!existsOnFileSystem) { diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/plugin/ServerPluginScanner.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/plugin/ServerPluginScanner.java index a6ff24c..a58afb2 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/plugin/ServerPluginScanner.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/plugin/ServerPluginScanner.java @@ -27,6 +27,7 @@ import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.ArrayList; +import java.util.Arrays; import java.util.Date; import java.util.HashMap; import java.util.List; @@ -49,6 +50,8 @@ import org.rhq.core.util.jdbc.JDBCUtil; import org.rhq.core.util.stream.StreamUtil; import org.rhq.enterprise.server.auth.SubjectManagerLocal; import org.rhq.enterprise.server.plugin.ServerPluginsLocal; +import org.rhq.enterprise.server.plugin.pc.AbstractTypeServerPluginContainer; +import org.rhq.enterprise.server.plugin.pc.MasterServerPluginContainer; import org.rhq.enterprise.server.plugin.pc.ServerPluginType; import org.rhq.enterprise.server.util.LookupUtil; import org.rhq.enterprise.server.xmlschema.ServerPluginDescriptorMetadataParser; @@ -87,6 +90,8 @@ public class ServerPluginScanner { * This should be called after a call to {@link #serverPluginScan()} to register * plugins that were found in the scan. * + * This will also check to see if previously registered plugins changed their state. + * * @throws Exception */ void registerServerPlugins() throws Exception { @@ -95,6 +100,52 @@ public class ServerPluginScanner { registerServerPlugin(file); } this.scanned.clear(); + + // we now have to see if the state of existing plugins have changed in the DB + ServerPluginsLocal serverPluginsManager = LookupUtil.getServerPlugins(); + List<ServerPlugin> allPlugins = serverPluginsManager.getAllServerPlugins(); + List<ServerPlugin> installedPlugins = new ArrayList<ServerPlugin>(); + List<ServerPlugin> undeployedPlugins = new ArrayList<ServerPlugin>(); + for (ServerPlugin allPlugin : allPlugins) { + if (allPlugin.getStatus() == PluginStatusType.INSTALLED) { + installedPlugins.add(allPlugin); + } else { + undeployedPlugins.add(allPlugin); + } + } + + // first, have any plugins been undeployed since we last checked? + for (ServerPlugin undeployedPlugin : undeployedPlugins) { + File undeployedFile = new File(this.getServerPluginDir(), undeployedPlugin.getPath()); + PluginWithDescriptor pluginWithDescriptor = this.serverPluginsOnFilesystem.get(undeployedFile); + if (pluginWithDescriptor != null) { + try { + log.info("Plugin file [" + undeployedFile + "] has been undeployed. It will be deleted."); + List<Integer> id = Arrays.asList(new Integer(undeployedPlugin.getId())); + serverPluginsManager.undeployServerPlugins(LookupUtil.getSubjectManager().getOverlord(), id); + } finally { + this.serverPluginsOnFilesystem.remove(undeployedFile); + } + } + } + + // now see if any plugins changed state from enabled->disabled or vice versa + MasterServerPluginContainer master = LookupUtil.getServerPluginService().getMasterPluginContainer(); + if (master != null) { + for (ServerPlugin installedPlugin : installedPlugins) { + PluginKey key = PluginKey.createServerPluginKey(installedPlugin.getType(), installedPlugin.getName()); + AbstractTypeServerPluginContainer pc = master.getPluginContainerByPlugin(key); + if (pc != null && pc.isPluginLoaded(key)) { + boolean currentlyEnabled = pc.isPluginEnabled(key); + if (installedPlugin.isEnabled() != currentlyEnabled) { + log.info("Detected a change to plugin [" + key + "]. It will now be " + + ((installedPlugin.isEnabled()) ? "[enabled]" : "[disabled]")); + pc.reloadPlugin(key, installedPlugin.isEnabled()); + } + } + } + } + return; }
@@ -231,7 +282,7 @@ public class ServerPluginScanner { for (File filesystemPluginFile : pluginJars) { if (cachedPluginFile.equals(filesystemPluginFile)) { existsOnFileSystem = true; - continue; // our cached jar still exists on the file system + break; // our cached jar still exists on the file system } } if (!existsOnFileSystem) { @@ -353,7 +404,7 @@ public class ServerPluginScanner { // the same list as above, only they are the files that are written to the filesystem and no longer missing List<File> updatedFiles = new ArrayList<File>();
- // get all the plugins + // process all the installed plugins ServerPluginsLocal serverPluginsManager = LookupUtil.getServerPlugins(); List<ServerPlugin> installedPlugins = serverPluginsManager.getServerPlugins(); for (ServerPlugin installedPlugin : installedPlugins) { diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/AbstractTypeServerPluginContainer.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/AbstractTypeServerPluginContainer.java index b5572be..17b60ca 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/AbstractTypeServerPluginContainer.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/AbstractTypeServerPluginContainer.java @@ -84,6 +84,32 @@ public abstract class AbstractTypeServerPluginContainer { }
/** + * Determines if the given plugin is loaded in the plugin container. + * The plugin may be loaded but not enabled. + * + * @param pluginKey + * + * @return <code>true</code> if the plugin is loaded in this plugin container; <code>false</code> otherwise + */ + public boolean isPluginLoaded(PluginKey pluginKey) { + return this.pluginManager.isPluginLoaded(pluginKey.getPluginName()); + } + + /** + * Determines if the given plugin is enabled in the plugin container. + * <code>true</code> implies the plugin is also loaded. If <code>false</code> is returned, + * it is either because the plugin is loaded but disabled, or the plugin is just + * not loaded. Use {@link #isPluginLoaded(PluginKey)} to know if the plugin is loaded or not. + * + * @param pluginKey + * + * @return <code>true</code> if the plugin is enabled in this plugin container; <code>false</code> otherwise + */ + public boolean isPluginEnabled(PluginKey pluginKey) { + return this.pluginManager.isPluginEnabled(pluginKey.getPluginName()); + } + + /** * The initialize method that prepares the plugin container. This should get the plugin * container ready to accept plugins. *
commit 83ec25d69ccf72369ef005c2b90b48dcc7986d0e Author: John Mazzitelli mazz@redhat.com Date: Mon Dec 14 17:23:08 2009 -0500
only link to the details page if the plugin is installed
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/plugin/plugin-list.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/plugin/plugin-list.xhtml index 15b3601..bca336f 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/plugin/plugin-list.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/plugin/plugin-list.xhtml @@ -162,12 +162,13 @@ <h:outputText styleClass="headerText" value="Name"/> </f:facet>
- <h:outputLink value="/rhq/admin/plugin/plugin-details-view.xhtml"> + <h:outputLink value="/rhq/admin/plugin/plugin-details-view.xhtml" rendered="#{serverPlugin.enabled}"> <f:param name="plugin" value="#{serverPlugin.name}"/> <f:param name="deployment" value="SERVER"/> <f:param name="pluginType" value="#{serverPlugin.type}"/> <h:outputText value="#{serverPlugin.displayName}"/> </h:outputLink> + <h:outputText value="#{serverPlugin.displayName}" rendered="#{!serverPlugin.enabled}"/>
</rich:column>
commit 546c68abe21d035952aab368fe65492065a30a58 Author: Jay Shaughnessy jshaughn@redhat.com Date: Mon Dec 14 17:16:08 2009 -0500
Fix up direct SQL error in 2.61
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml index a2182a7..cfab5a8 100644 --- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml +++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml @@ -1943,12 +1943,12 @@
<statement> INSERT INTO - RHQ_DISTRIBUTION_TYPE ( ID, NAME ) + RHQ_DISTRIBUTION_TYPE ( ID, NAME, DESCRIPTION ) VALUES ( 1, 'kickstart', 'Linux kickstart distribution' ) </statement> <statement> INSERT INTO - RHQ_DISTRIBUTION_TYPE ( ID, NAME ) + RHQ_DISTRIBUTION_TYPE ( ID, NAME, DESCRIPTION ) VALUES ( 2, 'jumpstart', 'solaris jumpstart distribution' ) </statement> </schema-directSQL>
commit e420319f056a06b3aed5c37c4a09f4d4c17a4101 Author: Jason Dobies jason.dobies@redhat.com Date: Mon Dec 14 15:04:00 2009 -0500
1054 - BZ 537216 - Need to reload the repo to get around HHH-2864.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/RepoManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/RepoManagerBean.java index 9f89050..7e96a7b 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/RepoManagerBean.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/RepoManagerBean.java @@ -300,6 +300,9 @@ public class RepoManagerBean implements RepoManagerLocal, RepoManagerRemote { throw new RepoException("Repo name is required"); }
+ // HHH-2864 - Leave this in until we move to hibernate > 3.2.r14201-2 + getRepo(subject, repo.getId()); + // should we check non-null repo relationships and warn that we aren't changing them? log.debug("User [" + subject + "] is updating repo [" + repo + "]"); repo = entityManager.merge(repo);
commit 4d88d5859f468ff0c973786cdebca0336c212609 Author: John Mazzitelli mazz@redhat.com Date: Mon Dec 14 14:46:56 2009 -0500
use SLSB to get plugins, not jdbc
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/plugin/ServerPluginScanner.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/plugin/ServerPluginScanner.java index d39c8ef..a6ff24c 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/plugin/ServerPluginScanner.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/plugin/ServerPluginScanner.java @@ -347,139 +347,139 @@ public class ServerPluginScanner { * @return a list of files that appear to be new or updated and should be deployed */ private List<File> serverPluginScanDatabase() throws Exception { - Connection conn = null; - PreparedStatement ps = null; - ResultSet rs = null; - // these are plugins (name/path/md5/mtime) that have changed in the DB but are missing from the file system List<ServerPlugin> updatedPlugins = new ArrayList<ServerPlugin>();
// the same list as above, only they are the files that are written to the filesystem and no longer missing List<File> updatedFiles = new ArrayList<File>();
- try { - DataSource ds = LookupUtil.getDataSource(); - conn = ds.getConnection(); - - // get all the plugins - ps = conn.prepareStatement("SELECT NAME, PATH, MD5, MTIME, VERSION, PTYPE FROM " + ServerPlugin.TABLE_NAME - + " WHERE DEPLOYMENT = 'SERVER' AND STATUS = 'INSTALLED' "); - rs = ps.executeQuery(); - while (rs.next()) { - String name = rs.getString(1); - String path = rs.getString(2); - String md5 = rs.getString(3); - long mtime = rs.getLong(4); - String version = rs.getString(5); - ServerPluginType pluginType = new ServerPluginType(rs.getString(6)); - - // let's see if we have this logical plugin on the filesystem (it may or may not be under the same filename) - File expectedFile = new File(this.getServerPluginDir(), path); - File currentFile = null; // will be non-null if we find that we have this plugin on the filesystem already - PluginWithDescriptor pluginWithDescriptor = this.serverPluginsOnFilesystem.get(expectedFile); - - if (pluginWithDescriptor != null) { - currentFile = expectedFile; // we have it where we are expected to have it - if (!pluginWithDescriptor.plugin.getName().equals(name) - || !pluginType.equals(pluginWithDescriptor.pluginType)) { - // Happens if someone wrote a plugin of one type but later changed it to a different type (or changed names) - log.warn("For some reason, the server plugin file [" + expectedFile + "] is plugin [" - + pluginWithDescriptor.plugin.getName() + "] of type [" + pluginWithDescriptor.pluginType - + "] but the database says it should be [" + name + "] of type [" + pluginType + "]"); - } else { - log.debug("File system and db agree on server plugin location for [" + expectedFile + "]"); - } + // get all the plugins + ServerPluginsLocal serverPluginsManager = LookupUtil.getServerPlugins(); + List<ServerPlugin> installedPlugins = serverPluginsManager.getServerPlugins(); + for (ServerPlugin installedPlugin : installedPlugins) { + String name = installedPlugin.getName(); + String path = installedPlugin.getPath(); + String md5 = installedPlugin.getMd5(); + long mtime = installedPlugin.getMtime(); + String version = installedPlugin.getVersion(); + ServerPluginType pluginType = new ServerPluginType(installedPlugin.getType()); + + // let's see if we have this logical plugin on the filesystem (it may or may not be under the same filename) + File expectedFile = new File(this.getServerPluginDir(), path); + File currentFile = null; // will be non-null if we find that we have this plugin on the filesystem already + PluginWithDescriptor pluginWithDescriptor = this.serverPluginsOnFilesystem.get(expectedFile); + + if (pluginWithDescriptor != null) { + currentFile = expectedFile; // we have it where we are expected to have it + if (!pluginWithDescriptor.plugin.getName().equals(name) + || !pluginType.equals(pluginWithDescriptor.pluginType)) { + // Happens if someone wrote a plugin of one type but later changed it to a different type (or changed names) + log.warn("For some reason, the server plugin file [" + expectedFile + "] is plugin [" + + pluginWithDescriptor.plugin.getName() + "] of type [" + pluginWithDescriptor.pluginType + + "] but the database says it should be [" + name + "] of type [" + pluginType + "]"); } else { - // the plugin might still be on the file system but under a different filename, see if we can find it - for (Map.Entry<File, PluginWithDescriptor> cacheEntry : this.serverPluginsOnFilesystem.entrySet()) { - if (cacheEntry.getValue().plugin.getName().equals(name) - && cacheEntry.getValue().pluginType.equals(pluginType)) { - currentFile = cacheEntry.getKey(); - pluginWithDescriptor = cacheEntry.getValue(); - log.info("Filesystem has a server plugin [" + name + "] at the file [" + currentFile - + "] which is different than where the DB thinks it should be [" + expectedFile + "]"); - break; // we found it, no need to continue the loop - } + log.debug("File system and db agree on server plugin location for [" + expectedFile + "]"); + } + } else { + // the plugin might still be on the file system but under a different filename, see if we can find it + for (Map.Entry<File, PluginWithDescriptor> cacheEntry : this.serverPluginsOnFilesystem.entrySet()) { + if (cacheEntry.getValue().plugin.getName().equals(name) + && cacheEntry.getValue().pluginType.equals(pluginType)) { + currentFile = cacheEntry.getKey(); + pluginWithDescriptor = cacheEntry.getValue(); + log.info("Filesystem has a server plugin [" + name + "] at the file [" + currentFile + + "] which is different than where the DB thinks it should be [" + expectedFile + "]"); + break; // we found it, no need to continue the loop } } + }
- if (pluginWithDescriptor != null && currentFile != null && currentFile.exists()) { - ServerPlugin dbPlugin = new ServerPlugin(name, path); - dbPlugin.setType(pluginType.stringify()); - dbPlugin.setMd5(md5); - dbPlugin.setVersion(version); - dbPlugin.setMtime(mtime); - - ServerPlugin obsoletePlugin = ServerPluginDescriptorUtil.determineObsoletePlugin(dbPlugin, - pluginWithDescriptor.plugin); - - if (obsoletePlugin == pluginWithDescriptor.plugin) { // yes use == for reference equality! - StringBuilder logMsg = new StringBuilder(); - logMsg.append("Found server plugin [").append(name); - logMsg.append("] in the DB that is newer than the one on the filesystem: "); - logMsg.append("DB path=[").append(path); - logMsg.append("]; file path=[").append(currentFile.getName()); - logMsg.append("]; DB MD5=[").append(md5); - logMsg.append("]; file MD5=[").append(pluginWithDescriptor.plugin.getMd5()); - logMsg.append("]; DB version=[").append(version); - logMsg.append("]; file version=[").append(pluginWithDescriptor.plugin.getVersion()); - logMsg.append("]; DB timestamp=[").append(new Date(mtime)); - logMsg.append("]; file timestamp=[").append(new Date(pluginWithDescriptor.plugin.getMtime())); - logMsg.append("]"); - log.info(logMsg.toString()); - - updatedPlugins.add(dbPlugin); - - if (currentFile.delete()) { - log.info("Deleted the obsolete server plugin file to be updated: " + currentFile); - this.serverPluginsOnFilesystem.remove(currentFile); - } else { - log.warn("Failed to delete the obsolete (to-be-updated) server plugin: " + currentFile); - } - currentFile = null; - } else if (obsoletePlugin == null) { - // the db is up-to-date, but update the cache so we don't check MD5 or parse the descriptor again - currentFile.setLastModified(mtime); - pluginWithDescriptor.plugin.setMtime(mtime); - pluginWithDescriptor.plugin.setVersion(version); - pluginWithDescriptor.plugin.setMd5(md5); + if (pluginWithDescriptor != null && currentFile != null && currentFile.exists()) { + ServerPlugin dbPlugin = new ServerPlugin(name, path); + dbPlugin.setType(pluginType.stringify()); + dbPlugin.setMd5(md5); + dbPlugin.setVersion(version); + dbPlugin.setMtime(mtime); + + ServerPlugin obsoletePlugin = ServerPluginDescriptorUtil.determineObsoletePlugin(dbPlugin, + pluginWithDescriptor.plugin); + + if (obsoletePlugin == pluginWithDescriptor.plugin) { // yes use == for reference equality! + StringBuilder logMsg = new StringBuilder(); + logMsg.append("Found server plugin [").append(name); + logMsg.append("] in the DB that is newer than the one on the filesystem: "); + logMsg.append("DB path=[").append(path); + logMsg.append("]; file path=[").append(currentFile.getName()); + logMsg.append("]; DB MD5=[").append(md5); + logMsg.append("]; file MD5=[").append(pluginWithDescriptor.plugin.getMd5()); + logMsg.append("]; DB version=[").append(version); + logMsg.append("]; file version=[").append(pluginWithDescriptor.plugin.getVersion()); + logMsg.append("]; DB timestamp=[").append(new Date(mtime)); + logMsg.append("]; file timestamp=[").append(new Date(pluginWithDescriptor.plugin.getMtime())); + logMsg.append("]"); + log.info(logMsg.toString()); + + updatedPlugins.add(dbPlugin); + + if (currentFile.delete()) { + log.info("Deleted the obsolete server plugin file to be updated: " + currentFile); + this.serverPluginsOnFilesystem.remove(currentFile); } else { - log.info("It appears that the server plugin [" + dbPlugin - + "] in the database may be obsolete. If so, it will be updated later."); + log.warn("Failed to delete the obsolete (to-be-updated) server plugin: " + currentFile); } + currentFile = null; + } else if (obsoletePlugin == null) { + // the db is up-to-date, but update the cache so we don't check MD5 or parse the descriptor again + currentFile.setLastModified(mtime); + pluginWithDescriptor.plugin.setMtime(mtime); + pluginWithDescriptor.plugin.setVersion(version); + pluginWithDescriptor.plugin.setMd5(md5); } else { - log.info("Found server plugin in the DB that we do not yet have: " + name); - ServerPlugin plugin = new ServerPlugin(name, path, md5); - plugin.setType(pluginType.stringify()); - plugin.setMtime(mtime); - plugin.setVersion(version); - updatedPlugins.add(plugin); - this.serverPluginsOnFilesystem.remove(expectedFile); // paranoia, make sure the cache doesn't have this + log.info("It appears that the server plugin [" + dbPlugin + + "] in the database may be obsolete. If so, it will be updated later."); } + } else { + log.info("Found server plugin in the DB that we do not yet have: " + name); + ServerPlugin plugin = new ServerPlugin(name, path, md5); + plugin.setType(pluginType.stringify()); + plugin.setMtime(mtime); + plugin.setVersion(version); + updatedPlugins.add(plugin); + this.serverPluginsOnFilesystem.remove(expectedFile); // paranoia, make sure the cache doesn't have this } - JDBCUtil.safeClose(ps, rs); - - // write all our updated plugins to the file system - ps = conn.prepareStatement("SELECT CONTENT FROM " + ServerPlugin.TABLE_NAME - + " WHERE DEPLOYMENT = 'SERVER' AND STATUS = 'INSTALLED' AND NAME = ? AND PTYPE = ?"); - for (ServerPlugin plugin : updatedPlugins) { - File file = new File(this.getServerPluginDir(), plugin.getPath()); - - ps.setString(1, plugin.getName()); - ps.setString(2, plugin.getType()); - rs = ps.executeQuery(); - rs.next(); - InputStream content = rs.getBinaryStream(1); - StreamUtil.copy(content, new FileOutputStream(file)); - rs.close(); - file.setLastModified(plugin.getMtime()); // so our file matches the database mtime - updatedFiles.add(file); - - // we are writing a new file to the filesystem, cache it since we know about it now - cacheFilesystemServerPluginJar(file, null); + } + + // write all our updated plugins to the file system + if (!updatedPlugins.isEmpty()) { + Connection conn = null; + PreparedStatement ps = null; + ResultSet rs = null; + + try { + DataSource ds = LookupUtil.getDataSource(); + conn = ds.getConnection(); + + ps = conn.prepareStatement("SELECT CONTENT FROM " + ServerPlugin.TABLE_NAME + + " WHERE DEPLOYMENT = 'SERVER' AND STATUS = 'INSTALLED' AND NAME = ? AND PTYPE = ?"); + for (ServerPlugin plugin : updatedPlugins) { + File file = new File(this.getServerPluginDir(), plugin.getPath()); + + ps.setString(1, plugin.getName()); + ps.setString(2, plugin.getType()); + rs = ps.executeQuery(); + rs.next(); + InputStream content = rs.getBinaryStream(1); + StreamUtil.copy(content, new FileOutputStream(file)); + rs.close(); + file.setLastModified(plugin.getMtime()); // so our file matches the database mtime + updatedFiles.add(file); + + // we are writing a new file to the filesystem, cache it since we know about it now + cacheFilesystemServerPluginJar(file, null); + } + } finally { + JDBCUtil.safeClose(conn, ps, rs); } - } finally { - JDBCUtil.safeClose(conn, ps, rs); }
return updatedFiles;
commit b2b5fcf609bce798d289458d54df039f289b68a0 Author: John Mazzitelli mazz@redhat.com Date: Mon Dec 14 14:31:12 2009 -0500
remove some unused methods ; use type when comparing plugin data
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/plugin/ServerPluginScanner.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/plugin/ServerPluginScanner.java index 96cd3a2..d39c8ef 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/plugin/ServerPluginScanner.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/plugin/ServerPluginScanner.java @@ -18,10 +18,7 @@ */ package org.rhq.enterprise.server.core.plugin;
-import java.io.BufferedInputStream; -import java.io.ByteArrayInputStream; import java.io.File; -import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.FilenameFilter; import java.io.InputStream; @@ -37,18 +34,11 @@ import java.util.Map; import java.util.Map.Entry;
import javax.sql.DataSource; -import javax.transaction.TransactionManager;
import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.maven.artifact.versioning.ComparableVersion;
-import org.rhq.core.db.DatabaseType; -import org.rhq.core.db.DatabaseTypeFactory; -import org.rhq.core.db.H2DatabaseType; -import org.rhq.core.db.OracleDatabaseType; -import org.rhq.core.db.PostgresqlDatabaseType; -import org.rhq.core.db.SQLServerDatabaseType; import org.rhq.core.domain.configuration.Configuration; import org.rhq.core.domain.configuration.definition.ConfigurationDefinition; import org.rhq.core.domain.plugin.PluginKey; @@ -73,14 +63,13 @@ import org.rhq.enterprise.server.xmlschema.generated.serverplugin.ServerPluginDe public class ServerPluginScanner { private Log log = LogFactory.getLog(ServerPluginScanner.class);
- private DatabaseType dbType = null; - /** a list of server plugins found on previous scans that have not yet been processed */ private List<File> scanned = new ArrayList<File>();
/** Maintains a cache of what we had on the filesystem during the last scan */ private Map<File, PluginWithDescriptor> serverPluginsOnFilesystem = new HashMap<File, PluginWithDescriptor>();
+ /** directory where the server plugin jar files are found */ private File serverPluginDir;
public ServerPluginScanner() { @@ -290,13 +279,13 @@ public class ServerPluginScanner { // Let's check to see if there are any obsolete plugins that need to be deleted. // This is needed if plugin-A-1.0.jar exists and someone deployed plugin-A-1.1.jar but fails to delete plugin-A-1.0.jar. doomedPluginFiles.clear(); - HashMap<String, ServerPlugin> pluginsByName = new HashMap<String, ServerPlugin>(); + HashMap<String, ServerPlugin> pluginsByName = new HashMap<String, ServerPlugin>(); // key on (name+type), not just name for (Entry<File, PluginWithDescriptor> currentPluginFileEntry : this.serverPluginsOnFilesystem.entrySet()) { ServerPlugin currentPlugin = currentPluginFileEntry.getValue().plugin; - ServerPlugin existingPlugin = pluginsByName.get(currentPlugin.getName()); + ServerPlugin existingPlugin = pluginsByName.get(currentPlugin.getName() + currentPlugin.getType()); if (existingPlugin == null) { // this is the usual case - this is the only plugin with the given name we've seen - pluginsByName.put(currentPlugin.getName(), currentPlugin); + pluginsByName.put(currentPlugin.getName() + currentPlugin.getType(), currentPlugin); } else { ServerPlugin obsolete = ServerPluginDescriptorUtil.determineObsoletePlugin(currentPlugin, existingPlugin); @@ -305,7 +294,7 @@ public class ServerPluginScanner { } doomedPluginFiles.add(new File(this.getServerPluginDir(), obsolete.getPath())); if (obsolete == existingPlugin) { // yes use == for reference equality! - pluginsByName.put(currentPlugin.getName(), currentPlugin); // override the original one we saw with this latest one + pluginsByName.put(currentPlugin.getName() + currentPlugin.getType(), currentPlugin); // override the original one we saw with this latest one } } } @@ -340,6 +329,7 @@ public class ServerPluginScanner { String version = ServerPluginDescriptorUtil.getPluginVersion(pluginJar, descriptor).toString(); String name = descriptor.getName(); ServerPlugin plugin = new ServerPlugin(name, pluginJar.getName()); + plugin.setType(new ServerPluginType(descriptor).stringify()); plugin.setMd5(md5); plugin.setVersion(version); plugin.setMtime(pluginJar.lastModified()); @@ -372,7 +362,7 @@ public class ServerPluginScanner { conn = ds.getConnection();
// get all the plugins - ps = conn.prepareStatement("SELECT NAME, PATH, MD5, MTIME, VERSION FROM " + ServerPlugin.TABLE_NAME + ps = conn.prepareStatement("SELECT NAME, PATH, MD5, MTIME, VERSION, PTYPE FROM " + ServerPlugin.TABLE_NAME + " WHERE DEPLOYMENT = 'SERVER' AND STATUS = 'INSTALLED' "); rs = ps.executeQuery(); while (rs.next()) { @@ -381,6 +371,7 @@ public class ServerPluginScanner { String md5 = rs.getString(3); long mtime = rs.getLong(4); String version = rs.getString(5); + ServerPluginType pluginType = new ServerPluginType(rs.getString(6));
// let's see if we have this logical plugin on the filesystem (it may or may not be under the same filename) File expectedFile = new File(this.getServerPluginDir(), path); @@ -389,19 +380,20 @@ public class ServerPluginScanner {
if (pluginWithDescriptor != null) { currentFile = expectedFile; // we have it where we are expected to have it - if (!pluginWithDescriptor.plugin.getName().equals(name)) { - // I have no idea when or if this would ever happen, but at least log it so we'll see it if it does happen + if (!pluginWithDescriptor.plugin.getName().equals(name) + || !pluginType.equals(pluginWithDescriptor.pluginType)) { + // Happens if someone wrote a plugin of one type but later changed it to a different type (or changed names) log.warn("For some reason, the server plugin file [" + expectedFile + "] is plugin [" - + pluginWithDescriptor.plugin.getName() + "] but the database says it should be [" + name - + "]"); + + pluginWithDescriptor.plugin.getName() + "] of type [" + pluginWithDescriptor.pluginType + + "] but the database says it should be [" + name + "] of type [" + pluginType + "]"); } else { - log.debug("File system and database agree on a server plugin location for [" + expectedFile - + "]"); + log.debug("File system and db agree on server plugin location for [" + expectedFile + "]"); } } else { // the plugin might still be on the file system but under a different filename, see if we can find it for (Map.Entry<File, PluginWithDescriptor> cacheEntry : this.serverPluginsOnFilesystem.entrySet()) { - if (cacheEntry.getValue().plugin.getName().equals(name)) { + if (cacheEntry.getValue().plugin.getName().equals(name) + && cacheEntry.getValue().pluginType.equals(pluginType)) { currentFile = cacheEntry.getKey(); pluginWithDescriptor = cacheEntry.getValue(); log.info("Filesystem has a server plugin [" + name + "] at the file [" + currentFile @@ -413,6 +405,7 @@ public class ServerPluginScanner {
if (pluginWithDescriptor != null && currentFile != null && currentFile.exists()) { ServerPlugin dbPlugin = new ServerPlugin(name, path); + dbPlugin.setType(pluginType.stringify()); dbPlugin.setMd5(md5); dbPlugin.setVersion(version); dbPlugin.setMtime(mtime); @@ -441,9 +434,7 @@ public class ServerPluginScanner { log.info("Deleted the obsolete server plugin file to be updated: " + currentFile); this.serverPluginsOnFilesystem.remove(currentFile); } else { - log - .warn("Failed to delete the obsolete (to-be-updated) server plugin file: " - + currentFile); + log.warn("Failed to delete the obsolete (to-be-updated) server plugin: " + currentFile); } currentFile = null; } else if (obsoletePlugin == null) { @@ -459,6 +450,7 @@ public class ServerPluginScanner { } else { log.info("Found server plugin in the DB that we do not yet have: " + name); ServerPlugin plugin = new ServerPlugin(name, path, md5); + plugin.setType(pluginType.stringify()); plugin.setMtime(mtime); plugin.setVersion(version); updatedPlugins.add(plugin); @@ -469,11 +461,12 @@ public class ServerPluginScanner {
// write all our updated plugins to the file system ps = conn.prepareStatement("SELECT CONTENT FROM " + ServerPlugin.TABLE_NAME - + " WHERE DEPLOYMENT = 'SERVER' AND STATUS = 'INSTALLED' AND NAME = ?"); + + " WHERE DEPLOYMENT = 'SERVER' AND STATUS = 'INSTALLED' AND NAME = ? AND PTYPE = ?"); for (ServerPlugin plugin : updatedPlugins) { File file = new File(this.getServerPluginDir(), plugin.getPath());
ps.setString(1, plugin.getName()); + ps.setString(2, plugin.getType()); rs = ps.executeQuery(); rs.next(); InputStream content = rs.getBinaryStream(1); @@ -492,101 +485,15 @@ public class ServerPluginScanner { return updatedFiles; }
- private void setEnabledFlag(Connection conn, PreparedStatement ps, int index, boolean enabled) throws Exception { - if (null == this.dbType) { - this.dbType = DatabaseTypeFactory.getDatabaseType(conn); - } - if (dbType instanceof PostgresqlDatabaseType || dbType instanceof H2DatabaseType) { - ps.setBoolean(index, enabled); - } else if (dbType instanceof OracleDatabaseType || dbType instanceof SQLServerDatabaseType) { - ps.setInt(index, (enabled ? 1 : 0)); - } else { - throw new RuntimeException("Unknown database type : " + dbType); - } - } - - /** - * This will write the contents of the given plugin file to the database. - * This will store both the contents and the MD5 in an atomic transaction - * so they remain insync. - * - * When <code>different</code> is <code>false</code>, it means the original - * plugin and the one currently found on the file system are the same. - * - * When <code>different</code> is <code>true</code>, it means the plugin - * is most likely a different one than the one that originally existed. - * When this happens, it is assumed that the we need - * to see the plugin on the file system as new and needing to be processed, therefore - * the MD5, CONTENT and MTIME columns will be updated to ensure the deployer - * will process this plugin and thus update all the metadata for this plugin. - * - * @param name the name of the plugin whose content is being updated - * @param file the plugin file whose content will be streamed to the database - * @param different this will be <code>true</code> if the given file has a different filename - * that the plugin's "path" as found in the database. - * - * - * @throws Exception - */ - private void streamPluginFileContentToDatabase(String name, File file, boolean different) throws Exception { - Connection conn = null; - PreparedStatement ps = null; - ResultSet rs = null; - TransactionManager tm = null; - - String sql = "UPDATE " - + ServerPlugin.TABLE_NAME - + " SET CONTENT = ?, MD5 = ?, MTIME = ?, PATH = ? WHERE DEPLOYMENT = 'SERVER' AND STATUS = 'INSTALLED' AND NAME = ?"; - - // if 'different' is true, give bogus data so the plugin deployer will think the plugin on the file system is new - String md5 = (!different) ? MessageDigestGenerator.getDigestString(file) : "TO BE UPDATED"; - long mtime = (!different) ? file.lastModified() : 0L; - InputStream fis = (!different) ? new FileInputStream(file) : new ByteArrayInputStream(new byte[0]); - int contentSize = (int) ((!different) ? file.length() : 0); - - try { - tm = LookupUtil.getTransactionManager(); - tm.begin(); - DataSource ds = LookupUtil.getDataSource(); - conn = ds.getConnection(); - ps = conn.prepareStatement(sql); - ps.setBinaryStream(1, new BufferedInputStream(fis), contentSize); - ps.setString(2, md5); - ps.setLong(3, mtime); - ps.setString(4, file.getName()); - ps.setString(5, name); - int updateResults = ps.executeUpdate(); - if (updateResults == 1) { - log.info("Stored content for plugin [" + name + "] in the db. file=" + file); - } else { - throw new Exception("Failed to update content for plugin [" + name + "] from [" + file + "]"); - } - } catch (Exception e) { - tm.rollback(); - tm = null; - throw e; - } finally { - JDBCUtil.safeClose(conn, ps, rs); - - try { - fis.close(); - } catch (Throwable t) { - } - - if (tm != null) { - tm.commit(); - } - } - return; - } - private class PluginWithDescriptor { public PluginWithDescriptor(ServerPlugin plugin, ServerPluginDescriptorType descriptor) { this.plugin = plugin; this.descriptor = descriptor; + this.pluginType = new ServerPluginType(descriptor); }
- public ServerPlugin plugin; - public ServerPluginDescriptorType descriptor; + public final ServerPlugin plugin; + public final ServerPluginDescriptorType descriptor; + public final ServerPluginType pluginType; } } diff --git a/modules/enterprise/server/xml-schemas/src/main/java/org/rhq/enterprise/server/xmlschema/ServerPluginDescriptorUtil.java b/modules/enterprise/server/xml-schemas/src/main/java/org/rhq/enterprise/server/xmlschema/ServerPluginDescriptorUtil.java index 0487d19..675a076 100644 --- a/modules/enterprise/server/xml-schemas/src/main/java/org/rhq/enterprise/server/xmlschema/ServerPluginDescriptorUtil.java +++ b/modules/enterprise/server/xml-schemas/src/main/java/org/rhq/enterprise/server/xmlschema/ServerPluginDescriptorUtil.java @@ -101,13 +101,17 @@ public abstract class ServerPluginDescriptorUtil { * @param plugin2 * @return a reference to the obsolete plugin (plugin1 or plugin2 reference will be returned) * <code>null</code> is returned if they are the same (i.e. they have the same MD5) - * @throws IllegalArgumentException if the two plugins have different logical names + * @throws IllegalArgumentException if the two plugins have different logical names or different types */ public static ServerPlugin determineObsoletePlugin(ServerPlugin plugin1, ServerPlugin plugin2) { if (!plugin1.getName().equals(plugin2.getName())) { throw new IllegalArgumentException("The two plugins don't have the same name:" + plugin1 + ":" + plugin2); }
+ if (!plugin1.getType().equals(plugin2.getType())) { + throw new IllegalArgumentException("The two plugins don't have the same type:" + plugin1 + ":" + plugin2); + } + if (plugin1.getMd5().equals(plugin2.getMd5())) { return null; } else {
commit c02a8fe5b89142966494cf564e15a9ed10d77591 Author: Adam Young ayoung@redhat.com Date: Mon Dec 14 14:12:24 2009 -0500
Cleaned up icons and sidebar navigation, toggles between edit in view
diff --git a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/AbstractConfigurationComponent.java b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/AbstractConfigurationComponent.java index 11a4672..2fe72ee 100644 --- a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/AbstractConfigurationComponent.java +++ b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/AbstractConfigurationComponent.java @@ -52,7 +52,7 @@ public abstract class AbstractConfigurationComponent extends UIComponentBase imp private static final String READ_ONLY_ATTRIBUTE = "readOnly"; private static final String FULLY_EDITABLE_ATTRIBUTE = "fullyEditable";
- private Boolean readOnly; + private Boolean readOnly = true; private Boolean fullyEditable; private String listName; private Integer listIndex; @@ -224,7 +224,8 @@ public abstract class AbstractConfigurationComponent extends UIComponentBase imp
RawConfigUIComponent getRawConfigUIComponent() { if (null == rawConfigUIComponent) { - rawConfigUIComponent = new RawConfigUIComponent(getConfiguration(), getConfigurationDefinition(), this); + rawConfigUIComponent = new RawConfigUIComponent(getConfiguration(), getConfigurationDefinition(), this, + isReadOnly()); } return rawConfigUIComponent; } diff --git a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/ConfigRenderer.java b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/ConfigRenderer.java index c779dda..b4f76f1 100644 --- a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/ConfigRenderer.java +++ b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/ConfigRenderer.java @@ -32,6 +32,7 @@ import javax.faces.component.UIComponent; import javax.faces.component.UIForm; import javax.faces.component.UIInput; import javax.faces.component.UIOutput; +import javax.faces.component.UIPanel; import javax.faces.component.UIParameter; import javax.faces.component.html.HtmlCommandLink; import javax.faces.component.html.HtmlForm; @@ -121,6 +122,19 @@ public class ConfigRenderer extends Renderer { } }
+ Boolean readOnly = Boolean.valueOf(FacesContextUtility.getOptionalRequestParameter("readOnly")); + Boolean save = Boolean.valueOf(FacesContextUtility.getOptionalRequestParameter("save")); + configurationComponent.setReadOnly(readOnly); + + if (component.getChildCount() == 0) + addChildComponents(configurationComponent); + for (UIComponent kid : configurationComponent.getChildren()) { + if (kid instanceof RawConfigUIComponent) { + kid.decode(facesContext); + } + + } + }
/** @@ -249,31 +263,60 @@ public class ConfigRenderer extends Renderer { } }
- if (!configurationComponent.isReadOnly()) - addRequiredNotationsKey(configurationComponent); - Boolean shouldShowRawNow = configurationComponent.getShouldShowRaw(); - addStructuredRawToggle(configurationComponent, shouldShowRawNow); + //addStructuredRawToggle(configurationComponent, shouldShowRawNow); if (shouldShowRawNow) { configurationComponent.getChildren().add( new RawConfigUIComponent(configurationComponent.getConfiguration(), configurationComponent - .getConfigurationDefinition(), configurationComponent)); + .getConfigurationDefinition(), configurationComponent, configurationComponent.isReadOnly())); } else { - if (configurationComponent.getListName() != null) { - if (configurationComponent.getListIndex() == null) { - // No index specified means we should add a new map to the list. - configurationComponent.setListIndex(addNewMap(configurationComponent)); - } + addStructuredConfig(configurationComponent); + } + }
- addListMemberProperty(configurationComponent); - } else { - addConfiguration(configurationComponent); + private void addStructuredConfig(AbstractConfigurationComponent configurationComponent) { + UIPanel toolbarPanel = FacesComponentUtility.addBlockPanel(configurationComponent, configurationComponent, + "summary-props-table"); + if (configurationComponent.isReadOnly()) { + HtmlCommandLink editLink = FacesComponentUtility.addCommandLink(toolbarPanel, configurationComponent); + FacesComponentUtility.addGraphicImage(editLink, configurationComponent, "/images/edit.png", "Edit"); + FacesComponentUtility.addOutputText(editLink, configurationComponent, "Edit", ""); + FacesComponentUtility.addParameter(editLink, configurationComponent, "readOnly", Boolean.toString(false)); + + } else { + HtmlCommandLink saveLink = FacesComponentUtility.addCommandLink(toolbarPanel, configurationComponent); + FacesComponentUtility.addGraphicImage(saveLink, configurationComponent, "/images/save.png", "Save"); + FacesComponentUtility.addOutputText(saveLink, configurationComponent, "Save", ""); + FacesComponentUtility.addParameter(saveLink, configurationComponent, "save", Boolean.toString(true)); + FacesComponentUtility.addParameter(saveLink, configurationComponent, "readOnly", Boolean.toString(true)); + } + + if (configurationComponent.getConfigurationDefinition().getConfigurationFormat().isRawSupported()) { + HtmlCommandLink toRawLink = FacesComponentUtility.addCommandLink(toolbarPanel, configurationComponent); + FacesComponentUtility.addGraphicImage(toRawLink, configurationComponent, "/images/raw.png", "showRaw"); + FacesComponentUtility.addOutputText(toRawLink, configurationComponent, "showRaw", ""); + FacesComponentUtility.addParameter(toRawLink, configurationComponent, "showRaw", Boolean.TRUE.toString()); + FacesComponentUtility.addParameter(toRawLink, configurationComponent, "readOnly", Boolean + .toString(configurationComponent.isReadOnly())); + } + + if (!configurationComponent.isReadOnly()) + addRequiredNotationsKey(configurationComponent); + + if (configurationComponent.getListName() != null) { + if (configurationComponent.getListIndex() == null) { + // No index specified means we should add a new map to the list. + configurationComponent.setListIndex(addNewMap(configurationComponent)); }
- String id = getInitInputsJavaScriptComponentId(configurationComponent); - PropertyRenderingUtility.addInitInputsJavaScript(configurationComponent, id, configurationComponent - .isFullyEditable(), false); + addListMemberProperty(configurationComponent); + } else { + addConfiguration(configurationComponent); } + + String id = getInitInputsJavaScriptComponentId(configurationComponent); + PropertyRenderingUtility.addInitInputsJavaScript(configurationComponent, id, configurationComponent + .isFullyEditable(), false); }
private void addStructuredRawToggle(AbstractConfigurationComponent configurationComponent, boolean showRaw) { diff --git a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/RawConfigUIComponent.java b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/RawConfigUIComponent.java index 1b7bf89..5280cb0 100644 --- a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/RawConfigUIComponent.java +++ b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/RawConfigUIComponent.java @@ -1,6 +1,10 @@ package org.rhq.core.gui.configuration;
import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map;
import javax.faces.component.UIComponent; import javax.faces.component.UIComponentBase; @@ -15,12 +19,16 @@ import org.rhq.core.domain.configuration.RawConfiguration; import org.rhq.core.domain.configuration.definition.ConfigurationDefinition; import org.rhq.core.gui.util.FacesComponentIdFactory; import org.rhq.core.gui.util.FacesComponentUtility; +import org.rhq.core.gui.util.FacesContextUtility;
public class RawConfigUIComponent extends UIComponentBase {
+ private boolean readOnly; + @Override public void decode(FacesContext context) { super.decode(context); + setSelectedPath(FacesContextUtility.getOptionalRequestParameter("path"));
}
@@ -29,9 +37,33 @@ public class RawConfigUIComponent extends UIComponentBase { return "rhq"; }
- Configuration configuration; - ConfigurationDefinition configurationDefinition; - FacesComponentIdFactory idFactory; + private Configuration configuration; + private ConfigurationDefinition configurationDefinition; + private FacesComponentIdFactory idFactory; + private String selectedPath; + private HtmlInputTextarea inputTextarea; + private Map<String, RawConfiguration> rawMap; + + public String getSelectedPath() { + if (null == selectedPath) { + if (configuration.getRawConfigurations().iterator().hasNext()) { + selectedPath = configuration.getRawConfigurations().iterator().next().getPath(); + } else { + selectedPath = ""; + } + } + return selectedPath; + } + + public void setSelectedPath(String selectedPath) { + if (selectedPath == null) + return; + for (RawConfiguration raw : configuration.getRawConfigurations()) { + if (raw.getPath().equals(selectedPath)) { + this.selectedPath = selectedPath; + } + } + }
@Override public boolean getRendersChildren() { @@ -51,14 +83,15 @@ public class RawConfigUIComponent extends UIComponentBase { }
public RawConfigUIComponent(Configuration configuration, ConfigurationDefinition configurationDefinition, - FacesComponentIdFactory componentIdFactory) { + FacesComponentIdFactory componentIdFactory, boolean readOnly) {
this.configuration = configuration; this.configurationDefinition = configurationDefinition; this.idFactory = componentIdFactory; + this.readOnly = readOnly;
UIPanel rawPanel = FacesComponentUtility.addBlockPanel(this, idFactory, ""); - addToolbarIcons(rawPanel); + addToolbarIcons(rawPanel, configurationDefinition.getConfigurationFormat().isStructuredSupported());
HtmlPanelGrid grid = FacesComponentUtility.addPanelGrid(rawPanel, idFactory, "summary-props-table"); grid.setParent(this); @@ -72,11 +105,28 @@ public class RawConfigUIComponent extends UIComponentBase { FacesComponentUtility.addOutputText(panelLeft, idFactory, "Raw Configurations Paths", "");
int rawCount = 0; + + ArrayList<String> configPathList = new ArrayList<String>(); + + rawMap = new HashMap<String, RawConfiguration>(); + for (RawConfiguration raw : configuration.getRawConfigurations()) { + configPathList.add(raw.getPath()); + rawMap.put(raw.getPath(), raw); + } + Collections.sort(configPathList); + String oldDirname = ""; + for (String s : configPathList) { + RawConfiguration raw = rawMap.get(s); + String dirname = raw.getPath().substring(0, raw.getPath().lastIndexOf("/") + 1); + String basename = raw.getPath().substring(raw.getPath().lastIndexOf("/") + 1, raw.getPath().length()); + if (!dirname.equals(oldDirname)) { + FacesComponentUtility.addOutputText(panelLeft, idFactory, dirname, ""); + oldDirname = dirname; + } UIPanel nextPath = FacesComponentUtility.addBlockPanel(panelLeft, idFactory, ""); HtmlCommandLink link = FacesComponentUtility.addCommandLink(nextPath, idFactory); - - FacesComponentUtility.addOutputText(link, idFactory, raw.getPath(), ""); + FacesComponentUtility.addOutputText(link, idFactory, "[]" + basename, ""); FacesComponentUtility.addParameter(link, idFactory, "path", raw.getPath()); FacesComponentUtility.addParameter(link, idFactory, "whichRaw", Integer.toString(rawCount++)); FacesComponentUtility.addParameter(link, idFactory, "showRaw", Boolean.TRUE.toString()); @@ -85,29 +135,54 @@ public class RawConfigUIComponent extends UIComponentBase { UIPanel panelRight = FacesComponentUtility.addBlockPanel(grid, idFactory, "summary-props-table");
UIPanel editPanel = FacesComponentUtility.addBlockPanel(panelRight, idFactory, "summary-props-table"); - HtmlInputTextarea inputTextarea = new HtmlInputTextarea(); + inputTextarea = new HtmlInputTextarea(); editPanel.getChildren().add(inputTextarea); inputTextarea.setParent(editPanel); inputTextarea.setCols(80); inputTextarea.setRows(40); - inputTextarea.setValue(configuration.getRawConfigurations().iterator().next().getContentString()); + inputTextarea.setValue(rawMap.get(getSelectedPath()).getContentString()); + inputTextarea.setReadonly(readOnly); }
- private void addToolbarIcons(UIPanel panelRight) { - HtmlCommandLink fullScreenCommandLink = FacesComponentUtility.addCommandLink(panelRight, idFactory); - FacesComponentUtility.addGraphicImage(fullScreenCommandLink, idFactory, "/images/save.png", "Save"); - FacesComponentUtility.addOutputText(fullScreenCommandLink, idFactory, "Save", ""); - - HtmlCommandLink saveCommandLink = FacesComponentUtility.addCommandLink(panelRight, idFactory); + private void addToolbarIcons(UIPanel toolbarPanel, boolean supportsStructured) { + + if (readOnly) { + HtmlCommandLink editLink = FacesComponentUtility.addCommandLink(toolbarPanel, idFactory); + FacesComponentUtility.addGraphicImage(editLink, idFactory, "/images/edit.png", "Edit"); + FacesComponentUtility.addOutputText(editLink, idFactory, "Edit", ""); + FacesComponentUtility.addParameter(editLink, idFactory, "showStructured", Boolean.FALSE.toString()); + } else { + HtmlCommandLink saveLink = FacesComponentUtility.addCommandLink(toolbarPanel, idFactory); + FacesComponentUtility.addGraphicImage(saveLink, idFactory, "/images/save.png", "Save"); + FacesComponentUtility.addOutputText(saveLink, idFactory, "Save", ""); + FacesComponentUtility.addParameter(saveLink, idFactory, "showStructured", Boolean.FALSE.toString()); + } + HtmlCommandLink saveCommandLink = FacesComponentUtility.addCommandLink(toolbarPanel, idFactory); FacesComponentUtility.addGraphicImage(saveCommandLink, idFactory, "/images/viewfullscreen.png", "FullScreen"); FacesComponentUtility.addOutputText(saveCommandLink, idFactory, "Full Screen", "");
- HtmlCommandLink uploadCommandLink = FacesComponentUtility.addCommandLink(panelRight, idFactory); + HtmlCommandLink uploadCommandLink = FacesComponentUtility.addCommandLink(toolbarPanel, idFactory); FacesComponentUtility.addGraphicImage(uploadCommandLink, idFactory, "/images/upload.png", "Upload"); FacesComponentUtility.addOutputText(uploadCommandLink, idFactory, "Upload", "");
- HtmlCommandLink downloadCommandLink = FacesComponentUtility.addCommandLink(panelRight, idFactory); + HtmlCommandLink downloadCommandLink = FacesComponentUtility.addCommandLink(toolbarPanel, idFactory); FacesComponentUtility.addGraphicImage(downloadCommandLink, idFactory, "/images/download.png", "download"); FacesComponentUtility.addOutputText(downloadCommandLink, idFactory, "Download", ""); + + if (supportsStructured) { + HtmlCommandLink toStructureLink = FacesComponentUtility.addCommandLink(toolbarPanel, idFactory); + FacesComponentUtility.addGraphicImage(toStructureLink, idFactory, "/images/structured.png", + "showStructured"); + FacesComponentUtility.addOutputText(toStructureLink, idFactory, "showStructured", ""); + FacesComponentUtility.addParameter(toStructureLink, idFactory, "showStructured", Boolean.FALSE.toString()); + } + } + + @Override + public void encodeBegin(FacesContext context) throws IOException { + // TODO Auto-generated method stub + super.encodeBegin(context); + inputTextarea.setValue(rawMap.get(getSelectedPath()).getContentString()); + } } diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/images/edit.png b/modules/enterprise/gui/portal-war/src/main/webapp/images/edit.png new file mode 100644 index 0000000..b1c3c61 Binary files /dev/null and b/modules/enterprise/gui/portal-war/src/main/webapp/images/edit.png differ diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/images/raw.png b/modules/enterprise/gui/portal-war/src/main/webapp/images/raw.png new file mode 100644 index 0000000..9ccae0e Binary files /dev/null and b/modules/enterprise/gui/portal-war/src/main/webapp/images/raw.png differ diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/images/structured.png b/modules/enterprise/gui/portal-war/src/main/webapp/images/structured.png new file mode 100644 index 0000000..94fcf83 Binary files /dev/null and b/modules/enterprise/gui/portal-war/src/main/webapp/images/structured.png differ diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml index d067d8a..a85f409 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml @@ -22,6 +22,12 @@ THIS TEXT WILL BE REMOVED. <ui:param name="selectedTabName" value="Configuration.Current"/>
<ui:define name="content"> + <style type="text/css"> + td.raw-config-table { + vertical-align: top; + valign: top; + } + </style>
<h:form id="editResourceConfigurationForm" onsubmit="prepareInputsForSubmission(this)" rendered="#{!ViewResourceConfigurationUIBean.updateInProgress}">
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml index 12156e4..dabda7e 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml @@ -25,7 +25,7 @@ THIS TEXT WILL BE REMOVED. <ui:define name="content">
- <style type="text/css"> +<style type="text/css"> td.raw-config-table { vertical-align: top; valign: top; @@ -43,22 +43,10 @@ THIS TEXT WILL BE REMOVED. <h:form id="viewResourceConfigurationForm"> <!-- TODO remove the id version --> <input type="hidden" name="id" value="#{ResourceUIBean.id}"/> - - <h:panelGrid columns="2" styleClass="buttons-table" columnClasses="button-cell" - rendered="#{ExistingResourceConfigurationUIBean.configuration != null and !ExistingResourceConfigurationUIBean.updateInProgress}"> - - <h:commandButton value="#{messages.editstructured}" action="#{ExistingResourceConfigurationUIBean.editConfiguration}" - title="Edit this Configuration" styleClass="buttonmed" - rendered="${ResourceUIBean.permissions.configure and ExistingResourceConfigurationUIBean.structuredSupported and !ExistingResourceConfigurationUIBean.updateInProgress}" /> - <h:commandButton value="#{messages.editraw}" action="#{ExistingResourceConfigurationUIBean.editRawConfiguration}" - title="Advanced Mode Edit of Raw Configuration Files" styleClass="buttonmed" - rendered="${ResourceUIBean.permissions.configure and ExistingResourceConfigurationUIBean.rawSupported and !ExistingResourceConfigurationUIBean.updateInProgress}" /> - </h:panelGrid>
<onc:config configurationDefinition="#{ExistingResourceConfigurationUIBean.configurationDefinition}" configuration="#{ExistingResourceConfigurationUIBean.configuration}" accessMapActionExpression="#{ExistingResourceConfigurationUIBean.accessMap}" - readOnly="true" nullConfigurationDefinitionMessage="#{ExistingResourceConfigurationUIBean.nullConfigurationDefinitionMessage}" nullConfigurationMessage="#{ExistingResourceConfigurationUIBean.nullConfigurationMessage}" prevalidate="true"/>
commit 3b562fa0f9ba67fd10cbe8ebc51719f9dafa9520 Author: Justin Harris jharris@redhat.com Date: Mon Dec 14 12:56:09 2009 -0500
Fixing scoping bug that affected editing the incorrect plugin.
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/plugin/EditPluginConfigurationUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/plugin/EditPluginConfigurationUIBean.java index 7fad490..f85269f 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/plugin/EditPluginConfigurationUIBean.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/plugin/EditPluginConfigurationUIBean.java @@ -39,7 +39,7 @@ import org.rhq.enterprise.gui.util.EnterpriseFacesContextUtility; import org.rhq.enterprise.server.plugin.ServerPluginsLocal; import org.rhq.enterprise.server.util.LookupUtil;
-@Scope(ScopeType.SESSION) +@Scope(ScopeType.PAGE) @Name("editPluginConfigurationUIBean") public class EditPluginConfigurationUIBean extends AbstractPluginConfigurationUIBean implements Serializable {
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/plugin/PluginFactory.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/plugin/PluginFactory.java index 8ea565e..8ebd73d 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/plugin/PluginFactory.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/plugin/PluginFactory.java @@ -47,7 +47,7 @@ public class PluginFactory { @RequestParameter("pluginType") private String pluginType;
- @Factory(value = "plugin", autoCreate = true) + @Factory(value = "plugin", autoCreate = true, scope = ScopeType.EVENT) public AbstractPlugin lookupPlugin() { if (this.deployment == PluginDeploymentType.AGENT) { return LookupUtil.getResourceMetadataManager().getPlugin(this.name);
commit 9bbb1e9dfe93f7ccced605748fae28c0b0a13080 Author: Justin Harris jharris@redhat.com Date: Mon Dec 14 12:38:40 2009 -0500
Disabling and re-enabling a plugin when configuration settings are saved.
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/plugin/EditPluginConfigurationUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/plugin/EditPluginConfigurationUIBean.java index 6dab242..7fad490 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/plugin/EditPluginConfigurationUIBean.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/plugin/EditPluginConfigurationUIBean.java @@ -19,6 +19,8 @@ package org.rhq.enterprise.gui.admin.plugin;
import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; import javax.faces.application.FacesMessage; import org.jboss.seam.ScopeType; import org.jboss.seam.annotations.Create; @@ -104,6 +106,11 @@ public class EditPluginConfigurationUIBean extends AbstractPluginConfigurationUI ServerPluginsLocal serverPlugins = LookupUtil.getServerPlugins(); Subject subject = EnterpriseFacesContextUtility.getSubject(); serverPlugins.updateServerPluginExceptContent(subject, getPlugin()); + + // rekick the updated plugin so that any config changes take effect + serverPlugins.disableServerPlugins(subject, getPluginIdList()); + serverPlugins.enableServerPlugins(subject, getPluginIdList()); + FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO, "Configuration settings saved."); } catch (Exception e) { log.error("Error updating the plugin configurations.", e); @@ -115,4 +122,15 @@ public class EditPluginConfigurationUIBean extends AbstractPluginConfigurationUI
return "success"; } + + private List<Integer> getPluginIdList() { + List<Integer> idList = new ArrayList<Integer>(1); + ServerPlugin plugin = getPlugin(); + + if (plugin != null) { + idList.add(plugin.getId()); + } + + return idList; + } } diff --git a/modules/enterprise/server/plugins/alert-irc/src/main/java/org/rhq/enterprise/server/plugins/alertIrc/IrcAlertComponent.java b/modules/enterprise/server/plugins/alert-irc/src/main/java/org/rhq/enterprise/server/plugins/alertIrc/IrcAlertComponent.java index f8716d6..13c910b 100644 --- a/modules/enterprise/server/plugins/alert-irc/src/main/java/org/rhq/enterprise/server/plugins/alertIrc/IrcAlertComponent.java +++ b/modules/enterprise/server/plugins/alert-irc/src/main/java/org/rhq/enterprise/server/plugins/alertIrc/IrcAlertComponent.java @@ -151,10 +151,7 @@ public class IrcAlertComponent implements ServerPluginComponent { public void onMessage(String channel, String sender, String login, String hostname, String message) {
- if (!message.contains(nick)) - return; - - if (this.response != null) { + if (this.response != null && message.startsWith(nick)) { if (channel != null && channel.length() > 0) { sendMessage(channel, sender + ": " + this.response); } else {
commit c5fb24fc44954ff14c38ca444d90fee7707ab76b Author: Adam Young ayoung@redhat.com Date: Sun Dec 13 15:53:48 2009 -0500
Extended the unit test to run through additional components such as grid and image.
diff --git a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/ConfigRendererTest.java b/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/ConfigRendererTest.java index 660933b..d3db839 100644 --- a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/ConfigRendererTest.java +++ b/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/ConfigRendererTest.java @@ -5,6 +5,7 @@ import java.io.StringWriter; import java.util.HashMap;
import javax.faces.FactoryFinder; +import javax.faces.component.UIForm; import javax.faces.context.FacesContext; import javax.faces.lifecycle.Lifecycle;
@@ -83,10 +84,17 @@ public class ConfigRendererTest { value.setName("test1"); value.setConfiguration(configuration); value.setId(3); + configuration.getMap().put(value.getName(), value); configuration.getRawConfigurations().add(buildMockRawConfig());
Assert.assertNotNull(configUIComponent.getConfigurationDefinition()); + + UIForm form = new UIForm(); + form.setId("form"); + form.getChildren().add(configUIComponent); + configUIComponent.setParent(form); + configUIComponent.getConfigurationDefinition().setConfigurationFormat(ConfigurationFormat.STRUCTURED_AND_RAW);
Assert.assertNotNull(configUIComponent.getConfigurationDefinition().getConfigurationFormat()); diff --git a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockApplication.java b/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockApplication.java index abe95ee..94f5bc8 100644 --- a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockApplication.java +++ b/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockApplication.java @@ -198,9 +198,11 @@ public class MockApplication extends Application {
}
+ MockViewHandler mockViewHandler = new MockViewHandler(); + @Override public ViewHandler getViewHandler() { - throw new RuntimeException("Function not implemented"); + return mockViewHandler;
}
diff --git a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockExternalContext.java b/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockExternalContext.java index cd8500c..ed0af06 100644 --- a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockExternalContext.java +++ b/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockExternalContext.java @@ -37,7 +37,8 @@ public class MockExternalContext extends ExternalContext {
@Override public String encodeResourceURL(String url) { - throw new RuntimeException("Function not implemented"); + + return "encodedUrl:" + url;
}
@@ -48,6 +49,7 @@ public class MockExternalContext extends ExternalContext { if (null == applicationMap) { applicationMap = new HashMap<String, Object>(); applicationMap.put("com.sun.faces.ApplicationImpl", new ApplicationImpl()); + applicationMap.put("com.sun.faces.sunJsfJs", "Javascript goes here".toCharArray()); }
return applicationMap; diff --git a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockFacesContext.java b/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockFacesContext.java index 77e410d..c61465d 100644 --- a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockFacesContext.java +++ b/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockFacesContext.java @@ -106,7 +106,8 @@ public class MockFacesContext extends FacesContext {
@Override public UIViewRoot getViewRoot() { - throw new RuntimeException("Function not implemented"); + return null; + //throw new RuntimeException("Function not implemented");
}
diff --git a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockRenderKit.java b/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockRenderKit.java index 6f490f2..2d1981f 100644 --- a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockRenderKit.java +++ b/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockRenderKit.java @@ -3,6 +3,7 @@ package org.rhq.core.gui.configuration; import java.io.OutputStream; import java.io.Writer; import java.util.HashMap; +import java.util.HashSet;
import javax.faces.context.ResponseStream; import javax.faces.context.ResponseWriter; @@ -34,10 +35,26 @@ public class MockRenderKit extends RenderKit {
}
+ HashSet<String> noRendererSet; + + public HashSet<String> getNoRendererSet() { + if (null == noRendererSet) { + noRendererSet = new HashSet<String>(); + noRendererSet.add("javax.faces.HtmlCommandLink"); + noRendererSet.add("javax.faces.Form"); + noRendererSet.add("javax.faces.Textarea"); + } + return noRendererSet; + } + HashMap<String, Class> rendererMap;
@Override public Renderer getRenderer(String family, String rendererType) { + + if (getNoRendererSet().contains(rendererType)) + return null; + try { if (null == rendererMap) { rendererMap = new HashMap<String, Class>(); @@ -45,16 +62,17 @@ public class MockRenderKit extends RenderKit { rendererMap.put("javax.faces.Format", OutputMessageRenderer.class); rendererMap.put("javax.faces.Group", GroupRenderer.class); rendererMap.put(ConfigRenderer.class.getName(), ConfigRenderer.class); - //HtmlCommandLink has no renderer. It renders itself + rendererMap.put("javax.faces.Link", com.sun.faces.renderkit.html_basic.CommandLinkRenderer.class); + rendererMap.put("javax.faces.Image", com.sun.faces.renderkit.html_basic.ImageRenderer.class); + rendererMap.put("javax.faces.Grid", com.sun.faces.renderkit.html_basic.GridRenderer.class); + } Class c = rendererMap.get(rendererType); if (c == null) { System.out.println("MockRenderKit request for unsupported type " + rendererType); - return null; - } else { - - return (Renderer) c.newInstance(); } + return (Renderer) c.newInstance(); + } catch (Exception e) { throw new RuntimeException(e); } diff --git a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockResponseWriter.java b/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockResponseWriter.java index d1b6e56..85247fb 100644 --- a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockResponseWriter.java +++ b/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockResponseWriter.java @@ -31,7 +31,8 @@ public class MockResponseWriter extends ResponseWriter {
@Override public void flush() throws IOException { - throw new RuntimeException("Function not implemented"); + + stringWriter.flush();
}
@@ -43,8 +44,7 @@ public class MockResponseWriter extends ResponseWriter {
@Override public String getContentType() { - throw new RuntimeException("Function not implemented"); - + return "contenttype:"; }
@Override @@ -55,7 +55,8 @@ public class MockResponseWriter extends ResponseWriter {
@Override public void startElement(String name, UIComponent component) throws IOException { - stringWriter.write("startElement: " + name + ": componenet:" + component.getId() + "\n"); + stringWriter.write("startElement: " + name + ": component:" + + (component != null ? component.getId() : "componenet is null") + "\n"); }
@Override @@ -82,8 +83,7 @@ public class MockResponseWriter extends ResponseWriter {
@Override public void writeURIAttribute(String name, Object value, String property) throws IOException { - throw new RuntimeException("Function not implemented"); - + stringWriter.write("attributename:" + name + ", value:" + value.toString() + ", property:" + property); }
@Override diff --git a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockViewHandler.java b/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockViewHandler.java new file mode 100644 index 0000000..0074169 --- /dev/null +++ b/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockViewHandler.java @@ -0,0 +1,53 @@ +package org.rhq.core.gui.configuration; + +import java.io.IOException; +import java.util.Locale; + +import javax.faces.FacesException; +import javax.faces.application.ViewHandler; +import javax.faces.component.UIViewRoot; +import javax.faces.context.FacesContext; + +public class MockViewHandler extends ViewHandler { + + @Override + public Locale calculateLocale(FacesContext context) { + throw new RuntimeException("Function not implemented"); + } + + @Override + public String calculateRenderKitId(FacesContext context) { + throw new RuntimeException("Function not implemented"); + } + + @Override + public UIViewRoot createView(FacesContext context, String viewId) { + throw new RuntimeException("Function not implemented"); + } + + @Override + public String getActionURL(FacesContext context, String viewId) { + throw new RuntimeException("Function not implemented"); + } + + @Override + public String getResourceURL(FacesContext context, String path) { + return "uri://" + path; + } + + @Override + public void renderView(FacesContext context, UIViewRoot viewToRender) throws IOException, FacesException { + throw new RuntimeException("Function not implemented"); + } + + @Override + public UIViewRoot restoreView(FacesContext context, String viewId) { + throw new RuntimeException("Function not implemented"); + } + + @Override + public void writeState(FacesContext context) throws IOException { + throw new RuntimeException("Function not implemented"); + } + +} diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit-raw.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit-raw.xhtml index c01694e..6ccfaab 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit-raw.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit-raw.xhtml @@ -34,15 +34,6 @@ </script> <a4j:form id="editResourceConfigurationForm"> - <h:outputText value="#{messages.youareviewingraw}" /> - <h:panelGroup rendered="#{ExistingResourceConfigurationUIBean.structuredSupported}"> - <h:outputText value=" #{messages.switch2}" /> - <h:commandLink action="#{ExistingResourceConfigurationUIBean.switchTostructured}"> - <s:conversationId /> - <f:param name="id" value="#{ResourceUIBean.id}" /> - <h:outputText value=" #{messages.structured}" /> - </h:commandLink> - </h:panelGroup> <table class="summary-props-table" style=""> <input type="hidden" name="id" value="#{ResourceUIBean.id}" />
commit 4d08d8f6188243555cf5dcf4c8cf2e00a95f44b8 Author: Adam Young ayoung@redhat.com Date: Sun Dec 13 14:22:13 2009 -0500
Fixed unit test
diff --git a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/ConfigRendererTest.java b/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/ConfigRendererTest.java index 9c57ad4..660933b 100644 --- a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/ConfigRendererTest.java +++ b/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/ConfigRendererTest.java @@ -17,6 +17,7 @@ import org.testng.annotations.Test;
import org.rhq.core.domain.configuration.Configuration; import org.rhq.core.domain.configuration.Property; +import org.rhq.core.domain.configuration.RawConfiguration; import org.rhq.core.domain.configuration.definition.ConfigurationDefinition; import org.rhq.core.domain.configuration.definition.ConfigurationFormat;
@@ -83,6 +84,7 @@ public class ConfigRendererTest { value.setConfiguration(configuration); value.setId(3); configuration.getMap().put(value.getName(), value); + configuration.getRawConfigurations().add(buildMockRawConfig());
Assert.assertNotNull(configUIComponent.getConfigurationDefinition()); configUIComponent.getConfigurationDefinition().setConfigurationFormat(ConfigurationFormat.STRUCTURED_AND_RAW); @@ -102,6 +104,13 @@ public class ConfigRendererTest {
}
+ private RawConfiguration buildMockRawConfig() { + RawConfiguration raw = new RawConfiguration(); + + raw.setContents("a=1".getBytes()); + return raw; + } + //@Test public void testDecode() { configUIComponent.setReadOnly(false); diff --git a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockApplication.java b/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockApplication.java index d89eb86..abe95ee 100644 --- a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockApplication.java +++ b/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockApplication.java @@ -14,8 +14,10 @@ import javax.faces.application.ViewHandler; import javax.faces.component.UIComponent; import javax.faces.component.UIParameter; import javax.faces.component.html.HtmlCommandLink; +import javax.faces.component.html.HtmlGraphicImage; import javax.faces.component.html.HtmlOutputFormat; import javax.faces.component.html.HtmlOutputText; +import javax.faces.component.html.HtmlPanelGrid; import javax.faces.component.html.HtmlPanelGroup; import javax.faces.context.FacesContext; import javax.faces.convert.Converter; @@ -118,6 +120,8 @@ public class MockApplication extends Application { componentTypeMap.put("javax.faces.Output", HtmlOutputFormat.class); componentTypeMap.put("javax.faces.HtmlCommandLink", HtmlCommandLink.class); componentTypeMap.put("javax.faces.Parameter", UIParameter.class); + componentTypeMap.put("javax.faces.HtmlGraphicImage", HtmlGraphicImage.class); + componentTypeMap.put("javax.faces.HtmlPanelGrid", HtmlPanelGrid.class); } return componentTypeMap; } diff --git a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockServletContext.java b/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockServletContext.java index 8740aca..f604d00 100644 --- a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockServletContext.java +++ b/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockServletContext.java @@ -34,7 +34,6 @@ import javax.servlet.ServletContext; import javax.servlet.ServletException;
import com.sun.faces.config.WebConfiguration; - final class MockServletContext implements ServletContext { public void setAttribute(String arg0, Object arg1) { this.attributeMap.put(arg0, arg1);
commit e1105e2cee84559602c932dcd87bd00832f6b77e Author: Adam Young ayoung@redhat.com Date: Fri Dec 11 18:47:28 2009 -0500
Merging the raw config work into the JSF components, and removing from the facelet code.
diff --git a/.classpath b/.classpath index 55ab9f4..91f0343 100644 --- a/.classpath +++ b/.classpath @@ -1,6 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" path="modules/common/jboss-as/src/main/java"/> + <classpathentry kind="src" path="modules/test-utils/src/main/java"/> <classpathentry kind="src" path="modules/common/jboss-as/src/test/java"/> <classpathentry kind="src" path="modules/plugins/jboss-as/src/main/java"/> <classpathentry kind="src" path="modules/plugins/jboss-as/src/test/java"/> @@ -13,8 +14,9 @@ <classpathentry kind="src" path="modules/plugins/tomcat/src/test/java"/> <classpathentry kind="src" path="modules/plugins/jboss-cache/src/main/java"/> <classpathentry kind="src" path="modules/plugins/jboss-cache-v3/src/main/java"/> - <classpathentry excluding="org/rhq/plugins/antlrconfig/" kind="src" path="modules/plugins/antlr-config/src/main/java"/> + <classpathentry kind="src" path="modules/plugins/antlr-config/src/main/java"/> <classpathentry kind="src" path="modules/core/gui/src/test/java"/> + <classpathentry kind="src" path="modules/plugins/antlr-config/target/generated-sources/antlr3"/> <classpathentry kind="var" path="M2_REPO/org/jboss/integration/jboss-profileservice-spi/5.1.0.SP1/jboss-profileservice-spi-5.1.0.SP1.jar"/> <classpathentry kind="var" path="M2_REPO/org/jboss/man/jboss-managed/2.1.1.GA/jboss-managed-2.1.1.GA.jar"/> <classpathentry kind="var" path="M2_REPO/org/jboss/man/jboss-metatype/2.1.1.GA/jboss-metatype-2.1.1.GA.jar"/> @@ -104,7 +106,6 @@ <classpathentry kind="src" path="modules/plugins/snmptrapd/src/main/java"/> <classpathentry kind="src" path="modules/plugins/script/src/main/java"/> <classpathentry kind="src" path="modules/plugins/antlr-config/src/main/antlr3"/> - <classpathentry kind="src" path="modules/plugins/antlr-config/target/generated-sources/antlr3"/> <classpathentry kind="src" path="modules/helpers/rtfilter/src/main/java"/> <classpathentry kind="src" path="modules/helpers/pluginAnnotations/src/main/java"/> <classpathentry kind="src" path="modules/helpers/pluginGen/src/main/java"/> @@ -204,5 +205,8 @@ <classpathentry exported="true" kind="var" path="M2_REPO/commons-digester/commons-digester/1.8/commons-digester-1.8.jar"/> <classpathentry exported="true" kind="var" path="M2_REPO/commons-codec/commons-codec/1.4/commons-codec-1.4.jar"/> <classpathentry exported="true" kind="lib" path="modules/enterprise/remoting/webservices/target/rhq-remoting-webservices-1.4.0-SNAPSHOT/wsconsume-output"/> + <classpathentry kind="var" path="M2_REPO/org/jmock/jmock/2.5.1/jmock-2.5.1.jar" sourcepath="/M2_REPO/org/jmock/jmock/2.5.1/jmock-2.5.1-sources.jar"/> + <classpathentry kind="var" path="M2_REPO/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1.jar" sourcepath="/M2_REPO/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1-sources.jar"/> + <classpathentry kind="var" path="M2_REPO/org/hamcrest/hamcrest-library/1.1/hamcrest-library-1.1.jar" sourcepath="M2_REPO/org/hamcrest/hamcrest-library/1.1/hamcrest-library-1.1-sources.jar"/> <classpathentry kind="output" path="eclipse-classes"/> </classpath> diff --git a/.gitignore b/.gitignore index 1d53abe..bca5c45 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,4 @@ dev-container dev-agent antlr-generated/ *.tokens +test-output/* diff --git a/modules/core/gui/pom.xml b/modules/core/gui/pom.xml index 96a3212..eaddceb 100644 --- a/modules/core/gui/pom.xml +++ b/modules/core/gui/pom.xml @@ -138,6 +138,14 @@ </exclusions> </dependency>
+ + <dependency> + <groupId>javax.faces</groupId> + <artifactId>jsf-impl</artifactId> + <scope>provided</scope> + </dependency> + + </dependencies>
<repositories> @@ -221,4 +229,4 @@
</profiles>
-</project> \ No newline at end of file +</project> diff --git a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/AbstractConfigurationComponent.java b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/AbstractConfigurationComponent.java index 3cda4bd..11a4672 100644 --- a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/AbstractConfigurationComponent.java +++ b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/AbstractConfigurationComponent.java @@ -29,9 +29,11 @@ import javax.faces.context.FacesContext;
import org.rhq.core.domain.configuration.Configuration; import org.rhq.core.domain.configuration.definition.ConfigurationDefinition; +import org.rhq.core.domain.configuration.definition.ConfigurationFormat; import org.rhq.core.gui.configuration.propset.ConfigurationSetComponent; import org.rhq.core.gui.util.FacesComponentIdFactory; import org.rhq.core.gui.util.FacesComponentUtility; +import org.rhq.core.gui.util.FacesContextUtility;
/** * An abstract base class for the {@link ConfigUIComponent} and the {@link ConfigurationSetComponent} JSF component @@ -213,4 +215,18 @@ public abstract class AbstractConfigurationComponent extends UIComponentBase imp this.isGroup = (Boolean) this.stateValues[6]; }
+ public boolean getShouldShowRaw() { + return Boolean.valueOf(FacesContextUtility.getOptionalRequestParameter("showRaw", String.class, "unset")) + || (this.getConfigurationDefinition().getConfigurationFormat().equals(ConfigurationFormat.RAW)); + } + + RawConfigUIComponent rawConfigUIComponent; + + RawConfigUIComponent getRawConfigUIComponent() { + if (null == rawConfigUIComponent) { + rawConfigUIComponent = new RawConfigUIComponent(getConfiguration(), getConfigurationDefinition(), this); + } + return rawConfigUIComponent; + } + } \ No newline at end of file diff --git a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/ConfigRenderer.java b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/ConfigRenderer.java index b5e67a3..c779dda 100644 --- a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/ConfigRenderer.java +++ b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/ConfigRenderer.java @@ -31,7 +31,9 @@ import javax.faces.application.FacesMessage; import javax.faces.component.UIComponent; import javax.faces.component.UIForm; import javax.faces.component.UIInput; +import javax.faces.component.UIOutput; import javax.faces.component.UIParameter; +import javax.faces.component.html.HtmlCommandLink; import javax.faces.component.html.HtmlForm; import javax.faces.component.html.HtmlOutputLink; import javax.faces.component.html.HtmlPanelGrid; @@ -54,6 +56,7 @@ import org.rhq.core.domain.configuration.Property; import org.rhq.core.domain.configuration.PropertyList; import org.rhq.core.domain.configuration.PropertyMap; import org.rhq.core.domain.configuration.PropertySimple; +import org.rhq.core.domain.configuration.definition.ConfigurationFormat; import org.rhq.core.domain.configuration.definition.PropertyDefinition; import org.rhq.core.domain.configuration.definition.PropertyDefinitionMap; import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple; @@ -117,6 +120,7 @@ public class ConfigRenderer extends Renderer { .isFullyEditable(), true); } } + }
/** @@ -195,12 +199,16 @@ public class ConfigRenderer extends Renderer { writer.writeText("\n", component, null); writer.endElement("div"); writer.writeComment("********** End of " + component.getClass().getSimpleName() + " component **********"); + + component.getChildren().clear(); }
public void addChildComponents(AbstractConfigurationComponent configurationComponent) { + if ((configurationComponent.getConfigurationDefinition() == null) || ((configurationComponent.getConfiguration() != null) && configurationComponent.getConfiguration() - .getMap().isEmpty())) { + .getMap().isEmpty()) + && !configurationComponent.getConfigurationDefinition().getConfigurationFormat().isRawSupported()) { if (configurationComponent.getNullConfigurationDefinitionMessage() != null) { String styleClass = (configurationComponent.getNullConfigurationStyle() == null) ? "ErrorBlock" : configurationComponent.getNullConfigurationStyle(); @@ -244,20 +252,49 @@ public class ConfigRenderer extends Renderer { if (!configurationComponent.isReadOnly()) addRequiredNotationsKey(configurationComponent);
- if (configurationComponent.getListName() != null) { - if (configurationComponent.getListIndex() == null) { - // No index specified means we should add a new map to the list. - configurationComponent.setListIndex(addNewMap(configurationComponent)); + Boolean shouldShowRawNow = configurationComponent.getShouldShowRaw(); + addStructuredRawToggle(configurationComponent, shouldShowRawNow); + if (shouldShowRawNow) { + configurationComponent.getChildren().add( + new RawConfigUIComponent(configurationComponent.getConfiguration(), configurationComponent + .getConfigurationDefinition(), configurationComponent)); + } else { + if (configurationComponent.getListName() != null) { + if (configurationComponent.getListIndex() == null) { + // No index specified means we should add a new map to the list. + configurationComponent.setListIndex(addNewMap(configurationComponent)); + } + + addListMemberProperty(configurationComponent); + } else { + addConfiguration(configurationComponent); }
- addListMemberProperty(configurationComponent); - } else { - addConfiguration(configurationComponent); + String id = getInitInputsJavaScriptComponentId(configurationComponent); + PropertyRenderingUtility.addInitInputsJavaScript(configurationComponent, id, configurationComponent + .isFullyEditable(), false); } + } + + private void addStructuredRawToggle(AbstractConfigurationComponent configurationComponent, boolean showRaw) { + if (configurationComponent.getConfigurationDefinition().getConfigurationFormat().equals( + ConfigurationFormat.STRUCTURED_AND_RAW)) { + + HtmlPanelGroup toRawLinkPanel = FacesComponentUtility.addBlockPanel(configurationComponent, + configurationComponent, UNGROUPED_PROPERTIES_STYLE_CLASS);
- String id = getInitInputsJavaScriptComponentId(configurationComponent); - PropertyRenderingUtility.addInitInputsJavaScript(configurationComponent, id, configurationComponent - .isFullyEditable(), false); + FacesComponentUtility.addOutputText(toRawLinkPanel, configurationComponent, + "internationalized Message goes here", UNGROUPED_PROPERTIES_STYLE_CLASS); + + HtmlCommandLink commandLink = FacesComponentUtility.addCommandLink(toRawLinkPanel, configurationComponent); + + UIOutput output = new UIOutput(); + output.setValue(showRaw ? "Show Structured" : " Show Raw"); + commandLink.getChildren().add(output); + //output.setParent(commandLink); + FacesComponentUtility.addParameter(commandLink, configurationComponent, "showRaw", Boolean + .toString(!showRaw)); + } }
private void addListMemberProperty(AbstractConfigurationComponent configurationComponent) { diff --git a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/RawConfigUIComponent.java b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/RawConfigUIComponent.java new file mode 100644 index 0000000..1b7bf89 --- /dev/null +++ b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/RawConfigUIComponent.java @@ -0,0 +1,113 @@ +package org.rhq.core.gui.configuration; + +import java.io.IOException; + +import javax.faces.component.UIComponent; +import javax.faces.component.UIComponentBase; +import javax.faces.component.UIPanel; +import javax.faces.component.html.HtmlCommandLink; +import javax.faces.component.html.HtmlInputTextarea; +import javax.faces.component.html.HtmlPanelGrid; +import javax.faces.context.FacesContext; + +import org.rhq.core.domain.configuration.Configuration; +import org.rhq.core.domain.configuration.RawConfiguration; +import org.rhq.core.domain.configuration.definition.ConfigurationDefinition; +import org.rhq.core.gui.util.FacesComponentIdFactory; +import org.rhq.core.gui.util.FacesComponentUtility; + +public class RawConfigUIComponent extends UIComponentBase { + + @Override + public void decode(FacesContext context) { + super.decode(context); + + } + + @Override + public String getFamily() { + return "rhq"; + } + + Configuration configuration; + ConfigurationDefinition configurationDefinition; + FacesComponentIdFactory idFactory; + + @Override + public boolean getRendersChildren() { + return true; + } + + @Override + public void encodeChildren(FacesContext context) throws IOException { + for (UIComponent kid : getChildren()) { + kid.encodeAll(context); + } + } + + @Override + public boolean isTransient() { + return true; + } + + public RawConfigUIComponent(Configuration configuration, ConfigurationDefinition configurationDefinition, + FacesComponentIdFactory componentIdFactory) { + + this.configuration = configuration; + this.configurationDefinition = configurationDefinition; + this.idFactory = componentIdFactory; + + UIPanel rawPanel = FacesComponentUtility.addBlockPanel(this, idFactory, ""); + addToolbarIcons(rawPanel); + + HtmlPanelGrid grid = FacesComponentUtility.addPanelGrid(rawPanel, idFactory, "summary-props-table"); + grid.setParent(this); + grid.setColumns(2); + grid.setColumnClasses("raw-config-table"); + + HtmlPanelGrid panelLeft = FacesComponentUtility.addPanelGrid(grid, idFactory, "summary-props-table"); + panelLeft.setBgcolor("#a4b2b9"); + panelLeft.setColumns(1); + + FacesComponentUtility.addOutputText(panelLeft, idFactory, "Raw Configurations Paths", ""); + + int rawCount = 0; + for (RawConfiguration raw : configuration.getRawConfigurations()) { + UIPanel nextPath = FacesComponentUtility.addBlockPanel(panelLeft, idFactory, ""); + HtmlCommandLink link = FacesComponentUtility.addCommandLink(nextPath, idFactory); + + FacesComponentUtility.addOutputText(link, idFactory, raw.getPath(), ""); + FacesComponentUtility.addParameter(link, idFactory, "path", raw.getPath()); + FacesComponentUtility.addParameter(link, idFactory, "whichRaw", Integer.toString(rawCount++)); + FacesComponentUtility.addParameter(link, idFactory, "showRaw", Boolean.TRUE.toString()); + } + + UIPanel panelRight = FacesComponentUtility.addBlockPanel(grid, idFactory, "summary-props-table"); + + UIPanel editPanel = FacesComponentUtility.addBlockPanel(panelRight, idFactory, "summary-props-table"); + HtmlInputTextarea inputTextarea = new HtmlInputTextarea(); + editPanel.getChildren().add(inputTextarea); + inputTextarea.setParent(editPanel); + inputTextarea.setCols(80); + inputTextarea.setRows(40); + inputTextarea.setValue(configuration.getRawConfigurations().iterator().next().getContentString()); + } + + private void addToolbarIcons(UIPanel panelRight) { + HtmlCommandLink fullScreenCommandLink = FacesComponentUtility.addCommandLink(panelRight, idFactory); + FacesComponentUtility.addGraphicImage(fullScreenCommandLink, idFactory, "/images/save.png", "Save"); + FacesComponentUtility.addOutputText(fullScreenCommandLink, idFactory, "Save", ""); + + HtmlCommandLink saveCommandLink = FacesComponentUtility.addCommandLink(panelRight, idFactory); + FacesComponentUtility.addGraphicImage(saveCommandLink, idFactory, "/images/viewfullscreen.png", "FullScreen"); + FacesComponentUtility.addOutputText(saveCommandLink, idFactory, "Full Screen", ""); + + HtmlCommandLink uploadCommandLink = FacesComponentUtility.addCommandLink(panelRight, idFactory); + FacesComponentUtility.addGraphicImage(uploadCommandLink, idFactory, "/images/upload.png", "Upload"); + FacesComponentUtility.addOutputText(uploadCommandLink, idFactory, "Upload", ""); + + HtmlCommandLink downloadCommandLink = FacesComponentUtility.addCommandLink(panelRight, idFactory); + FacesComponentUtility.addGraphicImage(downloadCommandLink, idFactory, "/images/download.png", "download"); + FacesComponentUtility.addOutputText(downloadCommandLink, idFactory, "Download", ""); + } +} diff --git a/modules/core/gui/src/main/java/org/rhq/core/gui/util/FacesComponentUtility.java b/modules/core/gui/src/main/java/org/rhq/core/gui/util/FacesComponentUtility.java index a3c2257..ad2274b 100644 --- a/modules/core/gui/src/main/java/org/rhq/core/gui/util/FacesComponentUtility.java +++ b/modules/core/gui/src/main/java/org/rhq/core/gui/util/FacesComponentUtility.java @@ -1,25 +1,25 @@ - /* - * RHQ Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2, as - * published by the Free Software Foundation, and/or the GNU Lesser - * General Public License, version 2.1, also as published by the Free - * Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License and the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License - * and the GNU Lesser General Public License along with this program; - * if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ +/* + * RHQ Management Platform + * Copyright (C) 2005-2008 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ package org.rhq.core.gui.util;
import java.util.ArrayList; @@ -32,10 +32,10 @@ import java.util.UUID; import javax.el.ValueExpression; import javax.faces.application.Application; import javax.faces.component.UIComponent; +import javax.faces.component.UIForm; import javax.faces.component.UIInput; import javax.faces.component.UIOutput; import javax.faces.component.UIParameter; -import javax.faces.component.UIForm; import javax.faces.component.UIViewRoot; import javax.faces.component.html.HtmlColumn; import javax.faces.component.html.HtmlCommandButton; @@ -50,16 +50,17 @@ import javax.faces.component.html.HtmlOutputText; import javax.faces.component.html.HtmlPanelGrid; import javax.faces.component.html.HtmlPanelGroup; import javax.faces.context.FacesContext; + import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.richfaces.component.html.HtmlSeparator; import org.richfaces.component.html.HtmlSimpleTogglePanel;
- /** - * A set of utility methods for working with JSF {@link UIComponent}s. - * - * @author Ian Springer - */ +/** +* A set of utility methods for working with JSF {@link UIComponent}s. +* +* @author Ian Springer +*/ public abstract class FacesComponentUtility { public static final String NO_STYLE_CLASS = null;
@@ -77,16 +78,31 @@ public abstract class FacesComponentUtility { }
@NotNull - public static HtmlPanelGroup addBlockPanel(@NotNull - UIComponent parent, FacesComponentIdFactory idFactory, String styleClass) { + public static HtmlPanelGrid createPanelGrid(FacesComponentIdFactory idFactory, String styleClass) { + HtmlPanelGrid panel = createComponent(HtmlPanelGrid.class, idFactory); + panel.setStyleClass(styleClass); + return panel; + } + + @NotNull + public static HtmlPanelGroup addBlockPanel(@NotNull UIComponent parent, FacesComponentIdFactory idFactory, + String styleClass) { HtmlPanelGroup panel = createBlockPanel(idFactory, styleClass); parent.getChildren().add(panel); return panel; }
@NotNull - public static HtmlPanelGroup addInlinePanel(@NotNull - UIComponent parent, FacesComponentIdFactory idFactory, String styleClass) { + public static HtmlPanelGrid addPanelGrid(@NotNull UIComponent parent, FacesComponentIdFactory idFactory, + String styleClass) { + HtmlPanelGrid panel = createPanelGrid(idFactory, styleClass); + parent.getChildren().add(panel); + return panel; + } + + @NotNull + public static HtmlPanelGroup addInlinePanel(@NotNull UIComponent parent, FacesComponentIdFactory idFactory, + String styleClass) { HtmlPanelGroup panel = createComponent(HtmlPanelGroup.class, idFactory); panel.setStyleClass(styleClass); parent.getChildren().add(panel); @@ -94,8 +110,8 @@ public abstract class FacesComponentUtility { }
@NotNull - public static HtmlSimpleTogglePanel addSimpleTogglePanel(@NotNull - UIComponent parent, FacesComponentIdFactory idFactory, String label) { + public static HtmlSimpleTogglePanel addSimpleTogglePanel(@NotNull UIComponent parent, + FacesComponentIdFactory idFactory, String label) { HtmlSimpleTogglePanel panel = createComponent(HtmlSimpleTogglePanel.class, idFactory); panel.setLabel(label);
@@ -106,16 +122,15 @@ public abstract class FacesComponentUtility { }
@NotNull - public static HtmlSeparator addSeparator(@NotNull - UIComponent parent, FacesComponentIdFactory idFactory) { + public static HtmlSeparator addSeparator(@NotNull UIComponent parent, FacesComponentIdFactory idFactory) { HtmlSeparator separator = createComponent(HtmlSeparator.class, idFactory); parent.getChildren().add(separator); return separator; }
@NotNull - public static HtmlOutputText addOutputText(@NotNull - UIComponent parent, FacesComponentIdFactory idFactory, CharSequence value, String styleClass) { + public static HtmlOutputText addOutputText(@NotNull UIComponent parent, FacesComponentIdFactory idFactory, + CharSequence value, String styleClass) { HtmlOutputText text = createComponent(HtmlOutputText.class, idFactory); text.setValue(value); text.setStyleClass(styleClass); @@ -135,8 +150,8 @@ public abstract class FacesComponentUtility { }
@NotNull - public static HtmlColumn addColumn(@NotNull - UIComponent parent, FacesComponentIdFactory idFactory, CharSequence headerText, String headerStyle) { + public static HtmlColumn addColumn(@NotNull UIComponent parent, FacesComponentIdFactory idFactory, + CharSequence headerText, String headerStyle) { HtmlColumn column = createComponent(HtmlColumn.class, idFactory); HtmlOutputText header = new HtmlOutputText(); header.setValue(headerText); @@ -147,8 +162,7 @@ public abstract class FacesComponentUtility { }
@NotNull - public static HtmlOutputText addVerbatimText(@NotNull - UIComponent parent, CharSequence html) { + public static HtmlOutputText addVerbatimText(@NotNull UIComponent parent, CharSequence html) { HtmlOutputText outputText = createComponent(HtmlOutputText.class, null); outputText.setEscape(false); outputText.setValue(html); @@ -163,10 +177,8 @@ public abstract class FacesComponentUtility { }
@NotNull - public static UIOutput addJavaScript(@NotNull - UIComponent parent, FacesComponentIdFactory idFactory, @Nullable - CharSequence src, @Nullable - CharSequence script) { + public static UIOutput addJavaScript(@NotNull UIComponent parent, FacesComponentIdFactory idFactory, + @Nullable CharSequence src, @Nullable CharSequence script) { UIOutput output = createComponent(UIOutput.class, idFactory); output.getAttributes().put("escape", Boolean.FALSE); StringBuilder value = new StringBuilder(); @@ -220,8 +232,8 @@ public abstract class FacesComponentUtility { }
@NotNull - public static HtmlOutputLabel addLabel(@NotNull - UIComponent parent, FacesComponentIdFactory idFactory, UIInput associatedInput, String value, String styleClass) { + public static HtmlOutputLabel addLabel(@NotNull UIComponent parent, FacesComponentIdFactory idFactory, + UIInput associatedInput, String value, String styleClass) { HtmlOutputLabel label = createComponent(HtmlOutputLabel.class, idFactory); label.setFor(associatedInput.getId()); label.setValue(value); @@ -231,8 +243,8 @@ public abstract class FacesComponentUtility { }
@NotNull - public static HtmlGraphicImage addGraphicImage(@NotNull - UIComponent parent, FacesComponentIdFactory idFactory, String url, String alt) { + public static HtmlGraphicImage addGraphicImage(@NotNull UIComponent parent, FacesComponentIdFactory idFactory, + String url, String alt) { HtmlGraphicImage image = FacesComponentUtility.createComponent(HtmlGraphicImage.class, idFactory); image.setUrl(url); image.setAlt(alt); @@ -242,8 +254,8 @@ public abstract class FacesComponentUtility { }
@NotNull - public static HtmlOutputLink addOutputLink(@NotNull - UIComponent parent, FacesComponentIdFactory idFactory, String value) { + public static HtmlOutputLink addOutputLink(@NotNull UIComponent parent, FacesComponentIdFactory idFactory, + String value) { HtmlOutputLink link = FacesComponentUtility.createComponent(HtmlOutputLink.class, idFactory); link.setValue(value); parent.getChildren().add(link); @@ -251,8 +263,8 @@ public abstract class FacesComponentUtility { }
@NotNull - public static UIParameter addParameter(@NotNull - UIComponent parent, FacesComponentIdFactory idFactory, String name, String value) { + public static UIParameter addParameter(@NotNull UIComponent parent, FacesComponentIdFactory idFactory, String name, + String value) { UIParameter parameter = createComponent(UIParameter.class, idFactory); parameter.setName(name); parameter.setValue(value); @@ -261,8 +273,7 @@ public abstract class FacesComponentUtility { }
@NotNull - public static HtmlForm addForm(@NotNull - UIComponent parent, FacesComponentIdFactory idFactory) { + public static HtmlForm addForm(@NotNull UIComponent parent, FacesComponentIdFactory idFactory) { HtmlForm form = createComponent(HtmlForm.class, idFactory); form.setPrependId(false); parent.getChildren().add(form); @@ -270,8 +281,8 @@ public abstract class FacesComponentUtility { }
@NotNull - public static HtmlCommandButton addCommandButton(@NotNull - UIComponent parent, FacesComponentIdFactory idFactory, String value, String styleClass) { + public static HtmlCommandButton addCommandButton(@NotNull UIComponent parent, FacesComponentIdFactory idFactory, + String value, String styleClass) { HtmlCommandButton button = createComponent(HtmlCommandButton.class, idFactory); button.setValue(value); button.setStyleClass(styleClass); @@ -280,16 +291,15 @@ public abstract class FacesComponentUtility { }
@NotNull - public static HtmlCommandLink addCommandLink(@NotNull - UIComponent parent, FacesComponentIdFactory idFactory) { + public static HtmlCommandLink addCommandLink(@NotNull UIComponent parent, FacesComponentIdFactory idFactory) { HtmlCommandLink link = FacesComponentUtility.createComponent(HtmlCommandLink.class, idFactory); parent.getChildren().add(link); return link; }
@NotNull - public static HtmlMessage addMessage(@NotNull - UIComponent parent, FacesComponentIdFactory idFactory, String associatedComponentId, String styleClass) { + public static HtmlMessage addMessage(@NotNull UIComponent parent, FacesComponentIdFactory idFactory, + String associatedComponentId, String styleClass) { HtmlMessage message = FacesComponentUtility.createComponent(HtmlMessage.class, idFactory); message.setFor(associatedComponentId); message.setShowDetail(true); @@ -302,8 +312,8 @@ public abstract class FacesComponentUtility { }
@NotNull - public static HtmlPanelGrid addPanelGrid(@NotNull - UIComponent parent, FacesComponentIdFactory idFactory, int columns, String styleClass) { + public static HtmlPanelGrid addPanelGrid(@NotNull UIComponent parent, FacesComponentIdFactory idFactory, + int columns, String styleClass) { HtmlPanelGrid panelGrid = FacesComponentUtility.createComponent(HtmlPanelGrid.class, idFactory); panelGrid.setColumns(columns); panelGrid.setStyleClass(styleClass); @@ -312,8 +322,8 @@ public abstract class FacesComponentUtility { }
@NotNull - public static HtmlDataTable addDataTable(@NotNull - UIComponent parent, FacesComponentIdFactory idFactory, String styleClass) { + public static HtmlDataTable addDataTable(@NotNull UIComponent parent, FacesComponentIdFactory idFactory, + String styleClass) { HtmlDataTable dataTable = FacesComponentUtility.createComponent(HtmlDataTable.class, idFactory); dataTable.setStyleClass(styleClass); parent.getChildren().add(dataTable); @@ -321,17 +331,13 @@ public abstract class FacesComponentUtility { }
@Nullable - public static String getExpressionAttribute(@NotNull - UIComponent component, @NotNull - String attribName) { + public static String getExpressionAttribute(@NotNull UIComponent component, @NotNull String attribName) { return getExpressionAttribute(component, attribName, String.class); }
@Nullable - public static <T> T getExpressionAttribute(@NotNull - UIComponent component, @NotNull - String attribName, @NotNull - Class<T> expectedType) { + public static <T> T getExpressionAttribute(@NotNull UIComponent component, @NotNull String attribName, + @NotNull Class<T> expectedType) { ValueExpression valueExpression = component.getValueExpression(attribName); T attribValue = (valueExpression != null) ? FacesExpressionUtility.getValue(valueExpression, expectedType) : null; @@ -339,8 +345,7 @@ public abstract class FacesComponentUtility { }
@NotNull - public static Map<String, String> getParameters(@NotNull - UIComponent component) { + public static Map<String, String> getParameters(@NotNull UIComponent component) { // Use a LinkedHashMap, so the order of the parameters is maintained. Map<String, String> params = new LinkedHashMap<String, String>(); List<UIComponent> children = component.getChildren(); @@ -375,8 +380,8 @@ public abstract class FacesComponentUtility { * @return a {@link UIComponent} of the specified type */ @SuppressWarnings("unchecked") - public static <T extends UIComponent> T createComponent(Class<T> componentClass, @Nullable - FacesComponentIdFactory idFactory) { + public static <T extends UIComponent> T createComponent(Class<T> componentClass, + @Nullable FacesComponentIdFactory idFactory) { Application application = FacesContext.getCurrentInstance().getApplication(); String componentType = getComponentType(componentClass); T component = (T) application.createComponent(componentType); @@ -500,25 +505,20 @@ public abstract class FacesComponentUtility { * @throws IllegalArgumentException if more than one UIForm is found in the component's ancestry */ @Nullable - public static UIForm getEnclosingForm(UIComponent component) - throws IllegalArgumentException - { - UIForm ret = null; - while (component != null) - { - if (component instanceof UIForm) - { - if (ret != null) - { - // Cannot have a doubly-nested form! - throw new IllegalArgumentException(); - } - ret = (UIForm) component; - } - component = component.getParent(); - } - return ret; - } + public static UIForm getEnclosingForm(UIComponent component) throws IllegalArgumentException { + UIForm ret = null; + while (component != null) { + if (component instanceof UIForm) { + if (ret != null) { + // Cannot have a doubly-nested form! + throw new IllegalArgumentException(); + } + ret = (UIForm) component; + } + component = component.getParent(); + } + return ret; + }
private static <T extends UIComponent> String getComponentType(Class<T> componentClass) { String componentType; @@ -531,9 +531,8 @@ public abstract class FacesComponentUtility { return componentType; }
- private static class DefaultFacesComponentIdFactory implements FacesComponentIdFactory { - public String createUniqueId() - { + private static class DefaultFacesComponentIdFactory implements FacesComponentIdFactory { + public String createUniqueId() { // NOTE: Our id's *must* begin with UIViewRoot.UNIQUE_ID_PREFIX ("j_id") to prevent HtmlOutputText // components from being rendered as SPAN elements // (see com.sun.faces.renderkit.html_basic.TextRenderer#getEndTextToRender()). diff --git a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/ConfigRendererTest.java b/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/ConfigRendererTest.java index 63c1d52..9c57ad4 100644 --- a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/ConfigRendererTest.java +++ b/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/ConfigRendererTest.java @@ -5,10 +5,8 @@ import java.io.StringWriter; import java.util.HashMap;
import javax.faces.FactoryFinder; -import javax.faces.context.ExternalContext; import javax.faces.context.FacesContext; import javax.faces.lifecycle.Lifecycle; -import javax.faces.render.RenderKitFactory;
import com.sun.faces.context.FacesContextImpl;
@@ -18,19 +16,21 @@ import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test;
import org.rhq.core.domain.configuration.Configuration; +import org.rhq.core.domain.configuration.Property; import org.rhq.core.domain.configuration.definition.ConfigurationDefinition; +import org.rhq.core.domain.configuration.definition.ConfigurationFormat;
public class ConfigRendererTest {
- RenderKitFactory rkf; ConfigUIComponent configUIComponent; ConfigRenderer configRenderer; FacesContext facesContext; - ExternalContext externalContext; + MockExternalContext externalContext; AjaxContext ajaxContext; MockResponseWriter mockResponseWriter; Lifecycle lifecycle; ConfigurationDefinition configurationDefinition; + private Configuration configuration;
@BeforeMethod protected void setUp() throws Exception { @@ -55,10 +55,12 @@ public class ConfigRendererTest { ajaxContext = AjaxContext.getCurrentInstance(facesContext);
configUIComponent.setId("ID"); - - configUIComponent.setValueExpression("configuration", new MockValueExpression(new Configuration())); + configuration = new Configuration(); + configUIComponent.setValueExpression("configuration", new MockValueExpression(configuration)); configUIComponent.setValueExpression("configurationDefinition", new MockValueExpression(buildConfigDefinition())); + configUIComponent.setRendererType(ConfigRenderer.class.getName()); + }
private ConfigurationDefinition buildConfigDefinition() { @@ -75,8 +77,29 @@ public class ConfigRendererTest {
@Test public void testUIComponentEncode() throws IOException { - configUIComponent.setRendererType(ConfigRenderer.class.getName()); + Property value; + value = new Property(); + value.setName("test1"); + value.setConfiguration(configuration); + value.setId(3); + configuration.getMap().put(value.getName(), value); + + Assert.assertNotNull(configUIComponent.getConfigurationDefinition()); + configUIComponent.getConfigurationDefinition().setConfigurationFormat(ConfigurationFormat.STRUCTURED_AND_RAW); + + Assert.assertNotNull(configUIComponent.getConfigurationDefinition().getConfigurationFormat()); + Assert.assertTrue(configUIComponent.getConfigurationDefinition().getConfigurationFormat().isRawSupported()); + Assert.assertTrue(configUIComponent.getConfigurationDefinition().getConfigurationFormat() + .isStructuredSupported()); + + externalContext.requestParameterMap.put("showRaw", "true"); + configUIComponent.encodeAll(facesContext); + + String s2 = mockResponseWriter.stringWriter.getBuffer().toString(); + + System.out.println(s2); + }
//@Test diff --git a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockApplication.java b/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockApplication.java index 335eb88..d89eb86 100644 --- a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockApplication.java +++ b/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockApplication.java @@ -1,8 +1,10 @@ package org.rhq.core.gui.configuration;
import java.util.Collection; +import java.util.HashMap; import java.util.Iterator; import java.util.Locale; +import java.util.Map;
import javax.faces.FacesException; import javax.faces.application.Application; @@ -10,6 +12,11 @@ import javax.faces.application.NavigationHandler; import javax.faces.application.StateManager; import javax.faces.application.ViewHandler; import javax.faces.component.UIComponent; +import javax.faces.component.UIParameter; +import javax.faces.component.html.HtmlCommandLink; +import javax.faces.component.html.HtmlOutputFormat; +import javax.faces.component.html.HtmlOutputText; +import javax.faces.component.html.HtmlPanelGroup; import javax.faces.context.FacesContext; import javax.faces.convert.Converter; import javax.faces.el.MethodBinding; @@ -22,6 +29,8 @@ import javax.faces.validator.Validator;
public class MockApplication extends Application {
+ Map<String, Class> componentTypeMap; + @Override public void addComponent(String componentType, String componentClass) { throw new RuntimeException("Function not implemented"); @@ -29,13 +38,13 @@ public class MockApplication extends Application { }
@Override - public void addConverter(String converterId, String converterClass) { + public void addConverter(Class targetClass, String converterClass) { throw new RuntimeException("Function not implemented");
}
@Override - public void addConverter(Class targetClass, String converterClass) { + public void addConverter(String converterId, String converterClass) { throw new RuntimeException("Function not implemented");
} @@ -48,7 +57,12 @@ public class MockApplication extends Application {
@Override public UIComponent createComponent(String componentType) throws FacesException { - throw new RuntimeException("Function not implemented"); + try { + return (UIComponent) getComponentTypeMap().get(componentType).newInstance(); + } catch (Exception e) { + e.printStackTrace(); + throw new FacesException("can't create component " + componentType); + }
}
@@ -60,13 +74,13 @@ public class MockApplication extends Application { }
@Override - public Converter createConverter(String converterId) { + public Converter createConverter(Class targetClass) { throw new RuntimeException("Function not implemented");
}
@Override - public Converter createConverter(Class targetClass) { + public Converter createConverter(String converterId) { throw new RuntimeException("Function not implemented");
} @@ -95,6 +109,19 @@ public class MockApplication extends Application {
}
+ Map<String, Class> getComponentTypeMap() { + if (null == componentTypeMap) { + + componentTypeMap = new HashMap<String, Class>(); + componentTypeMap.put("javax.faces.HtmlOutputText", HtmlOutputText.class); + componentTypeMap.put("javax.faces.HtmlPanelGroup", HtmlPanelGroup.class); + componentTypeMap.put("javax.faces.Output", HtmlOutputFormat.class); + componentTypeMap.put("javax.faces.HtmlCommandLink", HtmlCommandLink.class); + componentTypeMap.put("javax.faces.Parameter", UIParameter.class); + } + return componentTypeMap; + } + @Override public Iterator<String> getComponentTypes() { throw new RuntimeException("Function not implemented"); diff --git a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockExternalContext.java b/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockExternalContext.java index 8fb6172..cd8500c 100644 --- a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockExternalContext.java +++ b/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockExternalContext.java @@ -133,7 +133,7 @@ public class MockExternalContext extends ExternalContext { return requestMap; }
- Map<String, String> requestParameterMap = new HashMap<String, String>(); + public Map<String, String> requestParameterMap = new HashMap<String, String>();
@Override public Map<String, String> getRequestParameterMap() { diff --git a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockFacesContext.java b/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockFacesContext.java index 73097d6..77e410d 100644 --- a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockFacesContext.java +++ b/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockFacesContext.java @@ -12,6 +12,8 @@ import javax.faces.context.ResponseStream; import javax.faces.context.ResponseWriter; import javax.faces.render.RenderKit;
+import com.sun.faces.renderkit.RenderKitImpl; + public class MockFacesContext extends FacesContext {
private ExternalContext externalContext; @@ -26,13 +28,16 @@ public class MockFacesContext extends FacesContext { @Override public void addMessage(String clientId, FacesMessage message) { throw new RuntimeException("Function not implemented"); - }
+ MockApplication mockApp; + @Override public Application getApplication() { - throw new RuntimeException("Function not implemented"); - + if (null == mockApp) { + mockApp = new MockApplication(); + } + return mockApp; }
@Override @@ -65,11 +70,15 @@ public class MockFacesContext extends FacesContext {
}
- RenderKit mockRenderKit = new MockRenderKit(); + RenderKit renderKit = new MockRenderKit();
@Override public RenderKit getRenderKit() { - return mockRenderKit; + if (null == renderKit) { + renderKit = new RenderKitImpl(); + renderKit.addRenderer("rhq", ConfigRenderer.class.getName(), new ConfigRenderer()); + } + return renderKit; }
@Override diff --git a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockRenderKit.java b/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockRenderKit.java index 56df905..6f490f2 100644 --- a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockRenderKit.java +++ b/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockRenderKit.java @@ -2,6 +2,7 @@ package org.rhq.core.gui.configuration;
import java.io.OutputStream; import java.io.Writer; +import java.util.HashMap;
import javax.faces.context.ResponseStream; import javax.faces.context.ResponseWriter; @@ -9,6 +10,10 @@ import javax.faces.render.RenderKit; import javax.faces.render.Renderer; import javax.faces.render.ResponseStateManager;
+import com.sun.faces.renderkit.html_basic.GroupRenderer; +import com.sun.faces.renderkit.html_basic.OutputMessageRenderer; +import com.sun.faces.renderkit.html_basic.TextRenderer; + public class MockRenderKit extends RenderKit {
@Override @@ -29,12 +34,29 @@ public class MockRenderKit extends RenderKit {
}
+ HashMap<String, Class> rendererMap; + @Override public Renderer getRenderer(String family, String rendererType) { try { - return (Renderer) Class.forName(rendererType).newInstance(); + if (null == rendererMap) { + rendererMap = new HashMap<String, Class>(); + rendererMap.put("javax.faces.Text", TextRenderer.class); + rendererMap.put("javax.faces.Format", OutputMessageRenderer.class); + rendererMap.put("javax.faces.Group", GroupRenderer.class); + rendererMap.put(ConfigRenderer.class.getName(), ConfigRenderer.class); + //HtmlCommandLink has no renderer. It renders itself + } + Class c = rendererMap.get(rendererType); + if (c == null) { + System.out.println("MockRenderKit request for unsupported type " + rendererType); + return null; + } else { + + return (Renderer) c.newInstance(); + } } catch (Exception e) { - return null; + throw new RuntimeException(e); }
} diff --git a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockValueExpression.java b/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockValueExpression.java index 45d2993..cb3dc63 100644 --- a/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockValueExpression.java +++ b/modules/core/gui/src/test/java/org/rhq/core/gui/configuration/MockValueExpression.java @@ -32,8 +32,7 @@ public class MockValueExpression extends ValueExpression {
@Override public String getExpressionString() { - throw new RuntimeException("Function not implemented"); - + return "#{" + value.getClass().getSimpleName() + "}"; }
@Override diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml index 0d4899f..12156e4 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml @@ -24,18 +24,19 @@ THIS TEXT WILL BE REMOVED.
<ui:define name="content">
+ + <style type="text/css"> + td.raw-config-table { + vertical-align: top; + valign: top; + } +</style> + + <h:panelGroup layout="block" styleClass="InfoBlock" rendered="#{ExistingResourceConfigurationUIBean.updateInProgress}"> <b>${msg['note']}</b> ${msg['resource.config.Current.updateInProgress']} </h:panelGroup>
- <h:outputText value="#{messages.youareviewingstructured}" /> - <h:panelGroup rendered="#{ExistingResourceConfigurationUIBean.rawSupported}" > - <h:outputText value=" #{messages.switch2}" /> - <h:outputLink value="view-raw.xhtml"> - <f:param name="id" value="#{ResourceUIBean.id}" /> - <h:outputText value=" #{messages.raw}" /> - </h:outputLink> - </h:panelGroup>
<h:outputText value=" #{messages.nopermissionedit}" rendered="#{!ResourceUIBean.permissions.configure}"/>
@@ -61,6 +62,7 @@ THIS TEXT WILL BE REMOVED. nullConfigurationDefinitionMessage="#{ExistingResourceConfigurationUIBean.nullConfigurationDefinitionMessage}" nullConfigurationMessage="#{ExistingResourceConfigurationUIBean.nullConfigurationMessage}" prevalidate="true"/> + <input type="hidden" name="id" value="#{ResourceUIBean.id}"/>
</h:form>
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java index 8916b19..ad4ab27 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java @@ -286,7 +286,7 @@ public class WebservicesManagerBean implements WebservicesRemote { return repoManager.findPackageVersionsInRepoByCriteria(subject, criteria); }
- @Override + //@Override public int synchronizeRepos(Subject subject, Integer[] repoIds) { return repoManager.synchronizeRepos(subject, repoIds); } @@ -371,8 +371,8 @@ public class WebservicesManagerBean implements WebservicesRemote { }
public ResourceConfigurationUpdate updateStructuredOrRawConfiguration(Subject subject, int resourceId, - Configuration newConfiguration, boolean fromStructured) - throws ResourceNotFoundException, ConfigurationUpdateStillInProgressException { + Configuration newConfiguration, boolean fromStructured) throws ResourceNotFoundException, + ConfigurationUpdateStillInProgressException { return configurationManager.updateStructuredOrRawConfiguration(subject, resourceId, newConfiguration, fromStructured); } diff --git a/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/xmlrpc/ApacheXmlRpcExecutor.java b/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/xmlrpc/ApacheXmlRpcExecutor.java index f3c75e2..004608a 100644 --- a/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/xmlrpc/ApacheXmlRpcExecutor.java +++ b/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/xmlrpc/ApacheXmlRpcExecutor.java @@ -32,12 +32,10 @@ public class ApacheXmlRpcExecutor implements XmlRpcExecutor { this.client = clientIn; }
- @Override public Object execute(String methodName, Object[] params) throws XmlRpcException { return client.execute(methodName, params); }
- @Override public Object execute(String pMethodName, List pParams) throws XmlRpcException { return client.execute(pMethodName, pParams); } diff --git a/modules/enterprise/server/plugins/rhnhosted/src/test/java/org/rhq/enterprise/server/plugins/rhnhosted/xmlrpc/MockRhnXmlRpcExecutor.java b/modules/enterprise/server/plugins/rhnhosted/src/test/java/org/rhq/enterprise/server/plugins/rhnhosted/xmlrpc/MockRhnXmlRpcExecutor.java index bcdfe41..9a033d5 100644 --- a/modules/enterprise/server/plugins/rhnhosted/src/test/java/org/rhq/enterprise/server/plugins/rhnhosted/xmlrpc/MockRhnXmlRpcExecutor.java +++ b/modules/enterprise/server/plugins/rhnhosted/src/test/java/org/rhq/enterprise/server/plugins/rhnhosted/xmlrpc/MockRhnXmlRpcExecutor.java @@ -70,7 +70,7 @@ public class MockRhnXmlRpcExecutor implements XmlRpcExecutor { /* (non-Javadoc) * @see org.rhq.enterprise.server.plugins.rhnhosted.xmlrpc.XmlRpcExecutor#execute(java.lang.String, java.lang.Object[]) */ - @Override + //@Override public Object execute(String methodName, Object[] params) throws XmlRpcException { //for (Object object : params) { // System.out.println("parm: " + object); @@ -242,7 +242,7 @@ public class MockRhnXmlRpcExecutor implements XmlRpcExecutor {
}
- @Override + //@Override public Object execute(String pMethodName, List pParams) throws XmlRpcException { return execute(pMethodName, pParams.toArray()); }
commit dadf978f748092ae95ec8cf36d31ddd15241ef17 Author: Heiko W. Rupp pilhuhn@fedorapeople.org Date: Fri Dec 11 21:10:05 2009 +0100
Implement plugin validation for alerts.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/AlertPluginValidator.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/AlertPluginValidator.java index 9117447..7391723 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/AlertPluginValidator.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/AlertPluginValidator.java @@ -19,12 +19,72 @@
package org.rhq.enterprise.server.plugin.pc.alert;
+import java.net.URL; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + import org.rhq.enterprise.server.plugin.pc.ServerPluginEnvironment; import org.rhq.enterprise.server.plugin.pc.ServerPluginValidator; +import org.rhq.enterprise.server.xmlschema.generated.serverplugin.alert.AlertPluginDescriptorType; +import org.rhq.enterprise.server.xmlschema.generated.serverplugin.alert.CustomUi;
public class AlertPluginValidator implements ServerPluginValidator { + public boolean validate(ServerPluginEnvironment env) { - // TODO test validate env.getPluginDescriptor() + + Log log = LogFactory.getLog(AlertPluginValidator.class); + + AlertPluginDescriptorType type = (AlertPluginDescriptorType) env.getPluginDescriptor(); + + String className = type.getPluginClass(); + if (!className.contains(".")) { + className = type.getPackage() + "." + className; + } + try { + Class.forName(className,false,env.getPluginClassLoader()); + } + catch (Exception e) { + log.error("Can't find pluginClass " + className + " for plugin " + env.getPluginKey().getPluginName() ); + return false; + } + + // The short name is basically the key into the plugin + String shortName = type.getShortName(); + + // + // Ok, we have a valid plugin class, so we can look for other things + // and store the info + // + + String uiSnippetPath; + URL uiSnippetUrl = null; + CustomUi customUI = type.getCustomUi(); + if (customUI!=null) { + uiSnippetPath = customUI.getUiSnippetName(); + + try { + uiSnippetUrl = env.getPluginClassLoader().getResource(uiSnippetPath); + log.info("UI snipped for " + shortName + " is at " + uiSnippetUrl); + } + catch (Exception e) { + log.error("No valid ui snippet provided, but <custom-ui> given for sender plugin " + shortName + "Error is "+ e.getMessage()); + return false; + } + + // Get the backing bean class + className = customUI.getBackingBeanName(); + if (!className.contains(".")) { + className = type.getPackage() + "." + className; + } + try { + Class.forName(className,true,env.getPluginClassLoader()); // TODO how make this available to Seam and the Web-CL ? + } + catch (Throwable t ) { + log.error("Backing bean " + className + " not found for plugin " + shortName); + return false; + } + } return true; } } diff --git a/modules/enterprise/server/plugins/validate-all-serverplugins/pom.xml b/modules/enterprise/server/plugins/validate-all-serverplugins/pom.xml index 6576a1a..80b4634 100644 --- a/modules/enterprise/server/plugins/validate-all-serverplugins/pom.xml +++ b/modules/enterprise/server/plugins/validate-all-serverplugins/pom.xml @@ -26,7 +26,7 @@
<build> <plugins> - <plugin> + <plugin> <artifactId>maven-antrun-plugin</artifactId> <executions> <execution> @@ -43,6 +43,12 @@ <pathelement location="../rhnhosted/target/rhq-serverplugin-rhnhosted-${project.version}.jar" /> <pathelement location="../url/target/rhq-serverplugin-url-${project.version}.jar" /> <pathelement location="../yum/target/rhq-serverplugin-yum-${project.version}.jar" /> + <pathelement location="../alert-email/target/alert-email-${project.version}.jar" /> + <pathelement location="../alert-irc/target/alert-irc-${project.version}.jar" /> + <pathelement location="../alert-microblog/target/alert-microblog-${project.version}.jar" /> + <pathelement location="../alert-mobicents/target/alert-mobicents-${project.version}.jar" /> + <pathelement location="../alert-roles/target/alert-roles-${project.version}.jar" /> + <pathelement location="../alert-snmp/target/alert-snmp-${project.version}.jar" /> </classpath> <sysproperty key="org.apache.commons.logging.Log" value="org.apache.commons.logging.impl.SimpleLog" /> <sysproperty key="rhq.test.serverplugins" value="${rhq.test.serverplugins}" />
commit 92858cb608fdb1e0be43df73dbf3095cea3f66b8 Merge: 112dbac... 237b442... Author: Heiko W. Rupp pilhuhn@fedorapeople.org Date: Fri Dec 11 19:39:30 2009 +0100
Merge branch 'master' into alertPlugin
diff --cc modules/core/dbutils/src/main/scripts/dbsetup/alert-schema.xml index c9f03a8,e71ea82..a13e2c6 --- a/modules/core/dbutils/src/main/scripts/dbsetup/alert-schema.xml +++ b/modules/core/dbutils/src/main/scripts/dbsetup/alert-schema.xml @@@ -130,16 -130,7 +130,16 @@@ <column name="SNMP_PORT" type="INTEGER"/> <column name="SNMP_OID" size="250" type="VARCHAR2"/> <column name="ALERT_CONFIG_ID" required="false" type="INTEGER" references="RHQ_CONFIG(ID)"/> - <column name="ALERT_SENDER_NAME" required="false" type="VARCHAR2" /> <!-- TODO make required = true --> + <column name="ALERT_SENDER_NAME" required="false" size="100" type="VARCHAR2" /> <!-- TODO make required = true --> </table>
+ <table name="RHQ_ALERT_NOTIF_TEMPL" tablespace="@@@LARGE_TABLESPACE_FOR_DATA@@@" + storage-options="freelists 5" cache="true" logging="false"> + <column name="ID" default="sequence-only" initial="10001" + primarykey="true" required="true" type="INTEGER"/> + <column name="NAME" required="true" size="40" type="VARCHAR2"/> + <column name="DESCRIPTION" required="false" size="250" type="VARCHAR2"/> + + </table> + </dbsetup>
commit 237b4421775f5a72388f8c8d9a7c0dcc631be149 Author: Heiko W. Rupp pilhuhn@fedorapeople.org Date: Fri Dec 11 17:57:44 2009 +0100
Replace hardcoded version dependencies, as the release plugin screws them up
diff --git a/modules/enterprise/server/plugins/alert-email/pom.xml b/modules/enterprise/server/plugins/alert-email/pom.xml index 85dbd6d..d2455b4 100644 --- a/modules/enterprise/server/plugins/alert-email/pom.xml +++ b/modules/enterprise/server/plugins/alert-email/pom.xml @@ -35,7 +35,7 @@ <dependency> <groupId>org.rhq</groupId> <artifactId>rhq-enterprise-server</artifactId> - <version>1.4.0-SNAPSHOT</version> + <version>${project.version}</version> <scope>provided</scope> <!-- by JBossAS --> </dependency>
diff --git a/modules/enterprise/server/plugins/alert-irc/pom.xml b/modules/enterprise/server/plugins/alert-irc/pom.xml index 76b3b72..aba01fc 100644 --- a/modules/enterprise/server/plugins/alert-irc/pom.xml +++ b/modules/enterprise/server/plugins/alert-irc/pom.xml @@ -30,7 +30,7 @@ <dependency> <groupId>org.rhq</groupId> <artifactId>rhq-enterprise-server</artifactId> - <version>1.4.0-SNAPSHOT</version> + <version>${project.version}</version> <scope>provided</scope> <!-- by JBossAS --> </dependency>
diff --git a/modules/enterprise/server/plugins/alert-microblog/pom.xml b/modules/enterprise/server/plugins/alert-microblog/pom.xml index f35ae52..7af42ac 100644 --- a/modules/enterprise/server/plugins/alert-microblog/pom.xml +++ b/modules/enterprise/server/plugins/alert-microblog/pom.xml @@ -30,7 +30,7 @@ <dependency> <groupId>org.rhq</groupId> <artifactId>rhq-enterprise-server</artifactId> - <version>1.4.0-SNAPSHOT</version> + <version>${project.version}</version> <scope>provided</scope> <!-- by JBossAS --> </dependency>
diff --git a/modules/enterprise/server/plugins/alert-mobicents/pom.xml b/modules/enterprise/server/plugins/alert-mobicents/pom.xml index d231484..c169069 100644 --- a/modules/enterprise/server/plugins/alert-mobicents/pom.xml +++ b/modules/enterprise/server/plugins/alert-mobicents/pom.xml @@ -29,7 +29,7 @@ <dependency> <groupId>org.rhq</groupId> <artifactId>rhq-enterprise-server</artifactId> - <version>1.4.0-SNAPSHOT</version> + <version>${project.version}</version> <scope>provided</scope> <!-- by JBossAS --> </dependency>
diff --git a/modules/enterprise/server/plugins/alert-roles/pom.xml b/modules/enterprise/server/plugins/alert-roles/pom.xml index dc4e8b4..5747fe2 100644 --- a/modules/enterprise/server/plugins/alert-roles/pom.xml +++ b/modules/enterprise/server/plugins/alert-roles/pom.xml @@ -36,7 +36,7 @@ <dependency> <groupId>org.rhq</groupId> <artifactId>rhq-enterprise-server</artifactId> - <version>1.4.0-SNAPSHOT</version> + <version>${project.version}</version> <scope>provided</scope> <!-- by JBossAS --> </dependency>
@@ -50,7 +50,7 @@ <artifactId>xml-apis</artifactId> </exclusion> </exclusions> - </dependency> + </dependency>
<!-- TODO: This is a fix for the Javac bug requiring annotations to be available when compiling dependent classes. It is fixed in JDK 6 --> diff --git a/modules/enterprise/server/plugins/alert-snmp/pom.xml b/modules/enterprise/server/plugins/alert-snmp/pom.xml index 62ec039..e329982 100644 --- a/modules/enterprise/server/plugins/alert-snmp/pom.xml +++ b/modules/enterprise/server/plugins/alert-snmp/pom.xml @@ -29,7 +29,7 @@ <dependency> <groupId>org.rhq</groupId> <artifactId>rhq-enterprise-server</artifactId> - <version>1.4.0-SNAPSHOT</version> + <version>${project.version}</version> <scope>provided</scope> <!-- by JBossAS --> </dependency>
diff --git a/modules/enterprise/server/plugins/perspectives/core/perspective/pom.xml b/modules/enterprise/server/plugins/perspectives/core/perspective/pom.xml index ca5eda3..298c092 100644 --- a/modules/enterprise/server/plugins/perspectives/core/perspective/pom.xml +++ b/modules/enterprise/server/plugins/perspectives/core/perspective/pom.xml @@ -21,7 +21,9 @@ <description>A Perspective defining Core UI Elements</description>
<properties> - <rhq.version>1.4.0-SNAPSHOT</rhq.version> +<!-- + <rhq.version>${project.version}</rhq.version> +--> </properties>
<dependencies> @@ -30,7 +32,7 @@ <dependency> <groupId>org.rhq</groupId> <artifactId>rhq-enterprise-server</artifactId> - <version>${rhq.version}</version> + <version>${project.version}</version> <scope>provided</scope> <!-- provided by the server/plugin-container --> </dependency>
@@ -58,9 +60,9 @@ -->
</dependencies> - + <profiles> - + <profile> <id>dev</id>
@@ -115,7 +117,7 @@ </plugins> </build> </profile> - + </profiles>
</project> diff --git a/modules/helpers/pluginGen/pom.xml b/modules/helpers/pluginGen/pom.xml index 3197e9e..5bc551f 100644 --- a/modules/helpers/pluginGen/pom.xml +++ b/modules/helpers/pluginGen/pom.xml @@ -88,7 +88,7 @@ <dependency> <groupId>org.rhq.helpers</groupId> <artifactId>rhq-pluginAnnotations</artifactId> - <version>1.4.0-SNAPSHOT</version> + <version>${project.version}</version> </dependency> </dependencies> </project>
commit d10220faf2c617cd75b242a4077cc47422ab9a72 Author: John Sanda jsanda@redhat.com Date: Fri Dec 11 11:14:36 2009 -0500
Renaming script to something more logical
diff --git a/modules/enterprise/remoting/scripts/src/main/script/configuration/config_util.js b/modules/enterprise/remoting/scripts/src/main/script/configuration/config_util.js new file mode 100644 index 0000000..54c39a9 --- /dev/null +++ b/modules/enterprise/remoting/scripts/src/main/script/configuration/config_util.js @@ -0,0 +1,287 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2008 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +var waitInterval = 100; +var structured = true; +var raw = false; + +loadResourceTypes(); + +function loadResourceTypes() { + var resourceTypes = context.getAttribute('resourceTypes'); + if (resourceTypes != null && !resourceTypes.isEmpty()) { + return; + } + + var criteria = ResourceTypeCriteria(); + criteria.fetchResourceConfigurationDefinition(true); + + resourceTypes = ResourceTypeManager.findResourceTypesByCriteria(criteria); + context.setAttribute('resourceTypes', resourceTypes, javax.script.ScriptContext.ENGINE_SCOPE); +} + +function ConfigUtil(resourceName) { + var util = this; + + this.resource = findServer(resourceName); + + this.getLatestConfiguration = function () { + var latestUpdate = ConfigurationManager.getLatestResourceConfigurationUpdate(this.resource.id); + + Assert.assertNotNull( + latestUpdate, + "Failed to load the latest resource configuration update for " + this.resource.name + ); + Assert.assertNotNull( + latestUpdate.configuration, + "No configuration is attached to the latest config update object." + ); + + return latestUpdate.configuration; + } + + this.printLatestConfiguration = function() { + var configuration = this.getLatestConfiguration(); + printConfiguration(configuration); + } + + function printConfiguration(configuration) { + pretty.print(configuration); + + if (util.isRawSupported() || util.isStructuredAndRawSupported()) { + println("\nRaw configuration files:"); + var rawConfigs = java.util.ArrayList(configuration.rawConfigurations); + for (i = 0; i < rawConfigs.size(); i++) { + var rawConfig = rawConfigs.get(i); + println("\n[" + rawConfig.path + "]"); + println(java.lang.String(rawConfig.contents) + "\n\n---------------------"); + } + } + } + + this.translateToRaw = function(update) { + doTranslation(update, true); + } + + this.translateToStructured = function(update) { + doTranslation(update, false); + } + + function doTranslation(update, doStructured) { + println("Loading latest configuration for " + util.resource.name); + var configuration = util.getLatestConfiguration(); + + printConfiguration(configuration) + println(''); + + if (doStructured) { + doStructuredUpdate(util.resource, configuration, update); + } + else { + doRawUpdate(util.resource, configuration, update); + } + + println("Modified configuration..."); + printConfiguration(configuration) + println(''); + + var translatedConfig = ConfigurationManager.translateResourceConfiguration(util.resource.id, configuration, + doStructured); + + println("Translated configuration..."); + printConfiguration(translatedConfig); + println(''); + } + + this.updateConfiguration = function(update, doStructured) { + println("Loading latest configuration for " + this.resource.name); + var configuration = this.getLatestConfiguration(); + + printConfiguration(configuration); + println(''); + + if (this.isStructuredSupported()) { + applyStructuredUpdate(this.resource, configuration, update); + } + else if (this.isRawSupported()) { + applyRawUpdate(this.resource, configuration, update); + } + else if (this.isStructuredAndRawSupported()) { + if (doStructured == null) { + throw "\nMust specify structured or raw when updating a configuration that supports both " + + "structured and raw. Update will abort."; + } + + if (doStructured) { + applyStructuredUpdate(this.resource, configuration, update); + } + else { + applyRawUpdate(this.resource, configuration, update); + } + } + + this.waitForResourceConfigurationUpdateToComplete(); + println("Configuration update has completed."); + + println("Loading latest, updated configuration"); + this.printLatestConfiguration(); + } + + this.waitForResourceConfigurationUpdateToComplete = function() { + print("Waiting for configuration update to complete...") + while (ConfigurationManager.isResourceConfigurationUpdateInProgress(this.resource.id)) { + print("."); + java.lang.Thread.sleep(waitInterval); + } + println(''); + } + + this.isRawSupported = function() { + var configFormat = this.resource.resourceType.resourceConfigurationDefinition.configurationFormat; + return ConfigurationFormat.RAW == configFormat; + } + + this.isStructuredSupported = function() { + var configFormat = this.resource.resourceType.resourceConfigurationDefinition.configurationFormat; + return ConfigurationFormat.STRUCTURED == configFormat; + } + + this.isStructuredAndRawSupported = function() { + var configFormat = this.resource.resourceType.resourceConfigurationDefinition.configurationFormat; + return ConfigurationFormat.STRUCTURED_AND_RAW == configFormat; + } + + function verifyPropertyToUpdateExists(configuration) { + if (!isDefined('propertyName')) { + throw "\nThe 'propertyName' variable must be defined. Update will abort."; + } + + if (!isDefined('propertyValue')) { + throw "\nThe 'propertyValue' variable must be defined. Update will abort."; + } + + if(configuration.getSimple(propertyName) == null) { + throw "\nThe property '" + propertyName + "' is undefined. Update will abort."; + } + } + + function verifyRawContentExists() { + if (!isDefined('contents')) { + throw "\n'contents' argument is required when updating " + serverName; + } + } + + function applyStructuredUpdate(resource, configuration, update) { + println("Applying resource configuration update..."); + doStructuredUpdate(resource, configuration, update); + ConfigurationManager.updateStructuredOrRawConfiguration(resource.id, configuration, structured); + } + + function doStructuredUpdate(resource, configuration, update) { + for (key in update) { + var property = configuration.getSimple(key.toString()); + if (property == null) { + throw "\nThe property '" + key + "' does not exist in the configuration. Update will abort."; + } + property.stringValue = update[key]; + } + } + + function applyRawUpdate(resource, configuration, update) { + println("Applying resource configuration update..."); + doRawUpdate(resource, configuration, update); + ConfigurationManager.updateStructuredOrRawConfiguration(resource.id, configuration, raw); + } + + function doRawUpdate(resourcec, configuration) { + var updates = 0; + var rawConfigs = java.util.ArrayList(configuration.rawConfigurations); + for (path in update) { + var rawConfig = findRawConfig(path, rawConfigs); + if (rawConfig == null) { + println("Failed to find raw config with path ending with " + path); + } + else { + configuration.rawConfigurations.remove(rawConfig); + var contents = java.lang.String(update[path]); + rawConfig.contents = contents.bytes; + configuration.rawConfigurations.add(rawConfig); + updates++; + } + } + + if (updates == 0) { + throw "\nNo matching paths were found. Update will abort."; + } + } + + function findRawConfig(path, rawConfigs) { + for (i = 0; i < rawConfigs.size(); i++) { + var rawConfig = rawConfigs.get(i); + if (rawConfig.path.endsWith(path.toString())) { + return rawConfig; + } + } + return null; + } + +} + +function findServer(name) { + var criteria = ResourceCriteria(); + criteria.strict = true; + criteria.addFilterName(name); + criteria.fetchResourceType(true); + + var resources = ResourceManager.findResourcesByCriteria(criteria); + + Assert.assertTrue(resources.size() == 1, "Expected to get back one resource but got back " + resources.size()); + + var resource = resources.get(0); + var resourceType = findResourceType(resource); + + if (resourceType == null) { + resourceType = loadResourceType(resource); + + if (resourceType == null) { + throw "Failed to initialize resource type for " + resource.name; + } + } + resource.resourceType = resourceType; + + return resource; +} + +function loadResourceType(resource) { + return ResourceTypeManager.getResourceTypeById(resource.resourceType.id); +} + +function findResourceType(resource) { + for (i = 0; i < resourceTypes.size(); i++) { + var resourceType = resourceTypes.get(i); + if (resourceType.id == resource.resourceType.id) { + return resourceType; + } + } + return null; +} diff --git a/modules/enterprise/remoting/scripts/src/main/script/configuration/update_structured.js b/modules/enterprise/remoting/scripts/src/main/script/configuration/update_structured.js deleted file mode 100644 index 54c39a9..0000000 --- a/modules/enterprise/remoting/scripts/src/main/script/configuration/update_structured.js +++ /dev/null @@ -1,287 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2, as - * published by the Free Software Foundation, and/or the GNU Lesser - * General Public License, version 2.1, also as published by the Free - * Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License and the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License - * and the GNU Lesser General Public License along with this program; - * if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -var waitInterval = 100; -var structured = true; -var raw = false; - -loadResourceTypes(); - -function loadResourceTypes() { - var resourceTypes = context.getAttribute('resourceTypes'); - if (resourceTypes != null && !resourceTypes.isEmpty()) { - return; - } - - var criteria = ResourceTypeCriteria(); - criteria.fetchResourceConfigurationDefinition(true); - - resourceTypes = ResourceTypeManager.findResourceTypesByCriteria(criteria); - context.setAttribute('resourceTypes', resourceTypes, javax.script.ScriptContext.ENGINE_SCOPE); -} - -function ConfigUtil(resourceName) { - var util = this; - - this.resource = findServer(resourceName); - - this.getLatestConfiguration = function () { - var latestUpdate = ConfigurationManager.getLatestResourceConfigurationUpdate(this.resource.id); - - Assert.assertNotNull( - latestUpdate, - "Failed to load the latest resource configuration update for " + this.resource.name - ); - Assert.assertNotNull( - latestUpdate.configuration, - "No configuration is attached to the latest config update object." - ); - - return latestUpdate.configuration; - } - - this.printLatestConfiguration = function() { - var configuration = this.getLatestConfiguration(); - printConfiguration(configuration); - } - - function printConfiguration(configuration) { - pretty.print(configuration); - - if (util.isRawSupported() || util.isStructuredAndRawSupported()) { - println("\nRaw configuration files:"); - var rawConfigs = java.util.ArrayList(configuration.rawConfigurations); - for (i = 0; i < rawConfigs.size(); i++) { - var rawConfig = rawConfigs.get(i); - println("\n[" + rawConfig.path + "]"); - println(java.lang.String(rawConfig.contents) + "\n\n---------------------"); - } - } - } - - this.translateToRaw = function(update) { - doTranslation(update, true); - } - - this.translateToStructured = function(update) { - doTranslation(update, false); - } - - function doTranslation(update, doStructured) { - println("Loading latest configuration for " + util.resource.name); - var configuration = util.getLatestConfiguration(); - - printConfiguration(configuration) - println(''); - - if (doStructured) { - doStructuredUpdate(util.resource, configuration, update); - } - else { - doRawUpdate(util.resource, configuration, update); - } - - println("Modified configuration..."); - printConfiguration(configuration) - println(''); - - var translatedConfig = ConfigurationManager.translateResourceConfiguration(util.resource.id, configuration, - doStructured); - - println("Translated configuration..."); - printConfiguration(translatedConfig); - println(''); - } - - this.updateConfiguration = function(update, doStructured) { - println("Loading latest configuration for " + this.resource.name); - var configuration = this.getLatestConfiguration(); - - printConfiguration(configuration); - println(''); - - if (this.isStructuredSupported()) { - applyStructuredUpdate(this.resource, configuration, update); - } - else if (this.isRawSupported()) { - applyRawUpdate(this.resource, configuration, update); - } - else if (this.isStructuredAndRawSupported()) { - if (doStructured == null) { - throw "\nMust specify structured or raw when updating a configuration that supports both " + - "structured and raw. Update will abort."; - } - - if (doStructured) { - applyStructuredUpdate(this.resource, configuration, update); - } - else { - applyRawUpdate(this.resource, configuration, update); - } - } - - this.waitForResourceConfigurationUpdateToComplete(); - println("Configuration update has completed."); - - println("Loading latest, updated configuration"); - this.printLatestConfiguration(); - } - - this.waitForResourceConfigurationUpdateToComplete = function() { - print("Waiting for configuration update to complete...") - while (ConfigurationManager.isResourceConfigurationUpdateInProgress(this.resource.id)) { - print("."); - java.lang.Thread.sleep(waitInterval); - } - println(''); - } - - this.isRawSupported = function() { - var configFormat = this.resource.resourceType.resourceConfigurationDefinition.configurationFormat; - return ConfigurationFormat.RAW == configFormat; - } - - this.isStructuredSupported = function() { - var configFormat = this.resource.resourceType.resourceConfigurationDefinition.configurationFormat; - return ConfigurationFormat.STRUCTURED == configFormat; - } - - this.isStructuredAndRawSupported = function() { - var configFormat = this.resource.resourceType.resourceConfigurationDefinition.configurationFormat; - return ConfigurationFormat.STRUCTURED_AND_RAW == configFormat; - } - - function verifyPropertyToUpdateExists(configuration) { - if (!isDefined('propertyName')) { - throw "\nThe 'propertyName' variable must be defined. Update will abort."; - } - - if (!isDefined('propertyValue')) { - throw "\nThe 'propertyValue' variable must be defined. Update will abort."; - } - - if(configuration.getSimple(propertyName) == null) { - throw "\nThe property '" + propertyName + "' is undefined. Update will abort."; - } - } - - function verifyRawContentExists() { - if (!isDefined('contents')) { - throw "\n'contents' argument is required when updating " + serverName; - } - } - - function applyStructuredUpdate(resource, configuration, update) { - println("Applying resource configuration update..."); - doStructuredUpdate(resource, configuration, update); - ConfigurationManager.updateStructuredOrRawConfiguration(resource.id, configuration, structured); - } - - function doStructuredUpdate(resource, configuration, update) { - for (key in update) { - var property = configuration.getSimple(key.toString()); - if (property == null) { - throw "\nThe property '" + key + "' does not exist in the configuration. Update will abort."; - } - property.stringValue = update[key]; - } - } - - function applyRawUpdate(resource, configuration, update) { - println("Applying resource configuration update..."); - doRawUpdate(resource, configuration, update); - ConfigurationManager.updateStructuredOrRawConfiguration(resource.id, configuration, raw); - } - - function doRawUpdate(resourcec, configuration) { - var updates = 0; - var rawConfigs = java.util.ArrayList(configuration.rawConfigurations); - for (path in update) { - var rawConfig = findRawConfig(path, rawConfigs); - if (rawConfig == null) { - println("Failed to find raw config with path ending with " + path); - } - else { - configuration.rawConfigurations.remove(rawConfig); - var contents = java.lang.String(update[path]); - rawConfig.contents = contents.bytes; - configuration.rawConfigurations.add(rawConfig); - updates++; - } - } - - if (updates == 0) { - throw "\nNo matching paths were found. Update will abort."; - } - } - - function findRawConfig(path, rawConfigs) { - for (i = 0; i < rawConfigs.size(); i++) { - var rawConfig = rawConfigs.get(i); - if (rawConfig.path.endsWith(path.toString())) { - return rawConfig; - } - } - return null; - } - -} - -function findServer(name) { - var criteria = ResourceCriteria(); - criteria.strict = true; - criteria.addFilterName(name); - criteria.fetchResourceType(true); - - var resources = ResourceManager.findResourcesByCriteria(criteria); - - Assert.assertTrue(resources.size() == 1, "Expected to get back one resource but got back " + resources.size()); - - var resource = resources.get(0); - var resourceType = findResourceType(resource); - - if (resourceType == null) { - resourceType = loadResourceType(resource); - - if (resourceType == null) { - throw "Failed to initialize resource type for " + resource.name; - } - } - resource.resourceType = resourceType; - - return resource; -} - -function loadResourceType(resource) { - return ResourceTypeManager.getResourceTypeById(resource.resourceType.id); -} - -function findResourceType(resource) { - for (i = 0; i < resourceTypes.size(); i++) { - var resourceType = resourceTypes.get(i); - if (resourceType.id == resource.resourceType.id) { - return resourceType; - } - } - return null; -}
commit c54676125c0d6cd991bf0ff875518cc3a8547b30 Author: Heiko W. Rupp pilhuhn@fedorapeople.org Date: Thu Dec 10 09:45:03 2009 +0100
Add required elements
diff --git a/modules/enterprise/server/xml-schemas/src/test/resources/test-serverplugin-alert.xml b/modules/enterprise/server/xml-schemas/src/test/resources/test-serverplugin-alert.xml index 74b7ec0..4e321c3 100644 --- a/modules/enterprise/server/xml-schemas/src/test/resources/test-serverplugin-alert.xml +++ b/modules/enterprise/server/xml-schemas/src/test/resources/test-serverplugin-alert.xml @@ -18,4 +18,8 @@ <c:simple-property name="alertprop1" /> </serverplugin:plugin-configuration>
+ <short-name>Test</short-name> + + <plugin-class>MyClass</plugin-class> + </alert-plugin>
commit db58839ac804a515d6d2271d0e305d98950b2449 Author: Heiko W. Rupp pilhuhn@fedorapeople.org Date: Thu Dec 10 13:38:55 2009 +0100
Copy the needed libs also when not in dev profile
diff --git a/modules/enterprise/server/plugins/alert-irc/pom.xml b/modules/enterprise/server/plugins/alert-irc/pom.xml index d2b424d..76b3b72 100644 --- a/modules/enterprise/server/plugins/alert-irc/pom.xml +++ b/modules/enterprise/server/plugins/alert-irc/pom.xml @@ -77,85 +77,119 @@
<profiles>
- <profile> - <id>dev</id> - - <properties> - <rhq.rootDir>../../../../..</rhq.rootDir> - <rhq.containerDir>${rhq.rootDir}/${rhq.defaultDevContainerPath}</rhq.containerDir> - <rhq.deploymentDir>${rhq.containerDir}/jbossas/server/default/deploy/${rhq.earName}/rhq-serverplugins</rhq.deploymentDir> - </properties> - - <build> - <plugins> - - <plugin> - <artifactId>maven-antrun-plugin</artifactId> - <version>1.1</version> - <executions> - - <execution> - <id>deploy</id> - <phase>compile</phase> - <configuration> - <tasks> - <mkdir dir="${rhq.deploymentDir}" /> - <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" /> - <echo>*** Updating ${deployment.file}...</echo> - <jar destfile="${deployment.file}" basedir="${project.build.outputDirectory}" /> - </tasks> - </configuration> - <goals> - <goal>run</goal> - </goals> - </execution> - - <execution> - <id>undeploy</id> - <phase>clean</phase> - <configuration> - <tasks> - <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" /> - <echo>*** Deleting ${deployment.file}...</echo> - <delete file="${deployment.file}" /> - </tasks> - </configuration> - <goals> - <goal>run</goal> - </goals> - </execution> - - </executions> - </plugin> - <plugin> - <artifactId>maven-dependency-plugin</artifactId> - <version>2.0</version> - <executions> - <execution> - <id>copy-pircbot-jar</id> - <phase>process-resources</phase> - <goals> - <goal>copy</goal> - </goals> - <configuration> - <artifactItems> - <artifactItem> - <groupId>pircbot</groupId> - <artifactId>pircbot</artifactId> - <version>1.4.2</version> - </artifactItem> - </artifactItems> - <outputDirectory>${project.build.outputDirectory}/lib</outputDirectory> - </configuration> - </execution> - </executions> - </plugin> - - - </plugins> - </build> - </profile> - + <profile> + <id>dev</id> + + <properties> + <rhq.rootDir>../../../../..</rhq.rootDir> + <rhq.containerDir>${rhq.rootDir}/${rhq.defaultDevContainerPath}</rhq.containerDir> + <rhq.deploymentDir>${rhq.containerDir}/jbossas/server/default/deploy/${rhq.earName}/rhq-serverplugins</rhq.deploymentDir> + </properties> + + <build> + <plugins> + + <plugin> + <artifactId>maven-antrun-plugin</artifactId> + <version>1.1</version> + <executions> + + <execution> + <id>deploy</id> + <phase>compile</phase> + <configuration> + <tasks> + <mkdir dir="${rhq.deploymentDir}" /> + <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" /> + <echo>*** Updating ${deployment.file}...</echo> + <jar destfile="${deployment.file}" basedir="${project.build.outputDirectory}" /> + </tasks> + </configuration> + <goals> + <goal>run</goal> + </goals> + </execution> + + <execution> + <id>undeploy</id> + <phase>clean</phase> + <configuration> + <tasks> + <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" /> + <echo>*** Deleting ${deployment.file}...</echo> + <delete file="${deployment.file}" /> + </tasks> + </configuration> + <goals> + <goal>run</goal> + </goals> + </execution> + + </executions> + </plugin> + <plugin> + <artifactId>maven-dependency-plugin</artifactId> + <version>2.0</version> + <executions> + <execution> + <id>copy-pircbot-jar</id> + <phase>process-resources</phase> + <goals> + <goal>copy</goal> + </goals> + <configuration> + <artifactItems> + <artifactItem> + <groupId>pircbot</groupId> + <artifactId>pircbot</artifactId> + <version>1.4.2</version> + </artifactItem> + </artifactItems> + <outputDirectory>${project.build.outputDirectory}/lib</outputDirectory> + </configuration> + </execution> + </executions> + </plugin> + + + </plugins> + </build> + </profile> + + <profile > + <id>overrides</id> + <activation> + <activeByDefault/> + </activation> + <build> + <plugins> + <plugin> + <artifactId>maven-dependency-plugin</artifactId> + <version>2.0</version> + <executions> + <execution> + <id>copy-pircbot-jar</id> + <phase>process-resources</phase> + <goals> + <goal>copy</goal> + </goals> + <configuration> + <artifactItems> + <artifactItem> + <groupId>pircbot</groupId> + <artifactId>pircbot</artifactId> + <version>1.4.2</version> + </artifactItem> + </artifactItems> + <outputDirectory>${project.build.outputDirectory}/lib</outputDirectory> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> + + </profile> </profiles>
</project> diff --git a/modules/enterprise/server/plugins/alert-microblog/pom.xml b/modules/enterprise/server/plugins/alert-microblog/pom.xml index ea1d2eb..f35ae52 100644 --- a/modules/enterprise/server/plugins/alert-microblog/pom.xml +++ b/modules/enterprise/server/plugins/alert-microblog/pom.xml @@ -76,87 +76,121 @@ </plugins> </build>
- <profiles> + <profiles>
<profile> - <id>dev</id> - - <properties> - <rhq.rootDir>../../../../..</rhq.rootDir> - <rhq.containerDir>${rhq.rootDir}/${rhq.defaultDevContainerPath}</rhq.containerDir> - <rhq.deploymentDir>${rhq.containerDir}/jbossas/server/default/deploy/${rhq.earName}/rhq-serverplugins</rhq.deploymentDir> - </properties> - - <build> - <plugins> - - <plugin> - <artifactId>maven-antrun-plugin</artifactId> - <version>1.1</version> - <executions> - - <execution> - <id>deploy</id> - <phase>compile</phase> - <configuration> - <tasks> - <mkdir dir="${rhq.deploymentDir}" /> - <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" /> - <echo>*** Updating ${deployment.file}...</echo> - <jar destfile="${deployment.file}" basedir="${project.build.outputDirectory}" /> - </tasks> - </configuration> - <goals> - <goal>run</goal> - </goals> - </execution> - - <execution> - <id>undeploy</id> - <phase>clean</phase> - <configuration> - <tasks> - <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" /> - <echo>*** Deleting ${deployment.file}...</echo> - <delete file="${deployment.file}" /> - </tasks> - </configuration> - <goals> - <goal>run</goal> - </goals> - </execution> - - </executions> - </plugin> - <plugin> - <artifactId>maven-dependency-plugin</artifactId> - <version>2.0</version> - <executions> - <execution> - <id>copy-twitter4j-jar</id> - <phase>process-resources</phase> - <goals> - <goal>copy</goal> - </goals> - <configuration> - <artifactItems> - <artifactItem> - <groupId>net.homeip.yusuke</groupId> - <artifactId>twitter4j</artifactId> - <version>2.0.9</version> - </artifactItem> - </artifactItems> - <outputDirectory>${project.build.outputDirectory}/lib</outputDirectory> - </configuration> - </execution> - </executions> - </plugin> - - - </plugins> - </build> + <id>dev</id> + + <properties> + <rhq.rootDir>../../../../..</rhq.rootDir> + <rhq.containerDir>${rhq.rootDir}/${rhq.defaultDevContainerPath}</rhq.containerDir> + <rhq.deploymentDir>${rhq.containerDir}/jbossas/server/default/deploy/${rhq.earName}/rhq-serverplugins</rhq.deploymentDir> + </properties> + + <build> + <plugins> + + <plugin> + <artifactId>maven-antrun-plugin</artifactId> + <version>1.1</version> + <executions> + + <execution> + <id>deploy</id> + <phase>compile</phase> + <configuration> + <tasks> + <mkdir dir="${rhq.deploymentDir}" /> + <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" /> + <echo>*** Updating ${deployment.file}...</echo> + <jar destfile="${deployment.file}" basedir="${project.build.outputDirectory}" /> + </tasks> + </configuration> + <goals> + <goal>run</goal> + </goals> + </execution> + + <execution> + <id>undeploy</id> + <phase>clean</phase> + <configuration> + <tasks> + <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" /> + <echo>*** Deleting ${deployment.file}...</echo> + <delete file="${deployment.file}" /> + </tasks> + </configuration> + <goals> + <goal>run</goal> + </goals> + </execution> + + </executions> + </plugin> + <plugin> + <artifactId>maven-dependency-plugin</artifactId> + <version>2.0</version> + <executions> + <execution> + <id>copy-twitter4j-jar</id> + <phase>process-resources</phase> + <goals> + <goal>copy</goal> + </goals> + <configuration> + <artifactItems> + <artifactItem> + <groupId>net.homeip.yusuke</groupId> + <artifactId>twitter4j</artifactId> + <version>2.0.9</version> + </artifactItem> + </artifactItems> + <outputDirectory>${project.build.outputDirectory}/lib</outputDirectory> + </configuration> + </execution> + </executions> + </plugin> + + + </plugins> + </build> </profile> + <profile > + <id>overrides</id> + <activation> + <activeByDefault/> + </activation> + <build> + <plugins> + <plugin> + <artifactId>maven-dependency-plugin</artifactId> + <version>2.0</version> + <executions> + <execution> + <id>copy-twitter4j-jar</id> + <phase>process-resources</phase> + <goals> + <goal>copy</goal> + </goals> + <configuration> + <artifactItems> + <artifactItem> + <groupId>net.homeip.yusuke</groupId> + <artifactId>twitter4j</artifactId> + <version>2.0.9</version> + </artifactItem> + </artifactItems> + <outputDirectory>${project.build.outputDirectory}/lib</outputDirectory> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build>
- </profiles> + </profile> + + </profiles>
</project> \ No newline at end of file
commit 2bfffc8bf7a815a67a120ebec8cd0d80fe4b8d71 Author: Jason Dobies jason.dobies@redhat.com Date: Thu Dec 10 15:38:24 2009 -0500
Renamed source -> provider.
diff --git a/modules/enterprise/server/plugins/jboss-software/src/main/resources/META-INF/rhq-serverplugin.xml b/modules/enterprise/server/plugins/jboss-software/src/main/resources/META-INF/rhq-serverplugin.xml index 0597ea1..522bacd 100644 --- a/modules/enterprise/server/plugins/jboss-software/src/main/resources/META-INF/rhq-serverplugin.xml +++ b/modules/enterprise/server/plugins/jboss-software/src/main/resources/META-INF/rhq-serverplugin.xml @@ -7,8 +7,8 @@ xmlns:c="urn:xmlns:rhq-configuration">
<contentSourceType name="JBossASPatchSource" - displayName="JBoss AS Patch Content Source" - description="This content source retrieves packages from the JBoss CSP RSS feed." + displayName="JBoss AS Patch Content Provider" + description="This content provider retrieves packages from the JBoss CSP RSS feed." lazyLoad="true" apiClass="org.rhq.enterprise.server.plugins.jboss.software.JBossSoftwareContentSourceAdapter">
commit 38bd583418aea281d62fa5b723d604319b7c9377 Author: Jason Dobies jason.dobies@redhat.com Date: Thu Dec 10 15:37:56 2009 -0500
Renamed source -> provider.
diff --git a/modules/enterprise/server/plugins/yum/src/main/resources/META-INF/rhq-serverplugin.xml b/modules/enterprise/server/plugins/yum/src/main/resources/META-INF/rhq-serverplugin.xml index 287a6f3..e42102b 100644 --- a/modules/enterprise/server/plugins/yum/src/main/resources/META-INF/rhq-serverplugin.xml +++ b/modules/enterprise/server/plugins/yum/src/main/resources/META-INF/rhq-serverplugin.xml @@ -7,8 +7,8 @@ xmlns:c="urn:xmlns:rhq-configuration">
<contentSourceType name="YumSource" - displayName="Yum Repository Content Source" - description="This content source retrieves packages from a local or remote Yum repository." + displayName="Yum Repository Content Provider" + description="This content provider retrieves packages from a local or remote Yum repository." lazyLoad="true" downloadMode="filesystem" apiClass="org.rhq.enterprise.server.plugins.yum.RepoProvider">
commit 4e945b4751b21bf527641e6f6d9edf2656f047d9 Author: Jason Dobies jason.dobies@redhat.com Date: Thu Dec 10 15:37:33 2009 -0500
Renamed source -> provider.
diff --git a/modules/enterprise/server/plugins/url/src/main/resources/META-INF/rhq-serverplugin.xml b/modules/enterprise/server/plugins/url/src/main/resources/META-INF/rhq-serverplugin.xml index b8e67c2..3202151 100644 --- a/modules/enterprise/server/plugins/url/src/main/resources/META-INF/rhq-serverplugin.xml +++ b/modules/enterprise/server/plugins/url/src/main/resources/META-INF/rhq-serverplugin.xml @@ -7,14 +7,14 @@ xmlns:c="urn:xmlns:rhq-configuration">
<contentSourceType name="UrlSource" - displayName="Remote URL Content Source" - description="This content source retrieves packages from a remote system identified by a URL." + displayName="Remote URL Content Provider" + description="This content provider retrieves packages from a remote system identified by a URL." lazyLoad="true" downloadMode="database" apiClass="org.rhq.enterprise.server.plugins.url.UrlProvider">
<configuration> - <c:simple-property name="rootUrl" type="string" required="true" description="The URL that contains all content that is to be served by this content source."/> + <c:simple-property name="rootUrl" type="string" required="true" description="The URL that contains all content that is to be served by this content provider."/> <c:simple-property name="indexFile" type="string" required="true" default="content-index.txt" description="The index file that defines all the content that can be found on the remote server. If this is not a full URL, it is assumed to be relative to the root URL."/>
<c:list-property name="packageTypes" required="true" min="0" @@ -32,14 +32,14 @@ </contentSourceType>
<contentSourceType name="HttpSource" - displayName="HTTP Content Source" - description="This content source retrieves packages from a remote HTTP server, possibly via a proxy." + displayName="HTTP Content Provider" + description="This content provider retrieves packages from a remote HTTP server, possibly via a proxy." lazyLoad="true" downloadMode="database" apiClass="org.rhq.enterprise.server.plugins.url.HttpProvider">
<configuration> - <c:simple-property name="rootUrl" type="string" required="true" description="The HTTP URL that contains all content that is to be served by this content source."/> + <c:simple-property name="rootUrl" type="string" required="true" description="The HTTP URL that contains all content that is to be served by this content provider."/> <c:simple-property name="indexFile" type="string" required="true" default="content-index.txt" description="The index file that defines all the content that can be found on the remote server. If this is not a full URL, it is assumed to be relative to the root URL."/>
<c:list-property name="packageTypes" required="true" min="0"
commit 0fec19734ecada39194cf4bc21d3c0610706b9f6 Author: Jason Dobies jason.dobies@redhat.com Date: Thu Dec 10 15:36:16 2009 -0500
Renamed source -> provider.
diff --git a/modules/enterprise/server/plugins/disk/src/main/resources/META-INF/rhq-serverplugin.xml b/modules/enterprise/server/plugins/disk/src/main/resources/META-INF/rhq-serverplugin.xml index 45b3aa1..5097fa1 100644 --- a/modules/enterprise/server/plugins/disk/src/main/resources/META-INF/rhq-serverplugin.xml +++ b/modules/enterprise/server/plugins/disk/src/main/resources/META-INF/rhq-serverplugin.xml @@ -7,8 +7,8 @@ xmlns:c="urn:xmlns:rhq-configuration">
<contentSourceType name="DiskSource" - displayName="Local Disk Storage Content Source" - description="This content source retrieves packages from a local file system. If deployed in an HA environment, this must be on a distributed file system that all servers can access." + displayName="Local Disk Storage Content Provider" + description="This content provider retrieves packages from a local file system. If deployed in an HA environment, this must be on a distributed file system that all servers can access." lazyLoad="true" downloadMode="never" apiClass="org.rhq.enterprise.server.plugins.disk.DiskSource"> @@ -17,7 +17,7 @@
<c:group name="General"> <c:simple-property name="rootDirectory" type="directory" required="true" - description="The root directory that contains all content that is to be served by this content source. In an HA environment, this must be on a distributed file system that all servers can access."/> + description="The root directory that contains all content that is to be served by this content provider. In an HA environment, this must be on a distributed file system that all servers can access."/> </c:group>
<c:group name="Package Source">
commit 000ec01859f38e90b11cb77935325374b8509e5d Author: Jason Dobies jason.dobies@redhat.com Date: Fri Dec 4 16:20:08 2009 -0500
Added repo source support. Repos will be determined by directories in the root directory (specified in the plugin configuration). I'll add some docs for this in the wiki soon since this will likely help with QA.
diff --git a/modules/enterprise/server/plugins/disk/src/main/java/org/rhq/enterprise/server/plugins/disk/DiskSource.java b/modules/enterprise/server/plugins/disk/src/main/java/org/rhq/enterprise/server/plugins/disk/DiskSource.java index f70bb69..94f1ad3 100644 --- a/modules/enterprise/server/plugins/disk/src/main/java/org/rhq/enterprise/server/plugins/disk/DiskSource.java +++ b/modules/enterprise/server/plugins/disk/src/main/java/org/rhq/enterprise/server/plugins/disk/DiskSource.java @@ -30,6 +30,7 @@ import java.util.Map; import org.rhq.core.domain.configuration.Configuration; import org.rhq.core.domain.configuration.Property; import org.rhq.core.domain.configuration.PropertyMap; +import org.rhq.core.domain.configuration.PropertySimple; import org.rhq.core.util.MessageDigestGenerator; import org.rhq.core.util.file.ContentFileInfo; import org.rhq.core.util.file.ContentFileInfoFactory; @@ -38,6 +39,9 @@ import org.rhq.enterprise.server.plugin.pc.content.ContentProviderPackageDetails import org.rhq.enterprise.server.plugin.pc.content.ContentProviderPackageDetailsKey; import org.rhq.enterprise.server.plugin.pc.content.PackageSource; import org.rhq.enterprise.server.plugin.pc.content.PackageSyncReport; +import org.rhq.enterprise.server.plugin.pc.content.RepoDetails; +import org.rhq.enterprise.server.plugin.pc.content.RepoImportReport; +import org.rhq.enterprise.server.plugin.pc.content.RepoSource;
/** * This is the most basic <i>reference</i> implementation of a content source. It provides primative package @@ -47,7 +51,7 @@ import org.rhq.enterprise.server.plugin.pc.content.PackageSyncReport; * @author jortel * @author John Mazzitelli */ -public class DiskSource implements ContentProvider, PackageSource { +public class DiskSource implements ContentProvider, PackageSource, RepoSource {
/** * The root path (directory) from which to synchronize content. @@ -65,25 +69,28 @@ public class DiskSource implements ContentProvider, PackageSource { */ private Map<String, SupportedPackageType> supportedPackageTypes;
- protected File getRootDirectory() { - return this.rootDirectory; - } - - protected void setRootDirectory(File path) { - this.rootDirectory = path; - this.rootDirectoryAbsolutePath = this.rootDirectory.getAbsolutePath(); - } + /** + * Configuration for this instance of the plugin. + */ + private Configuration configuration;
- protected Map<String, SupportedPackageType> getSupportedPackageTypes() { - return this.supportedPackageTypes; - } + /** + * Indicates if the repo source functionality of this instance is enabled or disabled. + */ + private boolean isRepoSource;
- protected void setSupportedPackageTypes(Map<String, SupportedPackageType> supportedPackageTypes) { - this.supportedPackageTypes = supportedPackageTypes; - } + /** + * Indicates if the package source functionality of this instance is enabled or disabled. + */ + private boolean isPackageSource;
public void initialize(Configuration configuration) throws Exception { - initializePackageTypes(configuration); + this.configuration = configuration; + + isPackageSource = ((PropertySimple) configuration.get("packageSourceEnabled")).getBooleanValue(); + isRepoSource = ((PropertySimple) configuration.get("repoSourceEnabled")).getBooleanValue(); + + initializePackageTypes(); String pathString = configuration.getSimpleValue("rootDirectory", null); setRootDirectory(new File(pathString)); testConnection(); @@ -95,10 +102,27 @@ public class DiskSource implements ContentProvider, PackageSource { this.supportedPackageTypes = null; }
+ public RepoImportReport importRepos() throws Exception { + RepoImportReport report = new RepoImportReport(); + + if (!isRepoSource) { + return report; + } + + File directory = getRootDirectory(); + generateRepoDetails(report, directory, null); + + return report; + } + public void synchronizePackages(String repoName, PackageSyncReport report, Collection<ContentProviderPackageDetails> existingPackages) throws Exception {
+ if (!isPackageSource) { + return; + } + // put all existing packages in a "to be deleted" list. As we sync, we will remove // packages from this list that still exist on the file system. Any leftover in the list // are packages that no longer exist on the file system and should be removed from the server inventory. @@ -107,7 +131,7 @@ public class DiskSource implements ContentProvider, PackageSource {
// sync now long before = System.currentTimeMillis(); - syncPackages(report, deletedPackages, getRootDirectory()); + syncPackages(report, repoName, deletedPackages, getRootDirectory()); long elapsed = System.currentTimeMillis() - before;
// if there are packages that weren't found on the file system, tell server to remove them from inventory @@ -116,8 +140,6 @@ public class DiskSource implements ContentProvider, PackageSource { }
report.setSummary("Synchronized [" + getRootDirectory() + "]. Elapsed time=[" + elapsed + "] ms"); - - return; }
public void testConnection() throws Exception { @@ -134,52 +156,73 @@ public class DiskSource implements ContentProvider, PackageSource { if (!root.isDirectory()) { throw new Exception("Disk source [" + root + "] is not a directory"); } - - return; // good }
public InputStream getInputStream(String location) throws Exception { return new FileInputStream(new File(getRootDirectory(), location)); }
+ protected File getRootDirectory() { + return this.rootDirectory; + } + + protected void setRootDirectory(File path) { + this.rootDirectory = path; + this.rootDirectoryAbsolutePath = this.rootDirectory.getAbsolutePath(); + } + + protected Map<String, SupportedPackageType> getSupportedPackageTypes() { + return this.supportedPackageTypes; + } + + protected void setSupportedPackageTypes(Map<String, SupportedPackageType> supportedPackageTypes) { + this.supportedPackageTypes = supportedPackageTypes; + } + /** * Recursive function that drills down into subdirectories and builds up the report * of packages for all files found. As files are found, their associated packages * are removed from <code>packages</code> if they exist - leaving only packages * remaining that do not exist on the file system. - * + * * @param report the report that we are building up * @param packages existing packages not yet found on the file system but exist in server inventory * @param directory the directory (and its subdirectories) to scan * @throws Exception if the sync fails */ - protected void syncPackages(PackageSyncReport report, List<ContentProviderPackageDetails> packages, File directory) + protected void syncPackages(PackageSyncReport report, String repoName, + List<ContentProviderPackageDetails> packages, File directory) throws Exception {
for (File file : directory.listFiles()) { if (file.isDirectory()) { - // process the directory recursively - syncPackages(report, packages, file); - } else { - // process the file - ContentProviderPackageDetails details = createPackage(file); - if (details != null) { - ContentProviderPackageDetails existing = findPackage(packages, details); - if (existing == null) { - report.addNewPackage(details); - } else { - packages.remove(existing); // it still exists, remove it from our list - if (details.getFileCreatedDate().compareTo(existing.getFileCreatedDate()) > 0) { - report.addUpdatedPackage(details); + + if (file.getName().equals(repoName)) { + + for (File filePackage : file.listFiles()) { + ContentProviderPackageDetails details = createPackage(filePackage); + if (details != null) { + ContentProviderPackageDetails existing = findPackage(packages, details); + if (existing == null) { + report.addNewPackage(details); + } else { + packages.remove(existing); // it still exists, remove it from our list + if (details.getFileCreatedDate().compareTo(existing.getFileCreatedDate()) > 0) { + report.addUpdatedPackage(details); + } + } + } else { + // file does not match any filter and is therefore an unknown type - ignore it } } - } else { - // file does not match any filter and is therefore an unknown type - ignore it + + break; } + + // Otherwise, keep searching recursively for a directory with the same name + syncPackages(report, repoName, packages, file); } } - - return; }
protected ContentProviderPackageDetails createPackage(File file) throws Exception { @@ -238,16 +281,16 @@ public class DiskSource implements ContentProvider, PackageSource { return relativePath; }
- protected void initializePackageTypes(Configuration config) { + protected void initializePackageTypes() {
Map<String, SupportedPackageType> supportedPackageTypes = new HashMap<String, SupportedPackageType>();
- /* TODO: THE UI CURRENTLY DOES NOT SUPPORT ADDING/EDITING LIST OF MAPS, SO WE CAN ONLY SUPPORT ONE PACKAGE TYPE + /* TODO: THE UI CURRENTLY DOES NOT SUPPORT ADDING/EDITING LIST OF MAPS, SO WE CAN ONLY SUPPORT ONE PACKAGE TYPE * SO FOR NOW, JUST SUPPORT A FLAT SET OF SIMPLE PROPS - WE WILL RE-ENABLE THIS CODE LATER */ if (false) { // All of these properties must exist, any nulls should trigger runtime exceptions which is what we want - // because if the configuration is bad, this content source should not initialize. - List<Property> packageTypesList = config.getList("packageTypes").getList(); + // because if the configuration is bad, this content source should not initialize. + List<Property> packageTypesList = configuration.getList("packageTypes").getList(); for (Property property : packageTypesList) { PropertyMap pkgType = (PropertyMap) property; SupportedPackageType supportedPackageType = new SupportedPackageType(); @@ -262,11 +305,11 @@ public class DiskSource implements ContentProvider, PackageSource { } else { /* THIS CODE IS THE FLAT SET OF PROPS - USE UNTIL WE CAN EDIT MAPS AT WHICH TIME DELETE THIS ELSE CLAUSE */ SupportedPackageType supportedPackageType = new SupportedPackageType(); - supportedPackageType.packageTypeName = config.getSimpleValue("packageTypeName", null); - supportedPackageType.architectureName = config.getSimpleValue("architectureName", null); - supportedPackageType.resourceTypeName = config.getSimpleValue("resourceTypeName", null); - supportedPackageType.resourceTypePluginName = config.getSimpleValue("resourceTypePluginName", null); - String filenameFilter = config.getSimpleValue("filenameFilter", null); + supportedPackageType.packageTypeName = configuration.getSimpleValue("packageTypeName", null); + supportedPackageType.architectureName = configuration.getSimpleValue("architectureName", null); + supportedPackageType.resourceTypeName = configuration.getSimpleValue("resourceTypeName", null); + supportedPackageType.resourceTypePluginName = configuration.getSimpleValue("resourceTypePluginName", null); + String filenameFilter = configuration.getSimpleValue("filenameFilter", null); supportedPackageTypes.put(filenameFilter, supportedPackageType); }
@@ -284,6 +327,22 @@ public class DiskSource implements ContentProvider, PackageSource { return null; // the file doesn't match any known types for this content source }
+ protected void generateRepoDetails(RepoImportReport report, File base, String parentName) { + + for (File file : base.listFiles()) { + + if (file.isDirectory()) { + + // Add this as a new repo + RepoDetails repo = new RepoDetails(file.getName(), parentName); + report.addRepo(repo); + + // Check to see if there are any child repos + generateRepoDetails(report, file, repo.getName()); + } + } + } + protected class SupportedPackageType { public String packageTypeName; public String architectureName; diff --git a/modules/enterprise/server/plugins/disk/src/main/resources/META-INF/rhq-serverplugin.xml b/modules/enterprise/server/plugins/disk/src/main/resources/META-INF/rhq-serverplugin.xml index 9d2b458..45b3aa1 100644 --- a/modules/enterprise/server/plugins/disk/src/main/resources/META-INF/rhq-serverplugin.xml +++ b/modules/enterprise/server/plugins/disk/src/main/resources/META-INF/rhq-serverplugin.xml @@ -6,30 +6,42 @@ xmlns="urn:xmlns:rhq-serverplugin.content" xmlns:c="urn:xmlns:rhq-configuration">
- <contentSourceType name="DiskSource" - displayName="Local Disk Storage Content Source" - description="This content source retrieves packages from a local file system. If deployed in an HA environment, this must be on a distributed file system that all servers can access." - lazyLoad="true" - downloadMode="never" - apiClass="org.rhq.enterprise.server.plugins.disk.DiskSource"> - - <configuration> - <c:simple-property name="rootDirectory" type="directory" required="true" description="The root directory that contains all content that is to be served by this content source. In an HA environment, this must be on a distributed file system that all servers can access."/> - <!-- would like to be able to define multiple package types, but the UI doesn't allow editing maps yet - <c:list-property name="packageTypes" required="true" description="Defines the different package types that can be found on this disk content source"> - <c:map-property name="packageType"> - --> - <c:simple-property name="filenameFilter" required="true" summary="true" default=".*" description="A regular expression that identifies a file of this package type (e.g. '.*.jar', '.*/i686/.*.rpm$')"/> - <c:simple-property name="packageTypeName" required="true" summary="true" description="The name that identifies the kind of package this type represents (e.g. 'ear', 'rpm')"/> - <c:simple-property name="architectureName" required="true" summary="true" default="noarch" description="The specific hardware architecture this type of package can be deployed on. If there is no specific architecture required, use 'noarch'. (e.g. 'i686', 'amd64')"/> - <c:simple-property name="resourceTypeName" required="true" summary="true" description="The name of the resource type on which this package can be deployed. This is the resource type name as defined in the agent plugin. (e.g. 'Linux', 'JBossAS Server')"/> - <c:simple-property name="resourceTypePluginName" required="true" summary="true" description="The name of the plugin that defined the resource type. (e.g. 'Platform', 'JBossAS')"/> - <!-- - </c:map-property> - </c:list-property> - --> - </configuration> - - </contentSourceType> + <contentSourceType name="DiskSource" + displayName="Local Disk Storage Content Source" + description="This content source retrieves packages from a local file system. If deployed in an HA environment, this must be on a distributed file system that all servers can access." + lazyLoad="true" + downloadMode="never" + apiClass="org.rhq.enterprise.server.plugins.disk.DiskSource"> + + <configuration> + + <c:group name="General"> + <c:simple-property name="rootDirectory" type="directory" required="true" + description="The root directory that contains all content that is to be served by this content source. In an HA environment, this must be on a distributed file system that all servers can access."/> + </c:group> + + <c:group name="Package Source"> + <c:simple-property name="packageSourceEnabled" required="true" summary="true" default="true" + type="boolean" description="Indicates if this instance of the plugin should act as a package source"/> + <c:simple-property name="filenameFilter" required="true" summary="true" default=".*" + description="A regular expression that identifies a file of this package type (e.g. '.*.jar', '.*/i686/.*.rpm$')"/> + <c:simple-property name="packageTypeName" required="true" summary="true" + description="The name that identifies the kind of package this type represents (e.g. 'ear', 'rpm')"/> + <c:simple-property name="architectureName" required="true" summary="true" default="noarch" + description="The specific hardware architecture this type of package can be deployed on. If there is no specific architecture required, use 'noarch'. (e.g. 'i686', 'amd64')"/> + <c:simple-property name="resourceTypeName" required="true" summary="true" + description="The name of the resource type on which this package can be deployed. This is the resource type name as defined in the agent plugin. (e.g. 'Linux', 'JBossAS Server')"/> + <c:simple-property name="resourceTypePluginName" required="true" summary="true" + description="The name of the plugin that defined the resource type. (e.g. 'Platform', 'JBossAS')"/> + </c:group> + + <c:group name="Repo Source"> + <c:simple-property name="repoSourceEnabled" required="true" summary="true" default="true" + type="boolean" description="Indicates if this instance of the plugin should act as a repo source"/> + </c:group> + + </configuration> + + </contentSourceType>
</content-plugin> \ No newline at end of file
commit 70d7800c56eff73de20a5171f049d372ac9102f1 Merge: 3663681... 50c100c... Author: John Sanda jsanda@redhat.com Date: Thu Dec 10 11:51:05 2009 -0500
Merge branch 'master' into raw-config
Conflicts: modules/plugins/JBossOSGi/jopr-jbossOsgi-plugin.iml
commit c96ca25c9cdb732370678ac065e067e9b06c095c Author: John Mazzitelli mazz@redhat.com Date: Thu Dec 10 11:14:08 2009 -0500
add sorting to the plugin ui - hide the purge button unless you are viewing undeployed plugins
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/plugin/plugin-list.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/plugin/plugin-list.xhtml index 59ccecd..15b3601 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/plugin/plugin-list.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/plugin/plugin-list.xhtml @@ -72,8 +72,7 @@ <h:outputText value="#{agentPlugin.id}"/> </rich:column>
- - rich:column + <rich:column sortBy="#{agentPlugin.displayName}"> <f:facet name="header"> <h:outputText styleClass="headerText" value="Name"/> </f:facet> @@ -86,8 +85,7 @@
</rich:column>
- - rich:column + <rich:column sortBy="#{agentPlugin.description}"> <f:facet name="header"> <h:outputText styleClass="headerText" value="Description"/> </f:facet> @@ -95,7 +93,7 @@ <h:outputText value="#{agentPlugin.description}"/> </rich:column>
- rich:column + <rich:column sortBy="#{agentPlugin.mtime}"> <f:facet name="header"> <h:outputText styleClass="headerText" value="Last Update"/> </f:facet> @@ -105,7 +103,6 @@ </h:outputText> </rich:column>
- rich:column <f:facet name="header"> <h:outputText styleClass="headerText" value="Enabled"/> @@ -160,8 +157,7 @@ <h:outputText value="#{serverPlugin.id}"/> </rich:column>
- - rich:column + <rich:column sortBy="#{serverPlugin.displayName}"> <f:facet name="header"> <h:outputText styleClass="headerText" value="Name"/> </f:facet> @@ -175,8 +171,7 @@
</rich:column>
- - rich:column + <rich:column sortBy="#{serverPlugin.description}"> <f:facet name="header"> <h:outputText styleClass="headerText" value="Description"/> </f:facet> @@ -184,7 +179,7 @@ <h:outputText value="#{serverPlugin.description}"/> </rich:column>
- rich:column + <rich:column sortBy="#{serverPlugin.mtime}"> <f:facet name="header"> <h:outputText styleClass="headerText" value="Last Update"/> </f:facet> @@ -195,7 +190,7 @@ </rich:column>
- rich:column + <rich:column sortBy="#{serverPlugin.enabled}"> <f:facet name="header"> <h:outputText styleClass="headerText" value="Enabled"/> </f:facet> @@ -204,7 +199,7 @@ <h:graphicImage value="/images/icons/availability_red_16.png" rendered="#{!serverPlugin.enabled}"/> </rich:column>
- <rich:column rendered="#{InstalledPluginsSessionUIBean.showAllServerPlugins}"> + <rich:column sortBy="#{serverPlugin.status}" rendered="#{InstalledPluginsSessionUIBean.showAllServerPlugins}"> <f:facet name="header"> <h:outputText styleClass="headerText" value="Deployed"/> </f:facet> @@ -226,6 +221,7 @@ value="UNDEPLOY" target="selectedPlugin" styleClass="on-pager-button buttonsmall"> </onc:selectCommandButton> <onc:selectCommandButton action="#{InstalledPluginsUIBean.purgeServerPlugins}" + rendered="#{InstalledPluginsSessionUIBean.showAllServerPlugins}" value="PURGE" target="selectedPlugin" styleClass="on-pager-button buttonsmall"> </onc:selectCommandButton> </rich:column>
commit 50c100c622a4ed0938732a7ff3dd24c453b426ce Author: John Mazzitelli mazz@redhat.com Date: Wed Dec 9 23:45:22 2009 -0500
fix hot-deployment bugs so we can upload and enable plugisn without recycling the master PC
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/AbstractJobWrapper.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/AbstractJobWrapper.java index 4493a2d..24a4572 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/AbstractJobWrapper.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/AbstractJobWrapper.java @@ -33,6 +33,8 @@ import org.rhq.core.util.exception.ThrowableUtil; import org.rhq.enterprise.server.util.LookupUtil; import org.rhq.enterprise.server.xmlschema.AbstractScheduleType; import org.rhq.enterprise.server.xmlschema.ScheduledJobDefinition; +import org.rhq.enterprise.server.xmlschema.ServerPluginDescriptorMetadataParser; +import org.rhq.enterprise.server.xmlschema.generated.serverplugin.ServerPluginDescriptorType;
/** * The superclass to the concurrent and stateful job wrappers. @@ -189,6 +191,8 @@ abstract class AbstractJobWrapper implements Job { } } else { try { + ServerPluginDescriptorType descriptor = pluginEnv.getPluginDescriptor(); + jobClass = ServerPluginDescriptorMetadataParser.getFullyQualifiedClassName(descriptor, jobClass); pluginJobObject = pluginManager.instantiatePluginClass(pluginEnv, jobClass); } catch (Throwable t) { // invalid class - we need to unschedule this, do not refire since it will never work diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/AbstractTypeServerPluginContainer.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/AbstractTypeServerPluginContainer.java index 5c80ce3..b5572be 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/AbstractTypeServerPluginContainer.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/AbstractTypeServerPluginContainer.java @@ -173,7 +173,7 @@ public abstract class AbstractTypeServerPluginContainer { */ public synchronized void unloadPlugin(PluginKey pluginKey) throws Exception { if (this.pluginManager != null) { - this.pluginManager.unloadPlugin(pluginKey.getPluginName()); + this.pluginManager.unloadPlugin(pluginKey.getPluginName(), false); } else { throw new Exception("Cannot unload a plugin; plugin container has been shutdown"); } diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ClassLoaderManager.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ClassLoaderManager.java index ae3bbe4..d62465f 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ClassLoaderManager.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ClassLoaderManager.java @@ -83,9 +83,7 @@ public class ClassLoaderManager {
this.pluginKeysUrls = new HashMap<PluginKey, URL>(plugins.size()); for (Map.Entry<URL, ? extends ServerPluginDescriptorType> entry : plugins.entrySet()) { - ServerPluginType pluginType = new ServerPluginType(entry.getValue()); - PluginKey pluginKey = PluginKey.createServerPluginKey(pluginType.stringify(), entry.getValue().getName()); - this.pluginKeysUrls.put(pluginKey, entry.getKey()); + loadPlugin(entry.getKey(), entry.getValue()); }
return; @@ -108,6 +106,37 @@ public class ClassLoaderManager { return; }
+ /** + * Hot-deploys a plugin into this classloader manager. + * + * @param pluginUrl location of the plugin jar file + * @param descriptor the plugin descriptor + */ + public synchronized void loadPlugin(URL pluginUrl, ServerPluginDescriptorType descriptor) { + ServerPluginType pluginType = new ServerPluginType(descriptor); + PluginKey pluginKey = PluginKey.createServerPluginKey(pluginType.stringify(), descriptor.getName()); + this.pluginKeysUrls.put(pluginKey, pluginUrl); + } + + /** + * Unloads the plugin identified with the current key from this classloader manager and destroys + * that plugin's classloader, if one existed. + * + * @param pluginKey identifies the plugin to be unloaded + */ + public synchronized void unloadPlugin(PluginKey pluginKey) { + this.pluginKeysUrls.remove(pluginKey); + ClassLoader unloadedCL = this.serverPluginClassLoaders.remove(pluginKey); + if (unloadedCL instanceof ServerPluginClassLoader) { + try { + ((ServerPluginClassLoader) unloadedCL).destroy(); + } catch (Exception e) { + log.warn("Failed to destroy classloader [" + unloadedCL + "] for plugin [" + pluginKey + "]", e); + } + } + return; + } + @Override public String toString() { Set<ClassLoader> classLoaders; @@ -216,6 +245,7 @@ public class ClassLoaderManager { } } else { // this is mainly to support tests + log.info("No jar URL, this should only happen in tests! If this is not a test, this is probably a bug"); classLoader = parentClassLoader; }
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/MasterServerPluginContainer.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/MasterServerPluginContainer.java index a59d13b..382432e 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/MasterServerPluginContainer.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/MasterServerPluginContainer.java @@ -21,7 +21,6 @@ package org.rhq.enterprise.server.plugin.pc; import java.io.File; import java.net.URL; import java.util.ArrayList; -import java.util.Collection; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -225,6 +224,7 @@ public class MasterServerPluginContainer { ServerPluginDescriptorType descriptor = ServerPluginDescriptorUtil.loadPluginDescriptorFromUrl(pluginUrl); ServerPluginType pluginType = new ServerPluginType(descriptor); PluginKey pluginKey = PluginKey.createServerPluginKey(pluginType.stringify(), descriptor.getName()); + this.classLoaderManager.loadPlugin(pluginUrl, descriptor); ClassLoader classLoader = this.classLoaderManager.obtainServerPluginClassLoader(pluginKey); log.debug("Loading server plugin [" + pluginKey + "] from [" + pluginUrl + "] into its plugin container"); try { diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ServerPluginManager.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ServerPluginManager.java index 29726f9..acef4cf 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ServerPluginManager.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ServerPluginManager.java @@ -31,6 +31,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory;
import org.rhq.core.domain.configuration.Configuration; +import org.rhq.core.domain.plugin.PluginKey; import org.rhq.core.domain.plugin.ServerPlugin; import org.rhq.enterprise.server.plugin.ServerPluginsLocal; import org.rhq.enterprise.server.util.LookupUtil; @@ -264,8 +265,8 @@ public class ServerPluginManager {
/** * Informs the plugin manager that a plugin with the given name is to be unloaded. - * Once this method returns, the plugin's components are should no longer be created or used. - * + * The component's shutdown method will be called. + * * @param pluginName the name of the plugin to be unloaded * * @throws Exception if the plugin manager cannot unload the plugin @@ -305,6 +306,38 @@ public class ServerPluginManager { }
/** + * Informs the plugin manager that a plugin with the given name is to be unloaded. + * Once this method returns, the plugin's components should not be created or used. + * + * If <code>keepClassLoader</code> is <code>true</code>, this is the same as + * {@link #unloadPlugin(String)}. + * + * You want to keep the classloader if you are only temporarily unloading the plugin, and + * will load it back soon. + * + * Subclasses of this plugin manager class will normally not override this method; instead, + * they will typically want to override {@link #unloadPlugin(String)}. + * + * @param pluginName the name of the plugin to be unloaded + * @param keepClassLoader if <code>true</code> the classloader is not destroyed + * @throws Exception if the plugin manager cannot unload the plugin + */ + protected void unloadPlugin(String pluginName, boolean keepClassLoader) throws Exception { + try { + unloadPlugin(pluginName); + } finally { + if (!keepClassLoader) { + String pluginType = getParentPluginContainer().getSupportedServerPluginType().stringify(); + PluginKey pluginKey = PluginKey.createServerPluginKey(pluginType, pluginName); + MasterServerPluginContainer master = this.parentPluginContainer.getMasterServerPluginContainer(); + master.getClassLoaderManager().unloadPlugin(pluginKey); + } + } + + return; + } + + /** * This will reload a plugin allowing you to enable or disable it. * This will {@link #startPlugin(String) start the plugin component} if you enable it. * This will {@link #stopPlugin(String) stop the plugin component} if you disable it. @@ -331,7 +364,7 @@ public class ServerPluginManager { throw new IllegalArgumentException("Server plugin [" + pluginName + "] was never loaded, cannot enable it"); } stopPlugin(pluginName); // under normal circumstances, we should not need to do this, but just in case the plugin is somehow already started, stop it - unloadPlugin(pluginName); // unloading it will clean up old data and force the plugin context to reload if we later re-enable it + unloadPlugin(pluginName, true); // unloading it will clean up old data and force the plugin context to reload env = rebuildServerPluginEnvironment(env); try { // reload it in the enabled state. @@ -352,7 +385,7 @@ public class ServerPluginManager { throw new IllegalArgumentException("Server plugin [" + pluginName + "] was never loaded, cannot disable it"); } stopPlugin(pluginName); - unloadPlugin(pluginName); // unloading it will clean up old data and force the plugin context to reload if we later re-enable it + unloadPlugin(pluginName, true); // unloading it will clean up old data and force the plugin context to reload if we later re-enable it env = rebuildServerPluginEnvironment(env); loadPlugin(env, false); // re-load it in the disabled state return; diff --git a/modules/enterprise/server/xml-schemas/src/main/java/org/rhq/enterprise/server/xmlschema/ServerPluginDescriptorMetadataParser.java b/modules/enterprise/server/xml-schemas/src/main/java/org/rhq/enterprise/server/xmlschema/ServerPluginDescriptorMetadataParser.java index 4c16fee..637c609 100644 --- a/modules/enterprise/server/xml-schemas/src/main/java/org/rhq/enterprise/server/xmlschema/ServerPluginDescriptorMetadataParser.java +++ b/modules/enterprise/server/xml-schemas/src/main/java/org/rhq/enterprise/server/xmlschema/ServerPluginDescriptorMetadataParser.java @@ -76,11 +76,35 @@ public class ServerPluginDescriptorMetadataParser { throw new IllegalArgumentException("Missing plugin component classname for plugin " + descriptor.getName()); }
- String pkg = descriptor.getPackage(); - if ((className.indexOf('.') == -1) && (pkg != null)) { - className = pkg + '.' + className; - } + className = getFullyQualifiedClassName(descriptor, className); + + return className; + }
+ /** + * Given a plugn descriptor that may or may not have defined a {@link ServerPluginDescriptorType#getPackage() package name}, + * this converts the given class name to a fully qualified class name. + * + * If the descriptor does not define a package name, this method does nothing and returns <code>className</code> unchanged. + * + * If <code>className</code> contains at least one "." character, it is assumed to be already fully qualified and so it + * will be returned unchanged. + * + * If <code>className</code> has no "." characters, and the descriptor defines a package name, that package name + * will prefix the given class name and will form the fully qualified class name that is returned. + * + * @param descriptor a plugin descriptor that may or may not define a package name + * @param className a classname that may or may not be fully qualified + * @return the fully qualified class name or <code>null</code> if <code>className</code> is <code>null</code> + */ + public static String getFullyQualifiedClassName(ServerPluginDescriptorType descriptor, String className) { + + if (className != null) { + String pkg = (descriptor != null) ? descriptor.getPackage() : null; + if ((className.indexOf('.') == -1) && (pkg != null)) { + className = pkg + '.' + className; + } + } return className; }
commit 539f8d200cd707af27632e2dde547d5908492cf6 Merge: 96a82c7... 0206871... Author: Partha Aji paji@redhat.com Date: Wed Dec 9 15:24:59 2009 -0500
Merge branch 'master' into dumb
commit 112dbac1938cc6cc8cc9acf64f43655a65357cd9 Merge: 94d9e41... 0206871... Author: Heiko W. Rupp pilhuhn@fedorapeople.org Date: Wed Dec 9 21:14:39 2009 +0100
Merge branch 'master' into alertPlugin
commit 020687190fd6eba1b0c0f0da719d487b2c03b537 Merge: 114a890... 4f84d22... Author: Heiko W. Rupp pilhuhn@fedorapeople.org Date: Wed Dec 9 20:54:19 2009 +0100
Merge branch 'master' of ssh://git.fedorahosted.org/git/rhq/rhq
commit 114a89098cbc30c72dbab6a982499e4edef0cab5 Author: Heiko W. Rupp pilhuhn@fedorapeople.org Date: Wed Dec 9 20:53:20 2009 +0100
Small improvements in area of logging. Also don't reply to each message in the channel.
diff --git a/modules/enterprise/server/plugins/alert-irc/src/main/java/org/rhq/enterprise/server/plugins/alertIrc/IrcAlertComponent.java b/modules/enterprise/server/plugins/alert-irc/src/main/java/org/rhq/enterprise/server/plugins/alertIrc/IrcAlertComponent.java index e6bf730..f8716d6 100644 --- a/modules/enterprise/server/plugins/alert-irc/src/main/java/org/rhq/enterprise/server/plugins/alertIrc/IrcAlertComponent.java +++ b/modules/enterprise/server/plugins/alert-irc/src/main/java/org/rhq/enterprise/server/plugins/alertIrc/IrcAlertComponent.java @@ -71,8 +71,9 @@ public class IrcAlertComponent implements ServerPluginComponent {
try { this.ircBot.connect(server, port); + log.info("Connected to server " + server + ":" + port); } catch (Exception e) { - log.error("Error joining IRC", e); + log.error("Error joining IRC: " + e.getMessage());
return; } @@ -150,6 +151,9 @@ public class IrcAlertComponent implements ServerPluginComponent { public void onMessage(String channel, String sender, String login, String hostname, String message) {
+ if (!message.contains(nick)) + return; + if (this.response != null) { if (channel != null && channel.length() > 0) { sendMessage(channel, sender + ": " + this.response); diff --git a/modules/enterprise/server/plugins/alert-irc/src/main/java/org/rhq/enterprise/server/plugins/alertIrc/IrcSender.java b/modules/enterprise/server/plugins/alert-irc/src/main/java/org/rhq/enterprise/server/plugins/alertIrc/IrcSender.java index 34db27e..8cbd313 100644 --- a/modules/enterprise/server/plugins/alert-irc/src/main/java/org/rhq/enterprise/server/plugins/alertIrc/IrcSender.java +++ b/modules/enterprise/server/plugins/alert-irc/src/main/java/org/rhq/enterprise/server/plugins/alertIrc/IrcSender.java @@ -41,13 +41,15 @@ public class IrcSender extends AlertSender<IrcAlertComponent> { public SenderResult send(Alert alert) { SenderResult result; String channel = this.alertParameters.getSimpleValue("channel", null); + String server = preferences.getSimpleValue("server","-not set-"); + String chan = "irc://" + server + "/" + channel;
try { this.pluginComponent.sendIrcMessage(channel, getIrcMessage(alert)); - result = new SenderResult(ResultState.SUCCESS, "IRC Alert sent."); + result = new SenderResult(ResultState.SUCCESS, "IRC Alert sent to channel [" + chan + "]."); } catch (IllegalStateException e) { - log.error(e.getMessage(), e); - result = new SenderResult(ResultState.FAILURE, "IRC Alert failed!"); + log.error(e.getMessage()); + result = new SenderResult(ResultState.FAILURE, "IRC Alert to [" + chan + "] failed! " + e.getMessage()); }
return result; @@ -62,6 +64,8 @@ public class IrcSender extends AlertSender<IrcAlertComponent> { b.append(alert.getAlertDefinition().getResource().getName()); b.append("): "); b.append(alertManager.prettyPrintAlertURL(alert)); + b.append("\n"); + b.append(alertManager.prettyPrintAlertConditions(alert));
return b.toString(); }
commit 96a82c7ae46062101ea86afa00a412c6aa0c3abf Merge: 7991598... 4f84d22... Author: Partha Aji paji@redhat.com Date: Wed Dec 9 13:41:44 2009 -0500
Fixed merge conflicts
diff --cc modules/enterprise/server/plugins/pom.xml index 2c6472a,d1390e4..1e6a3d7 --- a/modules/enterprise/server/plugins/pom.xml +++ b/modules/enterprise/server/plugins/pom.xml @@@ -41,8 -39,8 +41,9 @@@ <module>yum</module> <module>url</module> <module>rhnhosted</module> + <module>perspectives/core</module> <module>alert-email</module> + <module>alert-irc</module> <module>alert-mobicents</module> <module>alert-microblog</module> <module>alert-roles</module>
commit 4c42a3cfd26575ff207577045e261f3fb8db4bed Author: Heiko W. Rupp pilhuhn@fedorapeople.org Date: Wed Dec 9 19:12:54 2009 +0100
Better handling of invalid input
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/AlertSenderPluginManager.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/AlertSenderPluginManager.java index 68b4241..e29e9b5 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/AlertSenderPluginManager.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/AlertSenderPluginManager.java @@ -163,8 +163,13 @@ public class AlertSenderPluginManager extends ServerPluginManager { */ public AlertSender getAlertSenderForNotification(AlertNotification notification) {
- String className = pluginClassByName.get(notification.getSenderName()); - ServerPluginEnvironment env = pluginEnvByName.get(notification.getSenderName()); + String senderName = notification.getSenderName(); + String className = pluginClassByName.get(senderName); + if (className==null) { + log.error("getAlertSender: No pluginClass found for sender: " + senderName); + return null; + } + ServerPluginEnvironment env = pluginEnvByName.get(senderName); Class clazz; try { clazz = Class.forName(className,true,env.getPluginClassLoader());
commit 4f84d2261465ba5b97b1c4ca127722791232107c Author: John Mazzitelli mazz@redhat.com Date: Wed Dec 9 12:18:01 2009 -0500
remove apt plugin source from eclise project
diff --git a/.classpath b/.classpath index c62026e..be48500 100644 --- a/.classpath +++ b/.classpath @@ -93,11 +93,9 @@ <classpathentry kind="src" path="modules/plugins/cron/src/main/java"/> <classpathentry kind="src" path="modules/plugins/hudson/src/main/java"/> <classpathentry kind="src" path="modules/plugins/platform/src/test/java"/> - <classpathentry kind="src" path="modules/plugins/apt/src/main/java"/> - <classpathentry kind="src" path="modules/plugins/apt/src/test/java"/> <classpathentry kind="src" path="modules/plugins/hosts/src/main/java"/> <classpathentry kind="src" path="modules/plugins/hosts/src/test/java"/> - <classpathentry kind="src" path="modules/plugins/virt/src/main/java"/> + <classpathentry kind="src" path="modules/plugins/virt/src/main/java"/> <classpathentry kind="src" path="modules/plugins/aliases/src/main/java"/> <classpathentry kind="src" path="modules/plugins/aliases/src/test/java"/> <classpathentry kind="src" path="modules/plugins/snmptrapd/src/main/java"/>
commit 6dac97c6bd83b481f67c62bbecd6ec0321dc5343 Merge: 47b1f89... 4d4d44e... Author: John Mazzitelli mazz@redhat.com Date: Wed Dec 9 11:30:44 2009 -0500
merged pc into master. fixed conflict in ServerPluginsLocal.java
diff --cc modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsLocal.java index f4bbb7b,7951af5..90bed89 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsLocal.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsLocal.java @@@ -147,15 -147,15 +147,15 @@@ public interface ServerPluginsLocal List<PluginKey> purgeServerPlugins(Subject subject, List<Integer> pluginIds) throws Exception;
/** - * Turns on or off the enabled flag in the database but does NOT restart the server plugin container. + * Turns on or off the enabled flag in the database but does NOT restart the server plugin. * This has "requires new" semantics, so the results are committed immediately upon return. - * + * * @param subject user making the request - * @param pluginIds the plugins to be enabled - * @param enabled the value of the enabled flag for the plugins - * @throws if failed to update a plugin + * @param pluginId the plugin to be enabled + * @param enabled the value of the enabled flag for the plugin + * @throws if failed to update the plugin */ - void setServerPluginEnabledFlag(Subject subject, List<Integer> pluginIds, boolean enabled) throws Exception; + void setServerPluginEnabledFlag(Subject subject, int pluginId, boolean enabled) throws Exception;
/** * Sets the status flag in the database but does NOT restart the server plugin container.
commit 47b1f89bc187679de4b23ce5b0393d8ebaab1730 Author: Jason Dobies jason.dobies@redhat.com Date: Wed Dec 9 10:53:51 2009 -0500
Moved apt plugin to etc, it's not supported enough to treat as a formal plugin.
diff --git a/etc/apt/pom.xml b/etc/apt/pom.xml new file mode 100644 index 0000000..47da3e5 --- /dev/null +++ b/etc/apt/pom.xml @@ -0,0 +1,199 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.rhq</groupId> + <artifactId>rhq-plugins-parent</artifactId> + <version>1.4.0-SNAPSHOT</version> + </parent> + + <groupId>org.rhq</groupId> + <artifactId>rhq-apt-plugin</artifactId> + <packaging>jar</packaging> + + <name>RHQ Apt Plugin</name> + <description>A plugin for managing the apt based features</description> + + <scm> + <connection>scm:git:ssh://git.fedorahosted.org/git/rhq.git/modules/plugins/apt</connection> + <developerConnection>scm:git:ssh://git.fedorahosted.org/git/rhq.git/modules/plugins/apt</developerConnection> + </scm> + + <properties> + <scm.module.path>modules/plugins/apt/</scm.module.path> + </properties> + + <dependencies> + + <dependency> + <groupId>net.augeas</groupId> + <artifactId>augeas</artifactId> + <version>0.0.1</version> + </dependency> + + <dependency> + <groupId>com.sun.jna</groupId> + <artifactId>jna</artifactId> + <version>3.0.1</version> + </dependency> + + </dependencies> + + <profiles> + <profile> + <id>integration-tests</id> + <activation> + <property> + <name>maven.test.skip</name> + <value>!true</value> + </property> + </activation> + + <build> + <plugins> + <plugin> + <artifactId>maven-antrun-plugin</artifactId> + <executions> + <execution> + <phase>pre-integration-test</phase> + <configuration> + <tasks> + <echo>Setting up plugin dependencies for ${project.artifactId}-${project.version}.jar... + </echo> + <property name="settings.localRepository" location="${user.home}/.m2/repository" /> + <mkdir dir="target/itest" /> + <mkdir dir="target/itest/plugins" /> + <mkdir dir="target/itest/lib" /> + <copy toDir="target/itest/plugins" flatten="true"> + <fileset dir="${settings.localRepository}/"> + <include name="org/rhq/rhq-platform-plugin/${project.version}/rhq-platform-plugin-${project.version}.jar" /> + </fileset> + <fileset dir="${project.build.directory}"> + <include name="${project.artifactId}-${project.version}.jar" /> + </fileset> + </copy> + <unzip dest="target/itest/lib"> + <fileset dir="${settings.localRepository}/org/hyperic/sigar-dist/${sigar.version}" includes="*.zip" /> + <patternset> + <include name="**/lib/sigar.jar" /> + <include name="**/lib/bcel*.jar" /> + <include name="**/lib/*.so" /> + <include name="**/lib/*.sl" /> + <include name="**/lib/*.dll" /> + <include name="**/lib/*.dylib" /> + </patternset> + </unzip> + <move todir="target/itest/lib" flatten="true"> + <fileset dir="target/itest/lib"> + <include name="**/lib/*" /> + </fileset> + </move> + <delete dir="target/itest/lib/hyperic-sigar-${sigar.version}" /> + </tasks> + </configuration> + <goals> + <goal>run</goal> + </goals> + </execution> + </executions> + </plugin> + + <!-- Integration testing voodoo to load and test this plugin with its plugin dependencies --> + <plugin> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <skip>true</skip> + </configuration> + <executions> + <execution> + <id>surefire-it</id> + <phase>integration-test</phase> + <goals> + <goal>test</goal> + </goals> + <configuration> + <skip>${maven.test.skip}</skip> + <excludedGroups>${rhq.testng.excludedGroups}</excludedGroups> + <useSystemClassLoader>false</useSystemClassLoader> + <argLine>-Dorg.hyperic.sigar.path=${basedir}/target/itest/lib</argLine> + <!--<argLine>-Dorg.hyperic.sigar.path=${basedir}/target/itest/lib -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y</argLine>--> + <systemProperties> + <property> + <name>project.artifactId</name> + <value>${project.artifactId}</value> + </property> + <property> + <name>project.version</name> + <value>${project.version}</value> + </property> + </systemProperties> + </configuration> + </execution> + </executions> + </plugin> + + </plugins> + </build> + </profile> + + <profile> + <id>dev</id> + + <properties> + <rhq.rootDir>../../..</rhq.rootDir> + <rhq.containerDir>${rhq.rootDir}/${rhq.defaultDevContainerPath}</rhq.containerDir> + <rhq.deploymentDir> + ${rhq.containerDir}/jbossas/server/default/deploy/${rhq.earName}/rhq-downloads/rhq-plugins + </rhq.deploymentDir> + </properties> + + <build> + <plugins> + + <plugin> + <artifactId>maven-antrun-plugin</artifactId> + <version>1.1</version> + <executions> + + <execution> + <id>deploy</id> + <!--<phase>compile</phase>--> + <configuration> + <tasks> + <mkdir dir="${rhq.deploymentDir}" /> + <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" /> + <echo>*** Updating ${deployment.file}...</echo> + <jar destfile="${deployment.file}" basedir="${project.build.outputDirectory}" /> + </tasks> + </configuration> + <goals> + <goal>run</goal> + </goals> + </execution> + + <execution> + <id>undeploy</id> + <!--<phase>clean</phase>--> + <configuration> + <tasks> + <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" /> + <echo>*** Deleting ${deployment.file}...</echo> + <delete file="${deployment.file}" /> + </tasks> + </configuration> + <goals> + <goal>run</goal> + </goals> + </execution> + + </executions> + </plugin> + + </plugins> + </build> + </profile> + + </profiles> + +</project> diff --git a/etc/apt/src/main/java/org/rhq/plugins/apt/AptSourcesComponent.java b/etc/apt/src/main/java/org/rhq/plugins/apt/AptSourcesComponent.java new file mode 100644 index 0000000..905caa6 --- /dev/null +++ b/etc/apt/src/main/java/org/rhq/plugins/apt/AptSourcesComponent.java @@ -0,0 +1,144 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2008 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +package org.rhq.plugins.apt; + +import java.io.File; +import java.util.Date; +import java.util.List; + +import net.augeas.Augeas; + +import org.rhq.core.domain.configuration.Configuration; +import org.rhq.core.domain.configuration.PropertyList; +import org.rhq.core.domain.configuration.PropertyMap; +import org.rhq.core.domain.configuration.PropertySimple; +import org.rhq.core.domain.measurement.AvailabilityType; +import org.rhq.core.pluginapi.configuration.ConfigurationFacet; +import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport; +import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException; +import org.rhq.core.pluginapi.inventory.ResourceComponent; +import org.rhq.core.pluginapi.inventory.ResourceContext; + +/** + * @author Jason Dobies + */ +public class AptSourcesComponent implements ResourceComponent, ConfigurationFacet { + + private ResourceContext resourceContext; + private File aptSourcesFile; + + public void start(ResourceContext resourceContext) throws InvalidPluginConfigurationException, Exception { + this.resourceContext = resourceContext; + + Configuration pluginConfiguration = resourceContext.getPluginConfiguration(); + + PropertySimple aptSourcesPathProperty = pluginConfiguration.getSimple("apt-sources-path"); + + if (aptSourcesPathProperty == null) { + throw new InvalidPluginConfigurationException( + "Apt sources not found in the plugin configuration, cannot start resource component"); + } + + String aptSourcesPath = aptSourcesPathProperty.getStringValue(); + + aptSourcesFile = new File(aptSourcesPath); + + if (!aptSourcesFile.exists()) { + throw new InvalidPluginConfigurationException("Apt sources file not found at specified location: " + + aptSourcesPath); + } + } + + public void stop() { + } + + public AvailabilityType getAvailability() { + if (aptSourcesFile == null) { + return AvailabilityType.DOWN; + } + + return aptSourcesFile.exists() ? AvailabilityType.UP : AvailabilityType.DOWN; + } + + public Configuration loadResourceConfiguration() throws Exception { + Configuration pluginConfiguration = resourceContext.getPluginConfiguration(); + + return loadResourceConfiguration(pluginConfiguration); + } + + public Configuration loadResourceConfiguration(Configuration pluginConfiguration) throws Exception { + // Gather data necessary to create the Augeas hook + PropertySimple lensesPathProperty = pluginConfiguration.getSimple("lenses-path"); + + if (lensesPathProperty == null) { + throw new Exception("Lenses path not found in plugin configuration, cannot retrieve configuration"); + } + + PropertySimple rootPathProperty = pluginConfiguration.getSimple("root-path"); + + if (rootPathProperty == null) { + throw new Exception("Root path not found in plugin configuration, cannot retrieve configuration"); + } + + String lensesPath = lensesPathProperty.getStringValue(); + String rootPath = rootPathProperty.getStringValue(); + + Augeas augeas = new Augeas(rootPath, lensesPath, Augeas.NONE); + + // Find out where to look for the apt sources tree + PropertySimple augeasTreeNodeProperty = pluginConfiguration.getSimple("augeas-apt-sources-path"); + + if (augeasTreeNodeProperty == null) { + throw new Exception("Augeas tree node not specified for apt sources, cannot retrive configuration"); + } + + String sourcesTreeNode = augeasTreeNodeProperty.getStringValue(); + + // Request data from augeas + List<String> matches = augeas.match(sourcesTreeNode); + if (matches.size() == 0) { + throw new Exception("Unable to load apt sources data from augeas"); + } + + // Parse out the properties + Configuration configuration = new Configuration(); + configuration.setNotes("Loaded from Augeas at " + new Date()); + + PropertyList entriesList = new PropertyList("aptEntries"); + configuration.put(entriesList); + + for (String entryNode : matches) { + String type = augeas.get(entryNode + "/type"); + String uri = augeas.get(entryNode + "/uri"); + String distribution = augeas.get(entryNode + "/distribution"); + + PropertyMap entry = new PropertyMap("aptEntry"); + entry.put(new PropertySimple("type", type)); + entry.put(new PropertySimple("uri", uri)); + entry.put(new PropertySimple("distribution", distribution)); + + entriesList.add(entry); + } + + return configuration; + } + + public void updateResourceConfiguration(ConfigurationUpdateReport report) { + } +} diff --git a/etc/apt/src/main/java/org/rhq/plugins/apt/AptSourcesDiscoveryComponent.java b/etc/apt/src/main/java/org/rhq/plugins/apt/AptSourcesDiscoveryComponent.java new file mode 100644 index 0000000..6ff3691 --- /dev/null +++ b/etc/apt/src/main/java/org/rhq/plugins/apt/AptSourcesDiscoveryComponent.java @@ -0,0 +1,50 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2008 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +package org.rhq.plugins.apt; + +import java.io.File; +import java.util.HashSet; +import java.util.Set; +import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails; +import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException; +import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent; +import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext; + +/** + * @author Jason Dobies + */ +public class AptSourcesDiscoveryComponent implements ResourceDiscoveryComponent { + + public Set discoverResources(ResourceDiscoveryContext resourceDiscoveryContext) throws InvalidPluginConfigurationException, Exception { + + Set<DiscoveredResourceDetails> details = new HashSet<DiscoveredResourceDetails>(); + + File sourcesFile = new File("/etc/apt/sources.list"); + + if (sourcesFile.exists()) { + DiscoveredResourceDetails resource = + new DiscoveredResourceDetails(resourceDiscoveryContext.getResourceType(), "apt-sources", "Apt Sources Service", + "1.0", "Apt sources in use on the machine.", null, null); + + details.add(resource); + } + + return details; + } +} diff --git a/etc/apt/src/main/resources/META-INF/rhq-plugin.xml b/etc/apt/src/main/resources/META-INF/rhq-plugin.xml new file mode 100644 index 0000000..a749435 --- /dev/null +++ b/etc/apt/src/main/resources/META-INF/rhq-plugin.xml @@ -0,0 +1,48 @@ +<plugin name="Apt" + displayName="Apt" + description="Support for apt configuration" + package="org.rhq.plugins.apt" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns="urn:xmlns:rhq-plugin" + xmlns:c="urn:xmlns:rhq-configuration"> + + <depends plugin="Augeas"/> + + <server name="Apt Sources" + description="Package list for APT" + discovery="AptSourcesDiscoveryComponent" + class="AptSourcesComponent"> + + <plugin-configuration> + <c:group name="augeas" displayName="Augeas Settings"> + <c:simple-property name="lenses-path" displayName="Augeas Lenses Path" + default="/usr/local/share/augeas/lenses" required="true" + description="Full path to the augeas lenses directory. Example: /usr/local/share/augeas/lenses"/> + <c:simple-property name="root-path" displayName="Augeas Root Path" default="/" required="true" + description="Path from which augeas should begin to search for configuration files. Example: /"/> + </c:group> + <c:group name="apt" displayName="Apt Settings"> + <c:simple-property name="apt-sources-path" displayName="Apt Sources File Path" required="true" + default="/etc/apt/sources.list" description="Location of the apt sources file."/> + <c:simple-property name="augeas-apt-sources-path" displayName="Augeas Apt Sources Tree Path" required="true" + default="/files/etc/apt/sources.list/*" description="Augeas tree location of the apt sources configuration values."/> + </c:group> + </plugin-configuration> + + <resource-configuration> + + <c:list-property name="aptEntries"> + <c:map-property name="aptEntry"> + <c:simple-property name="type" displayName="Type" type="string" required="true" activationPolicy="restart" + description="Type of packages found in the source, typically binaries v. source."/> + <c:simple-property name="uri" displayName="URI" type="string" required="true" activationPolicy="restart" + description="Location of the repository."/> + <c:simple-property name="distribution" displayName="Distribution" type="string" required="true" activationPolicy="restart"/> + </c:map-property> + </c:list-property> + </resource-configuration> + + + </server> + +</plugin> \ No newline at end of file diff --git a/etc/apt/src/test/java/org/rhq/plugins/apt/AptSourcesComponentTest.java b/etc/apt/src/test/java/org/rhq/plugins/apt/AptSourcesComponentTest.java new file mode 100644 index 0000000..c5c1b2e --- /dev/null +++ b/etc/apt/src/test/java/org/rhq/plugins/apt/AptSourcesComponentTest.java @@ -0,0 +1,93 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2008 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +package org.rhq.plugins.apt; + +import java.util.Collection; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.testng.annotations.BeforeSuite; +import org.testng.annotations.Test; + +import org.rhq.core.domain.configuration.Configuration; +import org.rhq.core.domain.configuration.Property; +import org.rhq.core.domain.configuration.PropertyList; +import org.rhq.core.domain.configuration.PropertyMap; +import org.rhq.core.domain.configuration.PropertySimple; + +/** + * @author Jason Dobies + */ +@Test(groups = "apt-plugin") +public class AptSourcesComponentTest { + + private AptSourcesComponent component = new AptSourcesComponent(); + + private Configuration pluginConfiguration = new Configuration(); + + private final Log log = LogFactory.getLog(this.getClass()); + + @BeforeSuite + public void initPluginConfiguration() throws Exception { + pluginConfiguration.put(new PropertySimple("lenses-path", "/usr/local/share/augeas/lenses")); + pluginConfiguration.put(new PropertySimple("root-path", "/")); + pluginConfiguration.put(new PropertySimple("apt-sources-path", "/etc/apt/sources.list")); + pluginConfiguration.put(new PropertySimple("augeas-apt-sources-path", "/files/etc/apt/sources.list/*")); + } + + public void loadResourceConfiguration() throws Exception { + // Just bail because this test wont work yet + if (true) { + return; + } + Configuration configuration; + try { + configuration = component.loadResourceConfiguration(pluginConfiguration); + } catch (UnsatisfiedLinkError ule) { + // Skip tests if augeas not available + return; + } + + assert configuration != null : "Null configuration returned from load call"; + + Collection<Property> allProperties = configuration.getProperties(); + + assert allProperties.size() == 1 : "Incorrect number of properties found. Expected: 1, Found: " + + allProperties.size(); + + PropertyList entryList = (PropertyList) allProperties.iterator().next(); + + for (Property property : entryList.getList()) { + PropertyMap entry = (PropertyMap) property; + + Property typeProperty = entry.get("type"); + Property uriProperty = entry.get("uri"); + Property distributionProperty = entry.get("distribution"); + + assert typeProperty != null : "Type was null in entry"; + assert uriProperty != null : "URI was null in entry"; + assert distributionProperty != null : "Distribution was null in entry"; + + log.info("Type: " + ((PropertySimple) typeProperty).getStringValue()); + log.info("URI: " + ((PropertySimple) uriProperty).getStringValue()); + log.info("Distribution: " + ((PropertySimple) distributionProperty).getStringValue()); + } + + } +} diff --git a/etc/apt/src/test/resources/log4j.xml b/etc/apt/src/test/resources/log4j.xml new file mode 100644 index 0000000..ef41b92 --- /dev/null +++ b/etc/apt/src/test/resources/log4j.xml @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> + +<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="true"> + + <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender"> + <param name="Target" value="System.out"/> + <param name="Threshold" value="DEBUG"/> + + <layout class="org.apache.log4j.PatternLayout"> + <!-- The default pattern: Date Priority [Category] Messagen --> + + <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/> + </layout> + </appender> + + <appender name="FILE" class="org.apache.log4j.RollingFileAppender"> + <param name="File" value="target/test.log"/> + <param name="Threshold" value="DEBUG"/> + <param name="Append" value="false"/> + + <layout class="org.apache.log4j.PatternLayout"> + <param name="ConversionPattern" value="%-5p %d{dd-MM HH:mm:ss,SSS} (%F:%M:%L) -%m%n"/> + </layout> + </appender> + + <root> + <appender-ref ref="CONSOLE"/> + <appender-ref ref="FILE"/> + </root> + +</log4j:configuration> diff --git a/modules/plugins/apt/pom.xml b/modules/plugins/apt/pom.xml deleted file mode 100644 index 47da3e5..0000000 --- a/modules/plugins/apt/pom.xml +++ /dev/null @@ -1,199 +0,0 @@ -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.rhq</groupId> - <artifactId>rhq-plugins-parent</artifactId> - <version>1.4.0-SNAPSHOT</version> - </parent> - - <groupId>org.rhq</groupId> - <artifactId>rhq-apt-plugin</artifactId> - <packaging>jar</packaging> - - <name>RHQ Apt Plugin</name> - <description>A plugin for managing the apt based features</description> - - <scm> - <connection>scm:git:ssh://git.fedorahosted.org/git/rhq.git/modules/plugins/apt</connection> - <developerConnection>scm:git:ssh://git.fedorahosted.org/git/rhq.git/modules/plugins/apt</developerConnection> - </scm> - - <properties> - <scm.module.path>modules/plugins/apt/</scm.module.path> - </properties> - - <dependencies> - - <dependency> - <groupId>net.augeas</groupId> - <artifactId>augeas</artifactId> - <version>0.0.1</version> - </dependency> - - <dependency> - <groupId>com.sun.jna</groupId> - <artifactId>jna</artifactId> - <version>3.0.1</version> - </dependency> - - </dependencies> - - <profiles> - <profile> - <id>integration-tests</id> - <activation> - <property> - <name>maven.test.skip</name> - <value>!true</value> - </property> - </activation> - - <build> - <plugins> - <plugin> - <artifactId>maven-antrun-plugin</artifactId> - <executions> - <execution> - <phase>pre-integration-test</phase> - <configuration> - <tasks> - <echo>Setting up plugin dependencies for ${project.artifactId}-${project.version}.jar... - </echo> - <property name="settings.localRepository" location="${user.home}/.m2/repository" /> - <mkdir dir="target/itest" /> - <mkdir dir="target/itest/plugins" /> - <mkdir dir="target/itest/lib" /> - <copy toDir="target/itest/plugins" flatten="true"> - <fileset dir="${settings.localRepository}/"> - <include name="org/rhq/rhq-platform-plugin/${project.version}/rhq-platform-plugin-${project.version}.jar" /> - </fileset> - <fileset dir="${project.build.directory}"> - <include name="${project.artifactId}-${project.version}.jar" /> - </fileset> - </copy> - <unzip dest="target/itest/lib"> - <fileset dir="${settings.localRepository}/org/hyperic/sigar-dist/${sigar.version}" includes="*.zip" /> - <patternset> - <include name="**/lib/sigar.jar" /> - <include name="**/lib/bcel*.jar" /> - <include name="**/lib/*.so" /> - <include name="**/lib/*.sl" /> - <include name="**/lib/*.dll" /> - <include name="**/lib/*.dylib" /> - </patternset> - </unzip> - <move todir="target/itest/lib" flatten="true"> - <fileset dir="target/itest/lib"> - <include name="**/lib/*" /> - </fileset> - </move> - <delete dir="target/itest/lib/hyperic-sigar-${sigar.version}" /> - </tasks> - </configuration> - <goals> - <goal>run</goal> - </goals> - </execution> - </executions> - </plugin> - - <!-- Integration testing voodoo to load and test this plugin with its plugin dependencies --> - <plugin> - <artifactId>maven-surefire-plugin</artifactId> - <configuration> - <skip>true</skip> - </configuration> - <executions> - <execution> - <id>surefire-it</id> - <phase>integration-test</phase> - <goals> - <goal>test</goal> - </goals> - <configuration> - <skip>${maven.test.skip}</skip> - <excludedGroups>${rhq.testng.excludedGroups}</excludedGroups> - <useSystemClassLoader>false</useSystemClassLoader> - <argLine>-Dorg.hyperic.sigar.path=${basedir}/target/itest/lib</argLine> - <!--<argLine>-Dorg.hyperic.sigar.path=${basedir}/target/itest/lib -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y</argLine>--> - <systemProperties> - <property> - <name>project.artifactId</name> - <value>${project.artifactId}</value> - </property> - <property> - <name>project.version</name> - <value>${project.version}</value> - </property> - </systemProperties> - </configuration> - </execution> - </executions> - </plugin> - - </plugins> - </build> - </profile> - - <profile> - <id>dev</id> - - <properties> - <rhq.rootDir>../../..</rhq.rootDir> - <rhq.containerDir>${rhq.rootDir}/${rhq.defaultDevContainerPath}</rhq.containerDir> - <rhq.deploymentDir> - ${rhq.containerDir}/jbossas/server/default/deploy/${rhq.earName}/rhq-downloads/rhq-plugins - </rhq.deploymentDir> - </properties> - - <build> - <plugins> - - <plugin> - <artifactId>maven-antrun-plugin</artifactId> - <version>1.1</version> - <executions> - - <execution> - <id>deploy</id> - <!--<phase>compile</phase>--> - <configuration> - <tasks> - <mkdir dir="${rhq.deploymentDir}" /> - <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" /> - <echo>*** Updating ${deployment.file}...</echo> - <jar destfile="${deployment.file}" basedir="${project.build.outputDirectory}" /> - </tasks> - </configuration> - <goals> - <goal>run</goal> - </goals> - </execution> - - <execution> - <id>undeploy</id> - <!--<phase>clean</phase>--> - <configuration> - <tasks> - <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" /> - <echo>*** Deleting ${deployment.file}...</echo> - <delete file="${deployment.file}" /> - </tasks> - </configuration> - <goals> - <goal>run</goal> - </goals> - </execution> - - </executions> - </plugin> - - </plugins> - </build> - </profile> - - </profiles> - -</project> diff --git a/modules/plugins/apt/src/main/java/org/rhq/plugins/apt/AptSourcesComponent.java b/modules/plugins/apt/src/main/java/org/rhq/plugins/apt/AptSourcesComponent.java deleted file mode 100644 index 905caa6..0000000 --- a/modules/plugins/apt/src/main/java/org/rhq/plugins/apt/AptSourcesComponent.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package org.rhq.plugins.apt; - -import java.io.File; -import java.util.Date; -import java.util.List; - -import net.augeas.Augeas; - -import org.rhq.core.domain.configuration.Configuration; -import org.rhq.core.domain.configuration.PropertyList; -import org.rhq.core.domain.configuration.PropertyMap; -import org.rhq.core.domain.configuration.PropertySimple; -import org.rhq.core.domain.measurement.AvailabilityType; -import org.rhq.core.pluginapi.configuration.ConfigurationFacet; -import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport; -import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException; -import org.rhq.core.pluginapi.inventory.ResourceComponent; -import org.rhq.core.pluginapi.inventory.ResourceContext; - -/** - * @author Jason Dobies - */ -public class AptSourcesComponent implements ResourceComponent, ConfigurationFacet { - - private ResourceContext resourceContext; - private File aptSourcesFile; - - public void start(ResourceContext resourceContext) throws InvalidPluginConfigurationException, Exception { - this.resourceContext = resourceContext; - - Configuration pluginConfiguration = resourceContext.getPluginConfiguration(); - - PropertySimple aptSourcesPathProperty = pluginConfiguration.getSimple("apt-sources-path"); - - if (aptSourcesPathProperty == null) { - throw new InvalidPluginConfigurationException( - "Apt sources not found in the plugin configuration, cannot start resource component"); - } - - String aptSourcesPath = aptSourcesPathProperty.getStringValue(); - - aptSourcesFile = new File(aptSourcesPath); - - if (!aptSourcesFile.exists()) { - throw new InvalidPluginConfigurationException("Apt sources file not found at specified location: " - + aptSourcesPath); - } - } - - public void stop() { - } - - public AvailabilityType getAvailability() { - if (aptSourcesFile == null) { - return AvailabilityType.DOWN; - } - - return aptSourcesFile.exists() ? AvailabilityType.UP : AvailabilityType.DOWN; - } - - public Configuration loadResourceConfiguration() throws Exception { - Configuration pluginConfiguration = resourceContext.getPluginConfiguration(); - - return loadResourceConfiguration(pluginConfiguration); - } - - public Configuration loadResourceConfiguration(Configuration pluginConfiguration) throws Exception { - // Gather data necessary to create the Augeas hook - PropertySimple lensesPathProperty = pluginConfiguration.getSimple("lenses-path"); - - if (lensesPathProperty == null) { - throw new Exception("Lenses path not found in plugin configuration, cannot retrieve configuration"); - } - - PropertySimple rootPathProperty = pluginConfiguration.getSimple("root-path"); - - if (rootPathProperty == null) { - throw new Exception("Root path not found in plugin configuration, cannot retrieve configuration"); - } - - String lensesPath = lensesPathProperty.getStringValue(); - String rootPath = rootPathProperty.getStringValue(); - - Augeas augeas = new Augeas(rootPath, lensesPath, Augeas.NONE); - - // Find out where to look for the apt sources tree - PropertySimple augeasTreeNodeProperty = pluginConfiguration.getSimple("augeas-apt-sources-path"); - - if (augeasTreeNodeProperty == null) { - throw new Exception("Augeas tree node not specified for apt sources, cannot retrive configuration"); - } - - String sourcesTreeNode = augeasTreeNodeProperty.getStringValue(); - - // Request data from augeas - List<String> matches = augeas.match(sourcesTreeNode); - if (matches.size() == 0) { - throw new Exception("Unable to load apt sources data from augeas"); - } - - // Parse out the properties - Configuration configuration = new Configuration(); - configuration.setNotes("Loaded from Augeas at " + new Date()); - - PropertyList entriesList = new PropertyList("aptEntries"); - configuration.put(entriesList); - - for (String entryNode : matches) { - String type = augeas.get(entryNode + "/type"); - String uri = augeas.get(entryNode + "/uri"); - String distribution = augeas.get(entryNode + "/distribution"); - - PropertyMap entry = new PropertyMap("aptEntry"); - entry.put(new PropertySimple("type", type)); - entry.put(new PropertySimple("uri", uri)); - entry.put(new PropertySimple("distribution", distribution)); - - entriesList.add(entry); - } - - return configuration; - } - - public void updateResourceConfiguration(ConfigurationUpdateReport report) { - } -} diff --git a/modules/plugins/apt/src/main/java/org/rhq/plugins/apt/AptSourcesDiscoveryComponent.java b/modules/plugins/apt/src/main/java/org/rhq/plugins/apt/AptSourcesDiscoveryComponent.java deleted file mode 100644 index 6ff3691..0000000 --- a/modules/plugins/apt/src/main/java/org/rhq/plugins/apt/AptSourcesDiscoveryComponent.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package org.rhq.plugins.apt; - -import java.io.File; -import java.util.HashSet; -import java.util.Set; -import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails; -import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException; -import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent; -import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext; - -/** - * @author Jason Dobies - */ -public class AptSourcesDiscoveryComponent implements ResourceDiscoveryComponent { - - public Set discoverResources(ResourceDiscoveryContext resourceDiscoveryContext) throws InvalidPluginConfigurationException, Exception { - - Set<DiscoveredResourceDetails> details = new HashSet<DiscoveredResourceDetails>(); - - File sourcesFile = new File("/etc/apt/sources.list"); - - if (sourcesFile.exists()) { - DiscoveredResourceDetails resource = - new DiscoveredResourceDetails(resourceDiscoveryContext.getResourceType(), "apt-sources", "Apt Sources Service", - "1.0", "Apt sources in use on the machine.", null, null); - - details.add(resource); - } - - return details; - } -} diff --git a/modules/plugins/apt/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/apt/src/main/resources/META-INF/rhq-plugin.xml deleted file mode 100644 index a749435..0000000 --- a/modules/plugins/apt/src/main/resources/META-INF/rhq-plugin.xml +++ /dev/null @@ -1,48 +0,0 @@ -<plugin name="Apt" - displayName="Apt" - description="Support for apt configuration" - package="org.rhq.plugins.apt" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns="urn:xmlns:rhq-plugin" - xmlns:c="urn:xmlns:rhq-configuration"> - - <depends plugin="Augeas"/> - - <server name="Apt Sources" - description="Package list for APT" - discovery="AptSourcesDiscoveryComponent" - class="AptSourcesComponent"> - - <plugin-configuration> - <c:group name="augeas" displayName="Augeas Settings"> - <c:simple-property name="lenses-path" displayName="Augeas Lenses Path" - default="/usr/local/share/augeas/lenses" required="true" - description="Full path to the augeas lenses directory. Example: /usr/local/share/augeas/lenses"/> - <c:simple-property name="root-path" displayName="Augeas Root Path" default="/" required="true" - description="Path from which augeas should begin to search for configuration files. Example: /"/> - </c:group> - <c:group name="apt" displayName="Apt Settings"> - <c:simple-property name="apt-sources-path" displayName="Apt Sources File Path" required="true" - default="/etc/apt/sources.list" description="Location of the apt sources file."/> - <c:simple-property name="augeas-apt-sources-path" displayName="Augeas Apt Sources Tree Path" required="true" - default="/files/etc/apt/sources.list/*" description="Augeas tree location of the apt sources configuration values."/> - </c:group> - </plugin-configuration> - - <resource-configuration> - - <c:list-property name="aptEntries"> - <c:map-property name="aptEntry"> - <c:simple-property name="type" displayName="Type" type="string" required="true" activationPolicy="restart" - description="Type of packages found in the source, typically binaries v. source."/> - <c:simple-property name="uri" displayName="URI" type="string" required="true" activationPolicy="restart" - description="Location of the repository."/> - <c:simple-property name="distribution" displayName="Distribution" type="string" required="true" activationPolicy="restart"/> - </c:map-property> - </c:list-property> - </resource-configuration> - - - </server> - -</plugin> \ No newline at end of file diff --git a/modules/plugins/apt/src/test/java/org/rhq/plugins/apt/AptSourcesComponentTest.java b/modules/plugins/apt/src/test/java/org/rhq/plugins/apt/AptSourcesComponentTest.java deleted file mode 100644 index c5c1b2e..0000000 --- a/modules/plugins/apt/src/test/java/org/rhq/plugins/apt/AptSourcesComponentTest.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package org.rhq.plugins.apt; - -import java.util.Collection; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; - -import org.rhq.core.domain.configuration.Configuration; -import org.rhq.core.domain.configuration.Property; -import org.rhq.core.domain.configuration.PropertyList; -import org.rhq.core.domain.configuration.PropertyMap; -import org.rhq.core.domain.configuration.PropertySimple; - -/** - * @author Jason Dobies - */ -@Test(groups = "apt-plugin") -public class AptSourcesComponentTest { - - private AptSourcesComponent component = new AptSourcesComponent(); - - private Configuration pluginConfiguration = new Configuration(); - - private final Log log = LogFactory.getLog(this.getClass()); - - @BeforeSuite - public void initPluginConfiguration() throws Exception { - pluginConfiguration.put(new PropertySimple("lenses-path", "/usr/local/share/augeas/lenses")); - pluginConfiguration.put(new PropertySimple("root-path", "/")); - pluginConfiguration.put(new PropertySimple("apt-sources-path", "/etc/apt/sources.list")); - pluginConfiguration.put(new PropertySimple("augeas-apt-sources-path", "/files/etc/apt/sources.list/*")); - } - - public void loadResourceConfiguration() throws Exception { - // Just bail because this test wont work yet - if (true) { - return; - } - Configuration configuration; - try { - configuration = component.loadResourceConfiguration(pluginConfiguration); - } catch (UnsatisfiedLinkError ule) { - // Skip tests if augeas not available - return; - } - - assert configuration != null : "Null configuration returned from load call"; - - Collection<Property> allProperties = configuration.getProperties(); - - assert allProperties.size() == 1 : "Incorrect number of properties found. Expected: 1, Found: " - + allProperties.size(); - - PropertyList entryList = (PropertyList) allProperties.iterator().next(); - - for (Property property : entryList.getList()) { - PropertyMap entry = (PropertyMap) property; - - Property typeProperty = entry.get("type"); - Property uriProperty = entry.get("uri"); - Property distributionProperty = entry.get("distribution"); - - assert typeProperty != null : "Type was null in entry"; - assert uriProperty != null : "URI was null in entry"; - assert distributionProperty != null : "Distribution was null in entry"; - - log.info("Type: " + ((PropertySimple) typeProperty).getStringValue()); - log.info("URI: " + ((PropertySimple) uriProperty).getStringValue()); - log.info("Distribution: " + ((PropertySimple) distributionProperty).getStringValue()); - } - - } -} diff --git a/modules/plugins/apt/src/test/resources/log4j.xml b/modules/plugins/apt/src/test/resources/log4j.xml deleted file mode 100644 index ef41b92..0000000 --- a/modules/plugins/apt/src/test/resources/log4j.xml +++ /dev/null @@ -1,32 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> - -<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="true"> - - <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender"> - <param name="Target" value="System.out"/> - <param name="Threshold" value="DEBUG"/> - - <layout class="org.apache.log4j.PatternLayout"> - <!-- The default pattern: Date Priority [Category] Messagen --> - - <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/> - </layout> - </appender> - - <appender name="FILE" class="org.apache.log4j.RollingFileAppender"> - <param name="File" value="target/test.log"/> - <param name="Threshold" value="DEBUG"/> - <param name="Append" value="false"/> - - <layout class="org.apache.log4j.PatternLayout"> - <param name="ConversionPattern" value="%-5p %d{dd-MM HH:mm:ss,SSS} (%F:%M:%L) -%m%n"/> - </layout> - </appender> - - <root> - <appender-ref ref="CONSOLE"/> - <appender-ref ref="FILE"/> - </root> - -</log4j:configuration> diff --git a/modules/plugins/pom.xml b/modules/plugins/pom.xml index de81bb2..50f68bb 100644 --- a/modules/plugins/pom.xml +++ b/modules/plugins/pom.xml @@ -101,7 +101,6 @@
<!-- other, possibly experimental plugins --> <module>augeas</module> - <module>apt</module> <module>cron</module> <module>script</module> <module>grub</module>
commit 94d9e41f45e4e4743347c688a6e0d1dcee61cabd Author: Heiko W. Rupp pilhuhn@fedorapeople.org Date: Wed Dec 9 14:30:00 2009 +0100
Start working on template bundles of notifications.
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/alert-schema.xml b/modules/core/dbutils/src/main/scripts/dbsetup/alert-schema.xml index f9560c1..c9f03a8 100644 --- a/modules/core/dbutils/src/main/scripts/dbsetup/alert-schema.xml +++ b/modules/core/dbutils/src/main/scripts/dbsetup/alert-schema.xml @@ -133,4 +133,13 @@ <column name="ALERT_SENDER_NAME" required="false" type="VARCHAR2" /> <!-- TODO make required = true --> </table>
+ <table name="RHQ_ALERT_NOTIF_TEMPL" tablespace="@@@LARGE_TABLESPACE_FOR_DATA@@@" + storage-options="freelists 5" cache="true" logging="false"> + <column name="ID" default="sequence-only" initial="10001" + primarykey="true" required="true" type="INTEGER"/> + <column name="NAME" required="true" size="40" type="VARCHAR2"/> + <column name="DESCRIPTION" required="false" size="250" type="VARCHAR2"/> + + </table> + </dbsetup> diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml index a2182a7..3441d9c 100644 --- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml +++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml @@ -2222,6 +2222,20 @@ </schema-directSQL>
</schemaSpec> + <schemaSpec version="2.70.1"> + <schema-directSQL> + <statement> + CREATE TABLE RHQ_ALERT_NOTIF_TEMPL ( ID INTEGER ) + </statement> + <statement> + ALTER TABLE RHQ_ALERT_NOTIF_TEMPL + ADD CONSTRAINT RHQ_ALERT_NOTIF_TEMPL_KEY + PRIMARY KEY ( ID ) + </statement> + </schema-directSQL> + <schema-addColumn table="RHQ_ALERT_NOTIF_TEMPL" column="NAME" columnType="VARCHAR2"/> + <schema-addColumn table="RHQ_ALERT_NOTIF_TEMPL" column="DESCRIPTION" columnType="VARCHAR2"/> + </schemaSpec>
</dbupgrade> </target> diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/NotificationTemplate.java b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/NotificationTemplate.java new file mode 100644 index 0000000..acf795f --- /dev/null +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/NotificationTemplate.java @@ -0,0 +1,123 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2009 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +package org.rhq.core.domain.alert.notification; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.OneToMany; +import javax.persistence.SequenceGenerator; +import javax.persistence.Table; +import javax.persistence.Transient; + +/** + * A template that consists of multiple notifications. This can be used to create + * 'bundles' of preconfigured alert notifications which can then be applied to + * AlertDefinitions directly or via AlertTemplates. + * @author Heiko W. Rupp + */ +@Entity +@Table(name="RHQ_ALERT_NOTIF_TEMPL") +@SequenceGenerator(name="RHQ_ALERT_NOTIF_SEQ", sequenceName = "RHQ_ALERT_NOTIF_SEQ") +public class NotificationTemplate implements Serializable { + + @Column(name="ID", nullable = false) + @GeneratedValue(generator = "RHQ_ALERT_NOTIF_SEQ") + @Id + private int id; + + @Column(name="NAME") + private String name; + + @Column(name="DESCRIPTION") + private String description; + + + // @OneToMany(cascade = CascadeType.ALL) + @Transient + List<AlertNotification> notifications = new ArrayList<AlertNotification>(); + + protected NotificationTemplate() { + // for JPA + } + + public NotificationTemplate(String name, String description) { + this.name = name; + this.description = description; + } + + public int getId() { + return id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public List<AlertNotification> getNotifications() { + return notifications; + } + + public void setNotifications(List<AlertNotification> notifications) { + this.notifications = notifications; + } + + public List<AlertNotification> addNotification(AlertNotification notification) { + this.notifications.add(notification); + return this.notifications; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + NotificationTemplate that = (NotificationTemplate) o; + + if (description != null ? !description.equals(that.description) : that.description != null) return false; + if (!name.equals(that.name)) return false; + + return true; + } + + @Override + public int hashCode() { + int result = name.hashCode(); + result = 31 * result + (description != null ? description.hashCode() : 0); + return result; + } +} diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java index e948aac..89d1cc1 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java @@ -40,6 +40,7 @@ import org.rhq.core.domain.alert.AlertDefinition; import org.rhq.core.domain.alert.AlertDefinitionContext; import org.rhq.core.domain.alert.notification.AlertNotification; import org.rhq.core.domain.alert.notification.EmailNotification; +import org.rhq.core.domain.alert.notification.NotificationTemplate; import org.rhq.core.domain.alert.notification.RoleNotification; import org.rhq.core.domain.alert.notification.SnmpNotification; import org.rhq.core.domain.alert.notification.SubjectNotification; @@ -536,4 +537,21 @@ public class AlertNotificationManagerBean implements AlertNotificationManagerLoc } return result; } + + /** + * Take the passed NotificationTemplate and apply its Notifications to the passed AlertDefinition + * @param template NotificationTemplate to apply + * @param def AlertDefinition to apply the template to + * @param removeOldNotifications Shall old Notifications on the Definition be removed? + */ + public void applyNotificationTemplateToAlertDefinition(NotificationTemplate template, AlertDefinition def, boolean removeOldNotifications) { + + if (removeOldNotifications) + def.getAlertNotifications().clear(); + + for (AlertNotification notif : template.getNotifications()) { + def.addAlertNotification(notif.copy(false)); // Attach a copy, as the ones in the template should not be shared + } + + } } \ No newline at end of file diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerLocal.java index f67927f..7c458f4 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerLocal.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerLocal.java @@ -23,8 +23,10 @@ import java.util.List; import javax.ejb.Local;
import org.rhq.core.clientapi.descriptor.configuration.ConfigurationDescriptor; +import org.rhq.core.domain.alert.AlertDefinition; import org.rhq.core.domain.alert.notification.AlertNotification; import org.rhq.core.domain.alert.notification.EmailNotification; +import org.rhq.core.domain.alert.notification.NotificationTemplate; import org.rhq.core.domain.alert.notification.RoleNotification; import org.rhq.core.domain.alert.notification.SnmpNotification; import org.rhq.core.domain.alert.notification.SubjectNotification; @@ -109,4 +111,12 @@ public interface AlertNotificationManagerLocal { List<AlertNotification> getNotificationsForAlertDefinition(Subject user, int alertDefinitionId);
AlertSenderInfo getAlertInfoForSender(String shortName); + + /** + * Take the passed NotificationTemplate and apply its Notifications to the passed AlertDefinition + * @param template NotificationTemplate to apply + * @param def AlertDefinition to apply the template to + * @param removeOldNotifications Shall old Notifications on the Definition be removed? + */ + void applyNotificationTemplateToAlertDefinition(NotificationTemplate template, AlertDefinition def, boolean removeOldNotifications); } \ No newline at end of file
commit f75169ed996d5ae4fff104a0c2bb88734cdb6cbf Author: Heiko W. Rupp pilhuhn@fedorapeople.org Date: Wed Dec 9 09:23:51 2009 +0100
Enable irc alert sender
diff --git a/modules/enterprise/server/plugins/pom.xml b/modules/enterprise/server/plugins/pom.xml index 7be2d7a..d1390e4 100644 --- a/modules/enterprise/server/plugins/pom.xml +++ b/modules/enterprise/server/plugins/pom.xml @@ -40,6 +40,7 @@ <modul