[rhq] Branch 'bugfixes' - 46 commits - modules/core modules/enterprise modules/plugins
by John Sanda
modules/core/dbutils/src/main/java/org/rhq/core/db/DatabaseType.java | 37
modules/core/dbutils/src/main/java/org/rhq/core/db/ant/DbAntI18NResourceKeys.java | 10
modules/core/dbutils/src/main/java/org/rhq/core/db/ant/dbupgrade/SST_JavaTask.java | 102 ++
modules/core/dbutils/src/main/java/org/rhq/core/db/upgrade/CustomAlertSenderUpgradeTask.java | 219 +++++
modules/core/dbutils/src/main/java/org/rhq/core/db/upgrade/DatabaseUpgradeTask.java | 34
modules/core/dbutils/src/main/resources/db-ant-tasks.properties | 1
modules/core/dbutils/src/main/scripts/dbsetup/alert-schema.xml | 23
modules/core/dbutils/src/main/scripts/dbsetup/authz-schema.xml | 2
modules/core/dbutils/src/main/scripts/dbsetup/search-data.xml | 8
modules/core/dbutils/src/main/scripts/dbsetup/search-schema.xml | 1
modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml | 180 ++--
modules/core/domain/src/main/java/org/rhq/core/domain/alert/Alert.java | 34
modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java | 4
modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java | 89 --
modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotificationTemplate.java | 177 ----
modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionEnumeration.java | 16
modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionSimple.java | 20
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertDefinitionCriteria.java | 10
modules/core/domain/src/main/java/org/rhq/core/domain/plugin/AbstractPlugin.java | 3
modules/core/domain/src/main/java/org/rhq/core/domain/search/SavedSearch.java | 39
modules/core/domain/src/main/java/org/rhq/core/domain/search/SearchSubsystem.java | 14
modules/core/domain/src/main/java/org/rhq/core/domain/search/SearchSuggestion.java | 94 ++
modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java | 32
modules/enterprise/gui/alert-migration/README.txt | 18
modules/enterprise/gui/alert-migration/etc/dumpAlertDefinitions.js | 14
modules/enterprise/gui/alert-migration/pom.xml | 254 -----
modules/enterprise/gui/alert-migration/src/main/java/org/rhq/helpers/alertMigration/Alert13Parser.java | 202 ----
modules/enterprise/gui/alert-migration/src/main/java/org/rhq/helpers/alertMigration/MigrationServlet.java | 100 --
modules/enterprise/gui/alert-migration/src/main/java/org/rhq/helpers/alertMigration/RestoreAlerts.java | 71 -
modules/enterprise/gui/alert-migration/src/main/webapp/WEB-INF/web.xml | 27
modules/enterprise/gui/alert-migration/src/main/webapp/index.html | 17
modules/enterprise/gui/alert-migration/src/test/java/Alert13ParserTest.java | 83 -
modules/enterprise/gui/alert-migration/src/test/resources/alertDef.csv | 13
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java | 66 -
modules/enterprise/gui/pom.xml | 1
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/alert/AlertNotificationTemplateDetailsUIBean.java | 90 --
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/alert/ListAlertNotificationTemplatesUIBean.java | 76 -
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/alert/NewAlertNotificationTemplateUIBean.java | 86 --
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/AddLdapGroupsAction.java | 8
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/AddLdapGroupsFormPrepareAction.java | 143 +++
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/RemoveLdapGroupsAction.java | 6
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/ViewAction.java | 13
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/user/RegisterAction.java | 44 -
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/AlertNotificationStoreUIBean.java | 72 -
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/AlertNotificationsUIBean.java | 26
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/CustomContentUIBean.java | 6
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/DefinitionNotificationsUIBean.java | 105 --
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/framework/UserPreferencesUIBean.java | 62 +
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/paging/PagedListDataModel.java | 4
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/definition/group/EditGroupDefinitionGeneralPropertiesUIBean.java | 6
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/definition/group/NewGroupDefinitionGeneralPropertiesUIBean.java | 2
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/browse/BrowseGroupsUIBean.java | 29
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/browse/BrowseResourcesUIBean.java | 48 -
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/WebUserPreferences.java | 10
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/alerts/AckAlertAction.java | 19
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/hub/ResourceHubPortalAction.java | 40
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/startup/StartupServlet.java | 11
modules/enterprise/gui/portal-war/src/main/webapp/admin/role/AddLdapRoleGroups.jsp | 2
modules/enterprise/gui/portal-war/src/main/webapp/admin/role/RoleLdapGroupsForm.jsp | 263 ++++++
modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/alert/template/notification/details.xhtml | 136 ---
modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/alert/template/notification/list.xhtml | 146 ---
modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/alert/template/notification/new.xhtml | 74 -
modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/alert/notification/details.xhtml | 84 -
modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/menu/menu.xhtml | 23
modules/enterprise/gui/portal-war/src/main/webapp/rhq/definition/group/list.xhtml | 2
modules/enterprise/gui/portal-war/src/main/webapp/rhq/inventory/browseGroups.xhtml | 8
modules/enterprise/gui/portal-war/src/main/webapp/rhq/inventory/browseResources.xhtml | 46 -
modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/listAlertHistory.xhtml | 6
modules/enterprise/server/ear/pom.xml | 14
modules/enterprise/server/jar/src/main/antlr3/org/rhq/enterprise/server/search/RHQL.g | 3
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerBean.java | 168 +--
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerLocal.java | 7
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java | 255 -----
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerLocal.java | 80 -
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerBean.java | 103 --
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerLocal.java | 11
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java | 54 -
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/LdapLoginModule.java | 10
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/CustomAlertSenderBackingBean.java | 9
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManager.java | 302 -------
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManagerBean.java | 426 ++++++++++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManagerLocal.java | 53 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/SavedSearchResultCountRecalculationJob.java | 101 ++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/assist/AbstractSearchAssistant.java | 12
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/assist/ResourceSearchAssistant.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/assist/SearchAssistant.java | 10
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/execution/SearchAssistManager.java | 115 ++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/execution/SearchSuggestion.java | 52 -
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/execution/SearchTranslationManager.java | 26
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/translation/SearchTranslatorFactory.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java | 26
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java | 6
modules/enterprise/server/jar/src/main/resources/single-line-rhql.txt | 10
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/authz/test/RoleManagerBeanTest.java | 5
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/SubcategoryTest.java | 18
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateConfigurationSubsystemTest.java | 321 +++----
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateEventsSubsystemTest.java | 17
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateSubsytemTestBase.java | 4
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/GenericSearchAssistTest.java | 5
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/TestAutoCompletionManager.java | 8
modules/enterprise/server/jar/src/test/resources/log4j.xml | 5
modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/OperationsBackingBean.java | 21
modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresTableComponent.java | 10
modules/plugins/sshd/src/main/java/org/rhq/plugins/sshd/OpenSSHDComponent.java | 2
104 files changed, 2542 insertions(+), 3442 deletions(-)
New commits:
commit de211f8fc7cbee6258b7dde44a602e9734036b23
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Apr 28 16:09:48 2010 -0400
[BZ 544353] Modifying ui backing bean for edit page so stale values are not used
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/definition/group/EditGroupDefinitionGeneralPropertiesUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/definition/group/EditGroupDefinitionGeneralPropertiesUIBean.java
index 09837ec..262c173 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/definition/group/EditGroupDefinitionGeneralPropertiesUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/definition/group/EditGroupDefinitionGeneralPropertiesUIBean.java
@@ -103,6 +103,8 @@ public class EditGroupDefinitionGeneralPropertiesUIBean {
}
public String update() {
+ HttpSession session = FacesContextUtility.getRequest().getSession();
+
try {
GroupDefinition groupDefinition = GroupDefinitionUIBean.lookupGroupDefinition();
@@ -120,8 +122,6 @@ public class EditGroupDefinitionGeneralPropertiesUIBean {
groupDefinition.setExpression(expression.replaceAll("\\r", "\n").replaceAll("\\f", "\n").replaceAll("\\n+",
"\n"));
- HttpSession session = FacesContextUtility.getRequest().getSession();
-
session.setAttribute(TEMPORARY_EDIT_MARKER, "marker");
session.setAttribute(TEMPORARY_EXPRESSION_ATTRIBUTE, expression);
session.setAttribute(TEMPORARY_NAME_ATTRIBUTE, name);
@@ -148,6 +148,8 @@ public class EditGroupDefinitionGeneralPropertiesUIBean {
return OUTCOME_FAILURE;
}
+ session.removeAttribute(TEMPORARY_EDIT_MARKER);
+
FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO, "General properties updated.");
return OUTCOME_SUCCESS;
}
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/definition/group/NewGroupDefinitionGeneralPropertiesUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/definition/group/NewGroupDefinitionGeneralPropertiesUIBean.java
index ef3c90d..587ed1b 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/definition/group/NewGroupDefinitionGeneralPropertiesUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/definition/group/NewGroupDefinitionGeneralPropertiesUIBean.java
@@ -99,7 +99,7 @@ public class NewGroupDefinitionGeneralPropertiesUIBean {
return OUTCOME_FAILURE;
}
- session.setAttribute(TEMPORARY_CREATE_MARKER, null);
+ session.removeAttribute(TEMPORARY_CREATE_MARKER);
FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO,
"Definition created successfully. Add conditions below.");
commit 303467aeda8d90b48cb68581d53211c774a82fd5
Author: Joseph Marques <joseph(a)redhat.com>
Date: Wed Apr 28 10:06:54 2010 -0400
BA-586918 - fix for ClassCastException when using AlertDefinitionCriteria when filtering by either alertTemplateParentId or alertTemplateResourceTypeId
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertDefinitionCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertDefinitionCriteria.java
index c3992cb..e553ca8 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertDefinitionCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertDefinitionCriteria.java
@@ -29,8 +29,8 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
-import org.rhq.core.domain.alert.AlertPriority;
import org.rhq.core.domain.alert.AlertDefinition;
+import org.rhq.core.domain.alert.AlertPriority;
import org.rhq.core.domain.util.PageOrdering;
/**
@@ -46,8 +46,8 @@ public class AlertDefinitionCriteria extends Criteria {
private String filterName;
private String filterDescription;
private AlertPriority filterPriority;
- private String filterAlertTemplateParentId; // requires overrides
- private String filterAlertTemplateResourceTypeId; // requires overrides
+ private Integer filterAlertTemplateParentId; // requires overrides
+ private Integer filterAlertTemplateResourceTypeId; // requires overrides
private String filterAlertTemplateResourceTypeName; // requires overrides
private List<Integer> filterResourceIds; // requires overrides
private Boolean filterEnabled;
@@ -90,11 +90,11 @@ public class AlertDefinitionCriteria extends Criteria {
this.filterPriority = filterPriority;
}
- public void addFilterAlertTemplateParentId(String filterAlertTemplateParentId) {
+ public void addFilterAlertTemplateParentId(Integer filterAlertTemplateParentId) {
this.filterAlertTemplateParentId = filterAlertTemplateParentId;
}
- public void addFilterAlertTemplateResourceTypeId(String filterAlertTemplateResourceTypeId) {
+ public void addFilterAlertTemplateResourceTypeId(Integer filterAlertTemplateResourceTypeId) {
this.filterAlertTemplateResourceTypeId = filterAlertTemplateResourceTypeId;
}
commit 1851fe41127d4fb136b88184189efc37439f8677
Author: Joseph Marques <joseph(a)redhat.com>
Date: Wed Apr 28 03:12:49 2010 -0400
BZ-586676: fix for alert>history sub-tab as a result of changes to dbsetup
* alert entity no longer refers to the subject entity via foreign key relationship, update Facelet accordingly
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/listAlertHistory.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/listAlertHistory.xhtml
index b708ab7..0d0a46d 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/listAlertHistory.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/listAlertHistory.xhtml
@@ -174,16 +174,16 @@
<f:facet name="header">
<h:outputText styleClass="headerText" value="Ack by" />
</f:facet>
- <h:outputText value="#{item.alert.ackBy.name}" title="#{item.alert.ackBy.firstName} #{item.alert.ackBy.lastName}"/>
+ <h:outputText value="#{item.alert.acknowledgingSubject}" />
</rich:column>
<rich:column>
<f:facet name="header">
- <onc:sortableColumnHeader sort="a.ackTime">
+ <onc:sortableColumnHeader sort="a.acknowledgeTime">
<h:outputText styleClass="headerText" value="Ack date" />
</onc:sortableColumnHeader>
</f:facet>
- <h:outputText value="#{item.alert.ackTime}">
+ <h:outputText value="#{item.alert.acknowledgeTime}">
<f:converter converterId="RelativeDurationConverter" />
</h:outputText>
</rich:column>
commit 605b051d37b98be46f183e3d2bce214d256507f5
Author: Joseph Marques <joseph(a)redhat.com>
Date: Wed Apr 28 01:29:18 2010 -0400
move logging message to DEBUG level
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/WebUserPreferences.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/WebUserPreferences.java
index c0abd7e..e2414a7 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/WebUserPreferences.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/WebUserPreferences.java
@@ -777,7 +777,7 @@ public class WebUserPreferences extends SubjectPreferencesBase {
pageControlProperties.add(field.getOrdering().toString());
pageControlProperties.add(field.getField());
}
- System.out.println("setPageControl(" + view + ", " + pageControl + ")");
+ log.debug("setPageControl(" + view + ", " + pageControl + ")");
setPreference(view.toString(), pageControlProperties);
}
commit 20fe0ece0175e24f2a8905c3a666011802decea5
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Tue Apr 27 18:44:32 2010 -0400
BZ 584355: i)refactored ldap auth classes to be more consitently defined.ii)modified exception handling.
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/AddLdapGroupsAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/AddLdapGroupsAction.java
index fe91d46..036f8c1 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/AddLdapGroupsAction.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/AddLdapGroupsAction.java
@@ -35,13 +35,16 @@ import org.rhq.enterprise.gui.legacy.action.BaseAction;
import org.rhq.enterprise.gui.legacy.action.BaseValidatorForm;
import org.rhq.enterprise.gui.legacy.util.RequestUtils;
import org.rhq.enterprise.gui.legacy.util.SessionUtils;
-import org.rhq.enterprise.server.authz.RoleManagerLocal;
+import org.rhq.enterprise.server.resource.group.LdapGroupManagerLocal;
import org.rhq.enterprise.server.util.LookupUtil;
/**
* An Action that adds resource groups for a role.
*/
public class AddLdapGroupsAction extends BaseAction {
+
+ LdapGroupManagerLocal ldapManager = LookupUtil.getLdapGroupManager();
+
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception {
Log log = LogFactory.getLog(AddLdapGroupsAction.class.getName());
@@ -75,8 +78,7 @@ public class AddLdapGroupsAction extends BaseAction {
log.debug("adding group [" + id + "] for role [" + roleId + "]");
}
- RoleManagerLocal roleManager = LookupUtil.getRoleManager();
- roleManager.addLdapGroupsToRole(RequestUtils.getSubject(request), roleId, pendingGroupIds);
+ ldapManager.addLdapGroupsToRole(RequestUtils.getSubject(request), roleId, pendingGroupIds);
log.debug("removing pending group list");
SessionUtils.removeList(session, Constants.PENDING_RESGRPS_SES_ATTR);
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/AddLdapGroupsFormPrepareAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/AddLdapGroupsFormPrepareAction.java
index 39fe62e..6cbbfce 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/AddLdapGroupsFormPrepareAction.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/AddLdapGroupsFormPrepareAction.java
@@ -28,6 +28,7 @@ import java.util.Properties;
import java.util.Set;
import java.util.TreeMap;
+import javax.ejb.EJBException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -55,7 +56,7 @@ import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.authz.RoleManagerLocal;
import org.rhq.enterprise.server.exception.LdapCommunicationException;
import org.rhq.enterprise.server.exception.LdapFilterException;
-import org.rhq.enterprise.server.resource.group.LdapGroupManager;
+import org.rhq.enterprise.server.resource.group.LdapGroupManagerLocal;
import org.rhq.enterprise.server.system.SystemManagerLocal;
import org.rhq.enterprise.server.util.LookupUtil;
@@ -65,6 +66,9 @@ import org.rhq.enterprise.server.util.LookupUtil;
public class AddLdapGroupsFormPrepareAction extends TilesAction {
final String LDAP_GROUP_CACHE = "ldapGroupCache";
+ RoleManagerLocal roleManager = LookupUtil.getRoleManager();
+ LdapGroupManagerLocal ldapManager = LookupUtil.getLdapGroupManager();
+
public ActionForward execute(ComponentContext context, ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception {
Log log = LogFactory.getLog(AddLdapGroupsFormPrepareAction.class.getName());
@@ -111,16 +115,16 @@ public class AddLdapGroupsFormPrepareAction extends TilesAction {
try { //defend against ldap communication runtime difficulties.
if (cachedAvailableLdapGroups == null) {
- allGroups = LdapGroupManager.getInstance().findAvailableGroups();
+ // allGroups = LdapGroupManagerBean.getInstance().findAvailableGroups();
+ allGroups = ldapManager.findAvailableGroups();
} else {//reuse cached.
allGroups = cachedAvailableLdapGroups;
}
//store unmodified list in session.
cachedAvailableLdapGroups = allGroups;
- RoleManagerLocal roleManager = LookupUtil.getRoleManager();
//retrieve currently assigned groups
- assignedList = roleManager.findLdapGroupsByRole(role.getId(), PageControl.getUnlimitedInstance());
+ assignedList = ldapManager.findLdapGroupsByRole(role.getId(), PageControl.getUnlimitedInstance());
//trim already defined from all groups returned.
allGroups = filterExisting(assignedList, allGroups);
@@ -217,6 +221,30 @@ public class AddLdapGroupsFormPrepareAction extends TilesAction {
availableGroups.setTotalSize(groupLookup.size());
availableGroups.setPageControl(pca);
+ } catch (EJBException ejx) {
+ //this is the exception type thrown now that we use SLSB.Local methods
+ // mine out other exceptions
+ Exception cause = ejx.getCausedByException();
+ if (cause == null) {
+ ActionMessages actionMessages = new ActionMessages();
+ actionMessages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("errors.cam.general"));
+ saveErrors(request, actionMessages);
+ } else {
+ if (cause instanceof LdapFilterException) {
+ ActionMessages actionMessages = new ActionMessages();
+ actionMessages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(
+ "admin.role.LdapGroupFilterMessage"));
+ saveErrors(request, actionMessages);
+ } else if (cause instanceof LdapCommunicationException) {
+ ActionMessages actionMessages = new ActionMessages();
+ SystemManagerLocal manager = LookupUtil.getSystemManager();
+ Properties options = manager.getSystemConfiguration();
+ String providerUrl = options.getProperty(RHQConstants.LDAPUrl, "(unavailable)");
+ actionMessages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(
+ "admin.role.LdapCommunicationMessage", providerUrl));
+ saveErrors(request, actionMessages);
+ }
+ }
} catch (LdapFilterException lce) {
ActionMessages actionMessages = new ActionMessages();
actionMessages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("admin.role.LdapGroupFilterMessage"));
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/RemoveLdapGroupsAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/RemoveLdapGroupsAction.java
index fb359c6..48ab1c5 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/RemoveLdapGroupsAction.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/RemoveLdapGroupsAction.java
@@ -31,12 +31,16 @@ import org.rhq.core.util.collection.ArrayUtils;
import org.rhq.enterprise.gui.legacy.Constants;
import org.rhq.enterprise.gui.legacy.action.BaseAction;
import org.rhq.enterprise.gui.legacy.util.RequestUtils;
+import org.rhq.enterprise.server.resource.group.LdapGroupManagerLocal;
import org.rhq.enterprise.server.util.LookupUtil;
/**
* An Action that retrieves data to facilitate display of the form for removing groups to a role.
*/
public class RemoveLdapGroupsAction extends BaseAction {
+
+ LdapGroupManagerLocal ldapManager = LookupUtil.getLdapGroupManager();
+
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception {
Log log = LogFactory.getLog(RemoveLdapGroupsAction.class.getName());
@@ -46,7 +50,7 @@ public class RemoveLdapGroupsAction extends BaseAction {
int[] groupIds = ArrayUtils.unwrapArray(rmForm.getLdapGroups());
log.debug("removing groups " + groupIds + "] for role [" + roleId + "]");
- LookupUtil.getRoleManager().removeLdapGroupsFromRole(RequestUtils.getSubject(request), roleId, groupIds);
+ ldapManager.removeLdapGroupsFromRole(RequestUtils.getSubject(request), roleId, groupIds);
RequestUtils.setConfirmation(request, "admin.role.confirm.RemoveLdapGroups");
return returnSuccess(request, mapping, Constants.ROLE_PARAM, roleId);
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/ViewAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/ViewAction.java
index 3414dab..b2e884e 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/ViewAction.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/ViewAction.java
@@ -45,6 +45,7 @@ import org.rhq.enterprise.gui.legacy.action.WorkflowPrepareAction;
import org.rhq.enterprise.gui.legacy.util.RequestUtils;
import org.rhq.enterprise.gui.util.WebUtility;
import org.rhq.enterprise.server.authz.RoleManagerLocal;
+import org.rhq.enterprise.server.resource.group.LdapGroupManagerLocal;
import org.rhq.enterprise.server.resource.group.ResourceGroupManagerLocal;
import org.rhq.enterprise.server.util.LookupUtil;
@@ -52,6 +53,11 @@ import org.rhq.enterprise.server.util.LookupUtil;
* An Action that retrieves a specific role. This is executed when you view a specific role.
*/
public class ViewAction extends WorkflowPrepareAction {
+
+ LdapGroupManagerLocal ldapManager = LookupUtil.getLdapGroupManager();
+ RoleManagerLocal roleManager = LookupUtil.getRoleManager();
+ ResourceGroupManagerLocal groupManager = LookupUtil.getResourceGroupManager();
+
/**
*/
public ActionForward workflow(ComponentContext context, ActionMapping mapping, ActionForm form,
@@ -75,8 +81,8 @@ public class ViewAction extends WorkflowPrepareAction {
log.trace("group page control: " + pcg);
log.trace("ldap group page control: " + pcldap);
- RoleManagerLocal roleManager = LookupUtil.getRoleManager();
- ResourceGroupManagerLocal groupManager = LookupUtil.getResourceGroupManager();
+ // RoleManagerLocal roleManager = LookupUtil.getRoleManager();
+ // ResourceGroupManagerLocal groupManager = LookupUtil.getResourceGroupManager();
// get all the role permissions
Set<Permission> permissions = roleManager.getPermissions(roleId);
@@ -91,6 +97,7 @@ public class ViewAction extends WorkflowPrepareAction {
// get the subjects attached to the role
log.trace("getting users for role [" + roleId + "]");
+ // PageList<Subject> users = roleManager.findSubjectsByRole(roleId, pcu);
PageList<Subject> users = roleManager.findSubjectsByRole(roleId, pcu);
request.setAttribute(Constants.ROLE_USERS_ATTR, users);
@@ -104,7 +111,7 @@ public class ViewAction extends WorkflowPrepareAction {
request.setAttribute(Constants.NUM_RESGRPS_ATTR, new Integer(groups.getTotalSize()));
}
- PageList<LdapGroup> ldapGroups = roleManager.findLdapGroupsByRole(roleId, pcldap);
+ PageList<LdapGroup> ldapGroups = ldapManager.findLdapGroupsByRole(roleId, pcldap);
request.setAttribute(Constants.ROLE_LDAPGRPS_ATTR, ldapGroups);
if (ldapGroups == null) {
request.setAttribute(Constants.NUM_LDAPGRPS_ATTR, new Integer(0));
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/user/RegisterAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/user/RegisterAction.java
index 9d4ec7a..91980ad 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/user/RegisterAction.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/user/RegisterAction.java
@@ -23,6 +23,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Properties;
+import javax.ejb.EJBException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
@@ -44,10 +45,9 @@ import org.rhq.enterprise.gui.legacy.util.RequestUtils;
import org.rhq.enterprise.gui.legacy.util.SessionUtils;
import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.auth.SubjectManagerLocal;
-import org.rhq.enterprise.server.authz.RoleManagerLocal;
import org.rhq.enterprise.server.exception.LdapCommunicationException;
import org.rhq.enterprise.server.exception.LdapFilterException;
-import org.rhq.enterprise.server.resource.group.LdapGroupManager;
+import org.rhq.enterprise.server.resource.group.LdapGroupManagerLocal;
import org.rhq.enterprise.server.system.SystemManagerLocal;
import org.rhq.enterprise.server.util.LookupUtil;
@@ -55,6 +55,11 @@ import org.rhq.enterprise.server.util.LookupUtil;
* Registers a user. Triggered when authenticated via LDAP.
*/
public class RegisterAction extends BaseAction {
+
+ SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager();
+ SystemManagerLocal systemManager = LookupUtil.getSystemManager();
+ LdapGroupManagerLocal ldapManager = LookupUtil.getLdapGroupManager();
+
/**
* Create the user with the attributes specified in the given <code>NewForm</code> and save it into the session
* attribute <code>Constants.USER_ATTR</code>.
@@ -96,7 +101,6 @@ public class RegisterAction extends BaseAction {
String password = (String) session.getAttribute(Constants.PASSWORD_SES_ATTR);
session.removeAttribute(Constants.PASSWORD_SES_ATTR);
- SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager();
Subject superuser = subjectManager.getOverlord();
// create the subject, but don't add a principal since LDAP will handle authentication
@@ -118,8 +122,7 @@ public class RegisterAction extends BaseAction {
parms.put(Constants.USER_PARAM, newSubject.getId());
//BZ-580127: only do group authz check if one or both of group filter fields is set
- SystemManagerLocal manager = LookupUtil.getSystemManager();
- Properties options = manager.getSystemConfiguration();
+ Properties options = systemManager.getSystemConfiguration();
String groupFilter = (String) options.getProperty(RHQConstants.LDAPGroupFilter, "");
String groupMember = (String) options.getProperty(RHQConstants.LDAPGroupMember, "");
if ((groupFilter.trim().length() > 0) || (groupMember.trim().length() > 0)) {
@@ -127,11 +130,32 @@ public class RegisterAction extends BaseAction {
String provider = LookupUtil.getSystemManager().getSystemConfiguration().getProperty(
RHQConstants.JAASProvider);
if (RHQConstants.LDAPJAASProvider.equals(provider)) {
- List<String> groupNames = new ArrayList(LdapGroupManager.getInstance().findAvailableGroupsFor(
- newSubject.getName()));
- RoleManagerLocal roleManager = LookupUtil.getRoleManager();
- roleManager.assignRolesToLdapSubject(newSubject.getId(), groupNames);
-
+ List<String> groupNames = new ArrayList(ldapManager.findAvailableGroupsFor(newSubject.getName()));
+ ldapManager.assignRolesToLdapSubject(newSubject.getId(), groupNames);
+ }
+ } catch (EJBException ejx) {
+ //this is the exception type thrown now that we use SLSB.Local methods
+ // mine out other exceptions
+ Exception cause = ejx.getCausedByException();
+ if (cause == null) {
+ ActionMessages actionMessages = new ActionMessages();
+ actionMessages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("errors.cam.general"));
+ saveErrors(request, actionMessages);
+ } else {
+ if (cause instanceof LdapFilterException) {
+ ActionMessages actionMessages = new ActionMessages();
+ actionMessages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(
+ "admin.role.LdapGroupFilterMessage"));
+ saveErrors(request, actionMessages);
+ } else if (cause instanceof LdapCommunicationException) {
+ ActionMessages actionMessages = new ActionMessages();
+ SystemManagerLocal manager = LookupUtil.getSystemManager();
+ options = manager.getSystemConfiguration();
+ String providerUrl = options.getProperty(RHQConstants.LDAPUrl, "(unavailable)");
+ actionMessages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(
+ "admin.role.LdapCommunicationMessage", providerUrl));
+ saveErrors(request, actionMessages);
+ }
}
} catch (LdapFilterException lce) {
ActionMessages actionMessages = new ActionMessages();
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerBean.java
index 8e4d96e..00d4c31 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerBean.java
@@ -20,9 +20,7 @@ package org.rhq.enterprise.server.authz;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collections;
import java.util.HashSet;
-import java.util.LinkedList;
import java.util.List;
import java.util.Set;
@@ -40,7 +38,6 @@ import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.authz.Permission;
import org.rhq.core.domain.authz.Role;
import org.rhq.core.domain.criteria.RoleCriteria;
-import org.rhq.core.domain.resource.group.LdapGroup;
import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
@@ -91,29 +88,6 @@ public class RoleManagerBean implements RoleManagerLocal, RoleManagerRemote {
return roles;
}
- @Override
- public PageList<LdapGroup> findLdapGroupsByRole(int roleId, PageControl pageControl) {
- Role role = entityManager.find(Role.class, roleId);
- if (role == null) {
- throw new IllegalArgumentException("Could not find role[" + roleId + "] to lookup ldap Groups on");
- }
- return new PageList<LdapGroup>(role.getLdapGroups(), role.getLdapGroups().size(), pageControl);
- }
-
- public PageList<LdapGroup> findLdapGroups(PageControl pc) {
-
- pc.initDefaultOrderingField("g.name");
-
- String queryName = LdapGroup.QUERY_FIND_ALL;
- Query queryCount = PersistenceUtility.createCountQuery(entityManager, queryName);
- Query query = PersistenceUtility.createQueryWithOrderBy(entityManager, queryName, pc);
-
- long count = (Long) queryCount.getSingleResult();
- // List<Role> roles = query.getResultList();
- List<LdapGroup> groups = query.getResultList();
- return new PageList<LdapGroup>(groups, (int) count, pc);
- }
-
/**
* @see org.rhq.enterprise.server.authz.RoleManagerLocal#findRoles(PageControl)
*/
@@ -466,83 +440,6 @@ public class RoleManagerBean implements RoleManagerLocal, RoleManagerRemote {
}
}
- /**
- * @see org.rhq.enterprise.server.authz.RoleManagerLocal#addResourceGroupsToRole(Subject, int, int[])
- */
- @RequiredPermission(Permission.MANAGE_SECURITY)
- public void addLdapGroupsToRole(Subject subject, int roleId, List<String> groupIds) {
- if ((groupIds != null) && (groupIds.size() > 0)) {
- Role role = entityManager.find(Role.class, roleId);
- if (role == null) {
- throw new IllegalArgumentException("Could not find role[" + roleId + "] to add resourceGroups to");
- }
- role.getLdapGroups().size(); // load them in
-
- for (String groupId : groupIds) {
- LdapGroup group = new LdapGroup();
- group.setName(groupId);
- if (role == null) {
- throw new IllegalArgumentException("Tried to add ldapGroup[" + groupId + "] to role[" + roleId
- + "], but resourceGroup was not found");
- }
- role.addLdapGroup(group);
- }
- }
- }
-
- /**
- * @see org.rhq.enterprise.server.authz.RoleManagerLocal#removeLdapGroupsFromRole(Subject, int, int[])
- */
-
- @RequiredPermission(Permission.MANAGE_SECURITY)
- public void removeLdapGroupsFromRole(Subject subject, int roleId, int[] groupIds) {
- if ((groupIds != null) && (groupIds.length > 0)) {
- Role role = entityManager.find(Role.class, roleId);
- if (role == null) {
- throw new IllegalArgumentException("Could not find role[" + roleId + "] to remove resourceGroups from");
- }
- role.getLdapGroups().size(); // load them in
-
- for (Integer groupId : groupIds) {
- LdapGroup doomedGroup = entityManager.find(LdapGroup.class, groupId);
- if (doomedGroup == null) {
- throw new IllegalArgumentException("Tried to remove doomedGroup[" + groupId + "] from role["
- + roleId + "], but subject was not found");
- }
- role.removeLdapGroup(doomedGroup);
- }
-
- Query purgeQuery = entityManager.createNamedQuery(LdapGroup.DELETE_BY_ID);
-
- List<Integer> ids = new LinkedList<Integer>();
- for (int i : groupIds) {
- ids.add(i);
- }
- purgeQuery.setParameter("ids", ids);
- purgeQuery.executeUpdate();
- }
- }
-
- private List<Role> findRolesByLdapGroupNames(List<String> ldapGroupNames) {
- if (ldapGroupNames.isEmpty()) {
- return Collections.EMPTY_LIST;
- }
- Query query = entityManager.createNamedQuery(LdapGroup.FIND_BY_ROLES_GROUP_NAMES);
- query.setParameter("names", ldapGroupNames);
- return (List<Role>) query.getResultList();
- }
-
- public void assignRolesToLdapSubject(int subjectId, List<String> ldapGroupNames) {
- Subject sub = entityManager.find(Subject.class, subjectId);
- List<Role> roles = findRolesByLdapGroupNames(ldapGroupNames);
- sub.getRoles().clear();
- sub.getLdapRoles().clear();
- for (Role role : roles) {
- sub.addRole(role);
- sub.addLdapRole(role);
- }
- }
-
private void processDependentPermissions(Role role) {
/*
* if you can control user/roles, then you can give yourself permissions, too; so we might as well
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerLocal.java
index b89020f..58f962a 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerLocal.java
@@ -18,7 +18,6 @@
*/
package org.rhq.enterprise.server.authz;
-import java.util.List;
import java.util.Set;
import javax.ejb.Local;
@@ -27,7 +26,6 @@ import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.authz.Permission;
import org.rhq.core.domain.authz.Role;
import org.rhq.core.domain.criteria.RoleCriteria;
-import org.rhq.core.domain.resource.group.LdapGroup;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
@@ -161,8 +159,6 @@ public interface RoleManagerLocal {
Role getRole(Subject subject, int roleId);
- PageList<LdapGroup> findLdapGroupsByRole(int roleId, PageControl pageControl);
-
PageList<Role> findSubjectAssignedRoles(Subject subject, int subjectId, PageControl pc);
//This is a proxy of getAvailableRolesForSubject but without pendingRoleIds as required by remote spec
@@ -202,8 +198,6 @@ public interface RoleManagerLocal {
void addRolesToResourceGroup(Subject subject, int groupId, int[] roleIds);
- void addLdapGroupsToRole(Subject subject, int roleId, List<String> groupIds);
-
/**
* Removes the given resource groups from the given role.
*
@@ -215,11 +209,6 @@ public interface RoleManagerLocal {
void removeRolesFromResourceGroup(Subject subject, int groupId, int[] roleIds);
- void removeLdapGroupsFromRole(Subject subject, int roleId, int[] groupIds);
-
PageList<Role> findRolesByCriteria(Subject subject, RoleCriteria criteria);
- void assignRolesToLdapSubject(int subjectId, List<String> ldapGroupNames);
-
- PageList<LdapGroup> findLdapGroups(PageControl pc);
}
\ No newline at end of file
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/LdapLoginModule.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/LdapLoginModule.java
index d6fcaa7..d6e6ae8 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/LdapLoginModule.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/LdapLoginModule.java
@@ -45,7 +45,7 @@ import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.server.auth.SubjectManagerLocal;
import org.rhq.enterprise.server.authz.RoleManagerLocal;
-import org.rhq.enterprise.server.resource.group.LdapGroupManager;
+import org.rhq.enterprise.server.resource.group.LdapGroupManagerLocal;
import org.rhq.enterprise.server.util.LookupUtil;
import org.rhq.enterprise.server.util.security.UntrustedSSLSocketFactory;
@@ -94,6 +94,8 @@ import org.rhq.enterprise.server.util.security.UntrustedSSLSocketFactory;
public class LdapLoginModule extends UsernamePasswordLoginModule {
private Log log = LogFactory.getLog(LdapLoginModule.class);
+ LdapGroupManagerLocal ldapManager = LookupUtil.getLdapGroupManager();
+
// The delimimiter to use when specifiying multiple BaseDN's.
private static final String BASEDN_DELIMITER = ";";
@@ -218,11 +220,11 @@ public class LdapLoginModule extends UsernamePasswordLoginModule {
//BUT still must always return true as authz is handled by RHQ if roles/groups correct
//retrieve all ldap groups that this user is authorized for based on ldap group filter and group member settings
- Set<String> authorizedLdapGroups = LdapGroupManager.getInstance().findAvailableGroupsFor(userName);
+ Set<String> authorizedLdapGroups = ldapManager.findAvailableGroupsFor(userName);
RoleManagerLocal roleManager = LookupUtil.getRoleManager();
//find all currently mapped ldap groups
- PageList<LdapGroup> allCurrentLdapGroupsRegistered = roleManager.findLdapGroups(PageControl
+ PageList<LdapGroup> allCurrentLdapGroupsRegistered = ldapManager.findLdapGroups(PageControl
.getUnlimitedInstance());
//find all roles for currently mapped ldap groups.
@@ -239,7 +241,7 @@ public class LdapLoginModule extends UsernamePasswordLoginModule {
//else add this subject back to all AuthoriziedLdapGroups
//lookup all roles that map to the authorizedLdapGroup names
List authorizedList = new ArrayList(authorizedLdapGroups);
- roleManager.assignRolesToLdapSubject(ldapSubject.getId(), authorizedList);
+ ldapManager.assignRolesToLdapSubject(ldapSubject.getId(), authorizedList);
}
return true;
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManager.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManager.java
deleted file mode 100644
index e372777..0000000
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManager.java
+++ /dev/null
@@ -1,304 +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.enterprise.server.resource.group;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-
-import javax.naming.Context;
-import javax.naming.NamingEnumeration;
-import javax.naming.NamingException;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.InvalidSearchFilterException;
-import javax.naming.directory.SearchControls;
-import javax.naming.directory.SearchResult;
-import javax.naming.ldap.InitialLdapContext;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.rhq.enterprise.server.RHQConstants;
-import org.rhq.enterprise.server.exception.LdapCommunicationException;
-import org.rhq.enterprise.server.exception.LdapFilterException;
-import org.rhq.enterprise.server.system.SystemManagerLocal;
-import org.rhq.enterprise.server.util.LookupUtil;
-import org.rhq.enterprise.server.util.security.UntrustedSSLSocketFactory;
-
-/**
- * @author paji
- */
-public class LdapGroupManager {
- private static final LdapGroupManager INSTANCE = new LdapGroupManager();
- private static final String BASEDN_DELIMITER = ";";
- private Log log = LogFactory.getLog(LdapGroupManager.class);
-
- private LdapGroupManager() {
- }
-
- public static LdapGroupManager getInstance() {
- return INSTANCE;
- }
-
- public Set<Map<String, String>> findAvailableGroups() {
- SystemManagerLocal manager = LookupUtil.getSystemManager();
-
- Properties options = manager.getSystemConfiguration();
- String groupFilter = (String) options.get(RHQConstants.LDAPGroupFilter);
- String filter = String.format("(%s)", groupFilter);
-
- return buildGroup(options, filter);
- }
-
- public Set<String> findAvailableGroupsFor(String userName) {
- SystemManagerLocal manager = LookupUtil.getSystemManager();
- Properties options = manager.getSystemConfiguration();
- String groupFilter = (String) options.getProperty(RHQConstants.LDAPGroupFilter, "");
- String groupMember = (String) options.getProperty(RHQConstants.LDAPGroupMember, "");
- String userDN = getUserDN(options, userName);
- //TODO: spinder 4/21/10 put in error/debug logging messages for badly formatted filter combinations
- String filter = "";
- //form assumes examples where groupFilter is like 'objecclass=groupOfNames' and groupMember is 'member'
- // to produce ldaf filter like (&(objecclass=groupOfNames)(member=cn=Administrator,ou=People,dc=test,dc=com))
- filter = String.format("(&(%s)(%s=%s))", groupFilter, groupMember, userDN);
-
- Set<Map<String, String>> matched = buildGroup(options, filter);
-
- Set<String> ldapSet = new HashSet<String>();
- for (Map<String, String> match : matched) {
- ldapSet.add(match.get("id"));
- }
- return ldapSet;
- }
-
- private String getUserDN(Properties options, String userName) {
- // Load our LDAP specific properties
- Properties env = getProperties(options);
-
- // Load the BaseDN
- // Load the BaseDN
- String baseDN = (String) options.get(RHQConstants.LDAPBaseDN);
-
- // Load the LoginProperty
- String loginProperty = (String) options.get(RHQConstants.LDAPLoginProperty);
- if (loginProperty == null) {
- // Use the default
- loginProperty = "cn";
- }
- // Load any information we may need to bind
- String bindDN = (String) options.get(RHQConstants.LDAPBindDN);
- String bindPW = (String) options.get(RHQConstants.LDAPBindPW);
-
- // Load any search filter
- String searchFilter = (String) options.get(RHQConstants.LDAPFilter);
- if (bindDN != null) {
- env.setProperty(Context.SECURITY_PRINCIPAL, bindDN);
- env.setProperty(Context.SECURITY_CREDENTIALS, bindPW);
- env.setProperty(Context.SECURITY_AUTHENTICATION, "simple");
- }
-
- try {
- InitialLdapContext ctx = new InitialLdapContext(env, null);
- SearchControls searchControls = getSearchControls();
-
- // Add the search filter if specified. This only allows for a single search filter.. i.e. foo=bar.
- String filter;
- if ((searchFilter != null) && (searchFilter.length() != 0)) {
- filter = "(&(" + loginProperty + "=" + userName + ")" + "(" + searchFilter + "))";
- } else {
- filter = "(" + loginProperty + "=" + userName + ")";
- }
-
- log.debug("Using LDAP filter=" + filter);
-
- // Loop through each configured base DN. It may be useful
- // in the future to allow for a filter to be configured for
- // each BaseDN, but for now the filter will apply to all.
- String[] baseDNs = baseDN.split(BASEDN_DELIMITER);
- for (int x = 0; x < baseDNs.length; x++) {
- NamingEnumeration answer = ctx.search(baseDNs[x], filter, searchControls);
- if (!answer.hasMoreElements()) { //BZ:582471- ldap api bug change
- log.debug("User " + userName + " not found for BaseDN " + baseDNs[x]);
- // Nothing found for this DN, move to the next one if we have one.
- continue;
- }
-
- // We use the first match
- SearchResult si = (SearchResult) answer.next();
-
- // Construct the UserDN
- String userDN = si.getName() + "," + baseDNs[x];
- return userDN;
- }
-
- // If we try all the BaseDN's and have not found a match, return false
- return "";
- } catch (NamingException e) {
- throw new RuntimeException(e);
- }
- }
-
- /**
- * @throws NamingException
- * @see org.jboss.security.auth.spi.UsernamePasswordLoginModule#validatePassword(java.lang.String,java.lang.String)
- */
- protected Set<Map<String, String>> buildGroup(Properties options, String filter) {
- Set<Map<String, String>> ret = new HashSet<Map<String, String>>();
- // Load our LDAP specific properties
- Properties env = getProperties(options);
-
- // Load the BaseDN
- String baseDN = (String) options.get(RHQConstants.LDAPBaseDN);
-
- // Load the LoginProperty
- String loginProperty = (String) options.get(RHQConstants.LDAPLoginProperty);
- if (loginProperty == null) {
- // Use the default
- loginProperty = "cn";
- }
- // Load any information we may need to bind
- String bindDN = (String) options.get(RHQConstants.LDAPBindDN);
- String bindPW = (String) options.get(RHQConstants.LDAPBindPW);
- if (bindDN != null) {
- env.setProperty(Context.SECURITY_PRINCIPAL, bindDN);
- env.setProperty(Context.SECURITY_CREDENTIALS, bindPW);
- env.setProperty(Context.SECURITY_AUTHENTICATION, "simple");
- }
- try {
- InitialLdapContext ctx = new InitialLdapContext(env, null);
- SearchControls searchControls = getSearchControls();
- /*String filter = "(&(objectclass=groupOfUniqueNames)(uniqueMember=uid=" + userName
- + ",ou=People, dc=rhndev, dc=redhat, dc=com))";*/
-
- // Loop through each configured base DN. It may be useful
- // in the future to allow for a filter to be configured for
- // each BaseDN, but for now the filter will apply to all.
- String[] baseDNs = baseDN.split(BASEDN_DELIMITER);
-
- for (int x = 0; x < baseDNs.length; x++) {
- NamingEnumeration answer = ctx.search(baseDNs[x], filter, searchControls);
- boolean ldapApiEnumerationBugEncountered = false;
- while ((!ldapApiEnumerationBugEncountered) && answer.hasMoreElements()) {//BZ:582471- ldap api bug change
- // We use the first match
- SearchResult si = null;
- try {
- si = (SearchResult) answer.next();
- } catch (NullPointerException npe) {
- ldapApiEnumerationBugEncountered = true;
- break;
- }
- Map<String, String> entry = new HashMap<String, String>();
- String name = (String) si.getAttributes().get("cn").get();
- name = name.trim();
- Attribute desc = si.getAttributes().get("description");
- String description = desc != null ? (String) desc.get() : "";
- description = description.trim();
- entry.put("id", name);
- entry.put("name", name);
- entry.put("description", description);
- ret.add(entry);
- }
- }
- } catch (NamingException e) {
- if (e instanceof InvalidSearchFilterException) {
- InvalidSearchFilterException fException = (InvalidSearchFilterException) e;
- String message = "The ldap group filter defined is invalid ";
- log.error(message, fException);
- throw new LdapFilterException(message + " " + fException.getMessage());
- }
- //TODO: check for ldap connection/unavailable/etc. exceptions.
- else {
- log.error("LDAP communication error: " + e.getMessage(), e);
- throw new LdapCommunicationException(e);
- }
- }
-
- return ret;
- }
-
- /**
- * Load a default set of properties to use when connecting to the LDAP server. If basic authentication is needed,
- * the caller must set Context.SECURITY_PRINCIPAL, Context.SECURITY_CREDENTIALS and Context.SECURITY_AUTHENTICATION
- * appropriately.
- *
- * @return properties that are to be used when connecting to LDAP server
- */
- private Properties getProperties(Properties options) {
- Properties env = new Properties(options);
- // Set our default factory name if one is not given
- String factoryName = env.getProperty(RHQConstants.LDAPFactory);
- env.setProperty(Context.INITIAL_CONTEXT_FACTORY, factoryName);
-
- // Setup SSL if requested
- String protocol = env.getProperty(RHQConstants.LDAPProtocol);
- if ((protocol != null) && protocol.equals("ssl")) {
- String ldapSocketFactory = env.getProperty("java.naming.ldap.factory.socket");
- if (ldapSocketFactory == null) {
- env.put("java.naming.ldap.factory.socket", UntrustedSSLSocketFactory.class.getName());
- }
- env.put(Context.SECURITY_PROTOCOL, "ssl");
- }
-
- // Set the LDAP url
- String providerUrl = env.getProperty(RHQConstants.LDAPUrl);
- if (providerUrl == null) {
- providerUrl = "ldap://localhost:" + (((protocol != null) && protocol.equals("ssl")) ? "636" : "389");
- }
-
- env.setProperty(Context.PROVIDER_URL, providerUrl);
-
- // Follow referrals automatically
- env.setProperty(Context.REFERRAL, "ignore"); //BZ:582471- active directory query change
-
- return env;
- }
-
- /**
- * A simple method to construct a SearchControls object for use when doing LDAP searches. All of the defaults are
- * used, with the exception of the scope, which is set to SUBTREE rather than the default of ONE_LEVEL
- *
- * @return controls what is searched in LDAP
- */
- private SearchControls getSearchControls() {
- // Set the scope to subtree, default is one-level
- int scope = SearchControls.SUBTREE_SCOPE;
-
- // No limit on the time waiting for a response
- int timeLimit = 0;
-
- // No limit on the number of entries returned
- long countLimit = 0;
-
- // Attributes to return.
- String[] returnedAttributes = null;
-
- // Don't return the object
- boolean returnObject = false;
-
- // No dereferencing during the search
- boolean deference = false;
-
- SearchControls constraints = new SearchControls(scope, countLimit, timeLimit, returnedAttributes, returnObject,
- deference);
- return constraints;
- }
-}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManagerBean.java
new file mode 100644
index 0000000..63e36db
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManagerBean.java
@@ -0,0 +1,426 @@
+/*
+ * 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.resource.group;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import javax.ejb.EJB;
+import javax.ejb.Stateless;
+import javax.naming.Context;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.InvalidSearchFilterException;
+import javax.naming.directory.SearchControls;
+import javax.naming.directory.SearchResult;
+import javax.naming.ldap.InitialLdapContext;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.Query;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.authz.Permission;
+import org.rhq.core.domain.authz.Role;
+import org.rhq.core.domain.resource.group.LdapGroup;
+import org.rhq.core.domain.util.PageControl;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.core.server.PersistenceUtility;
+import org.rhq.enterprise.server.RHQConstants;
+import org.rhq.enterprise.server.auth.SubjectManagerLocal;
+import org.rhq.enterprise.server.authz.RequiredPermission;
+import org.rhq.enterprise.server.exception.LdapCommunicationException;
+import org.rhq.enterprise.server.exception.LdapFilterException;
+import org.rhq.enterprise.server.system.SystemManagerLocal;
+import org.rhq.enterprise.server.util.security.UntrustedSSLSocketFactory;
+
+/**
+ * This bean provides functionality to manipulate the ldap auth/authz funcitonality.
+ * That is, adding/modifying/deleting ldap group/users and their
+ * associated subjects and permissions are performed by this manager.
+ * @author paji
+ * @author Simeon Pinder
+ */
+@Stateless
+public class LdapGroupManagerBean implements LdapGroupManagerLocal {
+
+ // private static final LdapGroupManagerBean INSTANCE = new LdapGroupManagerBean();
+ private Log log = LogFactory.getLog(LdapGroupManagerBean.class);
+
+ private static final String BASEDN_DELIMITER = ";";
+
+ @PersistenceContext(unitName = RHQConstants.PERSISTENCE_UNIT_NAME)
+ private EntityManager entityManager;
+
+ @EJB
+ private SubjectManagerLocal subjectManager;
+
+ @EJB
+ private SystemManagerLocal systemManager;
+
+ public Set<Map<String, String>> findAvailableGroups() {
+ Properties options = systemManager.getSystemConfiguration();
+ String groupFilter = (String) options.get(RHQConstants.LDAPGroupFilter);
+ String filter = String.format("(%s)", groupFilter);
+
+ return buildGroup(options, filter);
+ }
+
+ public Set<String> findAvailableGroupsFor(String userName) {
+ Properties options = systemManager.getSystemConfiguration();
+ String groupFilter = (String) options.getProperty(RHQConstants.LDAPGroupFilter, "");
+ String groupMember = (String) options.getProperty(RHQConstants.LDAPGroupMember, "");
+ String userDN = getUserDN(options, userName);
+ //TODO: spinder 4/21/10 put in error/debug logging messages for badly formatted filter combinations
+ String filter = "";
+ //form assumes examples where groupFilter is like 'objecclass=groupOfNames' and groupMember is 'member'
+ // to produce ldaf filter like (&(objecclass=groupOfNames)(member=cn=Administrator,ou=People,dc=test,dc=com))
+ filter = String.format("(&(%s)(%s=%s))", groupFilter, groupMember, userDN);
+
+ Set<Map<String, String>> matched = buildGroup(options, filter);
+
+ Set<String> ldapSet = new HashSet<String>();
+ for (Map<String, String> match : matched) {
+ ldapSet.add(match.get("id"));
+ }
+ return ldapSet;
+ }
+
+ /**
+ * @see org.rhq.enterprise.server.authz.RoleManagerLocal#addResourceGroupsToRole(Subject, int, int[])
+ */
+ @RequiredPermission(Permission.MANAGE_SECURITY)
+ public void addLdapGroupsToRole(Subject subject, int roleId, List<String> groupIds) {
+ if ((groupIds != null) && (groupIds.size() > 0)) {
+ Role role = entityManager.find(Role.class, roleId);
+ if (role == null) {
+ throw new IllegalArgumentException("Could not find role[" + roleId + "] to add resourceGroups to");
+ }
+ role.getLdapGroups().size(); // load them in
+
+ for (String groupId : groupIds) {
+ LdapGroup group = new LdapGroup();
+ group.setName(groupId);
+ if (role == null) {
+ throw new IllegalArgumentException("Tried to add ldapGroup[" + groupId + "] to role[" + roleId
+ + "], but resourceGroup was not found");
+ }
+ role.addLdapGroup(group);
+ }
+ }
+ }
+
+ /**
+ * @see org.rhq.enterprise.server.authz.RoleManagerLocal#removeLdapGroupsFromRole(Subject, int, int[])
+ */
+
+ @RequiredPermission(Permission.MANAGE_SECURITY)
+ public void removeLdapGroupsFromRole(Subject subject, int roleId, int[] groupIds) {
+ if ((groupIds != null) && (groupIds.length > 0)) {
+ Role role = entityManager.find(Role.class, roleId);
+ if (role == null) {
+ throw new IllegalArgumentException("Could not find role[" + roleId + "] to remove resourceGroups from");
+ }
+ role.getLdapGroups().size(); // load them in
+
+ for (Integer groupId : groupIds) {
+ LdapGroup doomedGroup = entityManager.find(LdapGroup.class, groupId);
+ if (doomedGroup == null) {
+ throw new IllegalArgumentException("Tried to remove doomedGroup[" + groupId + "] from role["
+ + roleId + "], but subject was not found");
+ }
+ role.removeLdapGroup(doomedGroup);
+ }
+
+ Query purgeQuery = entityManager.createNamedQuery(LdapGroup.DELETE_BY_ID);
+
+ List<Integer> ids = new LinkedList<Integer>();
+ for (int i : groupIds) {
+ ids.add(i);
+ }
+ purgeQuery.setParameter("ids", ids);
+ purgeQuery.executeUpdate();
+ }
+ }
+
+ private List<Role> findRolesByLdapGroupNames(List<String> ldapGroupNames) {
+ if (ldapGroupNames.isEmpty()) {
+ return Collections.EMPTY_LIST;
+ }
+ Query query = entityManager.createNamedQuery(LdapGroup.FIND_BY_ROLES_GROUP_NAMES);
+ query.setParameter("names", ldapGroupNames);
+ return (List<Role>) query.getResultList();
+ }
+
+ public void assignRolesToLdapSubject(int subjectId, List<String> ldapGroupNames) {
+ Subject sub = entityManager.find(Subject.class, subjectId);
+ List<Role> roles = findRolesByLdapGroupNames(ldapGroupNames);
+ sub.getRoles().clear();
+ sub.getLdapRoles().clear();
+ for (Role role : roles) {
+ sub.addRole(role);
+ sub.addLdapRole(role);
+ }
+ }
+
+ @Override
+ public PageList<LdapGroup> findLdapGroupsByRole(int roleId, PageControl pageControl) {
+ Role role = entityManager.find(Role.class, roleId);
+ if (role == null) {
+ throw new IllegalArgumentException("Could not find role[" + roleId + "] to lookup ldap Groups on");
+ }
+ return new PageList<LdapGroup>(role.getLdapGroups(), role.getLdapGroups().size(), pageControl);
+ }
+
+ public PageList<LdapGroup> findLdapGroups(PageControl pc) {
+
+ pc.initDefaultOrderingField("g.name");
+
+ String queryName = LdapGroup.QUERY_FIND_ALL;
+ Query queryCount = PersistenceUtility.createCountQuery(entityManager, queryName);
+ Query query = PersistenceUtility.createQueryWithOrderBy(entityManager, queryName, pc);
+
+ long count = (Long) queryCount.getSingleResult();
+ // List<Role> roles = query.getResultList();
+ List<LdapGroup> groups = query.getResultList();
+ return new PageList<LdapGroup>(groups, (int) count, pc);
+ }
+
+ private String getUserDN(Properties options, String userName) {
+ // Load our LDAP specific properties
+ Properties env = getProperties(options);
+
+ // Load the BaseDN
+ // Load the BaseDN
+ String baseDN = (String) options.get(RHQConstants.LDAPBaseDN);
+
+ // Load the LoginProperty
+ String loginProperty = (String) options.get(RHQConstants.LDAPLoginProperty);
+ if (loginProperty == null) {
+ // Use the default
+ loginProperty = "cn";
+ }
+ // Load any information we may need to bind
+ String bindDN = (String) options.get(RHQConstants.LDAPBindDN);
+ String bindPW = (String) options.get(RHQConstants.LDAPBindPW);
+
+ // Load any search filter
+ String searchFilter = (String) options.get(RHQConstants.LDAPFilter);
+ if (bindDN != null) {
+ env.setProperty(Context.SECURITY_PRINCIPAL, bindDN);
+ env.setProperty(Context.SECURITY_CREDENTIALS, bindPW);
+ env.setProperty(Context.SECURITY_AUTHENTICATION, "simple");
+ }
+
+ try {
+ InitialLdapContext ctx = new InitialLdapContext(env, null);
+ SearchControls searchControls = getSearchControls();
+
+ // Add the search filter if specified. This only allows for a single search filter.. i.e. foo=bar.
+ String filter;
+ if ((searchFilter != null) && (searchFilter.length() != 0)) {
+ filter = "(&(" + loginProperty + "=" + userName + ")" + "(" + searchFilter + "))";
+ } else {
+ filter = "(" + loginProperty + "=" + userName + ")";
+ }
+
+ log.debug("Using LDAP filter=" + filter);
+
+ // Loop through each configured base DN. It may be useful
+ // in the future to allow for a filter to be configured for
+ // each BaseDN, but for now the filter will apply to all.
+ String[] baseDNs = baseDN.split(BASEDN_DELIMITER);
+ for (int x = 0; x < baseDNs.length; x++) {
+ NamingEnumeration answer = ctx.search(baseDNs[x], filter, searchControls);
+ if (!answer.hasMoreElements()) { //BZ:582471- ldap api bug change
+ log.debug("User " + userName + " not found for BaseDN " + baseDNs[x]);
+ // Nothing found for this DN, move to the next one if we have one.
+ continue;
+ }
+
+ // We use the first match
+ SearchResult si = (SearchResult) answer.next();
+
+ // Construct the UserDN
+ String userDN = si.getName() + "," + baseDNs[x];
+ return userDN;
+ }
+
+ // If we try all the BaseDN's and have not found a match, return false
+ return "";
+ } catch (NamingException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * @throws NamingException
+ * @see org.jboss.security.auth.spi.UsernamePasswordLoginModule#validatePassword(java.lang.String,java.lang.String)
+ */
+ protected Set<Map<String, String>> buildGroup(Properties options, String filter) {
+ Set<Map<String, String>> ret = new HashSet<Map<String, String>>();
+ // Load our LDAP specific properties
+ Properties env = getProperties(options);
+
+ // Load the BaseDN
+ String baseDN = (String) options.get(RHQConstants.LDAPBaseDN);
+
+ // Load the LoginProperty
+ String loginProperty = (String) options.get(RHQConstants.LDAPLoginProperty);
+ if (loginProperty == null) {
+ // Use the default
+ loginProperty = "cn";
+ }
+ // Load any information we may need to bind
+ String bindDN = (String) options.get(RHQConstants.LDAPBindDN);
+ String bindPW = (String) options.get(RHQConstants.LDAPBindPW);
+ if (bindDN != null) {
+ env.setProperty(Context.SECURITY_PRINCIPAL, bindDN);
+ env.setProperty(Context.SECURITY_CREDENTIALS, bindPW);
+ env.setProperty(Context.SECURITY_AUTHENTICATION, "simple");
+ }
+ try {
+ InitialLdapContext ctx = new InitialLdapContext(env, null);
+ SearchControls searchControls = getSearchControls();
+ /*String filter = "(&(objectclass=groupOfUniqueNames)(uniqueMember=uid=" + userName
+ + ",ou=People, dc=rhndev, dc=redhat, dc=com))";*/
+
+ // Loop through each configured base DN. It may be useful
+ // in the future to allow for a filter to be configured for
+ // each BaseDN, but for now the filter will apply to all.
+ String[] baseDNs = baseDN.split(BASEDN_DELIMITER);
+
+ for (int x = 0; x < baseDNs.length; x++) {
+ NamingEnumeration answer = ctx.search(baseDNs[x], filter, searchControls);
+ boolean ldapApiEnumerationBugEncountered = false;
+ while ((!ldapApiEnumerationBugEncountered) && answer.hasMoreElements()) {//BZ:582471- ldap api bug change
+ // We use the first match
+ SearchResult si = null;
+ try {
+ si = (SearchResult) answer.next();
+ } catch (NullPointerException npe) {
+ ldapApiEnumerationBugEncountered = true;
+ break;
+ }
+ Map<String, String> entry = new HashMap<String, String>();
+ String name = (String) si.getAttributes().get("cn").get();
+ name = name.trim();
+ Attribute desc = si.getAttributes().get("description");
+ String description = desc != null ? (String) desc.get() : "";
+ description = description.trim();
+ entry.put("id", name);
+ entry.put("name", name);
+ entry.put("description", description);
+ ret.add(entry);
+ }
+ }
+ } catch (NamingException e) {
+ if (e instanceof InvalidSearchFilterException) {
+ InvalidSearchFilterException fException = (InvalidSearchFilterException) e;
+ String message = "The ldap group filter defined is invalid ";
+ log.error(message, fException);
+ throw new LdapFilterException(message + " " + fException.getMessage());
+ }
+ //TODO: check for ldap connection/unavailable/etc. exceptions.
+ else {
+ log.error("LDAP communication error: " + e.getMessage(), e);
+ throw new LdapCommunicationException(e);
+ }
+ }
+
+ return ret;
+ }
+
+ /**
+ * Load a default set of properties to use when connecting to the LDAP server. If basic authentication is needed,
+ * the caller must set Context.SECURITY_PRINCIPAL, Context.SECURITY_CREDENTIALS and Context.SECURITY_AUTHENTICATION
+ * appropriately.
+ *
+ * @return properties that are to be used when connecting to LDAP server
+ */
+ private Properties getProperties(Properties options) {
+ Properties env = new Properties(options);
+ // Set our default factory name if one is not given
+ String factoryName = env.getProperty(RHQConstants.LDAPFactory);
+ env.setProperty(Context.INITIAL_CONTEXT_FACTORY, factoryName);
+
+ // Setup SSL if requested
+ String protocol = env.getProperty(RHQConstants.LDAPProtocol);
+ if ((protocol != null) && protocol.equals("ssl")) {
+ String ldapSocketFactory = env.getProperty("java.naming.ldap.factory.socket");
+ if (ldapSocketFactory == null) {
+ env.put("java.naming.ldap.factory.socket", UntrustedSSLSocketFactory.class.getName());
+ }
+ env.put(Context.SECURITY_PROTOCOL, "ssl");
+ }
+
+ // Set the LDAP url
+ String providerUrl = env.getProperty(RHQConstants.LDAPUrl);
+ if (providerUrl == null) {
+ providerUrl = "ldap://localhost:" + (((protocol != null) && protocol.equals("ssl")) ? "636" : "389");
+ }
+
+ env.setProperty(Context.PROVIDER_URL, providerUrl);
+
+ // Follow referrals automatically
+ env.setProperty(Context.REFERRAL, "ignore"); //BZ:582471- active directory query change
+
+ return env;
+ }
+
+ /**
+ * A simple method to construct a SearchControls object for use when doing LDAP searches. All of the defaults are
+ * used, with the exception of the scope, which is set to SUBTREE rather than the default of ONE_LEVEL
+ *
+ * @return controls what is searched in LDAP
+ */
+ private SearchControls getSearchControls() {
+ // Set the scope to subtree, default is one-level
+ int scope = SearchControls.SUBTREE_SCOPE;
+
+ // No limit on the time waiting for a response
+ int timeLimit = 0;
+
+ // No limit on the number of entries returned
+ long countLimit = 0;
+
+ // Attributes to return.
+ String[] returnedAttributes = null;
+
+ // Don't return the object
+ boolean returnObject = false;
+
+ // No dereferencing during the search
+ boolean deference = false;
+
+ SearchControls constraints = new SearchControls(scope, countLimit, timeLimit, returnedAttributes, returnObject,
+ deference);
+ return constraints;
+ }
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManagerLocal.java
new file mode 100644
index 0000000..6709b32
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManagerLocal.java
@@ -0,0 +1,53 @@
+/*
+ * 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.server.resource.group;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.ejb.Local;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.resource.group.LdapGroup;
+import org.rhq.core.domain.util.PageControl;
+import org.rhq.core.domain.util.PageList;
+
+/**
+ * A manager that provides methods for creating, updating, deleting, and querying {@link LdapGroup}s.
+ *
+ * @author Simeon Pinder
+ */
+@Local
+public interface LdapGroupManagerLocal {
+
+ PageList<LdapGroup> findLdapGroupsByRole(int roleId, PageControl pageControl);
+
+ PageList<LdapGroup> findLdapGroups(PageControl pc);
+
+ void addLdapGroupsToRole(Subject subject, int roleId, List<String> groupIds);
+
+ void removeLdapGroupsFromRole(Subject subject, int roleId, int[] groupIds);
+
+ void assignRolesToLdapSubject(int subjectId, List<String> ldapGroupNames);
+
+ Set<Map<String, String>> findAvailableGroups();
+
+ Set<String> findAvailableGroupsFor(String userName);
+}
\ No newline at end of file
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
index c21526a..e5171e9 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
@@ -155,6 +155,8 @@ import org.rhq.enterprise.server.resource.ResourceTypeManagerLocal;
import org.rhq.enterprise.server.resource.ResourceTypeManagerRemote;
import org.rhq.enterprise.server.resource.cluster.ClusterManagerBean;
import org.rhq.enterprise.server.resource.cluster.ClusterManagerLocal;
+import org.rhq.enterprise.server.resource.group.LdapGroupManagerBean;
+import org.rhq.enterprise.server.resource.group.LdapGroupManagerLocal;
import org.rhq.enterprise.server.resource.group.ResourceGroupManagerBean;
import org.rhq.enterprise.server.resource.group.ResourceGroupManagerLocal;
import org.rhq.enterprise.server.resource.group.definition.GroupDefinitionExpressionBuilderManagerBean;
@@ -655,4 +657,8 @@ public final class LookupUtil {
return lookupLocal(DataAccessManagerBean.class);
}
+ public static LdapGroupManagerLocal getLdapGroupManager() {
+ return lookupLocal(LdapGroupManagerBean.class);
+ }
+
}
\ No newline at end of file
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/authz/test/RoleManagerBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/authz/test/RoleManagerBeanTest.java
index 2315ee8..c0ae4d9 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/authz/test/RoleManagerBeanTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/authz/test/RoleManagerBeanTest.java
@@ -33,6 +33,7 @@ import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.server.auth.SubjectManagerLocal;
import org.rhq.enterprise.server.authz.PermissionException;
import org.rhq.enterprise.server.authz.RoleManagerLocal;
+import org.rhq.enterprise.server.resource.group.LdapGroupManagerLocal;
import org.rhq.enterprise.server.test.AbstractEJB3Test;
import org.rhq.enterprise.server.util.LookupUtil;
@@ -43,6 +44,7 @@ import org.rhq.enterprise.server.util.LookupUtil;
public class RoleManagerBeanTest extends AbstractEJB3Test {
private SubjectManagerLocal subjectManager;
private RoleManagerLocal roleManager;
+ private LdapGroupManagerLocal ldapManager;
/**
* Prepares things for the entire test class.
@@ -51,6 +53,7 @@ public class RoleManagerBeanTest extends AbstractEJB3Test {
public void beforeClass() {
roleManager = LookupUtil.getRoleManager();
subjectManager = LookupUtil.getSubjectManager();
+ ldapManager = LookupUtil.getLdapGroupManager();
}
/**
@@ -263,7 +266,7 @@ public class RoleManagerBeanTest extends AbstractEJB3Test {
LdapGroup group = new LdapGroup();
group.setName("Foo");
role.addLdapGroup(group);
- assert roleManager.findLdapGroupsByRole(role.getId(), PageControl.getUnlimitedInstance()).size() == 1 : "Ldap Group Foo Should be assigned";
+ assert ldapManager.findLdapGroupsByRole(role.getId(), PageControl.getUnlimitedInstance()).size() == 1 : "Ldap Group Foo Should be assigned";
} finally {
getTransactionManager().rollback();
}
commit 03be63bc157f46c0c6192e25063da5fcf6b76e73
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Apr 27 16:35:00 2010 -0400
oops, referring to a table that no longer exists
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 145b8e2..1837d73 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/alert-schema.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/alert-schema.xml
@@ -124,7 +124,6 @@
<column name="ID" default="sequence-only" initial="10001"
primarykey="true" required="true" type="INTEGER"/>
<column name="ALERT_DEFINITION_ID" required="false" type="INTEGER" references="RHQ_ALERT_DEFINITION(ID)"/>
- <column name="TEMPLATE_ID" required="false" type="INTEGER" references="RHQ_ALERT_NOTIF_TEMPL(ID)"/>
<column name="SENDER_CONFIG_ID" required="false" type="INTEGER" references="RHQ_CONFIG(ID)"/>
<column name="SENDER_NAME" required="true" size="100" type="VARCHAR2" />
</table>
commit e2e2e300fa0fe5441b962cd7c109e13a2c2f8eb9
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Apr 27 16:25:52 2010 -0400
improve debug logging for pagination/sorting issues, so that root cause can more readily be determined in the future
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/WebUserPreferences.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/WebUserPreferences.java
index a939ab4..c0abd7e 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/WebUserPreferences.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/WebUserPreferences.java
@@ -693,16 +693,21 @@ public class WebUserPreferences extends SubjectPreferencesBase {
}
public PageControl getPageControl(PageControlView view) {
- return getPageControl(view, 15);
+ PageControl results = getPageControl(view, 15);
+ log.debug("getPageControl(" + view + ") " + results);
+ return results;
}
public PageControl getPageControl(PageControlView view, int defaultPageSize) {
if (view == PageControlView.NONE) {
+ log.debug("getPageControl(" + view + ") -> PageControl.getUnlimitedInstance()");
return PageControl.getUnlimitedInstance();
}
List<String> pageControlProperties = getPreferenceAsList(view.toString());
+ log.debug("getPageControl(" + view + ") -> pageControlProperties: " + pageControlProperties);
if (pageControlProperties.size() == 0) {
+ log.debug("getPageControl(" + view + ") -> getDefaultPageControl for empty properties");
PageControl defaultControl = getDefaultPageControl(view, defaultPageSize);
return defaultControl;
} else {
@@ -722,6 +727,7 @@ public class WebUserPreferences extends SubjectPreferencesBase {
i += 2;
}
+ log.debug("getPageControl(" + view + ") -> " + pageControl);
if (view.isUnlimited() && pageSize != PageControl.SIZE_UNLIMITED) {
// make sure pageSize for an unlimited view is actually unlimited
@@ -739,6 +745,7 @@ public class WebUserPreferences extends SubjectPreferencesBase {
* persist and load just fine because the logic in this method and its counterpart
* setPageControl are kept in sync
*/
+ log.debug("getPageControl(" + view + ") -> getDefaultPageControl for exception: " + t.getMessage());
pageControl = getDefaultPageControl(view, defaultPageSize);
}
return pageControl;
@@ -770,6 +777,7 @@ public class WebUserPreferences extends SubjectPreferencesBase {
pageControlProperties.add(field.getOrdering().toString());
pageControlProperties.add(field.getField());
}
+ System.out.println("setPageControl(" + view + ", " + pageControl + ")");
setPreference(view.toString(), pageControlProperties);
}
commit 85f04f40d6ca346279b916804e3c23a486ba98a8
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Apr 27 16:25:19 2010 -0400
do now swallow the error message when their appears to be an error handling PageControl data
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/paging/PagedListDataModel.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/paging/PagedListDataModel.java
index adbc7cf..ca3f353 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/paging/PagedListDataModel.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/paging/PagedListDataModel.java
@@ -340,9 +340,7 @@ public abstract class PagedListDataModel<T> extends DataModel {
* ordering (though the underlying SLSB may add a default ordering downstream).
*/
resetToDefaults(pc);
- if (log.isTraceEnabled()) {
- log.trace(pageControlView + ": Received error[" + t.getMessage() + "], resetting to " + pc);
- }
+ log.error(pageControlView + ": Received error[" + t.getMessage() + "], resetting to " + pc);
tryQueryAgain = true;
}
commit d568a683944cbb81c717589f7c8c1a341a0ae433
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Apr 27 16:24:38 2010 -0400
BZ-584149 fix for broken sorting on the inventory browser (resources and groups)
* CriteriaQueryGenerator now automatically prepends the alias to the ordering fields when building the query
* needed to remove explicit alias identifier from the sortableColumnHeader definitions
* also, updated CriteriaQueryGenerator to support sorting by column ordinals (required by group browser's availability columns)
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/inventory/browseGroups.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/inventory/browseGroups.xhtml
index 65be544..70d9821 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/inventory/browseGroups.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/inventory/browseGroups.xhtml
@@ -144,7 +144,7 @@
<rich:column>
<f:facet name="header">
- <onc:sortableColumnHeader sort="rg.name">
+ <onc:sortableColumnHeader sort="name">
<h:outputText styleClass="headerText" value="Name" />
</onc:sortableColumnHeader>
</f:facet>
@@ -157,7 +157,7 @@
<rich:column>
<f:facet name="header">
- <onc:sortableColumnHeader sort="rg.resourceType.name">
+ <onc:sortableColumnHeader sort="resourceType.name">
<h:outputText styleClass="headerText" value="Group Type" />
</onc:sortableColumnHeader>
</f:facet>
@@ -167,7 +167,7 @@
<rich:column>
<f:facet name="header">
- <onc:sortableColumnHeader sort="rg.resourceType.plugin">
+ <onc:sortableColumnHeader sort="resourceType.plugin">
<h:outputText styleClass="headerText" value="Plugin" />
</onc:sortableColumnHeader>
</f:facet>
@@ -177,7 +177,7 @@
<rich:column>
<f:facet name="header">
- <onc:sortableColumnHeader sort="rg.description">
+ <onc:sortableColumnHeader sort="description">
<h:outputText styleClass="headerText" value="Description" />
</onc:sortableColumnHeader>
</f:facet>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/inventory/browseResources.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/inventory/browseResources.xhtml
index 90d45c0..3a4c7ea 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/inventory/browseResources.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/inventory/browseResources.xhtml
@@ -157,7 +157,7 @@
<rich:column>
<f:facet name="header">
- <onc:sortableColumnHeader sort="r.name">
+ <onc:sortableColumnHeader sort="name">
<h:outputText styleClass="headerText" value="Name" />
</onc:sortableColumnHeader>
</f:facet>
@@ -178,7 +178,7 @@
<rich:column>
<f:facet name="header">
- <onc:sortableColumnHeader sort="r.resourceType.category">
+ <onc:sortableColumnHeader sort="resourceType.category">
<h:outputText styleClass="headerText" value="Category" />
</onc:sortableColumnHeader>
</f:facet>
@@ -188,7 +188,7 @@
<rich:column>
<f:facet name="header">
- <onc:sortableColumnHeader sort="r.resourceType.name">
+ <onc:sortableColumnHeader sort="resourceType.name">
<h:outputText styleClass="headerText" value="Type" />
</onc:sortableColumnHeader>
</f:facet>
@@ -198,7 +198,7 @@
<rich:column>
<f:facet name="header">
- <onc:sortableColumnHeader sort="r.resourceType.plugin">
+ <onc:sortableColumnHeader sort="resourceType.plugin">
<h:outputText styleClass="headerText" value="Plugin" />
</onc:sortableColumnHeader>
</f:facet>
@@ -208,7 +208,7 @@
<rich:column>
<f:facet name="header">
- <onc:sortableColumnHeader sort="r.description">
+ <onc:sortableColumnHeader sort="description">
<h:outputText styleClass="headerText" value="Description" />
</onc:sortableColumnHeader>
</f:facet>
@@ -218,7 +218,7 @@
<rich:column>
<f:facet name="header">
- <onc:sortableColumnHeader sort="r.currentAvailability.availabilityType">
+ <onc:sortableColumnHeader sort="currentAvailability.availabilityType">
<h:outputText styleClass="headerText" value="Availability" />
</onc:sortableColumnHeader>
</f:facet>
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java
index ff71760..2272f12 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java
@@ -302,15 +302,15 @@ public final class CriteriaQueryGenerator {
String fieldName = orderingField.getField();
String override = criteria.getJPQLSortOverride(fieldName);
- if (override == null) {
- override = alias + "." + fieldName;
- } else {
- override = alias + "." + override;
- }
+ String suffix = (override == null) ? fieldName : override;
+
+ // if the suffix is numerical, do not prefix the alias
+ // this allows us to sort by column ordinal, which is required for availability on the group browser
+ String sortFragment = (isNumber(suffix)) ? suffix : (alias + "." + suffix);
PageOrdering ordering = orderingField.getOrdering();
- results.append(override).append(' ').append(ordering);
+ results.append(sortFragment).append(' ').append(ordering);
}
}
results.append(NL);
@@ -319,6 +319,18 @@ public final class CriteriaQueryGenerator {
return results.toString();
}
+ private boolean isNumber(String input) {
+ if (input == null) {
+ return false;
+ }
+ for (char next : input.toCharArray()) {
+ if (Character.isDigit(next) == false) {
+ return false;
+ }
+ }
+ return true;
+ }
+
public List<String> getFetchFields(Criteria criteria) {
List<String> results = new ArrayList<String>();
for (Field fetchField : getFields(criteria, Criteria.Type.FETCH)) {
commit dbd83ebec16eafff8561e524cd089998c98ba356
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Apr 27 15:08:41 2010 -0400
fix sorting bug on the group definitions list page
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/definition/group/list.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/definition/group/list.xhtml
index 41f8728..61f9d89 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/definition/group/list.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/definition/group/list.xhtml
@@ -26,8 +26,6 @@
<ui:define name="content">
<h:form id="groupDefinitionsListForm">
- <input type="hidden" name="id" value="${param.id}"/>
-
<h:panelGrid columns="1" styleClass="data-table">
<ui:param name="groupDefinitionsDataModel" value="#{ListGroupDefinitionsUIBean.dataModel}"/>
commit 051595ca85f346a5f4f673632b2be17c62c2af25
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Apr 27 13:23:22 2010 -0400
suppress debugging statement
diff --git a/modules/enterprise/server/jar/src/main/antlr3/org/rhq/enterprise/server/search/RHQL.g b/modules/enterprise/server/jar/src/main/antlr3/org/rhq/enterprise/server/search/RHQL.g
index 4fa879e..6816a1e 100644
--- a/modules/enterprise/server/jar/src/main/antlr3/org/rhq/enterprise/server/search/RHQL.g
+++ b/modules/enterprise/server/jar/src/main/antlr3/org/rhq/enterprise/server/search/RHQL.g
@@ -75,7 +75,7 @@ tokens {
*/
searchExpression
- : conditionalExpression { System.out.println($conditionalExpression.tree.toStringTree()); }
+ : conditionalExpression { /* System.out.println($conditionalExpression.tree.toStringTree()); */ }
;
conditionalExpression
commit b3751bd05aca5af3d7fdf12971953231ffe491ac
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Apr 27 13:03:37 2010 -0400
if possible, use the resource-specific ancestry to populate relative resource drop-down
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/CustomContentUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/CustomContentUIBean.java
index eb7d500..64bf25a 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/CustomContentUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/CustomContentUIBean.java
@@ -77,6 +77,8 @@ public class CustomContentUIBean extends EnterpriseFacesContextUIBean {
customBackingBean.setWebUser(getSubject());
customBackingBean.setContext(FacesContextUtility.getRequiredRequestParameter("context"));
customBackingBean.setContextId(FacesContextUtility.getRequiredRequestParameter("contextId"));
+ customBackingBean.setContextSubId(FacesContextUtility.getOptionalRequestParameter("contextSubId",
+ (String) null));
customBackingBean.loadView();
outjectBean(backingBeanName, customBackingBean);
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/CustomAlertSenderBackingBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/CustomAlertSenderBackingBean.java
index 2f8b323..848765f 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/CustomAlertSenderBackingBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/CustomAlertSenderBackingBean.java
@@ -36,6 +36,7 @@ public class CustomAlertSenderBackingBean {
protected Subject webUser;
protected String context;
protected String contextId;
+ protected String contextSubId;
public Configuration getAlertParameters() {
return alertParameters;
@@ -69,6 +70,14 @@ public class CustomAlertSenderBackingBean {
this.contextId = contextId;
}
+ public String getContextSubId() {
+ return contextSubId;
+ }
+
+ public void setContextSubId(String contextSubId) {
+ this.contextSubId = contextSubId;
+ }
+
public void loadView() {
}
diff --git a/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/OperationsBackingBean.java b/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/OperationsBackingBean.java
index 7fd8cc1..2880800 100644
--- a/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/OperationsBackingBean.java
+++ b/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/OperationsBackingBean.java
@@ -18,6 +18,7 @@
*/
package org.rhq.enterprise.server.plugins.alertOperations;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
@@ -100,8 +101,24 @@ public class OperationsBackingBean extends CustomAlertSenderBackingBean {
descendantTypeId = get(OperationInfo.Constants.RELATIVE_DESCENDANT_TYPE_ID, "none");
ResourceType contextType = computeResourceTypeFromContext(); // should not be null
- List<ResourceType> ancestors = LookupUtil.getResourceTypeManager().getResourceTypeAncestorsWithOperations(
- getOverlord(), contextType.getId());
+ List<ResourceType> ancestors = null;
+ if (context.equals("resource")) {
+ try {
+ List<Resource> ancestry = LookupUtil.getResourceManager().getResourceLineage(
+ Integer.parseInt(contextSubId));
+ ancestors = new ArrayList<ResourceType>();
+ for (Resource next : ancestry) {
+ ancestors.add(next.getResourceType());
+ }
+ } catch (Throwable t) {
+ // ignore, we'll default to a different loading style below
+ }
+ }
+
+ if (ancestors == null) { // if not in the resource content or fallback if resource ancestry loading bombs
+ ancestors = LookupUtil.getResourceTypeManager().getResourceTypeAncestorsWithOperations(getOverlord(),
+ contextType.getId());
+ }
load(ancestorTypeOptions, ancestors);
if (ancestorTypeId.equals("none") == false) {
commit 901a44092dd5031653ac056bd9fd925dc97ab43e
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Apr 21 13:36:48 2010 -0400
bz535436 - removed all usages of collection.toArray in InventoryManager to avoid concurrency bug.
now using synchronized block that should protect against this.
(cherry picked from commit ac4460c69494fc6720de5d9ba03af5c6b89ed989)
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java
index f4785f8..8b6cf68 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java
@@ -1821,7 +1821,9 @@ public class InventoryManager extends AgentService implements ContainerService,
* @param listener instance to notify of change events
*/
public void addInventoryEventListener(InventoryEventListener listener) {
- this.inventoryEventListeners.add(listener);
+ synchronized (this.inventoryEventListeners) {
+ this.inventoryEventListeners.add(listener);
+ }
}
/**
@@ -1830,7 +1832,21 @@ public class InventoryManager extends AgentService implements ContainerService,
* @param listener instance to remove from event notification
*/
public void removeInventoryEventListener(InventoryEventListener listener) {
- this.inventoryEventListeners.remove(listener);
+ synchronized (this.inventoryEventListeners) {
+ this.inventoryEventListeners.remove(listener);
+ }
+ }
+
+ /**
+ * Always use this before accessing the event listeners because this ensures
+ * thread safety.
+ *
+ * @return all inventory event listeners
+ */
+ private Set<InventoryEventListener> getInventoryEventListeners() {
+ synchronized (this.inventoryEventListeners) {
+ return new HashSet<InventoryEventListener>(this.inventoryEventListeners);
+ }
}
/**
@@ -1844,8 +1860,7 @@ public class InventoryManager extends AgentService implements ContainerService,
return;
}
- InventoryEventListener[] iteratorSafeListeners = new InventoryEventListener[inventoryEventListeners.size()];
- iteratorSafeListeners = inventoryEventListeners.toArray(iteratorSafeListeners);
+ Set<InventoryEventListener> iteratorSafeListeners = getInventoryEventListeners();
for (InventoryEventListener listener : iteratorSafeListeners) {
// Catch anything to make sure we don't stop firing to other listeners
try {
@@ -1868,8 +1883,7 @@ public class InventoryManager extends AgentService implements ContainerService,
log.debug("Firing activated for resource: " + resource);
}
- InventoryEventListener[] iteratorSafeListeners = new InventoryEventListener[inventoryEventListeners.size()];
- iteratorSafeListeners = inventoryEventListeners.toArray(iteratorSafeListeners);
+ Set<InventoryEventListener> iteratorSafeListeners = getInventoryEventListeners();
for (InventoryEventListener listener : iteratorSafeListeners) {
// Catch anything to make sure we don't stop firing to other listeners
try {
@@ -1893,8 +1907,7 @@ public class InventoryManager extends AgentService implements ContainerService,
log.debug("Firing deactivated for resource: " + resource);
}
- InventoryEventListener[] iteratorSafeListeners = new InventoryEventListener[inventoryEventListeners.size()];
- iteratorSafeListeners = inventoryEventListeners.toArray(iteratorSafeListeners);
+ Set<InventoryEventListener> iteratorSafeListeners = getInventoryEventListeners();
for (InventoryEventListener listener : iteratorSafeListeners) {
// Catch anything to make sure we don't stop firing to other listeners
try {
@@ -1917,8 +1930,7 @@ public class InventoryManager extends AgentService implements ContainerService,
return;
}
- InventoryEventListener[] iteratorSafeListeners = new InventoryEventListener[inventoryEventListeners.size()];
- iteratorSafeListeners = inventoryEventListeners.toArray(iteratorSafeListeners);
+ Set<InventoryEventListener> iteratorSafeListeners = getInventoryEventListeners();
for (InventoryEventListener listener : iteratorSafeListeners) {
// Catch anything to make sure we don't stop firing to other listeners
try {
commit bdbc5d990cd959005e9a7355fc1ba5c1296187d7
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Tue Apr 27 12:49:48 2010 -0400
BZ 584994:i)pagination fix ii)added ldapgroupform iii)cache ldap group list
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/AddLdapGroupsFormPrepareAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/AddLdapGroupsFormPrepareAction.java
index bd38c20..39fe62e 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/AddLdapGroupsFormPrepareAction.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/AddLdapGroupsFormPrepareAction.java
@@ -19,11 +19,14 @@
package org.rhq.enterprise.gui.admin.role;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.NavigableSet;
import java.util.Properties;
import java.util.Set;
+import java.util.TreeMap;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -43,6 +46,7 @@ import org.rhq.core.domain.authz.Role;
import org.rhq.core.domain.resource.group.LdapGroup;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
+import org.rhq.core.domain.util.PageOrdering;
import org.rhq.enterprise.gui.legacy.Constants;
import org.rhq.enterprise.gui.legacy.util.RequestUtils;
import org.rhq.enterprise.gui.legacy.util.SessionUtils;
@@ -59,6 +63,8 @@ import org.rhq.enterprise.server.util.LookupUtil;
* An Action that retrieves data to facilitate display of the form for adding groups to a role.
*/
public class AddLdapGroupsFormPrepareAction extends TilesAction {
+ final String LDAP_GROUP_CACHE = "ldapGroupCache";
+
public ActionForward execute(ComponentContext context, ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception {
Log log = LogFactory.getLog(AddLdapGroupsFormPrepareAction.class.getName());
@@ -76,6 +82,9 @@ public class AddLdapGroupsFormPrepareAction extends TilesAction {
RequestUtils.setError(request, Constants.ERR_ROLE_NOT_FOUND);
return null;
}
+ //use cached LDAP group list to avoid hitting ldap server each time ui pref changed.
+ Set<Map<String, String>> cachedAvailableLdapGroups = null;
+ cachedAvailableLdapGroups = (Set<Map<String, String>>) request.getSession().getAttribute(LDAP_GROUP_CACHE);
addForm.setR(role.getId());
@@ -93,21 +102,31 @@ public class AddLdapGroupsFormPrepareAction extends TilesAction {
PageList<Map<String, String>> pendingGroups = new PageList<Map<String, String>>(pendingSet, 0, pcp);
PageList<Map<String, String>> availableGroups = new PageList<Map<String, String>>(availableGroupsSet, 0, pca);
/* pending groups are those on the right side of the "add
- * to list" widget- awaiting association with the rolewhen the form's "ok" button is clicked. */
+ * to list" widget- awaiting association with the role when the form's "ok" button is clicked. */
pendingGroupIds = SessionUtils.getListAsListStr(request.getSession(), Constants.PENDING_RESGRPS_SES_ATTR);
log.trace("getting pending groups for role [" + roleId + ")");
String name = "foo";
try { //defend against ldap communication runtime difficulties.
- allGroups = LdapGroupManager.getInstance().findAvailableGroups();
- RoleManagerLocal roleManager = LookupUtil.getRoleManager();
+ if (cachedAvailableLdapGroups == null) {
+ allGroups = LdapGroupManager.getInstance().findAvailableGroups();
+ } else {//reuse cached.
+ allGroups = cachedAvailableLdapGroups;
+ }
+ //store unmodified list in session.
+ cachedAvailableLdapGroups = allGroups;
+
+ RoleManagerLocal roleManager = LookupUtil.getRoleManager();
+ //retrieve currently assigned groups
assignedList = roleManager.findLdapGroupsByRole(role.getId(), PageControl.getUnlimitedInstance());
+ //trim already defined from all groups returned.
allGroups = filterExisting(assignedList, allGroups);
Set<String> pendingIds = new HashSet<String>(pendingGroupIds);
+ //retrieve pending information
pendingSet = findPendingGroups(pendingIds, allGroups);
pendingGroups = new PageList<Map<String, String>>(pendingSet, pendingSet.size(), pcp);
@@ -118,6 +137,86 @@ public class AddLdapGroupsFormPrepareAction extends TilesAction {
availableGroupsSet = findAvailableGroups(pendingIds, allGroups);
availableGroups = new PageList<Map<String, String>>(availableGroupsSet, availableGroupsSet.size(), pca);
+
+ //We cannot reuse the PageControl mechanism as there are no database calls to retrieve list
+ // must replicate paging using existing web params, formula etc.
+
+ //determine count to return up to 15|30|45 and page index
+ int returnAmount = pca.getPageSize();
+ int returnIndex = pca.getPageNumber();
+
+ //determine sort order
+ PageOrdering sortOrder = pca.getPrimarySortOrder();
+ if (sortOrder == null) {
+ sortOrder = PageOrdering.ASC;
+ pca.setPrimarySortOrder(sortOrder);//reset on pc
+ }
+
+ //determine which column to sort on
+ String sortColumn = pca.getPrimarySortColumn();
+ if (sortColumn == null) {
+ sortColumn = "lg.name";
+ pca.setPrimarySort(sortColumn, sortOrder);//reset on pc
+ }
+
+ //now sort based off these values and populate sizedAvailableGroups accordingly
+ ArrayList<Map<String, String>> groupsValues = availableGroups.getValues();
+
+ //store maps based off the keys and sort()
+ Map<Integer, Map> groupLookup = new HashMap<Integer, Map>();
+ TreeMap<String, Integer> groupNames = new TreeMap<String, Integer>();
+ TreeMap<String, Integer> groupDescriptions = new TreeMap<String, Integer>();
+ for (int i = 0; i < groupsValues.size(); i++) {
+ Map<String, String> entry = groupsValues.get(i);
+ Integer key = Integer.valueOf(i);
+ groupLookup.put(key, entry);
+ groupNames.put(entry.get("name"), key);
+ groupDescriptions.put(entry.get("description"), key);
+ }
+
+ //do calculations to determine how many sorted values to return.
+ int start, end;
+ start = (int) (returnIndex * returnAmount);
+ end = start + returnAmount;
+ PageList<Map<String, String>> sizedAvailableGroups = new PageList<Map<String, String>>();
+
+ //detect sort order
+ boolean descending = false;
+ if (sortOrder.DESC == sortOrder) {
+ descending = true;
+ }
+ //use sort column to determine which list to use
+ if (sortColumn.equalsIgnoreCase("lg.name")) {
+ int i = 0;
+ NavigableSet<String> keyList = groupNames.navigableKeySet();
+ if (descending) {
+ keyList = groupNames.descendingKeySet();
+ }
+ for (String key : keyList) {
+ if ((i >= start) && (i < end)) {
+ sizedAvailableGroups.add(groupLookup.get(groupNames.get(key)));
+ }
+ i++;
+ }
+ } else {
+ int i = 0;
+ NavigableSet<String> keyList = groupDescriptions.navigableKeySet();
+ if (descending) {
+ keyList = groupNames.descendingKeySet();
+ }
+ for (String key : keyList) {
+ if ((i >= start) && (i < end)) {
+ sizedAvailableGroups.add(groupLookup.get(groupDescriptions.get(key)));
+ }
+ i++;
+ }
+ }
+ //make sizedAvailableGroup the new reference to return.
+ availableGroups = sizedAvailableGroups;
+ //populate pagination elements for loaded elements.
+ availableGroups.setTotalSize(groupLookup.size());
+ availableGroups.setPageControl(pca);
+
} catch (LdapFilterException lce) {
ActionMessages actionMessages = new ActionMessages();
actionMessages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("admin.role.LdapGroupFilterMessage"));
@@ -136,7 +235,9 @@ public class AddLdapGroupsFormPrepareAction extends TilesAction {
request.setAttribute(Constants.PENDING_RESGRPS_ATTR, pendingGroups);
request.setAttribute(Constants.NUM_PENDING_RESGRPS_ATTR, new Integer(pendingGroups.getTotalSize()));
request.setAttribute(Constants.AVAIL_RESGRPS_ATTR, availableGroups);
- request.setAttribute(Constants.NUM_AVAIL_RESGRPS_ATTR, new Integer(availableGroups.getTotalSize()));
+ request.setAttribute(Constants.NUM_AVAIL_RESGRPS_ATTR, new Integer(allGroups.size()));
+ //store cachedAvailableGroups in session so trim down ldap communication chatter.
+ request.getSession().setAttribute(LDAP_GROUP_CACHE, cachedAvailableLdapGroups);
return null;
}
@@ -175,4 +276,4 @@ public class AddLdapGroupsFormPrepareAction extends TilesAction {
}
return ret;
}
-}
\ No newline at end of file
+}
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/admin/role/AddLdapRoleGroups.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/admin/role/AddLdapRoleGroups.jsp
index 93ec22e..4341a5e 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/admin/role/AddLdapRoleGroups.jsp
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/admin/role/AddLdapRoleGroups.jsp
@@ -13,7 +13,7 @@
<tiles:insert definition=".portlet.error"/>
-<tiles:insert page="/admin/role/RoleGroupsForm.jsp">
+<tiles:insert page="/admin/role/RoleLdapGroupsForm.jsp">
<tiles:put name="availableResGrps" beanName="AvailableResGrps"/>
<tiles:put name="numAvailableResGrps" beanName="NumAvailableResGrps"/>
<tiles:put name="pendingResGrps" beanName="PendingResGrps"/>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/admin/role/RoleLdapGroupsForm.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/admin/role/RoleLdapGroupsForm.jsp
new file mode 100644
index 0000000..2880f22
--- /dev/null
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/admin/role/RoleLdapGroupsForm.jsp
@@ -0,0 +1,263 @@
+<%@ page language="java" %>
+<%@ page errorPage="/common/Error.jsp" %>
+<%@ taglib uri="http://jakarta.apache.org/struts/tags-html-el" prefix="html" %>
+<%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles" prefix="tiles" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<%@ taglib uri="/WEB-INF/tld/display.tld" prefix="display" %>
+
+<tiles:importAttribute name="availableResGrps"/>
+<tiles:importAttribute name="numAvailableResGrps"/>
+<tiles:importAttribute name="pendingResGrps"/>
+<tiles:importAttribute name="numPendingResGrps"/>
+
+<script language="JavaScript" src="<html:rewrite page="/js/addRemoveWidget.js"/>" type="text/javascript"></script>
+<c:set var="widgetInstanceName" value="addGroups"/>
+
+<script type="text/javascript">
+var pageData = new Array();
+initializeWidgetProperties('<c:out value="${widgetInstanceName}"/>');
+widgetProperties = getWidgetProperties('<c:out value="${widgetInstanceName}"/>');
+</script>
+
+<c:url var="selfPnaAction" value="/admin/role/RoleAdmin.do">
+ <c:param name="mode" value="addLdapGroups"/>
+ <c:param name="r" value="${Role.id}"/>
+ <c:if test="${not empty param.psa}">
+ <c:param name="psa" value="${param.psa}"/>
+ </c:if>
+ <c:if test="${not empty param.soa}">
+ <c:param name="soa" value="${param.soa}"/>
+ </c:if>
+ <c:if test="${not empty param.sca}">
+ <c:param name="sca" value="${param.sca}"/>
+ </c:if>
+ <c:if test="${not empty param.psp}">
+ <c:param name="psp" value="${param.psp}"/>
+ </c:if>
+ <c:if test="${not empty param.pnp}">
+ <c:param name="pnp" value="${param.pnp}"/>
+ </c:if>
+ <c:if test="${not empty param.sop}">
+ <c:param name="sop" value="${param.sop}"/>
+ </c:if>
+ <c:if test="${not empty param.scp}">
+ <c:param name="scp" value="${param.scp}"/>
+ </c:if>
+</c:url>
+
+<c:url var="selfPnpAction" value="/admin/role/RoleAdmin.do">
+ <c:param name="mode" value="addLdapGroups"/>
+ <c:param name="r" value="${Role.id}"/>
+ <c:if test="${not empty param.psa}">
+ <c:param name="psa" value="${param.psa}"/>
+ </c:if>
+ <c:if test="${not empty param.pna}">
+ <c:param name="pna" value="${param.pna}"/>
+ </c:if>
+ <c:if test="${not empty param.soa}">
+ <c:param name="soa" value="${param.soa}"/>
+ </c:if>
+ <c:if test="${not empty param.sca}">
+ <c:param name="sca" value="${param.sca}"/>
+ </c:if>
+ <c:if test="${not empty param.psp}">
+ <c:param name="psp" value="${param.psp}"/>
+ </c:if>
+ <c:if test="${not empty param.sop}">
+ <c:param name="sop" value="${param.sop}"/>
+ </c:if>
+ <c:if test="${not empty param.scp}">
+ <c:param name="scp" value="${param.scp}"/>
+ </c:if>
+</c:url>
+
+<c:url var="selfPsaAction" value="/admin/role/RoleAdmin.do">
+ <c:param name="mode" value="addLdapGroups"/>
+ <c:param name="r" value="${Role.id}"/>
+ <c:if test="${not empty param.pna}">
+ <c:param name="pna" value="${param.pna}"/>
+ </c:if>
+ <c:if test="${not empty param.soa}">
+ <c:param name="soa" value="${param.soa}"/>
+ </c:if>
+ <c:if test="${not empty param.sca}">
+ <c:param name="sca" value="${param.sca}"/>
+ </c:if>
+ <c:if test="${not empty param.pnp}">
+ <c:param name="pnp" value="${param.pnp}"/>
+ </c:if>
+ <c:if test="${not empty param.psp}">
+ <c:param name="psp" value="${param.psp}"/>
+ </c:if>
+ <c:if test="${not empty param.sop}">
+ <c:param name="sop" value="${param.sop}"/>
+ </c:if>
+ <c:if test="${not empty param.scp}">
+ <c:param name="scp" value="${param.scp}"/>
+ </c:if>
+</c:url>
+
+
+<c:url var="selfPspAction" value="/admin/role/RoleAdmin.do">
+ <c:param name="mode" value="addLdapGroups"/>
+ <c:param name="r" value="${Role.id}"/>
+ <c:if test="${not empty param.pna}">
+ <c:param name="pna" value="${param.pna}"/>
+ </c:if>
+ <c:if test="${not empty param.psa}">
+ <c:param name="psa" value="${param.psa}"/>
+ </c:if>
+ <c:if test="${not empty param.soa}">
+ <c:param name="soa" value="${param.soa}"/>
+ </c:if>
+ <c:if test="${not empty param.sca}">
+ <c:param name="sca" value="${param.sca}"/>
+ </c:if>
+ <c:if test="${not empty param.pnp}">
+ <c:param name="pnp" value="${param.pnp}"/>
+ </c:if>
+ <c:if test="${not empty param.sop}">
+ <c:param name="sop" value="${param.sop}"/>
+ </c:if>
+ <c:if test="${not empty param.scp}">
+ <c:param name="scp" value="${param.scp}"/>
+ </c:if>
+</c:url>
+
+<c:url var="selfPaAction" value="/admin/role/RoleAdmin.do">
+ <c:param name="mode" value="addLdapGroups"/>
+ <c:param name="r" value="${Role.id}"/>
+ <c:if test="${not empty param.pna}">
+ <c:param name="pna" value="${param.pna}"/>
+ </c:if>
+ <c:if test="${not empty param.psa}">
+ <c:param name="psa" value="${param.psa}"/>
+ </c:if>
+ <c:if test="${not empty param.pnp}">
+ <c:param name="pnp" value="${param.pnp}"/>
+ </c:if>
+ <c:if test="${not empty param.psp}">
+ <c:param name="psp" value="${param.psp}"/>
+ </c:if>
+ <c:if test="${not empty param.sop}">
+ <c:param name="sop" value="${param.sop}"/>
+ </c:if>
+ <c:if test="${not empty param.scp}">
+ <c:param name="scp" value="${param.scp}"/>
+ </c:if>
+</c:url>
+
+<c:url var="selfPpAction" value="/admin/role/RoleAdmin.do">
+ <c:param name="mode" value="addLdapGroups"/>
+ <c:param name="r" value="${Role.id}"/>
+ <c:if test="${not empty param.pna}">
+ <c:param name="pna" value="${param.pna}"/>
+ </c:if>
+ <c:if test="${not empty param.psa}">
+ <c:param name="psa" value="${param.psa}"/>
+ </c:if>
+ <c:if test="${not empty param.soa}">
+ <c:param name="soa" value="${param.soa}"/>
+ </c:if>
+ <c:if test="${not empty param.sca}">
+ <c:param name="sca" value="${param.sca}"/>
+ </c:if>
+ <c:if test="${not empty param.pnp}">
+ <c:param name="pnp" value="${param.pnp}"/>
+ </c:if>
+ <c:if test="${not empty param.psp}">
+ <c:param name="psp" value="${param.psp}"/>
+ </c:if>
+</c:url>
+
+
+<!-- SELECT & ADD -->
+<table width="100%" cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td width="50%" valign="top">
+
+<tiles:insert definition=".header.tab">
+ <tiles:put name="tabKey" value="admin.role.groups.GroupsTab"/>
+ <tiles:put name="useFromSideBar" value="true"/>
+</tiles:insert>
+
+ </td>
+ <td><html:img page="/images/spacer.gif" width="40" height="1" border="0"/></td>
+ <td>
+
+<tiles:insert definition=".header.tab">
+ <tiles:put name="tabKey" value="admin.role.groups.AssignToRoleTab"/>
+ <tiles:put name="useToSideBar" value="true"/>
+</tiles:insert>
+
+ </td>
+ </tr>
+ <tr>
+ <!-- SELECT COLUMN -->
+ <td width="50%" valign="top">
+ <!-- TABLED LIST CONTENTS (SELECT COLUMN) -->
+ <div id="<c:out value="${widgetInstanceName}"/>FromDiv">
+
+ <display:table padRows="true" rightSidebar="true" items="${AvailableResGrps}" var="group" action="${selfPaAction}"
+ postfix="a"
+ styleId="fromTable" width="100%" cellpadding="0" cellspacing="0" border="0">
+ <display:column width="1%" property="id" title="<input type=\"checkbox\" onclick=\"ToggleAll(this, widgetProperties)\" name=\"fromToggleAll\">" isLocalizedTitle="false" styleClass="ListCellCheckbox" headerStyleClass="ListHeaderCheckbox">
+ <display:checkboxdecorator name="availableGroup" onclick="ToggleSelection(this, widgetProperties)" styleClass="availableListMember"/>
+ </display:column>
+ <display:column property="name" title="common.header.Group" sortAttr="lg.name" width="50%"/>
+ <display:column property="description" title="common.header.Description" sortAttr="lg.description" width="50%"/>
+ </display:table>
+
+ </div>
+ <!-- / -->
+
+<tiles:insert definition=".toolbar.new">
+ <tiles:put name="useFromSideBar" value="true"/>
+ <tiles:put name="pageList" beanName="AvailableResGrps"/>
+ <tiles:put name="pageAction" beanName="selfPsaAction"/>
+ <tiles:put name="postfix" value="a"/>
+</tiles:insert>
+
+ </td>
+ <!-- / SELECT COLUMN -->
+
+ <!-- ADD/REMOVE COLUMN -->
+ <td id="<c:out value="${widgetInstanceName}"/>AddRemoveButtonTd">
+ <div id="AddButtonDiv" align="left"><html:img page="/images/fb_addarrow_gray.gif" border="0" titleKey="AddToList.ClickToAdd"/></div>
+ <br> <br>
+ <div id="RemoveButtonDiv" align="right"><html:img page="/images/fb_removearrow_gray.gif" border="0" titleKey="AddToList.ClickToRemove"/></div>
+ </td>
+ <!-- / ADD/REMOVE COLUMN -->
+
+ <!-- ADD COLUMN -->
+ <td width="50%" valign="top">
+ <!-- TABLED LIST CONTENTS (SELECT COLUMN) -->
+ <div id='<c:out value="${widgetInstanceName}"/>ToDiv'>
+
+ <display:table padRows="true" leftSidebar="true" items="${PendingResGrps}" var="group" action="${selfPpAction}"
+ postfix="p"
+ styleId="toTable" width="100%" cellpadding="0" cellspacing="0" border="0">
+ <display:column width="1%" property="id" title="<input type=\"checkbox\" onclick=\"ToggleAll(this, widgetProperties)\" name=\"toToggleAll\">" isLocalizedTitle="false" styleClass="ListCellCheckbox" headerStyleClass="ListHeaderCheckbox">
+ <display:checkboxdecorator name="pendingGroup" onclick="ToggleSelection(this, widgetProperties)" styleClass="pendingListMember"/>
+ </display:column>
+ <display:column property="name" title="common.header.Group" sortAttr="lg.name" width="50%"/>
+ <display:column property="description" title="common.header.Description" width="50%" sortAttr="lg.description"/>
+ </display:table>
+
+ </div>
+ <!-- / -->
+
+<tiles:insert definition=".toolbar.new">
+ <tiles:put name="newButtonKey" value="admin.role.groups.NewResourceGroupButton"/>
+ <tiles:put name="useToSideBar" value="true"/>
+ <tiles:put name="pageList" beanName="PendingResGrps"/>
+ <tiles:put name="pageAction" beanName="selfPspAction"/>
+ <tiles:put name="postfix" value="p"/>
+</tiles:insert>
+
+ </td>
+ <!-- / ADD COLUMN -->
+
+ </tr>
+</table>
+<!-- / SELECT & ADD -->
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManager.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManager.java
index 0478fd8..e372777 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManager.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManager.java
@@ -208,8 +208,10 @@ public class LdapGroupManager {
}
Map<String, String> entry = new HashMap<String, String>();
String name = (String) si.getAttributes().get("cn").get();
+ name = name.trim();
Attribute desc = si.getAttributes().get("description");
String description = desc != null ? (String) desc.get() : "";
+ description = description.trim();
entry.put("id", name);
entry.put("name", name);
entry.put("description", description);
commit 33247dceb1a722507ae16190333ffe9f2b09180b
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Apr 27 12:32:55 2010 -0400
fix NPE seen during very first recalculation of saved search result counts
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/SavedSearchResultCountRecalculationJob.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/SavedSearchResultCountRecalculationJob.java
index 0e015e3..db826de 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/SavedSearchResultCountRecalculationJob.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/SavedSearchResultCountRecalculationJob.java
@@ -67,7 +67,10 @@ public class SavedSearchResultCountRecalculationJob extends AbstractStatefulJob
PageList<Resource> results = resourceManager.findResourcesByCriteria(overlord, criteria);
totalMillis += System.currentTimeMillis();
- if (results.getTotalSize() != next.getResultCount()) {
+ // TODO: should recent count be computed at the time of update/save for this saved search?
+ // it would obviate the need for null checking here as well as in the UI for conditional
+ // display of the result count
+ if (next.getResultCount() == null || results.getTotalSize() != next.getResultCount()) {
next.setResultCount((long) results.getTotalSize());
savedSearchManager.updateSavedSearch(overlord, next);
updated++;
@@ -76,7 +79,7 @@ public class SavedSearchResultCountRecalculationJob extends AbstractStatefulJob
} catch (Throwable t) {
// TODO: mark this saved search as "broken" so that future computation is suppressed for it
errors++;
- LOG.error("Could not calculate result count for SavedSearch[name=" + next.getName() + ", patter='"
+ LOG.error("Could not calculate result count for SavedSearch[name=" + next.getName() + ", pattern='"
+ next.getPattern() + "']");
}
}
commit 8bdaceac79897f786743a3607f287581565c9b6d
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Apr 27 12:32:37 2010 -0400
removal of alert notification templates
* charles explained they will not be released in their current form
* reuse occurs at the alert definitions level (resource/group/type), not a component thereof
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 b2db5f0..145b8e2 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/alert-schema.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/alert-schema.xml
@@ -119,16 +119,6 @@
</index>
</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="CTIME" required="true" type="LONG"/>
- <column name="MTIME" required="true" type="LONG"/>
- <column name="NAME" required="true" size="100" type="VARCHAR2"/>
- <column name="DESCRIPTION" required="false" size="250" type="VARCHAR2"/>
- </table>
-
<table name="RHQ_ALERT_NOTIFICATION" tablespace="@@@LARGE_TABLESPACE_FOR_DATA@@@"
storage-options="freelists 5" cache="true" logging="false">
<column name="ID" default="sequence-only" initial="10001"
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 d028a43..d97a230 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -2058,8 +2058,9 @@
<schemaSpec version="2.70">
<schema-addColumn table="RHQ_ALERT" column="ACK_TIME" columnType="LONG" />
- <!-- TODO: this needs to change to ack_subject_name -->
<schema-addColumn table="RHQ_ALERT" column="ACK_SUBJECT" precision="100" columnType="VARCHAR2" />
+ </schemaSpec>
+ <schemaSpec version="2.70.1">
<schema-addColumn table="RHQ_ALERT_NOTIFICATION" column="SENDER_NAME" precision="100" columnType="VARCHAR2" />
<schema-addColumn table="RHQ_ALERT_NOTIFICATION" column="SENDER_CONFIG_ID" columnType="INTEGER" />
<schema-directSQL>
@@ -2071,35 +2072,7 @@
</statement>
</schema-directSQL>
</schemaSpec>
- <schemaSpec version="2.70.1">
- <schema-createSequence name="RHQ_ALERT_NOTIF_TEMPL_ID_SEQ" initial="10001" />
- <schema-directSQL>
- <statement desc="Creating table RHQ_ALERT_NOTIF_TEMPL">
- CREATE TABLE RHQ_ALERT_NOTIF_TEMPL ( ID INTEGER PRIMARY KEY )
- </statement>
- </schema-directSQL>
- <schema-alterColumn table="RHQ_ALERT_NOTIF_TEMPL" column="ID" nullable="false" />
- <schema-addColumn table="RHQ_ALERT_NOTIF_TEMPL" column="CTIME" columnType="LONG" />
- <schema-alterColumn table="RHQ_ALERT_NOTIF_TEMPL" column="CTIME" nullable="false" />
- <schema-addColumn table="RHQ_ALERT_NOTIF_TEMPL" column="MTIME" columnType="LONG" />
- <schema-alterColumn table="RHQ_ALERT_NOTIF_TEMPL" column="MTIME" nullable="false" />
- <schema-addColumn table="RHQ_ALERT_NOTIF_TEMPL" column="NAME" precision="100" columnType="VARCHAR2" />
- <schema-alterColumn table="RHQ_ALERT_NOTIF_TEMPL" column="NAME" nullable="false" />
- <schema-addColumn table="RHQ_ALERT_NOTIF_TEMPL" column="DESCRIPTION" precision="250" columnType="VARCHAR2" />
- </schemaSpec>
<schemaSpec version="2.70.2">
- <!-- add structures for alert notification templates -->
- <schema-addColumn table="RHQ_ALERT_NOTIFICATION" column="TEMPLATE_ID" columnType="INTEGER" />
- <schema-directSQL>
- <statement>
- ALTER TABLE RHQ_ALERT_NOTIFICATION
- ADD CONSTRAINT RHQ_AN_TEMPLATE_ID_FK
- FOREIGN KEY (TEMPLATE_ID)
- REFERENCES RHQ_ALERT_NOTIF_TEMPL (ID)
- </statement>
- </schema-directSQL>
- </schemaSpec>
- <schemaSpec version="2.70.3">
<!-- turn first-class notification data into configuration objects for custom alert senders -->
<schema-alterColumn table="RHQ_ALERT_NOTIFICATION" column="NOTIFICATION_TYPE" nullable="TRUE" />
<schema-javaTask className="CustomAlertSenderUpgradeTask" />
@@ -2110,7 +2083,7 @@
</schema-directSQL>
<schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="NOTIFICATION_TYPE" />
</schemaSpec>
- <schemaSpec version="2.70.4">
+ <schemaSpec version="2.70.3">
<!-- remove first-class alert notification structures from definition side of the model-->
<schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="snmp_host" />
<schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="snmp_port" />
@@ -2120,19 +2093,19 @@
<schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="subject_id" />
<schema-deleteColumn table="RHQ_ALERT_DEFINITION" column="operation_def_id" />
</schemaSpec>
- <schemaSpec version="2.70.5">
+ <schemaSpec version="2.70.4">
<schema-deleteColumn table="RHQ_ALERT_NOTIF_LOG" column="roles" />
<schema-deleteColumn table="RHQ_ALERT_NOTIF_LOG" column="subjects" />
<schema-deleteColumn table="RHQ_ALERT_NOTIF_LOG" column="emails" />
</schemaSpec>
- <schemaSpec version="2.70.6">
+ <schemaSpec version="2.70.5">
<schema-addColumn table="RHQ_ALERT_NOTIF_LOG" column="SENDER" columnType="VARCHAR2" precision="200" />
<schema-addColumn table="RHQ_ALERT_NOTIF_LOG" column="RESULT_STATE" columnType="VARCHAR2" precision="20" />
<schema-addColumn table="RHQ_ALERT_NOTIF_LOG" column="MESSAGE" columnType="VARCHAR2" precision="255" />
<schema-addColumn table="RHQ_ALERT_NOTIF_LOG" column="ALL_EMAILS" columnType="VARCHAR2" precision="4000" />
<schema-addColumn table="RHQ_ALERT_NOTIF_LOG" column="EMAILS_FAILED" columnType="VARCHAR2" precision="4000" />
</schemaSpec>
- <schemaSpec version="2.70.7">
+ <schemaSpec version="2.70.6">
<schema-directSQL>
<statement>
DROP INDEX RHQ_ALERT_IDX_ALERT
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java
index b77d8b0..b9c0401 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java
@@ -49,7 +49,7 @@ import org.rhq.core.domain.configuration.Configuration;
@NamedQueries( {
@NamedQuery(name = AlertNotification.DELETE_BY_ID, query = "DELETE FROM AlertNotification an WHERE an.id IN ( :ids )"),
@NamedQuery(name = AlertNotification.QUERY_DELETE_BY_RESOURCES, query = "DELETE FROM AlertNotification an WHERE an.alertDefinition IN ( SELECT ad FROM AlertDefinition ad WHERE ad.resource.id IN ( :resourceIds ) )"),
- @NamedQuery(name = AlertNotification.QUERY_DELETE_ORPHANED, query = "DELETE FROM AlertNotification an WHERE an.alertDefinition IS NULL AND an.alertNotificationTemplate IS NULL") })
+ @NamedQuery(name = AlertNotification.QUERY_DELETE_ORPHANED, query = "DELETE FROM AlertNotification an WHERE an.alertDefinition IS NULL") })
@SequenceGenerator(name = "RHQ_ALERT_NOTIFICATION_ID_SEQ", sequenceName = "RHQ_ALERT_NOTIFICATION_ID_SEQ")
@Table(name = "RHQ_ALERT_NOTIFICATION")
public class AlertNotification implements Serializable {
@@ -74,10 +74,6 @@ public class AlertNotification implements Serializable {
@ManyToOne
private AlertDefinition alertDefinition;
- @JoinColumn(name = "TEMPLATE_ID")
- @ManyToOne
- private AlertNotificationTemplate alertNotificationTemplate;
-
@JoinColumn(name = "SENDER_CONFIG_ID", referencedColumnName = "ID")
@OneToOne(cascade = { CascadeType.ALL }, fetch = FetchType.EAGER)
private Configuration configuration;
@@ -162,14 +158,6 @@ public class AlertNotification implements Serializable {
this.configuration = configuration;
}
- public AlertNotificationTemplate getAlertNotificationTemplate() {
- return alertNotificationTemplate;
- }
-
- public void setAlertNotificationTemplate(AlertNotificationTemplate alertNotificationTemplate) {
- this.alertNotificationTemplate = alertNotificationTemplate;
- }
-
public int getAlertDefinitionId() {
return alertDefinitionId;
}
@@ -185,7 +173,6 @@ public class AlertNotification implements Serializable {
sb.append("{alertDefinitionId=").append(alertDefinitionId);
sb.append(", alertNotificationId=").append(alertNotificationId);
sb.append(", id=").append(id);
- sb.append(", notificationTemplate=").append(alertNotificationTemplate);
sb.append(", senderName='").append(senderName).append('\'');
sb.append('}');
return sb.toString();
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotificationTemplate.java b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotificationTemplate.java
deleted file mode 100644
index df64a54..0000000
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotificationTemplate.java
+++ /dev/null
@@ -1,177 +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.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.NamedQueries;
-import javax.persistence.NamedQuery;
-import javax.persistence.OneToMany;
-import javax.persistence.PrePersist;
-import javax.persistence.PreUpdate;
-import javax.persistence.SequenceGenerator;
-import javax.persistence.Table;
-
-import org.rhq.core.domain.alert.AlertDefinition;
-import org.rhq.core.domain.resource.Resource;
-import org.rhq.core.domain.resource.ResourceType;
-import org.rhq.core.domain.resource.group.ResourceGroup;
-
-/**
- * An {@link AlertNotificationTemplate} is a group of {@link AlertNotification}. This can be used to create
- * pre-configured sets of notifications which can then be applied to all types of {@link AlertDefinition}s -
- * those at the {@link Resource}-level, {@link ResourceGroup}-level, and {@link ResourceType}-level (a.k.a
- * Alert Template).
- *
- * @author Heiko W. Rupp
- */
-
-@NamedQueries( {
- @NamedQuery(name = AlertNotificationTemplate.FIND_BY_NAME, query = "SELECT t FROM AlertNotificationTemplate t WHERE t.name = :name"),
- @NamedQuery(name = AlertNotificationTemplate.FIND_ALL, query = "SELECT t FROM AlertNotificationTemplate AS t") })
-@Entity
-@Table(name = "RHQ_ALERT_NOTIF_TEMPL")
-@SequenceGenerator(name = "RHQ_ALERT_NOTIF_TEMPL_ID_SEQ", sequenceName = "RHQ_ALERT_NOTIF_TEMPL_ID_SEQ")
-public class AlertNotificationTemplate implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- public static final String FIND_BY_NAME = "AlertNotificationTemplate.findByName";
- public static final String FIND_ALL = "AlertNotificationTemplate.findAll";
-
- @Column(name = "ID", nullable = false)
- @GeneratedValue(generator = "RHQ_ALERT_NOTIF_TEMPL_ID_SEQ")
- @Id
- private int id;
-
- @Column(name = "CTIME")
- private long ctime;
-
- @Column(name = "MTIME")
- private long mtime;
-
- @Column(name = "NAME")
- private String name;
-
- @Column(name = "DESCRIPTION")
- private String description;
-
- @OneToMany(mappedBy = "alertNotificationTemplate", cascade = CascadeType.ALL)
- List<AlertNotification> notifications = new ArrayList<AlertNotification>();
-
- protected AlertNotificationTemplate() {
- // for JPA
- }
-
- public AlertNotificationTemplate(String name, String description) {
- this.name = name;
- this.description = description;
- }
-
- public int getId() {
- return this.id;
- }
-
- public long getCtime() {
- return ctime;
- }
-
- public long getMtime() {
- return mtime;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getDescription() {
- return this.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;
- }
-
- @PrePersist
- void onPersist() {
- this.mtime = this.ctime = System.currentTimeMillis();
- }
-
- @PreUpdate
- void onPreUpdate() {
- this.mtime = System.currentTimeMillis();
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o)
- return true;
- if (o == null || getClass() != o.getClass())
- return false;
-
- AlertNotificationTemplate that = (AlertNotificationTemplate) o;
-
- if (description != null ? !description.equals(that.description) : that.description != null)
- return false;
- return name.equals(that.name);
-
- }
-
- @Override
- public int hashCode() {
- int result = name.hashCode();
- result = 31 * result + (description != null ? description.hashCode() : 0);
- return result;
- }
-
- @Override
- public String toString() {
- final StringBuilder sb = new StringBuilder();
- sb.append("NotificationTemplate");
- sb.append("{id=").append(id);
- sb.append(", name='").append(name).append('\'');
- sb.append(", description='").append(description).append('\'');
- sb.append('}');
- return sb.toString();
- }
-}
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/alert/AlertNotificationTemplateDetailsUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/alert/AlertNotificationTemplateDetailsUIBean.java
deleted file mode 100644
index c3bad26..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/alert/AlertNotificationTemplateDetailsUIBean.java
+++ /dev/null
@@ -1,90 +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.enterprise.gui.admin.alert;
-
-import javax.faces.application.FacesMessage;
-
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.In;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-
-import org.rhq.core.domain.alert.notification.AlertNotificationTemplate;
-import org.rhq.core.gui.util.FacesContextUtility;
-import org.rhq.enterprise.gui.common.framework.EnterpriseFacesContextUIBean;
-import org.rhq.enterprise.server.alert.AlertNotificationManagerLocal;
-
-(a)Scope(ScopeType.PAGE)
-@Name("AlertNotificationTemplateDetailsUIBean")
-public class AlertNotificationTemplateDetailsUIBean extends EnterpriseFacesContextUIBean {
-
- @In
- private AlertNotificationManagerLocal alertNotificationManager;
-
- private AlertNotificationTemplate template;
-
- private void loadTemplate() {
- if (template == null) {
- int templateId = FacesContextUtility.getRequiredRequestParameter("templateId", Integer.class);
- template = alertNotificationManager.getAlertNotificationTemplate(getSubject(), templateId);
- }
- }
-
- public AlertNotificationTemplate getTemplate() {
- loadTemplate();
-
- return template;
- }
-
- public int getNotificationCount() {
- loadTemplate();
-
- return template.getNotifications().size();
- }
-
- public String edit() {
- return OUTCOME_EDIT;
- }
-
- public String editNotifications() {
- return OUTCOME_EDIT;
- }
-
- public String save() {
- try {
- alertNotificationManager.updateNotificationTemplate(getSubject(), template.getId(), template.getName(),
- template.getDescription());
- FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO,
- "Alert notification template was successfully modified.");
- } catch (Throwable t) {
- FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO,
- "Error while saving alert notification template: " + t.getMessage());
- }
-
- return OUTCOME_SAVE;
- }
-
- public String cancel() {
- FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO,
- "Alert notification template modifications were cancelled.");
-
- return OUTCOME_CANCELLED;
- }
-
-}
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/alert/ListAlertNotificationTemplatesUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/alert/ListAlertNotificationTemplatesUIBean.java
deleted file mode 100644
index dd63d29..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/alert/ListAlertNotificationTemplatesUIBean.java
+++ /dev/null
@@ -1,76 +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.enterprise.gui.admin.alert;
-
-import java.util.List;
-
-import javax.faces.application.FacesMessage;
-
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.In;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-
-import org.rhq.core.domain.alert.notification.AlertNotificationTemplate;
-import org.rhq.core.domain.auth.Subject;
-import org.rhq.core.domain.util.PageControl;
-import org.rhq.core.domain.util.PageList;
-import org.rhq.core.gui.util.FacesContextUtility;
-import org.rhq.core.gui.util.StringUtility;
-import org.rhq.enterprise.gui.common.framework.EnterpriseFacesContextUIBean;
-import org.rhq.enterprise.server.alert.AlertNotificationManagerLocal;
-
-(a)Scope(ScopeType.PAGE)
-@Name("ListAlertNotificationTemplatesUIBean")
-public class ListAlertNotificationTemplatesUIBean extends EnterpriseFacesContextUIBean {
-
- @In
- private AlertNotificationManagerLocal alertNotificationManager;
-
- public PageList<AlertNotificationTemplate> getAlertNotificationTemplates() {
- List<AlertNotificationTemplate> templates = alertNotificationManager.listNotificationTemplates(getSubject());
- return new PageList<AlertNotificationTemplate>(templates, new PageControl(0, templates.size()));
- }
-
- public String deleteSelectedAlertNotificationTemplates() {
- try {
- Subject subject = getSubject();
- String[] selectedNotificationTemplates = getSelectedNotificationTemplates();
- Integer[] selectedNotificationTemplateIds = StringUtility.getIntegerArray(selectedNotificationTemplates);
- int deleted = alertNotificationManager
- .deleteNotificationTemplates(subject, selectedNotificationTemplateIds);
- FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO, "Deleted " + deleted
- + " alert notification templates");
- } catch (Throwable t) {
- FacesContextUtility.addMessage(FacesMessage.SEVERITY_ERROR, "Deletion failed: " + t.getMessage());
- }
-
- return OUTCOME_SUCCESS;
- }
-
- public String createNewAlertNotificationTemplate() {
- return OUTCOME_CREATE;
- }
-
- private String[] getSelectedNotificationTemplates() {
- String[] results = FacesContextUtility.getRequest().getParameterValues("selectedNotificationTemplates");
- return results;
- }
-
-}
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/alert/NewAlertNotificationTemplateUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/alert/NewAlertNotificationTemplateUIBean.java
deleted file mode 100644
index b2e0b07..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/alert/NewAlertNotificationTemplateUIBean.java
+++ /dev/null
@@ -1,86 +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.enterprise.gui.admin.alert;
-
-import java.util.ArrayList;
-
-import javax.faces.application.FacesMessage;
-
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.In;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-
-import org.rhq.core.domain.alert.notification.AlertNotification;
-import org.rhq.core.domain.alert.notification.AlertNotificationTemplate;
-import org.rhq.core.gui.util.FacesContextUtility;
-import org.rhq.enterprise.gui.common.framework.EnterpriseFacesContextUIBean;
-import org.rhq.enterprise.server.alert.AlertNotificationManagerLocal;
-
-(a)Scope(ScopeType.PAGE)
-@Name("NewAlertNotificationTemplateUIBean")
-public class NewAlertNotificationTemplateUIBean extends EnterpriseFacesContextUIBean {
-
- @In
- private AlertNotificationManagerLocal alertNotificationManager;
-
- private String name;
- private String description;
-
- private int createdTemplateId; // will be set as a result of create(), used for JSF navigation rules
-
- public String create() {
- try {
- AlertNotificationTemplate template = alertNotificationManager.createNotificationTemplate(this.name,
- this.description, new ArrayList<AlertNotification>(), true);
- createdTemplateId = template.getId();
- FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO, "Created new alert notification template");
- } catch (Throwable t) {
- FacesContextUtility.addMessage(FacesMessage.SEVERITY_ERROR, "Creation failed: " + t.getMessage());
- }
-
- return OUTCOME_SUCCESS;
- }
-
- public String cancel() {
- FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO, "Template creation cancelled.");
- return OUTCOME_CANCELLED;
- }
-
- public int getCreatedTemplateId() {
- return createdTemplateId;
- }
-
- 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;
- }
-
-}
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/CustomContentUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/CustomContentUIBean.java
index 758383a..eb7d500 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/CustomContentUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/CustomContentUIBean.java
@@ -59,13 +59,15 @@ public class CustomContentUIBean extends EnterpriseFacesContextUIBean {
AlertNotification activeNotification = alertNotificationManager.getAlertNotification(getSubject(),
alertNotificationId);
+ if (activeNotification == null) {
+ return; // this was just removed on the previous request
+ }
String senderName = activeNotification.getSenderName();
AlertSenderInfo info = alertNotificationManager.getAlertInfoForSender(senderName);
if (info != null && info.getUiSnippetUrl() != null) {
this.contentUrl = info.getUiSnippetUrl().toString();
- //this.contentUrl = "rhq/custom/plugin/alert/" + senderName + "/" + info.getUiSnippetShortPath();
}
String backingBeanName = alertNotificationManager.getBackingBeanNameForSender(senderName);
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/DefinitionNotificationsUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/DefinitionNotificationsUIBean.java
deleted file mode 100644
index 5b7cbeb..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/DefinitionNotificationsUIBean.java
+++ /dev/null
@@ -1,105 +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.enterprise.gui.alert.common;
-
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.Create;
-import org.jboss.seam.annotations.In;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-
-import org.rhq.core.domain.alert.notification.AlertNotificationTemplate;
-import org.rhq.core.gui.util.FacesContextUtility;
-import org.rhq.enterprise.gui.common.framework.EnterpriseFacesContextUIBean;
-import org.rhq.enterprise.server.alert.AlertNotificationManagerLocal;
-
-(a)Scope(ScopeType.EVENT)
-@Name("definitionNotificationsUIBean")
-public class DefinitionNotificationsUIBean extends EnterpriseFacesContextUIBean {
-
- @In
- private AlertNotificationsUIBean alertNotificationsUIBean;
- @In
- private AlertNotificationManagerLocal alertNotificationManager;
-
- private String selectedTemplate;
- private Boolean clearExistingNotifications;
- private Map<String, String> notificationTemplates;
-
- public String getSelectedTemplate() {
- return selectedTemplate;
- }
-
- public void setSelectedTemplate(String selectedTemplate) {
- this.selectedTemplate = selectedTemplate;
- }
-
- public Boolean getClearExistingNotifications() {
- return clearExistingNotifications;
- }
-
- public void setClearExistingNotifications(Boolean clearExistingNotifications) {
- this.clearExistingNotifications = clearExistingNotifications;
- }
-
- public Map<String, String> getNotificationTemplates() {
- return this.notificationTemplates;
- }
-
- public String addAlertSenderFromTemplate() {
- int alertDefinitionId = FacesContextUtility.getRequiredRequestParameter("ad", Integer.class);
- this.alertNotificationManager.applyNotificationTemplateToAlertDefinition(getSelectedTemplate(),
- alertDefinitionId, getClearExistingNotifications());
- this.alertNotificationsUIBean.reloadAlertNotifications();
- return "success";
- }
-
- @Create
- public void init() {
- this.notificationTemplates = lookupNotificationTemplates();
- }
-
- private Map<String, String> lookupNotificationTemplates() {
- Map<String, String> result = new TreeMap<String, String>();
- List<AlertNotificationTemplate> templates = this.alertNotificationManager
- .listNotificationTemplates(getSubject());
-
- for (AlertNotificationTemplate template : templates) {
- String displayName = getNotificationDisplayName(template);
- result.put(displayName, template.getName()); // displayed text, option value
- }
-
- return result;
- }
-
- private String getNotificationDisplayName(AlertNotificationTemplate template) {
- StringBuilder builder = new StringBuilder(template.getName());
-
- builder.append(" (");
- builder.append(template.getDescription());
- builder.append(")");
-
- return builder.toString();
- }
-
-}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/alert/template/notification/details.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/alert/template/notification/details.xhtml
deleted file mode 100644
index 69bfcb3..0000000
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/alert/template/notification/details.xhtml
+++ /dev/null
@@ -1,136 +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:c="http://java.sun.com/jstl/core"
- xmlns:onc="http://jboss.org/on/component"
- xmlns:onf="http://jboss.org/on/function"
- xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"
- xmlns:rich="http://richfaces.ajax4jsf.org/rich">
-
-<ui:composition template="/rhq/layout/main.xhtml">
-
- <ui:param name="pageTitle" value="Alert Notification Template Details"/>
-
- <ui:define name="breadcrumbs">
- <h:outputLink value="/rhq/admin/alert/template/notification/list.xhtml">
- <h:outputText value="Alert Notification Templates" />
- </h:outputLink>
- <h:outputText value=" > " />
- <h:outputLink value="/rhq/admin/alert/template/notification/details.xhtml">
- <f:param name="templateId" value="#{AlertNotificationTemplateDetailsUIBean.template.id}" />
- <f:param name="mode" value="view" />
- <h:outputText value="Details for '#{AlertNotificationTemplateDetailsUIBean.template.name}'" />
- </h:outputLink>
- </ui:define>
-
- <ui:define name="body">
-
- <ui:param name="mode" value="#{param.mode}" />
-
- <br/>
- <h:messages showDetail="true"
- globalOnly="true"
- infoClass="InfoBlock"
- warnClass="WarnBlock"
- errorClass="ErrorBlock"
- fatalClass="FatalBlock"
- layout="table" />
-
- <h:form id="alertNotificationTemplateDetailsForm">
-
- <input type="hidden" name="templateId" value="#{param.templateId}" />
- <input type="hidden" name="mode" value="#{param.mode}" />
-
- <rich:panel>
- <f:facet name="header">
- General Properties
- </f:facet>
- <table width="100%">
- <tr>
- <td align="right" style="white-space: no-wrap;"><b>Name<span class="required-marker-text">*</span>:</b></td>
- <td align="left">
- <h:inputText rendered="${mode eq 'edit'}" value="#{AlertNotificationTemplateDetailsUIBean.template.name}" />
- <h:outputText rendered="${mode ne 'edit'}" value="#{AlertNotificationTemplateDetailsUIBean.template.name}" />
- </td>
- </tr>
- <tr>
- <td align="right" style="white-space: no-wrap;"><b>Description:</b></td>
- <td align="left">
- <h:inputText rendered="${mode eq 'edit'}" value="#{AlertNotificationTemplateDetailsUIBean.template.description}" />
- <h:outputText rendered="${mode ne 'edit'}" value="#{AlertNotificationTemplateDetailsUIBean.template.description}" />
- </td>
- </tr>
- <tr>
- <td align="right" style="white-space: no-wrap;"><b>Date Created:</b></td>
- <td align="left">
- <h:outputText value="#{AlertNotificationTemplateDetailsUIBean.template.ctime}">
- <f:converter converterId="UserDateTimeConverter" />
- </h:outputText>
- </td>
- </tr>
- <tr>
- <td align="right" style="white-space: no-wrap;"><b>Last Modified:</b></td>
- <td align="left">
- <h:outputText value="#{AlertNotificationTemplateDetailsUIBean.template.mtime}">
- <f:converter converterId="UserDateTimeConverter" />
- </h:outputText>
- </td>
- </tr>
- </table>
- <h:panelGroup layout="block">
- <h:panelGrid columns="3" styleClass="buttons-table" columnClasses="button-cell" >
- <h:commandButton action="#{AlertNotificationTemplateDetailsUIBean.edit}"
- value="EDIT" styleClass="buttonmed" id="editPropertiesButton"
- rendered="${mode ne 'edit'}"/>
- <h:commandButton action="#{AlertNotificationTemplateDetailsUIBean.save}"
- value="SAVE" styleClass="buttonmed" id="saveButton"
- rendered="${mode eq 'edit'}"/>
- <h:commandButton action="#{AlertNotificationTemplateDetailsUIBean.cancel}"
- value="CANCEL" styleClass="buttonmed" id="cancelButton" immediate="true"
- rendered="${mode eq 'edit'}"/>
- </h:panelGrid>
- </h:panelGroup>
- </rich:panel>
- <br/>
- <rich:panel rendered="${mode ne 'edit'}">
- <f:facet name="header">
- Notification Actions
- </f:facet>
- <table width="100%">
- <tr>
- <td align="right" style="white-space: no-wrap;" width="20%"><b>Sender Info:</b></td>
- <td align="left">
- <h:outputText value="#{AlertNotificationTemplateDetailsUIBean.notificationCount} " />
- <h:outputText value="${msg['alert.current.detail.notify.Message']}" />
- </td>
- </tr>
- </table>
- <h:panelGroup layout="block">
- <h:panelGrid columns="3" styleClass="buttons-table" columnClasses="button-cell" >
- <h:commandButton action="#{AlertNotificationTemplateDetailsUIBean.editNotifications}"
- value="EDIT" styleClass="buttonmed" id="editNotificationsButton" />
- </h:panelGrid>
- </h:panelGroup>
- </rich:panel>
-
- <ui:remove>
- <ui:include src="/rhq/common/alert/notification/details.xhtml"
- rendered="${mode eq 'edit'}">
- <ui:param name="redirect" value="/rhq/admin/alert/template/notification/details.xhtml?mode=view&templateId=#{param.templateId}" />
- </ui:include>
- </ui:remove>
-
- </h:form>
-
- </ui:define>
-
-</ui:composition>
-
-</html>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/alert/template/notification/list.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/alert/template/notification/list.xhtml
deleted file mode 100644
index 3b2c868..0000000
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/alert/template/notification/list.xhtml
+++ /dev/null
@@ -1,146 +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">
-
-<ui:composition template="/rhq/layout/main.xhtml">
-
- <ui:param name="pageTitle" value="List Alert Notification Templates"/>
-
- <ui:define name="metaHeaders">
- <style>
- #senderName {
- display: none;
- }
- </style>
- </ui:define>
-
- <ui:define name="breadcrumbs">
- <h:outputLink value="/rhq/admin/alert/template/notification/list.xhtml">
- <h:outputText value="Alert Notification Templates" />
- </h:outputLink>
- </ui:define>
-
- <ui:define name="body">
- <br/>
- <h:messages showDetail="true"
- globalOnly="true"
- infoClass="InfoBlock"
- warnClass="WarnBlock"
- errorClass="ErrorBlock"
- fatalClass="FatalBlock"
- layout="table" />
-
- <h:form id="listAlertNotificationTemplatesForm">
- <rich:panel>
- <f:facet name="header">
- <h:outputText value="Alert Notification Templates"/>
- </f:facet>
-
- <h:panelGrid columns="1" styleClass="data-table">
- <h:outputText value="*Templates are groups of notifications that can be applied to alert definitions en masse" />
- <br/>
-
- <ui:param name="notificationTemplateDataModel" value="#{ListAlertNotificationTemplatesUIBean.alertNotificationTemplates}"/>
- <rich:dataTable id="notificationTemplateDataModel"
- rows="0"
- value="#{notificationTemplateDataModel}"
- var="notificationTemplate"
- width="100%"
- columnsWidth="1%, 30%, 40%, 15%, 15%"
- styleClass="resources-table"
- headerClass="tableRowHeader"
- footerClass="on-pager-footer"
- onRowMouseOver="this.style.backgroundColor='#E7E7E7'"
- onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'">
-
- <f:facet name="PageControlView">
- <onc:paginationControl id="NONE" />
- </f:facet>
-
- <rich:column>
- <f:facet name="header">
- <onc:allSelect target="selectedNotificationTemplates" />
- </f:facet>
-
- <onc:select name="selectedNotificationTemplates" value="#{notificationTemplate.id}" />
- </rich:column>
-
- <rich:column>
- <f:facet name="header">
- <onc:sortableColumnHeader sort="name">
- <h:outputText styleClass="headerText" value="Name" />
- </onc:sortableColumnHeader>
- </f:facet>
-
- <h:outputLink value="/rhq/admin/alert/template/notification/details.xhtml">
- <f:param name="templateId" value="#{notificationTemplate.id}" />
- <f:param name="mode" value="view" />
- <h:outputText value="#{notificationTemplate.name}" />
- </h:outputLink>
- </rich:column>
-
- <rich:column>
- <f:facet name="header">
- <onc:sortableColumnHeader sort="description">
- <h:outputText styleClass="headerText" value="Description" />
- </onc:sortableColumnHeader>
- </f:facet>
-
- <h:outputText value="#{notificationTemplate.description}" />
- </rich:column>
-
- <rich:column>
- <f:facet name="header">
- <onc:sortableColumnHeader sort="ctime">
- <h:outputText styleClass="headerText" value="Created" />
- </onc:sortableColumnHeader>
- </f:facet>
-
- <h:outputText value="#{notificationTemplate.ctime}">
- <f:converter converterId="UserDateTimeConverter" />
- </h:outputText>
- </rich:column>
-
- <rich:column>
- <f:facet name="header">
- <onc:sortableColumnHeader sort="mtime">
- <h:outputText styleClass="headerText" value="Last Modified" />
- </onc:sortableColumnHeader>
- </f:facet>
-
- <h:outputText value="#{notificationTemplate.mtime}">
- <f:converter converterId="UserDateTimeConverter" />
- </h:outputText>
- </rich:column>
-
- <f:facet name="footer">
- <rich:columnGroup>
- <rich:column colspan="5" width="100%">
- <h:commandButton action="#{ListAlertNotificationTemplatesUIBean.createNewAlertNotificationTemplate}"
- value="CREATE NEW" styleClass="on-pager-button buttonsmall"
- rendered="#{GlobalPermissionsUIBean.inventory}" />
- <onc:selectCommandButton action="#{ListAlertNotificationTemplatesUIBean.deleteSelectedAlertNotificationTemplates}"
- value="DELETE SELECTED" target="selectedNotificationTemplates" styleClass="on-pager-button buttonsmall"
- rendered="#{GlobalPermissionsUIBean.inventory}" />
- </rich:column>
- </rich:columnGroup>
- </f:facet>
-
- <h:outputText value="Templates are groups of preconfigured alert notifications that can later be applied to alert definitions" />
-
- </rich:dataTable>
- </h:panelGrid>
- </rich:panel>
- </h:form>
-
- </ui:define>
-</ui:composition>
-
-</html>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/alert/template/notification/new.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/alert/template/notification/new.xhtml
deleted file mode 100644
index 25862c1..0000000
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/alert/template/notification/new.xhtml
+++ /dev/null
@@ -1,74 +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:c="http://java.sun.com/jstl/core"
- xmlns:onc="http://jboss.org/on/component"
- xmlns:onf="http://jboss.org/on/function"
- xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"
- xmlns:rich="http://richfaces.ajax4jsf.org/rich">
-
-<ui:composition template="/rhq/layout/main.xhtml">
-
- <ui:param name="pageTitle" value="Create New Alert Notification Template"/>
-
- <ui:define name="breadcrumbs">
- <h:outputLink value="/rhq/admin/alert/template/notification/list.xhtml">
- <h:outputText value="Alert Notification Templates" />
- </h:outputLink>
- <h:outputText value=" > " />
- <h:outputLink value="/rhq/admin/alert/template/notification/new.xhtml">
- <h:outputText value="Create New" />
- </h:outputLink>
- </ui:define>
-
- <ui:define name="body">
-
- <h:form>
-
- <rich:panel>
-
- <f:facet name="header">
- General Properties
- </f:facet>
-
- <table>
- <tr>
- <td align="right"><b>Name<span class="required-marker-text">*</span>:</b></td>
- <td align="left">
- <h:inputText value="#{NewAlertNotificationTemplateUIBean.name}" size="60" maxlength="100" />
- </td>
- </tr>
- <tr>
- <td align="right"><b>Description:</b></td>
- <td align="left">
- <h:inputText value="#{NewAlertNotificationTemplateUIBean.description}" size="60" maxlength="250" />
- </td>
- </tr>
- </table>
-
- </rich:panel>
-
- <h:panelGroup layout="block" styleClass="BlockContent">
- <h:panelGrid columns="2" styleClass="buttons-table" columnClasses="button-cell">
- <h:commandButton action="#{NewAlertNotificationTemplateUIBean.create}"
- value="CREATE" styleClass="buttonmed"/>
- <h:commandButton action="#{NewAlertNotificationTemplateUIBean.cancel}"
- immediate="true"
- value="CANCEL" styleClass="buttonmed"/>
- </h:panelGrid>
- </h:panelGroup>
-
- </h:form>
-
- </ui:define>
-
-</ui:composition>
-
-</html>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/alert/notification/details.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/alert/notification/details.xhtml
index 74b978e..0c25391 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/alert/notification/details.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/alert/notification/details.xhtml
@@ -27,10 +27,8 @@
<ui:define name="body">
<a4j:keepAlive beanName="AlertNotificationContextUIBean" />
- <a4j:keepAlive beanName="alertNotificationStoreUIBean" />
<a4j:keepAlive beanName="alertNotificationsUIBean" />
<a4j:keepAlive beanName="customContentUIBean" />
- <a4j:keepAlive beanName="definitionNotificationsUIBean" />
<rich:panel id="existingAlertsPanel">
@@ -98,15 +96,6 @@
operation="show"
event="onclick" />
</h:outputLink>
- <ui:remove>
- <h:outputLink id="addAlertTemplateLink" styleClass="buttonmed" value="#" rendered="#{param.context ne 'template'}">
- <h:outputText value="Import Templates" />
- <rich:componentControl for="addAlertFromTemplatePanel"
- attachTo="addAlertTemplateLink"
- operation="show"
- event="onclick" />
- </h:outputLink>
- </ui:remove>
<h:commandButton id="removeAlertButton"
value="Remove Selected"
action="#{alertNotificationsUIBean.removeSelected}"
@@ -185,55 +174,6 @@
</h:form>
</rich:panel>
</rich:modalPanel>
-
-
- <rich:modalPanel id="addAlertFromTemplatePanel" moveable="false" autosized="true">
- <rich:panel id="importTemplatesPanel">
- <f:facet name="header">
- <h:outputText value="Import Notifications From Template" style="white-space: nowrap;"/>
- </f:facet>
-
- <h:form id="newNotificationsFromTemplateForm">
- <input type="hidden" name="ad" value="#{param.contextId}"/>
- <input type="hidden" name="context" value="#{param.context}"/>
- <input type="hidden" name="contextId" value="#{param.contextId}"/>
- <input type="hidden" name="contextSubId" value="#{param.contextSubId}"/>
-
- <rich:panel rendered="#{definitionNotificationsUIBean.notificationTemplates.size ne 0}">
- <div style="height: 100px;">
- <h:selectOneMenu id="templateList" value="#{definitionNotificationsUIBean.selectedTemplate}">
- <f:selectItems value="#{definitionNotificationsUIBean.notificationTemplates}"/>
- </h:selectOneMenu>
-
- <br/>
-
- <h:selectBooleanCheckbox title="clearExisting" value="#{definitionNotificationsUIBean.clearExistingNotifications}"/>
- <h:outputText value="Clear existing notifications"/>
- </div>
- </rich:panel>
-
- <rich:panel rendered="#{definitionNotificationsUIBean.notificationTemplates.size eq 0}">
- <div style="height: 100px;">
- No Alert Notification Templates have been defined yet.<br/>
- Please create some in Administration -> System Configuration -> Alert Notification Templates
- </div>
- </rich:panel>
-
- <h:panelGrid columns="4" styleClass="buttons-table" columnClasses="button-cell">
- <a4j:commandButton value="OK" action="#{definitionNotificationsUIBean.addAlertSenderFromTemplate}"
- styleClass="buttonmed" id="addTemplateButton"
- reRender="sendersList"
- rendered="#{definitionNotificationsUIBean.notificationTemplates.size ne 0}">
- <rich:componentControl for="addAlertFromTemplatePanel" attachTo="addTemplateButton" operation="hide" event="onclick" />
- </a4j:commandButton>
- <h:outputLink id="alertTemplateCancelLink" styleClass="buttonmed" value="#" style="float: right; margin: 10px;">
- <h:outputText value="Cancel" />
- <rich:componentControl for="addAlertFromTemplatePanel" attachTo="alertTemplateCancelLink" operation="hide" event="onclick" />
- </h:outputLink>
- </h:panelGrid>
- </h:form>
- </rich:panel>
- </rich:modalPanel>
</ui:define>
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 0897dc7..3a9a56c 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
@@ -27,7 +27,6 @@ import java.util.Set;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
-import javax.persistence.NoResultException;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
@@ -38,7 +37,6 @@ import org.rhq.core.clientapi.agent.metadata.ConfigurationMetadataParser;
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.AlertNotificationTemplate;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.authz.Permission;
import org.rhq.core.domain.configuration.Configuration;
@@ -48,7 +46,6 @@ import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.auth.SubjectManagerLocal;
import org.rhq.enterprise.server.authz.AuthorizationManagerLocal;
import org.rhq.enterprise.server.authz.PermissionException;
-import org.rhq.enterprise.server.authz.RequiredPermission;
import org.rhq.enterprise.server.plugin.ServerPluginsLocal;
import org.rhq.enterprise.server.plugin.pc.alert.AlertSenderInfo;
import org.rhq.enterprise.server.plugin.pc.alert.AlertSenderPluginManager;
@@ -152,7 +149,9 @@ public class AlertNotificationManagerBean implements AlertNotificationManagerLoc
try {
bb.internalCleanup();
} catch (Throwable t) {
- LOG.error("removeNotifications, calling backingBean.internalCleanup() resulted in " + t.getMessage());
+ LOG
+ .error("removeNotifications, calling backingBean.internalCleanup() resulted in " + t.getMessage(),
+ t);
}
}
@@ -163,30 +162,6 @@ public class AlertNotificationManagerBean implements AlertNotificationManagerLoc
return removed;
}
- public int removeNotificationsFromTemplate(Subject subject, int templateId, Integer[] notificationIds) {
- if ((notificationIds == null) || (notificationIds.length == 0)) {
- return 0;
- }
-
- AlertNotificationTemplate templ = entityManager.find(AlertNotificationTemplate.class, templateId);
- Set<Integer> notificationIdSet = new HashSet<Integer>(Arrays.asList(notificationIds));
- List<AlertNotification> notifications = templ.getNotifications();
- List<AlertNotification> toBeRemoved = new ArrayList<AlertNotification>();
-
- int removed = 0;
- for (AlertNotification notification : notifications) {
- if (notificationIdSet.contains(notification.getId())) {
- toBeRemoved.add(notification);
- removed--;
- }
- }
-
- templ.getNotifications().removeAll(toBeRemoved);
-
- return removed;
-
- }
-
public int purgeOrphanedAlertNotifications() {
Query purgeQuery = entityManager.createNamedQuery(AlertNotification.QUERY_DELETE_ORPHANED);
return purgeQuery.executeUpdate();
@@ -350,191 +325,15 @@ public class AlertNotificationManagerBean implements AlertNotificationManagerLoc
entityManager.flush();
}
- /**
- * Take the passed NotificationTemplate and apply its Notifications to the passed AlertDefinition
- * @param templateName name of a pre-defined alert NotificationTemplate
- * @param alertDefinitionId id of an AlertDefinition on which the template should be applied
- * @param removeOldNotifications Shall old Notifications on the Definition be removed?
- */
- public void applyNotificationTemplateToAlertDefinition(String templateName, int alertDefinitionId,
- boolean removeOldNotifications) {
-
- AlertNotificationTemplate template = getNotificationTemplateByName(templateName);
-
- AlertDefinition definition = getDetachedAlertDefinition(alertDefinitionId);
-
- applyNotificationTemplateToAlertDefinition(template, definition, removeOldNotifications);
- }
-
- private AlertNotificationTemplate getNotificationTemplateByName(String templateName) {
- Query q = entityManager.createNamedQuery(AlertNotificationTemplate.FIND_BY_NAME);
- q.setParameter("name", templateName);
- AlertNotificationTemplate template;
- try {
- template = (AlertNotificationTemplate) q.getSingleResult();
- } catch (NoResultException nre) {
- LOG.info("There is no alert notification template with name '" + templateName + "'");
- template = new AlertNotificationTemplate("dummy", null);
- }
- return template;
- }
-
- /**
- * 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(AlertNotificationTemplate template, AlertDefinition def,
- boolean removeOldNotifications) {
-
- if (removeOldNotifications)
- def.getAlertNotifications().clear();
-
- for (AlertNotification notif : template.getNotifications()) {
- AlertNotification notification = new AlertNotification(notif, true);
- notification.setAlertDefinition(notif.getAlertDefinition());
- entityManager.persist(notification.getConfiguration());
- entityManager.persist(notification);
- def.addAlertNotification(notification); // Attach a copy, as the ones in the template should not be shared
- }
- }
-
- /**
- * Create a new NotificationTemplate from the passed parameters. The passed AlertNotification objects need to have the
- * name and sender and any configuration properties already set; alert definitions must not be set.
- * @param name name of this notification template. Must be unique
- * @param description description of the template
- * @param notifications notifications that make up the template
- * @param copyNotifications
- * @return the newly created template
- * @throws IllegalArgumentException when a template with the passed name already exists
- */
- @SuppressWarnings("unchecked")
- @RequiredPermission(Permission.MANAGE_INVENTORY)
- public AlertNotificationTemplate createNotificationTemplate(String name, String description,
- List<AlertNotification> notifications, boolean copyNotifications) throws IllegalArgumentException {
-
- Query q = entityManager.createNamedQuery(AlertNotificationTemplate.FIND_BY_NAME);
- q.setParameter("name", name);
- List<AlertNotificationTemplate> tmp = q.getResultList();
- if (tmp.size() > 0) {
- throw new IllegalArgumentException("AlertNotificationTemplate with name [" + name + "] already exists");
- }
-
- AlertNotificationTemplate templ = new AlertNotificationTemplate(name, description);
- entityManager.persist(templ);
- for (AlertNotification n : notifications) {
- if (copyNotifications) {
- // AlertNotification alNo = n.copyWithAlertDefintion() TODO implement / fix this
- } else {
- n.setAlertNotificationTemplate(templ);
- templ.addNotification(n);
- entityManager.persist(n);
- }
-
- }
- return templ;
- }
-
- @RequiredPermission(Permission.MANAGE_INVENTORY)
- public void updateNotificationTemplate(Subject subject, int templateId, String newName, String newDescription) {
- AlertNotificationTemplate template = getAlertNotificationTemplate(subject, templateId);
- template.setName(newName);
- template.setDescription(newDescription);
- entityManager.merge(template);
- }
-
- /**
- * Delete the passed Notification Templates
- * @param subject subject of the caller
- * @param templateIds ids of the templates to delete
- * @return number of templates deleted
- */
- public int deleteNotificationTemplates(Subject subject, Integer[] templateIds) {
- if (templateIds.length == 0)
- return 0;
-
- int num = 0;
- for (int id : templateIds) {
- AlertNotificationTemplate templ = entityManager.find(AlertNotificationTemplate.class, id);
- if (templ == null) {
- LOG.warn("No notification template found with id [" + id + "]");
- continue;
- }
- entityManager.remove(templ);
- num++;
- }
-
- return num;
- }
-
- /**
- * Add a new alert Notification to a template
- * @param user subject of the caller
- * @param templateName name of the NotificationTemplate to use
- * @param sender the alert sender to use
- * @param notificationName the name of this notification
- * @param notificationConfiguration the configuration of this AlertNotification
- * @return the new AlertNotification
- */
- public AlertNotification addAlertNotificationToTemplate(Subject user, int templateId, String sender,
- String notificationName, Configuration notificationConfiguration) {
-
- AlertNotificationTemplate template = entityManager.find(AlertNotificationTemplate.class, templateId);
-
- entityManager.persist(notificationConfiguration);
- AlertNotification alertNotification = new AlertNotification(sender);
- alertNotification.setConfiguration(notificationConfiguration);
- alertNotification.setAlertNotificationTemplate(template);
- entityManager.persist(alertNotification);
- template.addNotification(alertNotification);
-
- return alertNotification;
-
- }
-
- public List<AlertNotification> getNotificationsForTemplate(Subject subject, int templateId) {
-
- AlertNotificationTemplate template = entityManager.find(AlertNotificationTemplate.class, templateId);
- if (template == null) {
- LOG.error("DId not find notification template for id [" + templateId + "]");
- return new ArrayList<AlertNotification>();
- }
-
- List<AlertNotification> notifications = template.getNotifications();
- for (AlertNotification notification : notifications) {
- notification.getConfiguration().getProperties().size(); // eager load
- }
-
- return notifications;
- }
-
- /**
- * Get all defined notification templates in the system along with their AlertNotifications
- * @param user Subject of the caller
- * @return List of all defined alert notification templates
- */
- @SuppressWarnings("unchecked")
- public List<AlertNotificationTemplate> listNotificationTemplates(Subject user) {
-
- Query q = entityManager.createNamedQuery(AlertNotificationTemplate.FIND_ALL);
- List<AlertNotificationTemplate> ret = q.getResultList();
-
- return ret;
- }
-
public AlertNotification getAlertNotification(Subject user, int alertNotificationId) {
AlertNotification notification = entityManager.find(AlertNotification.class, alertNotificationId);
- notification.getConfiguration().getProperties().size(); // eager load the alert properties
+ if (notification == null) {
+ return null;
+ }
+ if (notification.getConfiguration() != null) { // an "incomplete" notification might not have a config yet
+ notification.getConfiguration().getProperties().size(); // eager load the alert properties
+ }
return notification;
}
- public AlertNotificationTemplate getAlertNotificationTemplate(Subject user, int alertNotificationTemplateId) {
- AlertNotificationTemplate template = entityManager.find(AlertNotificationTemplate.class,
- alertNotificationTemplateId);
- template.getNotifications().size(); // eager load the children alert notifications
- return template;
- }
-
}
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 9db80cc..bfa4dbf 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
@@ -22,9 +22,7 @@ import java.util.List;
import javax.ejb.Local;
-import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.alert.notification.AlertNotification;
-import org.rhq.core.domain.alert.notification.AlertNotificationTemplate;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
@@ -93,15 +91,6 @@ public interface AlertNotificationManagerLocal {
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(AlertNotificationTemplate template, AlertDefinition def,
- boolean removeOldNotifications);
-
- /**
* Return the backing bean for the AlertSender with the passed shortNama
* @param shortName name of a sender
* @param alertNotificationId
@@ -111,62 +100,5 @@ public interface AlertNotificationManagerLocal {
String getBackingBeanNameForSender(String shortName);
- /**
- * Create a new NotificationTemplate from the passed parameters. The passed AlertNotification objects need to have the
- * name and sender and any configuration properties already set; alert definitions must not be set.
- * @param name name of this notification template. Must be unique
- * @param description description of the template
- * @param notifications notifications that make up the template
- * @param copyNotifications
- * @return the newly created template
- * @throws IllegalArgumentException when a template with the passed name already exists
- */
- AlertNotificationTemplate createNotificationTemplate(String name, String description,
- List<AlertNotification> notifications, boolean copyNotifications) throws IllegalArgumentException;
-
- void updateNotificationTemplate(Subject subject, int templateId, String newName, String newDescription);
-
- /**
- * Get all defined notification templates in the system along with their AlertNotifications
- * @param user Subject of the caller
- * @return List of all defined alert notification templates
- */
- List<AlertNotificationTemplate> listNotificationTemplates(Subject user);
-
AlertNotification getAlertNotification(Subject user, int alertNotificationId);
-
- AlertNotificationTemplate getAlertNotificationTemplate(Subject user, int alertNotificationTemplateId);
-
- /**
- * Take the passed NotificationTemplate and apply its Notifications to the passed AlertDefinition
- * @param templateName name of a pre-defined alert NotificationTemplate
- * @param alertDefinitionId id of an AlertDefinition on which the template should be applied
- * @param removeOldNotifications Shall old Notifications on the Definition be removed?
- */
- void applyNotificationTemplateToAlertDefinition(String templateName, int alertDefinitionId,
- boolean removeOldNotifications);
-
- /**
- * Add a new alert Notification to a template
- * @param user subject of the caller
- * @param templateName name of the NotificationTemplate to use
- * @param sender the alert sender to use
- * @param notificationName the name of this notification
- * @param notificationConfiguration the configuration of this AlertNotification
- * @return the new AlertNotification
- */
- AlertNotification addAlertNotificationToTemplate(Subject user, int templateId, String sender,
- String notificationName, Configuration notificationConfiguration);
-
- int removeNotificationsFromTemplate(Subject subject, int templateId, Integer[] notificationIds);
-
- List<AlertNotification> getNotificationsForTemplate(Subject subject, int templateId);
-
- /**
- * Delete the passed Notification Templates
- * @param subject subject of the caller
- * @param templateIds ids of the templates to delete
- * @return number of templates deleted
- */
- int deleteNotificationTemplates(Subject subject, Integer[] templateIds);
}
commit e782aced9325fee8159672fb037eb96c3da74050
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Apr 27 11:09:57 2010 -0400
Additional check for proper prop def merging
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java
index 238c3c6..e4c608c 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java
@@ -445,13 +445,20 @@ public class ConfigurationMetadataManagerBean implements ConfigurationMetadataMa
* @param newProperty the new prop that should replace the existing prop
*/
private void replaceListPropertyMemberDefinition(PropertyDefinitionList exList, PropertyDefinitionList newList) {
- PropertyDefinition doomedMember = exList.getMemberDefinition();
+ PropertyDefinition doomedMember = null;
+
+ // only remove the existing member if it is a different entity
+ if (exList.getMemberDefinition().getId() != newList.getMemberDefinition().getId()) {
+ doomedMember = exList.getMemberDefinition();
+ }
exList.setMemberDefinition(newList.getMemberDefinition());
exList.setMax(newList.getMax());
exList.setMin(newList.getMin());
- entityManager.remove(doomedMember);
+ if (null != doomedMember) {
+ entityManager.remove(doomedMember);
+ }
entityManager.merge(exList);
entityManager.flush();
}
commit 36b1e605cad08f003af34fb8d51733142637534e
Merge: 229a6c4... cc8f2db...
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Apr 27 10:34:00 2010 -0400
Merge branch 'master' into master-jay
commit cc8f2db67869ec32176c5160bc2adb195fdbb678
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Apr 27 09:46:42 2010 -0400
small fix to dbsetup script data
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/search-data.xml b/modules/core/dbutils/src/main/scripts/dbsetup/search-data.xml
index da98622..380ef0f 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/search-data.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/search-data.xml
@@ -5,18 +5,18 @@
<!-- overlord-created, global, default saved searches -->
<table name="RHQ_SAVED_SEARCH">
<data ID="1"
- CONTEXT="Resource"
+ CONTEXT="RESOURCE"
NAME="Downed Platforms"
DESCRIPTION="All downed machines across the entire enterprise"
- PATTERN="down platform"
+ PATTERN="availability=down category=platform"
LAST_COMPUTE_TIME="0"
SUBJECT_ID="1"
GLOBAL="TRUE" />
<data ID="2"
- CONTEXT="Resource"
+ CONTEXT="RESOURCE"
NAME="Downed Servers"
DESCRIPTION="All downed servers across the entire enterprise"
- PATTERN="down server"
+ PATTERN="availability=down category=server"
LAST_COMPUTE_TIME="0"
SUBJECT_ID="1"
GLOBAL="TRUE" />
commit 229a6c47e809481ea9011698dc46a58ca574875f
Merge: d3fa4b8... d3cc735...
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Apr 27 09:45:34 2010 -0400
Merge branch 'master' into master-jay
commit d3fa4b8aceb726dc8eda7c6164e4693cb415512c
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Apr 27 09:43:59 2010 -0400
Test failure showed some bad behavior with respect to the handling
of PropDefEnumerations, their cleanup and their order indexing. To
resolve I've basically moved ordering logic from the PDE to the
PropDefSimple, which uses the enumerated values. In more detail:
- remove the PrePersist/PreUpdate orderIndex setting from PDE. this
didn't always work, and was the source of the test failure, it relied
on the encompassing PDS being fully formed, which it may not be.
- Add logic to PDS to assign sane orderIndexes at the time the enumerations
are set/added/removed.
- update the config metadata update logic analogously, and improve
cleanup of obsolete config defs.
- updated and reenabled the previously failing tests
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionEnumeration.java b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionEnumeration.java
index 3781d13..fbcabb4 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionEnumeration.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionEnumeration.java
@@ -31,8 +31,6 @@ import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
-import javax.persistence.PrePersist;
-import javax.persistence.PreUpdate;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlAccessType;
@@ -63,7 +61,7 @@ public class PropertyDefinitionEnumeration implements Serializable {
private String value;
@Column(name = "ORDER_INDEX", nullable = false)
- private int orderIndex;
+ private int orderIndex = -1;
@Column(name = "IS_DEFAULT")
private boolean isDefault;
@@ -87,11 +85,13 @@ public class PropertyDefinitionEnumeration implements Serializable {
this.isDefault = isDefault;
}
- @PrePersist
- @PreUpdate
- public void updateOrder() {
- this.orderIndex = this.propertyDefinitionSimple.getEnumeratedValues().indexOf(this);
- }
+ // @PrePersist
+ // @PreUpdate
+ // public void updateOrder() {
+ // if (this.orderIndex < 0) {
+ // this.orderIndex = this.propertyDefinitionSimple.getEnumeratedValues().indexOf(this);
+ // }
+ // }
public PropertyDefinitionSimple getPropertyDefinitionSimple() {
return propertyDefinitionSimple;
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionSimple.java b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionSimple.java
index 3a7be2c..a27b677 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionSimple.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionSimple.java
@@ -157,12 +157,30 @@ public class PropertyDefinitionSimple extends PropertyDefinition {
public void setEnumeratedValues(List<PropertyDefinitionEnumeration> enumeratedValues, boolean allowCustomEnumValue) {
this.enumeratedValues = enumeratedValues;
this.allowCustomEnumeratedValue = allowCustomEnumValue;
+ ensureOrdering();
}
public void addEnumeratedValues(PropertyDefinitionEnumeration... enumerations) {
for (PropertyDefinitionEnumeration enumeration : enumerations) {
- getEnumeratedValues().add(enumeration);
enumeration.setPropertyDefinitionSimple(this);
+ getEnumeratedValues().add(enumeration);
+ }
+ ensureOrdering();
+ }
+
+ public void removeEnumeratedValues(PropertyDefinitionEnumeration... enumerations) {
+ for (PropertyDefinitionEnumeration enumeration : enumerations) {
+ getEnumeratedValues().remove(enumeration);
+ }
+ ensureOrdering();
+ }
+
+ private void ensureOrdering() {
+ if (null == this.enumeratedValues) {
+ return;
+ }
+ for (int i = 0, size = getEnumeratedValues().size(); (i < size); ++i) {
+ getEnumeratedValues().get(i).setOrderIndex(i);
}
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java
index 4abf76f..238c3c6 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java
@@ -30,6 +30,7 @@ import javax.persistence.PersistenceContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.Property;
import org.rhq.core.domain.configuration.PropertySimple;
@@ -274,8 +275,7 @@ public class ConfigurationMetadataManagerBean implements ConfigurationMetadataMa
* @param existingProperties list of existing properties to inspect for potential removal
*/
private void removeNoLongerUsedProperties(ConfigurationDefinition newConfigDef,
- ConfigurationDefinition existingConfigDef,
- List<PropertyDefinition> existingProperties) {
+ ConfigurationDefinition existingConfigDef, List<PropertyDefinition> existingProperties) {
List<PropertyDefinition> propDefsToDelete = new ArrayList<PropertyDefinition>();
for (PropertyDefinition existingPropDef : existingProperties) {
PropertyDefinition newPropDef = newConfigDef.get(existingPropDef.getName());
@@ -350,14 +350,8 @@ public class ConfigurationMetadataManagerBean implements ConfigurationMetadataMa
PropertyDefinitionList exList = (PropertyDefinitionList) existingProperty;
if (newProperty instanceof PropertyDefinitionList) {
PropertyDefinitionList newList = (PropertyDefinitionList) newProperty;
- exList.setMemberDefinition(newList.getMemberDefinition());
- exList.setMax(newList.getMax());
- exList.setMin(newList.getMax());
- // what about parentPropertyListDefinition ?
-
- // TODO recursively update the member ?
- } else // simple property or map-property
- {
+ replaceListPropertyMemberDefinition(exList, newList);
+ } else { // simple property or map-property
replaceProperty(existingProperty, newProperty);
}
} else if (existingProperty instanceof PropertyDefinitionSimple) {
@@ -374,12 +368,11 @@ public class ConfigurationMetadataManagerBean implements ConfigurationMetadataMa
List<PropertyDefinitionEnumeration> toDelete = missingInFirstList(newOptions, existingOptions);
List<PropertyDefinitionEnumeration> changed = intersection(existingOptions, newOptions);
- // TODO GH: This still doesn't properly reorder options, but at least it doesn't leave any nulls
- // and therefore doesn't blow up the renderer
- // delete old ones (first so we don't leave index holes later)
+ // sync the enumerated values and then merge the changes into the PDS, I think this
+ // solves previous issues with orderIndex values.
+ // First remove obsolete values
for (PropertyDefinitionEnumeration pde : toDelete) {
- existingOptions.remove(pde);
- entityManager.remove(pde);
+ existingPDS.removeEnumeratedValues(pde);
}
// save new ones
@@ -388,16 +381,16 @@ public class ConfigurationMetadataManagerBean implements ConfigurationMetadataMa
entityManager.persist(pde);
}
+ // update others
for (PropertyDefinitionEnumeration pde : changed) {
for (PropertyDefinitionEnumeration nPde : newOptions) {
if (nPde.equals(pde)) {
pde.setDefault(nPde.isDefault());
- pde.setOrderIndex(nPde.getOrderIndex());
pde.setValue(nPde.getValue());
- entityManager.merge(pde);
}
}
}
+ entityManager.merge(existingPDS);
// handle <constraint> [0..*]
@@ -444,6 +437,26 @@ public class ConfigurationMetadataManagerBean implements ConfigurationMetadataMa
}
/**
+ * This replaces the member property for the list. If it is a nested structure the whole thing
+ * is replaced from the top. The previous member property is removed. cascading should remove a nested
+ * structure.
+ *
+ * @param existingProperty the existing prop
+ * @param newProperty the new prop that should replace the existing prop
+ */
+ private void replaceListPropertyMemberDefinition(PropertyDefinitionList exList, PropertyDefinitionList newList) {
+ PropertyDefinition doomedMember = exList.getMemberDefinition();
+
+ exList.setMemberDefinition(newList.getMemberDefinition());
+ exList.setMax(newList.getMax());
+ exList.setMin(newList.getMin());
+
+ entityManager.remove(doomedMember);
+ entityManager.merge(exList);
+ entityManager.flush();
+ }
+
+ /**
* Return a list containing those element that are in reference, but not in first. Both input lists are not modified
*
* @param first
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateConfigurationSubsystemTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateConfigurationSubsystemTest.java
index 0dc958a..4a07bb7 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateConfigurationSubsystemTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateConfigurationSubsystemTest.java
@@ -581,187 +581,176 @@ public class UpdateConfigurationSubsystemTest extends UpdateSubsytemTestBase {
}
}
- // TODO (jshaughn) For some reason this test is creating a ConfigDef that Hibernate chokes on. Need
- // to come back and figure out why. Perhaps it's oracle specific... Also, if activated update
- // cleanup routine in TestBase to delete myPlatform6.
- @Test(enabled = false)
- public void testListProperty() throws Exception {
- // Note, plugins are registered in new transactions. for tests, this means
- // you can't do everything in a trans and roll back at the end. You must clean up
- // manually.
+ @Test(enabled = ENABLED)
+ public void testListOfLists() throws Exception {
try {
- { // extra block for variable scoping purposes
- registerPlugin("propertyList-v1.xml");
- ResourceType platform = getResourceType("myPlatform6");
- getTransactionManager().begin();
- EntityManager em = getEntityManager();
- platform = em.find(ResourceType.class, platform.getId());
-
- ConfigurationDefinition cd = platform.getResourceConfigurationDefinition();
- Map<String, PropertyDefinition> propDefs = cd.getPropertyDefinitions();
- assert propDefs.size() == 4 : "Expected to see 4 <list-property>s in v1, but got " + propDefs.size();
- for (PropertyDefinition def : propDefs.values()) {
- assert def instanceof PropertyDefinitionList : "PropertyDefinition " + def.getName()
- + " is no list-property in v1";
- PropertyDefinitionList pdl = (PropertyDefinitionList) def;
- PropertyDefinition member = pdl.getMemberDefinition();
-
- if (pdl.getName().equals("myList1")) {
- assert pdl.getDescription().equals("Just a simple list");
- assert member instanceof PropertyDefinitionSimple : "Expected the member of myList1 to be a simple property in v1";
- PropertyDefinitionSimple pds = (PropertyDefinitionSimple) member;
- assert pds.getName().equals("foo");
- } else if (pdl.getName().equals("myList2")) {
- assert member instanceof PropertyDefinitionList : "Expected the member of myList2 to be a list property in v1";
- } else if (pdl.getName().equals("myList3")) {
- assert member instanceof PropertyDefinitionSimple : "Expected the member of myList3 to be a simple property in v1";
- PropertyDefinitionSimple pds = (PropertyDefinitionSimple) member;
- assert pds.getName().equals("baz");
- } else if (pdl.getName().equals("rec1")) {
- assert member instanceof PropertyDefinitionList : "Expected the member of rc1 to be a list property in v1";
- PropertyDefinitionList pdl2 = (PropertyDefinitionList) member;
-
- // TODO check min/max for the lists on the way. Commented out. See JBNADM-1595
- assert pdl2.getName().equals("rec2");
-
- // assert pdl2.getMin()==2 : "Expected rec2:min to be 2, but it was " + pdl2.getMin();
- // assert pdl2.getMax()==20;
- pdl2 = (PropertyDefinitionList) pdl2.getMemberDefinition();
- assert pdl2.getName().equals("rec3");
-
- // assert pdl2.getMin()==3;
- // assert pdl2.getMax()==30;
- pdl2 = (PropertyDefinitionList) pdl2.getMemberDefinition();
- assert pdl2.getName().equals("rec4");
-
- // assert pdl2.getMin()==4;
- // assert pdl2.getMax()==40;
- assert pdl2.getMemberDefinition() instanceof PropertyDefinitionSimple;
- PropertyDefinitionSimple pds = (PropertyDefinitionSimple) pdl2.getMemberDefinition();
- assert pds.getName().equals("rec5");
- assert pds.getDescription().equals("Deeply nested");
- List<PropertyDefinitionEnumeration> options = pds.getEnumeratedValues();
- assert options.size() == 4;
- int found = 0;
- String[] optionVals = new String[] { "a", "b", "c", "d" };
- for (PropertyDefinitionEnumeration option : options) {
- if (containedIn(option.getValue(), optionVals)) {
- found++;
- }
+ // extra block for variable scoping purposes
+ registerPlugin("propertyList-v1.xml");
+ ResourceType platform = getResourceType("myPlatform6");
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ platform = em.find(ResourceType.class, platform.getId());
+ ConfigurationDefinition cd = platform.getResourceConfigurationDefinition();
+ Map<String, PropertyDefinition> propDefs = cd.getPropertyDefinitions();
+ assert propDefs.size() == 4 : "Expected to see 4 <list-property>s in v1, but got " + propDefs.size();
+ for (PropertyDefinition def : propDefs.values()) {
+ assert def instanceof PropertyDefinitionList : "PropertyDefinition " + def.getName()
+ + " is no list-property in v1";
+ PropertyDefinitionList pdl = (PropertyDefinitionList) def;
+ PropertyDefinition member = pdl.getMemberDefinition();
+
+ if (pdl.getName().equals("myList1")) {
+ assert pdl.getDescription().equals("Just a simple list");
+ assert member instanceof PropertyDefinitionSimple : "Expected the member of myList1 to be a simple property in v1";
+ PropertyDefinitionSimple pds = (PropertyDefinitionSimple) member;
+ assert pds.getName().equals("foo");
+ } else if (pdl.getName().equals("myList2")) {
+ assert member instanceof PropertyDefinitionList : "Expected the member of myList2 to be a list property in v1";
+ } else if (pdl.getName().equals("myList3")) {
+ assert member instanceof PropertyDefinitionSimple : "Expected the member of myList3 to be a simple property in v1";
+ PropertyDefinitionSimple pds = (PropertyDefinitionSimple) member;
+ assert pds.getName().equals("baz");
+ } else if (pdl.getName().equals("rec1")) {
+ assert member instanceof PropertyDefinitionList : "Expected the member of rc1 to be a list property in v1";
+ PropertyDefinitionList pdl2 = (PropertyDefinitionList) member;
+
+ // TODO check min/max for the lists on the way. Commented out. See JBNADM-1595
+ assert pdl2.getName().equals("rec2");
+
+ // assert pdl2.getMin()==2 : "Expected rec2:min to be 2, but it was " + pdl2.getMin();
+ // assert pdl2.getMax()==20;
+ pdl2 = (PropertyDefinitionList) pdl2.getMemberDefinition();
+ assert pdl2.getName().equals("rec3");
+
+ // assert pdl2.getMin()==3;
+ // assert pdl2.getMax()==30;
+ pdl2 = (PropertyDefinitionList) pdl2.getMemberDefinition();
+ assert pdl2.getName().equals("rec4");
+
+ // assert pdl2.getMin()==4;
+ // assert pdl2.getMax()==40;
+ assert pdl2.getMemberDefinition() instanceof PropertyDefinitionSimple;
+ PropertyDefinitionSimple pds = (PropertyDefinitionSimple) pdl2.getMemberDefinition();
+ assert pds.getName().equals("rec5");
+ assert pds.getDescription().equals("Deeply nested");
+ List<PropertyDefinitionEnumeration> options = pds.getEnumeratedValues();
+ assert options.size() == 4;
+ int found = 0;
+ String[] optionVals = new String[] { "a", "b", "c", "d" };
+ for (PropertyDefinitionEnumeration option : options) {
+ if (containedIn(option.getValue(), optionVals)) {
+ found++;
}
-
- assert found == 4;
- Set<Constraint> constraints = pds.getConstraints();
- assert constraints.size() == 1;
- } else {
- assert true == false : "Unknown list-definition in v1: " + pdl.getName();
}
+
+ assert found == 4;
+ Set<Constraint> constraints = pds.getConstraints();
+ assert constraints.size() == 1;
+ } else {
+ assert true == false : "Unknown list-definition in v1: " + pdl.getName();
}
- getTransactionManager().rollback();
}
+ getTransactionManager().rollback();
/*
* Deploy v2 of the plugin
*/
- { // extra block for variable scoping purposes
- registerPlugin("propertyList-v2.xml");
- ResourceType platform = getResourceType("myPlatform6");
- getTransactionManager().begin();
- EntityManager em = getEntityManager();
- platform = em.find(ResourceType.class, platform.getId());
-
- ConfigurationDefinition cd = platform.getResourceConfigurationDefinition();
- Map<String, PropertyDefinition> propDefs = cd.getPropertyDefinitions();
- assert propDefs.size() == 4 : "Expected to see 4 <list-property>s in v2, but got " + propDefs.size();
- for (PropertyDefinition def : propDefs.values()) {
- assert def instanceof PropertyDefinitionList : "PropertyDefinition " + def.getName()
- + " is no list-property in v2";
- PropertyDefinitionList pdl = (PropertyDefinitionList) def;
- PropertyDefinition member = pdl.getMemberDefinition();
-
- if (pdl.getName().equals("myList2")) {
- assert member instanceof PropertyDefinitionList : "Expected the member of myList2 to be a list property in v2";
- } else if (pdl.getName().equals("myList3")) {
- assert member instanceof PropertyDefinitionList : "Expected the member of myList3 to be a list property in v2";
- PropertyDefinitionList pds = (PropertyDefinitionList) member;
- assert pds.getName().equals("baz");
- assert pds.getDescription().equals("myList3:baz");
- assert pds.getMemberDefinition() instanceof PropertyDefinitionSimple : "Expected the member of list3:baz to be a simple property in v2";
- } else if (pdl.getName().equals("myList4")) {
- assert pdl.getDescription().equals("Just a simple list");
- assert member instanceof PropertyDefinitionSimple : "Expected the member of myList4 to be a simple property in v2";
- PropertyDefinitionSimple pds = (PropertyDefinitionSimple) member;
- assert pds.getName().equals("foo");
- } else if (pdl.getName().equals("rec1")) {
- assert member instanceof PropertyDefinitionList : "Expected the member of rec1 to be a list property in v2";
- PropertyDefinitionList pdl2 = (PropertyDefinitionList) member;
- assert pdl2.getName().equals("rec2");
-
- /*
- * PropertyDefinitionList.getMin()/getMax() are commented out. See JBNADM1595
- */
+ registerPlugin("propertyList-v2.xml");
+ platform = getResourceType("myPlatform6");
+ getTransactionManager().begin();
+ em = getEntityManager();
+ platform = em.find(ResourceType.class, platform.getId());
- // assert pdl2.getMin()==12 : "Expected rec2:min to be 12, but it was " + pdl2.getMin();
- // assert pdl2.getMax()==200;
- pdl2 = (PropertyDefinitionList) pdl2.getMemberDefinition();
- assert pdl2.getName().equals("rec3+");
-
- // assert pdl2.getMin()==13;
- // assert pdl2.getMax()==300;
- pdl2 = (PropertyDefinitionList) pdl2.getMemberDefinition();
- assert pdl2.getName().equals("rec4");
-
- // assert pdl2.getMin()==14;
- // assert pdl2.getMax()==400;
- assert pdl2.getMemberDefinition() instanceof PropertyDefinitionSimple;
- PropertyDefinitionSimple pds = (PropertyDefinitionSimple) pdl2.getMemberDefinition();
- assert pds.getName().equals("rec5");
- assert pds.getDescription().equals("Nested deeply");
- List<PropertyDefinitionEnumeration> options = pds.getEnumeratedValues();
- assert options.size() == 5;
- int found = 0;
- String[] optionVals = new String[] { "b", "c", "d", "x", "z" };
- for (PropertyDefinitionEnumeration option : options) {
- if (containedIn(option.getValue(), optionVals)) {
- found++;
- }
+ cd = platform.getResourceConfigurationDefinition();
+ propDefs = cd.getPropertyDefinitions();
+ assert propDefs.size() == 4 : "Expected to see 4 <list-property>s in v2, but got " + propDefs.size();
+ for (PropertyDefinition def : propDefs.values()) {
+ assert def instanceof PropertyDefinitionList : "PropertyDefinition " + def.getName()
+ + " is no list-property in v2";
+ PropertyDefinitionList pdl = (PropertyDefinitionList) def;
+ PropertyDefinition member = pdl.getMemberDefinition();
+
+ if (pdl.getName().equals("myList2")) {
+ assert member instanceof PropertyDefinitionList : "Expected the member of myList2 to be a list property in v2";
+ } else if (pdl.getName().equals("myList3")) {
+ assert member instanceof PropertyDefinitionList : "Expected the member of myList3 to be a list property in v2";
+ PropertyDefinitionList pds = (PropertyDefinitionList) member;
+ assert pds.getName().equals("baz");
+ assert pds.getDescription().equals("myList3:baz");
+ assert pds.getMemberDefinition() instanceof PropertyDefinitionSimple : "Expected the member of list3:baz to be a simple property in v2";
+ } else if (pdl.getName().equals("myList4")) {
+ assert pdl.getDescription().equals("Just a simple list");
+ assert member instanceof PropertyDefinitionSimple : "Expected the member of myList4 to be a simple property in v2";
+ PropertyDefinitionSimple pds = (PropertyDefinitionSimple) member;
+ assert pds.getName().equals("foo");
+ } else if (pdl.getName().equals("rec1")) {
+ assert member instanceof PropertyDefinitionList : "Expected the member of rec1 to be a list property in v2";
+ PropertyDefinitionList pdl2 = (PropertyDefinitionList) member;
+ assert pdl2.getName().equals("rec2");
+
+ /*
+ * PropertyDefinitionList.getMin()/getMax() are commented out. See JBNADM1595
+ */
+
+ // assert pdl2.getMin()==12 : "Expected rec2:min to be 12, but it was " + pdl2.getMin();
+ // assert pdl2.getMax()==200;
+ pdl2 = (PropertyDefinitionList) pdl2.getMemberDefinition();
+ assert pdl2.getName().equals("rec3+");
+
+ // assert pdl2.getMin()==13;
+ // assert pdl2.getMax()==300;
+ pdl2 = (PropertyDefinitionList) pdl2.getMemberDefinition();
+ assert pdl2.getName().equals("rec4");
+
+ // assert pdl2.getMin()==14;
+ // assert pdl2.getMax()==400;
+ assert pdl2.getMemberDefinition() instanceof PropertyDefinitionSimple;
+ PropertyDefinitionSimple pds = (PropertyDefinitionSimple) pdl2.getMemberDefinition();
+ assert pds.getName().equals("rec5");
+ assert pds.getDescription().equals("Nested deeply");
+ List<PropertyDefinitionEnumeration> options = pds.getEnumeratedValues();
+ assert options.size() == 5;
+ int found = 0;
+ String[] optionVals = new String[] { "b", "c", "d", "x", "z" };
+ for (PropertyDefinitionEnumeration option : options) {
+ if (containedIn(option.getValue(), optionVals)) {
+ found++;
}
+ }
- assert found == optionVals.length;
- Set<Constraint> constraints = pds.getConstraints();
- assert constraints.size() == 2;
- for (Constraint constraint : constraints) {
- if (constraint instanceof IntegerRangeConstraint) {
- IntegerRangeConstraint irc = (IntegerRangeConstraint) constraint;
- assert irc != null : "Integer-constraint was null, but should not be";
- // See JBNADM-1596/97
- assert irc.getDetails().equals("-2#10");
- // TODO (ips, 3/31/10): The below is a workaround for IntegerRangeConstraint.onLoad() not being called by Hibernate.
- irc.setDetails(irc.getDetails());
- assert irc.getMaximum() == 10;
- assert irc.getMinimum() == -2;
- } else if (constraint instanceof FloatRangeConstraint) {
- FloatRangeConstraint frc = (FloatRangeConstraint) constraint;
- assert frc != null : "Float-constraint was null, but should not be";
- // See JBNADM-1596/97
- assert frc.getDetails().equals("10.0#5.0");
- // TODO (ips, 3/31/10): The below is a workaround for FloatRangeConstraint.onLoad() not being called by Hibernate.
- frc.setDetails(frc.getDetails());
- assert frc.getMinimum() == 10; // TODO change when JBNADM-1597 is being worked on
- assert frc.getMaximum() == 5;
-
- } else {
- assert true == false : "Unknown constraint type encountered";
- }
+ assert found == optionVals.length;
+ Set<Constraint> constraints = pds.getConstraints();
+ assert constraints.size() == 2;
+ for (Constraint constraint : constraints) {
+ if (constraint instanceof IntegerRangeConstraint) {
+ IntegerRangeConstraint irc = (IntegerRangeConstraint) constraint;
+ assert irc != null : "Integer-constraint was null, but should not be";
+ // See JBNADM-1596/97
+ assert irc.getDetails().equals("-2#10");
+ // TODO (ips, 3/31/10): The below is a workaround for IntegerRangeConstraint.onLoad() not being called by Hibernate.
+ irc.setDetails(irc.getDetails());
+ assert irc.getMaximum() == 10;
+ assert irc.getMinimum() == -2;
+ } else if (constraint instanceof FloatRangeConstraint) {
+ FloatRangeConstraint frc = (FloatRangeConstraint) constraint;
+ assert frc != null : "Float-constraint was null, but should not be";
+ // See JBNADM-1596/97
+ assert frc.getDetails().equals("10.0#5.0");
+ // TODO (ips, 3/31/10): The below is a workaround for FloatRangeConstraint.onLoad() not being called by Hibernate.
+ frc.setDetails(frc.getDetails());
+ assert frc.getMinimum() == 10; // TODO change when JBNADM-1597 is being worked on
+ assert frc.getMaximum() == 5;
+
+ } else {
+ assert true == false : "Unknown constraint type encountered";
}
- } else {
- assert true == false : "Unknown list-definition in v2: " + pdl.getName();
}
- getTransactionManager().rollback();
+ } else {
+ assert true == false : "Unknown list-definition in v2: " + pdl.getName();
}
-
- // done with v2
}
+ getTransactionManager().rollback();
+
} finally {
if (Status.STATUS_NO_TRANSACTION != getTransactionManager().getStatus()) {
getTransactionManager().rollback();
@@ -771,7 +760,7 @@ public class UpdateConfigurationSubsystemTest extends UpdateSubsytemTestBase {
try {
cleanupTest();
} catch (Exception e) {
- System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName() + ".testListProperty");
+ System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName() + ".testListOfLists");
}
}
}
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateSubsytemTestBase.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateSubsytemTestBase.java
index cb3f029..6b5c627 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateSubsytemTestBase.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateSubsytemTestBase.java
@@ -125,6 +125,7 @@ public class UpdateSubsytemTestBase extends AbstractEJB3Test {
Subject overlord = LookupUtil.getSubjectManager().getOverlord();
ResourceTypeCriteria resourceTypeCriteria = new ResourceTypeCriteria();
+ resourceTypeCriteria.setStrict(true);
resourceTypeCriteria.addFilterName(typeName);
resourceTypeCriteria.addFilterPluginName(pluginName);
@@ -274,7 +275,7 @@ public class UpdateSubsytemTestBase extends AbstractEJB3Test {
cleanupResourceType("myPlatform3");
cleanupResourceType("myPlatform4");
cleanupResourceType("myPlatform5");
- //cleanupResourceType("myPlatform6");
+ cleanupResourceType("myPlatform6");
cleanupResourceType("myPlatform7");
cleanupResourceType("ops");
cleanupResourceType("testApp1");
@@ -323,6 +324,7 @@ public class UpdateSubsytemTestBase extends AbstractEJB3Test {
// delete any resources first
ResourceCriteria c = new ResourceCriteria();
+ c.setStrict(true);
c.addFilterResourceTypeId(rt.getId());
c.addFilterInventoryStatus(InventoryStatus.NEW);
List<Resource> doomedResources = resourceManager.findResourcesByCriteria(overlord, c);
commit d2ce45f0122e499162151ef8e927d9d5086dc5ed
Author: Joseph Marques <joseph(a)redhat.com>
Date: Mon Apr 26 17:32:52 2010 -0400
remove name field from alert notifications
diff --git a/modules/core/dbutils/src/main/java/org/rhq/core/db/upgrade/CustomAlertSenderUpgradeTask.java b/modules/core/dbutils/src/main/java/org/rhq/core/db/upgrade/CustomAlertSenderUpgradeTask.java
index 0fa4ee8..07c7590 100644
--- a/modules/core/dbutils/src/main/java/org/rhq/core/db/upgrade/CustomAlertSenderUpgradeTask.java
+++ b/modules/core/dbutils/src/main/java/org/rhq/core/db/upgrade/CustomAlertSenderUpgradeTask.java
@@ -75,9 +75,8 @@ public class CustomAlertSenderUpgradeTask implements DatabaseUpgradeTask {
String propertyName = "subjectId";
String senderName = "System Users";
- String name = "User Notifications";
- persist(data, propertyName, senderName, name);
+ persist(data, propertyName, senderName);
}
private void upgradeRoleNotifications() throws SQLException {
@@ -91,9 +90,8 @@ public class CustomAlertSenderUpgradeTask implements DatabaseUpgradeTask {
String propertyName = "roleId";
String senderName = "System Roles";
- String name = "Role Notifications";
- persist(data, propertyName, senderName, name);
+ persist(data, propertyName, senderName);
}
private void upgradeEmailNotifications() throws SQLException {
@@ -107,9 +105,8 @@ public class CustomAlertSenderUpgradeTask implements DatabaseUpgradeTask {
String propertyName = "emailAddress";
String senderName = "Direct Emails";
- String name = "Email Notifications";
- persist(data, propertyName, senderName, name);
+ persist(data, propertyName, senderName);
}
private void upgradeSNMPNotifications() throws SQLException {
@@ -129,7 +126,7 @@ public class CustomAlertSenderUpgradeTask implements DatabaseUpgradeTask {
// buffer will be 0 the very first time, since definitionId is initially -1
int configId = persistConfiguration("host", host, "port", port, "oid", oid);
- persistNotification(alertDefinitionId, configId, "SNMP Traps", "SNMP Notifications");
+ persistNotification(alertDefinitionId, configId, "SNMP Traps");
}
}
@@ -147,11 +144,11 @@ public class CustomAlertSenderUpgradeTask implements DatabaseUpgradeTask {
// buffer will be 0 the very first time, since definitionId is initially -1
int configId = persistConfiguration("operation-definition-id", operationDefinitionId, "selection-mode",
"SELF");
- persistNotification(alertDefinitionId, configId, "Resource Operations", "Operation Invocation");
+ persistNotification(alertDefinitionId, configId, "Resource Operations");
}
}
- private void persist(List<Object[]> data, String propertyName, String sender, String name) throws SQLException {
+ private void persist(List<Object[]> data, String propertyName, String sender) throws SQLException {
int definitionId = -1;
StringBuilder buffer = new StringBuilder();
for (Object[] next : data) {
@@ -162,7 +159,7 @@ public class CustomAlertSenderUpgradeTask implements DatabaseUpgradeTask {
if (buffer.length() != 0) {
// buffer will be 0 the very first time, since definitionId is initially -1
int configId = persistConfiguration(propertyName, buffer.toString());
- persistNotification(definitionId, configId, sender, name);
+ persistNotification(definitionId, configId, sender);
}
buffer = new StringBuilder(); // reset for the next definitionId
}
@@ -176,7 +173,7 @@ public class CustomAlertSenderUpgradeTask implements DatabaseUpgradeTask {
if (buffer.length() != 0) {
int configId = persistConfiguration(propertyName, buffer.toString());
- persistNotification(definitionId, configId, sender, name);
+ persistNotification(definitionId, configId, sender);
}
}
@@ -197,9 +194,9 @@ public class CustomAlertSenderUpgradeTask implements DatabaseUpgradeTask {
return configId;
}
- private void persistNotification(int definitionId, int configId, String sender, String name) throws SQLException {
+ private void persistNotification(int definitionId, int configId, String sender) throws SQLException {
int notificationId = databaseType.getNextSequenceValue(connection, "rhq_alert_notification", "id");
- String insertNotificationSQL = getInsertNotificationSQL(notificationId, definitionId, configId, sender, name);
+ String insertNotificationSQL = getInsertNotificationSQL(notificationId, definitionId, configId, sender);
databaseType.executeSql(connection, insertNotificationSQL);
}
@@ -214,9 +211,9 @@ public class CustomAlertSenderUpgradeTask implements DatabaseUpgradeTask {
+ " VALUES ( " + id + ", " + configId + ", '" + name + "', '" + value + "', 'property' ) ";
}
- private String getInsertNotificationSQL(int id, int definitionId, int configId, String sender, String name) {
- return "INSERT INTO rhq_alert_notification ( id, alert_definition_id, sender_config_id, sender_name, display_name )" //
- + " VALUES ( " + id + ", " + definitionId + ", " + configId + ", '" + sender + "', '" + name + "' ) ";
+ private String getInsertNotificationSQL(int id, int definitionId, int configId, String sender) {
+ return "INSERT INTO rhq_alert_notification ( id, alert_definition_id, sender_config_id, sender_name )" //
+ + " VALUES ( " + id + ", " + definitionId + ", " + configId + ", '" + sender + "' ) ";
}
}
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 9617057..b2db5f0 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/alert-schema.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/alert-schema.xml
@@ -137,7 +137,6 @@
<column name="TEMPLATE_ID" required="false" type="INTEGER" references="RHQ_ALERT_NOTIF_TEMPL(ID)"/>
<column name="SENDER_CONFIG_ID" required="false" type="INTEGER" references="RHQ_CONFIG(ID)"/>
<column name="SENDER_NAME" required="true" size="100" type="VARCHAR2" />
- <column name="DISPLAY_NAME" type="VARCHAR2" size="100" />
</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 6974780..d028a43 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -2060,7 +2060,6 @@
<schema-addColumn table="RHQ_ALERT" column="ACK_TIME" columnType="LONG" />
<!-- TODO: this needs to change to ack_subject_name -->
<schema-addColumn table="RHQ_ALERT" column="ACK_SUBJECT" precision="100" columnType="VARCHAR2" />
- <schema-addColumn table="RHQ_ALERT_NOTIFICATION" column="DISPLAY_NAME" precision="100" columnType="VARCHAR2" />
<schema-addColumn table="RHQ_ALERT_NOTIFICATION" column="SENDER_NAME" precision="100" columnType="VARCHAR2" />
<schema-addColumn table="RHQ_ALERT_NOTIFICATION" column="SENDER_CONFIG_ID" columnType="INTEGER" />
<schema-directSQL>
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java
index 1a7be46..b77d8b0 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java
@@ -85,9 +85,6 @@ public class AlertNotification implements Serializable {
@Column(name = "SENDER_NAME")
private String senderName;
- @Column(name = "DISPLAY_NAME")
- private String displayName;
-
protected AlertNotification() {
} // JPA spec
@@ -115,7 +112,6 @@ public class AlertNotification implements Serializable {
} else {
this.configuration = source.configuration.deepCopy(false);
}
- this.displayName = source.displayName;
this.senderName = source.senderName;
}
@@ -129,8 +125,7 @@ public class AlertNotification implements Serializable {
this.alertNotificationId = alertNotificationId;
}
- public AlertNotification(String displayName, String sender) {
- this.displayName = displayName;
+ public AlertNotification(String sender) {
this.senderName = sender;
}
@@ -147,22 +142,6 @@ public class AlertNotification implements Serializable {
this.alertDefinition = alertDefinition;
}
- public AlertNotification copyWithAlertDefintion(AlertDefinition alertDefinition, boolean copyIds) {
- Configuration config;
- if (copyIds) {
- config = this.configuration;
- } else {
- config = this.configuration.deepCopy(false);
- }
- AlertNotification notification = new AlertNotification(alertDefinition, config);
- if (copyIds) {
- notification.id = this.id;
- }
- notification.setDisplayName(this.displayName);
- notification.setSenderName(this.senderName);
- return notification;
- }
-
public void prepareForOrphanDelete() {
this.alertDefinition = null;
}
@@ -183,14 +162,6 @@ public class AlertNotification implements Serializable {
this.configuration = configuration;
}
- public String getDisplayName() {
- return displayName;
- }
-
- public void setDisplayName(String displayName) {
- this.displayName = displayName;
- }
-
public AlertNotificationTemplate getAlertNotificationTemplate() {
return alertNotificationTemplate;
}
@@ -216,7 +187,6 @@ public class AlertNotification implements Serializable {
sb.append(", id=").append(id);
sb.append(", notificationTemplate=").append(alertNotificationTemplate);
sb.append(", senderName='").append(senderName).append('\'');
- sb.append(", displayName='").append(displayName).append('\'');
sb.append('}');
return sb.toString();
}
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/AlertNotificationStoreUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/AlertNotificationStoreUIBean.java
deleted file mode 100644
index 05e254e..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/AlertNotificationStoreUIBean.java
+++ /dev/null
@@ -1,72 +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.enterprise.gui.alert.common;
-
-import java.util.List;
-
-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.AlertNotification;
-import org.rhq.core.domain.auth.Subject;
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.enterprise.server.alert.AlertNotificationManagerLocal;
-import org.rhq.enterprise.server.util.LookupUtil;
-
-(a)Scope(ScopeType.EVENT)
-@Name("alertNotificationStoreUIBean")
-public class AlertNotificationStoreUIBean {
-
- @RequestParameter("context")
- private String context;
-
- @RequestParameter("contextId")
- private Integer contextId;
-
- private AlertNotificationManagerLocal alertNotificationManager = LookupUtil.getAlertNotificationManager();
-
- public List<AlertNotification> lookupNotifications(Subject subject) {
- if (context.equals("template")) {
- return this.alertNotificationManager.getNotificationsForTemplate(subject, contextId);
- } else {
- return this.alertNotificationManager.getNotificationsForAlertDefinition(subject, contextId);
- }
- }
-
- public AlertNotification addNotification(Subject subject, String senderType, String notificationName,
- Configuration configuration) {
- if (context.equals("template")) {
- return alertNotificationManager.addAlertNotificationToTemplate(subject, contextId, senderType,
- notificationName, configuration);
- } else {
- return this.alertNotificationManager.addAlertNotification(subject, contextId, senderType, notificationName,
- configuration);
- }
- }
-
- public void removeNotifications(Subject subject, Integer[] notificationIds) {
- if (context.equals("template")) {
- this.alertNotificationManager.removeNotificationsFromTemplate(subject, contextId, notificationIds);
- } else {
- this.alertNotificationManager.removeNotifications(subject, contextId, notificationIds);
- }
- }
-}
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/AlertNotificationsUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/AlertNotificationsUIBean.java
index f696c3c..80cc829 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/AlertNotificationsUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/AlertNotificationsUIBean.java
@@ -49,14 +49,16 @@ public class AlertNotificationsUIBean extends EnterpriseFacesContextUIBean {
@RequestParameter("nid")
private Integer notificationId;
+ @RequestParameter("context")
+ private String context;
+ @RequestParameter("contextId")
+ private Integer contextId;
+
@In
private AlertNotificationManagerLocal alertNotificationManager;
- @In(create = true)
- private AlertNotificationStoreUIBean alertNotificationStoreUIBean;
private List<AlertNotification> alertNotifications;
private Set<AlertNotification> selectedNotifications;
- private String newAlertName;
private String selectedNewSender;
private AlertNotification activeNotification;
private ConfigurationDefinition activeConfigDefinition;
@@ -79,14 +81,6 @@ public class AlertNotificationsUIBean extends EnterpriseFacesContextUIBean {
this.selectedNotifications = selectedNotifications;
}
- public String getNewAlertName() {
- return newAlertName;
- }
-
- public void setNewAlertName(String newAlertName) {
- this.newAlertName = newAlertName;
- }
-
public String getSelectedNewSender() {
return selectedNewSender;
}
@@ -136,7 +130,8 @@ public class AlertNotificationsUIBean extends EnterpriseFacesContextUIBean {
}
public void reloadAlertNotifications() {
- this.alertNotifications = this.alertNotificationStoreUIBean.lookupNotifications(getSubject());
+ this.alertNotifications = this.alertNotificationManager.getNotificationsForAlertDefinition(getSubject(),
+ contextId);
}
// Sets the initial state of the bean given the requrest parameters, this allows
@@ -175,8 +170,9 @@ public class AlertNotificationsUIBean extends EnterpriseFacesContextUIBean {
newSenderConfig = new Configuration();
}
- AlertNotification newlyCreated = this.alertNotificationStoreUIBean.addNotification(getSubject(),
- this.selectedNewSender, this.newAlertName, newSenderConfig);
+ AlertNotification newlyCreated = this.alertNotificationManager.addAlertNotification(getSubject(),
+ this.contextId, this.selectedNewSender, newSenderConfig);
+
this.alertNotifications.add(newlyCreated); // only add if no errors
this.activeNotification = newlyCreated;
this.selectedNotifications.clear();
@@ -194,7 +190,7 @@ public class AlertNotificationsUIBean extends EnterpriseFacesContextUIBean {
}
public String removeSelected() {
- this.alertNotificationStoreUIBean.removeNotifications(getSubject(), getSelectedIds());
+ this.alertNotificationManager.removeNotifications(getSubject(), contextId, getSelectedIds());
this.alertNotifications.removeAll(this.selectedNotifications); // only remove if no errors
this.activeNotification = null;
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/alert/notification/details.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/alert/notification/details.xhtml
index fd83f96..74b978e 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/alert/notification/details.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/alert/notification/details.xhtml
@@ -52,19 +52,13 @@
fastOrderControlsVisible="false"
orderControlsVisible="false"
id="sendersList">
- <rich:column width="20%">
- <f:facet name="header">
- <h:outputText value="Name" />
- </f:facet>
- <h:outputText value="#{alertNotification.displayName}" />
- </rich:column>
- <rich:column width="20%">
+ <rich:column width="25%">
<f:facet name="header">
<h:outputText value="Type" />
</f:facet>
<h:outputText value="#{alertNotification.senderName}" />
</rich:column>
- <rich:column width="60%">
+ <rich:column width="75%">
<f:facet name="header">
<h:outputText value="Configuration" />
</f:facet>
@@ -170,20 +164,6 @@
<input type="hidden" name="contextSubId" value="#{param.contextSubId}"/>
<div style="height: 100px;">
- <h:outputLabel for="alertNameInput" value="Alert Notification Name:" />
- <br />
- <h:inputText id="alertNameInput"
- value="#{alertNotificationsUIBean.newAlertName}"
- maxlength="100"
- required="true" />
-
- <h:message for="alertNameInput"
- infoClass="InfoBlock"
- warnClass="WarnBlock"
- errorClass="ErrorBlock"
- fatalClass="FatalBlock" />
- <br /><br />
-
<h:outputLabel for="senderList" value="Alert Sender Type:" />
<br />
<h:selectOneMenu id="senderList" value="#{alertNotificationsUIBean.selectedNewSender}">
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 0e7682a..0897dc7 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
@@ -296,7 +296,7 @@ public class AlertNotificationManagerBean implements AlertNotificationManagerLoc
* {@inheritDoc}
*/
public AlertNotification addAlertNotification(Subject user, int alertDefinitionId, String senderName,
- String alertName, Configuration configuration) {
+ Configuration configuration) {
AlertDefinition definition = alertDefinitionManager.getAlertDefinition(user, alertDefinitionId);
if (definition == null) {
@@ -307,7 +307,6 @@ public class AlertNotificationManagerBean implements AlertNotificationManagerLoc
entityManager.persist(configuration);
AlertNotification notif = new AlertNotification(definition);
notif.setSenderName(senderName);
- notif.setDisplayName(alertName);
notif.setConfiguration(configuration);
entityManager.persist(notif);
definition.getAlertNotifications().add(notif);
@@ -485,7 +484,7 @@ public class AlertNotificationManagerBean implements AlertNotificationManagerLoc
AlertNotificationTemplate template = entityManager.find(AlertNotificationTemplate.class, templateId);
entityManager.persist(notificationConfiguration);
- AlertNotification alertNotification = new AlertNotification(notificationName, sender);
+ AlertNotification alertNotification = new AlertNotification(sender);
alertNotification.setConfiguration(notificationConfiguration);
alertNotification.setAlertNotificationTemplate(template);
entityManager.persist(alertNotification);
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 56f1c20..9db80cc 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
@@ -65,10 +65,9 @@ public interface AlertNotificationManagerLocal {
* @param user subject of the caller
* @param alertDefinitionId Id of the alert definition
* @param senderName shortName of the {@link AlertSender}
- * @param alertName name of the new {@link AlertNotification}
* @param configuration Properties for this alert sender.
*/
- AlertNotification addAlertNotification(Subject user, int alertDefinitionId, String senderName, String alertName,
+ AlertNotification addAlertNotification(Subject user, int alertDefinitionId, String senderName,
Configuration configuration);
/**
commit d3cc735b22ba4548e5eef68b1dae73bf51335649
Author: Joseph Marques <joseph(a)redhat.com>
Date: Mon Apr 26 17:00:14 2010 -0400
BZ-562816: fix for stack trace when trying to edit general properties or conditions for an alert definition
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java
index afa5671..5a3aeba 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java
@@ -448,8 +448,7 @@ public class AlertDefinition implements Serializable {
Set<AlertNotification> copiedNotifications = new HashSet<AlertNotification>();
for (AlertNotification oldNotification : new HashSet<AlertNotification>(alertDef.getAlertNotifications())) {
- AlertNotification newNotification = oldNotification.copy(copyIds);
- newNotification.setAlertDefinition(this);
+ AlertNotification newNotification = new AlertNotification(oldNotification, copyIds);
copiedNotifications.add(newNotification);
}
this.removeAllAlertNotifications();
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java
index 1f14aad..1a7be46 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java
@@ -79,7 +79,7 @@ public class AlertNotification implements Serializable {
private AlertNotificationTemplate alertNotificationTemplate;
@JoinColumn(name = "SENDER_CONFIG_ID", referencedColumnName = "ID")
- @OneToOne(cascade = { CascadeType.ALL }, fetch = FetchType.LAZY)
+ @OneToOne(cascade = { CascadeType.ALL }, fetch = FetchType.EAGER)
private Configuration configuration;
@Column(name = "SENDER_NAME")
@@ -108,6 +108,17 @@ public class AlertNotification implements Serializable {
this.configuration = config.deepCopy();
}
+ public AlertNotification(AlertNotification source, boolean copyIds) {
+ if (copyIds) {
+ this.id = source.id;
+ this.configuration = source.configuration;
+ } else {
+ this.configuration = source.configuration.deepCopy(false);
+ }
+ this.displayName = source.displayName;
+ this.senderName = source.senderName;
+ }
+
/**
* Constructor only for transient usage
* @param alertDefinitionId
@@ -136,31 +147,22 @@ public class AlertNotification implements Serializable {
this.alertDefinition = alertDefinition;
}
- public AlertNotification copy(boolean copyIds) {
- AlertNotification results = copy();
- if (copyIds) {
- results.id = this.id;
- }
- return results;
- }
-
- public AlertNotification copyWithAlertDefintion(AlertDefinition alertDefinition, boolean cloneConfiguration) {
+ public AlertNotification copyWithAlertDefintion(AlertDefinition alertDefinition, boolean copyIds) {
Configuration config;
- if (cloneConfiguration) {
- config = this.configuration.deepCopy(false);
- } else {
+ if (copyIds) {
config = this.configuration;
+ } else {
+ config = this.configuration.deepCopy(false);
}
AlertNotification notification = new AlertNotification(alertDefinition, config);
+ if (copyIds) {
+ notification.id = this.id;
+ }
notification.setDisplayName(this.displayName);
notification.setSenderName(this.senderName);
return notification;
}
- protected AlertNotification copy() {
- return new AlertNotification(this.alertDefinition, this.configuration);
- }
-
public void prepareForOrphanDelete() {
this.alertDefinition = null;
}
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 8a4bb98..0e7682a 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
@@ -393,7 +393,8 @@ public class AlertNotificationManagerBean implements AlertNotificationManagerLoc
def.getAlertNotifications().clear();
for (AlertNotification notif : template.getNotifications()) {
- AlertNotification notification = notif.copyWithAlertDefintion(def, true);
+ AlertNotification notification = new AlertNotification(notif, true);
+ notification.setAlertDefinition(notif.getAlertDefinition());
entityManager.persist(notification.getConfiguration());
entityManager.persist(notification);
def.addAlertNotification(notification); // Attach a copy, as the ones in the template should not be shared
commit deef32fd46d29fa6bf9145ac360c9b1d59b2826a
Author: Joseph Marques <joseph(a)redhat.com>
Date: Mon Apr 26 16:28:38 2010 -0400
only print statistics for saved search result count recalculation if updates were non-zero
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/SavedSearchResultCountRecalculationJob.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/SavedSearchResultCountRecalculationJob.java
index a1e53b3..0e015e3 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/SavedSearchResultCountRecalculationJob.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/SavedSearchResultCountRecalculationJob.java
@@ -80,7 +80,10 @@ public class SavedSearchResultCountRecalculationJob extends AbstractStatefulJob
+ next.getPattern() + "']");
}
}
- LOG.info("Statistics: updated " + updated + " in " + totalMillis + " ms (" + errors + " errors)");
+ if (updated > 0) {
+ // only print non-zero stats
+ LOG.info("Statistics: updated " + updated + " in " + totalMillis + " ms (" + errors + " errors)");
+ }
}
private List<SavedSearch> getSavedSearchesNeedingRecomputation() {
commit 9937c0a8336afcf18245fe8614ad3fe413d178bc
Author: Joseph Marques <joseph(a)redhat.com>
Date: Mon Apr 26 15:52:28 2010 -0400
fix failure unit tests for saved searches subsystem
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/execution/SearchAssistManager.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/execution/SearchAssistManager.java
index 2cb808c..97f44dd 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/execution/SearchAssistManager.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/execution/SearchAssistManager.java
@@ -31,7 +31,7 @@ public class SearchAssistManager {
private static List<String> booleanOperators = Arrays.asList("and", "or", "|");
private Subject subject;
- private AbstractSearchAssistant completor;
+ private SearchSubsystem searchSubsystem;
/*
* states:
@@ -278,10 +278,11 @@ public class SearchAssistManager {
public SearchAssistManager(Subject subject, SearchSubsystem searchSubsystem) {
this.subject = subject;
- this.completor = getAutoCompletor(searchSubsystem);
+ this.searchSubsystem = searchSubsystem;
+
}
- protected AbstractSearchAssistant getAutoCompletor(SearchSubsystem searchSubsystem) {
+ protected AbstractSearchAssistant getSearchAssistant() {
if (searchSubsystem == SearchSubsystem.RESOURCE) {
return new ResourceSearchAssistant();
} else {
@@ -290,8 +291,8 @@ public class SearchAssistManager {
}
public List<String> getAllContexts() {
- List<String> results = new ArrayList<String>(completor.getSimpleContexts());
- for (String parameterized : completor.getParameterizedContexts()) {
+ List<String> results = new ArrayList<String>(getSearchAssistant().getSimpleContexts());
+ for (String parameterized : getSearchAssistant().getParameterizedContexts()) {
results.add(parameterized + "[");
}
return results;
@@ -299,7 +300,7 @@ public class SearchAssistManager {
public List<SearchSuggestion> getSuggestions(String expression, int caretPos) {
//List<SearchSuggestion> simple = getSimpleSuggestions(expression, caretPos);
- List<SearchSuggestion> advanced = getAdvancedSuggestions(expression, caretPos, SearchSuggestion.Kind.Advanced);
+ List<SearchSuggestion> advanced = getAdvancedSuggestions(expression, caretPos);
List<SearchSuggestion> userSavedSearches = getUserSavedSearchSuggestions(expression);
List<SearchSuggestion> globalSavedSearches = getGlobalSavedSearchSuggestions(expression);
@@ -313,11 +314,12 @@ public class SearchAssistManager {
}
public List<SearchSuggestion> getSimpleSuggestions(String expression, int caretPos) {
+ AbstractSearchAssistant completor = getSearchAssistant();
+
List<SearchSuggestion> results = new ArrayList<SearchSuggestion>();
for (String nextContext : completor.getSimpleContexts()) {
String intermediateExpression = nextContext + "=" + expression;
- List<SearchSuggestion> suggestions = getAdvancedSuggestions(intermediateExpression, caretPos,
- SearchSuggestion.Kind.Simple);
+ List<SearchSuggestion> suggestions = getAdvancedSuggestions(intermediateExpression, caretPos);
results.addAll(suggestions);
}
Collections.sort(results);
@@ -328,8 +330,9 @@ public class SearchAssistManager {
}
}
- public List<SearchSuggestion> getAdvancedSuggestions(String expression, int caretPos,
- SearchSuggestion.Kind targetKind) {
+ public List<SearchSuggestion> getAdvancedSuggestions(String expression, int caretPos) {
+ AbstractSearchAssistant completor = getSearchAssistant();
+
debug("getAdvancedSuggestions: START");
long id = HibernatePerformanceMonitor.get().start();
SearchTermAssistant assistant = new SearchTermAssistant(expression, caretPos);
@@ -339,7 +342,7 @@ public class SearchAssistManager {
if (tokens.length == 0) {
debug("getAdvancedSuggestions: no terms");
- return convert(getAllContexts(), targetKind); // no terms yet defined
+ return convert(getAllContexts()); // no terms yet defined
}
String beforeCaret = assistant.getFragmentBeforeCaret();
@@ -352,26 +355,26 @@ public class SearchAssistManager {
if (parsed.context.equals("")) {
if (tokens.length == 1) {
debug("getAdvancedSuggestions: no terms yet, suggesting contexts");
- return convert(getAllContexts(), targetKind);
+ return convert(getAllContexts());
} else if (isBooleanTerm(assistant.getPreviousToken())) {
debug("getAdvancedSuggestions: previous term was boolean, suggesting contexts");
- return convert(getAllContexts(), targetKind);
+ return convert(getAllContexts());
} else {
debug("getAdvancedSuggestions: previous term was not boolean, suggesting boolean");
- return convert(booleanOperators, targetKind);
+ return convert(booleanOperators);
}
} else if (isBooleanTerm(parsed.context)) {
debug("getAdvancedSuggestions: beforeCaret is whole boolean operator");
- return convert(getAllContexts(), targetKind); // TODO: should we tell user to type a space first?
+ return convert(getAllContexts()); // TODO: should we tell user to type a space first?
} else {
// check if this context is complete or not
if (completor.getSimpleContexts().contains(parsed.context)) {
debug("getAdvancedSuggestions: search term is simple context, wants operator");
- return convert(pad(parsed.context, comparisonOperators, ""), targetKind);
+ return convert(pad(parsed.context, comparisonOperators, ""));
}
if (completor.getParameterizedContexts().contains(parsed.context)) {
debug("getAdvancedSuggestions: search term is parameterized context, wants open bracket");
- return convert(Arrays.asList(parsed.context + "["), targetKind);
+ return convert(Arrays.asList(parsed.context + "["));
}
debug("getAdvancedSuggestions: search term wants context completion");
@@ -386,12 +389,11 @@ public class SearchAssistManager {
startsWithContexts.add(context + "[");
}
}
- return convert(startsWithContexts, targetKind);
+ return convert(startsWithContexts);
}
case PARAM:
debug("getAdvancedSuggestions: param state");
- return convert(pad(parsed.context + "[", completor.getParameters(parsed.context, parsed.param), "]"),
- targetKind);
+ return convert(pad(parsed.context + "[", completor.getParameters(parsed.context, parsed.param), "]"));
case OPERATOR:
debug("getAdvancedSuggestions: operator state");
if (comparisonOperators.contains(parsed.operator)) {
@@ -399,11 +401,11 @@ public class SearchAssistManager {
List<String> valueSuggestions = pad("\"", completor.getValues(parsed.context, parsed.param, ""), "\"");
if (completor.getSimpleContexts().contains(parsed.context)) {
debug("getAdvancedSuggestions: suggesting value completions for a simple context");
- return convert(pad(parsed.context + parsed.operator, valueSuggestions, ""), targetKind);
+ return convert(pad(parsed.context + parsed.operator, valueSuggestions, ""));
} else {
debug("getAdvancedSuggestions: suggesting value completions for a parameterized context");
return convert(pad(parsed.context + "[" + parsed.param + "]" + parsed.operator, valueSuggestions,
- ""), targetKind);
+ ""));
}
}
@@ -416,9 +418,9 @@ public class SearchAssistManager {
debug("getAdvancedSuggestions: providing suggestions for comparison operators");
if (completor.getSimpleContexts().contains(parsed.context)) {
- return convert(pad(parsed.context, operatorSuggestions, ""), targetKind);
+ return convert(pad(parsed.context, operatorSuggestions, ""));
} else {
- return convert(pad(parsed.context + "[" + parsed.param + "]", operatorSuggestions, ""), targetKind);
+ return convert(pad(parsed.context + "[" + parsed.param + "]", operatorSuggestions, ""));
}
case VALUE:
debug("getAdvancedSuggestions: value state");
@@ -426,11 +428,10 @@ public class SearchAssistManager {
"\"");
if (completor.getSimpleContexts().contains(parsed.context)) {
debug("getAdvancedSuggestions: suggesting value completions for a simple context");
- return convert(pad(parsed.context + parsed.operator, valueSuggestions, ""), targetKind);
+ return convert(pad(parsed.context + parsed.operator, valueSuggestions, ""));
} else {
debug("getAdvancedSuggestions: suggesting value completions for a parameterized context");
- return convert(pad(parsed.context + "[" + parsed.param + "]" + parsed.operator, valueSuggestions, ""),
- targetKind);
+ return convert(pad(parsed.context + "[" + parsed.param + "]" + parsed.operator, valueSuggestions, ""));
}
default:
return Collections.emptyList();
@@ -440,6 +441,7 @@ public class SearchAssistManager {
public List<SearchSuggestion> getUserSavedSearchSuggestions(String expression) {
SavedSearchCriteria criteria = new SavedSearchCriteria();
criteria.addFilterSubjectId(subject.getId());
+ criteria.addFilterSearchContext(searchSubsystem);
if (expression != null && expression.trim().equals("")) {
criteria.addFilterName(expression);
}
@@ -494,10 +496,10 @@ public class SearchAssistManager {
return false;
}
- private List<SearchSuggestion> convert(List<String> suggestions, SearchSuggestion.Kind targetKind) {
+ private List<SearchSuggestion> convert(List<String> suggestions) {
List<SearchSuggestion> results = new ArrayList<SearchSuggestion>(suggestions.size());
for (String suggestion : suggestions) {
- results.add(new SearchSuggestion(targetKind, suggestion));
+ results.add(new SearchSuggestion(Kind.Advanced, suggestion));
}
return results;
}
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/GenericSearchAssistTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/GenericSearchAssistTest.java
index 5d51d10..0a28dee 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/GenericSearchAssistTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/GenericSearchAssistTest.java
@@ -36,7 +36,7 @@ public class GenericSearchAssistTest extends AbstractEJB3Test {
}
count++;
- List<SearchSuggestion> results = new TestAutoCompletionManager().getSuggestions(expression,
+ List<SearchSuggestion> results = new TestAutoCompletionManager().getAdvancedSuggestions(expression,
expression.length());
List<String> expectedResults = Arrays.asList(expected.split(" "));
@@ -51,7 +51,8 @@ public class GenericSearchAssistTest extends AbstractEJB3Test {
}
System.out.println("Tested " + count + " expressions for assist");
} catch (Exception e) {
- System.out.println("Error testing single line RHQL: " + e);
+ System.out.println("Error testing GenericSearchAssistTest: " + e);
+ e.printStackTrace(System.out);
throw e;
} finally {
if (reader != null) {
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/TestAutoCompletionManager.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/TestAutoCompletionManager.java
index 28a11a7..704146b 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/TestAutoCompletionManager.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/TestAutoCompletionManager.java
@@ -9,6 +9,7 @@ import java.util.Map;
import org.rhq.core.domain.search.SearchSubsystem;
import org.rhq.enterprise.server.search.assist.AbstractSearchAssistant;
import org.rhq.enterprise.server.search.execution.SearchAssistManager;
+import org.rhq.enterprise.server.util.LookupUtil;
public class TestAutoCompletionManager extends SearchAssistManager {
public static class TestAutoCompletor extends AbstractSearchAssistant {
@@ -61,10 +62,12 @@ public class TestAutoCompletionManager extends SearchAssistManager {
}
public TestAutoCompletionManager() {
- super(null, null);
+ super(LookupUtil.getSubjectManager().getOverlord(), null);
}
- protected AbstractSearchAssistant getAutoCompletor(SearchSubsystem searchContext) {
+ @Override
+ protected AbstractSearchAssistant getSearchAssistant() {
return new TestAutoCompletor();
+
}
}
commit 7064ea6ab73f1899567ed6bd6e48ee86aaf3f2cc
Author: Joseph Marques <joseph(a)redhat.com>
Date: Mon Apr 26 13:04:08 2010 -0400
BZ-562816: fix regression in custom alert sender UI
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/alert/notification/details.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/alert/notification/details.xhtml
index b8ae721..fd83f96 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/alert/notification/details.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/alert/notification/details.xhtml
@@ -56,7 +56,7 @@
<f:facet name="header">
<h:outputText value="Name" />
</f:facet>
- <h:outputText value="#{alertNotification.name}" />
+ <h:outputText value="#{alertNotification.displayName}" />
</rich:column>
<rich:column width="20%">
<f:facet name="header">
commit 8f4b79421c74e3d50abb3d8ab209168912e4c8fa
Author: Joseph Marques <joseph(a)redhat.com>
Date: Mon Apr 26 13:03:16 2010 -0400
continuing development on search subsystem:
add support for simple search terms (as opposed to context=value advanced expressions)
fixed search portlet on the dashboard to point to the JSF-based inventory browser
added display of global and user-specific saved searches to the resources menu
support for loading saved searches from the menu bar, pre-populating the search textbox
support for loading saved searches from the search suggestion, pre-populating the search textbox
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/search-schema.xml b/modules/core/dbutils/src/main/scripts/dbsetup/search-schema.xml
index 14634b6..7910f84 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/search-schema.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/search-schema.xml
@@ -12,7 +12,6 @@
<column name="DESCRIPTION" type="VARCHAR2" size="500" required="false"/>
<column name="PATTERN" type="VARCHAR2" size="1000" required="true"/>
- <column name="JPQL_TRANSLATION" type="VARCHAR2" size="4000" required="false"/>
<column name="LAST_COMPUTE_TIME" type="LONG" required="true"/>
<column name="RESULT_COUNT" type="LONG" required="false"/>
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/plugin/AbstractPlugin.java b/modules/core/domain/src/main/java/org/rhq/core/domain/plugin/AbstractPlugin.java
index d056fbb..e64c22b 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/plugin/AbstractPlugin.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/plugin/AbstractPlugin.java
@@ -23,7 +23,6 @@
package org.rhq.core.domain.plugin;
-import java.io.ByteArrayInputStream;
import java.io.Serializable;
import javax.persistence.Column;
@@ -40,8 +39,6 @@ import javax.persistence.PrePersist;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
-import org.rhq.core.util.MessageDigestGenerator;
-
/**
* Base plugin implementation that agent and server plugin implementations extend.
*
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/search/SavedSearch.java b/modules/core/domain/src/main/java/org/rhq/core/domain/search/SavedSearch.java
index a9d4ff1..147942b 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/search/SavedSearch.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/search/SavedSearch.java
@@ -22,13 +22,18 @@
*/
package org.rhq.core.domain.search;
+import java.io.Serializable;
+
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
+import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
@@ -55,7 +60,9 @@ import org.rhq.core.domain.auth.Subject;
@Entity
@SequenceGenerator(name = "id", sequenceName = "RHQ_SAVED_SEARCH_ID_SEQ")
@Table(name = "RHQ_SAVED_SEARCH")
-public class SavedSearch {
+public class SavedSearch implements Serializable {
+
+ private static final long serialVersionUID = 1L;
@Id
@Column(name = "ID", nullable = false)
@@ -75,16 +82,14 @@ public class SavedSearch {
@Column(name = "PATTERN", nullable = false)
private String pattern;
- @Column(name = "JPQL_TRANSLATION")
- private String jpqlTranslation;
-
@Column(name = "LAST_COMPUTE_TIME", nullable = false)
private long lastComputeTime;
@Column(name = "RESULT_COUNT")
private Long resultCount;
- @Column(name = "SUBJECT_ID", nullable = false)
+ @JoinColumn(name = "SUBJECT_ID", nullable = false)
+ @ManyToOne(fetch = FetchType.LAZY)
private Subject subject;
@Column(name = "SUBJECT_ID", insertable = false, updatable = false)
@@ -105,7 +110,6 @@ public class SavedSearch {
setName(name); // name can be null, to allow for saving searches quickly
this.description = null;
- this.jpqlTranslation = null; // null value for pre-computed JPQL implies computation is needed
this.lastComputeTime = 0; // further imply that computation needs to occur
this.resultCount = null; // NULL resultCount implies either computation failed or hasn't begun yet
this.global = false; // user must promote saved search to be a global after creation
@@ -157,14 +161,6 @@ public class SavedSearch {
this.pattern = pattern;
}
- public String getJpqlTranslation() {
- return jpqlTranslation;
- }
-
- public void setJpqlTransation(String jpqlTranslation) {
- this.jpqlTranslation = jpqlTranslation;
- }
-
public long getLastComputeTime() {
return lastComputeTime;
}
@@ -250,4 +246,19 @@ public class SavedSearch {
return true;
}
+
+ @Override
+ public String toString() {
+ return "SavedSearch [" //
+ + "id=" + id //
+ + ", context=" + context //
+ + ", description=" + description //
+ + ", global=" + global //
+ + ", lastComputeTime=" + lastComputeTime //
+ + ", name=" + name //
+ + ", pattern=" + pattern //
+ + ", resultCount=" + resultCount //
+ + ", subjectId=" + subjectId + "]";
+ }
+
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/search/SearchSubsystem.java b/modules/core/domain/src/main/java/org/rhq/core/domain/search/SearchSubsystem.java
index a834833..cc489f8 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/search/SearchSubsystem.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/search/SearchSubsystem.java
@@ -25,6 +25,7 @@ package org.rhq.core.domain.search;
import java.util.HashMap;
import java.util.Map;
+import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.group.ResourceGroup;
/**
@@ -40,8 +41,8 @@ import org.rhq.core.domain.resource.group.ResourceGroup;
*/
public enum SearchSubsystem {
- Resource(org.rhq.core.domain.resource.Resource.class), //
- Group(ResourceGroup.class);
+ RESOURCE(Resource.class), //
+ GROUP(ResourceGroup.class);
private Class<?> entityClass;
private static Map<Class<?>, SearchSubsystem> subsystems;
@@ -63,4 +64,13 @@ public enum SearchSubsystem {
public static SearchSubsystem get(Class<?> entityClass) {
return SearchSubsystem.subsystems.get(entityClass);
}
+
+ /**
+ * A Java bean style getter to allow us to access the enum name from JSP or Facelets pages
+ *
+ * @return the enum name
+ */
+ public String getName() {
+ return name();
+ }
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/search/SearchSuggestion.java b/modules/core/domain/src/main/java/org/rhq/core/domain/search/SearchSuggestion.java
new file mode 100644
index 0000000..7e47275
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/search/SearchSuggestion.java
@@ -0,0 +1,94 @@
+package org.rhq.core.domain.search;
+
+import java.io.Serializable;
+
+public class SearchSuggestion implements Serializable, Comparable<SearchSuggestion> {
+
+ private static final long serialVersionUID = 1L;
+
+ public enum Kind {
+ Unknown(""), //
+ InstructionalTextComment(""), //
+ GlobalSavedSearch("GLOBAL"), //
+ UserSavedSearch("SAVED"), //
+ AdvancedOperator("SYNTAX"), //
+ Advanced("QUERY"), //
+ Simple("TEXT");
+
+ private String displayName;
+
+ private Kind(String displayName) {
+ this.displayName = displayName;
+ }
+
+ public String getDisplayName() {
+ return displayName;
+ }
+
+ public String getName() {
+ return name();
+ }
+ }
+
+ private final Kind kind;
+ private final String value;
+ private final String label;
+ private final int startIndex;
+ private final int endIndex;
+
+ public SearchSuggestion(Kind kind, String value) {
+ this(kind, value, 0, 0);
+ }
+
+ public SearchSuggestion(Kind kind, String value, int startIndex, int length) {
+ this.kind = kind;
+ this.label = value;
+ this.value = value;
+ this.startIndex = startIndex;
+ this.endIndex = startIndex + length;
+ }
+
+ public SearchSuggestion(Kind kind, String label, String value, int startIndex, int length) {
+ this.kind = kind;
+ this.label = label;
+ this.value = value;
+ this.startIndex = startIndex;
+ this.endIndex = startIndex + length;
+ }
+
+ public Kind getKind() {
+ return kind;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public int getStartIndex() {
+ return startIndex;
+ }
+
+ public int getEndIndex() {
+ return endIndex;
+ }
+
+ @Override
+ public int compareTo(SearchSuggestion other) {
+ int kindComparision = (this.kind.ordinal() - other.kind.ordinal());
+ if (kindComparision != 0) {
+ return kindComparision;
+ }
+ return label.compareTo(other.label);
+ }
+
+ public String toString() {
+ String before = label.substring(0, startIndex);
+ String highlight = label.substring(startIndex, endIndex);
+ String after = label.substring(endIndex);
+ return before + "(" + highlight + ")" + after + "->" + value;
+ }
+}
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/framework/UserPreferencesUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/framework/UserPreferencesUIBean.java
index 0b87f7f..8fa9e9f 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/framework/UserPreferencesUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/framework/UserPreferencesUIBean.java
@@ -19,15 +19,14 @@
package org.rhq.enterprise.gui.common.framework;
import java.util.List;
-import java.util.Enumeration;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.criteria.SavedSearchCriteria;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.group.ResourceGroup;
+import org.rhq.core.domain.search.SavedSearch;
import org.rhq.core.domain.util.PageControl;
+import org.rhq.core.domain.util.PageOrdering;
import org.rhq.core.gui.util.FacesContextUtility;
import org.rhq.enterprise.gui.legacy.ParamConstants;
import org.rhq.enterprise.gui.legacy.WebUser;
@@ -35,6 +34,7 @@ import org.rhq.enterprise.gui.legacy.WebUserPreferences;
import org.rhq.enterprise.gui.util.EnterpriseFacesContextUtility;
import org.rhq.enterprise.server.resource.ResourceManagerLocal;
import org.rhq.enterprise.server.resource.group.ResourceGroupManagerLocal;
+import org.rhq.enterprise.server.search.SavedSearchManagerLocal;
import org.rhq.enterprise.server.util.LookupUtil;
/**
@@ -42,23 +42,40 @@ import org.rhq.enterprise.server.util.LookupUtil;
*/
public class UserPreferencesUIBean {
- private final Log log = LogFactory.getLog(UserPreferencesUIBean.class);
+ //private final Log log = LogFactory.getLog(UserPreferencesUIBean.class);
public static final String LEFT_RESOURCE_NAV_SHOWING = "ui.leftResourceNavShowing";
public static final String SUMMARY_PANEL_DISPLAY_STATE = "ui.summaryPanelDisplayState";
private ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();
private ResourceGroupManagerLocal groupManager = LookupUtil.getResourceGroupManager();
+ private SavedSearchManagerLocal savedSearchManager = LookupUtil.getSavedSearchManager();
+
private List<Resource> resourceFavorites;
private List<ResourceGroup> groupFavorites;
+ private List<SavedSearch> savedSearches;
private String refreshPath;
+ private WebUser webUser;
+ private Subject subject;
+
public Subject getSubject() {
- return EnterpriseFacesContextUtility.getSubject();
+ if (subject == null) {
+ loadUserInfo();
+ }
+ return subject;
}
public WebUser getWebUser() {
- return EnterpriseFacesContextUtility.getWebUser();
+ if (webUser == null) {
+ loadUserInfo();
+ }
+ return webUser;
+ }
+
+ private void loadUserInfo() {
+ webUser = EnterpriseFacesContextUtility.getWebUser();
+ subject = webUser.getSubject();
}
public String getLeftResourceNavState() {
@@ -68,8 +85,7 @@ public class UserPreferencesUIBean {
}
public void setLeftResourceNavState(String state) {
- WebUser webUser = EnterpriseFacesContextUtility.getWebUser();
- WebUserPreferences preferences = webUser.getWebPreferences();
+ WebUserPreferences preferences = getWebUser().getWebPreferences();
preferences.setPreference(LEFT_RESOURCE_NAV_SHOWING, state);
}
@@ -95,17 +111,13 @@ public class UserPreferencesUIBean {
}
public void setPageRefresh(int refresh, String path) {
- WebUser webUser = EnterpriseFacesContextUtility.getWebUser();
- WebUserPreferences preferences = webUser.getWebPreferences();
+ WebUserPreferences preferences = getWebUser().getWebPreferences();
preferences.setPreference("PATH_REFRESH." + path, refresh);
}
-
-
public int getPageRefresh() {
- WebUser webUser = EnterpriseFacesContextUtility.getWebUser();
- WebUserPreferences preferences = webUser.getWebPreferences();
+ WebUserPreferences preferences = getWebUser().getWebPreferences();
String path = (String) FacesContextUtility.getRequest().getAttribute("javax.servlet.forward.request_uri");
if (path == null) {
@@ -124,13 +136,11 @@ public class UserPreferencesUIBean {
}
public String getSummaryPanelDisplayState() {
- return EnterpriseFacesContextUtility.getWebUser().getWebPreferences().getPreference(
- SUMMARY_PANEL_DISPLAY_STATE, "true");
+ return getWebUser().getWebPreferences().getPreference(SUMMARY_PANEL_DISPLAY_STATE, "true");
}
public void setSummaryPanelDisplayState(String state) {
- WebUser webUser = EnterpriseFacesContextUtility.getWebUser();
- WebUserPreferences preferences = webUser.getWebPreferences();
+ WebUserPreferences preferences = getWebUser().getWebPreferences();
preferences.setPreference(SUMMARY_PANEL_DISPLAY_STATE, state);
}
@@ -146,6 +156,20 @@ public class UserPreferencesUIBean {
return resourceFavorites;
}
+ public List<SavedSearch> getSavedSearches() {
+ if (savedSearches == null) {
+ SavedSearchCriteria criteria = new SavedSearchCriteria();
+ criteria.addFilterSubjectId(getSubject().getId());
+ criteria.addFilterGlobal(true);
+ criteria.setFiltersOptional(true); // get this user's searches as well as global ones
+ criteria.addSortGlobal(PageOrdering.DESC); // globals, then user-specified
+ criteria.addSortName(PageOrdering.ASC); // each sublist is alphabetical
+
+ savedSearches = savedSearchManager.findSavedSearchesByCriteria(getSubject(), criteria);
+ }
+ return savedSearches;
+ }
+
public List<ResourceGroup> getGroupFavorites() {
if (groupFavorites == null) {
WebUser user = EnterpriseFacesContextUtility.getWebUser();
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/browse/BrowseGroupsUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/browse/BrowseGroupsUIBean.java
index 37941e7..aad85f1 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/browse/BrowseGroupsUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/browse/BrowseGroupsUIBean.java
@@ -13,6 +13,7 @@ import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.criteria.ResourceGroupCriteria;
import org.rhq.core.domain.resource.group.GroupCategory;
import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
+import org.rhq.core.domain.search.SearchSuggestion;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.gui.util.FacesContextUtility;
@@ -21,7 +22,6 @@ import org.rhq.enterprise.gui.common.framework.PagedDataTableUIBean;
import org.rhq.enterprise.gui.common.paging.PageControlView;
import org.rhq.enterprise.gui.common.paging.PagedListDataModel;
import org.rhq.enterprise.server.resource.group.ResourceGroupManagerLocal;
-import org.rhq.enterprise.server.search.execution.SearchSuggestion;
import org.rhq.enterprise.server.util.LookupUtil;
public class BrowseGroupsUIBean extends PagedDataTableUIBean {
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/browse/BrowseResourcesUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/browse/BrowseResourcesUIBean.java
index 074cd3a..e01a8f2 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/browse/BrowseResourcesUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/browse/BrowseResourcesUIBean.java
@@ -13,7 +13,9 @@ import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.criteria.ResourceCriteria;
import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.resource.composite.ResourceComposite;
+import org.rhq.core.domain.search.SavedSearch;
import org.rhq.core.domain.search.SearchSubsystem;
+import org.rhq.core.domain.search.SearchSuggestion;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.gui.util.FacesContextUtility;
@@ -24,8 +26,8 @@ import org.rhq.enterprise.gui.common.paging.PageControlView;
import org.rhq.enterprise.gui.common.paging.ResourceNameDisambiguatingPagedListDataModel;
import org.rhq.enterprise.gui.util.EnterpriseFacesContextUtility;
import org.rhq.enterprise.server.resource.ResourceManagerLocal;
+import org.rhq.enterprise.server.search.SavedSearchManagerLocal;
import org.rhq.enterprise.server.search.execution.SearchAssistManager;
-import org.rhq.enterprise.server.search.execution.SearchSuggestion;
import org.rhq.enterprise.server.util.HibernatePerformanceMonitor;
import org.rhq.enterprise.server.util.LookupUtil;
@@ -34,10 +36,13 @@ public class BrowseResourcesUIBean extends PagedDataTableUIBean {
public static final String MANAGED_BEAN_NAME = "BrowseResourcesUIBean";
- private String filter;
- private HtmlInputText filterInput;
+ private String search;
+ private HtmlInputText searchInput;
private ResourceCategory category;
+ private ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();
+ private SavedSearchManagerLocal savedSearchManager = LookupUtil.getSavedSearchManager();
+
private static final IntExtractor<ResourceComposite> RESOURCE_ID_EXTRATOR = new IntExtractor<ResourceComposite>() {
public int extract(ResourceComposite object) {
return object.getResource().getId();
@@ -54,15 +59,21 @@ public class BrowseResourcesUIBean extends PagedDataTableUIBean {
category = ResourceCategory.SERVICE;
}
- filter = FacesContextUtility.getOptionalRequestParameter("filter");
+ String searchId = FacesContextUtility.getOptionalRequestParameter("searchId");
+ if (searchId != null) {
+ SavedSearch savedSearch = savedSearchManager.getSavedSearchById(getSubject(), Integer.valueOf(searchId));
+ search = savedSearch.getPattern();
+ } else {
+ search = FacesContextUtility.getOptionalRequestParameter("search");
+ }
}
- public String getFilter() {
- return this.filter;
+ public String getSearch() {
+ return this.search;
}
- public void setFilter(String filter) {
- this.filter = filter;
+ public void setSearch(String search) {
+ this.search = search;
}
public ResourceCategory getCategory() {
@@ -77,8 +88,6 @@ public class BrowseResourcesUIBean extends PagedDataTableUIBean {
return dataModel;
}
- private ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();
-
private class ResultsDataModel extends ResourceNameDisambiguatingPagedListDataModel<ResourceComposite> {
public ResultsDataModel(PageControlView view, String beanName) {
@@ -86,14 +95,14 @@ public class BrowseResourcesUIBean extends PagedDataTableUIBean {
}
public PageList<ResourceComposite> fetchDataForPage(PageControl pc) {
- String filter = getFilter();
+ String search = getSearch();
ResourceCategory category = getCategory();
ResourceCriteria criteria = new ResourceCriteria();
criteria.setPageControl(pc);
criteria.addFilterResourceCategory(category);
- if (filter != null && !filter.trim().equals("")) {
- criteria.setSearchExpression(filter);
+ if (search != null && !search.trim().equals("")) {
+ criteria.setSearchExpression(search);
}
criteria.fetchParentResource(true);
@@ -127,25 +136,24 @@ public class BrowseResourcesUIBean extends PagedDataTableUIBean {
return FacesContextUtility.getRequest().getParameterValues("selectedItems");
}
- SearchAssistManager searchAssist = new SearchAssistManager(SearchSubsystem.Resource);
+ SearchAssistManager searchAssist = new SearchAssistManager(getSubject(), SearchSubsystem.RESOURCE);
public List<SearchSuggestion> autocomplete(Object suggest) {
String currentInputText = (String) suggest;
// assume caret at the end of the input
long id = HibernatePerformanceMonitor.get().start();
- List<SearchSuggestion> suggestions = searchAssist.getAdvancedSuggestions(currentInputText, currentInputText
- .length());
+ List<SearchSuggestion> suggestions = searchAssist.getSuggestions(currentInputText, currentInputText.length());
HibernatePerformanceMonitor.get().stop(id, "ResourceSuggestions");
return suggestions;
}
- public HtmlInputText getFilterInput() {
- return filterInput;
+ public HtmlInputText getSearchInput() {
+ return searchInput;
}
- public void setFilterInput(HtmlInputText filterInput) {
- this.filterInput = filterInput;
+ public void setSearchInput(HtmlInputText searchInput) {
+ this.searchInput = searchInput;
}
}
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/hub/ResourceHubPortalAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/hub/ResourceHubPortalAction.java
index f3d14be..1c775c8 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/hub/ResourceHubPortalAction.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/hub/ResourceHubPortalAction.java
@@ -36,6 +36,7 @@ import org.jetbrains.annotations.NotNull;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.plugin.Plugin;
+import org.rhq.core.domain.resource.InventorySummary;
import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.resource.composite.ResourceComposite;
import org.rhq.core.domain.util.PageList;
@@ -48,7 +49,6 @@ import org.rhq.enterprise.gui.legacy.util.HubUtils;
import org.rhq.enterprise.gui.legacy.util.RequestUtils;
import org.rhq.enterprise.gui.legacy.util.SessionUtils;
import org.rhq.enterprise.gui.util.WebUtility;
-import org.rhq.core.domain.resource.InventorySummary;
import org.rhq.enterprise.server.resource.ResourceTypeManagerLocal;
import org.rhq.enterprise.server.util.LookupUtil;
@@ -86,29 +86,23 @@ public class ResourceHubPortalAction extends BaseAction {
messages = getResources(request);
ResourceHubForm hubForm = (ResourceHubForm) form;
- /*
- * once search functionality is complete, this will redirect to the new inventory manager;
- * until then, keep it working against the old ResourceHub
- */
- if (false) {
- String filter = hubForm.getKeywords();
- if (filter.equals("Resource Name")) {
- filter = null; // user didn't type a filter, just selected a category and clicked 'GO'
- }
- String category = hubForm.getResourceCategory();
- String subtab = "all";
- try {
- ResourceCategory.valueOf(category.toUpperCase());
- subtab = category.toLowerCase();
- } catch (Exception e) {
- subtab = "hub";
- }
- String url = "/rhq/inventory/browseResources.xhtml?subtab=" + subtab;
- if (filter != null && !filter.trim().equals("")) {
- url += "&filter=" + filter;
- }
- response.sendRedirect(url);
+ String searchExpression = hubForm.getKeywords();
+ if (searchExpression.equals("Resource Name")) {
+ searchExpression = null; // user didn't type a filter, just selected a category and clicked 'GO'
+ }
+ String category = hubForm.getResourceCategory();
+ String subtab = "all";
+ try {
+ ResourceCategory.valueOf(category.toUpperCase());
+ subtab = category.toLowerCase();
+ } catch (Exception e) {
+ subtab = "hub";
+ }
+ String url = "/rhq/inventory/browseResources.xhtml?subtab=" + subtab;
+ if (searchExpression != null && !searchExpression.trim().equals("")) {
+ url += "&search=name=" + searchExpression;
}
+ response.sendRedirect(url);
org.rhq.core.domain.util.PageControl pageControl = WebUtility.getPageControl(request);
Subject subject = RequestUtils.getSubject(request);
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/startup/StartupServlet.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/startup/StartupServlet.java
index d6cb267..51107b2 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/startup/StartupServlet.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/startup/StartupServlet.java
@@ -59,6 +59,7 @@ import org.rhq.enterprise.server.plugin.pc.ServerPluginServiceManagement;
import org.rhq.enterprise.server.resource.ResourceTypeManagerLocal;
import org.rhq.enterprise.server.scheduler.SchedulerLocal;
import org.rhq.enterprise.server.scheduler.jobs.AsyncResourceDeleteJob;
+import org.rhq.enterprise.server.scheduler.jobs.SavedSearchResultCountRecalculationJob;
import org.rhq.enterprise.server.scheduler.jobs.CheckForSuspectedAgentsJob;
import org.rhq.enterprise.server.scheduler.jobs.CheckForTimedOutConfigUpdatesJob;
import org.rhq.enterprise.server.scheduler.jobs.CheckForTimedOutContentRequestsJob;
@@ -325,6 +326,16 @@ public class StartupServlet extends HttpServlet {
LookupUtil.getSystemManager().scheduleConfigCacheReloader();
try {
+ // Do not check until we are up at least 1 min, and every minute thereafter.
+ final long initialDelay = 1000L * 60;
+ final long interval = 1000L * 60;
+ scheduler.scheduleSimpleRepeatingJob(SavedSearchResultCountRecalculationJob.class, true, false, initialDelay,
+ interval);
+ } catch (Exception e) {
+ log("Cannot schedule asynchronous resource deletion job: " + e.getMessage());
+ }
+
+ try {
// Do not check until we are up at least 1 min, and every 5 minutes thereafter.
final long initialDelay = 1000L * 60;
final long interval = 1000L * 60 * 5;
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/menu/menu.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/menu/menu.xhtml
index 232974b..8e016de 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/menu/menu.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/menu/menu.xhtml
@@ -124,6 +124,21 @@
</c:if>
</c:forEach>
</rich:menuGroup>
+
+ <ui:remove>***** Resources > SAVED SEARCHES *****</ui:remove>
+ <rich:menuGroup value="Saved Searches" icon="/images/bookmark.png">
+ <c:forEach var="savedSearch" items="#{UserPreferencesUIBean.savedSearches}">
+ <c:if test="#{savedSearch.context.name == 'RESOURCE'}">
+ <rich:menuItem submitMode="none"
+ icon="/images/icons/Flag_#{savedSearch.global ? 'yellow' : 'blue'}_16.png"
+ onclick="window.location = '/rhq/inventory/browseResources.xhtml?subtab=all&searchId=#{savedSearch.id}'">
+ <h:outputText value="#{savedSearch.name}" />
+ <h:outputText value=" (#{savedSearch.resultCount})"
+ rendered="#{not empty savedSearch.resultCount}" />
+ </rich:menuItem>
+ </c:if>
+ </c:forEach>
+ </rich:menuGroup>
<rich:menuSeparator/>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/inventory/browseResources.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/inventory/browseResources.xhtml
index ac11225..90d45c0 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/inventory/browseResources.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/inventory/browseResources.xhtml
@@ -31,17 +31,23 @@
<a4j:keepAlive beanName="BrowseResourcesUIBean"/>
<h:form id="browseResourcesForm">
- <input type="hidden" name="subtab" value="${param.subtab}"/>
+ <input type="hidden" name="subtab" value="${param.subtab}" />
<p/>
<h:panelGroup>
- <h:outputLabel for="filter" value="Search: " />
- <h:inputText id="filter"
- binding="#{BrowseResourcesUIBean.filterInput}"
- value="#{BrowseResourcesUIBean.filter}"
+ <h:outputLabel for="search" value="Search: " />
+ <h:inputText id="search"
+ binding="#{BrowseResourcesUIBean.searchInput}"
+ value="#{BrowseResourcesUIBean.search}"
onkeypress="return ignoreEnterKey(event);"
- style="width: 600px;" />
- <rich:suggestionbox id="suggest" for="filter"
+ style="width: 600px;">
+ <ui:remove>
+ <a4j:support event="onfocus" reRender="suggest"
+ disableDefault="true" status="commonStatus" limitToList="true"
+ ajaxSingle="true" oncomplete="#{rich:component('suggest')}.show(event, {})"/>
+ </ui:remove>
+ </h:inputText>
+ <rich:suggestionbox id="suggest" for="search"
width="600" height="400"
border="1" cellpadding="1" cellspacing="1"
minChars="0"
@@ -56,7 +62,19 @@
eventsQueue="resourceSearchSuggestions"
ignoreDupResponses="true"
rendered="true"> <!-- disable until auto-completer is added -->
- <h:column>
+ <h:column width="10%">
+ <h:outputText value="#{suggestItem.kind.displayName}" style="font-variant: small-caps; color: gray;"
+ rendered="#{suggestItem.kind.name eq 'Simple'}" />
+ <h:outputText value="#{suggestItem.kind.displayName}" style="font-variant: small-caps; "
+ rendered="#{suggestItem.kind.name eq 'Advanced'}" />
+ <h:outputText value="#{suggestItem.kind.displayName}" style="font-variant: small-caps; color: yellow"
+ rendered="#{suggestItem.kind.name eq 'AdvancedOperator'}" />
+ <h:outputText value="#{suggestItem.kind.displayName}" style="font-variant: small-caps; color: green;"
+ rendered="#{suggestItem.kind.name eq 'UserSavedSearch'}" />
+ <h:outputText value="#{suggestItem.kind.displayName}" style="font-variant: small-caps; color: orange;"
+ rendered="#{suggestItem.kind.name eq 'GlobalSavedSearch'}" />
+ </h:column>
+ <h:column width="90%">
<h:outputText value="#{suggestItem.label}" />
</h:column>
</rich:suggestionbox>
diff --git a/modules/enterprise/server/jar/src/main/antlr3/org/rhq/enterprise/server/search/RHQL.g b/modules/enterprise/server/jar/src/main/antlr3/org/rhq/enterprise/server/search/RHQL.g
index b8ff97e..4fa879e 100644
--- a/modules/enterprise/server/jar/src/main/antlr3/org/rhq/enterprise/server/search/RHQL.g
+++ b/modules/enterprise/server/jar/src/main/antlr3/org/rhq/enterprise/server/search/RHQL.g
@@ -95,6 +95,7 @@ conditionalPrimary
simpleConditionalExpression
: c=context WS* op=comparisonOperator WS* ident=identifier -> ^($op $c ^(VALUE $ident))
+ | ident=identifier
; // rewrite tree output so operator is always the root -- ignore captured WS
context
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/SavedSearchResultCountRecalculationJob.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/SavedSearchResultCountRecalculationJob.java
new file mode 100644
index 0000000..a1e53b3
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/SavedSearchResultCountRecalculationJob.java
@@ -0,0 +1,95 @@
+/*
+ * 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.server.scheduler.jobs;
+
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.criteria.ResourceCriteria;
+import org.rhq.core.domain.criteria.SavedSearchCriteria;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.search.SavedSearch;
+import org.rhq.core.domain.search.SearchSubsystem;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.enterprise.server.resource.ResourceManagerLocal;
+import org.rhq.enterprise.server.search.SavedSearchManagerLocal;
+import org.rhq.enterprise.server.util.LookupUtil;
+
+/**
+ *
+ *
+ * @author Joseph Marques
+ */
+public class SavedSearchResultCountRecalculationJob extends AbstractStatefulJob {
+
+ private final static Log LOG = LogFactory.getLog(SavedSearchResultCountRecalculationJob.class);
+
+ private SavedSearchManagerLocal savedSearchManager = LookupUtil.getSavedSearchManager();
+ private ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();
+
+ private Subject overlord = LookupUtil.getSubjectManager().getOverlord();
+
+ @Override
+ public void executeJobCode(JobExecutionContext context) throws JobExecutionException {
+ List<SavedSearch> staleSavedSearches = getSavedSearchesNeedingRecomputation();
+
+ int errors = 0;
+ int updated = 0;
+ long totalMillis = 0;
+ for (SavedSearch next : staleSavedSearches) {
+ try {
+ if (next.getContext() == SearchSubsystem.RESOURCE) {
+ ResourceCriteria criteria = new ResourceCriteria();
+ criteria.setSearchExpression(next.getPattern());
+
+ totalMillis -= System.currentTimeMillis();
+ PageList<Resource> results = resourceManager.findResourcesByCriteria(overlord, criteria);
+ totalMillis += System.currentTimeMillis();
+
+ if (results.getTotalSize() != next.getResultCount()) {
+ next.setResultCount((long) results.getTotalSize());
+ savedSearchManager.updateSavedSearch(overlord, next);
+ updated++;
+ }
+ }
+ } catch (Throwable t) {
+ // TODO: mark this saved search as "broken" so that future computation is suppressed for it
+ errors++;
+ LOG.error("Could not calculate result count for SavedSearch[name=" + next.getName() + ", patter='"
+ + next.getPattern() + "']");
+ }
+ }
+ LOG.info("Statistics: updated " + updated + " in " + totalMillis + " ms (" + errors + " errors)");
+ }
+
+ private List<SavedSearch> getSavedSearchesNeedingRecomputation() {
+ long fiveMinutesAgo = System.currentTimeMillis() - (5 * 60 * 1000);
+
+ SavedSearchCriteria criteria = new SavedSearchCriteria();
+ criteria.addFilterLastComputeTimeMax(fiveMinutesAgo);
+
+ List<SavedSearch> results = savedSearchManager.findSavedSearchesByCriteria(overlord, criteria);
+ return results;
+ }
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/assist/AbstractSearchAssistant.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/assist/AbstractSearchAssistant.java
index 90c790f..05b39e1 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/assist/AbstractSearchAssistant.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/assist/AbstractSearchAssistant.java
@@ -12,6 +12,16 @@ import org.rhq.enterprise.server.util.LookupUtil;
public abstract class AbstractSearchAssistant implements SearchAssistant {
+ private int maxResultCount = 20;
+
+ public int getMaxResultCount() {
+ return maxResultCount;
+ }
+
+ public void setMaxResultCount(int maxResultCount) {
+ this.maxResultCount = maxResultCount;
+ }
+
@Override
public List<String> getSimpleContexts() {
return Collections.emptyList();
@@ -46,7 +56,7 @@ public abstract class AbstractSearchAssistant implements SearchAssistant {
@SuppressWarnings("unchecked")
protected final List<String> execute(String jpql) {
Query query = LookupUtil.getEntityManager().createQuery(jpql);
- query.setMaxResults(20);
+ query.setMaxResults(maxResultCount);
List<String> results = query.getResultList();
return results;
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/assist/ResourceSearchAssistant.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/assist/ResourceSearchAssistant.java
index 94dcb7f..0e2b3df 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/assist/ResourceSearchAssistant.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/assist/ResourceSearchAssistant.java
@@ -21,7 +21,7 @@ public class ResourceSearchAssistant extends AbstractSearchAssistant {
@Override
public SearchSubsystem getSearchSubsystem() {
- return SearchSubsystem.Resource;
+ return SearchSubsystem.RESOURCE;
}
@Override
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/assist/SearchAssistant.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/assist/SearchAssistant.java
index 804e0bb..4314e06 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/assist/SearchAssistant.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/assist/SearchAssistant.java
@@ -6,14 +6,14 @@ import org.rhq.core.domain.search.SearchSubsystem;
public interface SearchAssistant {
- public SearchSubsystem getSearchSubsystem();
+ SearchSubsystem getSearchSubsystem();
- public List<String> getSimpleContexts();
+ List<String> getSimpleContexts();
- public List<String> getParameterizedContexts();
+ List<String> getParameterizedContexts();
- public List<String> getParameters(String context, String filter);
+ List<String> getParameters(String context, String filter);
- public List<String> getValues(String context, String param, String filter);
+ List<String> getValues(String context, String param, String filter);
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/execution/SearchAssistManager.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/execution/SearchAssistManager.java
index e500449..2cb808c 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/execution/SearchAssistManager.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/execution/SearchAssistManager.java
@@ -9,19 +9,29 @@ import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.criteria.SavedSearchCriteria;
+import org.rhq.core.domain.search.SavedSearch;
import org.rhq.core.domain.search.SearchSubsystem;
+import org.rhq.core.domain.search.SearchSuggestion;
+import org.rhq.core.domain.search.SearchSuggestion.Kind;
+import org.rhq.core.domain.util.PageOrdering;
+import org.rhq.enterprise.server.search.SavedSearchManagerLocal;
+import org.rhq.enterprise.server.search.assist.AbstractSearchAssistant;
import org.rhq.enterprise.server.search.assist.ResourceSearchAssistant;
-import org.rhq.enterprise.server.search.assist.SearchAssistant;
import org.rhq.enterprise.server.util.HibernatePerformanceMonitor;
+import org.rhq.enterprise.server.util.LookupUtil;
public class SearchAssistManager {
private static final Log LOG = LogFactory.getLog(SearchAssistManager.class);
+ private SavedSearchManagerLocal savedSearchManager = LookupUtil.getSavedSearchManager();
private static List<String> comparisonOperators = Arrays.asList("!==", "!=", "==", "=");
- private static List<String> booleanOperators = Arrays.asList("and", "or");
+ private static List<String> booleanOperators = Arrays.asList("and", "or", "|");
- private SearchAssistant completor;
+ private Subject subject;
+ private AbstractSearchAssistant completor;
/*
* states:
@@ -266,12 +276,13 @@ public class SearchAssistManager {
}
}
- public SearchAssistManager(SearchSubsystem searchSubsystem) {
+ public SearchAssistManager(Subject subject, SearchSubsystem searchSubsystem) {
+ this.subject = subject;
this.completor = getAutoCompletor(searchSubsystem);
}
- protected SearchAssistant getAutoCompletor(SearchSubsystem searchSubsystem) {
- if (searchSubsystem == SearchSubsystem.Resource) {
+ protected AbstractSearchAssistant getAutoCompletor(SearchSubsystem searchSubsystem) {
+ if (searchSubsystem == SearchSubsystem.RESOURCE) {
return new ResourceSearchAssistant();
} else {
throw new IllegalArgumentException("No SearchAssistant found for SearchSubsystem[" + searchSubsystem + "]");
@@ -286,7 +297,39 @@ public class SearchAssistManager {
return results;
}
- public List<SearchSuggestion> getAdvancedSuggestions(String expression, int caretPos) {
+ public List<SearchSuggestion> getSuggestions(String expression, int caretPos) {
+ //List<SearchSuggestion> simple = getSimpleSuggestions(expression, caretPos);
+ List<SearchSuggestion> advanced = getAdvancedSuggestions(expression, caretPos, SearchSuggestion.Kind.Advanced);
+ List<SearchSuggestion> userSavedSearches = getUserSavedSearchSuggestions(expression);
+ List<SearchSuggestion> globalSavedSearches = getGlobalSavedSearchSuggestions(expression);
+
+ List<SearchSuggestion> results = new ArrayList<SearchSuggestion>();
+ //results.addAll(simple);
+ results.addAll(advanced);
+ results.addAll(userSavedSearches);
+ results.addAll(globalSavedSearches);
+ Collections.sort(results);
+ return results;
+ }
+
+ public List<SearchSuggestion> getSimpleSuggestions(String expression, int caretPos) {
+ List<SearchSuggestion> results = new ArrayList<SearchSuggestion>();
+ for (String nextContext : completor.getSimpleContexts()) {
+ String intermediateExpression = nextContext + "=" + expression;
+ List<SearchSuggestion> suggestions = getAdvancedSuggestions(intermediateExpression, caretPos,
+ SearchSuggestion.Kind.Simple);
+ results.addAll(suggestions);
+ }
+ Collections.sort(results);
+ if (results.size() > completor.getMaxResultCount()) {
+ return results.subList(0, completor.getMaxResultCount());
+ } else {
+ return results;
+ }
+ }
+
+ public List<SearchSuggestion> getAdvancedSuggestions(String expression, int caretPos,
+ SearchSuggestion.Kind targetKind) {
debug("getAdvancedSuggestions: START");
long id = HibernatePerformanceMonitor.get().start();
SearchTermAssistant assistant = new SearchTermAssistant(expression, caretPos);
@@ -296,7 +339,7 @@ public class SearchAssistManager {
if (tokens.length == 0) {
debug("getAdvancedSuggestions: no terms");
- return convert(getAllContexts()); // no terms yet defined
+ return convert(getAllContexts(), targetKind); // no terms yet defined
}
String beforeCaret = assistant.getFragmentBeforeCaret();
@@ -309,26 +352,26 @@ public class SearchAssistManager {
if (parsed.context.equals("")) {
if (tokens.length == 1) {
debug("getAdvancedSuggestions: no terms yet, suggesting contexts");
- return convert(getAllContexts());
+ return convert(getAllContexts(), targetKind);
} else if (isBooleanTerm(assistant.getPreviousToken())) {
debug("getAdvancedSuggestions: previous term was boolean, suggesting contexts");
- return convert(getAllContexts());
+ return convert(getAllContexts(), targetKind);
} else {
debug("getAdvancedSuggestions: previous term was not boolean, suggesting boolean");
- return convert(booleanOperators);
+ return convert(booleanOperators, targetKind);
}
} else if (isBooleanTerm(parsed.context)) {
debug("getAdvancedSuggestions: beforeCaret is whole boolean operator");
- return convert(getAllContexts()); // TODO: should we tell user to type a space first?
+ return convert(getAllContexts(), targetKind); // TODO: should we tell user to type a space first?
} else {
// check if this context is complete or not
if (completor.getSimpleContexts().contains(parsed.context)) {
debug("getAdvancedSuggestions: search term is simple context, wants operator");
- return convert(pad(parsed.context, comparisonOperators, ""));
+ return convert(pad(parsed.context, comparisonOperators, ""), targetKind);
}
if (completor.getParameterizedContexts().contains(parsed.context)) {
debug("getAdvancedSuggestions: search term is parameterized context, wants open bracket");
- return convert(Arrays.asList(parsed.context + "["));
+ return convert(Arrays.asList(parsed.context + "["), targetKind);
}
debug("getAdvancedSuggestions: search term wants context completion");
@@ -343,11 +386,12 @@ public class SearchAssistManager {
startsWithContexts.add(context + "[");
}
}
- return convert(startsWithContexts);
+ return convert(startsWithContexts, targetKind);
}
case PARAM:
debug("getAdvancedSuggestions: param state");
- return convert(pad(parsed.context + "[", completor.getParameters(parsed.context, parsed.param), "]"));
+ return convert(pad(parsed.context + "[", completor.getParameters(parsed.context, parsed.param), "]"),
+ targetKind);
case OPERATOR:
debug("getAdvancedSuggestions: operator state");
if (comparisonOperators.contains(parsed.operator)) {
@@ -355,11 +399,11 @@ public class SearchAssistManager {
List<String> valueSuggestions = pad("\"", completor.getValues(parsed.context, parsed.param, ""), "\"");
if (completor.getSimpleContexts().contains(parsed.context)) {
debug("getAdvancedSuggestions: suggesting value completions for a simple context");
- return convert(pad(parsed.context + parsed.operator, valueSuggestions, ""));
+ return convert(pad(parsed.context + parsed.operator, valueSuggestions, ""), targetKind);
} else {
debug("getAdvancedSuggestions: suggesting value completions for a parameterized context");
return convert(pad(parsed.context + "[" + parsed.param + "]" + parsed.operator, valueSuggestions,
- ""));
+ ""), targetKind);
}
}
@@ -372,9 +416,9 @@ public class SearchAssistManager {
debug("getAdvancedSuggestions: providing suggestions for comparison operators");
if (completor.getSimpleContexts().contains(parsed.context)) {
- return convert(pad(parsed.context, operatorSuggestions, ""));
+ return convert(pad(parsed.context, operatorSuggestions, ""), targetKind);
} else {
- return convert(pad(parsed.context + "[" + parsed.param + "]", operatorSuggestions, ""));
+ return convert(pad(parsed.context + "[" + parsed.param + "]", operatorSuggestions, ""), targetKind);
}
case VALUE:
debug("getAdvancedSuggestions: value state");
@@ -382,16 +426,65 @@ public class SearchAssistManager {
"\"");
if (completor.getSimpleContexts().contains(parsed.context)) {
debug("getAdvancedSuggestions: suggesting value completions for a simple context");
- return convert(pad(parsed.context + parsed.operator, valueSuggestions, ""));
+ return convert(pad(parsed.context + parsed.operator, valueSuggestions, ""), targetKind);
} else {
debug("getAdvancedSuggestions: suggesting value completions for a parameterized context");
- return convert(pad(parsed.context + "[" + parsed.param + "]" + parsed.operator, valueSuggestions, ""));
+ return convert(pad(parsed.context + "[" + parsed.param + "]" + parsed.operator, valueSuggestions, ""),
+ targetKind);
}
default:
return Collections.emptyList();
}
}
+ public List<SearchSuggestion> getUserSavedSearchSuggestions(String expression) {
+ SavedSearchCriteria criteria = new SavedSearchCriteria();
+ criteria.addFilterSubjectId(subject.getId());
+ if (expression != null && expression.trim().equals("")) {
+ criteria.addFilterName(expression);
+ }
+
+ criteria.setCaseSensitive(false);
+ criteria.addSortName(PageOrdering.ASC);
+
+ List<SavedSearch> savedSearchResults = savedSearchManager.findSavedSearchesByCriteria(subject, criteria);
+
+ List<SearchSuggestion> results = new ArrayList<SearchSuggestion>();
+ for (SavedSearch next : savedSearchResults) {
+ String label = next.getName();
+ String value = next.getPattern();
+ int index = next.getName().toLowerCase().indexOf(expression);
+ SearchSuggestion suggestion = new SearchSuggestion(Kind.UserSavedSearch, label, value, index, expression
+ .length());
+ results.add(suggestion);
+ }
+ return results;
+ }
+
+ public List<SearchSuggestion> getGlobalSavedSearchSuggestions(String expression) {
+ SavedSearchCriteria criteria = new SavedSearchCriteria();
+ criteria.addFilterGlobal(true);
+ if (expression != null && expression.trim().equals("")) {
+ criteria.addFilterName(expression);
+ }
+
+ criteria.setCaseSensitive(false);
+ criteria.addSortName(PageOrdering.ASC);
+
+ List<SavedSearch> savedSearchResults = savedSearchManager.findSavedSearchesByCriteria(subject, criteria);
+
+ List<SearchSuggestion> results = new ArrayList<SearchSuggestion>();
+ for (SavedSearch next : savedSearchResults) {
+ String label = next.getName();
+ String value = next.getPattern();
+ int index = next.getName().toLowerCase().indexOf(expression);
+ SearchSuggestion suggestion = new SearchSuggestion(Kind.GlobalSavedSearch, label, value, index, expression
+ .length());
+ results.add(suggestion);
+ }
+ return results;
+ }
+
private boolean isBooleanTerm(String term) {
for (String op : booleanOperators) {
if (op.equals(term)) {
@@ -401,10 +494,10 @@ public class SearchAssistManager {
return false;
}
- private List<SearchSuggestion> convert(List<String> suggestions) {
+ private List<SearchSuggestion> convert(List<String> suggestions, SearchSuggestion.Kind targetKind) {
List<SearchSuggestion> results = new ArrayList<SearchSuggestion>(suggestions.size());
for (String suggestion : suggestions) {
- results.add(new SearchSuggestion(SearchSuggestion.SearchCategory.Advanced, suggestion));
+ results.add(new SearchSuggestion(targetKind, suggestion));
}
return results;
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/execution/SearchSuggestion.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/execution/SearchSuggestion.java
deleted file mode 100644
index e69090d..0000000
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/execution/SearchSuggestion.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package org.rhq.enterprise.server.search.execution;
-
-public class SearchSuggestion {
- public enum SearchCategory {
- Simple, Advanced, SavedSearch, InstructionalTextComment, Unknown;
- }
-
- private final SearchCategory category;
- private final String value;
- private final String label;
- private final int startIndex;
- private final int endIndex;
-
- public SearchSuggestion(SearchCategory category, String value) {
- this(category, value, 0, 0);
- }
-
- public SearchSuggestion(SearchCategory category, String value, int startIndex, int length) {
- this.category = category;
- this.label = value;
- this.value = value;
- this.startIndex = startIndex;
- this.endIndex = startIndex + length;
- }
-
- public SearchCategory getCategory() {
- return category;
- }
-
- public String getLabel() {
- return label;
- }
-
- public String getValue() {
- return value;
- }
-
- public int getStartIndex() {
- return startIndex;
- }
-
- public int getEndIndex() {
- return endIndex;
- }
-
- public String toString() {
- String before = label.substring(0, startIndex);
- String highlight = label.substring(startIndex, endIndex);
- String after = label.substring(endIndex);
- return before + "(" + highlight + ")" + after + "->" + value;
- }
-}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/execution/SearchTranslationManager.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/execution/SearchTranslationManager.java
index 806987f..812bc57 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/execution/SearchTranslationManager.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/execution/SearchTranslationManager.java
@@ -57,19 +57,19 @@ public class SearchTranslationManager {
public String getJPQLSelectStatement() throws Exception {
String jpql = "SELECT " + alias + " FROM " + entity + " " + alias + " WHERE " + getJPQLWhereFragment();
- System.out.println("JPQL was:");
+ //System.out.println("JPQL was:");
PrintUtils.printJPQL(jpql.split(" "));
- System.out.println();
+ //System.out.println();
return jpql;
}
public String getJPQLWhereFragment() throws Exception {
RHQLParser.searchExpression_return searchAST = parser.searchExpression();
- System.out.println("Search was: " + expression);
+ //System.out.println("Search was: " + expression);
CommonTree searchExpressionTree = (CommonTree) searchAST.getTree();
- System.out.println("Errors found: " + adaptor.getErrorMessages());
- System.out.println("Tree was:");
+ //System.out.println("Errors found: " + adaptor.getErrorMessages());
+ //System.out.println("Tree was:");
PrintUtils.print(searchExpressionTree, "");
String fragment = generateJPQL(searchExpressionTree);
return fragment;
@@ -193,12 +193,12 @@ public class SearchTranslationManager {
}
if (lineBreakers.contains(next)) {
- System.out.println();
- System.out.print(indent);
+ //System.out.println();
+ //System.out.print(indent);
}
- System.out.print(next);
- System.out.print(" ");
+ //System.out.print(next);
+ //System.out.print(" ");
if (next.equals(")")) {
indent = indent.substring(3);
@@ -228,11 +228,11 @@ public class SearchTranslationManager {
return;
}
- System.out.print(indent + token.getText());
+ //System.out.print(indent + token.getText());
if (isStringNode(token)) {
- System.out.println(collapseStringChildren(tree));
+ //System.out.println(collapseStringChildren(tree));
} else {
- System.out.println();
+ //System.out.println();
for (int childIndex = 0; childIndex < tree.getChildCount(); childIndex++) {
CommonTree child = (CommonTree) tree.getChild(childIndex);
print(child, indent + " ");
@@ -261,7 +261,7 @@ public class SearchTranslationManager {
}
public static void main(String[] args) throws Exception {
- SearchTranslationManager manager = new SearchTranslationManager(SearchSubsystem.Resource);
+ SearchTranslationManager manager = new SearchTranslationManager(SearchSubsystem.RESOURCE);
manager.setExpression("(name = rhq and category = server) or plugin = jbossas");
String jpql = manager.getJPQLSelectStatement();
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/translation/SearchTranslatorFactory.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/translation/SearchTranslatorFactory.java
index fa8d626..ee8ecda 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/translation/SearchTranslatorFactory.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/translation/SearchTranslatorFactory.java
@@ -8,7 +8,7 @@ public class SearchTranslatorFactory {
}
public static SearchTranslator getTranslator(SearchSubsystem searchContext) {
- if (searchContext == SearchSubsystem.Resource) {
+ if (searchContext == SearchSubsystem.RESOURCE) {
return new ResourceSearchTranslator();
}
throw new IllegalArgumentException("No SearchTranslator found for SearchContext[" + searchContext + "]");
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java
index 0e1a789..ff71760 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java
@@ -398,7 +398,7 @@ public final class CriteriaQueryGenerator {
// translate first, if there was an error we won't add the dangling 'AND' to the where clause
String translatedJPQL = searchManager.getJPQLWhereFragment();
- LOG.info("Translated JPQL Fragment was: " + translatedJPQL);
+ LOG.debug("Translated JPQL Fragment was: " + translatedJPQL);
if (translatedJPQL != null) {
searchExpressionWhereClause = translatedJPQL;
}
diff --git a/modules/enterprise/server/jar/src/main/resources/single-line-rhql.txt b/modules/enterprise/server/jar/src/main/resources/single-line-rhql.txt
index 8793fb1..265071b 100644
--- a/modules/enterprise/server/jar/src/main/resources/single-line-rhql.txt
+++ b/modules/enterprise/server/jar/src/main/resources/single-line-rhql.txt
@@ -94,4 +94,12 @@ context = value1 | ((context = value2))
((context = value1)) context = value2
(context = value1) (context = value2)
(context = value1 (context = value2))
-context = value1 ((context = value2))
\ No newline at end of file
+context = value1 ((context = value2))
+
+# simple terms
+hello
+hello world
+"hello world" 'foo bar'
+'hello world' "foo bar"
+hello | world
+context=value | world
\ No newline at end of file
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/GenericSearchAssistTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/GenericSearchAssistTest.java
index 867ee78..5d51d10 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/GenericSearchAssistTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/GenericSearchAssistTest.java
@@ -10,7 +10,7 @@ import java.util.List;
import org.testng.annotations.Test;
-import org.rhq.enterprise.server.search.execution.SearchSuggestion;
+import org.rhq.core.domain.search.SearchSuggestion;
import org.rhq.enterprise.server.test.AbstractEJB3Test;
public class GenericSearchAssistTest extends AbstractEJB3Test {
@@ -36,7 +36,7 @@ public class GenericSearchAssistTest extends AbstractEJB3Test {
}
count++;
- List<SearchSuggestion> results = new TestAutoCompletionManager().getAdvancedSuggestions(expression,
+ List<SearchSuggestion> results = new TestAutoCompletionManager().getSuggestions(expression,
expression.length());
List<String> expectedResults = Arrays.asList(expected.split(" "));
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/TestAutoCompletionManager.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/TestAutoCompletionManager.java
index 89cb5ff..28a11a7 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/TestAutoCompletionManager.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/TestAutoCompletionManager.java
@@ -8,7 +8,6 @@ import java.util.Map;
import org.rhq.core.domain.search.SearchSubsystem;
import org.rhq.enterprise.server.search.assist.AbstractSearchAssistant;
-import org.rhq.enterprise.server.search.assist.SearchAssistant;
import org.rhq.enterprise.server.search.execution.SearchAssistManager;
public class TestAutoCompletionManager extends SearchAssistManager {
@@ -62,10 +61,10 @@ public class TestAutoCompletionManager extends SearchAssistManager {
}
public TestAutoCompletionManager() {
- super(null);
+ super(null, null);
}
- protected SearchAssistant getAutoCompletor(SearchSubsystem searchContext) {
+ protected AbstractSearchAssistant getAutoCompletor(SearchSubsystem searchContext) {
return new TestAutoCompletor();
}
}
commit 4fd30d06a5ad9001591e4a573a3051ef657c1ae8
Merge: 7bb4095... e529883...
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Apr 26 14:21:51 2010 +0200
Merge branch 'master' of ssh://git.fedorahosted.org/git/rhq/rhq
commit 7bb40954466ae844f2135f8062d4cd4ad0385bd2
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Apr 26 14:05:17 2010 +0200
BZ 548172 pg_relation_size() no longer understands names in postgres 8.4+
Also prevent a NPE from unboxing.
diff --git a/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresTableComponent.java b/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresTableComponent.java
index c69496f..ff21e78 100644
--- a/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresTableComponent.java
+++ b/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresTableComponent.java
@@ -55,7 +55,7 @@ public class PostgresTableComponent implements DatabaseComponent<PostgresDatabas
private static final List<String> PG_STAT_USER_TABLE_STATS = Arrays.asList("seq_scan", "seq_tup_read", "idx_scan",
"idx_tup_fetch", "n_tup_ins", "n_tup_upd", "n_tup_del", "table_size", "total_size");
- public static final String PG_STAT_USER_TABLES_QUERY = "SELECT ts.*, pg_relation_size(ts.relname) AS table_size, pg_total_relation_size(ts.relname) AS total_size, \n"
+ public static final String PG_STAT_USER_TABLES_QUERY = "SELECT ts.*, pg_relation_size(ts.relid) AS table_size, pg_total_relation_size(ts.relid) AS total_size, \n"
+ " ios.heap_blks_read, ios.heap_blks_hit, ios.idx_blks_read, ios.idx_blks_hit, \n"
+ " ios.toast_blks_read, ios.toast_blks_hit, ios.tidx_blks_read, ios.tidx_blks_hit \n"
+ "FROM pg_stat_user_tables ts LEFT JOIN pg_statio_user_tables ios on ts.relid = ios.relid \n"
@@ -90,7 +90,7 @@ public class PostgresTableComponent implements DatabaseComponent<PostgresDatabas
getTableName());
for (MeasurementScheduleRequest request : requests) {
String metricName = request.getName();
- double value;
+ Double value;
if (metricName.equals("rows")) {
value = DatabaseQueryUtility.getSingleNumericQueryValue(this, PG_COUNT_ROWS + getTableName());
} else if (metricName.equals("rows_approx")) {
@@ -99,8 +99,10 @@ public class PostgresTableComponent implements DatabaseComponent<PostgresDatabas
value = results.get(metricName);
}
- MeasurementDataNumeric mdn = new MeasurementDataNumeric(request, value);
- report.addData(mdn);
+ if (value!=null) {
+ MeasurementDataNumeric mdn = new MeasurementDataNumeric(request, value);
+ report.addData(mdn);
+ }
}
}
commit 3b0f9d16573db48e4d5f85463a8d550356c79c2b
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Apr 26 11:58:20 2010 +0200
Prevent NPE if no sshd is running/found.
diff --git a/modules/plugins/sshd/src/main/java/org/rhq/plugins/sshd/OpenSSHDComponent.java b/modules/plugins/sshd/src/main/java/org/rhq/plugins/sshd/OpenSSHDComponent.java
index a2cd1a6..c84beb5 100644
--- a/modules/plugins/sshd/src/main/java/org/rhq/plugins/sshd/OpenSSHDComponent.java
+++ b/modules/plugins/sshd/src/main/java/org/rhq/plugins/sshd/OpenSSHDComponent.java
@@ -70,7 +70,7 @@ public class OpenSSHDComponent implements ResourceComponent, ConfigurationFacet,
}
public AvailabilityType getAvailability() {
- return processInfo.isRunning() ? AvailabilityType.UP : AvailabilityType.DOWN;
+ return (processInfo != null && processInfo.isRunning()) ? AvailabilityType.UP : AvailabilityType.DOWN;
}
private void getSSHDProcess() {
commit e5298839fe034f63c45b100c2a1f2e5464794d23
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Apr 23 19:15:39 2010 -0400
BZ-567297 add deletion/removal functionality to the inventory browser group tab
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/browse/BrowseGroupsUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/browse/BrowseGroupsUIBean.java
index 5c39367..37941e7 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/browse/BrowseGroupsUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/browse/BrowseGroupsUIBean.java
@@ -3,17 +3,20 @@ package org.rhq.enterprise.gui.inventory.browse;
import java.util.ArrayList;
import java.util.List;
+import javax.faces.application.FacesMessage;
import javax.faces.model.DataModel;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.criteria.ResourceGroupCriteria;
import org.rhq.core.domain.resource.group.GroupCategory;
import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.gui.util.FacesContextUtility;
+import org.rhq.core.gui.util.StringUtility;
import org.rhq.enterprise.gui.common.framework.PagedDataTableUIBean;
import org.rhq.enterprise.gui.common.paging.PageControlView;
import org.rhq.enterprise.gui.common.paging.PagedListDataModel;
@@ -93,4 +96,28 @@ public class BrowseGroupsUIBean extends PagedDataTableUIBean {
// offer suggestions based on currentInputText
return suggestions;
}
+
+ public String deleteSelectedGroups() {
+ try {
+ Subject subject = getSubject();
+
+ String[] selectedGroups = getSelectedItems();
+ int[] groupIds = StringUtility.getIntArray(selectedGroups);
+
+ for (int nextGroupId : groupIds) {
+ groupManager.deleteResourceGroup(subject, nextGroupId);
+ }
+
+ FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO, "Deleted selected groups");
+ } catch (Exception e) {
+ FacesContextUtility.addMessage(FacesMessage.SEVERITY_ERROR, "Failed to delete all selected groups", e);
+ }
+
+ return "success";
+ }
+
+ private String[] getSelectedItems() {
+ return FacesContextUtility.getRequest().getParameterValues("selectedItems");
+ }
+
}
commit 190d928d699c43b53b4f794b113fe035c701a10c
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Apr 23 19:02:41 2010 -0400
BZ-585255 - fix resource search from the menu bar to properly show disambiguated results
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/menu/menu.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/menu/menu.xhtml
index fb41230..232974b 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/menu/menu.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/menu/menu.xhtml
@@ -136,7 +136,7 @@
<rich:suggestionbox id="resourceSelectBox" for="selectedResource" tokens=",[]"
ajaxSingle="true" immediate="true"
suggestionAction="#{ResourceSelectUIBean.autocomplete}"
- var="result" data="foo" fetchValue="#{result.resource.id}"
+ var="result" data="foo" fetchValue="#{result.original.resource.id}"
nothingLabel="No matching resources found"
style="background-color: #cccccc;"
onselect="document.location.href='#{onf:getDefaultResourceTabURL()}?id=' + #{rich:element('selectedResource')}.value"
@@ -144,15 +144,15 @@
<h:column>
<f:facet name="header">Avail</f:facet>
<h:graphicImage
- value="/images/icons/availability_#{result.availability == 'UP' ? 'green' : 'red'}_16.png"/>
+ value="/images/icons/availability_#{result.original.availability == 'UP' ? 'green' : 'red'}_16.png"/>
</h:column>
<h:column>
<f:facet name="header">Resource</f:facet>
- <h:outputText value="#{result.resource.name}"/>
+ <h:outputText value="#{result.original.resource.name}"/>
</h:column>
<h:column>
<f:facet name="header">Parent</f:facet>
- <h:outputText value="#{result.parent.name}"/>
+ <h:outputText value="#{result.original.parent.name}"/>
</h:column>
</rich:suggestionbox>
</h:panelGroup>
commit 55e50e5881b78557432e365da3eb05f11f832ff5
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Apr 23 17:01:56 2010 -0400
-updated log4j.xml to reduce unit test hibernate verbosity
-fixed failing test UpdateEventsSubsystemTest.testDeleteEventStuff()
-fixed a log message
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/SubcategoryTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/SubcategoryTest.java
index 270fad3..1031f42 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/SubcategoryTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/SubcategoryTest.java
@@ -46,7 +46,7 @@ public class SubcategoryTest extends UpdateSubsytemTestBase {
cleanupTest();
} catch (Exception e) {
System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
- + ".testAddDeleteDefaultTemplate");
+ + ".testAddResourcTypeWithKnownSubCategory");
}
}
}
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateEventsSubsystemTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateEventsSubsystemTest.java
index 78d2788..4c8ab8a 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateEventsSubsystemTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateEventsSubsystemTest.java
@@ -45,12 +45,14 @@ import org.rhq.enterprise.server.util.LookupUtil;
*/
public class UpdateEventsSubsystemTest extends UpdateSubsytemTestBase {
+ static final boolean ENABLED = true;
+
@Override
protected String getSubsystemDirectory() {
return "events";
}
- @Test
+ @Test(enabled = ENABLED)
public void testCreateDeleteEvent() throws Exception {
System.out.println("= testCreateDeleteEvent");
try {
@@ -124,7 +126,7 @@ public class UpdateEventsSubsystemTest extends UpdateSubsytemTestBase {
* Simulate just redeploying the plugin with no change in descriptor.
* @throws Exception
*/
- @Test
+ @Test(enabled = ENABLED)
public void testNoOpChange() throws Exception {
System.out.println("= testNoOpChange");
try {
@@ -172,7 +174,7 @@ public class UpdateEventsSubsystemTest extends UpdateSubsytemTestBase {
}
}
- @Test
+ @Test(enabled = ENABLED)
public void testDeleteEventStuff() throws Exception {
System.out.println("= testDeleteEvent");
EventManagerLocal eventManager = LookupUtil.getEventManager();
@@ -186,8 +188,6 @@ public class UpdateEventsSubsystemTest extends UpdateSubsytemTestBase {
registerPlugin("event1-2.xml");
getTransactionManager().begin();
entityManager = getEntityManager();
- getPluginId(entityManager);
-
platform = getResourceType("events");
testResource = new Resource("-test-", "-test resource", platform);
@@ -198,13 +198,13 @@ public class UpdateEventsSubsystemTest extends UpdateSubsytemTestBase {
getTransactionManager().begin();
entityManager = getEntityManager();
- //platform = getResourceType("events");
platform = entityManager.find(ResourceType.class, platform.getId());
testResource = entityManager.find(Resource.class, testResource.getId());
Set<EventDefinition> eDefs = platform.getEventDefinitions();
assert eDefs.size() == 2 : "Did not find the expected 2 eventDefinitions, but " + eDefs.size();
Iterator<EventDefinition> eIter = eDefs.iterator();
boolean found = false;
+ Map<EventSource, Set<Event>> events = new HashMap<EventSource, Set<Event>>(1);
while (eIter.hasNext()) {
EventDefinition def = eIter.next();
if (def.getName().equals("hans")) {
@@ -212,18 +212,17 @@ public class UpdateEventsSubsystemTest extends UpdateSubsytemTestBase {
// We got the definition that will vanish later, so attach some stuff to it
EventSource source = new EventSource("test location", def, testResource);
entityManager.persist(source);
+
Event ev = new Event(def.getName(), source.getLocation(), System.currentTimeMillis(),
EventSeverity.INFO, "This is a test");
- // entityManager.persist(ev); // We can't do this, as Event.source does not get filled this way :(
- Map<EventSource, Set<Event>> events = new HashMap<EventSource, Set<Event>>(1);
Set<Event> evSet = new HashSet<Event>(1);
evSet.add(ev);
events.put(source, evSet);
- eventManager.addEventData(events);
}
}
assert found : "Hans was not found";
getTransactionManager().commit();
+ eventManager.addEventData(events);
/*
* --- done with the setup ---
diff --git a/modules/enterprise/server/jar/src/test/resources/log4j.xml b/modules/enterprise/server/jar/src/test/resources/log4j.xml
index b9817dd..d721bff 100644
--- a/modules/enterprise/server/jar/src/test/resources/log4j.xml
+++ b/modules/enterprise/server/jar/src/test/resources/log4j.xml
@@ -44,6 +44,11 @@
</layout>
</appender>
+ <!-- Hibernate logs WARNINGS frequent from this class, in test envs. -->
+ <category name="org.hibernate.hql.ast.QueryTranslatorImpl">
+ <priority value="ERROR"/>
+ </category>
+
<root>
<appender-ref ref="CONSOLE"/>
<appender-ref ref="FILE"/>
commit 520863990da701f0ba2c239726fa5bfac992afda
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Apr 23 16:07:08 2010 -0400
Fix the cleanup of this test.
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/SubcategoryTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/SubcategoryTest.java
index 696a25c..270fad3 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/SubcategoryTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/SubcategoryTest.java
@@ -18,8 +18,6 @@
*/
package org.rhq.enterprise.server.resource.metadata.test;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.testng.annotations.Test;
/**
@@ -29,8 +27,6 @@ import org.testng.annotations.Test;
*/
public class SubcategoryTest extends UpdateSubsytemTestBase {
- private final Log log = LogFactory.getLog(SubcategoryTest.class);
-
@Override
protected String getSubsystemDirectory() {
return "resource";
@@ -38,14 +34,20 @@ public class SubcategoryTest extends UpdateSubsytemTestBase {
@Test
public void testAddResourcTypeWithKnownSubCategory() throws Exception {
- getTransactionManager().begin();
+ // Note, plugins are registered in new transactions. for tests, this means
+ // you can't do everything in a trans and roll back at the end. You must clean up
+ // manually.
try {
registerPlugin("test-subcategories.xml");
registerPlugin("test-subcategories3.xml");
-
-
} finally {
- getTransactionManager().rollback();
+ // clean up
+ try {
+ cleanupTest();
+ } catch (Exception e) {
+ System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
+ + ".testAddDeleteDefaultTemplate");
+ }
}
}
commit 3259b72fe1efb4b46c0f47e2ef82b2de89b23c09
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Apr 23 14:46:17 2010 -0400
Fixed a couple of too-long constraint names for ora.
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 8a89f96..6974780 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -2066,7 +2066,7 @@
<schema-directSQL>
<statement>
ALTER TABLE RHQ_ALERT_NOTIFICATION
- ADD CONSTRAINT RHQ_ALERT_NOTIFICATION_SENDER_CONFIG_ID_FK
+ ADD CONSTRAINT RHQ_AN_SENDER_CONFIG_ID_FK
FOREIGN KEY (SENDER_CONFIG_ID)
REFERENCES RHQ_CONFIG (ID)
</statement>
@@ -2094,7 +2094,7 @@
<schema-directSQL>
<statement>
ALTER TABLE RHQ_ALERT_NOTIFICATION
- ADD CONSTRAINT RHQ_ALERT_NOTIFICATION_TEMPLATE_ID_FK
+ ADD CONSTRAINT RHQ_AN_TEMPLATE_ID_FK
FOREIGN KEY (TEMPLATE_ID)
REFERENCES RHQ_ALERT_NOTIF_TEMPL (ID)
</statement>
commit 6d0e513b5a6ba7005e5da47c328a55a8104a7f19
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Apr 23 13:17:31 2010 -0400
remove mention of the alert-migration maven module, since it is no longer needed
diff --git a/modules/enterprise/gui/pom.xml b/modules/enterprise/gui/pom.xml
index 5a91cab..0c529ba 100644
--- a/modules/enterprise/gui/pom.xml
+++ b/modules/enterprise/gui/pom.xml
@@ -38,7 +38,6 @@
<module>base-perspective-war</module>
<module>webdav-war</module>
<module>content_http-war</module>
- <module>alert-migration</module>
<module>coregui</module>
</modules>
</profile>
diff --git a/modules/enterprise/server/ear/pom.xml b/modules/enterprise/server/ear/pom.xml
index 0cc1fb2..eba5172 100644
--- a/modules/enterprise/server/ear/pom.xml
+++ b/modules/enterprise/server/ear/pom.xml
@@ -80,13 +80,6 @@
<type>war</type>
</dependency>
- <dependency>
- <groupId>org.rhq.helpers</groupId>
- <artifactId>alert-migration</artifactId>
- <version>${project.version}</version>
- <type>war</type>
- </dependency>
-
<!-- ** SARs -->
<!--
<dependency> <groupId>org.rhq</groupId> <artifactId>rhq-enterprise-server-agent-sar</artifactId>
@@ -193,13 +186,6 @@
<contextRoot>/content</contextRoot>
</webModule>
- <webModule>
- <groupId>org.rhq.helpers</groupId>
- <artifactId>alert-migration</artifactId>
- <bundleFileName>alert-migration.war</bundleFileName>
- <contextRoot>/alert-migration</contextRoot>
- </webModule>
-
<!-- ** EJB-JARs -->
<ejbModule>
commit 3d3f6dd4d74aa463dc54208aef82fd127be40a27
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Apr 23 13:14:24 2010 -0400
alert notifications are now db-upgraded using the standard mechanism, this project is no longer needed
diff --git a/modules/enterprise/gui/alert-migration/README.txt b/modules/enterprise/gui/alert-migration/README.txt
deleted file mode 100644
index 511720f..0000000
--- a/modules/enterprise/gui/alert-migration/README.txt
+++ /dev/null
@@ -1,18 +0,0 @@
-
-This module is to migrate alert definitions from rhq 1.3.1 to rhq 3
-
-You need to follow those steps:
-
-- have rhq 1.3.1 running
-- dump the old alerts (running the scripts need java 1.6 )
-
- $ rhq-cli.sh -u rhqadmin -p rhqadmin -f dumpAlertDefinitions.js
-
- This will dump the alert definitions in to a file called alertDefinitions.csv
- in the current directory
-
-- download rhq 3 and run the installer
-- *after* running the installer, direct the
- browser to localhost:7080/alert-migration
- and upload the alertDefinitions.csv file
-
diff --git a/modules/enterprise/gui/alert-migration/etc/dumpAlertDefinitions.js b/modules/enterprise/gui/alert-migration/etc/dumpAlertDefinitions.js
deleted file mode 100644
index d5c45b3..0000000
--- a/modules/enterprise/gui/alert-migration/etc/dumpAlertDefinitions.js
+++ /dev/null
@@ -1,14 +0,0 @@
-#
-# CLI script to export Alert Definitions
-# Writes the dump to a file 'alertDefinitions.csv' in the
-# current directory - appends to this file if it already exists.
-# call it liek this: "rhq-cli.sh -u rhqadmin -p rhqadmin -f dumpAlertDefinitions.js"
-#
-criteria = new AlertDefinitionCriteria()
-criteria.fetchAlertNotifications(true)
-
-defs = AlertDefinitionManager.findAlertDefinitionsByCriteria(subject,criteria)
-
-exporter.setTarget('csv', 'alertDefinitions.csv')
-exporter.write(defs)
-
diff --git a/modules/enterprise/gui/alert-migration/pom.xml b/modules/enterprise/gui/alert-migration/pom.xml
deleted file mode 100644
index b7e8205..0000000
--- a/modules/enterprise/gui/alert-migration/pom.xml
+++ /dev/null
@@ -1,254 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<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/xsd/maven-4.0.0.xsd">
- <parent>
- <artifactId>rhq-helpers</artifactId>
- <groupId>org.rhq.helpers</groupId>
- <version>3.0.0-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>org.rhq.helpers</groupId>
- <artifactId>alert-migration</artifactId>
- <packaging>war</packaging>
-
- <name>RHQ alert migration</name>
- <description>Migrate alert notification from RHQ 1.3.1 to RHQ 3 format</description>
-
- <scm>
- <connection>scm:git:ssh://git.fedorahosted.org/git/rhq.git/modules/enterprise/gui/ale...</connection>
- <developerConnection>scm:git:ssh://git.fedorahosted.org/git/rhq.git/modules/enterprise/gui/ale...</developerConnection>
- </scm>
-
- <dependencies>
- <dependency>
- <groupId>org.rhq</groupId>
- <artifactId>rhq-core-domain</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope> <!-- by ear -->
- </dependency>
-
- <dependency>
- <groupId>org.rhq</groupId>
- <artifactId>rhq-enterprise-server</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope> <!-- by rhq.ear (as ejb-jar) -->
- </dependency>
-
- <dependency>
- <groupId>org.rhq</groupId>
- <artifactId>rhq-core-util</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope> <!-- by rhq.ear -->
- </dependency>
-
-
- <dependency>
- <groupId>net.sf.opencsv</groupId>
- <artifactId>opencsv</artifactId>
- <version>2.0</version>
- </dependency>
-
- <!-- This is a fix for the Javac bug requiring annotations to be
- available when compiling dependent classes. -->
- <dependency>
- <groupId>javax.persistence</groupId>
- <artifactId>persistence-api</artifactId>
- <version>1.0</version>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>jboss.jboss-embeddable-ejb3</groupId>
- <artifactId>hibernate-all</artifactId>
- <version>1.0.0.Alpha9</version>
- <scope>provided</scope>
- <!-- 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>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <version>2.4</version>
- <scope>provided</scope> <!-- by JBossAS -->
- </dependency>
-
- <dependency>
- <groupId>commons-fileupload</groupId>
- <artifactId>commons-fileupload</artifactId>
- <version>1.2</version>
- </dependency>
-
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- <version>1.3.1</version>
- </dependency>
-
- <dependency>
- <groupId>i18nlog</groupId>
- <artifactId>i18nlog</artifactId>
- <version>1.0.9</version>
- <scope>provided</scope>
- </dependency>
-
- </dependencies>
-
- <build>
- <finalName>alert-migration</finalName>
-
- <plugins>
-
- <plugin>
- <artifactId>maven-war-plugin</artifactId>
- <configuration>
- <archive>
- <manifest>
- <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
- <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
- </manifest>
- <manifestEntries>
- <Build-Number>${buildNumber}</Build-Number>
- </manifestEntries>
- </archive>
- <webResources>
- <resource>
- <filtering>false</filtering>
- <directory>${basedir}/src/main/webapp</directory>
- <!--<includes>-->
- <!--<include>**/*.properties</include>-->
- <!--</includes>-->
- </resource>
- <!--<resource>-->
- <!--<filtering>true</filtering>-->
- <!--<directory>${basedir}/target/resources</directory>-->
- <!--<includes>-->
- <!--<include>**/*.properties</include>-->
- <!--</includes>-->
- <!--</resource>-->
- </webResources>
- </configuration>
- </plugin>
-
-<!--
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
- <execution>
- <id>Generate I18N Resource Bundles</id>
- <phase>process-classes</phase>
- <configuration>
- <tasks>
- <- - generate the I18N resource bundles - - >
- <taskdef name="i18n" classpathref="maven.runtime.classpath" classname="mazz.i18n.ant.I18NAntTask" />
- <- -<i18n outputdir="${project.build.outputDirectory}" defaultlocale="en" verbose="false" append="false" verify="true">- ->
- <i18n outputdir="${basedir}/target/resources/WEB-INF/classes" defaultlocale="en" verbose="false" append="false" verify="true">
- <classpath refid="maven.runtime.classpath" />
- <classfileset dir="${project.build.outputDirectory}">
- <include name="**/*I18NResourceKeys.class" />
- </classfileset>
- </i18n>
- <copy todir="${project.build.outputDirectory}" encoding="UTF-8" outputencoding="UTF-8">
- <fileset dir="${basedir}/target/resources/WEB-INF/classes">
- <include name="InstallerMessages*.properties" />
- </fileset>
- <mapper type="glob" from="*" to="*.unfiltered" />
- </copy>
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
--->
- </plugins>
-
- </build>
-
- <profiles>
-
- <profile>
- <id>dev</id>
-
- <properties>
- <rhq.rootDir>../../../..</rhq.rootDir>
- <rhq.containerDir>${rhq.rootDir}/${rhq.defaultDevContainerPath}</rhq.containerDir>
- <rhq.deploymentName>${project.build.finalName}.war</rhq.deploymentName>
- <rhq.deploymentDir>${rhq.containerDir}/jbossas/server/default/deploy/${rhq.earName}/${rhq.deploymentName}</rhq.deploymentDir>
- </properties>
-
- <build>
- <plugins>
-
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <version>1.1</version>
- <executions>
-
- <execution>
- <id>deploy-classes</id>
- <phase>compile</phase>
- <configuration>
- <tasks>
- <property name="classes.dir" location="${rhq.deploymentDir}/WEB-INF/classes" />
- <echo>*** Copying updated files from target/classes to ${classes.dir}...</echo>
- <copy todir="${classes.dir}" verbose="${rhq.verbose}">
- <fileset dir="target/classes" />
- </copy>
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
-
- <execution>
- <id>deploy</id>
- <phase>package</phase>
- <configuration>
- <tasks>
- <property name="deployment.dir" location="${rhq.deploymentDir}" />
- <echo>*** Copying updated files from target${file.separator}${project.build.finalName}${file.separator} to ${deployment.dir}${file.separator}...</echo>
- <copy todir="${deployment.dir}" verbose="${rhq.verbose}">
- <fileset dir="${basedir}/target/${project.build.finalName}" />
- </copy>
- <delete dir="${deployment.dir}.rej" /> <!-- need to remove any residual backups -->
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
-
- <execution>
- <id>undeploy</id>
- <phase>clean</phase>
- <configuration>
- <tasks>
- <property name="deployment.dir" location="${rhq.deploymentDir}" />
- <echo>*** Deleting ${deployment.dir}${file.separator}...</echo>
- <delete dir="${deployment.dir}" />
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
-
- </executions>
- </plugin>
-
- </plugins>
- </build>
- </profile>
-
- </profiles>
-</project>
\ No newline at end of file
diff --git a/modules/enterprise/gui/alert-migration/src/main/java/org/rhq/helpers/alertMigration/Alert13Parser.java b/modules/enterprise/gui/alert-migration/src/main/java/org/rhq/helpers/alertMigration/Alert13Parser.java
deleted file mode 100644
index 9107354..0000000
--- a/modules/enterprise/gui/alert-migration/src/main/java/org/rhq/helpers/alertMigration/Alert13Parser.java
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2010 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.helpers.alertMigration;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.io.StringReader;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import au.com.bytecode.opencsv.CSVReader;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.rhq.core.domain.alert.notification.AlertNotification;
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.PropertySimple;
-
-/**
- * Parser for a dump of the 1.3 alert structures via CLI
- * @author Heiko W. Rupp
- */
-public class Alert13Parser {
-
- private final Log log = LogFactory.getLog(Alert13Parser.class);
- File inputFile;
- Reader inputReader;
-
- public static final String RHQ_USERS = "RHQ Users";
-
- public Alert13Parser(File input) {
- this.inputFile = input;
- try {
- inputReader = new FileReader(input);
- } catch (FileNotFoundException e) {
- throw new RuntimeException("File " + input.getAbsolutePath() + " not found");
- }
- }
-
- public Alert13Parser(Reader reader) {
- inputReader = reader;
- }
-
- public Alert13Parser(InputStream stream) {
- inputReader = new InputStreamReader(stream);
- }
-
-
-
- public List<AlertNotification> parse() {
-
- List<AlertNotification> result = new ArrayList<AlertNotification>();
-
- List<String[]> lines = null;
- try {
- CSVReader reader = new CSVReader(inputReader);
- lines = reader.readAll();
- reader.close();
-
-
- boolean isFirst = true;
- for (String[] line : lines) {
- if (isFirst) { // Skip over first line with headers
- isFirst=false;
- continue;
- }
- if (line.length<2) // Skip over empty lines
- continue;
-
- log.debug(Arrays.asList(line));
- String tmp = line[9]; // alert definition id
- int alertDefinitionId = Integer.valueOf(tmp);
- log.debug(" adefid " + alertDefinitionId);
-
- tmp = line[1]; // Notifications
- CSVReader nr = new CSVReader(new StringReader(tmp));
- String[] notifications = nr.readNext();
- int i = 0;
- int pos = 0;
- while (i < notifications.length) {
- int nid;
- String n = notifications[i];
- log.debug(" Notification: " + n);
- /*
- * A single notification now runs over multiple lines
- */
- if (n.startsWith("[") || n.startsWith(" "))
- n = n.substring(1);
-
- if (n.equals("]")) {
- i++;
- continue;
- }
-
- nid = Integer.valueOf(getField(n,"id"));
-
-
- AlertNotification alNo = new AlertNotification(alertDefinitionId,nid);
- Configuration config = new Configuration();
- alNo.setConfiguration(config);
- alNo.setOrder(pos);
-
- if (n.startsWith("Subject")) {
- String subjectId = getField(notifications[i+1],"id");
- String subject = getField(notifications[i+2],"name");
- i+=4;
- log.debug("subject: " + subjectId);
- config.put(new PropertySimple("subjectId", subjectId));
- alNo.setSenderName(RHQ_USERS);
- alNo.setName(subject);
-
- } else if (n.startsWith("Role")) {
- String roleId = getField(notifications[i+1],"id");
- String role = getField(notifications[i+2],"name");
- i+=4;
- log.debug("role: " + roleId);
- config.put(new PropertySimple("roleId", roleId));
- alNo.setSenderName("Roles");
- alNo.setName(role);
-
-
- } else if (n.startsWith("Snmp")) {
- String host = getField(notifications[i+1],"host");
- String port = getField(notifications[i+2],"port");
- String oid = getField(notifications[i+3],"oid");
- i+=5;
- log.debug("snmp: " + host + ", " + port + ", " + oid);
- config.put(new PropertySimple("host",host));
- config.put(new PropertySimple("port",port));
- config.put(new PropertySimple("OID",oid));
- alNo.setSenderName("SNMP");
- alNo.setName(host+oid);
-
- } else if (n.startsWith("Email")) {
- String emails = getField(notifications[i+1],"emailAddress");
- log.debug("email: " + emails);
- config.put(new PropertySimple("emailAddress",emails));
- alNo.setSenderName("Email");
- alNo.setName(emails);
- i+=3;
- } else {
- log.error("Unknown notification :>" + n + "<");
- i++;
- }
- log.debug(" -- for nid : " + nid);
-
- result.add(alNo);
- pos++;
- }
-
- tmp = line[12];
- nr = new CSVReader(new StringReader(tmp));
- String[] operations = nr.readNext();
-// for (String op: operations) {
-// log.debug(" Operation: " + op);
-// }
-
- }
- } catch (IOException e) {
- e.printStackTrace(); // TODO: Customise this generated block
- return result;
- }
-
- return result;
- }
-
- private String getField(String input, String fieldName) {
-
- String str = fieldName + "=";
- int pos = input.indexOf(str);
- if (pos==-1)
- return "";
- String tmp = input.substring(pos+str.length());
- if (tmp.endsWith("]"))
- tmp = tmp.substring(0,tmp.length()-1);
-
- return tmp;
- }
-}
diff --git a/modules/enterprise/gui/alert-migration/src/main/java/org/rhq/helpers/alertMigration/MigrationServlet.java b/modules/enterprise/gui/alert-migration/src/main/java/org/rhq/helpers/alertMigration/MigrationServlet.java
deleted file mode 100644
index 9ac4b25..0000000
--- a/modules/enterprise/gui/alert-migration/src/main/java/org/rhq/helpers/alertMigration/MigrationServlet.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2010 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.helpers.alertMigration;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.commons.fileupload.FileItem;
-import org.apache.commons.fileupload.FileUploadException;
-import org.apache.commons.fileupload.disk.DiskFileItemFactory;
-import org.apache.commons.fileupload.servlet.ServletFileUpload;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.rhq.core.domain.alert.notification.AlertNotification;
-import org.rhq.core.domain.auth.Subject;
-import org.rhq.enterprise.server.alert.AlertNotificationManagerLocal;
-import org.rhq.enterprise.server.util.LookupUtil;
-
-/**
- * Simple servlet to upload an rhq 1.3 alert definition dump after
- * migrating the database to rhq 3.0 format.
- *
- * @author Heiko W. Rupp
- */
-public class MigrationServlet extends HttpServlet {
-
- private final Log log = LogFactory.getLog(MigrationServlet.class);
-
- @Override
- protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
-
- PrintWriter writer;
- if (ServletFileUpload.isMultipartContent(req)){
-
- ServletFileUpload servletFileUpload = new ServletFileUpload(new DiskFileItemFactory());
- List fileItemsList = null;
- try {
- fileItemsList = servletFileUpload.parseRequest(req);
- } catch (FileUploadException e) {
-
- writer = resp.getWriter();
- writer.write("<strong>File upload failed: </strong><br/>");
- for (StackTraceElement elem : e.getStackTrace())
- writer.write(elem.toString() + "br/>");
- writer.flush();
- return;
- }
-
- Iterator it = fileItemsList.iterator();
- while (it.hasNext()){
- FileItem fileItem = (FileItem)it.next();
- if (fileItem.isFormField()){
- /* The file item contains a simple name-value pair of a form field */
- // TODO flag as error ?
- }
- else{
- /* The file item contains an uploaded file */
-
- Alert13Parser parser = new Alert13Parser(fileItem.getInputStream());
- List<AlertNotification> notifications = parser.parse();
- AlertNotificationManagerLocal notificationManager = LookupUtil.getAlertNotificationManager();
- Subject overlord = LookupUtil.getSubjectManager().getOverlord();
-
- notificationManager.mergeTransientAlertNotifications(overlord,notifications);
-
- writer = resp.getWriter();
- writer.write("<strong>Alert Definitions have been migrated</strong><p/>");
- writer.write("<a href=\"/Dashboard.do\">To the RHQ Dashboard</a>");
- writer.flush();
-
- }
- }
- }
-
- }
-}
diff --git a/modules/enterprise/gui/alert-migration/src/main/java/org/rhq/helpers/alertMigration/RestoreAlerts.java b/modules/enterprise/gui/alert-migration/src/main/java/org/rhq/helpers/alertMigration/RestoreAlerts.java
deleted file mode 100644
index 7e9e761..0000000
--- a/modules/enterprise/gui/alert-migration/src/main/java/org/rhq/helpers/alertMigration/RestoreAlerts.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2010 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.helpers.alertMigration;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.rhq.core.domain.alert.notification.AlertNotification;
-
-/**
- * Read in a dump file and print the Alert notifications to stdout.
- * Only useful for testing.
- *
- * @author Heiko W. Rupp
- */
-public class RestoreAlerts {
-
- private final Log log = LogFactory.getLog(RestoreAlerts.class);
-
-
- public static void main(String[] args) {
-
- if (args.length<1) {
- usage();
- System.exit(1);
- }
-
- File file = new File(args[0]);
- if (!file.canRead()) {
- System.err.println("Can not read file " + file.getAbsolutePath());
- System.exit(2);
- }
-
- Alert13Parser parser = new Alert13Parser(file);
- List<AlertNotification> notifications = parser.parse();
-
- System.out.println("Found " + notifications.size() + " notifications in the dump");
- for (AlertNotification n : notifications)
- System.out.println(n);
-
- }
-
-
- private static void usage() {
- System.out.println("Usage:");
- System.out.println(" RestoreAlerts inputFile");
- }
-
-}
diff --git a/modules/enterprise/gui/alert-migration/src/main/webapp/WEB-INF/web.xml b/modules/enterprise/gui/alert-migration/src/main/webapp/WEB-INF/web.xml
deleted file mode 100644
index ec27207..0000000
--- a/modules/enterprise/gui/alert-migration/src/main/webapp/WEB-INF/web.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0"?>
-
-<web-app xmlns="http://java.sun.com/xml/ns/javaee"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_4.xsd"
- version="2.4">
-
- <display-name>RHQ Alert Migration Helper</display-name>
- <description>RHQ Alert Migration Helper. This is uesd to migrate 1.3.1 style alerts to the 3.0 format.</description>
-
- <servlet>
- <servlet-name>Migration Servlet</servlet-name>
- <servlet-class>org.rhq.helpers.alertMigration.MigrationServlet</servlet-class>
- <load-on-startup>2</load-on-startup>
- </servlet>
-
- <servlet-mapping>
- <servlet-name>Migration Servlet</servlet-name>
- <url-pattern>/migration</url-pattern>
- </servlet-mapping>
-
-
- <welcome-file-list>
- <welcome-file>index.html</welcome-file>
- </welcome-file-list>
-
-</web-app>
\ No newline at end of file
diff --git a/modules/enterprise/gui/alert-migration/src/main/webapp/index.html b/modules/enterprise/gui/alert-migration/src/main/webapp/index.html
deleted file mode 100644
index 0650df0..0000000
--- a/modules/enterprise/gui/alert-migration/src/main/webapp/index.html
+++ /dev/null
@@ -1,17 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
- "http://www.w3.org/TR/html4/loose.dtd">
-<html>
-<head>
- <title>Alert Migration</title>
-</head>
-<body>
-
-<h1>Alert Migration</h1>
-<strong>Please supply the dump file</strong>
-<form action="migration" method="POST" enctype="multipart/form-data">
- <input name="alertDumpFile" type="file" size="50" maxlength="100000" accept="text/*">
- <br/>
- <input type="submit" value="Upload!">
-</form>
-</body>
-</html>
\ No newline at end of file
diff --git a/modules/enterprise/gui/alert-migration/src/test/java/Alert13ParserTest.java b/modules/enterprise/gui/alert-migration/src/test/java/Alert13ParserTest.java
deleted file mode 100644
index d038f8e..0000000
--- a/modules/enterprise/gui/alert-migration/src/test/java/Alert13ParserTest.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2010 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.
- */
-
-import java.io.File;
-import java.util.List;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.testng.annotations.Test;
-
-import org.rhq.core.domain.alert.notification.AlertNotification;
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.helpers.alertMigration.Alert13Parser;
-
-/**
- * Test for the alert13 parser
- * @author Heiko W. Rupp
- */
-@Test
-public class Alert13ParserTest {
-
- private final Log log = LogFactory.getLog(Alert13ParserTest.class);
-
-
-
- public void testParser() throws Exception {
-
- File input = new File("src/test/resources/alertDef.csv");
-
- Alert13Parser parser = new Alert13Parser(input);
- List<AlertNotification> notifications = parser.parse();
-
- assert notifications != null;
- assert notifications.size()==15 : "Did not find 15 notifications, but " + notifications.size();
-
- for (AlertNotification n : notifications) {
-
- switch (n.getAlertNotificationId()) {
- case 10001:
- assert n.getAlertDefinitionId() == 10001;
- assert n.getSenderName().equals(Alert13Parser.RHQ_USERS);
- break;
- case 10011:
- assert n.getAlertDefinitionId() == 10011;
- assert n.getSenderName().equals("Roles");
- break;
- case 10002:
- assert n.getAlertDefinitionId() == 10011;
- assert n.getSenderName().equals("Email");
- assert n.getConfiguration().getSimpleValue("emailAddress","").equals("hwr(a)bsd.de");
- break;
- case 10031:
- assert n.getAlertDefinitionId() == 10011;
- assert n.getSenderName().equals("Email");
- assert n.getConfiguration().getSimpleValue("emailAddress","").equals("hwr(a)pilhuhn.de");
- break;
- case 10032:
- assert n.getAlertDefinitionId() == 10051;
- assert n.getSenderName().equals("SNMP");
- Configuration c = n.getConfiguration();
- assert c.getSimpleValue("host","").equals("localhost");
- assert c.getSimpleValue("OID","").equals("1.2.3.4.5.6.7");
-
- }
- }
- }
-}
diff --git a/modules/enterprise/gui/alert-migration/src/test/resources/alertDef.csv b/modules/enterprise/gui/alert-migration/src/test/resources/alertDef.csv
deleted file mode 100644
index 4a7bb87..0000000
--- a/modules/enterprise/gui/alert-migration/src/test/resources/alertDef.csv
+++ /dev/null
@@ -1,13 +0,0 @@
-"alertDampening","alertNotifications","conditionExpression","context","controlFiltered","deleted","description","enabled","groupAlertDefinition","id","name","notifyFiltered","operationDefinition","parentId","priority","readOnly","recoveryId","resource","resourceGroup","resourceType","willRecover"
-
-"org.rhq.core.domain.alert.AlertDampening[ category=NONE[] ]","[SubjectNotification[id=10001, subject=org.rhq.core.domain.auth.Subject[id=2,name=rhqadmin], ]]","ANY","Resource","false","false","","false","null","10001","test1","false","null","0","!! - Medium","false","0","Resource[id=10001, type=Mac OS X, key=snert-embedded, name=snert-embedded, parent=<null>, version=MacOSX 10.6.2]","null","null","false"
-"org.rhq.core.domain.alert.AlertDampening[ category=NONE[] ]","[RoleNotification[id=10011, role=org.rhq.core.domain.authz.Role[id=1, name=Super User Role], ], EmailNotification[id=10031, emailAddress=hwr(a)pilhuhn.de, ], EmailNotification[id=10002, emailAddress=hwr(a)bsd.de, ]]","ANY","Resource","false","false","","false","null","10011","test2","false","null","0","!!! - High","false","0","Resource[id=10001, type=Mac OS X, key=snert-embedded, name=snert-embedded, parent=<null>, version=MacOSX 10.6.2]","null","null","false"
-"org.rhq.core.domain.alert.AlertDampening[ category=NONE[] ]","[RoleNotification[id=10021, role=org.rhq.core.domain.authz.Role[id=1, name=Super User Role], ], RoleNotification[id=10022, role=org.rhq.core.domain.authz.Role[id=2, name=All Resources Role], ]]","ANY","Group","false","false","","true","null","10041","Group Alert","false","null","0","!! - Medium","false","0","null","ResourceGroup[id=10001, name=ASse, category=COMPATIBLE, type=JBossAS Server, isDynaGroup=false, isClusterGroup=false]","null","true"
-"org.rhq.core.domain.alert.AlertDampening[ category=NONE[] ]","[RoleNotification[id=10023, role=org.rhq.core.domain.authz.Role[id=1, name=Super User Role], ], RoleNotification[id=10024, role=org.rhq.core.domain.authz.Role[id=2, name=All Resources Role], ]]","ANY","Resource","false","false","","true","org.rhq.core.domain.alert.AlertDefinition[ id=10041, name=Group Alert, conditionExpression=ANY, priority=!! - Medium, ]","10042","Group Alert","false","null","0","!! - Medium","false","0","Resource[id=10004, type=JBossAS Server, key=/jon/jopr-server-2.3.1/jbossas/server/default, name=snert JBossAS 4.2.3.GA default (snert:2099), parent=snert-embedded, version=4.2.3.GA]","null","null","true"
-"org.rhq.core.domain.alert.AlertDampening[ category=NONE[] ]","[RoleNotification[id=10025, role=org.rhq.core.domain.authz.Role[id=1, name=Super User Role], ], RoleNotification[id=10026, role=org.rhq.core.domain.authz.Role[id=2, name=All Resources Role], ]]","ANY","Resource","false","false","","true","org.rhq.core.domain.alert.AlertDefinition[ id=10041, name=Group Alert, conditionExpression=ANY, priority=!! - Medium, ]","10043","Group Alert","false","null","0","!! - Medium","false","0","Resource[id=11034, type=JBossAS Server, key=/devel/jboss-4.0.5.GA/server/default, name=pickeldi JBossAS 4.0.5.GA default (1099), version=4.0.5.GA]","null","null","true"
-"org.rhq.core.domain.alert.AlertDampening[ category=NONE[] ]","[SnmpNotification[id=10032, host=localhost, port=162, oid=1.2.3.4.5.6.7, ]]","ANY","Resource","false","false","","true","null","10051","snmp","false","null","0","!! - Medium","false","0","Resource[id=10001, type=Mac OS X, key=snert-embedded, name=snert-embedded, parent=<null>, version=MacOSX 10.6.2]","null","null","true"
-"org.rhq.core.domain.alert.AlertDampening[ category=NONE[] ]","[RoleNotification[id=10041, role=org.rhq.core.domain.authz.Role[id=1, name=Super User Role], ], RoleNotification[id=10042, role=org.rhq.core.domain.authz.Role[id=2, name=All Resources Role], ]]","ANY","Type","false","false","","true","null","10061","test-template","false","null","0","!! - Medium","false","0","null","null","Mac OS X","true"
-"org.rhq.core.domain.alert.AlertDampening[ category=NONE[] ]","[RoleNotification[id=10043, role=org.rhq.core.domain.authz.Role[id=1, name=Super User Role], ], RoleNotification[id=10044, role=org.rhq.core.domain.authz.Role[id=2, name=All Resources Role], ]]","ANY","Resource","false","false","","true","null","10062","test-template","false","null","10061","!! - Medium","false","0","Resource[id=10001, type=Mac OS X, key=snert-embedded, name=snert-embedded, parent=<null>, version=MacOSX 10.6.2]","null","null","true"
-"org.rhq.core.domain.alert.AlertDampening[ category=NONE[] ]","[]","ANY","Resource","false","false","no explicit notification","false","null","10021","Test3","false","null","0","!! - Medium","false","0","Resource[id=10001, type=Mac OS X, key=snert-embedded, name=snert-embedded, parent=<null>, version=MacOSX 10.6.2]","null","null","true"
-"org.rhq.core.domain.alert.AlertDampening[ category=NONE[] ]","[]","ANY","Resource","false","false","","false","null","10031","OPs","false","OperationDefinition[id=10016, resourceType=ResourceType[id=10051, category=Platform, name=Mac OS X, plugin=Platforms], name=viewProcessList]","0","!! - Medium","false","0","Resource[id=10001, type=Mac OS X, key=snert-embedded, name=snert-embedded, parent=<null>, version=MacOSX 10.6.2]","null","null","true"
-10 rows
commit 6308d13ee4d776800175ba2d07d44bb8c00aba90
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Apr 23 12:52:39 2010 -0400
remove OrderBy attribute, since alert notification order column was removed
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java
index f607af3..afa5671 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java
@@ -352,7 +352,6 @@ public class AlertDefinition implements Serializable {
private Set<AlertCondition> conditions = new LinkedHashSet<AlertCondition>(1); // Most alerts will only have one condition.
@OneToMany(mappedBy = "alertDefinition", cascade = CascadeType.ALL)
- @OrderBy("order asc")
@org.hibernate.annotations.Cascade(org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
private List<AlertNotification> alertNotifications = new ArrayList<AlertNotification>();
commit 24bb8b4dfe497ca6f8e0716e5933f8dbe55f3e8d
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Apr 23 11:16:47 2010 -0400
move the upgrade procedures for postgreaming blob streaming out into its own schemaSpec
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 af19962..8a89f96 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -2665,6 +2665,27 @@
</schema-directSQL>
</schemaSpec>
+ <schemaSpec version="2.81">
+ <!-- fix for postgres not properly streaming blobs to JDBC clients -->
+ <schema-directSQL targetDBVendor="postgresql">
+ <statement desc="Change bytea column to oid in postgres.">
+ ALTER TABLE RHQ_PACKAGE_BITS ADD COLUMN NEWOID OID
+ </statement>
+ <statement desc="Change bytea column to oid in postgres.">
+ UPDATE RHQ_PACKAGE_BITS t SET NEWOID = (
+ SELECT oid FROM (
+ SELECT oid, lowrite(lo_open(oid, 131072), t.bits)
+ FROM lo_create(0) o(oid)) x)
+ </statement>
+ <statement desc="Change bytea column to oid in postgres.">
+ ALTER TABLE RHQ_PACKAGE_BITS DROP COLUMN BITS
+ </statement>
+ <statement desc="Change bytea column to oid in postgres.">
+ ALTER TABLE RHQ_PACKAGE_BITS RENAME COLUMN NEWOID TO BITS
+ </statement>
+ </schema-directSQL>
+ </schemaSpec>
+
<schemaSpec version="2.82">
<schema-directSQL>
<statement desc="Creating table RHQ_SAVED_SEARCH">
@@ -2711,23 +2732,6 @@
VALUES (2, 'Resource', 'Downed Servers', 'All downed servers across the entire enterprise', 'down server', 0, 1, 1)
</statement>
</schema-directSQL>
- <schema-directSQL targetDBVendor="postgresql">
- <statement desc="Change bytea column to oid in postgres.">
- ALTER TABLE RHQ_PACKAGE_BITS ADD COLUMN NEWOID OID
- </statement>
- <statement desc="Change bytea column to oid in postgres.">
- UPDATE RHQ_PACKAGE_BITS t SET NEWOID = (
- SELECT oid FROM (
- SELECT oid, lowrite(lo_open(oid, 131072), t.bits)
- FROM lo_create(0) o(oid)) x)
- </statement>
- <statement desc="Change bytea column to oid in postgres.">
- ALTER TABLE RHQ_PACKAGE_BITS DROP COLUMN BITS
- </statement>
- <statement desc="Change bytea column to oid in postgres.">
- ALTER TABLE RHQ_PACKAGE_BITS RENAME COLUMN NEWOID TO BITS
- </statement>
- </schema-directSQL>
</schemaSpec>
<schemaSpec version="2.83">
commit 169dc47215afcf11a84e7d8161b2d9071d4fa4ac
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Apr 23 11:11:34 2010 -0400
fix/simplified dbupgrade for RHQ_SAVED_SEARCH table
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 c3aeffe..af19962 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -2668,14 +2668,11 @@
<schemaSpec version="2.82">
<schema-directSQL>
<statement desc="Creating table RHQ_SAVED_SEARCH">
- CREATE TABLE RHQ_SAVED_SEARCH ( ID INTEGER )
- </statement>
- </schema-directSQL>
- <schema-directSQL>
- <statement desc="Creating primary key for RHQ_SAVED_SEARCH">
- ALTER TABLE RHQ_SAVED_SEARCH ADD PRIMARY KEY ( ID )
+ CREATE TABLE RHQ_SAVED_SEARCH ( ID INTEGER PRIMARY KEY )
</statement>
</schema-directSQL>
+ <schema-alterColumn table="RHQ_SAVED_SEARCH" column="ID" nullable="FALSE" />
+
<schema-addColumn table="RHQ_SAVED_SEARCH" column="CONTEXT" columnType="VARCHAR2" precision="25" />
<schema-alterColumn table="RHQ_SAVED_SEARCH" column="CONTEXT" nullable="FALSE" />
commit fb8574a8eaa130bb1d2af1bb97cac5bf03d81d16
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Apr 23 11:11:15 2010 -0400
change name of primary key constraint on RHQ_SUBJECT_ROLE_LDAP_MAP to be less than 30 chars, to match dbupgrade task 2.83
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/authz-schema.xml b/modules/core/dbutils/src/main/scripts/dbsetup/authz-schema.xml
index 45cc880..8d9f738 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/authz-schema.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/authz-schema.xml
@@ -84,7 +84,7 @@
<table name="RHQ_SUBJECT_ROLE_LDAP_MAP">
<column name="SUBJECT_ID" required="true" type="INTEGER" references="RHQ_SUBJECT"/>
<column name="ROLE_ID" required="true" type="INTEGER" references="RHQ_ROLE"/>
- <constraint name="RHQ_SUBJECT_ROLE_LDAP_MAP_KEY">
+ <constraint name="RHQ_SUBJECT_ROLE_LDAP_MAP_PK">
<primaryKey>
<field ref="SUBJECT_ID" />
<field ref="ROLE_ID"/>
commit a58af3b6c8c4e5aaab67c1e706d249392dcbe79e
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Apr 23 11:08:22 2010 -0400
add necessary dbupgrade pieces for RHQ_SUBJECT_ROLE_LDAP_MAP table
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 047be90..c3aeffe 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -2090,7 +2090,7 @@
</schemaSpec>
<schemaSpec version="2.70.2">
<!-- add structures for alert notification templates -->
- <schema-addColumn table="RHQ_ALERT_NOTIFICATION" column="NOTIF_TEMPLATE_ID" columnType="INTEGER" />
+ <schema-addColumn table="RHQ_ALERT_NOTIFICATION" column="TEMPLATE_ID" columnType="INTEGER" />
<schema-directSQL>
<statement>
ALTER TABLE RHQ_ALERT_NOTIFICATION
@@ -2734,18 +2734,30 @@
</schemaSpec>
<schemaSpec version="2.83">
- <!-- The following constraint change shortens the constraint name < 30 chars for Oracle. -->
- <schema-directSQL>
- <statement targetDBVendor="postgresql" desc="Dropping RHQ_SUBJECT_ROLE_LDAP_MAP constraint RHQ_SUBJECT_ROLE_LDAP_MAPPING_KEY.">
- ALTER TABLE RHQ_SUBJECT_ROLE_LDAP_MAP DROP CONSTRAINT RHQ_SUBJECT_ROLE_LDAP_MAPPING_KEY;
+ <schema-directSQL>
+ <statement desc="Creating table RHQ_SUBJECT_ROLE_LDAP_MAP">
+ CREATE TABLE RHQ_SUBJECT_ROLE_LDAP_MAP ( SUBJECT_ID INTEGER, ROLE_ID INTEGER )
</statement>
- <!-- There is no PL/SQL update for ora dbs as the problematic statement could never be created on oracle, so nothing to fix. -->
- <statement targetDBVendor="postgresql" desc="Creating new RHQ_SUBJECT_ROLE_LDAP_MAP constraint RHQ_SUBJECT_ROLE_LDAP_MAP_KEY">
+ <statement desc="Creating composite PK for RHQ_SUBJECT_ROLE_LDAP_MAP">
ALTER TABLE RHQ_SUBJECT_ROLE_LDAP_MAP
- ADD CONSTRAINT RHQ_SUBJECT_ROLE_LDAP_MAP_KEY
+ ADD CONSTRAINT RHQ_SUBJECT_ROLE_LDAP_MAP_PK
PRIMARY KEY ( SUBJECT_ID, ROLE_ID )
</statement>
+ <statement desc="Creating FK relation to RHQ_SUBJECT table for SUBJECT_ID column">
+ ALTER TABLE RHQ_SUBJECT_ROLE_LDAP_MAP
+ ADD CONSTRAINT RHQ_SRLM_SUBJECT_ID_FK
+ FOREIGN KEY (SUBJECT_ID)
+ REFERENCES RHQ_SUBJECT (ID)
+ </statement>
+ <statement desc="Creating FK relation to RHQ_ROLE table for ROLE_ID column">
+ ALTER TABLE RHQ_SUBJECT_ROLE_LDAP_MAP
+ ADD CONSTRAINT RHQ_SRLM_ROLE_ID_FK
+ FOREIGN KEY (ROLE_ID)
+ REFERENCES RHQ_ROLE (ID)
+ </statement>
</schema-directSQL>
+ <schema-alterColumn table="RHQ_SUBJECT_ROLE_LDAP_MAP" column="SUBJECT_ID" nullable="FALSE" />
+ <schema-alterColumn table="RHQ_SUBJECT_ROLE_LDAP_MAP" column="ROLE_ID" nullable="FALSE" />
</schemaSpec>
</dbupgrade>
commit 1a06c55942f3b03f78b061ec3aee6e36a8820173
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Apr 23 11:03:28 2010 -0400
fix dbupgrade logic for subject/role/email notifications
diff --git a/modules/core/dbutils/src/main/java/org/rhq/core/db/upgrade/CustomAlertSenderUpgradeTask.java b/modules/core/dbutils/src/main/java/org/rhq/core/db/upgrade/CustomAlertSenderUpgradeTask.java
index a94f095..0fa4ee8 100644
--- a/modules/core/dbutils/src/main/java/org/rhq/core/db/upgrade/CustomAlertSenderUpgradeTask.java
+++ b/modules/core/dbutils/src/main/java/org/rhq/core/db/upgrade/CustomAlertSenderUpgradeTask.java
@@ -147,7 +147,7 @@ public class CustomAlertSenderUpgradeTask implements DatabaseUpgradeTask {
// buffer will be 0 the very first time, since definitionId is initially -1
int configId = persistConfiguration("operation-definition-id", operationDefinitionId, "selection-mode",
"SELF");
- persistNotification(alertDefinitionId, configId, "Resource Operations", "Operational ");
+ persistNotification(alertDefinitionId, configId, "Resource Operations", "Operation Invocation");
}
}
@@ -165,13 +165,18 @@ public class CustomAlertSenderUpgradeTask implements DatabaseUpgradeTask {
persistNotification(definitionId, configId, sender, name);
}
buffer = new StringBuilder(); // reset for the next definitionId
- } else {
- if (buffer.length() != 0) {
- // elements are already in the list
- buffer.append(',');
- }
- buffer.append(nextData);
}
+
+ if (buffer.length() != 0) {
+ // elements are already in the list
+ buffer.append(',');
+ }
+ buffer.append(nextData);
+ }
+
+ if (buffer.length() != 0) {
+ int configId = persistConfiguration(propertyName, buffer.toString());
+ persistNotification(definitionId, configId, sender, name);
}
}
commit e8b7b579f801fc1c50afc7f8631dd5471d01beb1
Author: Joseph Marques <joseph(a)redhat.com>
Date: Thu Apr 22 14:34:17 2010 -0400
add database upgrade support for customer alert senders
diff --git a/modules/core/dbutils/src/main/java/org/rhq/core/db/ant/dbupgrade/SST_JavaTask.java b/modules/core/dbutils/src/main/java/org/rhq/core/db/ant/dbupgrade/SST_JavaTask.java
index b083510..707694f 100644
--- a/modules/core/dbutils/src/main/java/org/rhq/core/db/ant/dbupgrade/SST_JavaTask.java
+++ b/modules/core/dbutils/src/main/java/org/rhq/core/db/ant/dbupgrade/SST_JavaTask.java
@@ -74,9 +74,6 @@ public class SST_JavaTask extends SchemaSpecTask {
validateAttributes();
try {
- DatabaseType db_type = getDatabaseType();
- Connection conn = getConnection();
-
if (className.indexOf(".") == -1) {
className = "org.rhq.core.db.upgrade." + className;
}
@@ -85,7 +82,11 @@ public class SST_JavaTask extends SchemaSpecTask {
Class<?> javaTaskClass = Class.forName(className);
DatabaseUpgradeTask javaTask = (DatabaseUpgradeTask) javaTaskClass.newInstance();
- javaTask.execute(conn, db_type);
+
+ DatabaseType db_type = getDatabaseType();
+ Connection conn = getConnection();
+
+ javaTask.execute(db_type, conn);
} catch (Exception e) {
throw new BuildException(MSG.getMsg(DbAntI18NResourceKeys.JAVA_TASK_ERROR, e), e);
}
diff --git a/modules/core/dbutils/src/main/java/org/rhq/core/db/upgrade/CustomAlertSenderUpgradeTask.java b/modules/core/dbutils/src/main/java/org/rhq/core/db/upgrade/CustomAlertSenderUpgradeTask.java
new file mode 100644
index 0000000..a94f095
--- /dev/null
+++ b/modules/core/dbutils/src/main/java/org/rhq/core/db/upgrade/CustomAlertSenderUpgradeTask.java
@@ -0,0 +1,217 @@
+/*
+ * 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.core.db.upgrade;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.util.List;
+
+import org.rhq.core.db.DatabaseType;
+
+/**
+ * The introduction of custom alert senders brought with it the denormalization of the AlertNotification schema.
+ * Instead of the AlertNotification entity storing the notification-related data itself (through referential integrity)
+ * it has been subsumed inside of configuration objects, which are then associated back to the entity.
+ *
+ * Each custom alert sender has full control over the structure within that configuration object. This task represents
+ * the work necessary to translate the first-class notification data (previously stored in the rhq_alert_notification
+ * table itself) into appropriate configuration objects to be used by the custom senders that will be shipped with the
+ * product by default.
+ *
+ * In particular, this task handles the upgrade tasks for alert notifications setup against the following types of data:
+ *
+ * <ul>
+ * <li>RHQ Subjects</li>
+ * <li>RHQ Roles</li>
+ * <li>Direct Email Addresses</li>
+ * <li>SNMP Trap Receivers</li>
+ * <li>Resource Operations</li>
+ * </ul>
+ *
+ * @author Joseph Marques
+ */
+public class CustomAlertSenderUpgradeTask implements DatabaseUpgradeTask {
+
+ private DatabaseType databaseType;
+ private Connection connection;
+
+ private final long NOW = System.currentTimeMillis();
+
+ @Override
+ public void execute(DatabaseType databaseType, Connection connection) throws SQLException {
+ this.databaseType = databaseType;
+ this.connection = connection;
+
+ upgradeSubjectNotifications();
+ upgradeRoleNotifications();
+ upgradeEmailNotifications();
+ upgradeSNMPNotifications();
+ upgradeOperationNotifications();
+ }
+
+ private void upgradeSubjectNotifications() throws SQLException {
+ String dataMapSQL = "" //
+ + " SELECT notif.alert_definition_id, notif.subject_id "//
+ + " FROM rhq_alert_notification notif "//
+ + " WHERE notif.notification_type = 'SUBJECT' "//
+ + "ORDER BY notif.alert_definition_id";
+ List<Object[]> data = databaseType.executeSelectSql(connection, dataMapSQL);
+
+ String propertyName = "subjectId";
+ String senderName = "System Users";
+ String name = "User Notifications";
+
+ persist(data, propertyName, senderName, name);
+ }
+
+ private void upgradeRoleNotifications() throws SQLException {
+ String dataMapSQL = "" //
+ + " SELECT notif.alert_definition_id, notif.role_id "//
+ + " FROM rhq_alert_notification notif "//
+ + " WHERE notif.notification_type = 'ROLE' "//
+ + "ORDER BY notif.alert_definition_id";
+
+ List<Object[]> data = databaseType.executeSelectSql(connection, dataMapSQL);
+
+ String propertyName = "roleId";
+ String senderName = "System Roles";
+ String name = "Role Notifications";
+
+ persist(data, propertyName, senderName, name);
+ }
+
+ private void upgradeEmailNotifications() throws SQLException {
+ String dataMapSQL = "" //
+ + " SELECT notif.alert_definition_id, notif.email_address "//
+ + " FROM rhq_alert_notification notif "//
+ + " WHERE notif.notification_type = 'EMAIL' "//
+ + "ORDER BY notif.alert_definition_id";
+
+ List<Object[]> data = databaseType.executeSelectSql(connection, dataMapSQL);
+
+ String propertyName = "emailAddress";
+ String senderName = "Direct Emails";
+ String name = "Email Notifications";
+
+ persist(data, propertyName, senderName, name);
+ }
+
+ private void upgradeSNMPNotifications() throws SQLException {
+ String dataMapSQL = "" //
+ + " SELECT notif.alert_definition_id, notif.snmp_host, notif.snmp_port, notif.snmp_oid "//
+ + " FROM rhq_alert_notification notif "//
+ + " WHERE notif.notification_type = 'SNMP' "//
+ + "ORDER BY notif.alert_definition_id";
+
+ List<Object[]> data = databaseType.executeSelectSql(connection, dataMapSQL);
+
+ for (Object[] next : data) {
+ int alertDefinitionId = ((Number) next[0]).intValue();
+ String host = (String) next[1];
+ String port = ((Number) next[2]).toString();
+ String oid = (String) next[3];
+
+ // buffer will be 0 the very first time, since definitionId is initially -1
+ int configId = persistConfiguration("host", host, "port", port, "oid", oid);
+ persistNotification(alertDefinitionId, configId, "SNMP Traps", "SNMP Notifications");
+ }
+ }
+
+ private void upgradeOperationNotifications() throws SQLException {
+ String dataMapSQL = "" //
+ + " SELECT def.id, def.operation_def_id" //
+ + " FROM rhq_alert_definition def";
+
+ List<Object[]> data = databaseType.executeSelectSql(connection, dataMapSQL);
+
+ for (Object[] next : data) {
+ int alertDefinitionId = ((Number) next[0]).intValue();
+ String operationDefinitionId = ((Number) next[1]).toString();
+
+ // buffer will be 0 the very first time, since definitionId is initially -1
+ int configId = persistConfiguration("operation-definition-id", operationDefinitionId, "selection-mode",
+ "SELF");
+ persistNotification(alertDefinitionId, configId, "Resource Operations", "Operational ");
+ }
+ }
+
+ private void persist(List<Object[]> data, String propertyName, String sender, String name) throws SQLException {
+ int definitionId = -1;
+ StringBuilder buffer = new StringBuilder();
+ for (Object[] next : data) {
+ int nextDefinitionId = ((Number) next[0]).intValue();
+ String nextData = String.valueOf(next[1]);
+ if (nextDefinitionId != definitionId) {
+ definitionId = nextDefinitionId;
+ if (buffer.length() != 0) {
+ // buffer will be 0 the very first time, since definitionId is initially -1
+ int configId = persistConfiguration(propertyName, buffer.toString());
+ persistNotification(definitionId, configId, sender, name);
+ }
+ buffer = new StringBuilder(); // reset for the next definitionId
+ } else {
+ if (buffer.length() != 0) {
+ // elements are already in the list
+ buffer.append(',');
+ }
+ buffer.append(nextData);
+ }
+ }
+ }
+
+ private int persistConfiguration(String... propertyNameValues) throws SQLException {
+ int configId = databaseType.getNextSequenceValue(connection, "rhq_config", "id");
+ String insertConfigSQL = getInsertConfigSQL(configId);
+ databaseType.executeSql(connection, insertConfigSQL);
+
+ for (int i = 0; i < propertyNameValues.length; i += 2) {
+ String propertyName = propertyNameValues[i];
+ String propertyValue = propertyNameValues[i + 1];
+
+ int propertyId = databaseType.getNextSequenceValue(connection, "rhq_config_property", "id");
+ String insertPropertySQL = getInsertPropertySQL(propertyId, configId, propertyName, propertyValue);
+ databaseType.executeSql(connection, insertPropertySQL);
+ }
+
+ return configId;
+ }
+
+ private void persistNotification(int definitionId, int configId, String sender, String name) throws SQLException {
+ int notificationId = databaseType.getNextSequenceValue(connection, "rhq_alert_notification", "id");
+ String insertNotificationSQL = getInsertNotificationSQL(notificationId, definitionId, configId, sender, name);
+
+ databaseType.executeSql(connection, insertNotificationSQL);
+ }
+
+ private String getInsertConfigSQL(int id) {
+ return "INSERT INTO rhq_config ( id, ctime, mtime )" //
+ + " VALUES ( " + id + ", " + NOW + ", " + NOW + " ) ";
+ }
+
+ private String getInsertPropertySQL(int id, int configId, String name, String value) {
+ return "INSERT INTO rhq_config_property ( id, configuration_id, name, string_value, dtype )" //
+ + " VALUES ( " + id + ", " + configId + ", '" + name + "', '" + value + "', 'property' ) ";
+ }
+
+ private String getInsertNotificationSQL(int id, int definitionId, int configId, String sender, String name) {
+ return "INSERT INTO rhq_alert_notification ( id, alert_definition_id, sender_config_id, sender_name, display_name )" //
+ + " VALUES ( " + id + ", " + definitionId + ", " + configId + ", '" + sender + "', '" + name + "' ) ";
+ }
+
+}
diff --git a/modules/core/dbutils/src/main/java/org/rhq/core/db/upgrade/DatabaseUpgradeTask.java b/modules/core/dbutils/src/main/java/org/rhq/core/db/upgrade/DatabaseUpgradeTask.java
index fd438c0..4811b7d 100644
--- a/modules/core/dbutils/src/main/java/org/rhq/core/db/upgrade/DatabaseUpgradeTask.java
+++ b/modules/core/dbutils/src/main/java/org/rhq/core/db/upgrade/DatabaseUpgradeTask.java
@@ -30,5 +30,5 @@ import org.rhq.core.db.ant.dbupgrade.SST_JavaTask;
* @author Joseph Marques
*/
public interface DatabaseUpgradeTask {
- public void execute(Connection connection, DatabaseType type) throws SQLException;
+ public void execute(DatabaseType type, Connection connection) throws SQLException;
}
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 3098d97..9617057 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/alert-schema.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/alert-schema.xml
@@ -79,7 +79,7 @@
<!-- required, but 0 effectively means null -->
<column name="WILL_RECOVER" required="true" default="false" type="BOOLEAN"/>
<column name="ACK_TIME" required="false" type="LONG"/>
- <column name="ACK_BY_ID" required="false" type="INTEGER" references="RHQ_SUBJECT(ID)"/>
+ <column name="ACK_SUBJECT" required="false" size="100" type="VARCHAR2"/>
<index name="RHQ_ALERT_IDX_TIME" unique="false">
<field ref="CTIME"/>
</index>
@@ -127,21 +127,17 @@
<column name="MTIME" required="true" type="LONG"/>
<column name="NAME" required="true" size="100" type="VARCHAR2"/>
<column name="DESCRIPTION" required="false" size="250" type="VARCHAR2"/>
-
</table>
<table name="RHQ_ALERT_NOTIFICATION" 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="NOTIFICATION_TYPE" required="true" size="20" type="VARCHAR2"/>
<column name="ALERT_DEFINITION_ID" required="false" type="INTEGER" references="RHQ_ALERT_DEFINITION(ID)"/>
- <column name="NOTIF_TEMPLATE_ID" required="false" type="INTEGER" references="RHQ_ALERT_NOTIF_TEMPL(ID)"/>
- <column name="ALERT_CONFIG_ID" required="false" type="INTEGER" references="RHQ_CONFIG(ID)"/>
- <column name="ALERT_SENDER_NAME" required="false" size="100" type="VARCHAR2" /> <!-- TODO make required = true -->
- <column name="NAME" type="VARCHAR2" size="100" />
+ <column name="TEMPLATE_ID" required="false" type="INTEGER" references="RHQ_ALERT_NOTIF_TEMPL(ID)"/>
+ <column name="SENDER_CONFIG_ID" required="false" type="INTEGER" references="RHQ_CONFIG(ID)"/>
+ <column name="SENDER_NAME" required="true" size="100" type="VARCHAR2" />
+ <column name="DISPLAY_NAME" type="VARCHAR2" size="100" />
</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 bf9b21f..047be90 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -2059,28 +2059,27 @@
<schemaSpec version="2.70">
<schema-addColumn table="RHQ_ALERT" column="ACK_TIME" columnType="LONG" />
<!-- TODO: this needs to change to ack_subject_name -->
- <schema-addColumn table="RHQ_ALERT" column="ACK_BY_ID" columnType="INTEGER" />
-
- <schema-addColumn table="RHQ_ALERT_NOTIFICATION" column="ALERT_SENDER_NAME" columnType="VARCHAR2" precision="100"/>
- <schema-addColumn table="RHQ_ALERT_NOTIFICATION" column="ALERT_CONFIG_ID" columnType="INTEGER" />
+ <schema-addColumn table="RHQ_ALERT" column="ACK_SUBJECT" precision="100" columnType="VARCHAR2" />
+ <schema-addColumn table="RHQ_ALERT_NOTIFICATION" column="DISPLAY_NAME" precision="100" columnType="VARCHAR2" />
+ <schema-addColumn table="RHQ_ALERT_NOTIFICATION" column="SENDER_NAME" precision="100" columnType="VARCHAR2" />
+ <schema-addColumn table="RHQ_ALERT_NOTIFICATION" column="SENDER_CONFIG_ID" columnType="INTEGER" />
<schema-directSQL>
<statement>
ALTER TABLE RHQ_ALERT_NOTIFICATION
- ADD CONSTRAINT RHQ_AN_ALERT_CONFIG_ID_FK
- FOREIGN KEY (ALERT_CONFIG_ID)
+ ADD CONSTRAINT RHQ_ALERT_NOTIFICATION_SENDER_CONFIG_ID_FK
+ FOREIGN KEY (SENDER_CONFIG_ID)
REFERENCES RHQ_CONFIG (ID)
</statement>
</schema-directSQL>
</schemaSpec>
-
<schemaSpec version="2.70.1">
<schema-createSequence name="RHQ_ALERT_NOTIF_TEMPL_ID_SEQ" initial="10001" />
<schema-directSQL>
- <statement>
+ <statement desc="Creating table RHQ_ALERT_NOTIF_TEMPL">
CREATE TABLE RHQ_ALERT_NOTIF_TEMPL ( ID INTEGER PRIMARY KEY )
</statement>
</schema-directSQL>
- <schema-alterColumn table="RHQ_ALERT_NOTIF_TEMPL" column="ID" nullable="false" />
+ <schema-alterColumn table="RHQ_ALERT_NOTIF_TEMPL" column="ID" nullable="false" />
<schema-addColumn table="RHQ_ALERT_NOTIF_TEMPL" column="CTIME" columnType="LONG" />
<schema-alterColumn table="RHQ_ALERT_NOTIF_TEMPL" column="CTIME" nullable="false" />
<schema-addColumn table="RHQ_ALERT_NOTIF_TEMPL" column="MTIME" columnType="LONG" />
@@ -2089,6 +2088,61 @@
<schema-alterColumn table="RHQ_ALERT_NOTIF_TEMPL" column="NAME" nullable="false" />
<schema-addColumn table="RHQ_ALERT_NOTIF_TEMPL" column="DESCRIPTION" precision="250" columnType="VARCHAR2" />
</schemaSpec>
+ <schemaSpec version="2.70.2">
+ <!-- add structures for alert notification templates -->
+ <schema-addColumn table="RHQ_ALERT_NOTIFICATION" column="NOTIF_TEMPLATE_ID" columnType="INTEGER" />
+ <schema-directSQL>
+ <statement>
+ ALTER TABLE RHQ_ALERT_NOTIFICATION
+ ADD CONSTRAINT RHQ_ALERT_NOTIFICATION_TEMPLATE_ID_FK
+ FOREIGN KEY (TEMPLATE_ID)
+ REFERENCES RHQ_ALERT_NOTIF_TEMPL (ID)
+ </statement>
+ </schema-directSQL>
+ </schemaSpec>
+ <schemaSpec version="2.70.3">
+ <!-- turn first-class notification data into configuration objects for custom alert senders -->
+ <schema-alterColumn table="RHQ_ALERT_NOTIFICATION" column="NOTIFICATION_TYPE" nullable="TRUE" />
+ <schema-javaTask className="CustomAlertSenderUpgradeTask" />
+ <schema-directSQL>
+ <statement desc="Removing obsolete alert notifications">
+ DELETE FROM RHQ_ALERT_NOTIFICATION WHERE NOTIFICATION_TYPE IS NOT NULL
+ </statement>
+ </schema-directSQL>
+ <schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="NOTIFICATION_TYPE" />
+ </schemaSpec>
+ <schemaSpec version="2.70.4">
+ <!-- remove first-class alert notification structures from definition side of the model-->
+ <schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="snmp_host" />
+ <schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="snmp_port" />
+ <schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="snmp_oid" />
+ <schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="email_address" />
+ <schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="role_id" />
+ <schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="subject_id" />
+ <schema-deleteColumn table="RHQ_ALERT_DEFINITION" column="operation_def_id" />
+ </schemaSpec>
+ <schemaSpec version="2.70.5">
+ <schema-deleteColumn table="RHQ_ALERT_NOTIF_LOG" column="roles" />
+ <schema-deleteColumn table="RHQ_ALERT_NOTIF_LOG" column="subjects" />
+ <schema-deleteColumn table="RHQ_ALERT_NOTIF_LOG" column="emails" />
+ </schemaSpec>
+ <schemaSpec version="2.70.6">
+ <schema-addColumn table="RHQ_ALERT_NOTIF_LOG" column="SENDER" columnType="VARCHAR2" precision="200" />
+ <schema-addColumn table="RHQ_ALERT_NOTIF_LOG" column="RESULT_STATE" columnType="VARCHAR2" precision="20" />
+ <schema-addColumn table="RHQ_ALERT_NOTIF_LOG" column="MESSAGE" columnType="VARCHAR2" precision="255" />
+ <schema-addColumn table="RHQ_ALERT_NOTIF_LOG" column="ALL_EMAILS" columnType="VARCHAR2" precision="4000" />
+ <schema-addColumn table="RHQ_ALERT_NOTIF_LOG" column="EMAILS_FAILED" columnType="VARCHAR2" precision="4000" />
+ </schemaSpec>
+ <schemaSpec version="2.70.7">
+ <schema-directSQL>
+ <statement>
+ DROP INDEX RHQ_ALERT_IDX_ALERT
+ </statement>
+ <statement>
+ CREATE INDEX RHQ_ALERT_IDX_ALERT ON RHQ_ALERT_NOTIF_LOG (alert_id)
+ </statement>
+ </schema-directSQL>
+ </schemaSpec>
<!-- RHQ Advisory Representation -->
<schemaSpec version="2.71">
@@ -2296,47 +2350,6 @@
<schema-addColumn table="RHQ_CONFIG_PROP_DEF" column="DYNAMIC_KEY" columnType="VARCHAR2" precision="128" />
</schemaSpec>
- <schemaSpec version="2.77">
- <schema-addColumn table="RHQ_ALERT_NOTIFICATION" column="NOTIF_TEMPLATE_ID" columnType="INTEGER" />
- <schema-directSQL>
- <statement>
- ALTER TABLE RHQ_ALERT_NOTIFICATION
- ADD CONSTRAINT RHQ_CPD_NOTIF_TEMPLATE_ID_FK
- FOREIGN KEY (NOTIF_TEMPLATE_ID)
- REFERENCES RHQ_ALERT_NOTIF_TEMPL(ID)
- </statement>
- </schema-directSQL>
- </schemaSpec>
- <schemaSpec version="2.77.1">
- <schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="snmp_host" />
- <schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="snmp_port" />
- <schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="snmp_oid" />
- <schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="email_address" />
- <schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="role_id" />
- <schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="subject_id" />
- </schemaSpec>
- <schemaSpec version="2.77.2">
- <schema-deleteColumn table="RHQ_ALERT_NOTIF_LOG" column="roles" />
- <schema-deleteColumn table="RHQ_ALERT_NOTIF_LOG" column="subjects" />
- <schema-deleteColumn table="RHQ_ALERT_NOTIF_LOG" column="emails" />
-
- <schema-addColumn table="RHQ_ALERT_NOTIF_LOG" column="SENDER" columnType="VARCHAR2" precision="200" />
- <schema-addColumn table="RHQ_ALERT_NOTIF_LOG" column="RESULT_STATE" columnType="VARCHAR2" precision="20" />
- <schema-addColumn table="RHQ_ALERT_NOTIF_LOG" column="MESSAGE" columnType="VARCHAR2" precision="255" />
- <schema-addColumn table="RHQ_ALERT_NOTIF_LOG" column="ALL_EMAILS" columnType="VARCHAR2" precision="4000" />
- <schema-addColumn table="RHQ_ALERT_NOTIF_LOG" column="EMAILS_FAILED" columnType="VARCHAR2" precision="4000" />
- </schemaSpec>
- <schemaSpec version="2.77.3">
- <schema-directSQL>
- <statement>
- DROP INDEX RHQ_ALERT_IDX_ALERT
- </statement>
- <statement>
- CREATE INDEX RHQ_ALERT_IDX_ALERT ON RHQ_ALERT_NOTIF_LOG (alert_id)
- </statement>
- </schema-directSQL>
- </schemaSpec>
-
<schemaSpec version="2.78">
<!-- RHQ_BUNDLE_TYPE -->
<schema-createSequence name="RHQ_BUNDLE_TYPE_ID_SEQ" initial="10001" />
@@ -2734,7 +2747,7 @@
</statement>
</schema-directSQL>
</schemaSpec>
-
+
</dbupgrade>
</target>
</project>
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/Alert.java b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/Alert.java
index 904acce..b676c05 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/Alert.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/Alert.java
@@ -45,7 +45,6 @@ import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import org.rhq.core.domain.alert.notification.AlertNotificationLog;
-import org.rhq.core.domain.auth.Subject;
/**
* @author Joseph Marques
@@ -113,10 +112,10 @@ import org.rhq.core.domain.auth.Subject;
+ " WHERE condition.measurementDefinition.id = :measurementDefinitionId " //
+ " AND definition.resource.id = ( :resourceId ) " //
+ " AND ( a.ctime BETWEEN :startDate AND :endDate )"),
- @NamedQuery(name = Alert.QUERY_GET_ALERT_COUNT_FOR_SCHEDULES, query = "SELECT sched.id, count(*) " +
- " FROM Alert AS a JOIN a.alertDefinition aDef JOIN aDef.conditions condition " +
- " JOIN aDef.resource res JOIN condition.measurementDefinition mDef JOIN mDef.schedules sched" +
- " WHERE sched.definition = mDef.id AND sched.resource = res AND sched.id IN (:schedIds) "
+ @NamedQuery(name = Alert.QUERY_GET_ALERT_COUNT_FOR_SCHEDULES, query = "SELECT sched.id, count(*) "
+ + " FROM Alert AS a JOIN a.alertDefinition aDef JOIN aDef.conditions condition "
+ + " JOIN aDef.resource res JOIN condition.measurementDefinition mDef JOIN mDef.schedules sched"
+ + " WHERE sched.definition = mDef.id AND sched.resource = res AND sched.id IN (:schedIds) "
+ " AND (a.ctime BETWEEN :startDate AND :endDate)" + "GROUP BY sched.id"),
@NamedQuery(name = Alert.QUERY_FIND_BY_RESOURCE_DATED, //
query = "SELECT a " //
@@ -258,12 +257,11 @@ public class Alert implements Serializable {
@Column(name = "WILL_RECOVER", nullable = false)
private boolean willRecover;
- @Column(name ="ACK_TIME")
- private long ackTime = -1;
+ @Column(name = "ACK_TIME")
+ private long acknowledgeTime = -1;
- @JoinColumn(name = "ACK_BY_ID", referencedColumnName = "ID")
- @ManyToOne
- private Subject ackBy;
+ @Column(name = "ACK_SUBJECT")
+ private String acknowledgingSubject;
/**
* Creates a new alert. (required by EJB3 spec, but not used)
@@ -335,20 +333,20 @@ public class Alert implements Serializable {
this.triggeredOperation = triggeredOperation;
}
- public long getAckTime() {
- return ackTime;
+ public long getAcknowledgeTime() {
+ return acknowledgeTime;
}
- public void setAckTime(long ackTime) {
- this.ackTime = ackTime;
+ public void setAcknowledgeTime(long acknowledgeTime) {
+ this.acknowledgeTime = acknowledgeTime;
}
- public Subject getAckBy() {
- return ackBy;
+ public String getAcknowledgingSubject() {
+ return acknowledgingSubject;
}
- public void setAckBy(Subject ackBy) {
- this.ackBy = ackBy;
+ public void setAcknowledgingSubject(String acknowledgingSubject) {
+ this.acknowledgingSubject = acknowledgingSubject;
}
public boolean getWillRecover() {
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java
index ef7b3e9..1f14aad 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java
@@ -26,15 +26,11 @@ import java.io.Serializable;
import javax.persistence.CascadeType;
import javax.persistence.Column;
-import javax.persistence.DiscriminatorColumn;
-import javax.persistence.DiscriminatorType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
-import javax.persistence.Inheritance;
-import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
@@ -49,9 +45,7 @@ import org.jetbrains.annotations.NotNull;
import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.configuration.Configuration;
-@DiscriminatorColumn(name = "NOTIFICATION_TYPE", discriminatorType = DiscriminatorType.STRING)
@Entity
-@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@NamedQueries( {
@NamedQuery(name = AlertNotification.DELETE_BY_ID, query = "DELETE FROM AlertNotification an WHERE an.id IN ( :ids )"),
@NamedQuery(name = AlertNotification.QUERY_DELETE_BY_RESOURCES, query = "DELETE FROM AlertNotification an WHERE an.alertDefinition IN ( SELECT ad FROM AlertDefinition ad WHERE ad.resource.id IN ( :resourceIds ) )"),
@@ -80,22 +74,19 @@ public class AlertNotification implements Serializable {
@ManyToOne
private AlertDefinition alertDefinition;
- @JoinColumn(name = "NOTIF_TEMPLATE_ID")
+ @JoinColumn(name = "TEMPLATE_ID")
@ManyToOne
private AlertNotificationTemplate alertNotificationTemplate;
- @JoinColumn(name = "ALERT_CONFIG_ID", referencedColumnName = "ID")
+ @JoinColumn(name = "SENDER_CONFIG_ID", referencedColumnName = "ID")
@OneToOne(cascade = { CascadeType.ALL }, fetch = FetchType.LAZY)
private Configuration configuration;
- @Column(name = "ALERT_SENDER_NAME")
+ @Column(name = "SENDER_NAME")
private String senderName;
- @Column(name = "ALERT_ORDER")
- private int order;
-
- @Column(name = "NAME")
- private String name;
+ @Column(name = "DISPLAY_NAME")
+ private String displayName;
protected AlertNotification() {
} // JPA spec
@@ -127,8 +118,8 @@ public class AlertNotification implements Serializable {
this.alertNotificationId = alertNotificationId;
}
- public AlertNotification(String name, String sender) {
- this.name = name;
+ public AlertNotification(String displayName, String sender) {
+ this.displayName = displayName;
this.senderName = sender;
}
@@ -155,14 +146,14 @@ public class AlertNotification implements Serializable {
public AlertNotification copyWithAlertDefintion(AlertDefinition alertDefinition, boolean cloneConfiguration) {
Configuration config;
- if (cloneConfiguration)
+ if (cloneConfiguration) {
config = this.configuration.deepCopy(false);
- else
+ } else {
config = this.configuration;
+ }
AlertNotification notification = new AlertNotification(alertDefinition, config);
- notification.setName(this.name);
+ notification.setDisplayName(this.displayName);
notification.setSenderName(this.senderName);
- notification.setOrder(this.order);
return notification;
}
@@ -190,20 +181,12 @@ public class AlertNotification implements Serializable {
this.configuration = configuration;
}
- public int getOrder() {
- return order;
- }
-
- public void setOrder(int order) {
- this.order = order;
- }
-
- public String getName() {
- return name;
+ public String getDisplayName() {
+ return displayName;
}
- public void setName(String name) {
- this.name = name;
+ public void setDisplayName(String displayName) {
+ this.displayName = displayName;
}
public AlertNotificationTemplate getAlertNotificationTemplate() {
@@ -231,8 +214,7 @@ public class AlertNotification implements Serializable {
sb.append(", id=").append(id);
sb.append(", notificationTemplate=").append(alertNotificationTemplate);
sb.append(", senderName='").append(senderName).append('\'');
- sb.append(", order=").append(order);
- sb.append(", name='").append(name).append('\'');
+ sb.append(", displayName='").append(displayName).append('\'');
sb.append('}');
return sb.toString();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java
index a97374f..c02de80 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java
@@ -18,6 +18,13 @@
*/
package org.rhq.enterprise.gui.coregui.client.alert;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.user.client.Window;
@@ -33,6 +40,7 @@ import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.rpc.RPCResponse;
import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridRecord;
+
import org.rhq.core.domain.alert.Alert;
import org.rhq.core.domain.alert.AlertCondition;
import org.rhq.core.domain.alert.AlertConditionLog;
@@ -46,13 +54,6 @@ import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
/**
* A server-side SmartGWT DataSource for CRUD of {@link Alert}s.
*
@@ -107,7 +108,7 @@ public class AlertDataSource extends RPCDataSource<Alert> {
DataSourceTextField ctimeField = new DataSourceTextField(AlertCriteria.SORT_FIELD_CTIME, "Creation Time");
fields.add(ctimeField);
- DataSourceBooleanField boolField = new DataSourceBooleanField("ack","Ack'd");
+ DataSourceBooleanField boolField = new DataSourceBooleanField("ack", "Ack'd");
boolField.setCanSortClientOnly(true);
fields.add(boolField);
@@ -127,14 +128,17 @@ public class AlertDataSource extends RPCDataSource<Alert> {
this.alertService.deleteResourceAlerts(alertIds, new AsyncCallback<Void>() {
public void onSuccess(Void blah) {
- CoreGUI.getMessageCenter().notify(new Message("Deleted ["+ alertIds.length + "] alerts", Message.Severity.Info));
+ CoreGUI.getMessageCenter().notify(
+ new Message("Deleted [" + alertIds.length + "] alerts", Message.Severity.Info));
System.out.println("Deleted Alerts with id's: " + Arrays.toString(alertIds) + ".");
alertsView.refresh();
}
public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to delete Alerts with id's: " + Arrays.toString(alertIds), caught);
- System.err.println("Failed to delete Alerts with id's " + Arrays.toString(alertIds) + " - cause: " + caught);
+ CoreGUI.getErrorHandler().handleError(
+ "Failed to delete Alerts with id's: " + Arrays.toString(alertIds), caught);
+ System.err.println("Failed to delete Alerts with id's " + Arrays.toString(alertIds) + " - cause: "
+ + caught);
}
});
}
@@ -189,7 +193,7 @@ public class AlertDataSource extends RPCDataSource<Alert> {
@Override
public Alert copyValues(ListGridRecord from) {
- return null; // TODO: Implement this method.
+ return null; // TODO: Implement this method.
}
@Override
@@ -200,8 +204,9 @@ public class AlertDataSource extends RPCDataSource<Alert> {
record.setAttribute("name", from.getAlertDefinition().getName());
record.setAttribute("priority", from.getAlertDefinition().getPriority().name());
record.setAttribute("ctime", DATE_TIME_FORMAT.format(new Date(from.getCtime())));
- if (from.getAckTime() >0)
- record.setAttribute("ack","true");
+ if (from.getAcknowledgeTime() > 0) {
+ record.setAttribute("ack", "true");
+ }
Set<AlertConditionLog> conditionLogs = from.getConditionLogs();
String conditionText;
@@ -231,17 +236,17 @@ public class AlertDataSource extends RPCDataSource<Alert> {
for (AlertConditionLog log : from.getConditionLogs()) {
AlertCondition condition = log.getCondition();
DataClass dc = new DataClass();
- dc.setAttribute("text",AlertFormatUtility.formatAlertConditionForDisplay(condition));
+ dc.setAttribute("text", AlertFormatUtility.formatAlertConditionForDisplay(condition));
String value = log.getValue();
if (condition.getMeasurementDefinition() != null) {
value = MeasurementConverterClient.format(Double.valueOf(log.getValue()), condition
.getMeasurementDefinition().getUnits(), true);
}
- dc.setAttribute("value",value);
+ dc.setAttribute("value", value);
conditions[i++] = dc;
}
- record.setAttribute("conditionLogs",conditions);
- record.setAttribute("conditionExpression",from.getAlertDefinition().getConditionExpression());
+ record.setAttribute("conditionLogs", conditions);
+ record.setAttribute("conditionExpression", from.getAlertDefinition().getConditionExpression());
String recoveryInfo = AlertFormatUtility.getAlertRecoveryInfo(from);
record.setAttribute("recoveryInfo", recoveryInfo);
@@ -249,23 +254,23 @@ public class AlertDataSource extends RPCDataSource<Alert> {
// Alert notification logs
DataClass[] notifications = new DataClass[from.getAlertNotificationLogs().size()];
i = 0;
- for(AlertNotificationLog log : from.getAlertNotificationLogs()) {
+ for (AlertNotificationLog log : from.getAlertNotificationLogs()) {
DataClass dc = new DataClass();
- dc.setAttribute("sender",log.getSender());
- dc.setAttribute("status",log.getResultState());
- dc.setAttribute("message",log.getMessage());
- dc.setAttribute("allEmails",log.getAllEmails());
- dc.setAttribute("badEmails",log.getBadEmails());
+ dc.setAttribute("sender", log.getSender());
+ dc.setAttribute("status", log.getResultState());
+ dc.setAttribute("message", log.getMessage());
+ dc.setAttribute("allEmails", log.getAllEmails());
+ dc.setAttribute("badEmails", log.getBadEmails());
notifications[i++] = dc;
}
- record.setAttribute("notificationLogs",notifications);
+ record.setAttribute("notificationLogs", notifications);
return record;
}
protected void executeRemove(final DSRequest request, final DSResponse response) {
- JavaScriptObject data = request.getData ();
+ JavaScriptObject data = request.getData();
ListGridRecord record = new ListGridRecord(data);
Window.alert(String.valueOf(record.getAttributeAsInt("id")));
}
@@ -283,15 +288,18 @@ public class AlertDataSource extends RPCDataSource<Alert> {
this.alertService.acknowledgeResourceAlerts(alertIds, new AsyncCallback<Void>() {
public void onSuccess(Void blah) {
- CoreGUI.getMessageCenter().notify(new Message("Acknowledged ["+ alertIds.length + "] alerts", Message.Severity.Info));
+ CoreGUI.getMessageCenter().notify(
+ new Message("Acknowledged [" + alertIds.length + "] alerts", Message.Severity.Info));
System.out.println("Acknowledged Alerts with id's: " + Arrays.toString(alertIds) + ".");
alertsView.refresh();
}
public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to acknowledge Alerts with id's: " + Arrays.toString(alertIds), caught);
- System.err.println("Failed to acknowledge Alerts with id's " + Arrays.toString(alertIds) + " - cause: " + caught);
+ CoreGUI.getErrorHandler().handleError(
+ "Failed to acknowledge Alerts with id's: " + Arrays.toString(alertIds), caught);
+ System.err.println("Failed to acknowledge Alerts with id's " + Arrays.toString(alertIds) + " - cause: "
+ + caught);
}
});
}
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/alerts/AckAlertAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/alerts/AckAlertAction.java
index 6043d19..a202c5b 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/alerts/AckAlertAction.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/alerts/AckAlertAction.java
@@ -29,10 +29,7 @@ import org.apache.commons.logging.LogFactory;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
-import org.apache.struts.tiles.ComponentContext;
-import org.apache.struts.tiles.actions.TilesAction;
-import org.rhq.core.domain.alert.Alert;
import org.rhq.core.domain.auth.Subject;
import org.rhq.enterprise.gui.legacy.action.BaseAction;
import org.rhq.enterprise.gui.legacy.util.RequestUtils;
@@ -49,7 +46,7 @@ public class AckAlertAction extends BaseAction {
Log log = LogFactory.getLog(AckAlertAction.class);
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
- HttpServletResponse response) throws Exception {
+ HttpServletResponse response) throws Exception {
Subject subject = RequestUtils.getSubject(request);
AlertManagerLocal alertManager = LookupUtil.getAlertManager();
@@ -58,21 +55,21 @@ public class AckAlertAction extends BaseAction {
// pass-through the alertId and resource id
Integer alertId = new Integer(request.getParameter("a"));
request.setAttribute("a", alertId);
- params.put("a",alertId);
+ params.put("a", alertId);
Integer resourceId = new Integer(request.getParameter("id"));
- request.setAttribute("id",resourceId);
- params.put("id",resourceId);
+ request.setAttribute("id", resourceId);
+ params.put("id", resourceId);
String mode = request.getParameter("mode");
- request.setAttribute("mode",mode);
- params.put("mode",mode);
+ request.setAttribute("mode", mode);
+ params.put("mode", mode);
- alertManager.acknowledgeAlert(alertId,subject);
+ alertManager.acknowledgeAlerts(subject, new Integer[] { alertId });
log.debug("Acknowledged Alert with id " + alertId + " and user " + subject.getName());
- return returnSuccess(request,mapping,params);
+ return returnSuccess(request, mapping, params);
}
}
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 db62a94..2a9f4b3 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
@@ -57,6 +57,7 @@ import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.alert.AlertPriority;
import org.rhq.core.domain.alert.notification.AlertNotification;
import org.rhq.core.domain.alert.notification.AlertNotificationLog;
+import org.rhq.core.domain.alert.notification.ResultState;
import org.rhq.core.domain.alert.notification.SenderResult;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.authz.Permission;
@@ -68,9 +69,9 @@ import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.domain.util.PageOrdering;
+import org.rhq.core.domain.util.StringUtils;
import org.rhq.core.server.MeasurementConverter;
import org.rhq.core.server.PersistenceUtility;
-import org.rhq.core.domain.util.StringUtils;
import org.rhq.core.util.collection.ArrayUtils;
import org.rhq.core.util.jdbc.JDBCUtil;
import org.rhq.enterprise.server.RHQConstants;
@@ -87,14 +88,12 @@ import org.rhq.enterprise.server.plugin.pc.MasterServerPluginContainer;
import org.rhq.enterprise.server.plugin.pc.alert.AlertSender;
import org.rhq.enterprise.server.plugin.pc.alert.AlertSenderPluginManager;
import org.rhq.enterprise.server.plugin.pc.alert.AlertServerPluginContainer;
-import org.rhq.core.domain.alert.notification.ResultState;
import org.rhq.enterprise.server.resource.ResourceManagerLocal;
import org.rhq.enterprise.server.system.SystemManagerLocal;
import org.rhq.enterprise.server.util.CriteriaQueryGenerator;
import org.rhq.enterprise.server.util.CriteriaQueryRunner;
import org.rhq.enterprise.server.util.LookupUtil;
-
/**
* @author Joseph Marques
* @author Ian Springer
@@ -130,7 +129,6 @@ public class AlertManagerBean implements AlertManagerLocal, AlertManagerRemote {
@javax.annotation.Resource(name = "RHQ_DS")
private DataSource rhqDs;
-
/**
* Persist a detached alert.
*
@@ -148,27 +146,31 @@ public class AlertManagerBean implements AlertManagerLocal, AlertManagerRemote {
/**
* Remove the alerts with the specified id's.
* @param user caller
- * @param ids primary keys of the alerts to delete
+ * @param alertIds primary keys of the alerts to delete
* @return number of alerts deleted
*/
- public int deleteAlerts(Subject user, Integer[] ids) {
- if (!authorizationManager.hasGlobalPermission(user,Permission.MANAGE_ALERTS))
- throw new PermissionException("User [" + user.getName() + "] does not have permissions to delete alerts ");
-
- int i = 0;
- for (Integer id : ids) {
- Alert alert = entityManager.find(Alert.class, id);
+ public int deleteAlerts(Subject user, Integer[] alertIds) {
+ int count = 0;
+ for (Integer nextAlertId : alertIds) {
+ Alert alert = entityManager.find(Alert.class, nextAlertId);
if (alert != null) {
-// AlertNotificationLog anl = alert.getAlertNotificationLog(); TODO is that all?
-// entityManager.remove(anl);
+ // AlertNotificationLog anl = alert.getAlertNotificationLog(); TODO is that all?
+ // entityManager.remove(anl);
+ Resource resource = alert.getAlertDefinition().getResource();
+ if (!authorizationManager.hasResourcePermission(user, Permission.MANAGE_ALERTS, resource.getId())) {
+ throw new PermissionException("User [" + user.getName()
+ + "] does not have permissions to delete alerts: " + Arrays.asList(alertIds));
+ }
+
entityManager.remove(alert); // condition logs will be removed with entity cascading
}
- i++;
+ count++;
}
- return i;
+ return count;
}
- public void deleteResourceAlerts(Subject user, Integer[] alertIds) {
+ @SuppressWarnings("unchecked")
+ private void checkAlertsPermission(Subject user, Integer[] alertIds) {
Query q = entityManager.createNamedQuery(Alert.QUERY_FIND_RESOURCES);
q.setParameter("alertIds", Arrays.asList(alertIds));
List<Resource> resources = q.getResultList();
@@ -180,9 +182,13 @@ public class AlertManagerBean implements AlertManagerLocal, AlertManagerRemote {
}
}
if (!forbiddenResources.isEmpty()) {
- throw new PermissionException("User [" + user.getName() + "] does not have permissions to delete alerts "
- + "for the following Resource(s): " + forbiddenResources);
+ throw new PermissionException("User [" + user.getName() + "] does not have permissions to manage alerts "
+ + "for the following Resource(s): " + forbiddenResources);
}
+ }
+
+ public void deleteResourceAlerts(Subject user, Integer[] alertIds) {
+ checkAlertsPermission(user, alertIds);
deleteAlerts(user, alertIds);
}
@@ -568,48 +574,33 @@ public class AlertManagerBean implements AlertManagerLocal, AlertManagerRemote {
}
/**
- * Mark the matching alert as acknowledged by the user
- * @param alertId Id of the alert to acknowledge
- * @param user user who acknowledged the alert
- */
- public void acknowledgeAlert(int alertId, Subject user) {
- Alert alert = entityManager.find(Alert.class,alertId);
- if (alert==null) {
- log.warn("Alert [ " + alertId + " ] to acknowledge was not found ");
- return;
- }
- alert.setAckBy(user);
- alert.setAckTime(System.currentTimeMillis());
- }
-
- /**
- * Acknowledge the alerts (that got fired) so that admins know who is working
- * on fixing the situation.
+ * Acknowledge the alerts (that got fired) so that admins know who is working on fixing the situation.
+ *
* @param user calling user
- * @param alertIds PKs of the alerts to ack
+ * @param alertIds PKs of the alerts to acknowledge
* @return number of alerts acknowledged
*/
public int acknowledgeAlerts(Subject user, Integer[] alertIds) {
- if (!authorizationManager.hasGlobalPermission(user, Permission.MANAGE_ALERTS)) {
- throw new PermissionException("User [" + user.getName() + "] does not have permissions to acknowledge alerts ");
- }
-
- int i=0;
- if (alertIds==null || alertIds.length==0) {
+ if (alertIds == null || alertIds.length == 0) {
log.debug("acknowledgeAlerts: no alertIds passed");
- return -1;
+ return 0;
}
- for (int id : alertIds) {
- acknowledgeAlert(id,user);
- i++;
- if (i % 50 == 0) {
- entityManager.flush();
- entityManager.clear();
- }
+ checkAlertsPermission(user, alertIds);
+ int count = 0;
+ final long NOW = System.currentTimeMillis();
+ for (int nextAlertId : alertIds) {
+ Alert alert = entityManager.find(Alert.class, nextAlertId);
+ if (alert == null) {
+ continue;
+ } else {
+ count++;
+ }
+ alert.setAcknowledgingSubject(user.getName());
+ alert.setAcknowledgeTime(NOW);
}
- return i;
+ return count;
}
public void fireAlert(int alertDefinitionId) {
@@ -634,8 +625,8 @@ public class AlertManagerBean implements AlertManagerLocal, AlertManagerRemote {
this.createAlert(newAlert);
log.debug("New alert identifier=" + newAlert.getId());
-// AlertNotificationLog alertNotifLog = new AlertNotificationLog(newAlert); TODO - is that all?
-// entityManager.persist(alertNotifLog);
+ // AlertNotificationLog alertNotifLog = new AlertNotificationLog(newAlert); TODO - is that all?
+ // entityManager.persist(alertNotifLog);
List<AlertConditionLog> unmatchedConditionLogs = alertConditionLogManager
.getUnmatchedLogsByAlertDefinitionId(alertDefinitionId);
@@ -694,7 +685,7 @@ public class AlertManagerBean implements AlertManagerLocal, AlertManagerRemote {
// Send over the new AlertSender plugins
String senderName = alertNotification.getSenderName();
- if (senderName ==null) {
+ if (senderName == null) {
log.error("Alert notification " + alertNotification + " has no sender name defined");
continue;
}
@@ -707,9 +698,9 @@ public class AlertManagerBean implements AlertManagerLocal, AlertManagerRemote {
SenderResult result = sender.send(alert);
if (result == null) {
- log.warn("- !! -- sender [" + senderName +
- "] did not return a SenderResult. Please fix this -- !! - ");
- alNoLo = new AlertNotificationLog(alert,senderName);
+ log.warn("- !! -- sender [" + senderName
+ + "] did not return a SenderResult. Please fix this -- !! - ");
+ alNoLo = new AlertNotificationLog(alert, senderName);
alNoLo.setMessage("Sender did not return a SenderResult, assuming failure");
} else if (result.getState() == ResultState.DEFERRED_EMAIL) {
@@ -722,20 +713,16 @@ public class AlertManagerBean implements AlertManagerLocal, AlertManagerRemote {
alNoLo = new AlertNotificationLog(alert, senderName, result);
}
log.info(result);
- }
- catch (Throwable t) {
+ } catch (Throwable t) {
log.error("Sender failed: " + t.getMessage());
if (log.isDebugEnabled())
log.debug("Sender " + sender.toString() + "failed: \n", t);
- alNoLo = new AlertNotificationLog(alert, senderName,
- ResultState.FAILURE,
- "Failed with exception: " + t.getMessage());
+ alNoLo = new AlertNotificationLog(alert, senderName, ResultState.FAILURE,
+ "Failed with exception: " + t.getMessage());
}
- }
- else {
- alNoLo = new AlertNotificationLog(alert, senderName,
- ResultState.FAILURE,
- "Failed to obtain a sender with given name");
+ } else {
+ alNoLo = new AlertNotificationLog(alert, senderName, ResultState.FAILURE,
+ "Failed to obtain a sender with given name");
}
entityManager.persist(alNoLo);
alert.addAlertNotificatinLog(alNoLo);
@@ -758,23 +745,20 @@ public class AlertManagerBean implements AlertManagerLocal, AlertManagerRemote {
badList.add(badOne);
}
}
- if (anl.getResultState()==ResultState.FAILED_EMAIL)
- anl.setBadEmails(StringUtils.getListAsString(badList,","));
- if (anl.getResultState()==ResultState.DEFERRED_EMAIL && badList.isEmpty())
+ if (anl.getResultState() == ResultState.FAILED_EMAIL)
+ anl.setBadEmails(StringUtils.getListAsString(badList, ","));
+ if (anl.getResultState() == ResultState.DEFERRED_EMAIL && badList.isEmpty())
anl.setResultState(ResultState.SUCCESS);
}
- }
- else { // No bad addresses
+ } else { // No bad addresses
// Only set the result state to success for email sending notifications
// We must not set them if the notification failed.
for (AlertNotificationLog anl : alert.getAlertNotificationLogs()) {
- if (anl.getResultState()==ResultState.DEFERRED_EMAIL)
+ if (anl.getResultState() == ResultState.DEFERRED_EMAIL)
anl.setResultState(ResultState.SUCCESS);
}
}
-
-
} catch (Exception e) {
log.error("Failed to send all notifications for " + alert.toSimpleString(), e);
}
@@ -897,13 +881,11 @@ public class AlertManagerBean implements AlertManagerLocal, AlertManagerRemote {
format = AlertI18NResourceKeys.ALERT_EMAIL_CONDITION_LOG_FORMAT;
SimpleDateFormat dateFormat;
if (shortVersion)
- dateFormat= new SimpleDateFormat(
- "yy/MM/dd HH:mm:ss z");
+ dateFormat = new SimpleDateFormat("yy/MM/dd HH:mm:ss z");
else
- dateFormat= new SimpleDateFormat(
- "yyyy/MM/dd HH:mm:ss z");
- builder.append(AlertI18NFactory.getMessage(format,
- conditionCounter, prettyPrintAlertCondition(aLog.getCondition(), shortVersion), dateFormat.format(new Date(aLog.getCtime())), formattedValue));
+ dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss z");
+ builder.append(AlertI18NFactory.getMessage(format, conditionCounter, prettyPrintAlertCondition(aLog
+ .getCondition(), shortVersion), dateFormat.format(new Date(aLog.getCtime())), formattedValue));
conditionCounter++;
}
@@ -928,7 +910,7 @@ public class AlertManagerBean implements AlertManagerLocal, AlertManagerRemote {
builder.append(condition.getName()).append(' ');
}
} else {
- if (category.getName()!=null) // this is null for e.g. availability
+ if (category.getName() != null) // this is null for e.g. availability
builder.append(condition.getName()).append(' ');
}
@@ -961,7 +943,8 @@ public class AlertManagerBean implements AlertManagerLocal, AlertManagerRemote {
|| (category == AlertConditionCategory.TRAIT)) {
if (shortVersion)
- builder.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_CURRENT_LIST_VALUE_CHANGED_SHORT));
+ builder.append(AlertI18NFactory
+ .getMessage(AlertI18NResourceKeys.ALERT_CURRENT_LIST_VALUE_CHANGED_SHORT));
else
builder.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_CURRENT_LIST_VALUE_CHANGED));
@@ -973,21 +956,20 @@ public class AlertManagerBean implements AlertManagerLocal, AlertManagerRemote {
else
propsCbEventSeverityRegexMatch = AlertI18NResourceKeys.ALERT_CONFIG_PROPS_CB_EVENT_SEVERITY_REGEX_MATCH;
- builder.append(AlertI18NFactory.getMessage(
- propsCbEventSeverityRegexMatch, condition.getName(),
+ builder.append(AlertI18NFactory.getMessage(propsCbEventSeverityRegexMatch, condition.getName(),
condition.getOption()));
} else {
if (shortVersion)
- builder.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_CONFIG_PROPS_CB_EVENT_SEVERITY_SHORT,
- condition.getName()));
+ builder.append(AlertI18NFactory.getMessage(
+ AlertI18NResourceKeys.ALERT_CONFIG_PROPS_CB_EVENT_SEVERITY_SHORT, condition.getName()));
else
- builder.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_CONFIG_PROPS_CB_EVENT_SEVERITY,
- condition.getName()));
+ builder.append(AlertI18NFactory.getMessage(
+ AlertI18NResourceKeys.ALERT_CONFIG_PROPS_CB_EVENT_SEVERITY, condition.getName()));
}
} else if (category == AlertConditionCategory.AVAILABILITY) {
if (shortVersion)
- builder.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_CONFIG_PROPS_CB_AVAILABILITY_SHORT,
- condition.getOption()));
+ builder.append(AlertI18NFactory.getMessage(
+ AlertI18NResourceKeys.ALERT_CONFIG_PROPS_CB_AVAILABILITY_SHORT, condition.getOption()));
else
builder.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_CONFIG_PROPS_CB_AVAILABILITY,
condition.getOption()));
@@ -1015,7 +997,6 @@ public class AlertManagerBean implements AlertManagerLocal, AlertManagerRemote {
return builder.toString();
}
-
private void processRecovery(AlertDefinition firedDefinition) {
Subject overlord = subjectManager.getOverlord();
Integer recoveryDefinitionId = firedDefinition.getRecoveryId();
@@ -1088,7 +1069,6 @@ public class AlertManagerBean implements AlertManagerLocal, AlertManagerRemote {
return false; // Default is not to disable the definition
}
-
@SuppressWarnings("unchecked")
public PageList<Alert> findAlertsByCriteria(Subject subject, AlertCriteria criteria) {
CriteriaQueryGenerator generator = new CriteriaQueryGenerator(criteria);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerLocal.java
index 45deaf4..a55926a 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerLocal.java
@@ -92,13 +92,6 @@ public interface AlertManagerLocal {
Map<Integer, Integer> getAlertCountForSchedules(long begin, long end, List<Integer> scheduleIds);
/**
- * Mark the matching alert as acknowledged by the user
- * @param alertId Id of the alert to acknowledge
- * @param user user who acknowledged the alert
- */
- void acknowledgeAlert(int alertId, Subject user);
-
- /**
* Return the plugin manager that is managing alert sender plugins
* @return The alert sender plugin manager
*/
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 224961f..8a4bb98 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
@@ -307,7 +307,7 @@ public class AlertNotificationManagerBean implements AlertNotificationManagerLoc
entityManager.persist(configuration);
AlertNotification notif = new AlertNotification(definition);
notif.setSenderName(senderName);
- notif.setName(alertName);
+ notif.setDisplayName(alertName);
notif.setConfiguration(configuration);
entityManager.persist(notif);
definition.getAlertNotifications().add(notif);
@@ -537,38 +537,4 @@ public class AlertNotificationManagerBean implements AlertNotificationManagerLoc
return template;
}
- /**
- * Add the passed 'transient' notifications onto the alert definitions contained. The old
- * notifications are removed.
- * This method is mainly used when migrating alerts from an old format to the current.
- * @param subject Subject of the caller
- * @param notifications list of AlertNotifications that have the alert definition id encoded in a transient field
- */
- public void mergeTransientAlertNotifications(Subject subject, List<AlertNotification> notifications) {
-
- // Clear out old notifications
- for (AlertNotification n : notifications) {
- AlertDefinition def = alertDefinitionManager.getAlertDefinitionById(subject, n.getAlertDefinitionId());
- if (def == null) {
- LOG.error("Alert Definition with id " + n.getAlertDefinitionId() + "does not exist for notification "
- + n);
- continue;
- }
- def.getAlertNotifications().clear();
- }
-
- // add the new ones
- for (AlertNotification n : notifications) {
- AlertDefinition def = alertDefinitionManager.getAlertDefinitionById(subject, n.getAlertDefinitionId());
- if (def == null)
- continue;
-
- AlertNotification alNo = new AlertNotification(def, n.getConfiguration());
- alNo.setSenderName(n.getSenderName());
- alNo.setName(n.getName());
- alNo.setOrder(n.getOrder());
- entityManager.persist(alNo);
- def.addAlertNotification(alNo);
- }
- }
}
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 80c77db..56f1c20 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
@@ -113,15 +113,6 @@ public interface AlertNotificationManagerLocal {
String getBackingBeanNameForSender(String shortName);
/**
- * Add the passed 'transient' notifications onto the alert definitions contained. The old
- * notifications are removed.
- * This method is mainly used when migrating alerts from an old format to the current.
- * @param subject Subject of the caller
- * @param notifications list of AlertNotifications that have the alert definition id encoded in a transient field
- */
- void mergeTransientAlertNotifications(Subject subject, List<AlertNotification> notifications);
-
- /**
* Create a new NotificationTemplate from the passed parameters. The passed AlertNotification objects need to have the
* name and sender and any configuration properties already set; alert definitions must not be set.
* @param name name of this notification template. Must be unique
commit 144c8218afa68c76c5799a8efee3e8411e690989
Author: Joseph Marques <joseph(a)redhat.com>
Date: Wed Apr 21 20:32:59 2010 -0400
add support for launching JavaTasks which can execute arbitrary SQL against the connection used by the DBUpgrader
diff --git a/modules/core/dbutils/src/main/java/org/rhq/core/db/DatabaseType.java b/modules/core/dbutils/src/main/java/org/rhq/core/db/DatabaseType.java
index 1b48d57..bc4edb6 100644
--- a/modules/core/dbutils/src/main/java/org/rhq/core/db/DatabaseType.java
+++ b/modules/core/dbutils/src/main/java/org/rhq/core/db/DatabaseType.java
@@ -25,10 +25,13 @@ import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Types;
+import java.util.ArrayList;
import java.util.List;
import mazz.i18n.Logger;
+import org.rhq.core.db.ant.dbupgrade.SST_JavaTask;
+
/**
* A vendor-specific database with some vendor-specific method implementations in order to do things necessary for each
* individual type of database. This abstract class provides some default implementations; vendor-specific subclasses
@@ -356,6 +359,40 @@ public abstract class DatabaseType {
}
/**
+ * Executes the given SQL on the given connection. Use this method if you want to return the raw results
+ * for further processing. This is especially useful when used in conjunction with {@link SST_JavaTask}.
+ *
+ * @param conn the connection to the database that will execute the SQL
+ * @param sql the actual SQL to execute
+ *
+ * @throws SQLException
+ */
+ public List<Object[]> executeSelectSql(Connection conn, String sql) throws SQLException {
+ Statement ps = null;
+
+ try {
+ LOG.debug(DbUtilsI18NResourceKeys.EXECUTING_SQL, sql);
+ ps = conn.createStatement();
+
+ ResultSet resultSet = ps.executeQuery(sql);
+ ResultSetMetaData metadata = resultSet.getMetaData();
+
+ int numberColumns = metadata.getColumnCount();
+ List<Object[]> results = new ArrayList<Object[]>();
+ while (resultSet.next()) {
+ Object[] nextRow = new Object[numberColumns];
+ for (int i = 0; i < numberColumns; i++) {
+ nextRow[i] = resultSet.getObject(i + 1);
+ }
+ results.add(nextRow);
+ }
+ return results;
+ } finally {
+ closeStatement(ps);
+ }
+ }
+
+ /**
* Executes the given SQL on the given connection. Use this method if you don't care about what the results are, you
* just want to execute the SQL and know if it was successful or not.
*
diff --git a/modules/core/dbutils/src/main/java/org/rhq/core/db/ant/DbAntI18NResourceKeys.java b/modules/core/dbutils/src/main/java/org/rhq/core/db/ant/DbAntI18NResourceKeys.java
index c92d722..80061b8 100644
--- a/modules/core/dbutils/src/main/java/org/rhq/core/db/ant/DbAntI18NResourceKeys.java
+++ b/modules/core/dbutils/src/main/java/org/rhq/core/db/ant/DbAntI18NResourceKeys.java
@@ -202,6 +202,16 @@ public interface DbAntI18NResourceKeys {
@I18NMessage(value = "Konnte die Spalte nicht verändern. Grund: {0}", locale = "de") })
String ALTER_COLUMN_ERROR = "SchemaSpecTask.altercolumn.error";
+ @I18NMessages( {
+ @I18NMessage("Executing Java Task: class=[{0}]"),
+ @I18NMessage(value = "Führe die Java-Aufgabe: class=[{0}]", locale = "de") })
+ String JAVA_TASK_EXECUTING = "SchemaSpecTask.javaTask.executing";
+
+ @I18NMessages( {
+ @I18NMessage("Java Task Error: class=[{0}]"),
+ @I18NMessage(value = "Fehler beim Ausführen der Aufgabe [{0}]", locale = "de") })
+ String JAVA_TASK_ERROR = "SchemaSpecTask.javaTask.error";
+
@I18NMessages( { @I18NMessage("No 'jdbcUrl' attribute specified."),
@I18NMessage(value = "Es ist kein 'jdbcUrl' Attribut angegeben", locale = "de") })
String DBUPGRADE_NO_JDBC_URL = "DBUpgrader.no-jdbc-url";
diff --git a/modules/core/dbutils/src/main/java/org/rhq/core/db/ant/dbupgrade/SST_JavaTask.java b/modules/core/dbutils/src/main/java/org/rhq/core/db/ant/dbupgrade/SST_JavaTask.java
new file mode 100644
index 0000000..b083510
--- /dev/null
+++ b/modules/core/dbutils/src/main/java/org/rhq/core/db/ant/dbupgrade/SST_JavaTask.java
@@ -0,0 +1,101 @@
+/*
+ * 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.core.db.ant.dbupgrade;
+
+import java.sql.Connection;
+
+import mazz.i18n.Msg;
+
+import org.apache.tools.ant.BuildException;
+
+import org.rhq.core.db.DatabaseType;
+import org.rhq.core.db.ant.DbAntI18NFactory;
+import org.rhq.core.db.ant.DbAntI18NResourceKeys;
+import org.rhq.core.db.upgrade.DatabaseUpgradeTask;
+
+/**
+ * Task that allows more complicated upgrade logic to be externalized into a Java class. The JavaTask must implement
+ * the {@link DatabaseUpgradeTask} interface, which will pass the active {@link Connection} and {@link DatabaseType}
+ * objects used by the main upgrader to it. Authors of JavaTasks are encouraged to use the helper methods provided by
+ * the {@link DatabaseType} object, which will help keep the implementation vendor agnostic with respect to the set of
+ * databases supported by {@link DBUpgrader} at the time it was written.
+ *
+ * Ant task to invoke an external JavaTask, which can perform arbitrarily DDL and DML against the database. This task
+ * accepts one required attribute:
+ *
+ * <ul>
+ * <li>className</li>
+ * </ul>
+ *
+ * @author Joseph Marques
+ */
+public class SST_JavaTask extends SchemaSpecTask {
+ private static final Msg MSG = DbAntI18NFactory.getMsg();
+
+ private String className;
+
+ /**
+ * Sets the name of the class that implements the {@link DatabaseUpgradeTask} interface. If the name is not
+ * package-prefixed, the default "org.rhq.core.db.upgrade" will be assumed.
+ *
+ * @param className
+ */
+ public void setClassName(String className) {
+ this.className = className;
+ }
+
+ /**
+ * Launches the {@link DatabaseUpgradeTask} defined by the className attribute, passing the {@link Connection} and
+ * {@link DatabaseType} from the main {@link DBUpgrader}.
+ *
+ * @see org.apache.tools.ant.Task#execute()
+ */
+ public void execute() throws BuildException {
+ if (!isDBTargeted()) {
+ return;
+ }
+
+ validateAttributes();
+
+ try {
+ DatabaseType db_type = getDatabaseType();
+ Connection conn = getConnection();
+
+ if (className.indexOf(".") == -1) {
+ className = "org.rhq.core.db.upgrade." + className;
+ }
+
+ log(MSG.getMsg(DbAntI18NResourceKeys.JAVA_TASK_EXECUTING, className));
+
+ Class<?> javaTaskClass = Class.forName(className);
+ DatabaseUpgradeTask javaTask = (DatabaseUpgradeTask) javaTaskClass.newInstance();
+ javaTask.execute(conn, db_type);
+ } catch (Exception e) {
+ throw new BuildException(MSG.getMsg(DbAntI18NResourceKeys.JAVA_TASK_ERROR, e), e);
+ }
+ }
+
+ private void validateAttributes() throws BuildException {
+ if (className == null) {
+ throw new BuildException(MSG.getMsg(DbAntI18NResourceKeys.SCHEMA_SPEC_TASK_MISSING_CHILD_ELEMENT,
+ "JavaTask", "className"));
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/modules/core/dbutils/src/main/java/org/rhq/core/db/upgrade/DatabaseUpgradeTask.java b/modules/core/dbutils/src/main/java/org/rhq/core/db/upgrade/DatabaseUpgradeTask.java
new file mode 100644
index 0000000..fd438c0
--- /dev/null
+++ b/modules/core/dbutils/src/main/java/org/rhq/core/db/upgrade/DatabaseUpgradeTask.java
@@ -0,0 +1,34 @@
+/*
+ * 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.core.db.upgrade;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+
+import org.rhq.core.db.DatabaseType;
+import org.rhq.core.db.ant.dbupgrade.SST_JavaTask;
+
+/**
+ * Implement this interface if you wish to write database upgrade steps as {@link SST_JavaTask}s.
+ *
+ * @author Joseph Marques
+ */
+public interface DatabaseUpgradeTask {
+ public void execute(Connection connection, DatabaseType type) throws SQLException;
+}
diff --git a/modules/core/dbutils/src/main/resources/db-ant-tasks.properties b/modules/core/dbutils/src/main/resources/db-ant-tasks.properties
index 7a135d9..c5892a9 100644
--- a/modules/core/dbutils/src/main/resources/db-ant-tasks.properties
+++ b/modules/core/dbutils/src/main/resources/db-ant-tasks.properties
@@ -15,5 +15,6 @@ schema-alterColumn=org.rhq.core.db.ant.dbupgrade.SST_AlterColumn
schema-deleteColumn=org.rhq.core.db.ant.dbupgrade.SST_DeleteColumn
schema-dropTable=org.rhq.core.db.ant.dbupgrade.SST_DropTable
schema-directSQL=org.rhq.core.db.ant.dbupgrade.SST_DirectSQL
+schema-javaTask=org.rhq.core.db.ant.dbupgrade.SST_JavaTask
schema-createSequence=org.rhq.core.db.ant.dbupgrade.SST_CreateSequence
schema-dropSequence=org.rhq.core.db.ant.dbupgrade.SST_DropSequence
\ No newline at end of file
commit f7c53db7fa0085b412fcb9f462e2087726d8477c
Author: Joseph Marques <joseph(a)redhat.com>
Date: Wed Apr 21 16:20:59 2010 -0400
remove alert sender ordering, that feature has been removed from the release
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 8db8231..3098d97 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/alert-schema.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/alert-schema.xml
@@ -139,7 +139,6 @@
<column name="NOTIF_TEMPLATE_ID" required="false" type="INTEGER" references="RHQ_ALERT_NOTIF_TEMPL(ID)"/>
<column name="ALERT_CONFIG_ID" required="false" type="INTEGER" references="RHQ_CONFIG(ID)"/>
<column name="ALERT_SENDER_NAME" required="false" size="100" type="VARCHAR2" /> <!-- TODO make required = true -->
- <column name="ALERT_ORDER" type="INTEGER" />
<column name="NAME" type="VARCHAR2" size="100" />
</table>
14 years, 1 month
[rhq] Branch 'gwt' - modules/cli-tests modules/common modules/plugins
by ips
modules/cli-tests/src/test/resources/test-ant-bundle-v1.xml | 4
modules/cli-tests/src/test/resources/test-ant-bundle-v2.xml | 4
modules/common/ant-bundle/pom.xml | 6
modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/AntLauncher.java | 13
modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/task/BundleTask.java | 2
modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/task/InstallSystemServiceTask.java | 333 ++++++++++
modules/common/ant-bundle/src/main/resources/org/rhq/bundle/antlib.xml | 4
modules/common/ant-bundle/src/test/java/org/rhq/bundle/ant/AntLauncherTest.java | 8
modules/common/ant-bundle/src/test/resources/foo-config | 3
modules/common/ant-bundle/src/test/resources/foo-script | 24
modules/common/ant-bundle/src/test/resources/test-bundle-v1.xml | 9
modules/common/ant-bundle/src/test/resources/test-bundle-v2.xml | 2
modules/plugins/ant-bundle/src/test/resources/test-build.xml | 4
13 files changed, 398 insertions(+), 18 deletions(-)
New commits:
commit a40874a5be03f72f9099b6e8a3215083d24b512b
Author: Ian P. Springer <ips(a)jetengine.(none)>
Date: Wed Apr 28 15:33:02 2010 -0400
add a new rhq:install-system-service task for installing Unix init scripts (currently only supports RH Linux); rename rhq:inputProperty task to rhq-input-property to follow our task naming convention
diff --git a/modules/cli-tests/src/test/resources/test-ant-bundle-v1.xml b/modules/cli-tests/src/test/resources/test-ant-bundle-v1.xml
index ce580b6..e874c63 100644
--- a/modules/cli-tests/src/test/resources/test-ant-bundle-v1.xml
+++ b/modules/cli-tests/src/test/resources/test-ant-bundle-v1.xml
@@ -4,13 +4,13 @@
<rhq:bundle name="example.com (JBoss EAP 4.3)" version="1.0"
description="example.com corporate website hosted on JBoss EAP 4.3"/>
- <rhq:inputProperty
+ <rhq:input-property
name="http.port"
description="the HTTP port the JBoss EAP server should listen on"
required="true"
type="integer"/>
- <rhq:inputProperty
+ <rhq:input-property
name="https.port"
description="the HTTPS port the JBoss EAP server should listen on"
required="true"
diff --git a/modules/cli-tests/src/test/resources/test-ant-bundle-v2.xml b/modules/cli-tests/src/test/resources/test-ant-bundle-v2.xml
index db23396..b825a0f 100644
--- a/modules/cli-tests/src/test/resources/test-ant-bundle-v2.xml
+++ b/modules/cli-tests/src/test/resources/test-ant-bundle-v2.xml
@@ -4,13 +4,13 @@
<rhq:bundle name="example.com (JBoss EAP 4.3)" version="2.0"
description="example.com corporate website hosted on JBoss EAP 4.3"/>
- <rhq:inputProperty
+ <rhq:input-property
name="http.port"
description="the HTTP port the JBoss EAP server should listen on"
required="true"
type="integer"/>
- <rhq:inputProperty
+ <rhq:input-property
name="https.port"
description="the HTTPS port the JBoss EAP server should listen on"
required="true"
diff --git a/modules/common/ant-bundle/pom.xml b/modules/common/ant-bundle/pom.xml
index 6349d81..d7b9e91 100644
--- a/modules/common/ant-bundle/pom.xml
+++ b/modules/common/ant-bundle/pom.xml
@@ -74,6 +74,12 @@
<version>1.8.0</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.ant</groupId>
+ <artifactId>ant-nodeps</artifactId>
+ <version>1.8.0</version>
+ </dependency>
+
<!-- include some optional ant tasks for users to be able to use -->
<dependency>
<groupId>ant-contrib</groupId>
diff --git a/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/AntLauncher.java b/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/AntLauncher.java
index b29e5e9..e8391b7 100644
--- a/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/AntLauncher.java
+++ b/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/AntLauncher.java
@@ -43,6 +43,8 @@ import org.rhq.bundle.ant.task.InputPropertyTask;
* @author Ian Springer
*/
public class AntLauncher {
+ private final Log log = LogFactory.getLog(this.getClass());
+
// "out of box" we will provide the ant contrib optional tasks (from ant-contrib.jar)
private static final String ANTCONTRIB_ANT_TASKS = "net/sf/antcontrib/antcontrib.properties";
@@ -52,7 +54,10 @@ public class AntLauncher {
// private constant ProjectHelper2.REFID_CONTEXT value
private static final String REFID_CONTEXT = "ant.parsing.context";
- private final Log log = LogFactory.getLog(AntLauncher.class);
+ // TODO (ips, 04/28/10): Figure out a way to avoid assuming the prefix is "rhq".
+ private static final String BUNDLE_TASK_NAME = "rhq:bundle";
+ private static final String INPUT_PROPERTY_TASK_NAME = "rhq:input-property";
+ private static final String DEPLOY_TASK_NAME = "rhq:deploy";
/**
* Executes the specified bundle deploy Ant build file (i.e. rhq-deploy.xml).
@@ -190,14 +195,14 @@ public class AntLauncher {
Task[] tasks = target.getTasks();
for (Task task : tasks) {
// NOTE: For rhq:inputProperty tasks, the below call will add propDefs to the project configDef.
- if (task.getTaskName().equals("rhq:bundle")) {
+ if (task.getTaskName().equals(BUNDLE_TASK_NAME)) {
abortIfTaskWithinTarget(target, task);
bundleTaskCount++;
unconfiguredBundleTask = task;
- } else if (task.getTaskName().equals("rhq:inputProperty")) {
+ } else if (task.getTaskName().equals(INPUT_PROPERTY_TASK_NAME)) {
abortIfTaskWithinTarget(target, task);
InputPropertyTask inputPropertyTask = (InputPropertyTask) preconfigureTask(task);
- } else if (task.getTaskName().equals("rhq:deploy")) {
+ } else if (task.getTaskName().equals(DEPLOY_TASK_NAME)) {
DeployTask deployTask = (DeployTask) preconfigureTask(task);
Map<File, File> files = deployTask.getFiles();
for (File file : files.values()) {
diff --git a/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/task/BundleTask.java b/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/task/BundleTask.java
index 3d863ab..61d8898 100644
--- a/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/task/BundleTask.java
+++ b/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/task/BundleTask.java
@@ -28,7 +28,7 @@ import java.util.Hashtable;
/**
* @author Ian Springer
*/
-public class BundleTask extends AbstractBundleTask {
+public class BundleTask extends AbstractBundleTask {
private String name;
private String version;
private String description;
diff --git a/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/task/InstallSystemServiceTask.java b/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/task/InstallSystemServiceTask.java
new file mode 100644
index 0000000..828c39d
--- /dev/null
+++ b/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/task/InstallSystemServiceTask.java
@@ -0,0 +1,333 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2010 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.bundle.ant.task;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.taskdefs.Chmod;
+import org.apache.tools.ant.taskdefs.Copy;
+import org.apache.tools.ant.taskdefs.optional.unix.Symlink;
+
+import java.io.File;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.TreeSet;
+
+/**
+ * An Ant task that installs a system startup/shutdown service. Currently only Red Hat Linux versions are supported.
+ *
+ * @author Ian Springer
+ */
+public class InstallSystemServiceTask extends Task {
+ private static final String OS_NAME = System.getProperty("os.name");
+ private static final File REDHAT_RELEASE_FILE = new File("/etc/redhat-release");
+ private static final Set<Character> REDHAT_RUN_LEVELS = new HashSet<Character>();
+ static {
+ for (char c = '0'; c <= '6'; c++) {
+ REDHAT_RUN_LEVELS.add(c);
+ }
+ // TODO: Add 's' and/or 'S' depending on the flavor of UNIX.
+ }
+ private static final File INIT_DIR = new File("/etc/init.d");
+ private static final File SYSCONFIG_DIR = new File("/etc/sysconfig");
+ private static final File DEFAULT_ROOT = new File("/");
+
+ private String name;
+ private File scriptFile;
+ private File configFile;
+ private boolean overwriteScript;
+ private boolean overwriteConfig;
+ private boolean overwriteLinks = true;
+ private File root = DEFAULT_ROOT;
+ private String startLevels;
+
+ /**
+ * An integer from 0-99 indicating the service's start order - services with a lower priority number are started
+ * before services with a higher priority number.
+ */
+ private Byte startPriority;
+
+ /**
+ * An integer from 0-99 indicating the service's stop order - services with a lower priority number are stopped
+ * before services with a higher priority number.
+ */
+ private Byte stopPriority;
+
+ private Set<Character> startLevelChars;
+ private Set<Character> stopLevelChars;
+
+ @Override
+ public void execute() throws BuildException {
+ if (!OS_NAME.equals("Linux") || !REDHAT_RELEASE_FILE.exists() ) {
+ throw new BuildException("This task can only be run on Red Hat Linux systems.");
+ }
+ validateAttributes();
+
+ // Install the config file if one was provided (e.g. /etc/sysconfig/named).
+ if (this.configFile != null) {
+ File sysconfigDir = new File(this.root, SYSCONFIG_DIR.getPath().substring(1));
+ if (!sysconfigDir.exists()) {
+ sysconfigDir.mkdirs();
+ }
+ if (!sysconfigDir.canWrite()) {
+ throw new BuildException(sysconfigDir + " directory is not writeable.");
+ }
+ File configDestFile = new File(sysconfigDir, this.name);
+ copyFile(this.configFile, configDestFile, this.overwriteConfig);
+ setPermissions(configDestFile, "644");
+ }
+
+ // Install the script itself (e.g. /etc/init.d/named).
+ File initDir = new File(this.root, INIT_DIR.getPath().substring(1));
+ if (!initDir.exists()) {
+ initDir.mkdirs();
+ }
+ if (!initDir.canWrite()) {
+ throw new BuildException(initDir + " directory is not writeable.");
+ }
+ File scriptDestFile = new File(initDir, this.name);
+ getProject().log("Installing service script " + scriptDestFile + "...");
+ copyFile(this.scriptFile, scriptDestFile, this.overwriteScript);
+ setPermissions(scriptDestFile, "755");
+
+ // Create the symlinks in the rcX.d dirs (e.g. /etc/rc3.d/S24named -> ../init.d/named)
+ createScriptSymlinks(scriptDestFile, this.startPriority, this.startLevelChars, 'S');
+ createScriptSymlinks(scriptDestFile, this.stopPriority, this.stopLevelChars, 'K');
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public File getScriptFile() {
+ return scriptFile;
+ }
+
+ public void setScriptFile(File scriptFile) {
+ this.scriptFile = scriptFile;
+ }
+
+ public File getConfigFile() {
+ return configFile;
+ }
+
+ public void setConfigFile(File configFile) {
+ this.configFile = configFile;
+ }
+
+ public boolean isOverwriteScript() {
+ return overwriteScript;
+ }
+
+ public void setOverwriteScript(boolean overwriteScript) {
+ this.overwriteScript = overwriteScript;
+ }
+
+ public boolean isOverwriteConfig() {
+ return overwriteConfig;
+ }
+
+ public void setOverwriteConfig(boolean overwriteConfig) {
+ this.overwriteConfig = overwriteConfig;
+ }
+
+ public boolean isOverwriteLinks() {
+ return overwriteLinks;
+ }
+
+ public void setOverwriteLinks(boolean overwriteLinks) {
+ this.overwriteLinks = overwriteLinks;
+ }
+
+ public String getStartLevels() {
+ return startLevels;
+ }
+
+ public void setStartLevels(String startLevels) {
+ this.startLevels = startLevels;
+ }
+
+ public byte getStartPriority() {
+ return startPriority;
+ }
+
+ public void setStartPriority(byte startPriority) {
+ this.startPriority = startPriority;
+ }
+
+ public byte getStopPriority() {
+ return stopPriority;
+ }
+
+ public void setStopPriority(byte stopPriority) {
+ this.stopPriority = stopPriority;
+ }
+
+ public File getRoot() {
+ return root;
+ }
+
+ public void setRoot(File root) {
+ this.root = root;
+ }
+
+ /**
+ * Ensure we have a consistent and legal set of attributes, and set
+ * any internal flags necessary based on different combinations
+ * of attributes.
+ *
+ * @throws BuildException if an error occurs
+ */
+ protected void validateAttributes() throws BuildException {
+ if (this.name == null) {
+ throw new BuildException("The 'name' attribute is required.");
+ }
+ if (this.name.length() == 0) {
+ throw new BuildException("The 'name' attribute must have a non-empty value.");
+ }
+
+ if (this.scriptFile == null) {
+ throw new BuildException("The 'scriptFile' attribute is required.");
+ }
+ if (!this.scriptFile.exists() || this.scriptFile.isDirectory()) {
+ throw new BuildException("The 'scriptFile' attribute must be set to the path of an existing regular file.");
+ }
+ if (!this.configFile.exists() || this.configFile.isDirectory()) {
+ throw new BuildException("The 'configFile' attribute must be set to the path of an existing regular file.");
+ }
+
+ if (this.startLevels == null) {
+ throw new BuildException("The 'startLevels' attribute is required.");
+ }
+ if (this.startLevels.length() == 0) {
+ throw new BuildException("The 'startLevels' attribute must have a non-empty value.");
+ }
+ this.startLevelChars = parseLevels(this.startLevels);
+ this.stopLevelChars = new TreeSet<Character>();
+ for (char level : REDHAT_RUN_LEVELS) {
+ if (!this.startLevelChars.contains(level)) {
+ this.stopLevelChars.add(level);
+ }
+ }
+
+ if (this.startPriority == null) {
+ throw new BuildException("The 'startPriority' attribute is required.");
+ }
+ if (this.startPriority < 0 || this.startPriority > 99) {
+ throw new BuildException("The 'startPriority' attribute must be >=0 and <= 99.");
+ }
+ if (this.stopPriority == null) {
+ throw new BuildException("The 'stopPriority' attribute is required.");
+ }
+ if (this.stopPriority < 0 || this.stopPriority > 99) {
+ throw new BuildException("The 'startPriority' attribute must be >=0 and <= 99.");
+ }
+
+ if (!this.root.isDirectory()) {
+ throw new BuildException("The 'root' attribute must be set to the path of an existing directory.");
+ }
+ if (!this.root.equals(DEFAULT_ROOT)) {
+ getProject().log("Using root " + this.root + ".");
+ }
+ }
+
+ private static Set<Character> parseLevels(String levels) {
+ Set<Character> levelChars = new TreeSet<Character>();
+ String[] tokens = levels.split("[ ]*,[ ]*");
+ for (String token : tokens) {
+ if (!token.equals("")) {
+ Character level;
+ try {
+ if (token.length() != 1) {
+ throw new Exception();
+ }
+ level = token.charAt(0);
+ if (!REDHAT_RUN_LEVELS.contains(level)) {
+ throw new Exception();
+ }
+
+ } catch (Exception e) {
+ throw new BuildException("Invalid run level: " + token
+ + " - the 'startLevels' attribute must be a comma-separated list of run levels - the valid levels are "
+ + REDHAT_RUN_LEVELS + ".");
+ }
+ if (levelChars.contains(level)) {
+ throw new BuildException("The 'startLevels' attribute defines run level " + level + " more than once.");
+ }
+ levelChars.add(level);
+ }
+ }
+ return levelChars;
+ }
+
+ private void createScriptSymlinks(File scriptFile, byte priority, Set<Character> levels, char fileNamePrefix) {
+ String priorityString = String.format("%02d", priority);
+ for (char level : levels) {
+ File rcDir = new File(this.root, "etc/rc" + level + ".d");
+ if (!rcDir.exists()) {
+ rcDir.mkdirs();
+ }
+ if (!rcDir.exists()) {
+ throw new BuildException(rcDir + " does not exist.");
+ }
+ if (!rcDir.isDirectory()) {
+ throw new BuildException(rcDir + " exists but is not a directory.");
+ }
+ if (!rcDir.isDirectory()) {
+ throw new BuildException(rcDir + " directory is not writeable.");
+ }
+ File link = new File(rcDir, fileNamePrefix + priorityString + this.name);
+ getProject().log("Creating symbolic link " + link + " referencing " + scriptFile + "...");
+
+ createSymlink(scriptFile, link, this.overwriteLinks);
+ }
+ }
+
+ private void copyFile(File sourceFile, File destFile, boolean overwrite) {
+ Copy copyTask = new Copy();
+ copyTask.setProject(getProject());
+ copyTask.init();
+ copyTask.setFile(sourceFile);
+ copyTask.setTofile(destFile);
+ copyTask.setOverwrite(overwrite);
+ copyTask.execute();
+ }
+
+ private void createSymlink(File targetFile, File linkFile, boolean overwrite) {
+ Symlink symlinkTask = new Symlink();
+ symlinkTask.setProject(getProject());
+ symlinkTask.init();
+ symlinkTask.setResource(targetFile.getAbsolutePath());
+ symlinkTask.setLink(linkFile.getAbsolutePath());
+ symlinkTask.setOverwrite(overwrite);
+ symlinkTask.execute();
+ }
+
+ private void setPermissions(File file, String perms) {
+ Chmod chmodTask = new Chmod();
+ chmodTask.setProject(getProject());
+ chmodTask.init();
+ chmodTask.setFile(file);
+ chmodTask.setPerm(perms);
+ chmodTask.execute();
+ }
+}
diff --git a/modules/common/ant-bundle/src/main/resources/org/rhq/bundle/antlib.xml b/modules/common/ant-bundle/src/main/resources/org/rhq/bundle/antlib.xml
index 0a552d2..b522491 100644
--- a/modules/common/ant-bundle/src/main/resources/org/rhq/bundle/antlib.xml
+++ b/modules/common/ant-bundle/src/main/resources/org/rhq/bundle/antlib.xml
@@ -7,7 +7,7 @@
<taskdef name="bundle" classname="org.rhq.bundle.ant.task.BundleTask"/>
<!-- inputProperty task -->
- <taskdef name="inputProperty" classname="org.rhq.bundle.ant.task.InputPropertyTask"/>
+ <taskdef name="input-property" classname="org.rhq.bundle.ant.task.InputPropertyTask"/>
<!-- deploy task and its child types -->
<taskdef name="deploy" classname="org.rhq.bundle.ant.task.DeployTask"/>
@@ -18,4 +18,6 @@
<typedef name="ignore" classname="org.rhq.bundle.ant.type.IgnoreType"/>
<typedef name="fileset" classname="org.rhq.bundle.ant.type.FileSet"/>
+ <!-- install-system-service task -->
+ <taskdef name="install-system-service" classname="org.rhq.bundle.ant.task.InstallSystemServiceTask"/>
</antlib>
diff --git a/modules/common/ant-bundle/src/test/java/org/rhq/bundle/ant/AntLauncherTest.java b/modules/common/ant-bundle/src/test/java/org/rhq/bundle/ant/AntLauncherTest.java
index 7235815..d5802e9 100644
--- a/modules/common/ant-bundle/src/test/java/org/rhq/bundle/ant/AntLauncherTest.java
+++ b/modules/common/ant-bundle/src/test/java/org/rhq/bundle/ant/AntLauncherTest.java
@@ -60,8 +60,10 @@ public class AntLauncherTest {
assert bundleFiles.get("pkg").equals("package.zip") : bundleFiles;*/
ConfigurationDefinition configDef = project.getConfigurationDefinition();
- assert configDef.getPropertyDefinitions().size() == 1;
- assert configDef.getPropertyDefinitionSimple("listener.port") != null;
+ assert configDef.getPropertyDefinitions().size() == 1 : configDef.getPropertyDefinitions();
+ PropertyDefinitionSimple propDef = configDef.getPropertyDefinitionSimple("listener.port");
+ assert propDef != null;
+ assert propDef.getType() == PropertySimpleType.INTEGER;
}
public void testInstall() throws Exception {
@@ -81,7 +83,7 @@ public class AntLauncherTest {
assert bundleFiles.get("pkg").equals("package.zip") : bundleFiles;*/
ConfigurationDefinition configDef = project.getConfigurationDefinition();
- assert configDef.getPropertyDefinitions().size() == 1;
+ assert configDef.getPropertyDefinitions().size() == 1 : configDef.getPropertyDefinitions();
PropertyDefinitionSimple propDef = configDef.getPropertyDefinitionSimple("listener.port");
assert propDef != null;
assert propDef.getType() == PropertySimpleType.INTEGER;
diff --git a/modules/common/ant-bundle/src/test/resources/foo-config b/modules/common/ant-bundle/src/test/resources/foo-config
new file mode 100644
index 0000000..a5343be
--- /dev/null
+++ b/modules/common/ant-bundle/src/test/resources/foo-config
@@ -0,0 +1,3 @@
+# sysconfig file for foo init script
+
+FOO=1
diff --git a/modules/common/ant-bundle/src/test/resources/foo-script b/modules/common/ant-bundle/src/test/resources/foo-script
new file mode 100644
index 0000000..909ff79
--- /dev/null
+++ b/modules/common/ant-bundle/src/test/resources/foo-script
@@ -0,0 +1,24 @@
+#! /bin/bash
+
+# a sample init script
+
+# Set config defaults.
+FOO=0
+
+# Source config if it exists.
+NAME=`basename $0`
+CONFIG=/etc/sysconfig/$NAME
+[ -f "$CONFIG" ] && . "$CONFIG"
+
+case "$1" in
+ *start)
+ echo "Starting foo (FOO=$FOO)..."
+ ;;
+ *stop)
+ echo "Stopping foo (FOO=$FOO)..."
+ ;;
+ *)
+ echo "Usage: $NAME {start|stop}" >&2
+ exit 1
+ ;;
+esac
diff --git a/modules/common/ant-bundle/src/test/resources/test-bundle-v1.xml b/modules/common/ant-bundle/src/test/resources/test-bundle-v1.xml
index b5349c9..cf2c019 100644
--- a/modules/common/ant-bundle/src/test/resources/test-bundle-v1.xml
+++ b/modules/common/ant-bundle/src/test/resources/test-bundle-v1.xml
@@ -5,7 +5,7 @@
<rhq:bundle name="example.com (JBoss EAP 4.3)" version="1.0"
description="example.com corporate website hosted on JBoss EAP 4.3"/>
- <rhq:inputProperty
+ <rhq:input-property
name="listener.port"
description="This is where the product will listen for incoming messages"
required="true"
@@ -14,6 +14,7 @@
<target name="deploy">
<echo>Deploying Test Bundle v1.0 to ${rhq.deploy.dir}...</echo>
+
<rhq:deploy>
<rhq:file name="test-v1.properties" destinationFile="subdir/test.properties"/>
<rhq:archive name="file.zip"/>
@@ -23,7 +24,11 @@
<rhq:ignore>
<rhq:fileset includes="*.log"/>
</rhq:ignore>
- </rhq:deploy>
+ </rhq:deploy>
+
+ <mkdir dir="root"/>
+ <rhq:install-system-service name="foo" scriptFile="foo-script" configFile="foo-config" overwriteScript="true"
+ startLevels="3,4,5" startPriority="80" stopPriority="20" root="root"/>
</target>
</project>
\ No newline at end of file
diff --git a/modules/common/ant-bundle/src/test/resources/test-bundle-v2.xml b/modules/common/ant-bundle/src/test/resources/test-bundle-v2.xml
index 4c522f6..fd7ed44 100644
--- a/modules/common/ant-bundle/src/test/resources/test-bundle-v2.xml
+++ b/modules/common/ant-bundle/src/test/resources/test-bundle-v2.xml
@@ -5,7 +5,7 @@
<rhq:bundle name="example.com (JBoss EAP 4.3)" version="2.0"
description="example.com corporate website hosted on JBoss EAP 4.3"/>
- <rhq:inputProperty
+ <rhq:input-property
name="listener.port"
description="This is where the product will listen for incoming messages"
required="true"
diff --git a/modules/plugins/ant-bundle/src/test/resources/test-build.xml b/modules/plugins/ant-bundle/src/test/resources/test-build.xml
index 30a35f9..e4e062b 100644
--- a/modules/plugins/ant-bundle/src/test/resources/test-build.xml
+++ b/modules/plugins/ant-bundle/src/test/resources/test-build.xml
@@ -8,13 +8,13 @@
<rhq:bundle name="example.com (JBoss EAP 4.3)" version="1.0"
description="example.com corporate website hosted on JBoss EAP 4.3"/>
- <rhq:inputProperty
+ <rhq:input-property
name="custom.prop1"
description="my prop 1"
required="true"
defaultValue="default 1"/>
- <rhq:inputProperty
+ <rhq:input-property
name="custom.prop2"
description="my prop 2"
required="true"
14 years, 1 month
[rhq] Branch 'gwt' - etc/classloaders-test etc/rhq-plugin-archetype etc/samples modules/core modules/enterprise modules/plugins pom.xml
by ips
etc/classloaders-test/plugin1/pom.xml | 6 ++++++
etc/classloaders-test/plugin2/pom.xml | 6 ++++++
etc/rhq-plugin-archetype/src/main/resources/archetype-resources/pom.xml | 6 ++++++
etc/samples/custom-serverplugin/pom.xml | 6 ++++++
etc/samples/simplereport-serverplugin/pom.xml | 6 ++++++
etc/samples/skeleton-plugin/pom.xml | 6 ++++++
modules/core/client-api/pom.xml | 8 +++++++-
modules/core/domain/pom.xml | 8 +++++++-
modules/core/gui/pom.xml | 3 +++
modules/core/plugin-api/pom.xml | 8 +++++++-
modules/core/plugin-container/pom.xml | 6 ++++++
modules/enterprise/gui/base-perspective-jar/pom.xml | 3 +++
modules/enterprise/gui/coregui/pom.xml | 6 ++++++
modules/enterprise/gui/installer-war/pom.xml | 3 +++
modules/enterprise/gui/portal-war/pom.xml | 7 +++++--
modules/enterprise/gui/webdav-war/pom.xml | 3 +++
modules/enterprise/server/container/pom.xml | 6 ++++++
modules/enterprise/server/xml-schemas/pom.xml | 6 ++++++
modules/plugins/raw-config-test/pom.xml | 8 ++++++--
pom.xml | 5 +++++
20 files changed, 109 insertions(+), 7 deletions(-)
New commits:
commit 8fc73ce8dd4a67febe733af860c52bb6602bbc56
Author: Ian P. Springer <ips(a)jetengine.(none)>
Date: Wed Apr 28 15:13:20 2010 -0400
explicitly disable snapshots in all repository pom elements
diff --git a/etc/classloaders-test/plugin1/pom.xml b/etc/classloaders-test/plugin1/pom.xml
index 4a22a3f..405b9e7 100644
--- a/etc/classloaders-test/plugin1/pom.xml
+++ b/etc/classloaders-test/plugin1/pom.xml
@@ -229,6 +229,9 @@
<id>jboss</id>
<name>JBoss Repository</name>
<url>http://repository.jboss.org/maven2/</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
</repository>
</repositories>
@@ -237,6 +240,9 @@
<id>jboss</id>
<name>JBoss Plugin Repository</name>
<url>http://repository.jboss.org/maven2/</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
</pluginRepository>
</pluginRepositories>
diff --git a/etc/classloaders-test/plugin2/pom.xml b/etc/classloaders-test/plugin2/pom.xml
index e7d8317..8a79746 100644
--- a/etc/classloaders-test/plugin2/pom.xml
+++ b/etc/classloaders-test/plugin2/pom.xml
@@ -229,6 +229,9 @@
<id>jboss</id>
<name>JBoss Repository</name>
<url>http://repository.jboss.org/maven2/</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
</repository>
</repositories>
@@ -237,6 +240,9 @@
<id>jboss</id>
<name>JBoss Plugin Repository</name>
<url>http://repository.jboss.org/maven2/</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
</pluginRepository>
</pluginRepositories>
diff --git a/etc/rhq-plugin-archetype/src/main/resources/archetype-resources/pom.xml b/etc/rhq-plugin-archetype/src/main/resources/archetype-resources/pom.xml
index e28af52..4600423 100644
--- a/etc/rhq-plugin-archetype/src/main/resources/archetype-resources/pom.xml
+++ b/etc/rhq-plugin-archetype/src/main/resources/archetype-resources/pom.xml
@@ -168,6 +168,9 @@
<id>jboss</id>
<name>JBoss Repository</name>
<url>http://repository.jboss.org/maven2/</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
</repository>
</repositories>
@@ -176,6 +179,9 @@
<id>jboss</id>
<name>JBoss Plugin Repository</name>
<url>http://repository.jboss.org/maven2/</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
</pluginRepository>
</pluginRepositories>
diff --git a/etc/samples/custom-serverplugin/pom.xml b/etc/samples/custom-serverplugin/pom.xml
index 1a6df22..e1f3a15 100644
--- a/etc/samples/custom-serverplugin/pom.xml
+++ b/etc/samples/custom-serverplugin/pom.xml
@@ -138,6 +138,9 @@
<id>jboss</id>
<name>JBoss Repository</name>
<url>http://repository.jboss.org/maven2/</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
</repository>
</repositories>
@@ -146,6 +149,9 @@
<id>jboss</id>
<name>JBoss Plugin Repository</name>
<url>http://repository.jboss.org/maven2/</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
</pluginRepository>
</pluginRepositories>
diff --git a/etc/samples/simplereport-serverplugin/pom.xml b/etc/samples/simplereport-serverplugin/pom.xml
index 18f8c43..b92068d 100644
--- a/etc/samples/simplereport-serverplugin/pom.xml
+++ b/etc/samples/simplereport-serverplugin/pom.xml
@@ -138,6 +138,9 @@
<id>jboss</id>
<name>JBoss Repository</name>
<url>http://repository.jboss.org/maven2/</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
</repository>
</repositories>
@@ -146,6 +149,9 @@
<id>jboss</id>
<name>JBoss Plugin Repository</name>
<url>http://repository.jboss.org/maven2/</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
</pluginRepository>
</pluginRepositories>
diff --git a/etc/samples/skeleton-plugin/pom.xml b/etc/samples/skeleton-plugin/pom.xml
index 0b32d6a..e1be2c1 100644
--- a/etc/samples/skeleton-plugin/pom.xml
+++ b/etc/samples/skeleton-plugin/pom.xml
@@ -230,6 +230,9 @@
<id>jboss</id>
<name>JBoss Repository</name>
<url>http://repository.jboss.org/maven2/</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
</repository>
</repositories>
@@ -238,6 +241,9 @@
<id>jboss</id>
<name>JBoss Plugin Repository</name>
<url>http://repository.jboss.org/maven2/</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
</pluginRepository>
</pluginRepositories>
diff --git a/modules/core/client-api/pom.xml b/modules/core/client-api/pom.xml
index df2ae07..d177f9e 100644
--- a/modules/core/client-api/pom.xml
+++ b/modules/core/client-api/pom.xml
@@ -118,6 +118,9 @@
<name>java.net Maven Repository</name>
<url>http://download.java.net/maven/1/</url>
<layout>legacy</layout>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
</pluginRepository>
</pluginRepositories>
@@ -127,6 +130,9 @@
<name>java.net Maven Repository</name>
<url>http://download.java.net/maven/1/</url>
<layout>legacy</layout>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
</repository>
</repositories>
@@ -189,4 +195,4 @@
</profiles>
-</project>
\ No newline at end of file
+</project>
diff --git a/modules/core/domain/pom.xml b/modules/core/domain/pom.xml
index 5f9b183..266492d 100644
--- a/modules/core/domain/pom.xml
+++ b/modules/core/domain/pom.xml
@@ -410,12 +410,18 @@
<id>jboss-deprecated-repository</id>
<name>JBoss Deprecated Maven Repository</name>
<url>https://repository.jboss.org/nexus/content/repositories/deprecated/</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
</repository>
<repository>
<id>codehaus</id>
- <name>codehaus</name>
+ <name>Codehaus Releases</name>
<url>http://repository.codehaus.org/</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
</repository>
</repositories>
diff --git a/modules/core/gui/pom.xml b/modules/core/gui/pom.xml
index 9890665..0911918 100644
--- a/modules/core/gui/pom.xml
+++ b/modules/core/gui/pom.xml
@@ -154,6 +154,9 @@
<name>Java.net Maven1 Repository - for javax.faces, javax.el, com.sun.el, and com.sun.facelets releases</name>
<url>http://download.java.net/maven/1/</url>
<layout>legacy</layout>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
</repository>
</repositories>
diff --git a/modules/core/plugin-api/pom.xml b/modules/core/plugin-api/pom.xml
index aa65b2a..e1ce7ef 100644
--- a/modules/core/plugin-api/pom.xml
+++ b/modules/core/plugin-api/pom.xml
@@ -80,6 +80,9 @@
<name>java.net Maven Repository</name>
<url>http://download.java.net/maven/1/</url>
<layout>legacy</layout>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
</pluginRepository>
</pluginRepositories>
@@ -89,7 +92,10 @@
<name>java.net Maven Repository</name>
<url>http://download.java.net/maven/1/</url>
<layout>legacy</layout>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
</repository>
</repositories>
-</project>
\ No newline at end of file
+</project>
diff --git a/modules/core/plugin-container/pom.xml b/modules/core/plugin-container/pom.xml
index 32abd55..197ef69 100644
--- a/modules/core/plugin-container/pom.xml
+++ b/modules/core/plugin-container/pom.xml
@@ -179,6 +179,9 @@
<name>java.net Maven Repository</name>
<url>http://download.java.net/maven/1/</url>
<layout>legacy</layout>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
</pluginRepository>
</pluginRepositories>
@@ -188,6 +191,9 @@
<name>java.net Maven Repository</name>
<url>http://download.java.net/maven/1/</url>
<layout>legacy</layout>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
</repository>
</repositories>
diff --git a/modules/enterprise/gui/base-perspective-jar/pom.xml b/modules/enterprise/gui/base-perspective-jar/pom.xml
index 6514b7b..91a5440 100644
--- a/modules/enterprise/gui/base-perspective-jar/pom.xml
+++ b/modules/enterprise/gui/base-perspective-jar/pom.xml
@@ -193,6 +193,9 @@
<name>Java.net Maven1 Repository - for javax.faces, javax.el, com.sun.el, and com.sun.facelets releases</name>
<url>http://download.java.net/maven/1/</url>
<layout>legacy</layout>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
</repository>
</repositories>
diff --git a/modules/enterprise/gui/coregui/pom.xml b/modules/enterprise/gui/coregui/pom.xml
index 73b2823..3c87ff0 100644
--- a/modules/enterprise/gui/coregui/pom.xml
+++ b/modules/enterprise/gui/coregui/pom.xml
@@ -400,12 +400,18 @@
<id>smartgwt</id>
<name>SmartGWT Releases</name>
<url>http://www.smartclient.com/maven2/</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
</repository>
<repository>
<id>codehaus</id>
<name>Codehaus Releases</name>
<url>http://repository.codehaus.org/</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
</repository>
</repositories>
diff --git a/modules/enterprise/gui/installer-war/pom.xml b/modules/enterprise/gui/installer-war/pom.xml
index b500fb1..dcb1f88 100644
--- a/modules/enterprise/gui/installer-war/pom.xml
+++ b/modules/enterprise/gui/installer-war/pom.xml
@@ -301,6 +301,9 @@
<name>Java.net Maven1 Repository - for javax.faces, javax.el, com.sun.el, and com.sun.facelets releases</name>
<url>http://download.java.net/maven/1/</url>
<layout>legacy</layout>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
</repository>
</repositories>
diff --git a/modules/enterprise/gui/portal-war/pom.xml b/modules/enterprise/gui/portal-war/pom.xml
index 6a8c7ad..f461b8e 100644
--- a/modules/enterprise/gui/portal-war/pom.xml
+++ b/modules/enterprise/gui/portal-war/pom.xml
@@ -598,9 +598,12 @@
<url>https://repository.jboss.org/nexus/content/repositories/deprecated/</url>
<layout>default</layout>
<releases>
- <enabled>true</enabled>
- <updatePolicy>never</updatePolicy>
+ <enabled>true</enabled>
+ <updatePolicy>never</updatePolicy>
</releases>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
</repository>
</repositories>
diff --git a/modules/enterprise/gui/webdav-war/pom.xml b/modules/enterprise/gui/webdav-war/pom.xml
index ac493e8..aa880be 100644
--- a/modules/enterprise/gui/webdav-war/pom.xml
+++ b/modules/enterprise/gui/webdav-war/pom.xml
@@ -287,6 +287,9 @@
<repository>
<id>ettrema</id>
<url>http://www.ettrema.com/maven2</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
</repository>
</repositories>
diff --git a/modules/enterprise/server/container/pom.xml b/modules/enterprise/server/container/pom.xml
index e92bf98..6b296df 100644
--- a/modules/enterprise/server/container/pom.xml
+++ b/modules/enterprise/server/container/pom.xml
@@ -272,6 +272,9 @@
<name>Java.net Maven1 Repository</name>
<url>http://download.java.net/maven/1/</url>
<layout>legacy</layout>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
</repository>
<!-- for javax.el and com.sun.el dependencies -->
@@ -279,6 +282,9 @@
<id>java.net-m2-releases</id>
<name>Java.net Maven2 Repository</name>
<url>http://download.java.net/maven/2/</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
</repository>
</repositories>
diff --git a/modules/enterprise/server/xml-schemas/pom.xml b/modules/enterprise/server/xml-schemas/pom.xml
index 9d2ab8a..14738d0 100644
--- a/modules/enterprise/server/xml-schemas/pom.xml
+++ b/modules/enterprise/server/xml-schemas/pom.xml
@@ -153,6 +153,9 @@
<name>java.net Maven Repository</name>
<url>http://download.java.net/maven/1/</url>
<layout>legacy</layout>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
</pluginRepository>
</pluginRepositories>
@@ -162,6 +165,9 @@
<name>java.net Maven Repository</name>
<url>http://download.java.net/maven/1/</url>
<layout>legacy</layout>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
</repository>
</repositories>
diff --git a/modules/plugins/raw-config-test/pom.xml b/modules/plugins/raw-config-test/pom.xml
index c39712d..c3750ed 100644
--- a/modules/plugins/raw-config-test/pom.xml
+++ b/modules/plugins/raw-config-test/pom.xml
@@ -13,8 +13,11 @@
<repositories>
<repository>
<id>codehaus</id>
- <name>codehaus maven 2 repo</name>
- <url>http://repository.codehaus.org</url>
+ <name>Codehaus Releases</name>
+ <url>http://repository.codehaus.org/</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
</repository>
</repositories>
@@ -162,3 +165,4 @@
</profile>
</profiles>
</project>
+
diff --git a/pom.xml b/pom.xml
index 88f81e9..bec0c4f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -836,6 +836,11 @@
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
+ <!-- Explicitly disable snapshots, so Maven won't try to
+ check for updates for snapshot internal (rhq-*) deps. -->
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
</repository>
</repositories>
14 years, 1 month
[rhq] Branch 'gwt' - 4 commits - modules/core modules/enterprise
by Jay Shaughnessy
modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml | 13
modules/core/dbutils/src/main/scripts/dbsetup/inventory-schema.xml | 4
modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml | 209 +++-------
modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeployment.java | 3
modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersion.java | 2
modules/core/domain/src/main/java/org/rhq/core/domain/tagging/Tag.java | 43 --
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/DeployStep.java | 7
7 files changed, 98 insertions(+), 183 deletions(-)
New commits:
commit 66c6416a0602cb516fe69e304034e7bdeaeabd4e
Merge: c8402c4... 78ac8aa...
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Apr 28 12:42:12 2010 -0400
Merge branch 'gwt' into gwt-jay
Conflicts:
modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/DeployStep.java
commit c8402c4c01ebe1b4bb3b2541ea6604201b5fafa1
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Apr 28 12:40:31 2010 -0400
schema:
- remove some unnecessary abbreviations in new table names
upgrade:
- remove nullable="true" on new columns
(oracle fails when setting to the existing option setting, true by default)
- remove vendor specific FK statements, allow oracle to have named
constraints as they are better than the generated names
- apply fk constraint naming convention
- apply table name abbreviation removal
entity classes:
- fix some hibernate mapping annotations for the tag mapping tables
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml b/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml
index ab97d61..a89ab49 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml
@@ -604,10 +604,10 @@
</primaryKey>
</constraint>
</table>
- <table name="RHQ_TAGGING_BND_VER_MAP">
+ <table name="RHQ_TAGGING_BUNDLE_VERSION_MAP">
<column name="BUNDLE_VERSION_ID" type="INTEGER" references="RHQ_BUNDLE_VERSION"/>
<column name="TAG_ID" type="INTEGER" references="RHQ_TAGGING"/>
- <constraint name="RHQ_TAGGING_BND_VER_MAP_KEY">
+ <constraint name="RHQ_TAGGING_BUNDLE_VER_MAP_KEY">
<primaryKey>
<field ref="BUNDLE_VERSION_ID"/>
<field ref="TAG_ID"/>
@@ -615,17 +615,16 @@
</constraint>
</table>
- <table name="RHQ_TAGGING_BND_DEP_MAP">
- <column name="BUNDLE_DEPLOYMENT_ID" type="INTEGER" references="RHQ_BUNDLE_DEPLOY"/>
+ <table name="RHQ_TAGGING_BUNDLE_DEPLOY_MAP">
+ <column name="BUNDLE_DEPLOY_ID" type="INTEGER" references="RHQ_BUNDLE_DEPLOY"/>
<column name="TAG_ID" type="INTEGER" references="RHQ_TAGGING"/>
- <constraint name="RHQ_TAGGING_BND_DEP_MAP_KEY">
+ <constraint name="RHQ_TAGGING_BUNDLE_DEP_MAP_KEY">
<primaryKey>
- <field ref="BUNDLE_DEPLOYMENT_ID"/>
+ <field ref="BUNDLE_DEPLOY_ID"/>
<field ref="TAG_ID"/>
</primaryKey>
</constraint>
</table>
-
</dbsetup>
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/inventory-schema.xml b/modules/core/dbutils/src/main/scripts/dbsetup/inventory-schema.xml
index 3167457..964c975 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/inventory-schema.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/inventory-schema.xml
@@ -255,10 +255,10 @@
</constraint>
</table>
- <table name="RHQ_TAGGING_RES_GRP_MAP">
+ <table name="RHQ_TAGGING_RES_GROUP_MAP">
<column name="RESOURCE_GROUP_ID" type="INTEGER" references="RHQ_RESOURCE_GROUP"/>
<column name="TAG_ID" type="INTEGER" references="RHQ_TAGGING"/>
- <constraint name="RHQ_TAGGING_RES_GRP_MAP_KEY">
+ <constraint name="RHQ_TAGGING_RES_GROUP_MAP_KEY">
<primaryKey>
<field ref="RESOURCE_GROUP_ID"/>
<field ref="TAG_ID"/>
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 acfa021..a5c7b5e 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -2733,7 +2733,6 @@
<schema-alterColumn table="RHQ_SUBJECT_ROLE_LDAP_MAP" column="ROLE_ID" nullable="FALSE" />
</schemaSpec>
-
<!-- Remove the old tagging system -->
<schemaSpec version="2.84">
<schema-dropTable table="RHQ_REPO_TAG_MAP"/>
@@ -2742,30 +2741,25 @@
<!-- The new tagging system -->
<schemaSpec version="2.85">
+ <schema-createSequence name="RHQ_TAGGING_ID_SEQ" initial="10001" />
<schema-directSQL>
<statement desc="Creating table RHQ_TAGGING">
- CREATE TABLE RHQ_TAGGING ( ID INTEGER PRIMARY KEY)
+ CREATE TABLE RHQ_TAGGING ( ID INTEGER PRIMARY KEY )
</statement>
</schema-directSQL>
<schema-alterColumn table="RHQ_TAGGING" column="ID" nullable="FALSE" />
- <schema-createSequence name="RHQ_TAGGING_ID_SEQ" initial="10001" />
- <schema-addColumn table="RHQ_TAGGING" column="NAMESPACE" columnType="VARCHAR2" precision="20" />
- <schema-alterColumn table="RHQ_TAGGING" column="NAMESPACE" nullable="TRUE" />
- <schema-addColumn table="RHQ_TAGGING" column="SEMANTIC" columnType="VARCHAR2" precision="50" />
- <schema-alterColumn table="RHQ_TAGGING" column="SEMANTIC" nullable="TRUE" />
- <schema-addColumn table="RHQ_TAGGING" column="NAME" columnType="VARCHAR2" precision="100" />
+ <schema-addColumn table="RHQ_TAGGING" column="NAMESPACE" columnType="VARCHAR2" precision="20" />
+ <schema-addColumn table="RHQ_TAGGING" column="SEMANTIC" columnType="VARCHAR2" precision="50" />
+ <schema-addColumn table="RHQ_TAGGING" column="NAME" columnType="VARCHAR2" precision="100" />
<schema-alterColumn table="RHQ_TAGGING" column="NAME" nullable="FALSE" />
-
-
-
<schema-directSQL>
<statement>
CREATE TABLE RHQ_TAGGING_RESOURCE_MAP ( RESOURCE_ID INTEGER )
</statement>
</schema-directSQL>
<schema-alterColumn table="RHQ_TAGGING_RESOURCE_MAP" column="RESOURCE_ID" nullable="false" />
- <schema-addColumn table="RHQ_TAGGING_RESOURCE_MAP" column="TAG_ID" columnType="INTEGER" />
+ <schema-addColumn table="RHQ_TAGGING_RESOURCE_MAP" column="TAG_ID" columnType="INTEGER" />
<schema-alterColumn table="RHQ_TAGGING_RESOURCE_MAP" column="TAG_ID" nullable="false" />
<schema-directSQL>
<statement>
@@ -2773,80 +2767,55 @@
ADD CONSTRAINT RHQ_TAGGING_RESOURCE_MAP_KEY
PRIMARY KEY ( RESOURCE_ID, TAG_ID )
</statement>
- <statement targetDBVendor="postgresql">
+ <statement>
ALTER TABLE RHQ_TAGGING_RESOURCE_MAP
- ADD CONSTRAINT RHQ_TAGGING_RESOURCE_MAP_RESOURCE_ID_FKEY
+ ADD CONSTRAINT RHQ_TRM_RESOURCE_ID_FK
FOREIGN KEY ( RESOURCE_ID )
REFERENCES RHQ_RESOURCE ( ID )
</statement>
- <statement targetDBVendor="oracle">
- ALTER TABLE RHQ_TAGGING_RESOURCE_MAP
- ADD FOREIGN KEY ( RESOURCE_ID )
- REFERENCES RHQ_RESOURCE ( ID )
- </statement>
- <statement targetDBVendor="postgresql">
+ <statement>
ALTER TABLE RHQ_TAGGING_RESOURCE_MAP
- ADD CONSTRAINT RHQ_TAGGING_RESOURCE_MAP_TAG_ID_FKEY
+ ADD CONSTRAINT RHQ_TRM_TAG_ID_FK
FOREIGN KEY ( TAG_ID )
REFERENCES RHQ_TAGGING ( ID )
</statement>
- <statement targetDBVendor="oracle">
- ALTER TABLE RHQ_TAGGING_RESOURCE_MAP
- ADD FOREIGN KEY ( TAG_ID )
- REFERENCES RHQ_TAGGING ( ID )
- </statement>
</schema-directSQL>
-
-
<schema-directSQL>
<statement>
- CREATE TABLE RHQ_TAGGING_RES_GRP_MAP ( RESOURCE_GROUP_ID INTEGER )
+ CREATE TABLE RHQ_TAGGING_RES_GROUP_MAP ( RESOURCE_GROUP_ID INTEGER )
</statement>
</schema-directSQL>
- <schema-alterColumn table="RHQ_TAGGING_RES_GRP_MAP" column="RESOURCE_GROUP_ID" nullable="false" />
- <schema-addColumn table="RHQ_TAGGING_RES_GRP_MAP" column="TAG_ID" columnType="INTEGER" />
- <schema-alterColumn table="RHQ_TAGGING_RES_GRP_MAP" column="TAG_ID" nullable="false" />
+ <schema-alterColumn table="RHQ_TAGGING_RES_GROUP_MAP" column="RESOURCE_GROUP_ID" nullable="false" />
+ <schema-addColumn table="RHQ_TAGGING_RES_GROUP_MAP" column="TAG_ID" columnType="INTEGER" />
+ <schema-alterColumn table="RHQ_TAGGING_RES_GROUP_MAP" column="TAG_ID" nullable="false" />
<schema-directSQL>
<statement>
- ALTER TABLE RHQ_TAGGING_RES_GRP_MAP
- ADD CONSTRAINT RHQ_TAGGING_RES_GRP_MAP_KEY
+ ALTER TABLE RHQ_TAGGING_RES_GROUP_MAP
+ ADD CONSTRAINT RHQ_TAGGING_RES_GROUP_MAP_KEY
PRIMARY KEY ( RESOURCE_GROUP_ID, TAG_ID )
</statement>
- <statement targetDBVendor="postgresql">
- ALTER TABLE RHQ_TAGGING_RES_GRP_MAP
- ADD CONSTRAINT RHQ_TAGGING_RES_GRP_MAP_RESOURCE_GROUP_ID_FKEY
+ <statement>
+ ALTER TABLE RHQ_TAGGING_RES_GROUP_MAP
+ ADD CONSTRAINT RHQ_TRGM_RESOURCE_GROUP_ID_FK
FOREIGN KEY ( RESOURCE_GROUP_ID )
- REFERENCES RHQ_RESOURCE ( ID )
+ REFERENCES RHQ_RESOURCE_GROUP ( ID )
</statement>
- <statement targetDBVendor="oracle">
- ALTER TABLE RHQ_TAGGING_RES_GRP_MAP
- ADD FOREIGN KEY ( RESOURCE_GROUP_ID )
- REFERENCES RHQ_RESOURCE ( ID )
- </statement>
- <statement targetDBVendor="postgresql">
- ALTER TABLE RHQ_TAGGING_RES_GRP_MAP
- ADD CONSTRAINT RHQ_TAGGING_RES_GRP_MAP_TAG_ID_FKEY
+ <statement>
+ ALTER TABLE RHQ_TAGGING_RES_GROUP_MAP
+ ADD CONSTRAINT RHQ_TRGM_TAG_ID_FK
FOREIGN KEY ( TAG_ID )
REFERENCES RHQ_TAGGING ( ID )
</statement>
- <statement targetDBVendor="oracle">
- ALTER TABLE RHQ_TAGGING_RES_GRP_MAP
- ADD FOREIGN KEY ( TAG_ID )
- REFERENCES RHQ_TAGGING ( ID )
- </statement>
</schema-directSQL>
-
-
-
- <schema-directSQL>
+ <schema-directSQL>
<statement>
CREATE TABLE RHQ_TAGGING_BUNDLE_MAP ( BUNDLE_ID INTEGER )
</statement>
</schema-directSQL>
<schema-alterColumn table="RHQ_TAGGING_BUNDLE_MAP" column="BUNDLE_ID" nullable="false" />
- <schema-addColumn table="RHQ_TAGGING_BUNDLE_MAP" column="TAG_ID" columnType="INTEGER" />
+ <schema-addColumn table="RHQ_TAGGING_BUNDLE_MAP" column="TAG_ID" columnType="INTEGER" />
<schema-alterColumn table="RHQ_TAGGING_BUNDLE_MAP" column="TAG_ID" nullable="false" />
<schema-directSQL>
<statement>
@@ -2854,118 +2823,76 @@
ADD CONSTRAINT RHQ_TAGGING_BUNDLE_MAP_KEY
PRIMARY KEY ( BUNDLE_ID, TAG_ID )
</statement>
- <statement targetDBVendor="postgresql">
+ <statement>
ALTER TABLE RHQ_TAGGING_BUNDLE_MAP
- ADD CONSTRAINT RHQ_TAGGING_BUNDLE_MAP_BUNDLE_ID_FKEY
+ ADD CONSTRAINT RHQ_TBM_BUNDLE_ID_FK
FOREIGN KEY ( BUNDLE_ID )
- REFERENCES RHQ_RESOURCE ( ID )
- </statement>
- <statement targetDBVendor="oracle">
- ALTER TABLE RHQ_TAGGING_BUNDLE_MAP
- ADD FOREIGN KEY ( BUNDLE_ID )
- REFERENCES RHQ_RESOURCE ( ID )
+ REFERENCES RHQ_BUNDLE ( ID )
</statement>
- <statement targetDBVendor="postgresql">
+ <statement>
ALTER TABLE RHQ_TAGGING_BUNDLE_MAP
- ADD CONSTRAINT RHQ_TAGGING_BUNDLE_MAP_TAG_ID_FKEY
+ ADD CONSTRAINT RHQ_TBM_TAG_ID_FK
FOREIGN KEY ( TAG_ID )
REFERENCES RHQ_TAGGING ( ID )
</statement>
- <statement targetDBVendor="oracle">
- ALTER TABLE RHQ_TAGGING_BUNDLE_MAP
- ADD FOREIGN KEY ( TAG_ID )
- REFERENCES RHQ_TAGGING ( ID )
- </statement>
</schema-directSQL>
-
-
-
-
-
-
- <schema-directSQL>
+ <schema-directSQL>
<statement>
- CREATE TABLE RHQ_TAGGING_BND_VER_MAP ( BUNDLE_VERSION_ID INTEGER )
+ CREATE TABLE RHQ_TAGGING_BUNDLE_VERSION_MAP ( BUNDLE_VERSION_ID INTEGER )
</statement>
</schema-directSQL>
- <schema-alterColumn table="RHQ_TAGGING_BND_VER_MAP" column="BUNDLE_VERSION_ID" nullable="false" />
- <schema-addColumn table="RHQ_TAGGING_BND_VER_MAP" column="TAG_ID" columnType="INTEGER" />
- <schema-alterColumn table="RHQ_TAGGING_BND_VER_MAP" column="TAG_ID" nullable="false" />
+ <schema-alterColumn table="RHQ_TAGGING_BUNDLE_VERSION_MAP" column="BUNDLE_VERSION_ID" nullable="false" />
+ <schema-addColumn table="RHQ_TAGGING_BUNDLE_VERSION_MAP" column="TAG_ID" columnType="INTEGER" />
+ <schema-alterColumn table="RHQ_TAGGING_BUNDLE_VERSION_MAP" column="TAG_ID" nullable="false" />
<schema-directSQL>
<statement>
- ALTER TABLE RHQ_TAGGING_BND_VER_MAP
- ADD CONSTRAINT RHQ_TAGGING_BND_VER_MAP_KEY
+ ALTER TABLE RHQ_TAGGING_BUNDLE_VERSION_MAP
+ ADD CONSTRAINT RHQ_TAGGING_BUNDLE_VER_MAP_KEY
PRIMARY KEY ( BUNDLE_VERSION_ID, TAG_ID )
</statement>
- <statement targetDBVendor="postgresql">
- ALTER TABLE RHQ_TAGGING_BND_VER_MAP
- ADD CONSTRAINT RHQ_TAGGING_BND_VER_MAP_BUNDLE_VERSION_ID_FKEY
+ <statement>
+ ALTER TABLE RHQ_TAGGING_BUNDLE_VERSION_MAP
+ ADD CONSTRAINT RHQ_TBVM_BUNDLE_VERSION_ID_FK
FOREIGN KEY ( BUNDLE_VERSION_ID )
- REFERENCES RHQ_RESOURCE ( ID )
+ REFERENCES RHQ_BUNDLE_VERSION ( ID )
</statement>
- <statement targetDBVendor="oracle">
- ALTER TABLE RHQ_TAGGING_BND_VER_MAP
- ADD FOREIGN KEY ( BUNDLE_VERSION_ID )
- REFERENCES RHQ_RESOURCE ( ID )
- </statement>
- <statement targetDBVendor="postgresql">
- ALTER TABLE RHQ_TAGGING_BND_VER_MAP
- ADD CONSTRAINT RHQ_TAGGING_BND_VER_MAP_TAG_ID_FKEY
+ <statement>
+ ALTER TABLE RHQ_TAGGING_BUNDLE_VERSION_MAP
+ ADD CONSTRAINT RHQ_TBVM_TAG_ID_FK
FOREIGN KEY ( TAG_ID )
REFERENCES RHQ_TAGGING ( ID )
</statement>
- <statement targetDBVendor="oracle">
- ALTER TABLE RHQ_TAGGING_BND_VER_MAP
- ADD FOREIGN KEY ( TAG_ID )
- REFERENCES RHQ_TAGGING ( ID )
- </statement>
</schema-directSQL>
-
-
-
<schema-directSQL>
- <statement>
- CREATE TABLE RHQ_TAGGING_BND_DEP_MAP ( BUNDLE_DEPLOYMENT_ID INTEGER )
- </statement>
- </schema-directSQL>
- <schema-alterColumn table="RHQ_TAGGING_BND_DEP_MAP" column="BUNDLE_DEPLOYMENT_ID" nullable="false" />
- <schema-addColumn table="RHQ_TAGGING_BND_DEP_MAP" column="TAG_ID" columnType="INTEGER" />
- <schema-alterColumn table="RHQ_TAGGING_BND_DEP_MAP" column="TAG_ID" nullable="false" />
- <schema-directSQL>
- <statement>
- ALTER TABLE RHQ_TAGGING_BND_DEP_MAP
- ADD CONSTRAINT RHQ_TAGGING_BND_DEP_MAP_KEY
- PRIMARY KEY ( BUNDLE_DEPLOYMENT_ID, TAG_ID )
- </statement>
- <statement targetDBVendor="postgresql">
- ALTER TABLE RHQ_TAGGING_BND_DEP_MAP
- ADD CONSTRAINT RHQ_TAGGING_BND_DEP_MAP_BUNDLE_DEPLOYMENT_ID_FKEY
- FOREIGN KEY ( BUNDLE_DEPLOYMENT_ID )
- REFERENCES RHQ_RESOURCE ( ID )
- </statement>
- <statement targetDBVendor="oracle">
- ALTER TABLE RHQ_TAGGING_BND_DEP_MAP
- ADD FOREIGN KEY ( BUNDLE_DEPLOYMENT_ID )
- REFERENCES RHQ_RESOURCE ( ID )
- </statement>
- <statement targetDBVendor="postgresql">
- ALTER TABLE RHQ_TAGGING_BND_DEP_MAP
- ADD CONSTRAINT RHQ_TAGGING_BND_DEP_MAP_TAG_ID_FKEY
- FOREIGN KEY ( TAG_ID )
- REFERENCES RHQ_TAGGING ( ID )
- </statement>
- <statement targetDBVendor="oracle">
- ALTER TABLE RHQ_TAGGING_BND_DEP_MAP
- ADD FOREIGN KEY ( TAG_ID )
- REFERENCES RHQ_TAGGING ( ID )
- </statement>
- </schema-directSQL>
- </schemaSpec>
-
-
-
+ <statement>
+ CREATE TABLE RHQ_TAGGING_BUNDLE_DEPLOY_MAP ( BUNDLE_DEPLOY_ID INTEGER )
+ </statement>
+ </schema-directSQL>
+ <schema-alterColumn table="RHQ_TAGGING_BUNDLE_DEPLOY_MAP" column="BUNDLE_DEPLOY_ID" nullable="false" />
+ <schema-addColumn table="RHQ_TAGGING_BUNDLE_DEPLOY_MAP" column="TAG_ID" columnType="INTEGER" />
+ <schema-alterColumn table="RHQ_TAGGING_BUNDLE_DEPLOY_MAP" column="TAG_ID" nullable="false" />
+ <schema-directSQL>
+ <statement>
+ ALTER TABLE RHQ_TAGGING_BUNDLE_DEPLOY_MAP
+ ADD CONSTRAINT RHQ_TAGGING_BUNDLE_DEP_MAP_KEY
+ PRIMARY KEY ( BUNDLE_DEPLOY_ID, TAG_ID )
+ </statement>
+ <statement>
+ ALTER TABLE RHQ_TAGGING_BUNDLE_DEPLOY_MAP
+ ADD CONSTRAINT RHQ_TBDM_BUNDLE_DEPLOY_ID_FK
+ FOREIGN KEY ( BUNDLE_DEPLOY_ID )
+ REFERENCES RHQ_BUNDLE_DEPLOY ( ID )
+ </statement>
+ <statement>
+ ALTER TABLE RHQ_TAGGING_BUNDLE_DEPLOY_MAP
+ ADD CONSTRAINT RHQ_TBDM_TAG_ID_FK
+ FOREIGN KEY ( TAG_ID )
+ REFERENCES RHQ_TAGGING ( ID )
+ </statement>
+ </schema-directSQL>
+ </schemaSpec>
</dbupgrade>
</target>
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeployment.java b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeployment.java
index e86236d..200c2b5 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeployment.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeployment.java
@@ -104,10 +104,9 @@ public class BundleDeployment implements Serializable {
@OneToMany(mappedBy = "bundleDeployment", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
private List<BundleGroupDeployment> groupDeployments = new ArrayList<BundleGroupDeployment>();
- @ManyToMany(mappedBy = "resources", fetch = FetchType.LAZY)
+ @ManyToMany(mappedBy = "bundleDeployments", fetch = FetchType.LAZY)
private Set<Tag> tags;
-
public BundleDeployment() {
// for JPA use
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersion.java b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersion.java
index d8b09bb..9b3f606 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersion.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersion.java
@@ -124,7 +124,7 @@ public class BundleVersion implements Serializable {
@OneToMany(mappedBy = "bundleVersion", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
private List<BundleFile> bundleFiles = new ArrayList<BundleFile>();
- @ManyToMany(mappedBy = "resources", fetch = FetchType.LAZY)
+ @ManyToMany(mappedBy = "bundleVersions", fetch = FetchType.LAZY)
private Set<Tag> tags;
public BundleVersion() {
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/tagging/Tag.java b/modules/core/domain/src/main/java/org/rhq/core/domain/tagging/Tag.java
index c8c7db6..f30ab82 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/tagging/Tag.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/tagging/Tag.java
@@ -45,7 +45,6 @@ import org.rhq.core.domain.bundle.BundleVersion;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.group.ResourceGroup;
-
/**
* @author Greg Hinkle
*/
@@ -57,13 +56,11 @@ public class Tag implements Serializable {
private static final long serialVersionUID = 1L;
-
@Column(name = "ID", nullable = false)
@GeneratedValue(strategy = GenerationType.AUTO, generator = "RHQ_TAGGING_SEQ")
@Id
private int id;
-
@Column(name = "NAMESPACE", nullable = true)
private String namespace;
@@ -73,32 +70,29 @@ public class Tag implements Serializable {
@Column(name = "NAME", nullable = false)
private String name;
- @JoinTable(name = "RHQ_TAGGING_RESOURCE_MAP", joinColumns = {@JoinColumn(name = "TAG_ID")}, inverseJoinColumns = {@JoinColumn(name = "RESOURCE_ID")})
+ @JoinTable(name = "RHQ_TAGGING_RESOURCE_MAP", joinColumns = { @JoinColumn(name = "TAG_ID") }, inverseJoinColumns = { @JoinColumn(name = "RESOURCE_ID") })
@ManyToMany
private Set<Resource> resources;
- @JoinTable(name = "RHQ_TAGGING_RES_GRP_MAP", joinColumns = {@JoinColumn(name = "TAG_ID")}, inverseJoinColumns = {@JoinColumn(name = "RESOURCE_GROUP_ID")})
+ @JoinTable(name = "RHQ_TAGGING_RES_GROUP_MAP", joinColumns = { @JoinColumn(name = "TAG_ID") }, inverseJoinColumns = { @JoinColumn(name = "RESOURCE_GROUP_ID") })
@ManyToMany
private Set<ResourceGroup> resourceGroups;
- @JoinTable(name = "RHQ_TAGGING_BUNDLE_MAP", joinColumns = {@JoinColumn(name = "TAG_ID")}, inverseJoinColumns = {@JoinColumn(name = "BUNDLE_ID")})
+ @JoinTable(name = "RHQ_TAGGING_BUNDLE_MAP", joinColumns = { @JoinColumn(name = "TAG_ID") }, inverseJoinColumns = { @JoinColumn(name = "BUNDLE_ID") })
@ManyToMany
private Set<Bundle> bundles;
- @JoinTable(name = "RHQ_TAGGING_BND_VER_MAP", joinColumns = {@JoinColumn(name = "TAG_ID")}, inverseJoinColumns = {@JoinColumn(name = "BUNDLE_VERSION_ID")})
+ @JoinTable(name = "RHQ_TAGGING_BUNDLE_VERSION_MAP", joinColumns = { @JoinColumn(name = "TAG_ID") }, inverseJoinColumns = { @JoinColumn(name = "BUNDLE_VERSION_ID") })
@ManyToMany
private Set<BundleVersion> bundleVersions;
-
- @JoinTable(name = "RHQ_TAGGING_BND_DEP_MAP", joinColumns = {@JoinColumn(name = "TAG_ID")}, inverseJoinColumns = {@JoinColumn(name = "BUNDLE_DEPLOYMENT_ID")})
+ @JoinTable(name = "RHQ_TAGGING_BUNDLE_DEPLOY_MAP", joinColumns = { @JoinColumn(name = "TAG_ID") }, inverseJoinColumns = { @JoinColumn(name = "BUNDLE_DEPLOY_ID") })
@ManyToMany
private Set<BundleDeployment> bundleDeployments;
-
protected Tag() {
}
-
public Tag(String namespace, String semantic, String name) {
this.namespace = namespace;
this.semantic = semantic;
@@ -146,7 +140,6 @@ public class Tag implements Serializable {
this.name = name;
}
-
public Set<Resource> getResources() {
return resources;
}
@@ -172,7 +165,6 @@ public class Tag implements Serializable {
}
}
-
public Set<ResourceGroup> getResourceGroups() {
return resourceGroups;
}
@@ -198,7 +190,6 @@ public class Tag implements Serializable {
}
}
-
public Set<Bundle> getBundles() {
return bundles;
}
@@ -224,7 +215,6 @@ public class Tag implements Serializable {
}
}
-
public Set<BundleVersion> getBundleVersions() {
return bundleVersions;
}
@@ -250,7 +240,6 @@ public class Tag implements Serializable {
}
}
-
public Set<BundleDeployment> getBundleDeployments() {
return bundleDeployments;
}
@@ -259,7 +248,6 @@ public class Tag implements Serializable {
this.bundleDeployments = bundleDeployments;
}
-
public void addBundleDeployment(BundleDeployment bundleDeployment) {
if (bundleDeployments == null) {
bundleDeployments = new HashSet<BundleDeployment>();
@@ -277,25 +265,26 @@ public class Tag implements Serializable {
}
}
-
@Override
public String toString() {
- return (namespace != null ? namespace + ":" : "") +
- (semantic != null ? semantic + "=" : "") +
- name;
+ return (namespace != null ? namespace + ":" : "") + (semantic != null ? semantic + "=" : "") + name;
}
-
@Override
public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
Tag tag = (Tag) o;
- if (!name.equals(tag.name)) return false;
- if (namespace != null ? !namespace.equals(tag.namespace) : tag.namespace != null) return false;
- if (semantic != null ? !semantic.equals(tag.semantic) : tag.semantic != null) return false;
+ if (!name.equals(tag.name))
+ return false;
+ if (namespace != null ? !namespace.equals(tag.namespace) : tag.namespace != null)
+ return false;
+ if (semantic != null ? !semantic.equals(tag.semantic) : tag.semantic != null)
+ return false;
return true;
}
commit 69479c3815e8b8894e597ec679124d86cbcbd77a
Merge: 9634779... d59510c...
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Apr 28 11:06:09 2010 -0400
Merge branch 'gwt' into gwt-jay
commit 96347793dd16dba1f96082e6aadcbb02dceca372
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Apr 28 11:02:49 2010 -0400
remove straggling reference to scheduleBundleResourceDeployment
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/DeployStep.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/DeployStep.java
index 093802c..32bedf2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/DeployStep.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/DeployStep.java
@@ -28,7 +28,6 @@ import com.smartgwt.client.widgets.layout.VLayout;
import org.rhq.core.domain.bundle.BundleDeployment;
import org.rhq.core.domain.bundle.BundleGroupDeployment;
-import org.rhq.core.domain.bundle.BundleResourceDeployment;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.components.wizard.WizardStep;
import org.rhq.enterprise.gui.coregui.client.gwt.BundleGWTServiceAsync;
@@ -86,6 +85,7 @@ public class DeployStep implements WizardStep {
wizard.setBundleDeployment(result);
if (wizard.isResourceDeploy()) {
+ /*
bundleServer.scheduleBundleResourceDeployment(wizard.getBundleDeployment().getId(),
wizard.getDeployTargetId(), //
new AsyncCallback<BundleResourceDeployment>() {
@@ -107,6 +107,7 @@ public class DeployStep implements WizardStep {
wizard.setResourceDeployment(null);
}
});
+ */
} else {
bundleServer.scheduleBundleGroupDeployment(wizard.getBundleDeployment().getId(), wizard
.getDeployTargetId(), //
14 years, 1 month
[rhq] Branch 'gwt' - modules/core modules/enterprise
by Greg Hinkle
modules/core/domain/src/main/java/org/rhq/core/domain/resource/flyweight/AutoGroupCompositeFlyweight.java | 2 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/DeployStep.java | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
New commits:
commit 78ac8aac8fe933e4ac402f22999682c0d5bdb841
Author: Greg Hinkle <ghinkle(a)redhat.com>
Date: Wed Apr 28 12:12:14 2010 -0400
Can't use String.format in gwt code
remove unsupported bundle deploy scenario
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/flyweight/AutoGroupCompositeFlyweight.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/flyweight/AutoGroupCompositeFlyweight.java
index b779a63..46af2db 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/flyweight/AutoGroupCompositeFlyweight.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/flyweight/AutoGroupCompositeFlyweight.java
@@ -82,7 +82,7 @@ public class AutoGroupCompositeFlyweight implements Serializable {
this.resourceType = resourceType;
this.memberCount = memberCount;
if (isDuplicateResourceTypeName) {
- this.name = String.format("%s (%s plugin)", this.resourceType.getName(), this.resourceType.getPlugin());
+ this.name = this.resourceType.getName() + " (" + this.resourceType.getPlugin() + " plugin)";
} else {
this.name = this.resourceType.getName();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/DeployStep.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/DeployStep.java
index 093802c..a387813 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/DeployStep.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/DeployStep.java
@@ -86,7 +86,7 @@ public class DeployStep implements WizardStep {
wizard.setBundleDeployment(result);
if (wizard.isResourceDeploy()) {
- bundleServer.scheduleBundleResourceDeployment(wizard.getBundleDeployment().getId(),
+ /*bundleServer.scheduleBundleResourceDeployment(wizard.getBundleDeployment().getId(),
wizard.getDeployTargetId(), //
new AsyncCallback<BundleResourceDeployment>() {
public void onSuccess(BundleResourceDeployment result) {
@@ -106,7 +106,7 @@ public class DeployStep implements WizardStep {
"Failed to schedule deployment: " + caught.getMessage(), caught);
wizard.setResourceDeployment(null);
}
- });
+ });*/
} else {
bundleServer.scheduleBundleGroupDeployment(wizard.getBundleDeployment().getId(), wizard
.getDeployTargetId(), //
14 years, 1 month
[rhq] Branch 'gwt' - modules/core
by Greg Hinkle
modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml | 16 +++++-----
1 file changed, 8 insertions(+), 8 deletions(-)
New commits:
commit 71a6dca4164af14b0db2d6c1fce3fe51cf87d92f
Author: Greg Hinkle <ghinkle(a)redhat.com>
Date: Wed Apr 28 11:26:21 2010 -0400
Fixed db-upgrade
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 acfa021..b3c9b8c 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -2817,12 +2817,12 @@
ALTER TABLE RHQ_TAGGING_RES_GRP_MAP
ADD CONSTRAINT RHQ_TAGGING_RES_GRP_MAP_RESOURCE_GROUP_ID_FKEY
FOREIGN KEY ( RESOURCE_GROUP_ID )
- REFERENCES RHQ_RESOURCE ( ID )
+ REFERENCES RHQ_RESOURCE_GROUP ( ID )
</statement>
<statement targetDBVendor="oracle">
ALTER TABLE RHQ_TAGGING_RES_GRP_MAP
ADD FOREIGN KEY ( RESOURCE_GROUP_ID )
- REFERENCES RHQ_RESOURCE ( ID )
+ REFERENCES RHQ_RESOURCE_GROUP ( ID )
</statement>
<statement targetDBVendor="postgresql">
ALTER TABLE RHQ_TAGGING_RES_GRP_MAP
@@ -2858,12 +2858,12 @@
ALTER TABLE RHQ_TAGGING_BUNDLE_MAP
ADD CONSTRAINT RHQ_TAGGING_BUNDLE_MAP_BUNDLE_ID_FKEY
FOREIGN KEY ( BUNDLE_ID )
- REFERENCES RHQ_RESOURCE ( ID )
+ REFERENCES RHQ_BUNDLE ( ID )
</statement>
<statement targetDBVendor="oracle">
ALTER TABLE RHQ_TAGGING_BUNDLE_MAP
ADD FOREIGN KEY ( BUNDLE_ID )
- REFERENCES RHQ_RESOURCE ( ID )
+ REFERENCES RHQ_BUNDLE ( ID )
</statement>
<statement targetDBVendor="postgresql">
ALTER TABLE RHQ_TAGGING_BUNDLE_MAP
@@ -2902,12 +2902,12 @@
ALTER TABLE RHQ_TAGGING_BND_VER_MAP
ADD CONSTRAINT RHQ_TAGGING_BND_VER_MAP_BUNDLE_VERSION_ID_FKEY
FOREIGN KEY ( BUNDLE_VERSION_ID )
- REFERENCES RHQ_RESOURCE ( ID )
+ REFERENCES RHQ_BUNDLE_VERSION ( ID )
</statement>
<statement targetDBVendor="oracle">
ALTER TABLE RHQ_TAGGING_BND_VER_MAP
ADD FOREIGN KEY ( BUNDLE_VERSION_ID )
- REFERENCES RHQ_RESOURCE ( ID )
+ REFERENCES RHQ_BUNDLE_VERSION ( ID )
</statement>
<statement targetDBVendor="postgresql">
ALTER TABLE RHQ_TAGGING_BND_VER_MAP
@@ -2943,12 +2943,12 @@
ALTER TABLE RHQ_TAGGING_BND_DEP_MAP
ADD CONSTRAINT RHQ_TAGGING_BND_DEP_MAP_BUNDLE_DEPLOYMENT_ID_FKEY
FOREIGN KEY ( BUNDLE_DEPLOYMENT_ID )
- REFERENCES RHQ_RESOURCE ( ID )
+ REFERENCES RHQ_BUNDLE_DEPLOY ( ID )
</statement>
<statement targetDBVendor="oracle">
ALTER TABLE RHQ_TAGGING_BND_DEP_MAP
ADD FOREIGN KEY ( BUNDLE_DEPLOYMENT_ID )
- REFERENCES RHQ_RESOURCE ( ID )
+ REFERENCES RHQ_BUNDLE_DEPLOY ( ID )
</statement>
<statement targetDBVendor="postgresql">
ALTER TABLE RHQ_TAGGING_BND_DEP_MAP
14 years, 1 month
[rhq] Branch 'gwt' - 28 commits - modules/core modules/enterprise
by Greg Hinkle
modules/core/dbutils/pom.xml | 2
modules/core/dbutils/src/main/java/org/rhq/core/db/setup/DBSetup.java | 2
modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml | 143 ++-
modules/core/dbutils/src/main/scripts/dbsetup/dbsetup-schema.xsd | 1
modules/core/dbutils/src/main/scripts/dbsetup/inventory-schema.xml | 30
modules/core/dbutils/src/main/scripts/dbsetup/obsolete-schema.xml | 19
modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml | 236 ++++++
modules/core/domain/src/main/java/org/rhq/core/domain/bundle/Bundle.java | 31
modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeployment.java | 31
modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersion.java | 30
modules/core/domain/src/main/java/org/rhq/core/domain/common/Tag.java | 121 ---
modules/core/domain/src/main/java/org/rhq/core/domain/common/Taggable.java | 38 -
modules/core/domain/src/main/java/org/rhq/core/domain/content/Repo.java | 99 --
modules/core/domain/src/main/java/org/rhq/core/domain/content/RepoTag.java | 129 ---
modules/core/domain/src/main/java/org/rhq/core/domain/content/RepoTagPK.java | 122 ---
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleCriteria.java | 6
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleDeploymentCriteria.java | 5
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleVersionCriteria.java | 7
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceCriteria.java | 5
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceGroupCriteria.java | 6
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/TagCriteria.java | 86 ++
modules/core/domain/src/main/java/org/rhq/core/domain/install/remote/AgentInstallInfo.java | 120 +++
modules/core/domain/src/main/java/org/rhq/core/domain/install/remote/AgentInstallStep.java | 63 +
modules/core/domain/src/main/java/org/rhq/core/domain/install/remote/RemoteAccessInfo.java | 93 ++
modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java | 29
modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ResourceGroup.java | 29
modules/core/domain/src/main/java/org/rhq/core/domain/tagging/Tag.java | 310 ++++++++
modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java | 1
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml | 11
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/BookmarkableView.java | 31
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/Breadcrumb.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/BreadcrumbTrailPane.java | 63 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java | 152 +---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/UnknownViewException.java | 33
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/View.java | 12
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewId.java | 70 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewPath.java | 75 ++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewRenderer.java | 34
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/AdministrationView.java | 363 ++++-----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/agent/install/RemoteAgentInstallView.java | 303 ++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java | 16
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertsView.java | 167 ++--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AlertDefinitionsView.java | 10
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/RadioGroupWithComponentsItem.java | 131 +++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java | 20
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tagging/TagEditorView.java | 199 +++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tagging/TaggingDataSource.java | 76 ++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tagging/TagsChangedCallback.java | 35
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java | 276 ++++---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java | 125 +++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/OldDashboardView.java | 265 +++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortalColumn.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortalLayout.java | 10
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/Portlet.java | 57 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java | 79 ++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletView.java | 36
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletViewFactory.java | 28
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/RecentlyAddedResource.java | 78 --
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/RecentlyAddedResourceDS.java | 226 ------
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/RecentlyAddedView.java | 56 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java | 56 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/graph/GraphPortlet.java | 59 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformMetricDataSource.java | 58 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformPortletView.java | 364 ++++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/RecentAlertsPortlet.java | 56 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResource.java | 78 ++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourceDS.java | 226 ++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedView.java | 85 ++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/summary/InventorySummaryView.java | 140 +++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/store/DashboardStore.java | 58 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/store/StoredDashboard.java | 77 ++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/store/StoredPortlet.java | 104 ++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AvailabilityGWTService.java | 36
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ConfigurationGWTService.java | 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java | 11
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/RemoteInstallGWTService.java | 48 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGWTService.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/TagGWTService.java | 57 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java | 46 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/CustomResourceTreeGrid.java | 8
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java | 77 --
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTitleBar.java | 73 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java | 132 ++-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceView.java | 81 --
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/alert/AlertEditOldStyleView.java | 206 +++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/alert/AlertEditView.java | 329 +++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/PluginConfigurationEditView.java | 103 ++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/AvailabilityBarView.java | 171 ++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/GraphListView.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/SmallGraphView.java | 78 ++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/OperationHistoryDataSource.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/OperationHistoryView.java | 46 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/detail/OperationDetailsView.java | 13
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/overview/ResourceOverviewView.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/overview/ResourceSummaryView.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/factory/ConfigurationTemplateStep.java | 8
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/type/ResourceTypePluginTreeDataSource.java | 259 +++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/type/ResourceTypeTreeDataSource.java | 26
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/summary/SummaryCountsView.java | 110 ---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java | 5
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/preferences/UserPreferences.java | 25
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AvailabilityGWTServiceImpl.java | 46 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ConfigurationGWTServiceImpl.java | 8
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/RemoteInstallGWTServiceImpl.java | 68 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java | 8
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/TagGWTServiceImpl.java | 76 ++
modules/enterprise/gui/coregui/src/main/webapp/CoreGUI.css | 32
modules/enterprise/gui/coregui/src/main/webapp/CoreGUI.html | 1
modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml | 24
modules/enterprise/gui/coregui/src/main/webapp/images/availBar/down.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/availBar/leftCap.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/availBar/rightCap.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/availBar/unknown.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/availBar/up.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/alert/Alert_HIGH_16.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/alert/Alert_LOW_16.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/alert/Alert_MEDIUM_16.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/alert/Alerts_16.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/availability/availability_green_16.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/availability/availability_green_24.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/availability/availability_grey_16.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/availability/availability_grey_24.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/availability/availability_red_16.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/availability/availability_red_24.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/availability/availability_yellow_16.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/availability/availability_yellow_24.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/configure/Configure_16.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/configure/Configure_24.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/configure/Configure_failed_16.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/configure/Configure_grey_16.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/configure/Configure_ok_16.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/content/Content_16.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/content/Content_24.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/content/Content_cancel_16.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/content/Content_failed_16.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/content/Content_grey_16.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/content/Content_ok_16.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/control/Operation_16.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/control/Operation_24.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/control/Operation_cancel_16.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/control/Operation_failed_16.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/control/Operation_grey_16.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/control/Operation_ok_16.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_11.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_16.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_24.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_debug_16.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_debug_24.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_debug_multi_16.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_debug_multi_24.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_error_16.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_error_24.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_error_multi_16.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_error_multi_24.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_fatal_16.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_fatal_24.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_fatal_multi_16.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_fatal_multi_24.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_grey_16.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_info_16.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_info_24.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_info_multi_16.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_info_multi_24.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_warning_16.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_warning_24.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_warning_multi_16.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_warning_multi_24.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/inventory/Inventory_16.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/inventory/Inventory_24.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/inventory/Inventory_grey_16.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/monitor/Monitor_16.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/monitor/Monitor_24.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/monitor/Monitor_failed_16.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/monitor/Monitor_failed_24.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/monitor/Monitor_grey_16.png |binary
modules/enterprise/server/jar/pom.xml | 6
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/install/remote/RemoteInstallManagerBean.java | 80 ++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/install/remote/RemoteInstallManagerLocal.java | 50 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/install/remote/RemoteInstallManagerRemote.java | 50 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/install/remote/SSHFileSend.java | 149 ++++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/install/remote/SSHInstallUtility.java | 351 +++++++++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/tagging/TagManagerBean.java | 168 ++++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/tagging/TagManagerLocal.java | 33
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/tagging/TagManagerRemote.java | 61 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java | 16
186 files changed, 7480 insertions(+), 1920 deletions(-)
New commits:
commit d59510cc70304da46a4ae3e2d1cfdd7e0ee276ab
Author: Greg Hinkle <ghinkle(a)redhat.com>
Date: Wed Apr 28 10:51:35 2010 -0400
Resource tag loading fix
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tagging/TagEditorView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tagging/TagEditorView.java
index 91bbbde..6aba3bf 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tagging/TagEditorView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tagging/TagEditorView.java
@@ -72,6 +72,15 @@ public class TagEditorView extends HLayout {
this.callback = callback;
}
+ public LinkedHashSet<Tag> getTags() {
+ return tags;
+ }
+
+ public void setTags(LinkedHashSet<Tag> tags) {
+ this.tags = tags;
+ setup();
+ }
+
@Override
protected void onDraw() {
super.onDraw();
@@ -180,6 +189,7 @@ public class TagEditorView extends HLayout {
});
addMember(modeImg);
}
+ markForRedraw();
}
private void save() {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTitleBar.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTitleBar.java
index 93b6512..7d0c499 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTitleBar.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTitleBar.java
@@ -21,9 +21,11 @@ package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail;
import com.google.gwt.user.client.rpc.AsyncCallback;
import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.criteria.ResourceCriteria;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.tagging.Tag;
+import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.components.tagging.TagEditorView;
import org.rhq.enterprise.gui.coregui.client.components.tagging.TagsChangedCallback;
@@ -38,6 +40,7 @@ import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.layout.HLayout;
import java.util.HashSet;
+import java.util.LinkedHashSet;
import java.util.Set;
/**
@@ -101,6 +104,8 @@ public class ResourceTitleBar extends HLayout {
}
});
+ loadTags(tagEditorView);
+
addMember(badge);
addMember(title);
@@ -109,6 +114,25 @@ public class ResourceTitleBar extends HLayout {
addMember(favoriteButton);
}
+ private void loadTags(final TagEditorView tagEditorView) {
+ ResourceCriteria criteria = new ResourceCriteria();
+ criteria.addFilterId(resource.getId());
+ criteria.fetchTags(true);
+ GWTServiceLookup.getResourceService().findResourcesByCriteria(criteria, new AsyncCallback<PageList<Resource>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Could not load resource tags",caught);
+ }
+
+ public void onSuccess(PageList<Resource> result) {
+ LinkedHashSet<Tag> tags = new LinkedHashSet<Tag>();
+ tags.addAll(result.get(0).getTags());
+ tagEditorView.setTags(tags);
+ }
+ });
+ }
+
+
+
public void setResource(Resource resource) {
this.resource = resource;
update();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java
index add7a25..31dd771 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java
@@ -95,11 +95,11 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl implements Re
// "resourceRepos \n" +
"schedules",
// "availability \n" +
- "currentAvailability"
+ "currentAvailability",
// "resourceErrors \n" +
// "eventSources \n" +
// "productVersion "}
-
+ "tags"
};
private static Set<String> importantFieldsSet = new HashSet<String>(Arrays.asList(importantFields));
commit a294b967a0f8304c81d0e852704a409ec184f7c1
Author: Greg Hinkle <ghinkle(a)redhat.com>
Date: Wed Apr 28 10:50:25 2010 -0400
merge of schema setup
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 2985e71..acfa021 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -2734,7 +2734,6 @@
</schemaSpec>
-
<!-- Remove the old tagging system -->
<schemaSpec version="2.84">
<schema-dropTable table="RHQ_REPO_TAG_MAP"/>
@@ -2963,15 +2962,11 @@
REFERENCES RHQ_TAGGING ( ID )
</statement>
</schema-directSQL>
+ </schemaSpec>
-
-
-
- </schemaSpec>
-
</dbupgrade>
</target>
</project>
commit 570086740595768de3cb113f49b62956f12d8fd3
Author: Greg Hinkle <ghinkle(a)redhat.com>
Date: Wed Apr 28 10:49:28 2010 -0400
Too verbose on dbsetup for builds
diff --git a/modules/core/dbutils/src/main/java/org/rhq/core/db/setup/DBSetup.java b/modules/core/dbutils/src/main/java/org/rhq/core/db/setup/DBSetup.java
index 993b044..eb1d0eb 100644
--- a/modules/core/dbutils/src/main/java/org/rhq/core/db/setup/DBSetup.java
+++ b/modules/core/dbutils/src/main/java/org/rhq/core/db/setup/DBSetup.java
@@ -1018,7 +1018,7 @@ public class DBSetup {
}
long duration = System.currentTimeMillis() - start;
- log(LogPriority.DEBUG, DbUtilsI18NResourceKeys.DBSETUP_DURATION, duration);
+// log(LogPriority.DEBUG, DbUtilsI18NResourceKeys.DBSETUP_DURATION, duration);
// Reset the commit option
this.getConnection().setAutoCommit(committing);
commit fa0b68b79053fa43f9b06d9fa25c0ce5c634f5cd
Author: Greg Hinkle <ghinkle(a)redhat.com>
Date: Wed Apr 28 08:14:36 2010 -0400
Fix bug where manually inventoried servers are not being set to committed on the agent side
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java
index 8b6cf68..e309286 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java
@@ -672,6 +672,7 @@ public class InventoryManager extends AgentService implements ContainerService,
if (log.isDebugEnabled()) {
log.debug("Adding manually discovered resource [" + resource + "] to inventory...");
}
+ resource.setInventoryStatus(InventoryStatus.COMMITTED);
parentResource.addChildResource(resource);
initResourceContainer(resource);
}
commit 938e1f638b7058aa3f8accc7edd916ac7a75e5ed
Author: Greg Hinkle <ghinkle(a)redhat.com>
Date: Wed Apr 28 08:13:06 2010 -0400
remote agent install for gwt
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 6550626..2985e71 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -2706,18 +2706,10 @@
</schema-directSQL>
</schemaSpec>
-<<<<<<< HEAD
- <schemaSpec version="2.83">
+ <schemaSpec version="2.83">
<schema-directSQL>
<statement desc="Creating table RHQ_SUBJECT_ROLE_LDAP_MAP">
CREATE TABLE RHQ_SUBJECT_ROLE_LDAP_MAP ( SUBJECT_ID INTEGER, ROLE_ID INTEGER )
-=======
- <schemaSpec version="2.83">
- <!-- The following constraint change shortens the constraint name < 30 chars for Oracle. -->
- <schema-directSQL>
- <statement targetDBVendor="postgresql" desc="Dropping RHQ_SUBJECT_ROLE_LDAP_MAP constraint RHQ_SUBJECT_ROLE_LDAP_MAPPING_KEY.">
- ALTER TABLE RHQ_SUBJECT_ROLE_LDAP_MAP DROP CONSTRAINT RHQ_SUBJECT_ROLE_LDAP_MAPPING_KEY;
->>>>>>> New tag system for bundle system
</statement>
<statement desc="Creating composite PK for RHQ_SUBJECT_ROLE_LDAP_MAP">
ALTER TABLE RHQ_SUBJECT_ROLE_LDAP_MAP
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/install/remote/AgentInstallInfo.java b/modules/core/domain/src/main/java/org/rhq/core/domain/install/remote/AgentInstallInfo.java
new file mode 100644
index 0000000..c40440e
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/install/remote/AgentInstallInfo.java
@@ -0,0 +1,120 @@
+/*
+ * 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.core.domain.install.remote;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Greg Hinkle
+ */
+public class AgentInstallInfo implements Serializable {
+
+ private String serverAddress;
+ private String agentAddress;
+
+ private String path;
+ private String owner;
+ private String version;
+
+
+ public List<AgentInstallStep> steps = new ArrayList<AgentInstallStep>();
+
+ public static final String SETUP_PROP = "rhq.agent.configuration-setup-flag";
+
+
+ public static final String SERVER_ADDRESS_PROP = "rhq.agent.server.bind-address";
+ public static final String SERVER_PORT_PROP = "rhq.agent.server.bind-port";
+
+ public static final String AGENT_ADDRESS_PROP = "rhq.communications.connector.bind-address";
+ public static final String AGENT_PORT_PROP = "rhq.communications.connector.bind-port";
+
+ public static final int DEFAULT_SERVER_PORT = 7080;
+ public static final int DEFAULT_AGENT_PORT = 16163;
+
+
+ public AgentInstallInfo() {
+ }
+
+ public AgentInstallInfo(String serverAddress, String agentAddress) {
+ this.serverAddress = serverAddress;
+ this.agentAddress = agentAddress;
+ }
+
+ public AgentInstallInfo(String path, String owner, String version) {
+ this.path = path;
+ this.owner = owner;
+ this.version = version;
+ }
+
+ public String getPath() {
+ return path;
+ }
+
+ public void setPath(String path) {
+ this.path = path;
+ }
+
+ public String getOwner() {
+ return owner;
+ }
+
+ public void setOwner(String owner) {
+ this.owner = owner;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+
+ public void addStep(AgentInstallStep step) {
+ steps.add(step);
+ }
+
+ public List<AgentInstallStep> getSteps() {
+ return steps;
+ }
+
+
+
+
+ public String getConfigurationStartString() {
+ StringBuilder buf = new StringBuilder();
+
+ buf.append("-D").append(SERVER_ADDRESS_PROP).append("=").append(serverAddress);
+ buf.append(" ");
+
+ buf.append("-D").append(AGENT_ADDRESS_PROP).append("=").append(agentAddress);
+ buf.append(" ");
+
+ buf.append("-D").append(SETUP_PROP).append("=").append("true");
+ buf.append(" ");
+ buf.append("-d ");
+
+ return buf.toString();
+ }
+
+
+}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/install/remote/AgentInstallStep.java b/modules/core/domain/src/main/java/org/rhq/core/domain/install/remote/AgentInstallStep.java
new file mode 100644
index 0000000..91b1d8e
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/install/remote/AgentInstallStep.java
@@ -0,0 +1,63 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.install.remote;
+
+import java.io.Serializable;
+
+/**
+* @author Greg Hinkle
+*/
+public class AgentInstallStep implements Serializable {
+ int resultCode;
+ String command;
+ String description;
+ String result;
+ long time;
+
+ public AgentInstallStep() {
+ }
+
+ public AgentInstallStep(int resultCode, String command, String description, String result, long time) {
+ this.resultCode = resultCode;
+ this.command = command;
+ this.description = description;
+ this.result = result;
+ this.time = time;
+ }
+
+ public int getResultCode() {
+ return resultCode;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public String getCommand() {
+ return command;
+ }
+
+ public String getResult() {
+ return result;
+ }
+
+ public long getTime() {
+ return time;
+ }
+}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/install/remote/RemoteAccessInfo.java b/modules/core/domain/src/main/java/org/rhq/core/domain/install/remote/RemoteAccessInfo.java
new file mode 100644
index 0000000..67857ce
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/install/remote/RemoteAccessInfo.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.core.domain.install.remote;
+
+import java.io.Serializable;
+
+/**
+ * @author Greg Hinkle
+ */
+public class RemoteAccessInfo implements Serializable {
+
+ private String host, user, pass;
+ byte[] key;
+ private int port = 22;
+
+
+ public RemoteAccessInfo(String host, String user, byte[] key) {
+ this.host = host;
+ this.user = user;
+ this.key = key;
+ }
+
+ public RemoteAccessInfo(String host, String user, String pass) {
+ this(host, 22, user, pass);
+ }
+
+ public RemoteAccessInfo(String host, int port, String user, String pass) {
+ this.host = host;
+ this.port = port;
+ this.user = user;
+ this.pass = pass;
+ }
+
+ public RemoteAccessInfo() {
+
+ }
+
+ public String getHost() {
+ return host;
+ }
+
+ public void setHost(String host) {
+ this.host = host;
+ }
+
+ public int getPort() {
+ return port;
+ }
+
+ public void setPort(int port) {
+ this.port = port;
+ }
+
+ public String getUser() {
+ return user;
+ }
+
+ public void setUser(String user) {
+ this.user = user;
+ }
+
+ public String getPass() {
+ return pass;
+ }
+
+ public void setPass(String pass) {
+ this.pass = pass;
+ }
+
+ public byte[] getKey() {
+ return key;
+ }
+
+ public void setKey(byte[] key) {
+ this.key = key;
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml
index b980d6a..4faf4ff 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml
@@ -59,5 +59,6 @@
<servlet path="/AuthorizationGWTService" class="org.rhq.enterprise.gui.coregui.server.gwt.AuthorizationGWTServiceImpl"/>
<servlet path="/AvailabilityGWTService" class="org.rhq.enterprise.gui.coregui.server.gwt.AvailabilityGWTServiceImpl"/>
<servlet path="/TagGWTService" class="org.rhq.enterprise.gui.coregui.server.gwt.TagGWTServiceImpl"/>
+ <servlet path="/RemoteInstallGWTService" class="org.rhq.enterprise.gui.coregui.server.gwt.RemoteInstallGWTServiceImpl"/>
</module>
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/AdministrationView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/AdministrationView.java
index 913ff6c..5c31020 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/AdministrationView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/AdministrationView.java
@@ -36,6 +36,7 @@ import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.ViewId;
import org.rhq.enterprise.gui.coregui.client.ViewPath;
+import org.rhq.enterprise.gui.coregui.client.admin.agent.install.RemoteAgentInstallView;
import org.rhq.enterprise.gui.coregui.client.admin.roles.RolesView;
import org.rhq.enterprise.gui.coregui.client.admin.users.UsersView;
import org.rhq.enterprise.gui.coregui.client.components.FullHTMLPane;
@@ -238,8 +239,7 @@ public class AdministrationView extends HLayout implements BookmarkableView {
} else if ("Auto Discovery Queue".equals(page)) {
content = new ResourceAutodiscoveryView();
} else if ("Remote Agent Install".equals(page)) {
- // todo
- //content = new RemoteAgentInstallView();
+ content = new RemoteAgentInstallView();
}
} else if ("Configuration".equals(section)) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/agent/install/RemoteAgentInstallView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/agent/install/RemoteAgentInstallView.java
new file mode 100644
index 0000000..76c64a2
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/agent/install/RemoteAgentInstallView.java
@@ -0,0 +1,303 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.enterprise.gui.coregui.client.admin.agent.install;
+
+import java.util.ArrayList;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.types.Autofit;
+import com.smartgwt.client.types.ExpansionMode;
+import com.smartgwt.client.types.TitleOrientation;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.FormItemIfFunction;
+import com.smartgwt.client.widgets.form.fields.ButtonItem;
+import com.smartgwt.client.widgets.form.fields.CanvasItem;
+import com.smartgwt.client.widgets.form.fields.FormItem;
+import com.smartgwt.client.widgets.form.fields.HeaderItem;
+import com.smartgwt.client.widgets.form.fields.PasswordItem;
+import com.smartgwt.client.widgets.form.fields.SpacerItem;
+import com.smartgwt.client.widgets.form.fields.StaticTextItem;
+import com.smartgwt.client.widgets.form.fields.TextItem;
+import com.smartgwt.client.widgets.form.fields.events.ClickEvent;
+import com.smartgwt.client.widgets.form.fields.events.ClickHandler;
+import com.smartgwt.client.widgets.grid.ListGrid;
+import com.smartgwt.client.widgets.grid.ListGridField;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+import com.smartgwt.client.widgets.layout.VLayout;
+
+import org.rhq.core.domain.install.remote.AgentInstallInfo;
+import org.rhq.core.domain.install.remote.AgentInstallStep;
+import org.rhq.core.domain.measurement.MeasurementConverterClient;
+import org.rhq.core.domain.measurement.MeasurementUnits;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.gwt.RemoteInstallGWTServiceAsync;
+import org.rhq.core.domain.install.remote.RemoteAccessInfo;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message;
+
+/**
+ * @author Greg Hinkle
+ */
+public class RemoteAgentInstallView extends VLayout {
+
+ private RemoteInstallGWTServiceAsync remoteInstallService = GWTServiceLookup.getRemoteInstallService();
+
+ private DynamicForm form;
+ private VLayout agentInfoLayout;
+
+ public RemoteAgentInstallView() {
+ setMembersMargin(10);
+ }
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+
+
+ addMember(getConnectionForm());
+
+ agentInfoLayout = new VLayout();
+ agentInfoLayout.setWidth100();
+ addMember(agentInfoLayout);
+
+
+ }
+
+
+ DynamicForm getConnectionForm() {
+
+ form = new DynamicForm();
+ form.setWidth100();
+
+ HeaderItem connectionHeader = new HeaderItem();
+ connectionHeader.setValue("Connection Information");
+
+ TextItem host = new TextItem("host");
+ host.setRequired(true);
+
+ TextItem username = new TextItem("username");
+ username.setRequired(true);
+
+ PasswordItem password = new PasswordItem("password");
+// password.setRequired(true);
+
+
+ ButtonItem statusCheck = new ButtonItem("updateStatus", "Update Status");
+
+
+ final StaticTextItem agentStatus = new StaticTextItem("agentStatus", "Agent Status");
+ agentStatus.setRedrawOnChange(true);
+
+
+ statusCheck.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent clickEvent) {
+ if (form.validate()) {
+ agentStatusCheck();
+ }
+ }
+ });
+
+
+ ButtonItem startButton = new ButtonItem("start", "Start Agent");
+ startButton.setEndRow(false);
+// startButton.setShowIfCondition(new FormItemIfFunction() {
+// public boolean execute(FormItem formItem, Object o, DynamicForm dynamicForm) {
+// return form.getValue("agentStatus") != null && !"Agent Not Installed".equals(form.getValue("agentStatus"));
+// }
+// });
+ startButton.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent clickEvent) {
+ remoteInstallService.startAgent(getRemoteAccessInfo(), new AsyncCallback<String>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to start agent", caught);
+ }
+
+ public void onSuccess(String result) {
+ CoreGUI.getMessageCenter().notify(new Message("Agent successfully started.", Message.Severity.Info));
+ agentStatusCheck();
+ }
+ });
+ }
+ });
+
+
+ ButtonItem stopButton = new ButtonItem("stop", "Stop Agent");
+ stopButton.setStartRow(false);
+// stopButton.setShowIfCondition(new FormItemIfFunction() {
+// public boolean execute(FormItem formItem, Object o, DynamicForm dynamicForm) {
+// return form.getValue("agentStatus") != null && !"Agent Not Installed".equals(form.getValue("agentStatus"));
+// }
+// });
+ stopButton.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent clickEvent) {
+ remoteInstallService.stopAgent(getRemoteAccessInfo(), new AsyncCallback<String>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to stop agent", caught);
+ }
+
+ public void onSuccess(String result) {
+ CoreGUI.getMessageCenter().notify(new Message("Agent successfully stopped.", Message.Severity.Info));
+ agentStatusCheck();
+ }
+ });
+ }
+ });
+
+
+ ButtonItem installButton = new ButtonItem("install", "Install Agent");
+ installButton.setRedrawOnChange(true);
+// installButton.setShowIfCondition(new FormItemIfFunction() {
+// public boolean execute(FormItem formItem, Object o, DynamicForm dynamicForm) {
+// return form.getValue("agentStatus") != null && "Agent Not Installed".equals(form.getValue("agentStatus"));
+// }
+// });
+
+
+ installButton.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent clickEvent) {
+ remoteInstallService.installAgent(getRemoteAccessInfo(), "/tmp/rhqAgent", new AsyncCallback<AgentInstallInfo>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to install agent", caught);
+ }
+
+ public void onSuccess(AgentInstallInfo result) {
+ CoreGUI.getMessageCenter().notify(new Message("Agent successfully installed.", Message.Severity.Info));
+
+ for (Canvas child : agentInfoLayout.getChildren()) {
+ child.destroy();
+ }
+ agentInfoLayout.addMember(buildInstallInfoCanvas(result));
+ agentInfoLayout.markForRedraw();
+ agentStatusCheck();
+ }
+ });
+ }
+ });
+
+
+ form.setFields(connectionHeader, host, username, password, statusCheck, agentStatus, new SpacerItem(), startButton, stopButton, new SpacerItem(), installButton, new SpacerItem());
+
+ return form;
+ }
+
+ private void agentStatusCheck() {
+ remoteInstallService.agentStatus(getRemoteAccessInfo(), new AsyncCallback<String>() {
+ public void onFailure(Throwable caught) {
+ form.setValue("agentStatus", caught.getMessage());
+ }
+
+ public void onSuccess(String result) {
+ form.setValue("agentStatus", result);
+ }
+ });
+ }
+
+
+ private Canvas buildInstallInfoCanvas(AgentInstallInfo info) {
+
+ VLayout installInfo = new VLayout();
+ installInfo.setWidth100();
+
+ DynamicForm infoForm = new DynamicForm();
+ infoForm.setWidth100();
+ HeaderItem infoHeader = new HeaderItem();
+ infoHeader.setValue("Agent Installation Information");
+ StaticTextItem version = new StaticTextItem("version", "Version");
+ version.setValue(info.getVersion());
+
+ StaticTextItem path = new StaticTextItem("path", "Path");
+ path.setValue(info.getPath());
+
+ StaticTextItem owner = new StaticTextItem("owner", "Owner");
+ owner.setValue(info.getOwner());
+
+ StaticTextItem config = new StaticTextItem("config", "Configuration");
+ config.setValue(info.getConfigurationStartString());
+
+ infoForm.setFields(infoHeader, version, path, owner, config);
+
+ installInfo.addMember(infoForm);
+
+
+ ListGrid listGrid = new ListGrid() {
+ @Override
+ protected Canvas getExpansionComponent(ListGridRecord record) {
+ Canvas canvas = super.getExpansionComponent(record);
+ canvas.setPadding(5);
+ return canvas;
+ }
+ };
+ listGrid.setWidth(800);
+ listGrid.setHeight(500);
+ listGrid.setCanExpandRecords(true);
+ listGrid.setExpansionMode(ExpansionMode.DETAIL_FIELD);
+ listGrid.setDetailField("result");
+
+
+ listGrid.setAutoFitData(Autofit.VERTICAL);
+ ListGridField step = new ListGridField("description", "Step");
+ ListGridField resultCode = new ListGridField("resultCode", "Result Code", 90);
+ ListGridField time = new ListGridField("time", "Time", 90);
+
+
+ listGrid.setFields(step, resultCode, time);
+
+ listGrid.setData(getStepRecords(info));
+
+
+ installInfo.addMember(listGrid);
+
+ for (ListGridRecord rec : listGrid.getRecords()) {
+ listGrid.expandRecord(rec);
+ }
+
+ return installInfo;
+
+ }
+
+ private ListGridRecord[] getStepRecords(AgentInstallInfo info) {
+ ArrayList<ListGridRecord> steps = new ArrayList<ListGridRecord>();
+
+ for (AgentInstallStep step : info.getSteps()) {
+ ListGridRecord rec = new ListGridRecord();
+ rec.setAttribute("description", step.getDescription());
+ rec.setAttribute("result", step.getResult());
+ rec.setAttribute("resultCode", "" + step.getResultCode());
+ rec.setAttribute("time", MeasurementConverterClient.format((double) step.getTime(), MeasurementUnits.MILLISECONDS, true));
+ steps.add(rec);
+ }
+
+ return steps.toArray(new ListGridRecord[steps.size()]);
+ }
+
+
+ private RemoteAccessInfo getRemoteAccessInfo() {
+ RemoteAccessInfo info = new RemoteAccessInfo(
+ form.getValueAsString("host"),
+ form.getValueAsString("username"),
+ form.getValueAsString("password")
+ );
+ return info;
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java
index d251630..689c26f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java
@@ -92,6 +92,10 @@ public class GWTServiceLookup {
return secure(TagGWTServiceAsync.Util.getInstance());
}
+ public static RemoteInstallGWTServiceAsync getRemoteInstallService() {
+ return secure(RemoteInstallGWTServiceAsync.Util.getInstance());
+ }
+
private static <T> T secure(Object sdt) {
if (!(sdt instanceof ServiceDefTarget))
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/RemoteInstallGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/RemoteInstallGWTService.java
new file mode 100644
index 0000000..d25a9d3
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/RemoteInstallGWTService.java
@@ -0,0 +1,48 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.enterprise.gui.coregui.client.gwt;
+
+import com.google.gwt.user.client.rpc.RemoteService;
+
+import org.rhq.core.domain.install.remote.AgentInstallInfo;
+import org.rhq.core.domain.install.remote.RemoteAccessInfo;
+
+/**
+ * @author Greg Hinkle
+ */
+public interface RemoteInstallGWTService extends RemoteService {
+
+ // RemoteInstallManagerRemote
+ AgentInstallInfo agentInstallCheck(RemoteAccessInfo remoteAccessInfo);
+
+ AgentInstallInfo installAgent(RemoteAccessInfo remoteAccessInfo, String path);
+
+ String[] remotePathDiscover(RemoteAccessInfo remoteAccessInfo, String parentPath);
+
+ String startAgent(RemoteAccessInfo remoteAccessInfo);
+
+ String stopAgent(RemoteAccessInfo remoteAccessInfo);
+
+ String agentStatus(RemoteAccessInfo remoteAccessInfo);
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/RemoteInstallGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/RemoteInstallGWTServiceImpl.java
new file mode 100644
index 0000000..1a6af99
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/RemoteInstallGWTServiceImpl.java
@@ -0,0 +1,68 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.enterprise.gui.coregui.server.gwt;
+
+import org.rhq.core.domain.install.remote.AgentInstallInfo;
+import org.rhq.core.domain.install.remote.RemoteAccessInfo;
+import org.rhq.enterprise.gui.coregui.client.gwt.RemoteInstallGWTService;
+import org.rhq.enterprise.gui.coregui.server.util.SerialUtility;
+import org.rhq.enterprise.server.install.remote.RemoteInstallManagerLocal;
+import org.rhq.enterprise.server.util.LookupUtil;
+
+/**
+ * @author Greg Hinkle
+ */
+public class RemoteInstallGWTServiceImpl extends AbstractGWTServiceImpl implements RemoteInstallGWTService {
+
+ private RemoteInstallManagerLocal remoteInstallManager = LookupUtil.getRemoteInstallManager();
+
+ public AgentInstallInfo agentInstallCheck(RemoteAccessInfo remoteAccessInfo) {
+ return SerialUtility.prepare(remoteInstallManager.agentInstallCheck(getSessionSubject(), remoteAccessInfo),
+ "RemoteInstallService.agentInstallCheck");
+ }
+
+ public AgentInstallInfo installAgent(RemoteAccessInfo remoteAccessInfo, String path) {
+ return SerialUtility.prepare(remoteInstallManager.installAgent(getSessionSubject(), remoteAccessInfo, path),
+ "RemoteInstallService.installAgent");
+ }
+
+ public String[] remotePathDiscover(RemoteAccessInfo remoteAccessInfo, String parentPath) {
+ return SerialUtility.prepare((remoteInstallManager.remotePathDiscover(getSessionSubject(), remoteAccessInfo, parentPath)),
+ "RemoteInstallService.remotePathDiscover");
+ }
+
+ public String startAgent(RemoteAccessInfo remoteAccessInfo) {
+ return SerialUtility.prepare(remoteInstallManager.startAgent(getSessionSubject(), remoteAccessInfo),
+ "RemoteInstallService.startAgent");
+ }
+
+ public String stopAgent(RemoteAccessInfo remoteAccessInfo) {
+ return SerialUtility.prepare(remoteInstallManager.stopAgent(getSessionSubject(), remoteAccessInfo),
+ "RemoteInstallService.stopAgent");
+ }
+
+ public String agentStatus(RemoteAccessInfo remoteAccessInfo) {
+ return SerialUtility.prepare(remoteInstallManager.agentStatus(getSessionSubject(), remoteAccessInfo),
+ "RemoteInstallService.agentStatus");
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml b/modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml
index ce0e2eb..87b0f0e 100644
--- a/modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml
+++ b/modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml
@@ -80,6 +80,10 @@
<servlet-name>org.rhq.enterprise.gui.coregui.CoreGUI TagGWTService</servlet-name>
<servlet-class>org.rhq.enterprise.gui.coregui.server.gwt.TagGWTServiceImpl</servlet-class>
</servlet>
+ <servlet>
+ <servlet-name>org.rhq.enterprise.gui.coregui.CoreGUI RemoteInstallGWTService</servlet-name>
+ <servlet-class>org.rhq.enterprise.gui.coregui.server.gwt.RemoteInstallGWTServiceImpl</servlet-class>
+ </servlet>
<servlet-mapping>
<servlet-name>org.rhq.enterprise.gui.coregui.CoreGUI RoleGWTService</servlet-name>
@@ -151,4 +155,8 @@
<servlet-name>org.rhq.enterprise.gui.coregui.CoreGUI TagGWTService</servlet-name>
<url-pattern>/org.rhq.enterprise.gui.coregui.CoreGUI/TagGWTService</url-pattern>
</servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>org.rhq.enterprise.gui.coregui.CoreGUI RemoteInstallGWTService</servlet-name>
+ <url-pattern>/org.rhq.enterprise.gui.coregui.CoreGUI/RemoteInstallGWTService</url-pattern>
+ </servlet-mapping>
</web-app>
diff --git a/modules/enterprise/server/jar/pom.xml b/modules/enterprise/server/jar/pom.xml
index 6e9b09c..e718952 100644
--- a/modules/enterprise/server/jar/pom.xml
+++ b/modules/enterprise/server/jar/pom.xml
@@ -330,6 +330,12 @@
</dependency>
+ <dependency>
+ <groupId>com.jcraft</groupId>
+ <artifactId>jsch</artifactId>
+ <version>0.1.29</version>
+ </dependency>
+
<!--================ Test Deps ================-->
<dependency>
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/install/remote/RemoteInstallManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/install/remote/RemoteInstallManagerBean.java
new file mode 100644
index 0000000..4763ed5
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/install/remote/RemoteInstallManagerBean.java
@@ -0,0 +1,80 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.enterprise.server.install.remote;
+
+import javax.ejb.Stateless;
+
+import org.rhq.core.domain.install.remote.AgentInstallInfo;
+import org.rhq.core.domain.install.remote.RemoteAccessInfo;
+import org.rhq.enterprise.server.authz.RequiredPermission;
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.authz.Permission;
+
+/**
+ * @author Greg Hinkle
+ */
+@Stateless
+public class RemoteInstallManagerBean implements RemoteInstallManagerLocal, RemoteInstallManagerRemote {
+
+
+ @RequiredPermission(Permission.MANAGE_INVENTORY)
+ public AgentInstallInfo agentInstallCheck(Subject subject, RemoteAccessInfo remoteAccessInfo) {
+ SSHInstallUtility sshUtil = new SSHInstallUtility(remoteAccessInfo);
+
+ return sshUtil.installAgent();
+ }
+
+ @RequiredPermission(Permission.MANAGE_INVENTORY)
+ public AgentInstallInfo installAgent(Subject subject, RemoteAccessInfo remoteAccessInfo, String path) {
+ SSHInstallUtility sshUtil = new SSHInstallUtility(remoteAccessInfo);
+
+ return sshUtil.installAgent();
+ }
+
+ @RequiredPermission(Permission.MANAGE_INVENTORY)
+ public String[] remotePathDiscover(Subject subject, RemoteAccessInfo remoteAccessInfo, String parentPath) {
+ SSHInstallUtility ssh = new SSHInstallUtility(remoteAccessInfo);
+ ssh.connect();
+ return ssh.pathDiscovery(parentPath);
+ }
+
+ @RequiredPermission(Permission.MANAGE_INVENTORY)
+ public String startAgent(Subject subject, RemoteAccessInfo remoteAccessInfo) {
+ SSHInstallUtility sshUtil = new SSHInstallUtility(remoteAccessInfo);
+ return sshUtil.agentStart();
+ }
+
+ @RequiredPermission(Permission.MANAGE_INVENTORY)
+ public String stopAgent(Subject subject, RemoteAccessInfo remoteAccessInfo) {
+ SSHInstallUtility sshUtil = new SSHInstallUtility(remoteAccessInfo);
+ return sshUtil.agentStop();
+ }
+
+ public String agentStatus(Subject subject, RemoteAccessInfo remoteAccessInfo) {
+ if (remoteAccessInfo.getHost() == null) {
+ return "Enter a host";
+ }
+ SSHInstallUtility sshUtil = new SSHInstallUtility(remoteAccessInfo);
+ return sshUtil.agentStatus();
+ }
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/install/remote/RemoteInstallManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/install/remote/RemoteInstallManagerLocal.java
new file mode 100644
index 0000000..c50dd52
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/install/remote/RemoteInstallManagerLocal.java
@@ -0,0 +1,50 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.enterprise.server.install.remote;
+
+import javax.ejb.Local;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.install.remote.AgentInstallInfo;
+import org.rhq.core.domain.install.remote.RemoteAccessInfo;
+
+/**
+ * @author Greg Hinkle
+ */
+@Local
+public interface RemoteInstallManagerLocal {
+
+
+ AgentInstallInfo agentInstallCheck(Subject subject, RemoteAccessInfo remoteAccessInfo);
+
+ AgentInstallInfo installAgent(Subject subject, RemoteAccessInfo remoteAccessInfo, String path);
+
+ String[] remotePathDiscover(Subject subject, RemoteAccessInfo remoteAccessInfo, String parentPath);
+
+ String startAgent(Subject subject, RemoteAccessInfo remoteAccessInfo);
+
+ String stopAgent(Subject subject, RemoteAccessInfo remoteAccessInfo);
+
+ String agentStatus(Subject subject, RemoteAccessInfo remoteAccessInfo);
+
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/install/remote/RemoteInstallManagerRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/install/remote/RemoteInstallManagerRemote.java
new file mode 100644
index 0000000..cca5c4e
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/install/remote/RemoteInstallManagerRemote.java
@@ -0,0 +1,50 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.enterprise.server.install.remote;
+
+import javax.ejb.Remote;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.install.remote.AgentInstallInfo;
+import org.rhq.core.domain.install.remote.RemoteAccessInfo;
+
+/**
+ * @author Greg Hinkle
+ */
+@Remote
+public interface RemoteInstallManagerRemote {
+
+
+ AgentInstallInfo agentInstallCheck(Subject subject, RemoteAccessInfo remoteAccessInfo);
+
+ AgentInstallInfo installAgent(Subject subject, RemoteAccessInfo remoteAccessInfo, String path);
+
+ String[] remotePathDiscover(Subject subject, RemoteAccessInfo remoteAccessInfo, String parentPath);
+
+ String startAgent(Subject subject, RemoteAccessInfo remoteAccessInfo);
+
+ String stopAgent(Subject subject, RemoteAccessInfo remoteAccessInfo);
+
+ String agentStatus(Subject subject, RemoteAccessInfo remoteAccessInfo);
+
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/install/remote/SSHFileSend.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/install/remote/SSHFileSend.java
new file mode 100644
index 0000000..ece76af
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/install/remote/SSHFileSend.java
@@ -0,0 +1,149 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.enterprise.server.install.remote;
+
+import com.jcraft.jsch.Channel;
+import com.jcraft.jsch.ChannelExec;
+import com.jcraft.jsch.Session;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+/**
+ * @author Greg Hinkle
+ */
+public class SSHFileSend {
+
+
+ public static boolean sendFile(Session session, String sourceFilename, String destFilename) {
+ FileInputStream fis = null;
+
+ try {
+
+ String command = "scp -p -t " + destFilename;
+ Channel channel = session.openChannel("exec");
+ ((ChannelExec) channel).setCommand(command);
+
+ OutputStream out = channel.getOutputStream();
+ InputStream in = channel.getInputStream();
+
+ channel.connect();
+
+ if (checkAck(in) != 0) {
+ return false;
+ }
+
+ //send "C0644 filesize filename" where filename doesn't contain a /
+ long filesize = (new File(sourceFilename)).length();
+ command = "C0644 " + filesize + " ";
+ if (sourceFilename.lastIndexOf('/') > 0) {
+ command += sourceFilename.substring(sourceFilename.lastIndexOf('/') + 1);
+ } else {
+ command += sourceFilename;
+ }
+ command += "\n";
+
+ out.write(command.getBytes());
+ out.flush();
+
+ if (checkAck(in) != 0) {
+ return false;
+ }
+
+ //send the contents of the source file
+ fis = new FileInputStream(sourceFilename);
+ byte[] buf = new byte[1024];
+ while (true) {
+ int len = fis.read(buf, 0, buf.length);
+
+ if (len <= 0) {
+ break;
+ }
+
+ out.write(buf, 0, len);
+ }
+
+ fis.close();
+ fis = null;
+
+ //send '\0' to end it
+ buf[0] = 0;
+ out.write(buf, 0, 1);
+ out.flush();
+
+ if (checkAck(in) != 0) {
+ return false;
+ }
+
+ out.close();
+
+ channel.disconnect();
+
+ return true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ try {
+ if (fis != null) {
+ fis.close();
+ }
+ } catch (Exception ee) {
+ ee.printStackTrace();
+ }
+ }
+
+ return false;
+ }
+
+
+ public static int checkAck(InputStream in) throws IOException {
+ int b = in.read();
+ // b may be 0 for success,
+ // 1 for error,
+ // 2 for fatal error,
+ // -1
+ if (b == 0) return b;
+ if (b == -1) return b;
+
+ if (b == 1 || b == 2) {
+ StringBuffer sb = new StringBuffer();
+ int c;
+ do {
+ c = in.read();
+ sb.append((char) c);
+ }
+ while (c != '\n');
+ if (b == 1) { // error
+ System.out.print(sb.toString());
+ }
+ if (b == 2) { // fatal error
+ System.out.print(sb.toString());
+ }
+ }
+ return b;
+ }
+
+
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/install/remote/SSHInstallUtility.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/install/remote/SSHInstallUtility.java
new file mode 100644
index 0000000..3f94c86
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/install/remote/SSHInstallUtility.java
@@ -0,0 +1,351 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.enterprise.server.install.remote;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ByteArrayOutputStream;
+
+import com.jcraft.jsch.Channel;
+import com.jcraft.jsch.ChannelExec;
+import com.jcraft.jsch.JSch;
+import com.jcraft.jsch.JSchException;
+import com.jcraft.jsch.Session;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.core.domain.install.remote.AgentInstallInfo;
+import org.rhq.core.domain.install.remote.AgentInstallStep;
+import org.rhq.core.domain.install.remote.RemoteAccessInfo;
+import org.rhq.core.util.file.FileUtil;
+import org.rhq.enterprise.server.util.LookupUtil;
+
+/**
+ * @author Greg Hinkle
+ */
+public class SSHInstallUtility {
+
+ static final int DEFAULT_BUFFER_SIZE = 4096;
+ static final long TIMEOUT = 10000L;
+ static final long POLL_TIMEOUT = 1000L;
+
+ private Log log = LogFactory.getLog(SSHInstallUtility.class);
+
+ private RemoteAccessInfo accessInfo;
+ private Session session;
+
+ private String agentDestination = "/tmp/rhqAgent"; // todo: Make configurable
+
+
+ private String agentFile = "rhq-enterprise-agent-3.0.0-SNAPSHOT.jar"; // Corrected below
+ private String agentPath = "/projects/rhq/dev-container/jbossas/server/default/deploy/rhq.ear/rhq-downloads/rhq-agent/" + agentFile; // corrected below
+
+
+ public SSHInstallUtility(RemoteAccessInfo accessInfo) {
+ this.accessInfo = accessInfo;
+
+ try {
+ File agentBinaryFile = LookupUtil.getAgentManager().getAgentUpdateBinaryFile();
+ agentPath = agentBinaryFile.getCanonicalPath();
+ agentFile = agentBinaryFile.getName();
+ } catch (Exception e) {
+ // Could not find agent file, leave the default
+ log.warn("Failed agent binary file lookup", e);
+ }
+
+ if (!new File(agentPath).exists()) {
+ throw new RuntimeException("Unable to find agent binary file for installation at [" + agentPath + "]");
+ }
+
+ connect();
+ }
+
+
+ public void connect() {
+ try {
+ JSch jsch = new JSch();
+
+
+// if (accessInfo.getKey() != null) {
+ jsch.addIdentity("/Users/ghinkle/.ssh/ghinkleawskey.pem");
+
+// }
+
+ session = jsch.getSession(accessInfo.getUser(), accessInfo.getHost(), 22); // accessInfo.getPort());
+
+ if (accessInfo.getPass() != null) {
+ session.setPassword(accessInfo.getPass());
+ }
+
+ java.util.Properties config = new java.util.Properties();
+ config.put("StrictHostKeyChecking", "no");
+ session.setConfig(config);
+
+ //session.connect();
+ session.connect(30000); // making a connection with timeout.
+ } catch (JSchException e) {
+ e.printStackTrace();
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void disconnect() {
+ session.disconnect();
+ }
+
+
+ public String[] pathDiscovery(String parentPath) {
+ String full = executeCommand("ls" + parentPath);
+ return full.split("\n");
+ }
+
+
+ private String executeCommand(String command, String description) {
+ return executeCommand(command, description, new AgentInstallInfo(null, null));
+ }
+
+
+ private String executeCommand(String command, String description, AgentInstallInfo info) {
+ log.info("Running: " + description);
+ long start = System.currentTimeMillis();
+ String result = null;
+ try {
+ result = executeCommand(command);
+ info.addStep(new AgentInstallStep(0, command, description, result, (System.currentTimeMillis() - start)));
+ } catch (ExecuteException e) {
+ info.addStep(new AgentInstallStep(e.errorCode, command, e.message, description, (System.currentTimeMillis() - start)));
+ }
+ log.info("Result [" + description + "]: " + result);
+ return result;
+ }
+
+
+ private String executeCommand(String command) {
+ ChannelExec channel = null;
+ int exitStatus = 0;
+
+ InputStream is = null;
+ InputStream es = null;
+
+ try {
+ channel = (ChannelExec) session.openChannel("exec");
+ ((ChannelExec) channel).setCommand(command);
+
+ is = channel.getInputStream();
+ es = channel.getErrStream();
+
+ channel.connect(10000); // connect and execute command
+
+ String out = read(is, channel);
+ String err = read(es, channel);
+
+ // System.out.println("Output: " + out);
+ if (err.length() > 0) {
+ // System.out.println("Error [" + channel.getExitStatus() + "]: " + err);
+ if (channel.getExitStatus() != 0) {
+ throw new ExecuteException(channel.getExitStatus(), err);
+ } else if (out.length() == 0) {
+ return err;
+ }
+ }
+ return out;
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ try {
+ is.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ try {
+ es.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ if (channel != null) {
+ channel.disconnect();
+ }
+ }
+ return "exit: " + exitStatus;
+ }
+
+
+ public String read(InputStream is, Channel channel) throws IOException {
+ // read command output
+ byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ final long endTime = System.currentTimeMillis() + TIMEOUT;
+ while (System.currentTimeMillis() < endTime) {
+ while (is.available() > 0) {
+ int count = is.read(buffer, 0, DEFAULT_BUFFER_SIZE);
+ if (count >= 0) {
+ bos.write(buffer, 0, count);
+ } else {
+ break;
+ }
+ }
+ if (channel.isClosed()) {
+ // int exitStatus = channel.getExitStatus();
+ // System.out.println("exit status: " + exitStatus);
+ break;
+ }
+ try {
+ Thread.sleep(POLL_TIMEOUT);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ return bos.toString();
+ }
+
+
+ public String read2(BufferedReader reader) throws IOException {
+ StringBuilder buf = new StringBuilder();
+ while (true) {
+ String line = reader.readLine();
+ if (line == null) {
+ break;
+ }
+ buf.append(line + "\n");
+ }
+ return buf.toString();
+ }
+
+ public String agentStop() {
+ String agentWrapperScript = agentDestination + "/rhq-agent/bin/rhq-agent-wrapper.sh ";
+
+ return executeCommand(agentWrapperScript + " stop", "Agent Stop");
+ }
+
+ public String agentStart() {
+ String agentWrapperScript = agentDestination + "/rhq-agent/bin/rhq-agent-wrapper.sh ";
+
+ return executeCommand(agentWrapperScript + " start", "Agent Start");
+ }
+
+ public String agentStatus() {
+ String agentWrapperScript = agentDestination + "/rhq-agent/bin/rhq-agent-wrapper.sh ";
+
+
+ String value = executeCommand("if [ -f " + agentWrapperScript + " ]; then echo \"exists\"; fi");
+ if (value == null || value.length() == 0) {
+ return "Agent Not Installed";
+ }
+
+ return executeCommand(agentWrapperScript + " status", "Agent Status");
+ }
+
+ public AgentInstallInfo installAgent() {
+
+
+ AgentInstallInfo info = new AgentInstallInfo(agentDestination, accessInfo.getUser(), "3.0.0-SNAPSHOT");
+
+
+ executeCommand("uname -a", "Machine uname", info);
+
+ executeCommand("java -version", "Java Version Check", info);
+
+ executeCommand("mkdir -p " + agentDestination, "Create Agent Install Directory", info);
+
+
+ log.info("Copying Agent Distribution");
+ long start = System.currentTimeMillis();
+ boolean fileSent = SSHFileSend.sendFile(session, agentPath, agentDestination);
+ info.addStep(new AgentInstallStep(0, "scp agent-installer", "Remote copy the agent distribution", fileSent ? "Success" : "Failed", (System.currentTimeMillis() - start)));
+ log.info("Agent Distribution Copied");
+
+
+ executeCommand("cd " + agentDestination, "Change to install directory", info);
+
+ executeCommand("java -jar " + agentDestination + "/" + agentFile + " --install=" + agentDestination, "Install Agent", info);
+
+
+ String serverAddress = LookupUtil.getCloudManager().getAllCloudServers().get(0).getAddress();
+
+ System.out.println("Install an agent at " + accessInfo.getHost() + " point to the server " + serverAddress);
+
+
+ AgentInstallInfo agentInfo = new AgentInstallInfo(serverAddress, accessInfo.getHost());
+
+ String agentScript = agentDestination + "/rhq-agent/bin/rhq-agent.sh ";
+ String agentWrapperScript = agentDestination + "/rhq-agent/bin/rhq-agent-wrapper.sh ";
+
+
+ String properties = agentInfo.getConfigurationStartString();
+
+ // Tell the script to store a pid file to make the wrapper script work
+ String pidFileProp = "export RHQ_AGENT_IN_BACKGROUND=" + agentDestination + "/rhq-agent/bin/rhq-agent.pid";
+
+ String startCommand = pidFileProp + " ; nohup " + agentScript + properties + "&";
+ executeCommand(startCommand, "Agent Start With Configuration", info);
+
+
+ return info;
+ }
+
+
+ public static class ExecuteException extends RuntimeException {
+ int errorCode;
+ String message;
+
+ public ExecuteException(int errorCode, String message) {
+ this.errorCode = errorCode;
+ this.message = message;
+ }
+ }
+
+
+ public static void main(String[] args) throws IOException {
+
+ String pass = null;
+ if (args.length > 2) {
+ pass = args[2];
+ }
+ RemoteAccessInfo info = new RemoteAccessInfo(args[0], args[1], pass);
+
+ SSHInstallUtility ssh = new SSHInstallUtility(info);
+
+ System.out.println("Agent status: " + ssh.agentStatus());
+
+ System.out.println("Set server address: " + ssh.executeCommand("echo '71.162.145.95 ghinkle' >> /etc/hosts"));
+
+ ssh.agentStop();
+
+ ssh.installAgent();
+
+ ssh.agentStatus();
+
+ ssh.agentStop();
+ ssh.agentStatus();
+ ssh.agentStart();
+
+ ssh.disconnect();
+ }
+
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
index 39b2c47..9367bdc 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
@@ -107,6 +107,8 @@ import org.rhq.enterprise.server.entitlement.EntitlementManagerBean;
import org.rhq.enterprise.server.entitlement.EntitlementManagerLocal;
import org.rhq.enterprise.server.event.EventManagerBean;
import org.rhq.enterprise.server.event.EventManagerLocal;
+import org.rhq.enterprise.server.install.remote.RemoteInstallManagerBean;
+import org.rhq.enterprise.server.install.remote.RemoteInstallManagerLocal;
import org.rhq.enterprise.server.measurement.AvailabilityManagerBean;
import org.rhq.enterprise.server.measurement.AvailabilityManagerLocal;
import org.rhq.enterprise.server.measurement.CallTimeDataManagerBean;
@@ -478,6 +480,10 @@ public final class LookupUtil {
return lookupLocal(CacheConsistencyManagerBean.class);
}
+ public static RemoteInstallManagerLocal getRemoteInstallManager() {
+ return lookupLocal(RemoteInstallManagerBean.class);
+ }
+
public static ResourceMetadataManagerLocal getResourceMetadataManager() {
return lookupLocal(ResourceMetadataManagerBean.class);
}
@@ -669,4 +675,4 @@ public final class LookupUtil {
return lookupLocal(LdapGroupManagerBean.class);
}
-}
\ No newline at end of file
+}
commit 1fae5bf95800ffc0b803f00a9ba9e4b364cd2c6e
Author: Greg Hinkle <ghinkle(a)redhat.com>
Date: Mon Apr 26 15:17:53 2010 -0400
dashboard tweaks
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java
index 14334e7..944a612 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java
@@ -100,9 +100,10 @@ public class DashboardsView extends VLayout {
StoredPortlet graph = new StoredPortlet("ghinkle (MAC OS X) CPU", GraphPortlet.KEY, 250);
col1.add(graph);
- StoredPortlet platformSummary = new StoredPortlet("Platform Summary", PlatformPortletView.KEY, 300);
- col2.add(platformSummary);
-
+ // Experimental
+// StoredPortlet platformSummary = new StoredPortlet("Platform Summary", PlatformPortletView.KEY, 300);
+// col2.add(platformSummary);
+//
StoredPortlet discoveryQueue = new StoredPortlet("Discovery Queue", AutodiscoveryPortlet.KEY, 250);
col2.add(discoveryQueue);
commit 345d917cabf93f72ed07c0cc69c6f5a2bb4efae4
Author: Greg Hinkle <ghinkle(a)redhat.com>
Date: Mon Apr 26 15:16:59 2010 -0400
Tag editor component
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tagging/TagEditorView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tagging/TagEditorView.java
new file mode 100644
index 0000000..91bbbde
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tagging/TagEditorView.java
@@ -0,0 +1,189 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.enterprise.gui.coregui.client.components.tagging;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.Map;
+import java.util.Set;
+
+import com.google.gwt.event.dom.client.KeyCodes;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.google.gwt.user.client.ui.HorizontalPanel;
+import com.smartgwt.client.types.TextMatchStyle;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.HTMLFlow;
+import com.smartgwt.client.widgets.Img;
+import com.smartgwt.client.widgets.events.ClickEvent;
+import com.smartgwt.client.widgets.events.ClickHandler;
+import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.fields.ComboBoxItem;
+import com.smartgwt.client.widgets.form.fields.events.BlurEvent;
+import com.smartgwt.client.widgets.form.fields.events.BlurHandler;
+import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
+import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
+import com.smartgwt.client.widgets.form.fields.events.KeyPressEvent;
+import com.smartgwt.client.widgets.form.fields.events.KeyPressHandler;
+import com.smartgwt.client.widgets.layout.HLayout;
+
+import org.rhq.core.domain.tagging.Tag;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+
+/**
+ * @author Greg Hinkle
+ */
+public class TagEditorView extends HLayout {
+
+ private LinkedHashSet<Tag> tags = new LinkedHashSet<Tag>();
+
+ private boolean editing = false;
+
+ private DynamicForm form;
+ private boolean readOnly;
+ private TagsChangedCallback callback;
+
+ public TagEditorView(Set<Tag> tags, boolean readOnly, TagsChangedCallback callback) {
+ if (tags != null) {
+ this.tags.addAll(tags);
+ }
+ this.readOnly = readOnly;
+ this.callback = callback;
+ }
+
+ @Override
+ protected void onDraw() {
+ super.onDraw();
+
+ setup();
+ }
+
+
+ private void setup() {
+ for (Canvas child : getChildren()) {
+ child.destroy();
+ }
+
+ HTMLFlow title = new HTMLFlow("<b>Tags:</b>");
+ title.setAutoWidth();
+ addMember(title);
+
+ for (final Tag tag : tags) {
+ HTMLFlow tagString = new HTMLFlow(tag.toString());
+ tagString.setAutoWidth();
+ addMember(tagString);
+ if (editing) {
+ Img remove = new Img("[skin]/images/actions/remove.png", 16, 16);
+ remove.setTooltip("Click to remove this tag");
+ remove.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent clickEvent) {
+ tags.remove(tag);
+ TagEditorView.this.setup();
+ }
+ });
+ addMember(remove);
+ }
+
+ Canvas spacer = new Canvas();
+ spacer.setWidth(8);
+ addMember(spacer);
+ }
+
+ if (editing) {
+ form = new DynamicForm();
+ ComboBoxItem tagInput = new ComboBoxItem("tag");
+ tagInput.setShowTitle(false);
+ tagInput.setHideEmptyPickList(true);
+ tagInput.setOptionDataSource(new TaggingDataSource());
+ tagInput.setValueField("tag");
+ tagInput.setDisplayField("tag");
+ tagInput.setType("comboBox");
+ tagInput.setTextMatchStyle(TextMatchStyle.SUBSTRING);
+ tagInput.setTooltip("Enter a tag in the format \"(namespace:)(semantic=)tagname\" (e.g. it:env=QA, or owner=John)");
+ tagInput.addBlurHandler(new BlurHandler() {
+ public void onBlur(BlurEvent blurEvent) {
+ String tag = form.getValueAsString("tag");
+ if (tag != null) {
+ Tag newTag = new Tag(tag);
+ tags.add(newTag);
+ TagEditorView.this.setup();
+ }
+ }
+ });
+ tagInput.addKeyPressHandler(new KeyPressHandler() {
+ public void onKeyPress(KeyPressEvent event) {
+ if ((event.getCharacterValue() != null) && (event.getCharacterValue() == KeyCodes.KEY_ENTER)) {
+ String tag = form.getValueAsString("tag");
+ if (tag != null) {
+ Tag newTag = new Tag(tag);
+ tags.add(newTag);
+ TagEditorView.this.setup();
+ }
+ }
+ }
+ });
+
+ form.setFields(tagInput);
+ addMember(form);
+ }
+
+
+ if (!readOnly) {
+ Img modeImg = new Img("[skin]/images/actions/" + (editing ? "approve" : "edit") + ".png", 16, 16);
+ modeImg.setTooltip(editing ? "Click to save edits" : "Click to edit tags");
+ modeImg.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent clickEvent) {
+
+ if (editing) {
+ save();
+ // save the tags
+ /* GWTServiceLookup.getTagService().addTags(tags, new AsyncCallback<Set<Tag>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Tag add failed", caught);
+ HashMap<String, String> errors = new HashMap<String, String>();
+ errors.put("tag", "Tag add failed");
+ form.setErrors(errors, true);
+ }
+
+ public void onSuccess(Set<Tag> result) {
+ editing = !editing;
+ tags.addAll(result);
+ TagEditorView.this.setup();
+ }
+ });*/
+ } else {
+ editing = !editing;
+ TagEditorView.this.setup();
+ }
+ }
+ });
+ addMember(modeImg);
+ }
+ }
+
+ private void save() {
+ this.callback.tagsChanged(tags);
+ TagEditorView.this.setup();
+ }
+}
commit dddd1229ef9a88c7b64dc9b99be270a6e8012a74
Author: Greg Hinkle <ghinkle(a)redhat.com>
Date: Mon Apr 26 15:16:36 2010 -0400
Tag core domain, service, gwt services, editing component
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/Bundle.java b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/Bundle.java
index 11a1b2c..f14fb59 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/Bundle.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/Bundle.java
@@ -24,6 +24,7 @@ package org.rhq.core.domain.bundle;
import java.io.Serializable;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -184,6 +185,21 @@ public class Bundle implements Serializable {
this.tags = tags;
}
+ public void addTag(Tag tag) {
+ if (this.tags == null) {
+ tags = new HashSet<Tag>();
+ }
+ tags.add(tag);
+ }
+
+ public boolean removeTag(Tag tag) {
+ if (tags != null) {
+ return tags.remove(tag);
+ } else {
+ return false;
+ }
+ }
+
@Override
public String toString() {
return "Bundle[id=" + id + ",name=" + name + ",bundleType=" + bundleType + ",packageType=" + packageType + "]";
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeployment.java b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeployment.java
index 081815b..e86236d 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeployment.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeployment.java
@@ -24,6 +24,7 @@ package org.rhq.core.domain.bundle;
import java.io.Serializable;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -221,6 +222,21 @@ public class BundleDeployment implements Serializable {
this.tags = tags;
}
+ public void addTag(Tag tag) {
+ if (this.tags == null) {
+ tags = new HashSet<Tag>();
+ }
+ tags.add(tag);
+ }
+
+ public boolean removeTag(Tag tag) {
+ if (tags != null) {
+ return tags.remove(tag);
+ } else {
+ return false;
+ }
+ }
+
@Override
public String toString() {
return "BundleDeployment[id=" + id + ", name=" + name + "]";
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersion.java b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersion.java
index 55cffad..d8b09bb 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersion.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersion.java
@@ -24,6 +24,7 @@ package org.rhq.core.domain.bundle;
import java.io.Serializable;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -243,6 +244,21 @@ public class BundleVersion implements Serializable {
this.tags = tags;
}
+ public void addTag(Tag tag) {
+ if (this.tags == null) {
+ tags = new HashSet<Tag>();
+ }
+ tags.add(tag);
+ }
+
+ public boolean removeTag(Tag tag) {
+ if (tags != null) {
+ return tags.remove(tag);
+ } else {
+ return false;
+ }
+ }
+
@Override
public String toString() {
return "BundleVersion[id=" + id + ",name=" + name + ",version=" + version + ",bundle=" + bundle + "]";
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java
index d77e1bf..23186e5 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java
@@ -1701,6 +1701,20 @@ public class Resource implements Comparable<Resource>, Serializable {
this.tags = tags;
}
+ public void addTag(Tag tag) {
+ if (this.tags == null) {
+ tags = new HashSet<Tag>();
+ }
+ tags.add(tag);
+ }
+ public boolean removeTag (Tag tag) {
+ if (tags != null) {
+ return tags.remove (tag);
+ } else {
+ return false;
+ }
+ }
+
public int compareTo(Resource that) {
return this.name.compareTo(that.getName());
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ResourceGroup.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ResourceGroup.java
index 35804c8..abe2ca0 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ResourceGroup.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ResourceGroup.java
@@ -657,6 +657,21 @@ public class ResourceGroup extends Group {
this.tags = tags;
}
+ public void addTag(Tag tag) {
+ if (this.tags == null) {
+ tags = new HashSet<Tag>();
+ }
+ tags.add(tag);
+ }
+
+ public boolean removeTag(Tag tag) {
+ if (tags != null) {
+ return tags.remove(tag);
+ } else {
+ return false;
+ }
+ }
+
@PrePersist
@PreUpdate
void onPersist() {
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/tagging/Tag.java b/modules/core/domain/src/main/java/org/rhq/core/domain/tagging/Tag.java
index 623ec87..c8c7db6 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/tagging/Tag.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/tagging/Tag.java
@@ -23,6 +23,7 @@
package org.rhq.core.domain.tagging;
import java.io.Serializable;
+import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
@@ -72,24 +73,24 @@ public class Tag implements Serializable {
@Column(name = "NAME", nullable = false)
private String name;
- @JoinTable(name = "RHQ_TAGGING_RESOURCE_MAP", joinColumns = { @JoinColumn(name = "TAG_ID") }, inverseJoinColumns = { @JoinColumn(name = "RESOURCE_ID") })
+ @JoinTable(name = "RHQ_TAGGING_RESOURCE_MAP", joinColumns = {@JoinColumn(name = "TAG_ID")}, inverseJoinColumns = {@JoinColumn(name = "RESOURCE_ID")})
@ManyToMany
private Set<Resource> resources;
- @JoinTable(name = "RHQ_TAGGING_RES_GRP_MAP", joinColumns = { @JoinColumn(name = "TAG_ID") }, inverseJoinColumns = { @JoinColumn(name = "RESOURCE_GROUP_ID") })
+ @JoinTable(name = "RHQ_TAGGING_RES_GRP_MAP", joinColumns = {@JoinColumn(name = "TAG_ID")}, inverseJoinColumns = {@JoinColumn(name = "RESOURCE_GROUP_ID")})
@ManyToMany
private Set<ResourceGroup> resourceGroups;
- @JoinTable(name = "RHQ_TAGGING_BUNDLE_MAP", joinColumns = { @JoinColumn(name = "TAG_ID") }, inverseJoinColumns = { @JoinColumn(name = "BUNDLE_ID") })
+ @JoinTable(name = "RHQ_TAGGING_BUNDLE_MAP", joinColumns = {@JoinColumn(name = "TAG_ID")}, inverseJoinColumns = {@JoinColumn(name = "BUNDLE_ID")})
@ManyToMany
private Set<Bundle> bundles;
- @JoinTable(name = "RHQ_TAGGING_BND_VER_MAP", joinColumns = { @JoinColumn(name = "TAG_ID") }, inverseJoinColumns = { @JoinColumn(name = "BUNDLE_VERSION_ID") })
+ @JoinTable(name = "RHQ_TAGGING_BND_VER_MAP", joinColumns = {@JoinColumn(name = "TAG_ID")}, inverseJoinColumns = {@JoinColumn(name = "BUNDLE_VERSION_ID")})
@ManyToMany
private Set<BundleVersion> bundleVersions;
- @JoinTable(name = "RHQ_TAGGING_BND_DEP_MAP", joinColumns = { @JoinColumn(name = "TAG_ID") }, inverseJoinColumns = { @JoinColumn(name = "BUNDLE_DEPLOYMENT_ID") })
+ @JoinTable(name = "RHQ_TAGGING_BND_DEP_MAP", joinColumns = {@JoinColumn(name = "TAG_ID")}, inverseJoinColumns = {@JoinColumn(name = "BUNDLE_DEPLOYMENT_ID")})
@ManyToMany
private Set<BundleDeployment> bundleDeployments;
@@ -146,6 +147,137 @@ public class Tag implements Serializable {
}
+ public Set<Resource> getResources() {
+ return resources;
+ }
+
+ public void setResources(Set<Resource> resources) {
+ this.resources = resources;
+ }
+
+ public void addResource(Resource resource) {
+ if (resources == null) {
+ resources = new HashSet<Resource>();
+ }
+ resource.addTag(this);
+ resources.add(resource);
+ }
+
+ public boolean removeResource(Resource resource) {
+ if (resources != null) {
+ resource.removeTag(this);
+ return resources.remove(resource);
+ } else {
+ return false;
+ }
+ }
+
+
+ public Set<ResourceGroup> getResourceGroups() {
+ return resourceGroups;
+ }
+
+ public void setResourceGroups(Set<ResourceGroup> resourceGroups) {
+ this.resourceGroups = resourceGroups;
+ }
+
+ public void addResourceGroup(ResourceGroup resourceGroup) {
+ if (resourceGroups == null) {
+ resourceGroups = new HashSet<ResourceGroup>();
+ }
+ resourceGroup.addTag(this);
+ resourceGroups.add(resourceGroup);
+ }
+
+ public boolean removeResourceGroup(ResourceGroup resourceGroup) {
+ if (resourceGroups != null) {
+ resourceGroup.removeTag(this);
+ return resourceGroups.remove(resourceGroup);
+ } else {
+ return false;
+ }
+ }
+
+
+ public Set<Bundle> getBundles() {
+ return bundles;
+ }
+
+ public void setBundles(Set<Bundle> bundles) {
+ this.bundles = bundles;
+ }
+
+ public void addBundle(Bundle bundle) {
+ if (bundles == null) {
+ bundles = new HashSet<Bundle>();
+ }
+ bundle.addTag(this);
+ bundles.add(bundle);
+ }
+
+ public boolean removeBundle(Bundle bundle) {
+ if (bundles != null) {
+ bundle.removeTag(this);
+ return bundles.remove(bundle);
+ } else {
+ return false;
+ }
+ }
+
+
+ public Set<BundleVersion> getBundleVersions() {
+ return bundleVersions;
+ }
+
+ public void setBundleVersions(Set<BundleVersion> bundleVersions) {
+ this.bundleVersions = bundleVersions;
+ }
+
+ public void addBundleVersion(BundleVersion bundleVersion) {
+ if (bundleVersions == null) {
+ bundleVersions = new HashSet<BundleVersion>();
+ }
+ bundleVersion.addTag(this);
+ bundleVersions.add(bundleVersion);
+ }
+
+ public boolean removeBundleVersion(BundleVersion bundleVersion) {
+ if (bundleVersions != null) {
+ bundleVersion.removeTag(this);
+ return bundleVersions.remove(bundleVersion);
+ } else {
+ return false;
+ }
+ }
+
+
+ public Set<BundleDeployment> getBundleDeployments() {
+ return bundleDeployments;
+ }
+
+ public void setBundleDeployments(Set<BundleDeployment> bundleDeployments) {
+ this.bundleDeployments = bundleDeployments;
+ }
+
+
+ public void addBundleDeployment(BundleDeployment bundleDeployment) {
+ if (bundleDeployments == null) {
+ bundleDeployments = new HashSet<BundleDeployment>();
+ }
+ bundleDeployment.addTag(this);
+ bundleDeployments.add(bundleDeployment);
+ }
+
+ public boolean removeBundleDeployment(BundleDeployment bundleDeployment) {
+ if (bundleDeployments != null) {
+ bundleDeployment.removeTag(this);
+ return bundleDeployments.remove(bundleDeployment);
+ } else {
+ return false;
+ }
+ }
+
+
@Override
public String toString() {
return (namespace != null ? namespace + ":" : "") +
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tagging/TaggingDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tagging/TaggingDataSource.java
new file mode 100644
index 0000000..fe6c3c7
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tagging/TaggingDataSource.java
@@ -0,0 +1,76 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.enterprise.gui.coregui.client.components.tagging;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.data.DSRequest;
+import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+
+import org.rhq.core.domain.criteria.TagCriteria;
+import org.rhq.core.domain.tagging.Tag;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
+
+/**
+ * @author Greg Hinkle
+ */
+public class TaggingDataSource extends RPCDataSource<Tag> {
+
+ @Override
+ protected void executeFetch(final DSRequest request, final DSResponse response) {
+
+ GWTServiceLookup.getTagService().findTagsByCriteria(new TagCriteria(),
+ new AsyncCallback<PageList<Tag>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to load tags",caught);
+ response.setStatus(DSResponse.STATUS_FAILURE);
+ processResponse(request.getRequestId(), response);
+ }
+
+ public void onSuccess(PageList<Tag> result) {
+ response.setData(buildRecords(result));
+ processResponse(request.getRequestId(), response);
+ }
+ });
+
+ }
+
+ @Override
+ public Tag copyValues(ListGridRecord from) {
+ return null; // TODO: Implement this method.
+ }
+
+ @Override
+ public ListGridRecord copyValues(Tag from) {
+ ListGridRecord record = new ListGridRecord();
+ record.setAttribute("id",from.getId());
+ record.setAttribute("namespace",from.getNamespace());
+ record.setAttribute("semantic",from.getSemantic());
+ record.setAttribute("name",from.getName());
+ record.setAttribute("tag",from.toString());
+ return record;
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tagging/TagsChangedCallback.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tagging/TagsChangedCallback.java
new file mode 100644
index 0000000..1de8ca7
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tagging/TagsChangedCallback.java
@@ -0,0 +1,35 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.enterprise.gui.coregui.client.components.tagging;
+
+import java.util.HashSet;
+
+import org.rhq.core.domain.tagging.Tag;
+
+/**
+ * @author Greg Hinkle
+ */
+public interface TagsChangedCallback {
+
+ void tagsChanged(HashSet<Tag> tags);
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/TagGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/TagGWTService.java
index 8f191d0..9ab2919 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/TagGWTService.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/TagGWTService.java
@@ -43,5 +43,15 @@ public interface TagGWTService extends RemoteService {
void removeTags(Set<Tag> tags);
+ void updateResourceTags(int resourceId, Set<Tag> tags);
+
+ void updateResourceGroupTags(int resourceGroupId, Set<Tag> tags);
+
+ void updateBundleTags(int bundleId, Set<Tag> tags);
+
+ void updateBundleVersionTags(int bundleVersionId, Set<Tag> tags);
+
+ void updateBundleDeploymentTags(int bundleDeploymentId, Set<Tag> tags);
+
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTitleBar.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTitleBar.java
index 3a010dd..93b6512 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTitleBar.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTitleBar.java
@@ -23,15 +23,21 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.tagging.Tag;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.components.tagging.TagEditorView;
+import org.rhq.enterprise.gui.coregui.client.components.tagging.TagsChangedCallback;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
+import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.HTMLFlow;
import com.smartgwt.client.widgets.Img;
import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.layout.HLayout;
+import java.util.HashSet;
import java.util.Set;
/**
@@ -58,9 +64,10 @@ public class ResourceTitleBar extends HLayout {
setMembersMargin(5);
}
- @Override
- protected void onInit() {
- super.onInit();
+ public void update() {
+ for (Canvas child : getChildren()) {
+ child.destroy();
+ }
this.title = new HTMLFlow();
this.title.setWidth("*");
@@ -78,14 +85,33 @@ public class ResourceTitleBar extends HLayout {
badge = new Img("types/Service_up_24.png", 24, 24);
+ TagEditorView tagEditorView = new TagEditorView(resource.getTags(), false, new TagsChangedCallback() {
+ public void tagsChanged(final HashSet<Tag> tags) {
+ GWTServiceLookup.getTagService().updateResourceTags(resource.getId(), tags, new AsyncCallback<Void>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to update resource tags", caught);
+ }
+
+ public void onSuccess(Void result) {
+ CoreGUI.getMessageCenter().notify(new Message("Resource tags updated", Message.Severity.Info));
+ // update what is essentially our local cache
+ resource.setTags(tags);
+ }
+ });
+ }
+ });
+
+
addMember(badge);
addMember(title);
+ addMember(tagEditorView);
addMember(availabilityImage);
addMember(favoriteButton);
}
public void setResource(Resource resource) {
this.resource = resource;
+ update();
this.title.setContents("<span class=\"SectionHeader\">" + resource.getName() + "</span> <span class=\"subtitle\">" + resource.getResourceType().getName() + "</span>");
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
index 86d3f8d..898b56a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
@@ -314,7 +314,7 @@ public class ResourceTreeView extends VLayout {
// Update breadcrumbs
viewId.getBreadcrumbs().clear();
- for (int i = parents.length-1; i >= 0; i--) {
+ for (int i = parents.length - 1; i >= 0; i--) {
TreeNode n = parents[i];
if (n instanceof ResourceTreeDatasource.ResourceTreeNode) {
viewId.getBreadcrumbs().add(new Breadcrumb(n.getAttribute("id"), n.getName(), true));
@@ -367,15 +367,17 @@ public class ResourceTreeView extends VLayout {
treeGrid.markForRedraw();
// Update breadcrumbs
- viewId.getBreadcrumbs().clear();
- for (int i = parents.length-1; i >= 0; i--) {
- TreeNode n = parents[i];
- if (n instanceof ResourceTreeDatasource.ResourceTreeNode) {
- viewId.getBreadcrumbs().add(new Breadcrumb(n.getAttribute("id"), n.getName(), true));
+ if (viewId != null) {
+ viewId.getBreadcrumbs().clear();
+ for (int i = parents.length - 1; i >= 0; i--) {
+ TreeNode n = parents[i];
+ if (n instanceof ResourceTreeDatasource.ResourceTreeNode) {
+ viewId.getBreadcrumbs().add(new Breadcrumb(n.getAttribute("id"), n.getName(), true));
+ }
}
+ viewId.getBreadcrumbs().add(new Breadcrumb(selectedNode.getAttribute("id"), selectedNode.getName(), true));
+ CoreGUI.refreshBreadCrumbTrail();
}
- viewId.getBreadcrumbs().add(new Breadcrumb(selectedNode.getAttribute("id"), selectedNode.getName(), true));
- CoreGUI.refreshBreadCrumbTrail();
}
}
}
@@ -428,7 +430,7 @@ public class ResourceTreeView extends VLayout {
// Update breadcrumbs
viewId.getBreadcrumbs().clear();
- for (int i = parents.length-1; i >= 0; i--) {
+ for (int i = parents.length - 1; i >= 0; i--) {
TreeNode n = parents[i];
if (n instanceof ResourceTreeDatasource.ResourceTreeNode) {
viewId.getBreadcrumbs().add(new Breadcrumb(n.getAttribute("id"), n.getName(), true));
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/TagGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/TagGWTServiceImpl.java
index a99f389..fb27c52 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/TagGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/TagGWTServiceImpl.java
@@ -53,4 +53,24 @@ public class TagGWTServiceImpl extends AbstractGWTServiceImpl implements TagGWTS
public void removeTags(Set<Tag> tags) {
tagManager.removeTags(getSessionSubject(), tags);
}
+
+ public void updateResourceTags(int resourceId, Set<Tag> tags) {
+ tagManager.updateResourceTags(getSessionSubject(), resourceId, tags);
+ }
+
+ public void updateResourceGroupTags(int resourceGroupId, Set<Tag> tags) {
+ tagManager.updateResourceGroupTags(getSessionSubject(), resourceGroupId, tags);
+ }
+
+ public void updateBundleTags(int bundleId, Set<Tag> tags) {
+ tagManager.updateBundleTags(getSessionSubject(), bundleId, tags);
+ }
+
+ public void updateBundleVersionTags(int bundleVersionId, Set<Tag> tags) {
+ tagManager.updateBundleVersionTags(getSessionSubject(), bundleVersionId, tags);
+ }
+
+ public void updateBundleDeploymentTags(int bundleDeploymentId, Set<Tag> tags) {
+ tagManager.updateBundleDeploymentTags(getSessionSubject(), bundleDeploymentId, tags);
+ }
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/tagging/TagManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/tagging/TagManagerBean.java
index f18733e..4b34270 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/tagging/TagManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/tagging/TagManagerBean.java
@@ -22,6 +22,8 @@
*/
package org.rhq.enterprise.server.tagging;
+import java.util.HashSet;
+import java.util.List;
import java.util.Set;
import javax.ejb.EJB;
@@ -33,11 +35,19 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.authz.Permission;
+import org.rhq.core.domain.bundle.Bundle;
+import org.rhq.core.domain.bundle.BundleDeployment;
+import org.rhq.core.domain.bundle.BundleVersion;
import org.rhq.core.domain.criteria.TagCriteria;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.core.domain.tagging.Tag;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.authz.AuthorizationManagerLocal;
+import org.rhq.enterprise.server.authz.PermissionException;
+import org.rhq.enterprise.server.authz.RequiredPermission;
import org.rhq.enterprise.server.util.CriteriaQueryGenerator;
import org.rhq.enterprise.server.util.CriteriaQueryRunner;
@@ -56,7 +66,6 @@ public class TagManagerBean implements TagManagerLocal {
private AuthorizationManagerLocal authorizationManager;
-
public PageList<Tag> findTagsByCriteria(Subject subject, TagCriteria criteria) {
CriteriaQueryGenerator generator = new CriteriaQueryGenerator(criteria);
@@ -68,17 +77,92 @@ public class TagManagerBean implements TagManagerLocal {
public Set<Tag> addTags(Subject subject, Set<Tag> tags) {
+ Set<Tag> results = new HashSet<Tag>();
+
// This isn't efficient, but then how many tags will you really be creating at once
for (Tag tag : tags) {
- entityManager.persist(tag);
+ TagCriteria criteria = new TagCriteria();
+ criteria.addFilterNamespace(tag.getNamespace());
+ criteria.addFilterSemantic(tag.getSemantic());
+ criteria.addFilterName(tag.getName());
+ criteria.setStrict(true);
+ List<Tag> found = findTagsByCriteria(subject, criteria);
+ if (!found.isEmpty()) {
+ assert found.size() == 1; // should never be more than one
+ results.add(found.get(0));
+ } else {
+ entityManager.persist(tag);
+ results.add(tag);
+ }
}
- return tags;
+ return results;
}
public void removeTags(Subject subject, Set<Tag> tags) {
// This isn't efficient, but then how many tags will you really be deleting at once
for (Tag tag : tags) {
- entityManager.remove(entityManager.find(Tag.class,tag.getId()));
+ entityManager.remove(entityManager.find(Tag.class, tag.getId()));
+ }
+ }
+
+
+ public void updateResourceTags(Subject subject, int resourceId, Set<Tag> tags) {
+ if (!authorizationManager.hasResourcePermission(subject, Permission.MODIFY_RESOURCE, resourceId)) {
+ throw new PermissionException("You do not have permission to modify resource");
+ }
+
+ Set<Tag> definedTags = addTags(subject, tags);
+ Resource resource = entityManager.find(Resource.class, resourceId);
+ for (Tag tag : definedTags) {
+ tag.addResource(resource);
+ }
+ }
+
+ public void updateResourceGroupTags(Subject subject, int resourceGroupId, Set<Tag> tags) {
+ if (!authorizationManager.hasGroupPermission(subject, Permission.MODIFY_RESOURCE, resourceGroupId)) {
+ throw new PermissionException("You do not have permission to modify group");
+ }
+
+ Set<Tag> definedTags = addTags(subject, tags);
+ ResourceGroup group = entityManager.find(ResourceGroup.class, resourceGroupId);
+ group.setTags(definedTags);
+ for (Tag tag : definedTags) {
+ tag.addResourceGroup(group);
+ }
+ }
+
+ @RequiredPermission(Permission.MANAGE_INVENTORY)
+ // todo verify
+ public void updateBundleTags(Subject subject, int bundleId, Set<Tag> tags) {
+
+ Set<Tag> definedTags = addTags(subject, tags);
+ Bundle bundle = entityManager.find(Bundle.class, bundleId);
+ for (Tag tag : definedTags) {
+ tag.addBundle(bundle);
+ }
+ }
+
+ @RequiredPermission(Permission.MANAGE_INVENTORY)
+ // todo verify
+ public void updateBundleVersionTags(Subject subject, int bundleVersionId, Set<Tag> tags) {
+
+ Set<Tag> definedTags = addTags(subject, tags);
+ BundleVersion bundleVersion = entityManager.find(BundleVersion.class, bundleVersionId);
+ bundleVersion.setTags(definedTags);
+ for (Tag tag : definedTags) {
+ tag.addBundleVersion(bundleVersion);
+ }
+ }
+
+ @RequiredPermission(Permission.MANAGE_INVENTORY)
+ // todo verify
+ public void updateBundleDeploymentTags(Subject subject, int bundleDeploymentId, Set<Tag> tags) {
+
+ Set<Tag> definedTags = addTags(subject, tags);
+ BundleDeployment bundleDeployment = entityManager.find(BundleDeployment.class, bundleDeploymentId);
+ bundleDeployment.setTags(definedTags);
+ for (Tag tag : definedTags) {
+ tag.addBundleDeployment(bundleDeployment);
}
}
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/tagging/TagManagerRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/tagging/TagManagerRemote.java
index 65e566a..9dcbd74 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/tagging/TagManagerRemote.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/tagging/TagManagerRemote.java
@@ -46,5 +46,16 @@ public interface TagManagerRemote {
void removeTags(Subject subject, Set<Tag> tags);
+ void updateResourceTags(Subject subject, int resourceId, Set<Tag> tags);
+
+ void updateResourceGroupTags(Subject subject, int resourceGroupId, Set<Tag> tags);
+
+ void updateBundleTags(Subject subject, int bundleId, Set<Tag> tags);
+
+ void updateBundleVersionTags(Subject subject, int bundleVersionId, Set<Tag> tags);
+
+ void updateBundleDeploymentTags(Subject subject, int bundleDeploymentId, Set<Tag> tags);
+
+
}
commit 9b2d60404d8ec10df7b8325f1b6d84042dbe7261
Author: Greg Hinkle <ghinkle(a)redhat.com>
Date: Mon Apr 26 15:12:29 2010 -0400
Tag gwt service exposure
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml
index 51dcca6..b980d6a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml
@@ -58,5 +58,6 @@
<servlet path="/ResourceBossGWTService" class="org.rhq.enterprise.gui.coregui.server.gwt.ResourceBossGWTServiceImpl"/>
<servlet path="/AuthorizationGWTService" class="org.rhq.enterprise.gui.coregui.server.gwt.AuthorizationGWTServiceImpl"/>
<servlet path="/AvailabilityGWTService" class="org.rhq.enterprise.gui.coregui.server.gwt.AvailabilityGWTServiceImpl"/>
+ <servlet path="/TagGWTService" class="org.rhq.enterprise.gui.coregui.server.gwt.TagGWTServiceImpl"/>
</module>
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml b/modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml
index 10e8f01..ce0e2eb 100644
--- a/modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml
+++ b/modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml
@@ -76,6 +76,10 @@
<servlet-name>org.rhq.enterprise.gui.coregui.CoreGUI AvailabilityGWTService</servlet-name>
<servlet-class>org.rhq.enterprise.gui.coregui.server.gwt.AvailabilityGWTServiceImpl</servlet-class>
</servlet>
+ <servlet>
+ <servlet-name>org.rhq.enterprise.gui.coregui.CoreGUI TagGWTService</servlet-name>
+ <servlet-class>org.rhq.enterprise.gui.coregui.server.gwt.TagGWTServiceImpl</servlet-class>
+ </servlet>
<servlet-mapping>
<servlet-name>org.rhq.enterprise.gui.coregui.CoreGUI RoleGWTService</servlet-name>
@@ -143,4 +147,8 @@
<servlet-name>org.rhq.enterprise.gui.coregui.CoreGUI AvailabilityGWTService</servlet-name>
<url-pattern>/org.rhq.enterprise.gui.coregui.CoreGUI/AvailabilityGWTService</url-pattern>
</servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>org.rhq.enterprise.gui.coregui.CoreGUI TagGWTService</servlet-name>
+ <url-pattern>/org.rhq.enterprise.gui.coregui.CoreGUI/TagGWTService</url-pattern>
+ </servlet-mapping>
</web-app>
commit 8a1bd9af2d92bd45f16448763bb412c3c20809bd
Author: Greg Hinkle <ghinkle(a)redhat.com>
Date: Thu Apr 22 15:39:57 2010 -0400
Basic Tag infrastructure merged with latest from gwt branch, tables updated, etc.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/Repo.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/Repo.java
index 3d7b11a..3cd52f8 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/Repo.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/Repo.java
@@ -48,6 +48,8 @@ import javax.persistence.Table;
import javax.persistence.Transient;
import javax.xml.bind.annotation.XmlTransient;
+import org.jetbrains.annotations.NotNull;
+
import org.rhq.core.domain.resource.Resource;
/**
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleCriteria.java
index 9495b80..d6fd9a7 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleCriteria.java
@@ -45,6 +45,7 @@ public class BundleCriteria extends Criteria {
private boolean fetchBundleVersions;
private boolean fetchPackageType;
private boolean fetchRepo;
+ private boolean fetchTags;
private PageOrdering sortName;
private PageOrdering sortDescription;
@@ -102,6 +103,11 @@ public class BundleCriteria extends Criteria {
this.fetchRepo = fetchRepo;
}
+ public void fetchTags(boolean fetchTags) {
+ this.fetchTags = fetchTags;
+ }
+
+
public void addSortName(PageOrdering sortName) {
addSortField("name");
this.sortName = sortName;
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleDeploymentCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleDeploymentCriteria.java
index a8bf932..1ad7f05 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleDeploymentCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleDeploymentCriteria.java
@@ -40,6 +40,7 @@ public class BundleDeploymentCriteria extends Criteria {
private boolean fetchConfiguration;
private boolean fetchDeployments;
private boolean fetchGroupDeployments;
+ private boolean fetchTags;
public BundleDeploymentCriteria() {
}
@@ -77,4 +78,8 @@ public class BundleDeploymentCriteria extends Criteria {
this.fetchGroupDeployments = fetchGroupDeployments;
}
+ public void fetchTags(boolean fetchTags) {
+ this.fetchTags = fetchTags;
+ }
+
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleVersionCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleVersionCriteria.java
index 68d8913..d9ccb8e 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleVersionCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleVersionCriteria.java
@@ -45,6 +45,7 @@ public class BundleVersionCriteria extends Criteria {
private boolean fetchBundleDeployments;
private boolean fetchBundleFiles;
private boolean fetchConfigurationDefinition;
+ private boolean fetchTags;
public BundleVersionCriteria() {
filterOverrides.put("bundleId", "bundle.id = ?");
@@ -95,4 +96,10 @@ public class BundleVersionCriteria extends Criteria {
public void fetchConfigurationDefinition(boolean fetchConfigurationDefinition) {
this.fetchConfigurationDefinition = fetchConfigurationDefinition;
}
+
+ public void fetchTags(boolean fetchTags) {
+ this.fetchTags = fetchTags;
+ }
+
+
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceCriteria.java
index 69be135..d27a7e5 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceCriteria.java
@@ -85,6 +85,7 @@ public class ResourceCriteria extends Criteria {
private boolean fetchResourceErrors;
private boolean fetchEventSources;
private boolean fetchProductVersion;
+ private boolean fetchTags;
private PageOrdering sortName;
private PageOrdering sortInventoryStatus;
@@ -291,6 +292,10 @@ public class ResourceCriteria extends Criteria {
this.fetchProductVersion = fetchProductVersion;
}
+ public void fetchTags(boolean fetchTags) {
+ this.fetchTags = fetchTags;
+ }
+
public void addSortName(PageOrdering sortName) {
addSortField("name");
this.sortName = sortName;
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceGroupCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceGroupCriteria.java
index 6f831ce..2f98b5b 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceGroupCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceGroupCriteria.java
@@ -58,6 +58,7 @@ public class ResourceGroupCriteria extends Criteria {
private boolean fetchGroupDefinition;
private boolean fetchResourceType;
private boolean fetchRoles;
+ private boolean fetchTags;
private PageOrdering sortName;
private PageOrdering sortResourceTypeName; // requires overrides
@@ -159,6 +160,11 @@ public class ResourceGroupCriteria extends Criteria {
this.fetchResourceType = fetchResourceType;
}
+ public void fetchTags(boolean fetchTags) {
+ this.fetchTags = fetchTags;
+ }
+
+
/**
* Requires MANAGE_SECURITY
* @param fetchRoles
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/TagCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/TagCriteria.java
new file mode 100644
index 0000000..2c93450
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/TagCriteria.java
@@ -0,0 +1,86 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.domain.criteria;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.rhq.core.domain.tagging.Tag;
+import org.rhq.core.domain.util.PageOrdering;
+
+/**
+ * @author Greg Hinkle
+ */
+@XmlRootElement
+(a)XmlAccessorType(XmlAccessType.FIELD)
+@SuppressWarnings("unused")
+public class TagCriteria extends Criteria {
+ private static final long serialVersionUID = 1L;
+
+ private String filterNamespace;
+ private String filterSemantic;
+ private String filterName;
+
+ private PageOrdering sortNamespace;
+ private PageOrdering sortSemantic;
+ private PageOrdering sortName;
+
+
+ @Override
+ public Class<?> getPersistentClass() {
+ return Tag.class;
+ }
+
+
+ public void addFilterNamespace(String filterNamespace) {
+ this.filterNamespace = filterNamespace;
+ }
+
+ public void addFilterSemantic(String filterSemantic) {
+ this.filterSemantic = filterSemantic;
+ }
+
+ public void addFilterName(String filterName) {
+ this.filterName = filterName;
+ }
+
+
+ public void addSortNamespace(PageOrdering sortNamespace) {
+ addSortField("namespace");
+ this.sortNamespace = sortNamespace;
+ }
+
+ public void addSortSemantic(PageOrdering sortSemantic) {
+ addSortField("semantic");
+ this.sortSemantic = sortSemantic;
+ }
+
+ public void addSortName(PageOrdering sortName) {
+ addSortField("name");
+ this.sortName = sortName;
+ }
+
+
+
+}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/tagging/Tag.java b/modules/core/domain/src/main/java/org/rhq/core/domain/tagging/Tag.java
index 3749413..623ec87 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/tagging/Tag.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/tagging/Tag.java
@@ -26,6 +26,7 @@ import java.io.Serializable;
import java.util.Set;
import javax.persistence.Column;
+import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
@@ -47,7 +48,8 @@ import org.rhq.core.domain.resource.group.ResourceGroup;
/**
* @author Greg Hinkle
*/
-@SequenceGenerator(name = "id", sequenceName = "RHQ_TAGGING_ID_SEQ")
+@Entity
+@SequenceGenerator(name = "RHQ_TAGGING_SEQ", sequenceName = "RHQ_TAGGING_ID_SEQ", allocationSize = 10)
@Table(name = "RHQ_TAGGING")
@XmlAccessorType(XmlAccessType.FIELD)
public class Tag implements Serializable {
@@ -56,7 +58,7 @@ public class Tag implements Serializable {
@Column(name = "ID", nullable = false)
- @GeneratedValue(strategy = GenerationType.AUTO, generator = "RHQ_TAGGING_ID_SEQ")
+ @GeneratedValue(strategy = GenerationType.AUTO, generator = "RHQ_TAGGING_SEQ")
@Id
private int id;
@@ -74,7 +76,6 @@ public class Tag implements Serializable {
@ManyToMany
private Set<Resource> resources;
-
@JoinTable(name = "RHQ_TAGGING_RES_GRP_MAP", joinColumns = { @JoinColumn(name = "TAG_ID") }, inverseJoinColumns = { @JoinColumn(name = "RESOURCE_GROUP_ID") })
@ManyToMany
private Set<ResourceGroup> resourceGroups;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java
index d887f8c..d251630 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java
@@ -88,6 +88,10 @@ public class GWTServiceLookup {
return secure(AvailabilityGWTServiceAsync.Util.getInstance());
}
+ public static TagGWTServiceAsync getTagService() {
+ return secure(TagGWTServiceAsync.Util.getInstance());
+ }
+
private static <T> T secure(Object sdt) {
if (!(sdt instanceof ServiceDefTarget))
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGWTService.java
index 9fcb5cc..99234dc 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGWTService.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGWTService.java
@@ -51,6 +51,8 @@ public interface ResourceGWTService extends RemoteService {
List<Integer> deleteResources(int[] resourceIds);
+ void updateResource(Resource resource);
+
void createResource(int parentResourceId, int newResourceTypeId, String newResourceName, Configuration newResourceConfiguration);
Map<Resource, List<Resource>> getQueuedPlatformsAndServers(HashSet<InventoryStatus> statuses, PageControl pc);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/TagGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/TagGWTService.java
new file mode 100644
index 0000000..8f191d0
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/TagGWTService.java
@@ -0,0 +1,47 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.enterprise.gui.coregui.client.gwt;
+
+import java.util.Set;
+
+import com.google.gwt.user.client.rpc.RemoteService;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.criteria.TagCriteria;
+import org.rhq.core.domain.tagging.Tag;
+import org.rhq.core.domain.util.PageList;
+
+/**
+ * @author Greg Hinkle
+ */
+public interface TagGWTService extends RemoteService {
+
+
+ PageList<Tag> findTagsByCriteria(TagCriteria tagCriteria);
+
+ Set<Tag> addTags(Set<Tag> tags);
+
+ void removeTags(Set<Tag> tags);
+
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceView.java
index 503db39..e342628 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceView.java
@@ -86,6 +86,7 @@ public class ResourceView extends HLayout implements BookmarkableView {
} else {
ResourceCriteria criteria = new ResourceCriteria();
criteria.addFilterId(resourceId);
+ criteria.fetchTags(true);
//criteria.fetchParentResource(true);
resourceService.findResourcesByCriteria(criteria, new AsyncCallback<PageList<Resource>>() {
public void onFailure(Throwable caught) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java
index 3434a67..add7a25 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java
@@ -162,6 +162,10 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl implements Re
"ResourceService.deleteResources");
}
+ public void updateResource(Resource resource) {
+ resourceManager.updateResource(getSessionSubject(), resource);
+ }
+
public void createResource(int parentResourceId, int newResourceTypeId, String newResourceName, Configuration newResourceConfiguration) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/TagGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/TagGWTServiceImpl.java
new file mode 100644
index 0000000..a99f389
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/TagGWTServiceImpl.java
@@ -0,0 +1,56 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.enterprise.gui.coregui.server.gwt;
+
+import java.util.Set;
+
+import org.rhq.core.domain.criteria.TagCriteria;
+import org.rhq.core.domain.tagging.Tag;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.enterprise.gui.coregui.client.gwt.TagGWTService;
+import org.rhq.enterprise.gui.coregui.server.util.SerialUtility;
+import org.rhq.enterprise.server.tagging.TagManagerLocal;
+import org.rhq.enterprise.server.util.LookupUtil;
+
+/**
+ * @author Greg Hinkle
+ */
+public class TagGWTServiceImpl extends AbstractGWTServiceImpl implements TagGWTService {
+
+ private TagManagerLocal tagManager = LookupUtil.getTagManager();
+
+ public PageList<Tag> findTagsByCriteria(TagCriteria tagCriteria) {
+ return SerialUtility.prepare(tagManager.findTagsByCriteria(getSessionSubject(), tagCriteria),
+ "TagService.findTagsByCriteria");
+ }
+
+ public Set<Tag> addTags(Set<Tag> tags) {
+ return SerialUtility.prepare(
+ tagManager.addTags(getSessionSubject(), tags),
+ "TagService.addTags");
+ }
+
+ public void removeTags(Set<Tag> tags) {
+ tagManager.removeTags(getSessionSubject(), tags);
+ }
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/tagging/TagManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/tagging/TagManagerBean.java
new file mode 100644
index 0000000..f18733e
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/tagging/TagManagerBean.java
@@ -0,0 +1,84 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.enterprise.server.tagging;
+
+import java.util.Set;
+
+import javax.ejb.EJB;
+import javax.ejb.Stateless;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.criteria.TagCriteria;
+import org.rhq.core.domain.tagging.Tag;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.enterprise.server.RHQConstants;
+import org.rhq.enterprise.server.authz.AuthorizationManagerLocal;
+import org.rhq.enterprise.server.util.CriteriaQueryGenerator;
+import org.rhq.enterprise.server.util.CriteriaQueryRunner;
+
+/**
+ * @author Greg Hinkle
+ */
+@Stateless
+public class TagManagerBean implements TagManagerLocal {
+
+ private final Log log = LogFactory.getLog(TagManagerBean.class);
+
+ @PersistenceContext(unitName = RHQConstants.PERSISTENCE_UNIT_NAME)
+ private EntityManager entityManager;
+
+ @EJB
+ private AuthorizationManagerLocal authorizationManager;
+
+
+
+ public PageList<Tag> findTagsByCriteria(Subject subject, TagCriteria criteria) {
+
+ CriteriaQueryGenerator generator = new CriteriaQueryGenerator(criteria);
+
+ CriteriaQueryRunner<Tag> queryRunner = new CriteriaQueryRunner<Tag>(criteria, generator, entityManager);
+
+ return queryRunner.execute();
+ }
+
+
+ public Set<Tag> addTags(Subject subject, Set<Tag> tags) {
+ // This isn't efficient, but then how many tags will you really be creating at once
+ for (Tag tag : tags) {
+ entityManager.persist(tag);
+ }
+ return tags;
+ }
+
+ public void removeTags(Subject subject, Set<Tag> tags) {
+ // This isn't efficient, but then how many tags will you really be deleting at once
+ for (Tag tag : tags) {
+ entityManager.remove(entityManager.find(Tag.class,tag.getId()));
+ }
+ }
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/tagging/TagManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/tagging/TagManagerLocal.java
new file mode 100644
index 0000000..6197db3
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/tagging/TagManagerLocal.java
@@ -0,0 +1,33 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.enterprise.server.tagging;
+
+import javax.ejb.Local;
+
+/**
+ * @author Greg Hinkle
+ */
+@Local
+public interface TagManagerLocal extends TagManagerRemote {
+
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/tagging/TagManagerRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/tagging/TagManagerRemote.java
new file mode 100644
index 0000000..65e566a
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/tagging/TagManagerRemote.java
@@ -0,0 +1,50 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.enterprise.server.tagging;
+
+import java.util.Set;
+
+import javax.ejb.Local;
+import javax.ejb.Remote;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.criteria.TagCriteria;
+import org.rhq.core.domain.tagging.Tag;
+import org.rhq.core.domain.util.PageList;
+
+/**
+ * @author Greg Hinkle
+ */
+@Remote
+public interface TagManagerRemote {
+
+
+ PageList<Tag> findTagsByCriteria(Subject subject, TagCriteria tagCriteria);
+
+ Set<Tag> addTags(Subject subject, Set<Tag> tags);
+
+ void removeTags(Subject subject, Set<Tag> tags);
+
+
+
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
index e5171e9..39b2c47 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
@@ -179,6 +179,8 @@ import org.rhq.enterprise.server.support.SupportManagerBean;
import org.rhq.enterprise.server.support.SupportManagerLocal;
import org.rhq.enterprise.server.system.SystemManagerBean;
import org.rhq.enterprise.server.system.SystemManagerLocal;
+import org.rhq.enterprise.server.tagging.TagManagerBean;
+import org.rhq.enterprise.server.tagging.TagManagerLocal;
import org.rhq.enterprise.server.test.AccessBean;
import org.rhq.enterprise.server.test.AccessLocal;
import org.rhq.enterprise.server.test.AlertTemplateTestBean;
@@ -560,6 +562,12 @@ public final class LookupUtil {
return lookupLocal(ServerPluginsBean.class);
}
+ public static TagManagerLocal getTagManager() {
+ return lookupLocal(TagManagerBean.class);
+ }
+
+
+
public static CoreServerMBean getCoreServer() {
MBeanServer jBossMBeanServer = MBeanServerLocator.locateJBoss();
CoreServerMBean jonServer = (CoreServerMBean) MBeanProxyExt.create(CoreServerMBean.class,
commit 1a412ccbc69c9c5981bf16dfaa2037bd7ab07917
Author: Greg Hinkle <ghinkle(a)redhat.com>
Date: Thu Apr 22 11:19:32 2010 -0400
resource column for alerts for dashboard view
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java
index c02de80..de4d5ea 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java
@@ -38,6 +38,7 @@ import com.smartgwt.client.data.fields.DataSourceBooleanField;
import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.rpc.RPCResponse;
+import com.smartgwt.client.types.FieldType;
import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridRecord;
@@ -94,9 +95,17 @@ public class AlertDataSource extends RPCDataSource<Alert> {
conditionValueField.setCanSortClientOnly(true);
fields.add(conditionValueField);
- DataSourceTextField recoveryInfoField = new DataSourceTextField("recoveryInfo", "Recovery Info");
- recoveryInfoField.setCanSortClientOnly(true);
- fields.add(recoveryInfoField);
+ DataSourceTextField resourceName = new DataSourceTextField("resourceName", "Resource");
+ resourceName.setCanSortClientOnly(true);
+ fields.add(resourceName);
+
+
+// DataSourceTextField recoveryInfoField = new DataSourceTextField("recoveryInfo", "Recovery Info");
+// recoveryInfoField.setCanSortClientOnly(true);
+// fields.add(recoveryInfoField);
+
+
+
// TODO: Will using DataSourceEnumField here allow us to do
// record.setAttribute("priority", alert.getAlertDefinition().getPriority()), rather than
@@ -201,6 +210,7 @@ public class AlertDataSource extends RPCDataSource<Alert> {
ListGridRecord record = new ListGridRecord();
record.setAttribute("id", from.getId());
record.setAttribute("resourceId", from.getAlertDefinition().getResource().getId());
+ record.setAttribute("resourceName", from.getAlertDefinition().getResource().getName());
record.setAttribute("name", from.getAlertDefinition().getName());
record.setAttribute("priority", from.getAlertDefinition().getPriority().name());
record.setAttribute("ctime", DATE_TIME_FORMAT.format(new Date(from.getCtime())));
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertsView.java
index fe64b84..adf12c5 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertsView.java
@@ -27,11 +27,13 @@ import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.data.Record;
import com.smartgwt.client.data.SortSpecifier;
import com.smartgwt.client.types.Alignment;
+import com.smartgwt.client.types.ListGridFieldType;
import com.smartgwt.client.types.SortDirection;
import com.smartgwt.client.widgets.HTMLFlow;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.FormItem;
import com.smartgwt.client.widgets.form.fields.StaticTextItem;
+import com.smartgwt.client.widgets.grid.CellFormatter;
import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
@@ -56,9 +58,9 @@ import org.rhq.enterprise.gui.coregui.client.components.table.TableAction;
public class AlertsView extends VLayout {
private static final String TITLE = "Alerts";
- private static final SortSpecifier[] SORT_SPECIFIERS = new SortSpecifier[] {
- new SortSpecifier(AlertCriteria.SORT_FIELD_CTIME, SortDirection.DESCENDING),
- new SortSpecifier(AlertCriteria.SORT_FIELD_NAME, SortDirection.ASCENDING)
+ private static final SortSpecifier[] SORT_SPECIFIERS = new SortSpecifier[]{
+ new SortSpecifier(AlertCriteria.SORT_FIELD_CTIME, SortDirection.DESCENDING),
+ new SortSpecifier(AlertCriteria.SORT_FIELD_NAME, SortDirection.ASCENDING)
};
private static final String DELETE_CONFIRM_MESSAGE = "Are you sure you want to delete the selected alert(s)?";
@@ -70,8 +72,20 @@ public class AlertsView extends VLayout {
private VerticalPanel vpanel;
private static final String SENDER = "sender";
+ Criteria criteria;
+ String[] excludedFieldNames;
+ boolean showDetails;
+
+ public AlertsView() {
+ this(null, null);
+ showDetails = false;
+
+ }
+
public AlertsView(Criteria criteria, String[] excludedFieldNames) {
- this.table = new Table(TITLE, criteria, SORT_SPECIFIERS, excludedFieldNames);
+ this.criteria = criteria;
+ this.excludedFieldNames = excludedFieldNames;
+ showDetails = false;
}
@@ -88,59 +102,72 @@ public class AlertsView extends VLayout {
protected void onDraw() {
super.onDraw();
+ if (table == null) {
+ this.table = new Table(TITLE, criteria, SORT_SPECIFIERS, excludedFieldNames);
+
+
+ // Add the list table as the top half of the view.
+ //Criteria criteria = new Criteria(AlertCriteria.);
+ this.table.setHeight("50%");
+ ListGrid listGrid = this.table.getListGrid();
+ this.dataSource = new AlertDataSource();
+ this.table.setDataSource(this.dataSource);
+ listGrid.getField("name").setWidth("15%");
+ listGrid.getField("conditionText").setWidth("30%");
+ listGrid.getField("conditionValue").setWidth("10%");
+ listGrid.getField("resourceName").setWidth("20%");
+// listGrid.getField("recoveryInfo").setWidth("20%");
+ listGrid.getField("priority").setWidth("7%");
+ listGrid.getField("ctime").setWidth("13%");
+ listGrid.getField("ack").setWidth("5%");
+
+ listGrid.getField("resourceName").setCellFormatter(new CellFormatter() {
+ public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
+ return "<a href=\"#Resource/" + listGridRecord.getAttribute("resourceId") + "\">" + o + "</a>";
+ }
+ });
- // Add the list table as the top half of the view.
- //Criteria criteria = new Criteria(AlertCriteria.);
- this.table.setHeight("50%");
- ListGrid listGrid = this.table.getListGrid();
- this.dataSource = new AlertDataSource();
- this.table.setDataSource(this.dataSource);
- listGrid.getField("name").setWidth("10%");
- listGrid.getField("conditionText").setWidth("30%");
- listGrid.getField("conditionValue").setWidth("15%");
- listGrid.getField("recoveryInfo").setWidth("20%");
- listGrid.getField("priority").setWidth("7%");
- listGrid.getField("ctime").setWidth("13%");
- listGrid.getField("ack").setWidth("5%");
-
- this.table.addTableAction("Delete", Table.SelectionEnablement.ANY, DELETE_CONFIRM_MESSAGE, new TableAction() {
- public void executeAction(ListGridRecord[] selection) {
- AlertsView.this.dataSource.deleteAlerts(AlertsView.this);
- }
- });
- this.table.addTableAction("Acknowledge", Table.SelectionEnablement.ANY, null, new TableAction() {
- public void executeAction(ListGridRecord[] selection) {
- AlertsView.this.dataSource.acknowledgeAlerts(AlertsView.this);
- }
- });
-
- listGrid.addSelectionChangedHandler(new SelectionChangedHandler() {
- public void onSelectionChanged(SelectionEvent event) {
- ListGridRecord[] selectedRecords = AlertsView.this.table.getListGrid().getSelection();
- String contents;
- if (selectedRecords.length == 1) {
- ListGridRecord record = selectedRecords[0];
-
- // Clean out existing details and provide new ones
- for (int i = 1 ; i <= getChildren().length ; i ++)
- getChildren()[1].destroy();
-
- addMember(getDetailsTabSet(record));
-
- } else {
- // Clean out existing details and show the "nothing selected message"
- for (int i = 1 ; i <= getChildren().length ; i ++)
- getChildren()[1].destroy();
- addMember(getNoAlertSelectedMessage());
+ this.table.addTableAction("Delete", Table.SelectionEnablement.ANY, DELETE_CONFIRM_MESSAGE, new TableAction() {
+ public void executeAction(ListGridRecord[] selection) {
+ AlertsView.this.dataSource.deleteAlerts(AlertsView.this);
}
+ });
+ this.table.addTableAction("Acknowledge", Table.SelectionEnablement.ANY, null, new TableAction() {
+ public void executeAction(ListGridRecord[] selection) {
+ AlertsView.this.dataSource.acknowledgeAlerts(AlertsView.this);
+ }
+ });
+
+ if (showDetails) {
+ listGrid.addSelectionChangedHandler(new SelectionChangedHandler() {
+ public void onSelectionChanged(SelectionEvent event) {
+ ListGridRecord[] selectedRecords = AlertsView.this.table.getListGrid().getSelection();
+ String contents;
+ if (selectedRecords.length == 1) {
+ ListGridRecord record = selectedRecords[0];
+
+ // Clean out existing details and provide new ones
+ for (int i = 1; i <= getChildren().length; i++)
+ getChildren()[1].destroy();
+
+ addMember(getDetailsTabSet(record));
+
+ } else {
+ // Clean out existing details and show the "nothing selected message"
+ for (int i = 1; i <= getChildren().length; i++)
+ getChildren()[1].destroy();
+ addMember(getNoAlertSelectedMessage());
+ }
+ }
+ });
}
- });
- addMember(this.table);
+ addMember(this.table);
+ }
- // Add the details panel as the bottom half of the view.
- // Default is the "nothing selected" message
- addMember(getNoAlertSelectedMessage());
+// // Add the details panel as the bottom half of the view.
+// // Default is the "nothing selected" message
+// addMember(getNoAlertSelectedMessage());
}
@@ -185,27 +212,27 @@ public class AlertsView extends VLayout {
descriptionTextItem.setValue(record.getAttribute("description"));
items.add(descriptionTextItem);
- StaticTextItem prioTextItem = new StaticTextItem("priority","Priority");
+ StaticTextItem prioTextItem = new StaticTextItem("priority", "Priority");
prioTextItem.setValue(record.getAttribute("priority"));
items.add(prioTextItem);
- StaticTextItem createdTextItem = new StaticTextItem("ctime","Created at");
+ StaticTextItem createdTextItem = new StaticTextItem("ctime", "Created at");
createdTextItem.setValue(record.getAttribute("ctime"));
items.add(createdTextItem);
- StaticTextItem ackByItem = new StaticTextItem("ack_by","Acknowledged by");
- if (record.getAttribute("ack_by")!=null) {
+ StaticTextItem ackByItem = new StaticTextItem("ack_by", "Acknowledged by");
+ if (record.getAttribute("ack_by") != null) {
ackByItem.setValue(record.getAttribute("ack_by"));
}
items.add(ackByItem);
- StaticTextItem ackTimeItem = new StaticTextItem("ack_time","Acknowledged at");
- if (record.getAttribute("ack_time")!=null) {
+ StaticTextItem ackTimeItem = new StaticTextItem("ack_time", "Acknowledged at");
+ if (record.getAttribute("ack_time") != null) {
ackTimeItem.setValue(record.getAttribute("ack_time"));
}
items.add(ackTimeItem);
- StaticTextItem recoveryItem = new StaticTextItem("recovery","Recovery Info");
+ StaticTextItem recoveryItem = new StaticTextItem("recovery", "Recovery Info");
recoveryItem.setValue(record.getAttribute("recoveryInfo"));
items.add(recoveryItem);
@@ -219,25 +246,25 @@ public class AlertsView extends VLayout {
DataClass[] input = record.getAttributeAsRecordArray("notificationLogs");
- Table notifTable = new Table("Notifications",false);
+ Table notifTable = new Table("Notifications", false);
notifTable.setHeight("35%");
notifTable.setWidth100();
ListGrid grid = notifTable.getListGrid();
grid.setData((Record[]) input);
- ListGridField sender = new ListGridField(SENDER,"Sender");
+ ListGridField sender = new ListGridField(SENDER, "Sender");
sender.setWidth("10%");
- ListGridField status = new ListGridField("status","Result");
+ ListGridField status = new ListGridField("status", "Result");
status.setWidth("8%");
- ListGridField message = new ListGridField("message","Message");
+ ListGridField message = new ListGridField("message", "Message");
message.setWidth("32%");
- ListGridField allEmails = new ListGridField("allEmails","All Emails");
+ ListGridField allEmails = new ListGridField("allEmails", "All Emails");
allEmails.setWidth("25%");
- ListGridField badEmails = new ListGridField("badEmails","Bad Emails");
+ ListGridField badEmails = new ListGridField("badEmails", "Bad Emails");
badEmails.setWidth("25%");
- grid.setFields(sender,status,message,allEmails,badEmails);
+ grid.setFields(sender, status, message, allEmails, badEmails);
return notifTable;
}
@@ -248,18 +275,18 @@ public class AlertsView extends VLayout {
String mode = record.getAttribute("conditionExpression");
- Table table = new Table("Conditions: match = " + mode,false);
+ Table table = new Table("Conditions: match = " + mode, false);
table.setHeight("35%");
table.setWidth100();
ListGrid grid = table.getListGrid();
grid.setData((Record[]) input);
- ListGridField condition = new ListGridField("text","Matching condition");
+ ListGridField condition = new ListGridField("text", "Matching condition");
condition.setWidth("60%");
- ListGridField value = new ListGridField("value","Value");
+ ListGridField value = new ListGridField("value", "Value");
- grid.setFields(condition,value);
+ grid.setFields(condition, value);
return table;
commit fc98d9d53d9d0943984842beb63a1ab842a933c5
Author: Greg Hinkle <ghinkle(a)redhat.com>
Date: Thu Apr 22 11:18:50 2010 -0400
Continued prototyping of new alert def ui
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/alert/AlertEditView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/alert/AlertEditView.java
index 4bc4a03..8ef2feb 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/alert/AlertEditView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/alert/AlertEditView.java
@@ -24,6 +24,7 @@ import java.util.LinkedHashMap;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.Window;
import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.FormItemIfFunction;
import com.smartgwt.client.widgets.form.ValuesManager;
import com.smartgwt.client.widgets.form.fields.BlurbItem;
import com.smartgwt.client.widgets.form.fields.CanvasItem;
@@ -72,6 +73,7 @@ public class AlertEditView extends VLayout {
addMember(buildEditForm());
+ addMember(buildConditionSection(0));
}
@@ -119,12 +121,6 @@ public class AlertEditView extends VLayout {
conditionsHeader.setValue("Alert Conditions");
- CanvasItem conditionOne = new CanvasItem("condition0");
- conditionOne.setShowTitle(false);
- conditionOne.setColSpan(4);
- conditionOne.setCanvas(buildConditionSection(0));
-
-
/*
LinkedHashMap valuesMap = new LinkedHashMap();
valuesMap.put("Metric", buildMetricSectionCavans(vm));
@@ -134,7 +130,7 @@ public class AlertEditView extends VLayout {
RadioGroupWithComponentsItem conditionGroup = new RadioGroupWithComponentsItem("radioTest", "Test", valuesMap, form);
*/
- form.setItems(alertPropertiesHeader, alertName, priority, description, active, conditionsHeader, conditionOne);
+ form.setItems(alertPropertiesHeader, alertName, priority, description, active, conditionsHeader);
return form;
@@ -152,22 +148,26 @@ public class AlertEditView extends VLayout {
ALERT("Alert Fired"), //
RESOURCE_CONFIG("Resource Configuration Property Value Change"), //
EVENT("Log Event");
+ */
- */
+ private DynamicForm buildConditionSection(final int ci) {
- private DynamicForm buildConditionSection(int ci) {
+ final DynamicForm form = new DynamicForm();
+
+ ValuesManager vm = new ValuesManager();
+ form.setValuesManager(vm);
- DynamicForm form = new DynamicForm();
form.setNumCols(3);
form.setColWidths("30","120","*");
ArrayList<FormItem> items = new ArrayList<FormItem>();
-//
-// RadioGroupItem conditionType = new RadioGroupItem("conditionType" + ci, "Condition Type");
-// conditionType.setImageURLPrefix("subsystems/");
-// conditionType.setImageURLSuffix("_16.png");
+
+ RadioGroupItem conditionType = new RadioGroupItem("conditionType" + ci, "Condition Type");
+ conditionType.setImageURLPrefix("subsystems/");
+ conditionType.setImageURLSuffix("_16.png");
+ items.add(conditionType);
LinkedHashMap<String, String> valueMap = new LinkedHashMap<String, String>();
valueMap.put(AlertConditionCategory.AVAILABILITY.name(), AlertConditionCategory.AVAILABILITY.getDisplayName());
@@ -175,7 +175,7 @@ public class AlertEditView extends VLayout {
valueMap.put(AlertConditionCategory.TRAIT.name(), AlertConditionCategory.TRAIT.getDisplayName());
valueMap.put(AlertConditionCategory.CONTROL.name(), AlertConditionCategory.CONTROL.getDisplayName());
valueMap.put(AlertConditionCategory.EVENT.name(), AlertConditionCategory.EVENT.getDisplayName());
-// conditionType.setValueMap(valueMap);
+ conditionType.setValueMap(valueMap);
LinkedHashMap<String, String> iconMap = new LinkedHashMap<String, String>();
@@ -185,11 +185,12 @@ public class AlertEditView extends VLayout {
iconMap.put(AlertConditionCategory.CONTROL.name(), "control/Operation");
iconMap.put(AlertConditionCategory.EVENT.name(), "event/Events_error");
-// conditionType.setValueIcons(iconMap);
-//// conditionType.setValueIconSize(24);http://localhost:7080/coregui/images/availability/availability_red
-// conditionType.setShowIcons(true);
-
+ conditionType.setValueIcons(iconMap);
+ conditionType.setValue(AlertConditionCategory.AVAILABILITY.name());
+// conditionType.setValueIconSize(24);http://localhost:7080/coregui/images/availability/availability_red
+ conditionType.setShowIcons(true);
+/*
for (final String key : valueMap.keySet()) {
BlurbItem icon = new BlurbItem();
icon.setColSpan(1);
@@ -204,6 +205,7 @@ public class AlertEditView extends VLayout {
radio.setStartRow(false);
radio.setShowTitle(false);
radio.setValueMap(valueMap.get(key));
+ radio.setRedrawOnChange(true);
items.add(radio);
icon.addClickHandler(new ClickHandler() {
@@ -212,16 +214,32 @@ public class AlertEditView extends VLayout {
}
});
- }
+ }*/
+
+ CanvasItem metricCanvas = buildMetricSectionCavans(vm);
+ metricCanvas.setShowIfCondition(new FormItemIfFunction() {
+ public boolean execute(FormItem formItem, Object o, DynamicForm dynamicForm) {
+ return "metric".equals(form.getValue("conditionType" + ci));
+ }
+ });
+ items.add(metricCanvas);
+ CanvasItem propertyCanvas = buildInventoryPropertySectionCavans(vm);
+ propertyCanvas.setShowIfCondition(new FormItemIfFunction() {
+ public boolean execute(FormItem formItem, Object o, DynamicForm dynamicForm) {
+ return AlertConditionCategory.AVAILABILITY.name().equals(form.getValue("conditionType" + ci));
+ }
+ });
+ items.add(propertyCanvas);
+
form.setItems(items.toArray(new FormItem[items.size()]));
return form;
}
- private DynamicForm buildMetricSectionCavans(ValuesManager vm) {
+ private CanvasItem buildMetricSectionCavans(ValuesManager vm) {
DynamicForm form = new DynamicForm();
form.setTitleSuffix("");
@@ -281,11 +299,16 @@ public class AlertEditView extends VLayout {
metricConditionType.setShowTitle(false);
form.setItems(metricSelect, new SpacerItem(), metricConditionType);
- return form;
+
+ CanvasItem canvasItem = new CanvasItem("metricConditionCanvas");
+ canvasItem.setShowTitle(false);
+ canvasItem.setCanvas(form);
+
+ return canvasItem;
}
- private DynamicForm buildInventoryPropertySectionCavans(ValuesManager vm) {
+ private CanvasItem buildInventoryPropertySectionCavans(ValuesManager vm) {
DynamicForm form = new DynamicForm();
form.setValuesManager(vm);
@@ -297,6 +320,10 @@ public class AlertEditView extends VLayout {
form.setItems(inventoryProperty);
- return form;
+ CanvasItem canvasItem = new CanvasItem("inventoryPropertyCanvas");
+ canvasItem.setShowTitle(false);
+ canvasItem.setCanvas(form);
+
+ return canvasItem;
}
}
commit c0deec533226d9f6de0ddb85f9bb39243f443a52
Author: Greg Hinkle <ghinkle(a)redhat.com>
Date: Thu Apr 22 11:18:24 2010 -0400
Support resource column for alerts for dasbhoard view
Add operation execution popup
Add error message on op results page
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/OperationHistoryDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/OperationHistoryDataSource.java
index fd79d76..b6f6702 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/OperationHistoryDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/OperationHistoryDataSource.java
@@ -18,6 +18,8 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation;
+import java.util.Date;
+
import org.rhq.core.domain.criteria.ResourceOperationHistoryCriteria;
import org.rhq.core.domain.operation.ResourceOperationHistory;
import org.rhq.core.domain.util.PageList;
@@ -95,7 +97,7 @@ public class OperationHistoryDataSource extends RPCDataSource<ResourceOperationH
ListGridRecord record = new ListGridRecord();
record.setAttribute("id", from.getId());
record.setAttribute("createdTime", from.getCreatedTime());
- record.setAttribute("startedTime", from.getStartedTime());
+ record.setAttribute("startedTime", new Date(from.getStartedTime()));
record.setAttribute("duration", from.getDuration());
record.setAttribute("resource", from.getResource());
record.setAttribute("subject", from.getSubjectName());
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/OperationHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/OperationHistoryView.java
index 758cc3d..9a04cdc 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/OperationHistoryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/OperationHistoryView.java
@@ -18,19 +18,31 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation;
+import java.util.EnumSet;
+
import org.rhq.core.domain.criteria.ResourceOperationHistoryCriteria;
+import org.rhq.core.domain.operation.OperationDefinition;
import org.rhq.core.domain.operation.ResourceOperationHistory;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.components.table.Table;
import org.rhq.enterprise.gui.coregui.client.components.table.TableAction;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.create.OperationCreateWizard;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.detail.OperationDetailsView;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import com.smartgwt.client.widgets.layout.VLayout;
+import com.smartgwt.client.widgets.menu.Menu;
+import com.smartgwt.client.widgets.menu.MenuButton;
+import com.smartgwt.client.widgets.menu.MenuItem;
+import com.smartgwt.client.widgets.menu.events.ClickHandler;
+import com.smartgwt.client.widgets.menu.events.MenuItemClickEvent;
/**
* @author Greg Hinkle
@@ -38,6 +50,7 @@ import com.smartgwt.client.widgets.layout.VLayout;
public class OperationHistoryView extends VLayout {
Table table;
+ Resource resource;
Criteria criteria;
@Override
@@ -50,8 +63,9 @@ public class OperationHistoryView extends VLayout {
public OperationHistoryView() {
}
- public OperationHistoryView(Criteria criteria) {
- this.criteria = criteria;
+ public OperationHistoryView(Resource resource) {
+ this.resource = resource;
+ this.criteria = new Criteria("resourceId", String.valueOf(resource.getId()));
}
@Override
@@ -95,13 +109,35 @@ public class OperationHistoryView extends VLayout {
});
+ final Menu operationMenu = new Menu();
+ ResourceTypeRepository.Cache.getInstance().getResourceTypes(
+ resource.getResourceType().getId(),
+ EnumSet.of(ResourceTypeRepository.MetadataType.operations),
+ new ResourceTypeRepository.TypeLoadedCallback() {
+ public void onTypesLoaded(ResourceType type) {
+ for (final OperationDefinition od : type.getOperationDefinitions()) {
+ MenuItem menuItem = new MenuItem(od.getDisplayName());
+ operationMenu.addItem(menuItem);
+ menuItem.addClickHandler(new ClickHandler() {
+ public void onClick(MenuItemClickEvent event) {
+ new OperationCreateWizard(resource, od).startOperationWizard();
+ }
+ });
+ }
+ }
+ });
+
+ MenuButton operationsButton = new MenuButton("Run Operation",operationMenu);
+ operationsButton.setShowMenuBelow(false);
+ table.addExtraWidget(operationsButton);
+
+
addMember(table);
}
- public static OperationHistoryView getResourceHistoryView(int resourceId) {
- Criteria criteria = new Criteria("resourceId", String.valueOf(resourceId));
+ public static OperationHistoryView getResourceHistoryView(Resource resource) {
- return new OperationHistoryView(criteria);
+ return new OperationHistoryView(resource);
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/detail/OperationDetailsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/detail/OperationDetailsView.java
index 9c14c0e..de1747b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/detail/OperationDetailsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/detail/OperationDetailsView.java
@@ -20,8 +20,10 @@ package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operatio
import java.util.Date;
+import com.smartgwt.client.types.TitleOrientation;
import com.smartgwt.client.widgets.Window;
import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.fields.AutoFitTextAreaItem;
import com.smartgwt.client.widgets.form.fields.StaticTextItem;
import com.smartgwt.client.widgets.layout.VLayout;
@@ -83,11 +85,20 @@ public class OperationDetailsView extends VLayout {
// Results configuration view
+ if (operationHistory.getErrorMessage() != null) {
+
+ DynamicForm errorDisplay = new DynamicForm();
+ errorDisplay.setNumCols(1);
+ AutoFitTextAreaItem errorText = new AutoFitTextAreaItem("error","Error");
+ errorText.setTitleOrientation(TitleOrientation.TOP);
+ errorText.setValue(operationHistory.getErrorMessage());
+
+ }
if (operationHistory.getResults() != null) {
ConfigurationEditor resultsEditor = new ConfigurationEditor(definition.getResultsConfigurationDefinition(), operationHistory.getResults());
-
+ resultsEditor.setReadOnly(true);
addMember(resultsEditor);
}
commit 7acaed8260593d6a0b4027c52337cb14e94c1cd2
Author: Greg Hinkle <ghinkle(a)redhat.com>
Date: Thu Apr 22 11:17:31 2010 -0400
Updated resource tree icons
Cleaned up resource title bar
Bookmarkable view fixes
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/CustomResourceTreeGrid.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/CustomResourceTreeGrid.java
index d7543fb..cd5e060 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/CustomResourceTreeGrid.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/CustomResourceTreeGrid.java
@@ -42,12 +42,10 @@ public class CustomResourceTreeGrid extends TreeGrid {
boolean up = resource.getCurrentAvailability().getAvailabilityType() == AvailabilityType.UP;
- if (resource.getResourceType().getChildResourceTypes() == null || resource.getResourceType().getChildResourceTypes().isEmpty()) {
- return "resources/Service_" + (up ? "up" : "down") + "_16.png";
+ String category = resource.getResourceType().getCategory().getDisplayName();
+
+ return "types/" + category + "_" + (up ? "up" : "down") + "_16.png";
- } else {
- return "resources/folder_" + (up ? "" : "down_") + (open ? "opened" : "closed") + ".png";
- }
} else {
return "resources/folder_group_" + (open ? "opened" : "closed") + ".png";
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
index f6c31da..cdf3025 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
@@ -18,20 +18,25 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail;
+import java.util.EnumSet;
+import java.util.Set;
+
+import com.google.gwt.user.client.History;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.types.Side;
+import com.smartgwt.client.widgets.layout.VLayout;
+import com.smartgwt.client.widgets.tab.Tab;
+
import org.rhq.core.domain.authz.Permission;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.resource.composite.ResourcePermission;
-import org.rhq.enterprise.gui.coregui.client.Breadcrumb;
+import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.UnknownViewException;
-import org.rhq.enterprise.gui.coregui.client.View;
import org.rhq.enterprise.gui.coregui.client.ViewId;
-import org.rhq.enterprise.gui.coregui.client.ViewRenderer;
+import org.rhq.enterprise.gui.coregui.client.ViewPath;
import org.rhq.enterprise.gui.coregui.client.alert.definitions.AlertDefinitionsView;
import org.rhq.enterprise.gui.coregui.client.components.FullHTMLPane;
-import org.rhq.enterprise.gui.coregui.client.components.SimpleCollapsiblePanel;
-import org.rhq.enterprise.gui.coregui.client.components.configuration.ConfigurationEditor;
import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTab;
import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTabSelectedEvent;
import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTabSelectedHandler;
@@ -42,27 +47,19 @@ import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceSelectLi
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.alert.ResourceAlertHistoryView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.configuration.ConfigurationHistoryView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.configuration.ResourceConfigurationEditView;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.inventory.PluginConfigurationEditView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.GraphListView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.calltime.CallTimeView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.OperationHistoryView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.overview.ResourceOverviewView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
-import com.google.gwt.user.client.History;
-import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.smartgwt.client.types.Side;
-import com.smartgwt.client.widgets.layout.VLayout;
-import com.smartgwt.client.widgets.tab.Tab;
-
-import java.util.EnumSet;
-import java.util.Set;
-
/**
* Right panel of the resource view.
*
* @author Greg Hinkle
*/
-public class ResourceDetailView extends VLayout implements ViewRenderer, ResourceSelectListener, TwoLevelTabSelectedHandler {
+public class ResourceDetailView extends VLayout implements BookmarkableView, ResourceSelectListener, TwoLevelTabSelectedHandler {
private Resource resource;
private ResourcePermission permissions;
@@ -81,8 +78,9 @@ public class ResourceDetailView extends VLayout implements ViewRenderer, Resourc
private ResourceTitleBar titleBar;
- private ViewId currentView;
- private ViewId baseViewId;
+ private ViewId tabView;
+ private ViewId subtabView;
+
public void setResource(Resource resource) {
this.resource = resource;
@@ -165,9 +163,9 @@ public class ResourceDetailView extends VLayout implements ViewRenderer, Resourc
inventoryTab.updateSubTab("Children", ResourceSearchView.getChildrenOf(resource.getId()));
- inventoryTab.updateSubTab("Connection Settings", new ConfigurationEditor(resource.getId(), resource.getResourceType().getId(), ConfigurationEditor.ConfigType.plugin));
+ inventoryTab.updateSubTab("Connection Settings", new PluginConfigurationEditView(resource)); // new ConfigurationEditor(resource.getId(), resource.getResourceType().getId(), ConfigurationEditor.ConfigType.plugin));
- operationsTab.updateSubTab("History", OperationHistoryView.getResourceHistoryView(resource.getId()));
+ operationsTab.updateSubTab("History", OperationHistoryView.getResourceHistoryView(resource));
configurationTab.updateSubTab("Current", new ResourceConfigurationEditView(resource));
configurationTab.updateSubTab("History", ConfigurationHistoryView.getHistoryOf(resource.getId()));
@@ -275,41 +273,34 @@ public class ResourceDetailView extends VLayout implements ViewRenderer, Resourc
}
}
- public View renderView(ViewId viewId, boolean lastNode) throws UnknownViewException {
- if (baseViewId == null) {
- baseViewId = viewId;
- }
- currentView = viewId;
+ public void renderView(ViewPath viewPath) {
+ // TODO: Implement this method.
- String[] parts = currentView.getPath().split("/");
- Breadcrumb crumb = null;
- if (parts.length >= 3) {
- for (Tab t : topTabSet.getTabs()) {
- TwoLevelTab tab = (TwoLevelTab) t;
+ if (viewPath.isEnd()) {
+ // default
- if (tab.getTitle().equals(parts[2])) {
+ } else {
- if (parts.length == 3) {
- crumb = new Breadcrumb(parts[2], parts[2], false);
- }
+ tabView = viewPath.getCurrent();
+ subtabView = viewPath.getNext();
+ for (Tab t : topTabSet.getTabs()) {
+ TwoLevelTab tab = (TwoLevelTab) t;
- if (parts.length >= 4) {
- tab.getLayout().selectTab(parts[3]);
+ if (tab.getTitle().equals(tabView.getPath())) {
+ topTabSet.selectTab(tabView.getPath());
- // Switch the top tab after the subtab to avoid an extra subtab render
- topTabSet.selectTab(tab);
+ tab.getLayout().selectTab(subtabView.getPath());
- if (parts.length == 4) {
- crumb = new Breadcrumb(parts[3], parts[3], false);
- }
- }
}
+
}
+
+
}
- return new View(viewId, crumb);
+
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTitleBar.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTitleBar.java
index 426d84e..3a010dd 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTitleBar.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTitleBar.java
@@ -19,6 +19,7 @@
package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail;
import com.google.gwt.user.client.rpc.AsyncCallback;
+
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.resource.Resource;
@@ -54,6 +55,7 @@ public class ResourceTitleBar extends HLayout {
setWidth100();
setHeight(30);
setPadding(5);
+ setMembersMargin(5);
}
@Override
@@ -96,7 +98,9 @@ public class ResourceTitleBar extends HLayout {
"_24.png");
String category = this.resource.getResourceType().getCategory().getDisplayName();
- String avail = resource.getCurrentAvailability().getAvailabilityType().name().toLowerCase();
+
+ String avail = (resource.getCurrentAvailability() != null && resource.getCurrentAvailability().getAvailabilityType() != null)
+ ? (resource.getCurrentAvailability().getAvailabilityType().name().toLowerCase()) : "down";
badge.setSrc("types/" + category + "_" + avail + "_24.png");
markForRedraw();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
index 30822c5..86d3f8d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
@@ -21,7 +21,10 @@ package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail;
import org.rhq.core.domain.operation.OperationDefinition;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.enterprise.gui.coregui.client.Breadcrumb;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.ViewId;
+import org.rhq.enterprise.gui.coregui.client.ViewPath;
import org.rhq.enterprise.gui.coregui.client.components.configuration.ConfigurationEditor;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGWTServiceAsync;
@@ -67,11 +70,13 @@ public class ResourceTreeView extends VLayout {
private TreeGrid treeGrid;
Menu contextMenu;
+ private ViewId currentViewId;
+
private ArrayList<ResourceSelectListener> selectListeners = new ArrayList<ResourceSelectListener>();
private boolean initialSelect = false;
- public ResourceTreeView(Resource selectedResource) {
+ public ResourceTreeView() {
super();
this.selectedResource = selectedResource;
@@ -79,10 +84,6 @@ public class ResourceTreeView extends VLayout {
setHeight100();
setShowResizeBar(true);
-
- if (selectedResource != null) {
- setSelectedResource(selectedResource);
- }
}
public void onInit() {
@@ -137,43 +138,48 @@ public class ResourceTreeView extends VLayout {
public void onNodeContextClick(final NodeContextClickEvent event) {
event.getNode();
- buildContextMenu(event.getNode());
-
- contextMenu.showContextMenu();
+ if (event.getNode() instanceof ResourceTreeDatasource.TypeTreeNode) {
+ showContextMenu((ResourceTreeDatasource.TypeTreeNode) event.getNode());
+ } else if (event.getNode() instanceof ResourceTreeDatasource.ResourceTreeNode) {
+ showContextMenu((ResourceTreeDatasource.ResourceTreeNode) event.getNode());
+ }
}
});
}
- private void buildContextMenu(TreeNode node) {
- if (node instanceof ResourceTreeDatasource.TypeTreeNode) {
- buildContextMenu((ResourceTreeDatasource.TypeTreeNode) node);
- } else if (node instanceof ResourceTreeDatasource.ResourceTreeNode) {
- buildContextMenu((ResourceTreeDatasource.ResourceTreeNode) node);
- }
- }
-
-
- private void buildContextMenu(ResourceTreeDatasource.TypeTreeNode node) {
+ private void showContextMenu(ResourceTreeDatasource.TypeTreeNode node) {
contextMenu.setItems(new MenuItem(node.getName()));
+ contextMenu.showContextMenu();
+ }
+ private void showContextMenu(final ResourceTreeDatasource.ResourceTreeNode node) {
+ ResourceTypeRepository.Cache.getInstance().getResourceTypes(
+ node.getResourceType().getId(),
+ EnumSet.of(ResourceTypeRepository.MetadataType.operations, ResourceTypeRepository.MetadataType.children, ResourceTypeRepository.MetadataType.subCategory,
+ ResourceTypeRepository.MetadataType.pluginConfigurationDefinition, ResourceTypeRepository.MetadataType.resourceConfigurationDefinition),
+ new ResourceTypeRepository.TypeLoadedCallback() {
+ public void onTypesLoaded(ResourceType type) {
+ buildResourceContextMenu(node.getResource(), type);
+ contextMenu.showContextMenu();
+ }
+ });
}
- private void buildContextMenu(final ResourceTreeDatasource.ResourceTreeNode node) {
- contextMenu.setItems(new MenuItem(node.getName()));
+ private void buildResourceContextMenu(final Resource resource, final ResourceType resourceType) {
+ contextMenu.setItems(new MenuItem(resource.getName()));
- contextMenu.addItem(new MenuItem("Type: " + node.getResourceType().getName()));
+ contextMenu.addItem(new MenuItem("Type: " + resourceType.getName()));
MenuItem editPluginConfiguration = new MenuItem("Plugin Configuration");
editPluginConfiguration.addClickHandler(new ClickHandler() {
public void onClick(MenuItemClickEvent event) {
- Resource resource = node.getResource();
- int resourceId = node.getResource().getId();
- int resourceTypeId = node.getResourceType().getId();
+ int resourceId = resource.getId();
+ int resourceTypeId = resourceType.getId();
Window configEditor = new Window();
configEditor.setTitle("Edit " + resource.getName() + " plugin configuration");
@@ -188,16 +194,15 @@ public class ResourceTreeView extends VLayout {
}
});
- editPluginConfiguration.setEnabled(node.getResource().getResourceType().getPluginConfigurationDefinition() != null);
+ editPluginConfiguration.setEnabled(resourceType.getPluginConfigurationDefinition() != null);
contextMenu.addItem(editPluginConfiguration);
MenuItem editResourceConfiguration = new MenuItem("Resource Configuration");
editResourceConfiguration.addClickHandler(new ClickHandler() {
public void onClick(MenuItemClickEvent event) {
- Resource resource = node.getResource();
- int resourceId = node.getResource().getId();
- int resourceTypeId = node.getResourceType().getId();
+ int resourceId = resource.getId();
+ int resourceTypeId = resourceType.getId();
final Window configEditor = new Window();
configEditor.setTitle("Edit " + resource.getName() + " resource configuration");
@@ -218,7 +223,7 @@ public class ResourceTreeView extends VLayout {
}
});
- editResourceConfiguration.setEnabled(node.getResource().getResourceType().getResourceConfigurationDefinition() != null);
+ editResourceConfiguration.setEnabled(resourceType.getResourceConfigurationDefinition() != null);
contextMenu.addItem(editResourceConfiguration);
contextMenu.addItem(new MenuItemSeparator());
@@ -227,7 +232,7 @@ public class ResourceTreeView extends VLayout {
// Operations Menu
MenuItem operations = new MenuItem("Operations");
Menu opSubMenu = new Menu();
- for (final OperationDefinition operationDefinition : node.getResourceType().getOperationDefinitions()) {
+ for (final OperationDefinition operationDefinition : resourceType.getOperationDefinitions()) {
MenuItem operationItem = new MenuItem(operationDefinition.getDisplayName());
operationItem.addClickHandler(new ClickHandler() {
public void onClick(MenuItemClickEvent event) {
@@ -237,7 +242,7 @@ public class ResourceTreeView extends VLayout {
opSubMenu.addItem(operationItem);
// todo action
}
- operations.setEnabled(!node.getResourceType().getOperationDefinitions().isEmpty());
+ operations.setEnabled(!resourceType.getOperationDefinitions().isEmpty());
operations.setSubmenu(opSubMenu);
contextMenu.addItem(operations);
@@ -245,13 +250,13 @@ public class ResourceTreeView extends VLayout {
// Create Menu
MenuItem createChildMenu = new MenuItem("Create Child");
Menu createChildSubMenu = new Menu();
- for (final ResourceType childType : node.getResourceType().getChildResourceTypes()) {
+ for (final ResourceType childType : resourceType.getChildResourceTypes()) {
if (childType.isCreatable()) {
MenuItem createItem = new MenuItem(childType.getName());
createChildSubMenu.addItem(createItem);
createItem.addClickHandler(new ClickHandler() {
public void onClick(MenuItemClickEvent event) {
- ResourceFactoryCreateWizard.showCreateWizard(node.getResource(), childType);
+ ResourceFactoryCreateWizard.showCreateWizard(resource, childType);
}
});
@@ -262,10 +267,10 @@ public class ResourceTreeView extends VLayout {
contextMenu.addItem(createChildMenu);
- // Manually Menu
+ // Manually Add Menu
MenuItem importChildMenu = new MenuItem("Import");
Menu importChildSubMenu = new Menu();
- for (ResourceType childType : node.getResourceType().getChildResourceTypes()) {
+ for (ResourceType childType : resourceType.getChildResourceTypes()) {
if (childType.isSupportsManualAdd()) {
importChildSubMenu.addItem(new MenuItem(childType.getName()));
//todo action
@@ -274,9 +279,9 @@ public class ResourceTreeView extends VLayout {
importChildMenu.setSubmenu(importChildSubMenu);
importChildMenu.setEnabled(importChildSubMenu.getItems().length > 0);
contextMenu.addItem(importChildMenu);
-
}
+
Resource getResource(int resourceId) {
if (this.treeGrid != null && this.treeGrid.getTree() != null) {
ResourceTreeDatasource.ResourceTreeNode treeNode =
@@ -292,7 +297,7 @@ public class ResourceTreeView extends VLayout {
this.rootResource = rootResource;
}
- public void setSelectedResource(final Resource selectedResource) {
+ public void setSelectedResource(final Resource selectedResource, final ViewId viewId) {
this.selectedResource = selectedResource;
TreeNode node = null;
@@ -305,8 +310,25 @@ public class ResourceTreeView extends VLayout {
treeGrid.deselectAllRecords();
treeGrid.selectRecord(node);
+
+
+ // Update breadcrumbs
+ viewId.getBreadcrumbs().clear();
+ for (int i = parents.length-1; i >= 0; i--) {
+ TreeNode n = parents[i];
+ if (n instanceof ResourceTreeDatasource.ResourceTreeNode) {
+ viewId.getBreadcrumbs().add(new Breadcrumb(n.getAttribute("id"), n.getName(), true));
+ }
+ }
+ viewId.getBreadcrumbs().add(new Breadcrumb(node.getAttribute("id"), node.getName(), true));
+ CoreGUI.refreshBreadCrumbTrail();
+
+
+ // Todo: update viewId's breadcrumbs with known data
} else {
+
final ResourceGWTServiceAsync resourceService = GWTServiceLookup.getResourceService();
+ // This is an expensive call, but loads all nodes that are visible in the tree given a selected resource
resourceService.getResourceLineageAndSiblings(selectedResource.getId(), new AsyncCallback<List<Resource>>() {
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError("Failed to lookup platform for tree", caught);
@@ -343,6 +365,17 @@ public class ResourceTreeView extends VLayout {
treeGrid.selectRecord(selectedNode);
initialSelect = true;
treeGrid.markForRedraw();
+
+ // Update breadcrumbs
+ viewId.getBreadcrumbs().clear();
+ for (int i = parents.length-1; i >= 0; i--) {
+ TreeNode n = parents[i];
+ if (n instanceof ResourceTreeDatasource.ResourceTreeNode) {
+ viewId.getBreadcrumbs().add(new Breadcrumb(n.getAttribute("id"), n.getName(), true));
+ }
+ }
+ viewId.getBreadcrumbs().add(new Breadcrumb(selectedNode.getAttribute("id"), selectedNode.getName(), true));
+ CoreGUI.refreshBreadCrumbTrail();
}
}
}
@@ -392,6 +425,18 @@ public class ResourceTreeView extends VLayout {
TreeNode[] parents = treeGrid.getTree().getParents(selectedNode);
treeGrid.getTree().openFolders(parents);
treeGrid.getTree().openFolder(selectedNode);
+
+ // Update breadcrumbs
+ viewId.getBreadcrumbs().clear();
+ for (int i = parents.length-1; i >= 0; i--) {
+ TreeNode n = parents[i];
+ if (n instanceof ResourceTreeDatasource.ResourceTreeNode) {
+ viewId.getBreadcrumbs().add(new Breadcrumb(n.getAttribute("id"), n.getName(), true));
+ }
+ }
+ viewId.getBreadcrumbs().add(new Breadcrumb(selectedNode.getAttribute("id"), selectedNode.getName(), true));
+ CoreGUI.refreshBreadCrumbTrail();
+
} else {
CoreGUI.getMessageCenter().notify(new Message("Failed to select resource [" + selectedResource.getId() + "] in tree.", Message.Severity.Warning));
}
@@ -403,6 +448,13 @@ public class ResourceTreeView extends VLayout {
}
+ TreeNode selectedNode = treeGrid.getTree().findById(String.valueOf(selectedResource.getId()));
+// System.out.println("Trying to preopen: " + selectedNode);
+ if (selectedNode != null) {
+ TreeNode[] parents = treeGrid.getTree().getParents(selectedNode);
+
+ // todo update viewPath's breadcrumbs
+ }
// CoreGUI.addBreadCrumb(new Place(String.valueOf(result.getId()), result.getName()));
}
@@ -439,6 +491,10 @@ public class ResourceTreeView extends VLayout {
public void addResourceSelectListener(ResourceSelectListener listener) {
this.selectListeners.add(listener);
}
+
+ public void renderView(ViewPath viewPath) {
+ currentViewId = viewPath.getCurrent();
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceView.java
index f2dd8b8..503db39 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceView.java
@@ -18,33 +18,30 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.layout.HLayout;
+
import org.rhq.core.domain.criteria.ResourceCriteria;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.util.PageList;
-import org.rhq.enterprise.gui.coregui.client.Breadcrumb;
-import org.rhq.enterprise.gui.coregui.client.UnknownViewException;
-import org.rhq.enterprise.gui.coregui.client.View;
-import org.rhq.enterprise.gui.coregui.client.ViewId;
-import org.rhq.enterprise.gui.coregui.client.ViewRenderer;
+import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.ViewId;
+import org.rhq.enterprise.gui.coregui.client.ViewPath;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.InventoryView;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
-import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.smartgwt.client.util.SC;
-import com.smartgwt.client.widgets.Canvas;
-import com.smartgwt.client.widgets.layout.HLayout;
-
/**
* @author Greg Hinkle
*/
-public class ResourceView extends HLayout implements ViewRenderer {
+public class ResourceView extends HLayout implements BookmarkableView {
private Canvas contentCanvas;
- private Resource selectedResource;
+ private Resource currentResource;
//private Resource resourcePlatform;
private ResourceTreeView treeView;
@@ -57,12 +54,6 @@ public class ResourceView extends HLayout implements ViewRenderer {
}
- public ResourceView(Resource selectedResource) {
- this.selectedResource = selectedResource;
-
- System.out.println("Displaying Resource: " + selectedResource);
- }
-
@Override
protected void onInit() {
super.onInit();
@@ -71,7 +62,7 @@ public class ResourceView extends HLayout implements ViewRenderer {
setHeight100();
- treeView = new ResourceTreeView(selectedResource);
+ treeView = new ResourceTreeView();
addMember(treeView);
contentCanvas = new Canvas();
@@ -88,7 +79,7 @@ public class ResourceView extends HLayout implements ViewRenderer {
}
- public void setSelectedResource(final int resourceId, final View view) {
+ public void setSelectedResource(final int resourceId, final ViewPath view) {
Resource resource = this.treeView.getResource(resourceId);
if (resource != null) {
setSelectedResource(resource, view);
@@ -117,15 +108,9 @@ public class ResourceView extends HLayout implements ViewRenderer {
}
}
- private void setSelectedResource(Resource resource, View view) {
- view.getBreadcrumb().setDisplayName(resource.getName());
- CoreGUI.refreshBreadCrumbTrail();
- setSelectedResource(resource);
- }
-
- public void setSelectedResource(Resource resource) {
- this.selectedResource = resource;
- this.treeView.setSelectedResource(resource);
+ private void setSelectedResource(Resource resource, ViewPath viewPath) {
+ this.currentResource = resource;
+ this.treeView.setSelectedResource(resource, viewPath.getCurrent());
this.detailView.onResourceSelected(resource);
}
@@ -136,28 +121,27 @@ public class ResourceView extends HLayout implements ViewRenderer {
contentCanvas.markForRedraw();
}
- public View renderView(ViewId viewId, boolean lastNode) throws UnknownViewException {
- String parentPath = viewId.getParent().getPath();
- if (!parentPath.equals("Resource")) {
- throw new UnknownViewException();
- }
- int resourceId;
- try {
- resourceId = Integer.parseInt(viewId.getName());
- } catch (NumberFormatException e) {
- // not a valid Resource id - nothing for us to do
- throw new UnknownViewException("Invalid Resource id [" + viewId + "]");
+
+ public void renderView(ViewPath viewPath) {
+ if (viewPath.isEnd()) {
+ // default detail view
+ viewPath.getViewPath().add(new ViewId("Summary"));
+ viewPath.getViewPath().add(new ViewId("Overview"));
}
- // Use "..." as temporary display name for breadcrumb. If the Resource is fetched successfully, the display name
- // will be updated to be the Resource's name.
- Breadcrumb breadcrumb = new Breadcrumb(viewId.getName(), "...");
+ Integer resourceId = Integer.parseInt(viewPath.getCurrent().getPath());
- View view = new View(viewId, detailView, breadcrumb);
- if (this.selectedResource == null || this.selectedResource.getId() != resourceId) {
- setSelectedResource(resourceId, view);
- }
+ if (currentResource == null || currentResource.getId() != resourceId) {
- return view;
+ setSelectedResource(resourceId, viewPath);
+
+ this.treeView.renderView(viewPath);
+
+ viewPath.next();
+
+ this.detailView.renderView(viewPath);
+
+ }
}
+
}
commit 5465c814f1635f311f583810e1be24b16d44e7e7
Author: Greg Hinkle <ghinkle(a)redhat.com>
Date: Thu Apr 22 11:16:31 2010 -0400
Fix resource section menu highlight
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java
index e134f04..c80b21d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java
@@ -56,6 +56,10 @@ public class MenuBarView extends VLayout {
public void onValueChange(ValueChangeEvent<String> stringValueChangeEvent) {
String first = stringValueChangeEvent.getValue().split("/")[0];
+ if ("Resource".equals(first)) {
+ first = "Inventory";
+ }
+
selected = first;
linksPane.setContents(setupLinks());
linksPane.markForRedraw();
@@ -91,6 +95,7 @@ public class MenuBarView extends VLayout {
HLayout helpLayout = new HLayout();
Label loggedInAs = new Label("Logged in as " + CoreGUI.getSessionSubject().getName());
+ loggedInAs.setWrap(false);
loggedInAs.setValign(VerticalAlignment.CENTER);
helpLayout.addMember(loggedInAs);
helpLayout.addMember(new Hyperlink("Help", "Help"));
commit ec7c8fdc6aa1a58fdbfe131be2459c72f1e24cc1
Author: Greg Hinkle <ghinkle(a)redhat.com>
Date: Thu Apr 22 11:16:07 2010 -0400
New admin view for updated history system
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/AdministrationView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/AdministrationView.java
index ff6f3ee..913ff6c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/AdministrationView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/AdministrationView.java
@@ -18,16 +18,7 @@
*/
package org.rhq.enterprise.gui.coregui.client.admin;
-import org.rhq.enterprise.gui.coregui.client.Breadcrumb;
-import org.rhq.enterprise.gui.coregui.client.UnknownViewException;
-import org.rhq.enterprise.gui.coregui.client.View;
-import org.rhq.enterprise.gui.coregui.client.ViewId;
-import org.rhq.enterprise.gui.coregui.client.ViewRenderer;
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.admin.roles.RolesView;
-import org.rhq.enterprise.gui.coregui.client.admin.users.UsersView;
-import org.rhq.enterprise.gui.coregui.client.components.FullHTMLPane;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.discovery.ResourceAutodiscoveryView;
+import java.util.LinkedHashMap;
import com.smartgwt.client.types.VisibilityMode;
import com.smartgwt.client.widgets.Canvas;
@@ -41,25 +32,31 @@ import com.smartgwt.client.widgets.tree.Tree;
import com.smartgwt.client.widgets.tree.TreeGrid;
import com.smartgwt.client.widgets.tree.TreeNode;
-import java.util.ArrayList;
-import java.util.List;
+import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.ViewId;
+import org.rhq.enterprise.gui.coregui.client.ViewPath;
+import org.rhq.enterprise.gui.coregui.client.admin.roles.RolesView;
+import org.rhq.enterprise.gui.coregui.client.admin.users.UsersView;
+import org.rhq.enterprise.gui.coregui.client.components.FullHTMLPane;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.discovery.ResourceAutodiscoveryView;
/**
- *
* @author Greg Hinkle
*/
-public class AdministrationView extends HLayout implements ViewRenderer {
+public class AdministrationView extends HLayout implements BookmarkableView {
+
public static final String VIEW_PATH = "Administration";
- public static final String SUBVIEW_PATH_REPORTS = VIEW_PATH + ViewId.PATH_SEPARATOR + "Reports";
- public static final String SUBVIEW_PATH_REPORTS_INVENTORY_SUMMARY = SUBVIEW_PATH_REPORTS + ViewId.PATH_SEPARATOR + "InventorySummary";
- private static final String IFRAME_URL_INVENTORY_SUMMARY_REPORT = "/rhq/admin/report/resourceInstallReport-body.xhtml";
+ private ViewId currentSectionViewId;
+ private ViewId currentPageViewId;
+
private SectionStack sectionStack;
private Canvas contentCanvas;
- private List<TreeGrid> treeGrids;
+ private LinkedHashMap<String, TreeGrid> treeGrids = new LinkedHashMap<String, TreeGrid>();
@Override
protected void onInit() {
@@ -78,21 +75,39 @@ public class AdministrationView extends HLayout implements ViewRenderer {
sectionStack.setWidth(250);
sectionStack.setHeight100();
- this.treeGrids = new ArrayList<TreeGrid>(5);
- sectionStack.addSection(buildSecuritySection());
- sectionStack.addSection(buildPluginsSection());
- sectionStack.addSection(buildManagementClusterSection());
- sectionStack.addSection(buildSystemConfigurationSection());
- sectionStack.addSection(buildReportsSection());
+
+ treeGrids.put("Security", buildSecuritySection());
+ treeGrids.put("Configuration", buildSystemConfigurationSection());
+ treeGrids.put("Cluster", buildManagementClusterSection());
+ treeGrids.put("Reports", buildReportsSection());
+ treeGrids.put("Security", buildSecuritySection());
+
+
+ for (final String name : treeGrids.keySet()) {
+ TreeGrid grid = treeGrids.get(name);
+
+ grid.addSelectionChangedHandler(new SelectionChangedHandler() {
+ public void onSelectionChanged(SelectionEvent selectionEvent) {
+ CoreGUI.goTo("Administration/" + name + "/" + selectionEvent.getRecord().getAttribute("name"));
+ }
+ });
+
+
+ SectionStackSection section = new SectionStackSection(name);
+ section.setExpanded(true);
+ section.addItem(grid);
+
+ sectionStack.addSection(section);
+ }
+
addMember(sectionStack);
addMember(contentCanvas);
- setContent(buildLanding());
}
- private HTMLFlow buildLanding() {
+ private HTMLFlow defaultView() {
String contents = "<h1>Administration</h1>\n" +
"From this section, the RHQ global settings can be administered. This includes configuring \n" +
"<a href=\"\">Security</a>, setting up <a href=\"\">Plugins</a> and other stuff.";
@@ -102,61 +117,32 @@ public class AdministrationView extends HLayout implements ViewRenderer {
}
- private SectionStackSection buildSecuritySection() {
- final SectionStackSection section = new SectionStackSection("Security");
- section.setExpanded(true);
+ private TreeGrid buildSecuritySection() {
final TreeGrid securityTreeGrid = new TreeGrid();
securityTreeGrid.setShowHeader(false);
- this.treeGrids.add(securityTreeGrid);
Tree tree = new Tree();
final TreeNode manageUsersNode = new TreeNode("Manage Users");
final TreeNode manageRolesNode = new TreeNode("Manage Roles");
final TreeNode discoveryQueue = new TreeNode("Auto Discovery Queue");
+ final TreeNode remoteAgentInstall = new TreeNode("Remote Agent Install");
tree.setRoot(new TreeNode("security",
manageUsersNode,
manageRolesNode,
- discoveryQueue));
+ discoveryQueue,
+ remoteAgentInstall));
securityTreeGrid.setData(tree);
- securityTreeGrid.addSelectionChangedHandler(new SelectionChangedHandler() {
- public void onSelectionChanged(SelectionEvent selectionEvent) {
- if (selectionEvent.getState()) {
- Canvas content;
- if (selectionEvent.getRecord() == manageUsersNode) {
- content = new UsersView();
- } else if (selectionEvent.getRecord() == manageRolesNode) {
- content = new RolesView();
- } else if (selectionEvent.getRecord() == discoveryQueue) {
- content = new ResourceAutodiscoveryView();
- } else {
- throw new IllegalStateException("Unknown record selected: " + selectionEvent.getRecord());
- }
- setContent(content);
-
- for (TreeGrid treeGrid : treeGrids) {
- if (treeGrid != securityTreeGrid) {
- treeGrid.deselectAllRecords();
- }
- }
- }
- }
- });
-
- section.addItem(securityTreeGrid);
-
- return section;
+ return securityTreeGrid;
}
- private SectionStackSection buildManagementClusterSection() {
- final SectionStackSection section = new SectionStackSection("Management Cluster");
- section.setExpanded(true);
+
+ private TreeGrid buildManagementClusterSection() {
final TreeGrid mgmtClusterTreeGrid = new TreeGrid();
mgmtClusterTreeGrid.setShowHeader(false);
- this.treeGrids.add(mgmtClusterTreeGrid);
Tree tree = new Tree();
final TreeNode manageServersNode = new TreeNode("Servers");
@@ -172,144 +158,37 @@ public class AdministrationView extends HLayout implements ViewRenderer {
mgmtClusterTreeGrid.setData(tree);
- mgmtClusterTreeGrid.addSelectionChangedHandler(new SelectionChangedHandler() {
- public void onSelectionChanged(SelectionEvent selectionEvent) {
- if (selectionEvent.getState()) {
- String url;
- if (selectionEvent.getRecord() == manageServersNode) {
- url = "/rhq/ha/listServers.xhtml";
- } else if (selectionEvent.getRecord() == manageAgentsNode) {
- url = "/rhq/ha/listAgents.xhtml";
- } else if (selectionEvent.getRecord() == manageAffinityGroupsNode) {
- url = "/rhq/ha/listAffinityGroups.xhtml";
- } else if (selectionEvent.getRecord() == managePartitionEventsNode) {
- url = "/rhq/ha/listPartitionEvents.xhtml";
- } else {
- throw new IllegalStateException("Unknown record selected: " + selectionEvent.getRecord());
- }
- url = addQueryStringParam(url, "nomenu=true");
- FullHTMLPane pane = new FullHTMLPane(url);
- setContent(pane);
-
- for (TreeGrid treeGrid : treeGrids) {
- if (treeGrid != mgmtClusterTreeGrid) {
- treeGrid.deselectAllRecords();
- }
- }
- }
- }
- });
-
- section.addItem(mgmtClusterTreeGrid);
-
- return section;
+ return mgmtClusterTreeGrid;
}
- private SectionStackSection buildPluginsSection() {
- final SectionStackSection section = new SectionStackSection("Plugins");
- section.setExpanded(true);
- final TreeGrid pluginsTreeGrid = new TreeGrid();
- pluginsTreeGrid.setShowHeader(false);
- this.treeGrids.add(pluginsTreeGrid);
-
- Tree tree = new Tree();
- final TreeNode managePlugins = new TreeNode("Plugins");
-
- tree.setRoot(new TreeNode("clustering",
- managePlugins));
-
- pluginsTreeGrid.setData(tree);
-
- pluginsTreeGrid.addSelectionChangedHandler(new SelectionChangedHandler() {
- public void onSelectionChanged(SelectionEvent selectionEvent) {
- if (selectionEvent.getState()) {
- String url = null;
- if (selectionEvent.getRecord() == managePlugins) {
- url = "/rhq/admin/plugin/plugin-list.xhtml";
- } else {
- throw new IllegalStateException("Unknown record selected: " + selectionEvent.getRecord());
- }
- url = addQueryStringParam(url, "nomenu=true");
- FullHTMLPane pane = new FullHTMLPane(url);
- setContent(pane);
-
- for (TreeGrid treeGrid : treeGrids) {
- if (treeGrid != pluginsTreeGrid) {
- treeGrid.deselectAllRecords();
- }
- }
- }
- }
- });
-
- section.addItem(pluginsTreeGrid);
-
- return section;
- }
-
-
- private SectionStackSection buildSystemConfigurationSection() {
- final SectionStackSection section = new SectionStackSection("System Configuration");
- section.setExpanded(true);
+ private TreeGrid buildSystemConfigurationSection() {
final TreeGrid systemConfigTreeGrid = new TreeGrid();
systemConfigTreeGrid.setShowHeader(false);
- this.treeGrids.add(systemConfigTreeGrid);
Tree tree = new Tree();
final TreeNode manageSettings = new TreeNode("System Settings");
final TreeNode manageTemplates = new TreeNode("Templates");
final TreeNode manageDownloads = new TreeNode("Downloads");
final TreeNode manageLicense = new TreeNode("License");
+ final TreeNode managePlugins = new TreeNode("Plugins");
+ FullHTMLPane pane = new FullHTMLPane("/rhq/admin/plugin/plugin-list.xhtml");
+
tree.setRoot(new TreeNode("System Configuration",
- manageSettings, manageTemplates, manageDownloads, manageLicense));
+ manageSettings, manageTemplates, manageDownloads, manageLicense, managePlugins));
systemConfigTreeGrid.setData(tree);
-
- systemConfigTreeGrid.addSelectionChangedHandler(new SelectionChangedHandler() {
- public void onSelectionChanged(SelectionEvent selectionEvent) {
- if (selectionEvent.getState()) {
- String url;
- if (selectionEvent.getRecord() == manageSettings) {
- url = "/admin/config/Config.do?mode=edit";
- } else if (selectionEvent.getRecord() == manageTemplates) {
- url = "/admin/config/EditDefaults.do?mode=monitor&viewMode=all";
- } else if (selectionEvent.getRecord() == manageDownloads) {
- url = "/rhq/admin/downloads-body.xhtml";
- } else if (selectionEvent.getRecord() == manageLicense) {
- url = "/admin/license/LicenseAdmin.do?mode=view";
- } else {
- throw new IllegalStateException("Unknown record selected: " + selectionEvent.getRecord());
- }
- url = addQueryStringParam(url, "nomenu=true");
- FullHTMLPane pane = new FullHTMLPane(url);
- setContent(pane);
-
- for (TreeGrid treeGrid : treeGrids) {
- if (treeGrid != systemConfigTreeGrid) {
- treeGrid.deselectAllRecords();
- }
- }
- }
- }
- });
-
- section.addItem(systemConfigTreeGrid);
-
- return section;
+ return systemConfigTreeGrid;
}
- private SectionStackSection buildReportsSection() {
- final SectionStackSection section = new SectionStackSection("Reports");
- section.setID("Reports");
- section.setExpanded(true);
+
+ private TreeGrid buildReportsSection() {
final TreeGrid reportsTreeGrid = new TreeGrid();
reportsTreeGrid.setShowHeader(false);
- this.treeGrids.add(reportsTreeGrid);
Tree tree = new Tree();
final TreeNode inventorySummaryNode = new TreeNode("Inventory Summary");
@@ -319,24 +198,10 @@ public class AdministrationView extends HLayout implements ViewRenderer {
reportsTreeGrid.setData(tree);
- reportsTreeGrid.addSelectionChangedHandler(new SelectionChangedHandler() {
- public void onSelectionChanged(SelectionEvent selectionEvent) {
- if (selectionEvent.getState()) {
- CoreGUI.goTo(SUBVIEW_PATH_REPORTS_INVENTORY_SUMMARY);
- for (TreeGrid treeGrid : treeGrids) {
- if (treeGrid != reportsTreeGrid) {
- treeGrid.deselectAllRecords();
- }
- }
- }
- }
- });
-
- section.addItem(reportsTreeGrid);
-
- return section;
+ return reportsTreeGrid;
}
+
public void setContent(Canvas newContent) {
if (contentCanvas.getChildren().length > 0)
@@ -346,22 +211,104 @@ public class AdministrationView extends HLayout implements ViewRenderer {
contentCanvas.markForRedraw();
}
- public View renderView(ViewId viewId, boolean lastNode) throws UnknownViewException {
- String parentPath = viewId.getParent().getPath();
- if (parentPath.equals("Administration")) {
- SectionStackSection stackSection = this.sectionStack.getSection(viewId.getName());
- if (stackSection != null) {
- stackSection.setExpanded(true);
- if (lastNode) {
- // TODO: Render some default content for the e.g. Administration/Reports view.
- }
- return new View(viewId, new Breadcrumb(viewId.getName(), false));
+
+ private void renderContentView(ViewPath viewPath) {
+
+ currentSectionViewId = viewPath.getCurrent();
+ currentPageViewId = viewPath.getNext();
+
+ String section = currentSectionViewId.getPath();
+ String page = currentPageViewId.getPath();
+
+
+ Canvas content = null;
+ if ("Reports".equals(section)) {
+
+ if ("Inventory Summary".equals(page)) {
+ content = new FullHTMLPane("/rhq/admin/report/resourceInstallReport-body.xhtml");
+ }
+
+
+ } else if ("Security".equals(section)) {
+
+ if ("Manage Users".equals(page)) {
+ content = new UsersView();
+ } else if ("Manage Roles".equals(page)) {
+ content = new RolesView();
+ } else if ("Auto Discovery Queue".equals(page)) {
+ content = new ResourceAutodiscoveryView();
+ } else if ("Remote Agent Install".equals(page)) {
+ // todo
+ //content = new RemoteAgentInstallView();
+ }
+ } else if ("Configuration".equals(section)) {
+
+ String url = null;
+ if ("System Settings".equals(page)) {
+ url = "/admin/config/Config.do?mode=edit";
+ } else if ("Templates".equals(page)) {
+ url = "/admin/config/EditDefaults.do?mode=monitor&viewMode=all";
+ } else if ("Downloads".equals(page)) {
+ url = "/rhq/admin/downloads-body.xhtml";
+ } else if ("License".equals(page)) {
+ url = "/admin/license/LicenseAdmin.do?mode=view";
}
- } else if (parentPath.equals("Administration/Reports")) {
- setContent(new FullHTMLPane(IFRAME_URL_INVENTORY_SUMMARY_REPORT));
- return new View(viewId);
+ url = addQueryStringParam(url, "nomenu=true");
+ content = new FullHTMLPane(url);
+
+
+ } else if ("Cluster".equals(section)) {
+ String url = null;
+ if ("Servers".equals(page)) {
+ url = "/rhq/ha/listServers.xhtml";
+ } else if ("Agents".equals(page)) {
+ url = "/rhq/ha/listAgents.xhtml";
+ } else if ("Affinity Groups".equals(page)) {
+ url = "/rhq/ha/listAffinityGroups.xhtml";
+ } else if ("Partition Events".equals(page)) {
+ url = "/rhq/ha/listPartitionEvents.xhtml";
+ }
+ url = addQueryStringParam(url, "nomenu=true");
+ content = new FullHTMLPane(url);
+ }
+
+
+ for (String name : treeGrids.keySet()) {
+
+ TreeGrid treeGrid = treeGrids.get(name);
+ if (name.equals(section)) {
+ treeGrid.setSelectedPaths(page);
+ } else {
+ treeGrid.deselectAllRecords();
+ }
+ }
+
+
+
+ setContent(content);
+
+
+ if (content instanceof BookmarkableView) {
+ ((BookmarkableView) content).renderView(viewPath.next().next());
}
- throw new UnknownViewException();
+
+
+ }
+
+
+ public void renderView(ViewPath viewPath) {
+
+ if (!viewPath.isCurrent(currentSectionViewId) || !viewPath.isNext(currentPageViewId)) {
+
+ if (viewPath.isEnd()) {
+ // Display default view
+ setContent(defaultView());
+ } else {
+ renderContentView(viewPath);
+ }
+ }
+
+
}
private static String addQueryStringParam(String url, String param) {
commit eab57e81e77edf0f1342358f4f0b78c5b2202b74
Author: Greg Hinkle <ghinkle(a)redhat.com>
Date: Thu Apr 22 11:15:48 2010 -0400
New Dashboard system, storage, portlet factory, loading engine and layout
Cleanup of existin portlets, some new ones
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/UnknownViewException.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/UnknownViewException.java
deleted file mode 100644
index d5ff736..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/UnknownViewException.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2010 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.coregui.client;
-
-/**
- * TODO
- *
- * @author Ian Springer
- */
-public class UnknownViewException extends Exception {
- public UnknownViewException() {
- }
-
- public UnknownViewException(String message) {
- super(message);
- }
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewRenderer.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewRenderer.java
deleted file mode 100644
index 8a9279a..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewRenderer.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2010 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.coregui.client;
-
-/**
- * TODO
- *
- * @author Ian Springer
- */
-public interface ViewRenderer {
- /**
- * TODO
- *
- * @param viewId
- * @param lastNode @throws UnknownViewException
- */
- View renderView(ViewId viewId, boolean lastNode) throws UnknownViewException;
-}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java
index 2125a39..9f3a1c5 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java
@@ -18,7 +18,8 @@
*/
package org.rhq.enterprise.gui.coregui.client.dashboard;
-import com.google.gwt.user.client.Random;
+import java.util.ArrayList;
+
import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.widgets.AnimationCallback;
import com.smartgwt.client.widgets.Canvas;
@@ -26,29 +27,35 @@ import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.ButtonItem;
+import com.smartgwt.client.widgets.form.fields.CanvasItem;
import com.smartgwt.client.widgets.form.fields.StaticTextItem;
import com.smartgwt.client.widgets.layout.LayoutSpacer;
import com.smartgwt.client.widgets.layout.VLayout;
+import com.smartgwt.client.widgets.menu.Menu;
+import com.smartgwt.client.widgets.menu.MenuButton;
+import com.smartgwt.client.widgets.menu.MenuItem;
+import com.smartgwt.client.widgets.menu.events.ItemClickEvent;
+import com.smartgwt.client.widgets.menu.events.ItemClickHandler;
-import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.RecentlyAddedView;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.SmallGraphView;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.discovery.AutodiscoveryQueueDataSource;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.discovery.ResourceAutodiscoveryView;
-import org.rhq.enterprise.gui.coregui.client.inventory.summary.SummaryCountsView;
+import org.rhq.enterprise.gui.coregui.client.dashboard.store.StoredDashboard;
+import org.rhq.enterprise.gui.coregui.client.dashboard.store.StoredPortlet;
/**
* @author Greg Hinkle
*/
public class DashboardView extends VLayout {
+ StoredDashboard storedDashboard;
boolean editMode = false;
PortalLayout portalLayout;
DynamicForm form;
- ButtonItem addPortlet;
+ MenuButton addPortlet;
+
- public DashboardView() {
+ public DashboardView(StoredDashboard storedDashboard) {
+ this.storedDashboard = storedDashboard;
setOverflow(Overflow.AUTO);
setPadding(5);
}
@@ -72,42 +79,13 @@ public class DashboardView extends VLayout {
setHeight100();
- portalLayout = new PortalLayout(2);
+ portalLayout = new PortalLayout(storedDashboard.getColumns());
portalLayout.setWidth100();
portalLayout.setHeight100();
- Portlet summaryPortlet = new Portlet(editMode);
- summaryPortlet.setTitle("Inventory Summary");
- summaryPortlet.addItem(new SummaryCountsView());
- summaryPortlet.setHeight(300);
- portalLayout.addPortlet(summaryPortlet);
-
-
- Portlet adPortlet = new Portlet(editMode);
- adPortlet.setTitle("Auto Discovery Queue");
- adPortlet.addItem(new ResourceAutodiscoveryView(true));
- adPortlet.setHeight(250);
- portalLayout.addPortlet(adPortlet);
-
+ loadPortlets();
- // create portlets...
- for (int i = 1; i <= 2; i++) {
- Portlet portlet = new Portlet(editMode);
- portlet.setTitle("Portlet");
-
- // Label label = new Label();
- // label.setAlign(Alignment.CENTER);
- // label.setLayoutAlign(VerticalAlignment.CENTER);
- // label.setContents("Portlet contents");
- // label.setBackgroundColor(colors[Random.nextInt(colors.length - 1)]);
-
- portlet.addItem(new SmallGraphView());
- portlet.setHeight(400);
- portalLayout.addPortlet(portlet);
- }
-
- final VLayout vLayout = new VLayout(15);
form = new DynamicForm();
form.setAutoWidth();
@@ -165,23 +143,36 @@ public class DashboardView extends VLayout {
}
});
- addPortlet = new ButtonItem("addPortlet", "Add Portlet");
- addPortlet.setIcon("[skin]/images/actions/add.png");
- addPortlet.setAutoFit(true);
- addPortlet.setStartRow(false);
- addPortlet.setEndRow(false);
- addPortlet.addClickHandler(new com.smartgwt.client.widgets.form.fields.events.ClickHandler() {
- public void onClick(com.smartgwt.client.widgets.form.fields.events.ClickEvent event) {
+ Menu addPorletMenu = new Menu();
+ for (String portletName : PortletFactory.getRegisteredPortlets()) {
+ addPorletMenu.addItem(new MenuItem(portletName));
+ }
+
+
+ addPortlet = new MenuButton("Add Portlet", addPorletMenu);
- addPortlet();
+// addPortlet = new ButtonItem("addPortlet", "Add Portlet");
+ addPortlet.setIcon("[skin]/images/actions/add.png");
+ addPortlet.setAutoFit(true);
+
+ addPorletMenu.addItemClickHandler(new ItemClickHandler() {
+ public void onItemClick(ItemClickEvent itemClickEvent) {
+ String portalTitle = itemClickEvent.getItem().getTitle();
+ addPortlet(portalTitle);
}
});
+ CanvasItem addCanvas = new CanvasItem();
+ addCanvas.setShowTitle(false);
+ addCanvas.setCanvas(addPortlet);
+ addCanvas.setStartRow(false);
+ addCanvas.setEndRow(false);
+
if (editMode) {
- form.setItems(numColItem, addPortlet, addColumn, removeColumn, editButton);
+ form.setItems(numColItem, addCanvas, addColumn, removeColumn, editButton);
} else {
form.setItems(editButton);
}
@@ -190,69 +181,84 @@ public class DashboardView extends VLayout {
}
+ private void loadPortlets() {
- private void addPortlet() {
- final Portlet newPortlet = new Portlet(true);
- newPortlet.setTitle("Portlet ");
-
-// Label label = new Label();
-// label.setAlign(Alignment.CENTER);
-// label.setLayoutAlign(VerticalAlignment.CENTER);
-// label.setContents("Portlet contents");
-// label.setBackgroundColor(colors[Random.nextInt(colors.length - 1)]);
-// newPortlet.addItem(label);
-
- int nextInt = Random.nextInt() % 3;
-
-// if (nextInt == 0) {
-// ResourceSearchView item = new ResourceSearchView();
-// newPortlet.addItem(item);
-//
-// } else if (nextInt == 1) {
-// newPortlet.addItem(new RolesView());
-// } else {
-// newPortlet.addItem(new SummaryCountsView());
-// }
-
- ClickHandler handler = new ClickHandler() {
- public void onClick(ClickEvent clickEvent) {
- PortletSettingsWindow settingsWindow = new PortletSettingsWindow("Recently Added Resources");
- settingsWindow.show();
+ int col = 0;
+ for (ArrayList<StoredPortlet> column : storedDashboard.getPortlets()) {
+
+ for (StoredPortlet storedPortlet : column) {
+ Canvas portalCanvas = PortletFactory.buildPortlet(storedPortlet.getPortletKey());
+
+ final Portlet portlet = new Portlet(editMode);
+ portlet.addItem(portalCanvas);
+ portlet.setTitle(storedPortlet.getName());
+
+ portlet.setHeight(storedPortlet.getHeight());
+ portlet.setVisible(true);
+
+// newPortlet.setHelpClickHandler(handler);
+// newPortlet.setSettingsClickHandler(handler);
+
+ portalLayout.addPortlet(portlet, col);
+ }
+
+ col++;
+ }
+
+
+ }
+
+
+ private void addPortlet(String portletName) {
+ final Portlet newPortlet = new Portlet(true);
+
+ Canvas canvas = PortletFactory.buildPortlet(portletName);
+
+ newPortlet.setTitle(portletName);
+
+
+ ClickHandler handler = new ClickHandler() {
+ public void onClick(ClickEvent clickEvent) {
+ PortletSettingsWindow settingsWindow = new PortletSettingsWindow("Recently Added Resources");
+ settingsWindow.show();
+ }
+ };
+
+ newPortlet.addItem(canvas);
+
+ newPortlet.setHeight(350);
+ newPortlet.setVisible(false);
+ newPortlet.setHelpClickHandler(handler);
+ newPortlet.setSettingsClickHandler(handler);
+
+
+ PortalColumn column = portalLayout.addPortlet(newPortlet);
+
+ // also insert a blank spacer element, which will trigger the built-in
+ // animateMembers layout animation
+ final LayoutSpacer placeHolder = new LayoutSpacer();
+ placeHolder.setRect(newPortlet.getRect());
+ column.addMember(placeHolder, 0); // add to top
+
+ // create an outline around the clicked button
+ final Canvas outline = new Canvas();
+ outline.setLeft(form.getAbsoluteLeft() + addPortlet.getLeft());
+ outline.setTop(form.getAbsoluteTop());
+ outline.setWidth(addPortlet.getWidth());
+ outline.setHeight(addPortlet.getHeight());
+ outline.setBorder("2px solid 8289A6");
+ outline.draw();
+ outline.bringToFront();
+
+ outline.animateRect(newPortlet.getPageLeft(), newPortlet.getPageTop(),
+ newPortlet.getVisibleWidth(), newPortlet.getViewportHeight(),
+ new AnimationCallback() {
+ public void execute(boolean earlyFinish) {
+ // callback at end of animation - destroy placeholder and outline; show the new portlet
+ placeHolder.destroy();
+ outline.destroy();
+ newPortlet.show();
}
- };
-
- newPortlet.addItem(new RecentlyAddedView());
- newPortlet.setHeight(350);
- newPortlet.setVisible(false);
- newPortlet.setHelpClickHandler(handler);
- newPortlet.setSettingsClickHandler(handler);
- PortalColumn column = portalLayout.addPortlet(newPortlet);
-
- // also insert a blank spacer element, which will trigger the built-in
- // animateMembers layout animation
- final LayoutSpacer placeHolder = new LayoutSpacer();
- placeHolder.setRect(newPortlet.getRect());
- column.addMember(placeHolder, 0); // add to top
-
- // create an outline around the clicked button
- final Canvas outline = new Canvas();
- outline.setLeft(form.getAbsoluteLeft() + addPortlet.getLeft());
- outline.setTop(form.getAbsoluteTop());
- outline.setWidth(addPortlet.getWidth());
- outline.setHeight(addPortlet.getHeight());
- outline.setBorder("2px solid 8289A6");
- outline.draw();
- outline.bringToFront();
-
- outline.animateRect(newPortlet.getPageLeft(), newPortlet.getPageTop(),
- newPortlet.getVisibleWidth(), newPortlet.getViewportHeight(),
- new AnimationCallback() {
- public void execute(boolean earlyFinish) {
- // callback at end of animation - destroy placeholder and outline; show the new portlet
- placeHolder.destroy();
- outline.destroy();
- newPortlet.show();
- }
- }, 750);
+ }, 750);
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java
new file mode 100644
index 0000000..14334e7
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java
@@ -0,0 +1,124 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.coregui.client.dashboard;
+
+import java.util.ArrayList;
+
+import com.smartgwt.client.types.Overflow;
+import com.smartgwt.client.widgets.layout.VLayout;
+import com.smartgwt.client.widgets.tab.Tab;
+import com.smartgwt.client.widgets.tab.TabSet;
+
+import org.rhq.core.domain.resource.InventorySummary;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.queue.AutodiscoveryPortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.resource.graph.GraphPortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.platform.PlatformPortletView;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.alerts.RecentAlertsPortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.imported.RecentlyAddedView;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.summary.InventorySummaryView;
+import org.rhq.enterprise.gui.coregui.client.dashboard.store.DashboardStore;
+import org.rhq.enterprise.gui.coregui.client.dashboard.store.StoredDashboard;
+import org.rhq.enterprise.gui.coregui.client.dashboard.store.StoredPortlet;
+
+/**
+ * @author Greg Hinkle
+ */
+public class DashboardsView extends VLayout {
+
+ private TabSet tabSet;
+
+ private DashboardStore dashboardStore;
+
+
+ public DashboardsView() {
+ setOverflow(Overflow.AUTO);
+ setPadding(5);
+ setWidth100();
+ setHeight100();
+
+ }
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+
+ tabSet = new TabSet();
+ tabSet.setWidth100();
+ tabSet.setHeight100();
+
+ dashboardStore = new DashboardStore();
+
+ dashboardStore.getStoredDashboards().add(getDefaultDashboard());
+
+
+ for (StoredDashboard dashboard : dashboardStore.getStoredDashboards()) {
+ DashboardView dashboardView = new DashboardView(dashboard);
+
+ Tab tab = new Tab(dashboard.getName());
+ tab.setPane(dashboardView);
+
+ tabSet.addTab(tab);
+ }
+
+ addMember(tabSet);
+ }
+
+
+ protected StoredDashboard getDefaultDashboard() {
+
+ StoredDashboard dashboard = new StoredDashboard();
+ dashboard.setName("Default Dashboard");
+ dashboard.setColumns(2);
+ dashboard.setColumnWidths("30%","70%");
+
+
+ ArrayList<StoredPortlet> col1 = new ArrayList<StoredPortlet>();
+ ArrayList<StoredPortlet> col2 = new ArrayList<StoredPortlet>();
+
+
+
+
+ StoredPortlet summary = new StoredPortlet("Inventory Summary", InventorySummaryView.KEY, 300);
+ col1.add(summary);
+
+ StoredPortlet graph = new StoredPortlet("ghinkle (MAC OS X) CPU", GraphPortlet.KEY, 250);
+ col1.add(graph);
+
+ StoredPortlet platformSummary = new StoredPortlet("Platform Summary", PlatformPortletView.KEY, 300);
+ col2.add(platformSummary);
+
+ StoredPortlet discoveryQueue = new StoredPortlet("Discovery Queue", AutodiscoveryPortlet.KEY, 250);
+ col2.add(discoveryQueue);
+
+ StoredPortlet recentAlerts = new StoredPortlet("Recent Alerts", RecentAlertsPortlet.KEY, 250);
+ col2.add(recentAlerts);
+
+ StoredPortlet recentlyAdded = new StoredPortlet("Recently Added Resources", RecentlyAddedView.KEY, 250);
+ col2.add(recentlyAdded);
+
+
+ dashboard.getPortlets().add(col1);
+ dashboard.getPortlets().add(col2);
+
+
+
+ return dashboard;
+
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/OldDashboardView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/OldDashboardView.java
new file mode 100644
index 0000000..2fc4826
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/OldDashboardView.java
@@ -0,0 +1,265 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.coregui.client.dashboard;
+
+import com.google.gwt.user.client.Random;
+import com.smartgwt.client.types.Overflow;
+import com.smartgwt.client.widgets.AnimationCallback;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.events.ClickEvent;
+import com.smartgwt.client.widgets.events.ClickHandler;
+import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.fields.ButtonItem;
+import com.smartgwt.client.widgets.form.fields.StaticTextItem;
+import com.smartgwt.client.widgets.layout.LayoutSpacer;
+import com.smartgwt.client.widgets.layout.VLayout;
+
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.imported.RecentlyAddedView;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.platform.PlatformPortletView;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.summary.InventorySummaryView;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.SmallGraphView;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.discovery.ResourceAutodiscoveryView;
+
+/**
+ * @author Greg Hinkle
+ */
+public class OldDashboardView extends VLayout {
+
+
+ boolean editMode = false;
+
+ PortalLayout portalLayout;
+ DynamicForm form;
+ ButtonItem addPortlet;
+
+ public OldDashboardView() {
+ setOverflow(Overflow.AUTO);
+ setPadding(5);
+ }
+
+ public void redraw() {
+ for (Canvas c : getChildren()) {
+ c.destroy();
+ }
+
+ buildPortlets();
+ }
+
+ @Override
+ protected void onDraw() {
+ super.onDraw();
+ buildPortlets();
+ }
+
+ public void buildPortlets() {
+ setWidth100();
+ setHeight100();
+
+
+ portalLayout = new PortalLayout(2);
+ portalLayout.setWidth100();
+ portalLayout.setHeight100();
+
+
+ Portlet summaryPortlet = new Portlet(editMode);
+ summaryPortlet.setTitle("Inventory Summary");
+ summaryPortlet.addItem(new InventorySummaryView());
+ summaryPortlet.setHeight(300);
+ portalLayout.addPortlet(summaryPortlet);
+
+
+ Portlet platformsPortlet = new Portlet(editMode);
+ platformsPortlet.setTitle("Platform Portlet");
+ platformsPortlet.addItem(new PlatformPortletView());
+ platformsPortlet.setHeight(300);
+ portalLayout.addPortlet(platformsPortlet);
+
+
+ Portlet adPortlet = new Portlet(editMode);
+ adPortlet.setTitle("Auto Discovery Queue");
+ adPortlet.addItem(new ResourceAutodiscoveryView(true));
+ adPortlet.setHeight(250);
+ portalLayout.addPortlet(adPortlet);
+
+
+ // create portlets...
+ for (int i = 1; i <= 2; i++) {
+ Portlet portlet = new Portlet(editMode);
+ portlet.setTitle("Portlet");
+
+ // Label label = new Label();
+ // label.setAlign(Alignment.CENTER);
+ // label.setLayoutAlign(VerticalAlignment.CENTER);
+ // label.setContents("Portlet contents");
+ // label.setBackgroundColor(colors[Random.nextInt(colors.length - 1)]);
+
+ portlet.addItem(new SmallGraphView());
+ portlet.setHeight(400);
+ portalLayout.addPortlet(portlet);
+ }
+
+ final VLayout vLayout = new VLayout(15);
+
+ form = new DynamicForm();
+ form.setAutoWidth();
+ form.setNumCols(7);
+
+ final StaticTextItem numColItem = new StaticTextItem();
+ numColItem.setTitle("Columns");
+ numColItem.setValue(portalLayout.getMembers().length);
+
+ ButtonItem addColumn = new ButtonItem("addColumn", "Add Column");
+// addColumn.setIcon("silk/application_side_expand.png");
+ addColumn.setAutoFit(true);
+ addColumn.setStartRow(false);
+ addColumn.setEndRow(false);
+
+
+ addColumn.addClickHandler(new com.smartgwt.client.widgets.form.fields.events.ClickHandler() {
+ public void onClick(com.smartgwt.client.widgets.form.fields.events.ClickEvent event) {
+ portalLayout.addMember(new PortalColumn());
+ numColItem.setValue(portalLayout.getMembers().length);
+
+ }
+ });
+
+ ButtonItem removeColumn = new ButtonItem("removeColumn", "Remove Column");
+// removeColumn.setIcon("silk/application_side_contract.png");
+ removeColumn.setAutoFit(true);
+ removeColumn.setStartRow(false);
+ removeColumn.setEndRow(false);
+
+
+ removeColumn.addClickHandler(new com.smartgwt.client.widgets.form.fields.events.ClickHandler() {
+ public void onClick(com.smartgwt.client.widgets.form.fields.events.ClickEvent event) {
+
+ Canvas[] canvases = portalLayout.getMembers();
+ int numMembers = canvases.length;
+ if (numMembers > 0) {
+ Canvas lastMember = canvases[numMembers - 1];
+ portalLayout.removeMember(lastMember);
+ numColItem.setValue(numMembers - 1);
+ }
+
+ }
+ });
+
+
+ final ButtonItem editButton = new ButtonItem("editable", editMode ? "View Mode" : "Edit Mode");
+ editButton.setAutoFit(true);
+ editButton.setStartRow(false);
+ editButton.setEndRow(false);
+ editButton.addClickHandler(new com.smartgwt.client.widgets.form.fields.events.ClickHandler() {
+ public void onClick(com.smartgwt.client.widgets.form.fields.events.ClickEvent clickEvent) {
+ editMode = !editMode;
+ redraw();
+ }
+ });
+
+ addPortlet = new ButtonItem("addPortlet", "Add Portlet");
+ addPortlet.setIcon("[skin]/images/actions/add.png");
+ addPortlet.setAutoFit(true);
+
+ addPortlet.setStartRow(false);
+ addPortlet.setEndRow(false);
+ addPortlet.addClickHandler(new com.smartgwt.client.widgets.form.fields.events.ClickHandler() {
+ public void onClick(com.smartgwt.client.widgets.form.fields.events.ClickEvent event) {
+
+ addPortlet();
+
+ }
+ });
+
+
+ if (editMode) {
+ form.setItems(numColItem, addPortlet, addColumn, removeColumn, editButton);
+ } else {
+ form.setItems(editButton);
+ }
+ addMember(form);
+ addMember(portalLayout);
+
+ }
+
+
+ private void addPortlet() {
+ final Portlet newPortlet = new Portlet(true);
+ newPortlet.setTitle("Portlet ");
+
+// Label label = new Label();
+// label.setAlign(Alignment.CENTER);
+// label.setLayoutAlign(VerticalAlignment.CENTER);
+// label.setContents("Portlet contents");
+// label.setBackgroundColor(colors[Random.nextInt(colors.length - 1)]);
+// newPortlet.addItem(label);
+
+ int nextInt = Random.nextInt() % 3;
+
+// if (nextInt == 0) {
+// ResourceSearchView item = new ResourceSearchView();
+// newPortlet.addItem(item);
+//
+// } else if (nextInt == 1) {
+// newPortlet.addItem(new RolesView());
+// } else {
+// newPortlet.addItem(new SummaryCountsView());
+// }
+
+ ClickHandler handler = new ClickHandler() {
+ public void onClick(ClickEvent clickEvent) {
+ PortletSettingsWindow settingsWindow = new PortletSettingsWindow("Recently Added Resources");
+ settingsWindow.show();
+ }
+ };
+
+ newPortlet.addItem(new RecentlyAddedView());
+ newPortlet.setHeight(350);
+ newPortlet.setVisible(false);
+ newPortlet.setHelpClickHandler(handler);
+ newPortlet.setSettingsClickHandler(handler);
+ PortalColumn column = portalLayout.addPortlet(newPortlet);
+
+ // also insert a blank spacer element, which will trigger the built-in
+ // animateMembers layout animation
+ final LayoutSpacer placeHolder = new LayoutSpacer();
+ placeHolder.setRect(newPortlet.getRect());
+ column.addMember(placeHolder, 0); // add to top
+
+ // create an outline around the clicked button
+ final Canvas outline = new Canvas();
+ outline.setLeft(form.getAbsoluteLeft() + addPortlet.getLeft());
+ outline.setTop(form.getAbsoluteTop());
+ outline.setWidth(addPortlet.getWidth());
+ outline.setHeight(addPortlet.getHeight());
+ outline.setBorder("2px solid 8289A6");
+ outline.draw();
+ outline.bringToFront();
+
+ outline.animateRect(newPortlet.getPageLeft(), newPortlet.getPageTop(),
+ newPortlet.getVisibleWidth(), newPortlet.getViewportHeight(),
+ new AnimationCallback() {
+ public void execute(boolean earlyFinish) {
+ // callback at end of animation - destroy placeholder and outline; show the new portlet
+ placeHolder.destroy();
+ outline.destroy();
+ newPortlet.show();
+ }
+ }, 750);
+ }
+}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortalLayout.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortalLayout.java
index 1720962..b1b7b38 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortalLayout.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortalLayout.java
@@ -49,4 +49,14 @@ public class PortalLayout extends HLayout {
fewestPortletsColumn.addMember(portlet);
return fewestPortletsColumn;
}
+
+
+ public PortalColumn addPortlet(Portlet portlet, int column) {
+ PortalColumn fewestPortletsColumn = (PortalColumn) getMember(column);
+
+ fewestPortletsColumn.addMember(portlet);
+
+ return fewestPortletsColumn;
+ }
+
}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
new file mode 100644
index 0000000..e46aaa6
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
@@ -0,0 +1,79 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.coregui.client.dashboard;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.google.gwt.core.client.GWT;
+import com.smartgwt.client.widgets.Canvas;
+
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.queue.AutodiscoveryPortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.resource.graph.GraphPortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.alerts.RecentAlertsPortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.imported.RecentlyAddedView;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.platform.PlatformPortletView;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.summary.InventorySummaryView;
+
+/**
+ * @author Greg Hinkle
+ */
+public class PortletFactory {
+
+
+ private static Map<String, PortletViewFactory> registeredPortlets;
+
+ static {
+ registeredPortlets = new HashMap<String, PortletViewFactory>();
+
+
+ registeredPortlets.put(InventorySummaryView.KEY, InventorySummaryView.Factory.INSTANCE);
+ registeredPortlets.put(RecentlyAddedView.KEY, RecentlyAddedView.Factory.INSTANCE);
+ registeredPortlets.put(PlatformPortletView.KEY, PlatformPortletView.Factory.INSTANCE);
+
+ registeredPortlets.put(AutodiscoveryPortlet.KEY, AutodiscoveryPortlet.Factory.INSTANCE);
+
+ registeredPortlets.put(RecentAlertsPortlet.KEY, RecentAlertsPortlet.Factory.INSTANCE);
+
+ registeredPortlets.put(GraphPortlet.KEY, GraphPortlet.Factory.INSTANCE);
+
+ }
+
+ public static Canvas buildPortlet(String portletKey) {
+
+
+ PortletViewFactory viewFactory = registeredPortlets.get(portletKey);
+
+ Canvas canvas = null;
+ canvas = (Canvas) viewFactory.getInstance();
+
+ return canvas;
+
+ }
+
+ public static List<String> getRegisteredPortlets() {
+
+ ArrayList portlets = new ArrayList(registeredPortlets.keySet());
+ Collections.sort(portlets);
+ return portlets;
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletView.java
new file mode 100644
index 0000000..342c9ce
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletView.java
@@ -0,0 +1,36 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.coregui.client.dashboard;
+
+import com.smartgwt.client.widgets.Canvas;
+
+import org.rhq.enterprise.gui.coregui.client.dashboard.store.StoredPortlet;
+
+/**
+ * @author Greg Hinkle
+ */
+public interface PortletView {
+
+ void configure(StoredPortlet storedPortlet);
+
+ Canvas getHelpCanvas();
+
+ Canvas getSettingsCanvas();
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletViewFactory.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletViewFactory.java
new file mode 100644
index 0000000..34cfaf3
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletViewFactory.java
@@ -0,0 +1,28 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.coregui.client.dashboard;
+
+/**
+ * @author Greg Hinkle
+ */
+public interface PortletViewFactory {
+
+ PortletView getInstance();
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/RecentlyAddedResource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/RecentlyAddedResource.java
deleted file mode 100644
index db4205a..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/RecentlyAddedResource.java
+++ /dev/null
@@ -1,78 +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.
- */
-
-package org.rhq.enterprise.gui.coregui.client.dashboard.portlets;
-
-import com.google.gwt.user.client.rpc.IsSerializable;
-
-/**
- * This class is just for use in prototyping the TreeGrid and DataSource classes.
- *
- * @author John Sanda
- */
-public class RecentlyAddedResource implements IsSerializable {
-
- private RecentlyAddedResource parent;
-
- private String resourceName;
-
- private String timestamp;
-
- public RecentlyAddedResource() {
- }
-
- public RecentlyAddedResource(String resourceName, String timestamp) {
- this(resourceName, timestamp, null);
- }
-
- public RecentlyAddedResource(String resourceName, String timestamp, RecentlyAddedResource parent) {
- this.resourceName = resourceName;
- this.timestamp = timestamp;
- this.parent = parent;
- }
-
- public String getResourceName() {
- return resourceName;
- }
-
- public void setResourceName(String resourceName) {
- this.resourceName = resourceName;
- }
-
- public String getTimestamp() {
- return timestamp;
- }
-
- public void setTimestamp(String timestamp) {
- this.timestamp = timestamp;
- }
-
- public RecentlyAddedResource getParent() {
- return parent;
- }
-
- public void setParent(RecentlyAddedResource parent) {
- this.parent = parent;
- }
-
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/RecentlyAddedResourceDS.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/RecentlyAddedResourceDS.java
deleted file mode 100644
index df1ac0f..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/RecentlyAddedResourceDS.java
+++ /dev/null
@@ -1,226 +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.
- */
-
-package org.rhq.enterprise.gui.coregui.client.dashboard.portlets;
-
-import com.google.gwt.i18n.client.DateTimeFormat;
-import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.smartgwt.client.data.DSRequest;
-import com.smartgwt.client.data.DSResponse;
-import com.smartgwt.client.data.DataSource;
-import com.smartgwt.client.data.fields.DataSourceTextField;
-import com.smartgwt.client.types.DSDataFormat;
-import com.smartgwt.client.types.DSProtocol;
-import com.smartgwt.client.widgets.tree.TreeNode;
-import org.rhq.core.domain.criteria.ResourceCriteria;
-import org.rhq.core.domain.measurement.AvailabilityType;
-import org.rhq.core.domain.resource.Resource;
-import org.rhq.core.domain.resource.ResourceCategory;
-import org.rhq.core.domain.resource.ResourceType;
-import org.rhq.core.domain.resource.composite.RecentlyAddedResourceComposite;
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-public class RecentlyAddedResourceDS extends DataSource {
-
-
- public RecentlyAddedResourceDS() {
- setClientOnly(false);
- setDataProtocol(DSProtocol.CLIENTCUSTOM);
- setDataFormat(DSDataFormat.CUSTOM);
-
-
- DataSourceTextField idField = new DataSourceTextField("id", "ID");
- idField.setPrimaryKey(true);
-
- DataSourceTextField parentIdField = new DataSourceTextField("parentId", "Parent ID");
- parentIdField.setForeignKey("id");
-
- DataSourceTextField resourceNameField = new DataSourceTextField("name", "Resource Name");
- resourceNameField.setPrimaryKey(true);
-
- DataSourceTextField timestampField = new DataSourceTextField("timestamp", "Date/Time");
-
- setFields(idField, parentIdField, resourceNameField, timestampField);
- }
-
- @Override
- protected Object transformRequest(DSRequest request) {
- DSResponse response = new DSResponse();
- response.setAttribute("clientContext", request.getAttributeAsObject("clientContext"));
- // Asume success
- response.setStatus(0);
- switch (request.getOperationType()) {
- case FETCH:
- executeFetch(request, response);
- break;
- default:
- break;
- }
-
- return request.getData();
- }
-
- public void executeFetch(final DSRequest request, final DSResponse response) {
-
- ResourceCriteria c = new ResourceCriteria();
-
- String p = request.getCriteria().getAttribute("parentId");
-
- if (p == null) {
- c.addFilterResourceCategory(ResourceCategory.PLATFORM);
- c.fetchChildResources(true);
- } else {
- c.addFilterParentResourceId(Integer.parseInt(p));
- }
-
- // TODO GH: Enhance resourceCriteria query to support itime based filtering for
- // "Recently imported" resources
-
- GWTServiceLookup.getResourceService().findRecentlyAddedResources(0, 100,
- new AsyncCallback<List<RecentlyAddedResourceComposite>>() {
- public void onFailure(Throwable throwable) {
- CoreGUI.getErrorHandler().handleError("Failed to load recently added resources", throwable);
- }
-
- public void onSuccess(List<RecentlyAddedResourceComposite> recentlyAddedList) {
- List<RecentlyAddedResourceComposite> list = new ArrayList<RecentlyAddedResourceComposite>();
-
- for (RecentlyAddedResourceComposite recentlyAdded : recentlyAddedList) {
- list.add(recentlyAdded);
- list.addAll(recentlyAdded.getChildren());
- }
-
- response.setData(buildNodes(list));
- response.setTotalRows(list.size());
- processResponse(request.getRequestId(), response);
- }
- });
-//
-// GWTServiceLookup.getResourceService().findResourcesByCriteria(c, new AsyncCallback<PageList<Resource>>() {
-// public void onFailure(Throwable caught) {
-// CoreGUI.getErrorHandler().handleError("Failed to load recently added resources data",caught);
-// response.setStatus(DSResponse.STATUS_FAILURE);
-// processResponse(request.getRequestId(), response);
-// }
-//
-// public void onSuccess(PageList<Resource> result) {
-// PageList<Resource> all = new PageList<Resource>();
-//
-// for (Resource root : result) {
-// all.add(root);
-// if (root.getChildResources() != null)
-// all.addAll(root.getChildResources());
-// }
-//
-//
-// response.setData(buildNodes(all));
-// response.setTotalRows(all.getTotalSize());
-// processResponse(request.getRequestId(), response);
-// }
-// });
- }
-
-// private TreeNode[] buildNodes(PageList<Resource> list) {
-// TreeNode[] treeNodes = new TreeNode[list.size()];
-// for (int i = 0; i < list.size(); ++i) {
-// treeNodes[i] = new ResourceTreeNode(list.get(i));
-// }
-// return treeNodes;
-// }
-
- private TreeNode[] buildNodes(List<RecentlyAddedResourceComposite> list) {
- TreeNode[] treeNodes = new TreeNode[list.size()];
- for (int i = 0; i < list.size(); ++i) {
- treeNodes[i] = new RecentlyAddedTreeNode(list.get(i));
- }
- return treeNodes;
- }
-
- public static class RecentlyAddedTreeNode extends TreeNode {
- private RecentlyAddedResourceComposite recentlyAdded;
-
- private RecentlyAddedTreeNode(RecentlyAddedResourceComposite c) {
- recentlyAdded = c;
- Date dateAdded = new Date(recentlyAdded.getCtime());
-
- String id = String.valueOf(recentlyAdded.getId());
- String parentId = recentlyAdded.getParentId() == 0 ? null
- : String.valueOf((recentlyAdded.getParentId()));
-
- setID(id);
- setParentID(parentId);
-
- setAttribute("id", id);
- setAttribute("parentId", parentId);
- setAttribute("name", recentlyAdded.getName());
- setAttribute("timestamp", DateTimeFormat.getMediumDateTimeFormat().format(dateAdded));
- setIsFolder(recentlyAdded.getParentId() == 0);
- }
- }
-
- public static class ResourceTreeNode extends TreeNode {
-
- private Resource resource;
-
- private ResourceTreeNode(Resource resource) {
- this.resource = resource;
-
- String id = String.valueOf(resource.getId());
- String parentId = resource.getParentResource() == null ? null
- : String.valueOf((resource.getParentResource().getId()));
-
- setID(id);
- setParentID(parentId);
-
- setAttribute("id", id);
- setAttribute("parentId", parentId);
- setAttribute("name", resource.getName());
- setAttribute("timestamp", "");//String.valueOf(resource.getItime())); // Seems to be null
- setAttribute("currentAvailability",
- resource.getCurrentAvailability().getAvailabilityType() == AvailabilityType.UP
- ? "/images/icons/availability_green_16.png"
- : "/images/icons/availability_red_16.png");
- }
-
- public Resource getResource() {
- return resource;
- }
-
- public void setResource(Resource resource) {
- this.resource = resource;
- }
-
- public ResourceType getResourceType() {
- return resource.getResourceType();
- }
-
- public String getParentId() {
- return getAttribute("parentId");
- }
- }
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/RecentlyAddedView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/RecentlyAddedView.java
deleted file mode 100644
index fe023a6..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/RecentlyAddedView.java
+++ /dev/null
@@ -1,56 +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.
- */
-
-package org.rhq.enterprise.gui.coregui.client.dashboard.portlets;
-
-import com.smartgwt.client.data.DataSource;
-import com.smartgwt.client.widgets.grid.ListGridField;
-import com.smartgwt.client.widgets.layout.VLayout;
-import com.smartgwt.client.widgets.tree.TreeGrid;
-
-import org.rhq.enterprise.gui.coregui.client.components.table.Table;
-
-public class RecentlyAddedView extends VLayout {
-
-
- @Override
- protected void onInit() {
- super.onInit();
- TreeGrid treeGrid = new TreeGrid();
- treeGrid.setDataSource(new RecentlyAddedResourceDS());
- treeGrid.setAutoFetchData(true);
- treeGrid.setTitle("Recently Added Resources");
- treeGrid.setResizeFieldsInRealTime(true);
- treeGrid.setTreeFieldTitle("Resource Name");
-
- ListGridField resourceNameField = new ListGridField("name", "Resource Name");
- ListGridField timestampField = new ListGridField("timestamp", "Date//Time");
-
- treeGrid.setFields(resourceNameField, timestampField);
-
-
- addMember(treeGrid);
-
- }
-
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java
new file mode 100644
index 0000000..8425ad5
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java
@@ -0,0 +1,56 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.coregui.client.dashboard.portlets.inventory.queue;
+
+import com.google.gwt.core.client.GWT;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.HTMLFlow;
+
+import org.rhq.enterprise.gui.coregui.client.dashboard.PortletView;
+import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
+import org.rhq.enterprise.gui.coregui.client.dashboard.store.StoredPortlet;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.discovery.ResourceAutodiscoveryView;
+
+/**
+ * @author Greg Hinkle
+ */
+public class AutodiscoveryPortlet extends ResourceAutodiscoveryView implements PortletView {
+
+ public static final String KEY = "Discovery Queue";
+
+ public void configure(StoredPortlet storedPortlet) {
+ // TODO: Implement this method.
+ }
+
+ public Canvas getHelpCanvas() {
+ return new HTMLFlow("This portlet offers the ability to import newly discovered resources into the inventory " +
+ "for monitoring and management or to ingnore them from further action.");
+ }
+
+ public Canvas getSettingsCanvas() {
+ return null; // TODO: Implement this method.
+ }
+
+ public static final class Factory implements PortletViewFactory {
+ public static PortletViewFactory INSTANCE = new Factory();
+ public final PortletView getInstance() {
+ return GWT.create(AutodiscoveryPortlet.class);
+ }
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/graph/GraphPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/graph/GraphPortlet.java
new file mode 100644
index 0000000..ccba4e8
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/graph/GraphPortlet.java
@@ -0,0 +1,59 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.coregui.client.dashboard.portlets.inventory.resource.graph;
+
+import com.google.gwt.core.client.GWT;
+import com.smartgwt.client.widgets.Canvas;
+
+import org.rhq.enterprise.gui.coregui.client.dashboard.PortletView;
+import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
+import org.rhq.enterprise.gui.coregui.client.dashboard.store.StoredPortlet;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.SmallGraphView;
+
+/**
+ * @author Greg Hinkle
+ */
+public class GraphPortlet extends SmallGraphView implements PortletView {
+
+ public static final String KEY = "Resource Graph";
+
+ public GraphPortlet() {
+ super(10001, 10100);
+ }
+
+ public void configure(StoredPortlet storedPortlet) {
+ // TODO: Implement this method.
+ }
+
+ public Canvas getHelpCanvas() {
+ return null; // TODO: Implement this method.
+ }
+
+ public Canvas getSettingsCanvas() {
+ return null; // TODO: Implement this method.
+ }
+
+ public static final class Factory implements PortletViewFactory {
+ public static PortletViewFactory INSTANCE = new Factory();
+
+ public final PortletView getInstance() {
+ return GWT.create(GraphPortlet.class);
+ }
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformMetricDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformMetricDataSource.java
new file mode 100644
index 0000000..7f9d8fd
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformMetricDataSource.java
@@ -0,0 +1,58 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.coregui.client.dashboard.portlets.platform;
+
+import com.smartgwt.client.data.DataSourceField;
+import com.smartgwt.client.data.fields.DataSourceImageField;
+import com.smartgwt.client.data.fields.DataSourceIntegerField;
+import com.smartgwt.client.data.fields.DataSourceTextField;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDatasource;
+
+/**
+ * @author Greg Hinkle
+ */
+public class PlatformMetricDataSource extends ResourceDatasource {
+
+ PlatformPortletView view;
+
+ public PlatformMetricDataSource(PlatformPortletView view) {
+ super();
+ this.view = view;
+
+ DataSourceTextField cpuField = new DataSourceTextField("cpu","CPU");
+ addField(cpuField);
+ DataSourceTextField memoryField = new DataSourceTextField("memory", "Memory");
+ addField(memoryField);
+ DataSourceTextField swapField = new DataSourceTextField("swap", "Swap");
+ // todo swap
+ }
+
+
+
+ @Override
+ public ListGridRecord copyValues(Resource from) {
+ ListGridRecord record = super.copyValues(from);
+
+ view.loadMetricsForResource(from, record);
+ return record;
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformPortletView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformPortletView.java
new file mode 100644
index 0000000..c956e88
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformPortletView.java
@@ -0,0 +1,364 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.coregui.client.dashboard.portlets.platform;
+
+import java.util.HashMap;
+import java.util.Set;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.data.Criteria;
+import com.smartgwt.client.types.Autofit;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.HTMLFlow;
+import com.smartgwt.client.widgets.Img;
+import com.smartgwt.client.widgets.grid.CellFormatter;
+import com.smartgwt.client.widgets.grid.ListGrid;
+import com.smartgwt.client.widgets.grid.ListGridField;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+import com.smartgwt.client.widgets.layout.HLayout;
+import com.smartgwt.client.widgets.layout.VLayout;
+
+import org.rhq.core.domain.criteria.ResourceTypeCriteria;
+import org.rhq.core.domain.measurement.MeasurementConverterClient;
+import org.rhq.core.domain.measurement.MeasurementData;
+import org.rhq.core.domain.measurement.MeasurementDataNumeric;
+import org.rhq.core.domain.measurement.MeasurementDefinition;
+import org.rhq.core.domain.measurement.MeasurementUnits;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceCategory;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.components.HeaderLabel;
+import org.rhq.enterprise.gui.coregui.client.dashboard.PortletView;
+import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
+import org.rhq.enterprise.gui.coregui.client.dashboard.store.StoredPortlet;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.gwt.MeasurementDataGWTServiceAsync;
+import org.rhq.enterprise.gui.coregui.client.gwt.ResourceTypeGWTServiceAsync;
+
+/**
+ * @author Greg Hinkle
+ */
+public class PlatformPortletView extends VLayout implements PortletView {
+
+
+ private MeasurementDataGWTServiceAsync measurementService = GWTServiceLookup.getMeasurementDataService();
+ private ResourceTypeGWTServiceAsync typeService = GWTServiceLookup.getResourceTypeGWTService();
+
+
+ private PlatformListGrid listGrid;
+
+ private HashMap<Integer, ResourceType> types = new HashMap<Integer, ResourceType>();
+ private HashMap<Integer, PlatformMetricDefinitions> platformMetricDefinitionsHashMap = new HashMap<Integer, PlatformMetricDefinitions>();
+ public static final String KEY = "Platforms Summary";
+
+
+ public PlatformPortletView() {
+
+ prefetch();
+ }
+
+ private void prefetch() {
+
+ ResourceTypeCriteria typeCriteria = new ResourceTypeCriteria();
+ typeCriteria.addFilterCategory(ResourceCategory.PLATFORM);
+ typeCriteria.fetchMetricDefinitions(true);
+ typeCriteria.fetchOperationDefinitions(true);
+
+ // TODO GH: Find a way to pass resource type criteria lookups through the type cache
+ typeService.findResourceTypesByCriteria(typeCriteria, new AsyncCallback<PageList<ResourceType>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Couldn't load type data", caught);
+ }
+
+ public void onSuccess(PageList<ResourceType> result) {
+ setTypes(result);
+ buildUI();
+ }
+ });
+ }
+
+
+ private void buildUI() {
+
+ addMember(new HeaderLabel("Platforms"));
+
+ listGrid = new PlatformListGrid();
+ listGrid.setDataSource(new PlatformMetricDataSource(this));
+ listGrid.setInitialCriteria(new Criteria("category", ResourceCategory.PLATFORM.name()));
+ listGrid.setAutoFetchData(true);
+ listGrid.setUseAllDataSourceFields(true);
+ listGrid.setAutoFitData(Autofit.HORIZONTAL);
+
+ ListGridField nameField = new ListGridField("name", "Name", 250);
+ nameField.setCellFormatter(new CellFormatter() {
+ public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
+ return "<a href=\"#Resource/" + listGridRecord.getAttribute("id") + "\">" + o + "</a>";
+ }
+ });
+ listGrid.setFields(nameField);
+
+ addMember(listGrid);
+
+ listGrid.getField("icon").setWidth(25);
+
+ listGrid.hideField("id");
+ listGrid.hideField("description");
+ listGrid.hideField("pluginName");
+ listGrid.hideField("category");
+ listGrid.hideField("currentAvailability");
+
+
+ }
+
+
+ protected void loadMetricsForResource(Resource resource, final ListGridRecord record) {
+ final PlatformMetricDefinitions pmd = platformMetricDefinitionsHashMap.get(resource.getResourceType().getId());
+ measurementService.findLiveData(
+ resource.getId(),
+ pmd.getDefinitionIds(),
+ new AsyncCallback<Set<MeasurementData>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to load platform metrics", caught);
+ }
+
+ public void onSuccess(Set<MeasurementData> result) {
+
+ for (MeasurementData data : result) {
+ if (data instanceof MeasurementDataNumeric) {
+ record.setAttribute(data.getName(), ((MeasurementDataNumeric) data).getValue());
+ }
+ }
+
+ /*double idle = record.getAttributeAsDouble(CPUMetric.Idle.property);
+ record.setAttribute("cpu", 1 - idle);
+
+ double totalMem = record.getAttributeAsDouble(MemoryMetric.Total.property);
+ double usedMem = record.getAttributeAsDouble(MemoryMetric.Used.property);
+ double percent = usedMem / totalMem;
+ record.setAttribute("memory", percent);
+ */
+
+ listGrid.setSortField(1);
+ listGrid.refreshFields();
+ markForRedraw();
+ }
+ });
+ }
+
+
+ private void setTypes(PageList<ResourceType> types) {
+
+ for (ResourceType platformType : types) {
+
+ Set<MeasurementDefinition> defs = platformType.getMetricDefinitions();
+
+ PlatformMetricDefinitions pmd = new PlatformMetricDefinitions();
+ pmd.freeMemory = findDef(defs, MemoryMetric.Free.property);
+ pmd.usedMemory = findDef(defs, MemoryMetric.Used.property);
+ pmd.totalMemory = findDef(defs, MemoryMetric.Total.property);
+
+ pmd.freeSwap = findDef(defs, SwapMetric.Free.property);
+ pmd.usedSwap = findDef(defs, SwapMetric.Used.property);
+ pmd.totalSwap = findDef(defs, SwapMetric.Total.property);
+
+ pmd.idleCpu = findDef(defs, CPUMetric.Idle.property);
+ pmd.systemCpu = findDef(defs, CPUMetric.System.property);
+ pmd.userCpu = findDef(defs, CPUMetric.User.property);
+ pmd.waitCpu = findDef(defs, CPUMetric.Wait.property);
+
+ platformMetricDefinitionsHashMap.put(platformType.getId(), pmd);
+ }
+ }
+
+ private MeasurementDefinition findDef(Set<MeasurementDefinition> defs, String property) {
+ for (MeasurementDefinition def : defs) {
+ if (def.getName().equals(property)) {
+ return def;
+ }
+ }
+ return null;
+ }
+
+ public void configure(StoredPortlet storedPortlet) {
+ // TODO: Implement this method.
+ }
+
+ public Canvas getHelpCanvas() {
+ return new HTMLFlow("This portlet displays information about platforms in inventory.");
+ }
+
+ public Canvas getSettingsCanvas() {
+ return null; // TODO: Implement this method.
+ }
+
+
+ private static class PlatformListGrid extends ListGrid {
+
+ private PlatformListGrid() {
+ setShowRecordComponents(true);
+ setShowRecordComponentsByCell(true);
+ }
+
+ @Override
+ protected Canvas createRecordComponent(ListGridRecord listGridRecord, Integer colNum) {
+
+ String fieldName = this.getFieldName(colNum);
+
+ try {
+ if (fieldName.equals("cpu")) {
+ if (listGridRecord.getAttribute(CPUMetric.Idle.property) != null) {
+ HLayout bar = new HLayout();
+ bar.setHeight(18);
+ bar.setWidth100();
+
+ double value = listGridRecord.getAttributeAsDouble(CPUMetric.Idle.property);
+ value = 1 - value;
+
+ HTMLFlow text = new HTMLFlow(MeasurementConverterClient.format(value, MeasurementUnits.PERCENTAGE, true));
+ text.setAutoWidth();
+ bar.addMember(text);
+
+ Img first = new Img("availBar/up.png");
+ first.setHeight(18);
+ first.setWidth((value * 100) + "%");
+ bar.addMember(first);
+
+ Img second = new Img("availBar/unknown.png");
+ second.setHeight(18);
+ second.setWidth((100 - (value * 100)) + "%");
+ bar.addMember(second);
+
+
+ return bar;
+ }
+
+
+ } else if (fieldName.equals("memory")) {
+ if (listGridRecord.getAttribute(MemoryMetric.Total.property) != null) {
+ HLayout bar = new HLayout();
+ bar.setHeight(18);
+ bar.setWidth100();
+
+ double total = listGridRecord.getAttributeAsDouble(MemoryMetric.Total.property);
+ double value = listGridRecord.getAttributeAsDouble(MemoryMetric.Used.property);
+ double percent = value / total;
+
+ HTMLFlow text = new HTMLFlow(MeasurementConverterClient.format(percent, MeasurementUnits.PERCENTAGE, true));
+ text.setAutoWidth();
+ bar.addMember(text);
+
+ Img first = new Img("availBar/up.png");
+ first.setHeight(18);
+ first.setWidth((percent * 100) + "%");
+ bar.addMember(first);
+
+ Img second = new Img("availBar/unknown.png");
+ second.setHeight(18);
+ second.setWidth((100 - (percent * 100)) + "%");
+ bar.addMember(second);
+
+
+ return bar;
+ }
+
+ }
+ return null;
+
+ } catch (Exception e) {
+ // expected until first data loaded
+ return null;
+ }
+
+ }
+ }
+
+
+ private enum MemoryMetric {
+ Used("Native.MemoryInfo.used"), Free("Native.MemoryInfo.free"), Total("Native.MemoryInfo.total");
+
+ private final String property;
+
+ MemoryMetric(String property) {
+ this.property = property;
+ }
+
+ public String getProperty() {
+ return property;
+ }
+ }
+
+
+ private enum CPUMetric {
+ Idle("CpuPerc.idle"), System("CpuPerc.sys"), User("CpuPerc.user"), Wait("CpuPerc.wait");
+
+ private final String property;
+
+ CPUMetric(String property) {
+ this.property = property;
+ }
+
+ public String getProperty() {
+ return property;
+ }
+ }
+
+ private enum SwapMetric {
+ Used("Native.SwapInfo.used"), Free("Native.SwapInfo.free"), Total("Native.SwapInfo.total");
+
+ private final String property;
+
+ SwapMetric(String property) {
+ this.property = property;
+ }
+
+ public String getProperty() {
+ return property;
+ }
+ }
+
+
+ private static class PlatformMetricDefinitions {
+
+ MeasurementDefinition freeMemory, usedMemory, totalMemory;
+ MeasurementDefinition freeSwap, usedSwap, totalSwap;
+ MeasurementDefinition idleCpu, systemCpu, userCpu, waitCpu;
+
+ MeasurementDefinition[] definitions = new MeasurementDefinition[]{freeMemory, usedMemory, totalMemory, freeSwap, usedSwap, totalSwap, idleCpu, systemCpu, userCpu, waitCpu};
+
+
+ int[] getDefinitionIds() {
+ return new int[]{freeMemory.getId(), usedMemory.getId(), totalMemory.getId(),
+ freeSwap.getId(), usedSwap.getId(), totalSwap.getId(),
+ idleCpu.getId(), systemCpu.getId(), userCpu.getId(), waitCpu.getId()};
+ }
+
+
+ }
+
+ public static final class Factory implements PortletViewFactory {
+ public static PortletViewFactory INSTANCE = new Factory();
+
+ public final PortletView getInstance() {
+ return GWT.create(PlatformPortletView.class);
+ }
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/RecentAlertsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/RecentAlertsPortlet.java
new file mode 100644
index 0000000..b3a302c
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/RecentAlertsPortlet.java
@@ -0,0 +1,56 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.coregui.client.dashboard.portlets.recent.alerts;
+
+import com.google.gwt.core.client.GWT;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.HTMLFlow;
+
+import org.rhq.enterprise.gui.coregui.client.alert.AlertsView;
+import org.rhq.enterprise.gui.coregui.client.dashboard.PortletView;
+import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
+import org.rhq.enterprise.gui.coregui.client.dashboard.store.StoredPortlet;
+
+/**
+ * @author Greg Hinkle
+ */
+public class RecentAlertsPortlet extends AlertsView implements PortletView {
+
+ public static final String KEY = "Recent Alerts";
+
+ public void configure(StoredPortlet storedPortlet) {
+ // TODO: Implement this method.
+ }
+
+ public Canvas getHelpCanvas() {
+ return new HTMLFlow("Displays recent alerts fired on resources visible to the current user login.");
+ }
+
+ public Canvas getSettingsCanvas() {
+ return null; // TODO: Implement this method.
+ }
+
+ public static final class Factory implements PortletViewFactory {
+ public static PortletViewFactory INSTANCE = new Factory();
+
+ public final PortletView getInstance() {
+ return GWT.create(RecentAlertsPortlet.class);
+ }
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResource.java
new file mode 100644
index 0000000..3f139e0
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResource.java
@@ -0,0 +1,78 @@
+/*
+ * 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.enterprise.gui.coregui.client.dashboard.portlets.recent.imported;
+
+import com.google.gwt.user.client.rpc.IsSerializable;
+
+/**
+ * This class is just for use in prototyping the TreeGrid and DataSource classes.
+ *
+ * @author John Sanda
+ */
+public class RecentlyAddedResource implements IsSerializable {
+
+ private RecentlyAddedResource parent;
+
+ private String resourceName;
+
+ private String timestamp;
+
+ public RecentlyAddedResource() {
+ }
+
+ public RecentlyAddedResource(String resourceName, String timestamp) {
+ this(resourceName, timestamp, null);
+ }
+
+ public RecentlyAddedResource(String resourceName, String timestamp, RecentlyAddedResource parent) {
+ this.resourceName = resourceName;
+ this.timestamp = timestamp;
+ this.parent = parent;
+ }
+
+ public String getResourceName() {
+ return resourceName;
+ }
+
+ public void setResourceName(String resourceName) {
+ this.resourceName = resourceName;
+ }
+
+ public String getTimestamp() {
+ return timestamp;
+ }
+
+ public void setTimestamp(String timestamp) {
+ this.timestamp = timestamp;
+ }
+
+ public RecentlyAddedResource getParent() {
+ return parent;
+ }
+
+ public void setParent(RecentlyAddedResource parent) {
+ this.parent = parent;
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourceDS.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourceDS.java
new file mode 100644
index 0000000..fb1db39
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourceDS.java
@@ -0,0 +1,226 @@
+/*
+ * 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.enterprise.gui.coregui.client.dashboard.portlets.recent.imported;
+
+import com.google.gwt.i18n.client.DateTimeFormat;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.data.DSRequest;
+import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSource;
+import com.smartgwt.client.data.fields.DataSourceTextField;
+import com.smartgwt.client.types.DSDataFormat;
+import com.smartgwt.client.types.DSProtocol;
+import com.smartgwt.client.widgets.tree.TreeNode;
+import org.rhq.core.domain.criteria.ResourceCriteria;
+import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceCategory;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.domain.resource.composite.RecentlyAddedResourceComposite;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+public class RecentlyAddedResourceDS extends DataSource {
+
+
+ public RecentlyAddedResourceDS() {
+ setClientOnly(false);
+ setDataProtocol(DSProtocol.CLIENTCUSTOM);
+ setDataFormat(DSDataFormat.CUSTOM);
+
+
+ DataSourceTextField idField = new DataSourceTextField("id", "ID");
+ idField.setPrimaryKey(true);
+
+ DataSourceTextField parentIdField = new DataSourceTextField("parentId", "Parent ID");
+ parentIdField.setForeignKey("id");
+
+ DataSourceTextField resourceNameField = new DataSourceTextField("name", "Resource Name");
+ resourceNameField.setPrimaryKey(true);
+
+ DataSourceTextField timestampField = new DataSourceTextField("timestamp", "Date/Time");
+
+ setFields(idField, parentIdField, resourceNameField, timestampField);
+ }
+
+ @Override
+ protected Object transformRequest(DSRequest request) {
+ DSResponse response = new DSResponse();
+ response.setAttribute("clientContext", request.getAttributeAsObject("clientContext"));
+ // Asume success
+ response.setStatus(0);
+ switch (request.getOperationType()) {
+ case FETCH:
+ executeFetch(request, response);
+ break;
+ default:
+ break;
+ }
+
+ return request.getData();
+ }
+
+ public void executeFetch(final DSRequest request, final DSResponse response) {
+
+ ResourceCriteria c = new ResourceCriteria();
+
+ String p = request.getCriteria().getAttribute("parentId");
+
+ if (p == null) {
+ c.addFilterResourceCategory(ResourceCategory.PLATFORM);
+ c.fetchChildResources(true);
+ } else {
+ c.addFilterParentResourceId(Integer.parseInt(p));
+ }
+
+ // TODO GH: Enhance resourceCriteria query to support itime based filtering for
+ // "Recently imported" resources
+
+ GWTServiceLookup.getResourceService().findRecentlyAddedResources(0, 100,
+ new AsyncCallback<List<RecentlyAddedResourceComposite>>() {
+ public void onFailure(Throwable throwable) {
+ CoreGUI.getErrorHandler().handleError("Failed to load recently added resources", throwable);
+ }
+
+ public void onSuccess(List<RecentlyAddedResourceComposite> recentlyAddedList) {
+ List<RecentlyAddedResourceComposite> list = new ArrayList<RecentlyAddedResourceComposite>();
+
+ for (RecentlyAddedResourceComposite recentlyAdded : recentlyAddedList) {
+ list.add(recentlyAdded);
+ list.addAll(recentlyAdded.getChildren());
+ }
+
+ response.setData(buildNodes(list));
+ response.setTotalRows(list.size());
+ processResponse(request.getRequestId(), response);
+ }
+ });
+//
+// GWTServiceLookup.getResourceService().findResourcesByCriteria(c, new AsyncCallback<PageList<Resource>>() {
+// public void onFailure(Throwable caught) {
+// CoreGUI.getErrorHandler().handleError("Failed to load recently added resources data",caught);
+// response.setStatus(DSResponse.STATUS_FAILURE);
+// processResponse(request.getRequestId(), response);
+// }
+//
+// public void onSuccess(PageList<Resource> result) {
+// PageList<Resource> all = new PageList<Resource>();
+//
+// for (Resource root : result) {
+// all.add(root);
+// if (root.getChildResources() != null)
+// all.addAll(root.getChildResources());
+// }
+//
+//
+// response.setData(buildNodes(all));
+// response.setTotalRows(all.getTotalSize());
+// processResponse(request.getRequestId(), response);
+// }
+// });
+ }
+
+// private TreeNode[] buildNodes(PageList<Resource> list) {
+// TreeNode[] treeNodes = new TreeNode[list.size()];
+// for (int i = 0; i < list.size(); ++i) {
+// treeNodes[i] = new ResourceTreeNode(list.get(i));
+// }
+// return treeNodes;
+// }
+
+ private TreeNode[] buildNodes(List<RecentlyAddedResourceComposite> list) {
+ TreeNode[] treeNodes = new TreeNode[list.size()];
+ for (int i = 0; i < list.size(); ++i) {
+ treeNodes[i] = new RecentlyAddedTreeNode(list.get(i));
+ }
+ return treeNodes;
+ }
+
+ public static class RecentlyAddedTreeNode extends TreeNode {
+ private RecentlyAddedResourceComposite recentlyAdded;
+
+ private RecentlyAddedTreeNode(RecentlyAddedResourceComposite c) {
+ recentlyAdded = c;
+ Date dateAdded = new Date(recentlyAdded.getCtime());
+
+ String id = String.valueOf(recentlyAdded.getId());
+ String parentId = recentlyAdded.getParentId() == 0 ? null
+ : String.valueOf((recentlyAdded.getParentId()));
+
+ setID(id);
+ setParentID(parentId);
+
+ setAttribute("id", id);
+ setAttribute("parentId", parentId);
+ setAttribute("name", recentlyAdded.getName());
+ setAttribute("timestamp", DateTimeFormat.getMediumDateTimeFormat().format(dateAdded));
+ setIsFolder(recentlyAdded.getParentId() == 0);
+ }
+ }
+
+ public static class ResourceTreeNode extends TreeNode {
+
+ private Resource resource;
+
+ private ResourceTreeNode(Resource resource) {
+ this.resource = resource;
+
+ String id = String.valueOf(resource.getId());
+ String parentId = resource.getParentResource() == null ? null
+ : String.valueOf((resource.getParentResource().getId()));
+
+ setID(id);
+ setParentID(parentId);
+
+ setAttribute("id", id);
+ setAttribute("parentId", parentId);
+ setAttribute("name", resource.getName());
+ setAttribute("timestamp", "");//String.valueOf(resource.getItime())); // Seems to be null
+ setAttribute("currentAvailability",
+ resource.getCurrentAvailability().getAvailabilityType() == AvailabilityType.UP
+ ? "/images/icons/availability_green_16.png"
+ : "/images/icons/availability_red_16.png");
+ }
+
+ public Resource getResource() {
+ return resource;
+ }
+
+ public void setResource(Resource resource) {
+ this.resource = resource;
+ }
+
+ public ResourceType getResourceType() {
+ return resource.getResourceType();
+ }
+
+ public String getParentId() {
+ return getAttribute("parentId");
+ }
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedView.java
new file mode 100644
index 0000000..76f6d37
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedView.java
@@ -0,0 +1,85 @@
+/*
+ * 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.enterprise.gui.coregui.client.dashboard.portlets.recent.imported;
+
+import com.google.gwt.core.client.GWT;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.HTMLFlow;
+import com.smartgwt.client.widgets.grid.ListGridField;
+import com.smartgwt.client.widgets.layout.VLayout;
+import com.smartgwt.client.widgets.tree.TreeGrid;
+
+import org.rhq.enterprise.gui.coregui.client.components.HeaderLabel;
+import org.rhq.enterprise.gui.coregui.client.dashboard.PortletView;
+import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
+import org.rhq.enterprise.gui.coregui.client.dashboard.store.StoredPortlet;
+
+public class RecentlyAddedView extends VLayout implements PortletView {
+
+
+ public static final String KEY = "Recently Added Portlet";
+
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+ TreeGrid treeGrid = new TreeGrid();
+ treeGrid.setDataSource(new RecentlyAddedResourceDS());
+ treeGrid.setAutoFetchData(true);
+ treeGrid.setTitle("Recently Added Resources");
+ treeGrid.setResizeFieldsInRealTime(true);
+ treeGrid.setTreeFieldTitle("Resource Name");
+
+ ListGridField resourceNameField = new ListGridField("name", "Resource Name");
+ ListGridField timestampField = new ListGridField("timestamp", "Date//Time");
+
+ treeGrid.setFields(resourceNameField, timestampField);
+
+
+ addMember(new HeaderLabel("Recently Added Resources"));
+
+ addMember(treeGrid);
+
+ }
+
+ public void configure(StoredPortlet storedPortlet) {
+
+ }
+
+ public Canvas getHelpCanvas() {
+ return new HTMLFlow("This portlet displays resources that have recently been imported into the inventory.");
+ }
+
+ public Canvas getSettingsCanvas() {
+ return null;
+ }
+
+ public static final class Factory implements PortletViewFactory {
+ public static PortletViewFactory INSTANCE = new Factory();
+
+ public final PortletView getInstance() {
+ return GWT.create(RecentlyAddedView.class);
+ }
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/summary/InventorySummaryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/summary/InventorySummaryView.java
new file mode 100644
index 0000000..f3c8354
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/summary/InventorySummaryView.java
@@ -0,0 +1,140 @@
+/*
+ * 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.enterprise.gui.coregui.client.dashboard.portlets.summary;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.user.client.History;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.fields.FormItem;
+import com.smartgwt.client.widgets.form.fields.HeaderItem;
+import com.smartgwt.client.widgets.form.fields.LinkItem;
+import com.smartgwt.client.widgets.form.fields.StaticTextItem;
+import com.smartgwt.client.widgets.form.fields.events.ClickEvent;
+import com.smartgwt.client.widgets.form.fields.events.ClickHandler;
+import com.smartgwt.client.widgets.layout.VLayout;
+
+import org.rhq.core.domain.resource.InventorySummary;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.dashboard.PortletView;
+import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
+import org.rhq.enterprise.gui.coregui.client.dashboard.store.StoredPortlet;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.gwt.ResourceBossGWTServiceAsync;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.InventoryView;
+
+public class InventorySummaryView extends VLayout implements PortletView {
+
+ private ResourceBossGWTServiceAsync resourceBossService = GWTServiceLookup.getResourceBossService();
+
+ private DynamicForm form;
+ public static final String KEY = "Summary Counts";
+
+ public InventorySummaryView() {
+ resourceBossService.getInventorySummaryForLoggedInUser(new AsyncCallback<InventorySummary>() {
+ public void onFailure(Throwable throwable) {
+ CoreGUI.getErrorHandler().handleError("Failed to retrieve inventory summary", throwable);
+ }
+
+ public void onSuccess(InventorySummary summary) {
+ form = new DynamicForm();
+ List<FormItem> formItems = new ArrayList<FormItem>();
+
+ HeaderItem headerItem = new HeaderItem("header");
+ headerItem.setValue("Inventory Summary");
+ formItems.add(headerItem);
+
+ StaticTextItem platformTotal = createSummaryRow("platformTotal", "Platform Total",
+ summary.getPlatformCount());
+ formItems.add(platformTotal);
+
+ StaticTextItem serverTotal = createSummaryRow("serverTotal", "Server Total", summary.getServerCount());
+ formItems.add(serverTotal);
+
+ StaticTextItem serviceTotal = createSummaryRow("serviceTotal", "Service Total",
+ summary.getServiceCount());
+ formItems.add(serviceTotal);
+
+ StaticTextItem compatibleGroupTotal = createSummaryRow("compatibleGroupTotal", "Compatible Group Total",
+ summary.getCompatibleGroupCount());
+ formItems.add(compatibleGroupTotal);
+
+ StaticTextItem mixedGroupTotal = createSummaryRow("mixedGroupTotal", "Mixed Group Total",
+ summary.getMixedGroupCount());
+ formItems.add(mixedGroupTotal);
+
+ StaticTextItem groupDefinitionTotal = createSummaryRow("groupDefinitionTotal", "Group Definition Total",
+ summary.getGroupDefinitionCount());
+ formItems.add(groupDefinitionTotal);
+
+ StaticTextItem avergeMetricsTotal = createSummaryRow("averageMetricsTotal",
+ "Average Metrics per Minute", summary.getScheduledMeasurementsPerMinute());
+ formItems.add(avergeMetricsTotal);
+
+ form.setItems(formItems.toArray(new FormItem[formItems.size()]));
+ form.setWrapItemTitles(false);
+ form.setCellSpacing(5);
+ addMember(form);
+ }
+ });
+ }
+
+ private StaticTextItem createSummaryRow(String name, String label, int value) {
+ final LinkItem item = new LinkItem(name);
+ item.setTitle(label);
+ item.setValue(value);
+ item.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent clickEvent) {
+ // TODO Figure out to where the click events should be navigating
+ History.newItem(InventoryView.VIEW_PATH);
+ }
+ });
+
+ return item;
+ }
+
+ public void configure(StoredPortlet storedPortlet) {
+ // TODO: Implement this method.
+ }
+
+ public Canvas getHelpCanvas() {
+ return null; // TODO: Implement this method.
+ }
+
+ public Canvas getSettingsCanvas() {
+ return null; // TODO: Implement this method.
+ }
+
+ public static final class Factory implements PortletViewFactory {
+ public static PortletViewFactory INSTANCE = new Factory();
+ public final PortletView getInstance() {
+ return GWT.create(InventorySummaryView.class);
+ }
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/store/DashboardStore.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/store/DashboardStore.java
new file mode 100644
index 0000000..1067359
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/store/DashboardStore.java
@@ -0,0 +1,58 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.coregui.client.dashboard.store;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.util.preferences.UserPreferences;
+
+/**
+ * @author Greg Hinkle
+ */
+public class DashboardStore {
+
+ public static final String STORE_KEY = ".dashboards";
+
+ private UserPreferences preferences;
+
+
+ private HashSet<StoredDashboard> storedDashboards = new HashSet<StoredDashboard>();
+
+
+ public DashboardStore() {
+
+ preferences = CoreGUI.getUserPreferences();
+ load();
+
+ }
+
+
+ public void load() {
+// Set<Integer> dashboardIds = preferences.getPreferenceAsIntegerSet(STORE_KEY);
+
+
+ }
+
+
+ public Set<StoredDashboard> getStoredDashboards() {
+ return storedDashboards;
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/store/StoredDashboard.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/store/StoredDashboard.java
new file mode 100644
index 0000000..f6a9999
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/store/StoredDashboard.java
@@ -0,0 +1,77 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.coregui.client.dashboard.store;
+
+import java.util.ArrayList;
+
+/**
+ * @author Greg Hinkle
+ */
+public class StoredDashboard {
+
+ public static final String STORE_KEY = ".dashboard.";
+ private String id;
+
+ private String name;
+
+ private int columns;
+
+ private String[] columnWidths;
+
+ private ArrayList<ArrayList<StoredPortlet>> portlets = new ArrayList<ArrayList<StoredPortlet>>();
+
+
+ public String getId() {
+ return id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public int getColumns() {
+ return columns;
+ }
+
+
+ public ArrayList<ArrayList<StoredPortlet>> getPortlets() {
+ return portlets;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setColumns(int columns) {
+ this.columns = columns;
+ }
+
+
+ public String[] getColumnWidths() {
+ return columnWidths;
+ }
+
+ public void setColumnWidths(String... columnWidths) {
+ this.columnWidths = columnWidths;
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/store/StoredPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/store/StoredPortlet.java
new file mode 100644
index 0000000..2ac35c4
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/store/StoredPortlet.java
@@ -0,0 +1,104 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.coregui.client.dashboard.store;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author Greg Hinkle
+ */
+public class StoredPortlet {
+
+ public static final String STORE_KEY = ".dashboardPortlet.";
+ private String id;
+
+
+ private String portletKey;
+ private String name;
+
+ private int column;
+ private int index;
+
+ private int height = 300;
+
+ private Map<String,String> properties = new HashMap<String, String>();
+
+
+ public StoredPortlet() {
+ }
+
+ public StoredPortlet(String name, String portletKey, int height) {
+ this.name = name;
+ this.portletKey = portletKey;
+ this.height = height;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public String getPortletKey() {
+ return portletKey;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public int getColumn() {
+ return column;
+ }
+
+ public int getIndex() {
+ return index;
+ }
+
+ public int getHeight() {
+ return height;
+ }
+
+ public Map<String, String> getProperties() {
+ return properties;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public void setPortletKey(String portletKey) {
+ this.portletKey = portletKey;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setColumn(int column) {
+ this.column = column;
+ }
+
+ public void setIndex(int index) {
+ this.index = index;
+ }
+
+ public void setHeight(int height) {
+ this.height = height;
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/summary/SummaryCountsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/summary/SummaryCountsView.java
deleted file mode 100644
index 24ef04b..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/summary/SummaryCountsView.java
+++ /dev/null
@@ -1,110 +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.
- */
-
-package org.rhq.enterprise.gui.coregui.client.inventory.summary;
-
-import com.google.gwt.user.client.History;
-import com.google.gwt.user.client.Window;
-import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.smartgwt.client.types.Alignment;
-import com.smartgwt.client.widgets.form.DynamicForm;
-import com.smartgwt.client.widgets.form.fields.FormItem;
-import com.smartgwt.client.widgets.form.fields.LinkItem;
-import com.smartgwt.client.widgets.form.fields.StaticTextItem;
-import com.smartgwt.client.widgets.form.fields.events.ClickEvent;
-import com.smartgwt.client.widgets.form.fields.events.ClickHandler;
-import com.smartgwt.client.widgets.layout.VLayout;
-import org.rhq.core.domain.resource.InventorySummary;
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-import org.rhq.enterprise.gui.coregui.client.gwt.ResourceBossGWTServiceAsync;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.InventoryView;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class SummaryCountsView extends VLayout {
-
- private ResourceBossGWTServiceAsync resourceBossService = GWTServiceLookup.getResourceBossService();
-
- private DynamicForm form;
-
- public SummaryCountsView() {
- resourceBossService.getInventorySummaryForLoggedInUser(new AsyncCallback<InventorySummary>() {
- public void onFailure(Throwable throwable) {
- CoreGUI.getErrorHandler().handleError("Failed to retrieve inventory summary", throwable);
- }
-
- public void onSuccess(InventorySummary summary) {
- form = new DynamicForm();
- List<FormItem> formItems = new ArrayList<FormItem>();
-
- StaticTextItem platformTotal = createSummaryRow("platformTotal", "Platform Total",
- summary.getPlatformCount());
- formItems.add(platformTotal);
-
- StaticTextItem serverTotal = createSummaryRow("serverTotal", "Server Total", summary.getServerCount());
- formItems.add(serverTotal);
-
- StaticTextItem serviceTotal = createSummaryRow("serviceTotal", "Service Total",
- summary.getServiceCount());
- formItems.add(serviceTotal);
-
- StaticTextItem compatibleGroupTotal = createSummaryRow("compatibleGroupTotal", "Compatible Group Total",
- summary.getCompatibleGroupCount());
- formItems.add(compatibleGroupTotal);
-
- StaticTextItem mixedGroupTotal = createSummaryRow("mixedGroupTotal", "Mixed Group Total",
- summary.getMixedGroupCount());
- formItems.add(mixedGroupTotal);
-
- StaticTextItem groupDefinitionTotal = createSummaryRow("groupDefinitionTotal", "Group Definition Total",
- summary.getGroupDefinitionCount());
- formItems.add(groupDefinitionTotal);
-
- StaticTextItem avergeMetricsTotal = createSummaryRow("averageMetricsTotal",
- "Average Metrics per Minute", summary.getScheduledMeasurementsPerMinute());
- formItems.add(avergeMetricsTotal);
-
- form.setItems(formItems.toArray(new FormItem[formItems.size()]));
- form.setWrapItemTitles(false);
- form.setCellSpacing(15);
- addMember(form);
- }
- });
- }
-
- private StaticTextItem createSummaryRow(String name, String label, int value) {
- final LinkItem item = new LinkItem(name);
- item.setTitle(label);
- item.setValue(value);
- item.addClickHandler(new ClickHandler() {
- public void onClick(ClickEvent clickEvent) {
- // TODO Figure out to where the click events should be navigating
- History.newItem(InventoryView.VIEW_PATH);
- }
- });
-
- return item;
- }
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/preferences/UserPreferences.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/preferences/UserPreferences.java
index 2837a7d..edaa01f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/preferences/UserPreferences.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/preferences/UserPreferences.java
@@ -58,14 +58,16 @@ public class UserPreferences {
}
public void setFavoriteResources(Set<Integer> resourceIds, AsyncCallback<Subject> callback) {
- setPreference(UserPreferenceNames.RESOURCE_HEALTH_RESOURCES, resourceIds, callback);
+ setPreference(UserPreferenceNames.RESOURCE_HEALTH_RESOURCES, resourceIds);
+ store(callback);
}
+
protected String getPreference(String name) {
return userConfiguration.getSimpleValue(name, null);
}
- protected void setPreference(String name, Collection value, AsyncCallback<Subject> callback) {
+ protected void setPreference(String name, Collection value) {
StringBuilder buffer = new StringBuilder();
boolean first = true;
for (Object item : value) {
@@ -76,10 +78,10 @@ public class UserPreferences {
}
buffer.append(item);
}
- setPreference(name, buffer.toString(), callback);
+ setPreference(name, buffer.toString());
}
- protected void setPreference(String name, String value, AsyncCallback<Subject> callback) {
+ protected void setPreference(String name, String value) {
PropertySimple prop = this.userConfiguration.getSimple(name);
String oldValue = null;
if (prop == null) {
@@ -88,8 +90,6 @@ public class UserPreferences {
oldValue = prop.getStringValue();
prop.setStringValue(value);
}
- this.subjectService.updateSubject(this.subject, callback);
-
UserPreferenceChangeEvent event = new UserPreferenceChangeEvent(name, value, oldValue);
for (UserPreferenceChangeListener listener : changeListeners) {
@@ -98,20 +98,29 @@ public class UserPreferences {
}
+ public void store(AsyncCallback<Subject> callback) {
+ this.subjectService.updateSubject(this.subject, callback);
+ }
- protected List<String> getPreferenceAsList(String key) {
+ public Configuration getConfiguration() {
+ return userConfiguration;
+ }
+
+
+ public List<String> getPreferenceAsList(String key) {
String pref = null;
try {
pref = getPreference(key);
} catch (IllegalArgumentException e) {
+
// log.debug("A user preference named '" + key + "' does not exist.");
}
return (pref != null) ? Arrays.asList(pref.split(PREF_LIST_DELIM_REGEX)) : new ArrayList<String>();
}
- protected Set<Integer> getPreferenceAsIntegerSet(String key) {
+ public Set<Integer> getPreferenceAsIntegerSet(String key) {
try {
List<String> value = getPreferenceAsList(key);
// Use a TreeSet, so the Resource id's are sorted.
commit 8d98059a1cd461654c8e06a41a8299d2dd5eb304
Author: Greg Hinkle <ghinkle(a)redhat.com>
Date: Thu Apr 22 11:14:54 2010 -0400
New hierarchical core history management system
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/BookmarkableView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/BookmarkableView.java
new file mode 100644
index 0000000..9e59a26
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/BookmarkableView.java
@@ -0,0 +1,31 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2010 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.coregui.client;
+
+/**
+ * TODO
+ *
+ * @author Ian Springer
+ */
+public interface BookmarkableView {
+
+ void renderView(ViewPath viewPath);
+
+
+}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/Breadcrumb.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/Breadcrumb.java
index 1e647c5..dd8443c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/Breadcrumb.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/Breadcrumb.java
@@ -38,7 +38,7 @@ public class Breadcrumb {
}
public Breadcrumb(String name, boolean hyperlink) {
- this(name, null, hyperlink);
+ this(name, name, hyperlink);
}
public Breadcrumb(String name, String displayName, boolean hyperlink) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/BreadcrumbTrailPane.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/BreadcrumbTrailPane.java
index 377a3fa..4c1c5a0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/BreadcrumbTrailPane.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/BreadcrumbTrailPane.java
@@ -34,7 +34,6 @@ import java.util.List;
*/
public class BreadcrumbTrailPane extends HTMLPane {
- private List<Breadcrumb> breadcrumbs = new ArrayList<Breadcrumb>();
public BreadcrumbTrailPane() {
setHeight(28);
@@ -45,21 +44,17 @@ public class BreadcrumbTrailPane extends HTMLPane {
setOverflow(Overflow.CLIP_V);
}
- public List<Breadcrumb> getBreadcrumbs() {
- return this.breadcrumbs;
- }
-
- public void setBreadcrumbs(List<Breadcrumb> breadcrumbs) {
- this.breadcrumbs = breadcrumbs;
- }
- public void refresh() {
+ public void refresh(ViewPath viewPath) {
try {
+
boolean first = true;
StringBuilder path = new StringBuilder();
StringBuilder content = new StringBuilder();
content.append("<div class=\"BreadCrumb\">");
- for (int i = 0, trailSize = this.breadcrumbs.size(); i < trailSize; i++) {
+
+ for (ViewId viewId : viewPath.getViewPath()) {
+
if (!first) {
path.append("/");
content.append(" > ");
@@ -67,21 +62,30 @@ public class BreadcrumbTrailPane extends HTMLPane {
first = false;
}
- Breadcrumb breadcrumb = breadcrumbs.get(i);
- path.append(breadcrumb.getName());
+ boolean firstBC = true;
+ for (Breadcrumb breadcrumb : viewId.getBreadcrumbs()) {
+// path.append(breadcrumb.getName());
- if ((i == (trailSize - 1) || !breadcrumb.isHyperlink())) {
- // last item in trail is the current page and so should not be a link
- content.append(breadcrumb.getDisplayName());
- } else {
- content.append("<a href=\"#");
- // NOTE: We have to call toString() below, because GWT chokes if you try to append a StringBuilder.
- content.append(path.toString());
- content.append("\">");
- content.append(breadcrumb.getDisplayName());
- content.append("</a>");
+ if (!firstBC) {
+ content.append(" > ");
+ } else {
+ firstBC = false;
+ }
+
+ if (!breadcrumb.isHyperlink()) {
+ // last item in trail is the current page and so should not be a link
+ content.append(breadcrumb.getDisplayName());
+ } else {
+ content.append("<a href=\"#");
+ // NOTE: We have to call toString() below, because GWT chokes if you try to append a StringBuilder.
+ content.append(path.toString() + breadcrumb.getName());
+ content.append("\">");
+ content.append(breadcrumb.getDisplayName());
+ content.append("</a>");
+ }
+ content.append("\n");
}
- content.append("\n");
+ path.append(viewId.getPath());
}
content.append("</div>");
@@ -91,19 +95,12 @@ public class BreadcrumbTrailPane extends HTMLPane {
}
String title = "RHQ";
- if (!breadcrumbs.isEmpty()) {
- title += ": " + this.breadcrumbs.get(this.breadcrumbs.size() - 1);
+ if (!viewPath.getViewPath().isEmpty()) {
+ title += ": " + viewPath.getViewPath().get(viewPath.getViewPath().size()-1).getBreadcrumbs().get(0).getDisplayName();
+
}
Window.setTitle(title);
redraw();
}
-
- @Override
- public String toString() {
- StringBuilder result = new StringBuilder("BreadCrumb[");
- result.append(this.breadcrumbs);
- result.append("]");
- return result.toString();
- }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java
index 3be0f48..995d19b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java
@@ -30,7 +30,7 @@ import com.smartgwt.client.widgets.layout.VLayout;
import org.rhq.core.domain.auth.Subject;
import org.rhq.enterprise.gui.coregui.client.admin.AdministrationView;
import org.rhq.enterprise.gui.coregui.client.bundle.BundleTopView;
-import org.rhq.enterprise.gui.coregui.client.dashboard.DashboardView;
+import org.rhq.enterprise.gui.coregui.client.dashboard.DashboardsView;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.gwt.SubjectGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.InventoryView;
@@ -44,12 +44,11 @@ import org.rhq.enterprise.gui.coregui.client.util.preferences.UserPreferences;
* @author Greg Hinkle
* @author Ian Springer
*/
-public class CoreGUI implements EntryPoint {
+public class CoreGUI implements EntryPoint, ValueChangeHandler<String> {
public static final String CONTENT_CANVAS_ID = "BaseContent";
private static Subject sessionSubject;
- //private static Subject fullSubject;
private static UserPreferences userPreferences;
@@ -61,9 +60,9 @@ public class CoreGUI implements EntryPoint {
private static Canvas content;
- private View rootView;
+ private RootCanvas rootCanvas;
- public View currentView;
+ private static ViewPath currentViewPath;
public void onModuleLoad() {
@@ -85,7 +84,7 @@ public class CoreGUI implements EntryPoint {
});
RequestBuilder b = new RequestBuilder(RequestBuilder.GET,
- "/j_security_check.do?j_username=rhqadmin&j_password=rhqadmin");
+ "/j_security_check.do?j_username=rhqadmin&j_password=rhqadmin");
try {
b.setCallback(new RequestCallback() {
public void onResponseReceived(Request request, Response response) {
@@ -133,9 +132,8 @@ public class CoreGUI implements EntryPoint {
}
private void buildCoreUI() {
- RootCanvas rootCanvas = new RootCanvas();
+ this.rootCanvas = new RootCanvas();
rootCanvas.setOverflow(Overflow.HIDDEN);
- this.currentView = this.rootView = new View(new ViewId("", null), rootCanvas);
// HTMLPane menuPane = new HTMLPane();
// menuPane.setWidth100();
@@ -167,95 +165,24 @@ public class CoreGUI implements EntryPoint {
rootCanvas.draw();
- History.addValueChangeHandler(new ValueChangeHandler<String>() {
-
- public void onValueChange(ValueChangeEvent<String> historyChangeEvent) {
- String path = historyChangeEvent.getValue();
- System.out.println("History request: " + path);
-
- List<String> viewIdNames = path.equals("") ? Collections.<String> emptyList() : Arrays.asList(path
- .split("\\/"));
- String currentPath = CoreGUI.this.currentView.getId().getPath();
- List<String> currentViewIdNames = currentPath.equals("") ? Collections.<String> emptyList() : Arrays
- .asList(currentPath.split("\\/"));
-
- int commonBasePathSize = 0;
- for (int i = 0; i < viewIdNames.size() && i < currentViewIdNames.size(); i++) {
- String name = viewIdNames.get(i);
- String currentName = currentViewIdNames.get(i);
- if (name.equals(currentName)) {
- commonBasePathSize++;
- } else {
- break;
- }
- }
- int startIndex;
- View parentView = null;
- if (commonBasePathSize > 0) {
- // The requested path shares a common base path with the current view, so skip rendering of
- // views corresponding to this common base path. For example, if the current view is
- // Resource/10001/Summary/Overview and Resource/10001/Monitor/Graphs is requested, call renderView()
- // only on for the Monitor and Graphs components of the path.
- startIndex = commonBasePathSize;
- int subViewsToRenderPathSize = viewIdNames.size() - commonBasePathSize;
- View view = CoreGUI.this.currentView;
- if (view != null) {
- parentView = view;
- }
- for (int i = 0; i < subViewsToRenderPathSize; i++) {
- parentView = parentView.getParent();
- }
- } else {
- // Otherwise, start at the root view (i.e. call renderView() for every component in the path).
- startIndex = 0;
- parentView = CoreGUI.this.rootView;
- }
- System.out.println("Starting parent view: " + parentView);
-
- ViewRenderer viewRenderer = parentView.getDescendantViewRenderer();
- try {
- for (int i = startIndex, viewIdNamesSize = viewIdNames.size(); i < viewIdNamesSize; i++) {
- String viewIdName = viewIdNames.get(i);
- // See if the parent view provided a view renderer to use for its descendants. If not,
- // continue using the view renderer that renderer the parent view.
- ViewRenderer descendantViewRenderer = parentView.getDescendantViewRenderer();
- if (descendantViewRenderer != null) {
- viewRenderer = descendantViewRenderer;
- }
- ViewId viewId = new ViewId(viewIdName, parentView.getId());
- boolean lastNode = (i == (viewIdNamesSize - 1));
- View view = viewRenderer.renderView(viewId, lastNode);
- view.setParent(parentView);
-
- parentView = view;
- }
- } catch (UnknownViewException e) {
- // Abort the for-loop, since once we hit an unknown name, we don't care about any remaining names
- // in the list. The breadcrumbs list will contain breadcrumbs for only the names that were
- // recognized.
- System.err.println(e.getMessage());
- // TODO: Should we add a new token to the History to point to the valid location
- // we ended up at?
- }
- CoreGUI.this.currentView = parentView;
-
- // Update the breadcrumb trail.
- List<Breadcrumb> breadcrumbs = new LinkedList<Breadcrumb>();
- while (parentView.getParent() != null) {
- breadcrumbs.add(0, parentView.getBreadcrumb());
- parentView = parentView.getParent();
- }
- System.out.println("Breadcrumbs: " + breadcrumbs);
- breadCrumbTrailPane.setBreadcrumbs(breadcrumbs);
- breadCrumbTrailPane.refresh();
- }
- });
+ History.addValueChangeHandler(this);
History.fireCurrentHistoryState();
}
+
+ public void onValueChange(ValueChangeEvent<String> stringValueChangeEvent) {
+ System.out.println("Handling history event: " + stringValueChangeEvent.getValue());
+ currentViewPath = new ViewPath(stringValueChangeEvent.getValue());
+
+ rootCanvas.renderView(currentViewPath);
+
+ }
+
+
public Canvas createContent(String breadcrumbName) {
Canvas canvas;
+
if (breadcrumbName.equals("Administration")) {
canvas = new AdministrationView();
} else if (breadcrumbName.equals("Demo")) {
@@ -265,7 +192,7 @@ public class CoreGUI implements EntryPoint {
} else if (breadcrumbName.equals("Resource")) {
canvas = new ResourceView();
} else if (breadcrumbName.equals("Dashboard")) {
- canvas = new DashboardView();
+ canvas = new DashboardsView();
} else if (breadcrumbName.equals("Bundles")) {
canvas = new BundleTopView();
} else {
@@ -294,7 +221,6 @@ public class CoreGUI implements EntryPoint {
}
-
public static void setSessionSubject(Subject subject) {
GWTServiceLookup.registerSession(String.valueOf(subject.getSessionId()));
@@ -322,34 +248,40 @@ public class CoreGUI implements EntryPoint {
}
public static void refreshBreadCrumbTrail() {
- breadCrumbTrailPane.refresh();
+ breadCrumbTrailPane.refresh(currentViewPath);
}
- private class RootCanvas extends VLayout implements ViewRenderer {
+
+ private class RootCanvas extends VLayout implements BookmarkableView {
ViewId currentViewId;
Canvas currentCanvas;
private RootCanvas() {
- setWidth100(); // (1200);
- setHeight100(); // (900);
+ setWidth100();
+ setHeight100();
}
- public View renderView(ViewId viewId, boolean lastNode) throws UnknownViewException {
- if (!viewId.equals(currentViewId)) {
- currentViewId = viewId;
- String path = viewId.getPath();
- Canvas canvas = createContent(path);
- if (canvas == null) {
- throw new UnknownViewException();
+
+ public void renderView(ViewPath viewPath) {
+ if (viewPath.isEnd()) {
+ // default view
+ History.newItem("Dashboard");
+ } else {
+
+ if (!viewPath.getCurrent().equals(currentViewId)) {
+ currentViewId = viewPath.getCurrent();
+
+ currentCanvas = createContent(viewPath.getCurrent().getPath());
+ setContent(currentCanvas);
}
- currentCanvas = canvas;
- setContent(canvas);
- }
- ViewRenderer descendantViewRender = (currentCanvas instanceof ViewRenderer) ? (ViewRenderer) currentCanvas
- : null;
+ if (currentCanvas instanceof BookmarkableView) {
+ ((BookmarkableView) currentCanvas).renderView(viewPath.next()); // e.g.
+ }
+
+ refreshBreadCrumbTrail();
- return new View(viewId, descendantViewRender);
+ }
}
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/View.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/View.java
index eeaf777..18a0fd9 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/View.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/View.java
@@ -29,7 +29,7 @@ package org.rhq.enterprise.gui.coregui.client;
*/
public class View {
private ViewId id;
- private ViewRenderer descendantViewRenderer;
+ private BookmarkableView descendantViewRenderer;
private Breadcrumb breadcrumb;
private View parent;
@@ -37,7 +37,7 @@ public class View {
this(id, null, null);
}
- public View(ViewId id, ViewRenderer descendantViewRenderer) {
+ public View(ViewId id, BookmarkableView descendantViewRenderer) {
this(id, descendantViewRenderer, null);
}
@@ -45,18 +45,18 @@ public class View {
this(id, null, breadcrumb);
}
- public View(ViewId id, ViewRenderer descendantViewRenderer, Breadcrumb breadcrumb) {
+ public View(ViewId id, BookmarkableView descendantViewRenderer, Breadcrumb breadcrumb) {
if (id == null) {
throw new IllegalArgumentException("Id is null.");
}
this.id = id;
if (breadcrumb != null) {
- if (!breadcrumb.getName().equals(id.getName())) {
+ if (!breadcrumb.getName().equals(id.getPath())) {
throw new IllegalArgumentException("Breadcrumb name is not equal to id name.");
}
this.breadcrumb = breadcrumb;
} else {
- this.breadcrumb = new Breadcrumb(id.getName());
+ this.breadcrumb = new Breadcrumb(id.getPath());
}
this.descendantViewRenderer = descendantViewRenderer;
}
@@ -79,7 +79,7 @@ public class View {
* the view renderer that rendered this view should also be used to render
* descendant views
*/
- public ViewRenderer getDescendantViewRenderer() {
+ public BookmarkableView getDescendantViewRenderer() {
if (this.descendantViewRenderer != null) {
return this.descendantViewRenderer;
} else if (this.parent != null) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewId.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewId.java
index e5200fb..7d022ce 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewId.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewId.java
@@ -18,59 +18,44 @@
*/
package org.rhq.enterprise.gui.coregui.client;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
/**
- * TODO
*
- * @author Ian Springer
+ * @author Greg Hinkle
*/
public class ViewId {
- public static final char PATH_SEPARATOR = '/';
- public static final ViewId ROOT_VIEW_ID = new ViewId("", null);
- private String name;
- private ViewId parent;
+
private String path;
- /**
- * Create a view id with the specified base name and parent. The name must not contain any slashes. The parent
- * should not be null, unless this is the root view id.
- *
- * @param name the base name of the view represented by this id
- * @param parent the id of the view represented by this id's parent view
- */
- public ViewId(String name, ViewId parent) {
- if (name == null) {
- throw new IllegalArgumentException("Name is null.");
- }
- if (name.indexOf(PATH_SEPARATOR) >= 0) {
- throw new IllegalArgumentException("Name contains illegal character '" + PATH_SEPARATOR + "'. ");
+ private List<Breadcrumb> breadcrumbs;
+
+
+ public ViewId(String path, Breadcrumb... breadcrumbs) {
+ this.path = path;
+ if ( breadcrumbs != null) {
+ this.breadcrumbs = Arrays.asList(breadcrumbs);
+ } else {
+ this.breadcrumbs = new ArrayList<Breadcrumb>();
}
- this.name = name;
- this.parent = parent;
}
- public String getName() {
- return this.name;
+ public ViewId(String path) {
+ this.path = path;
+ breadcrumbs = new ArrayList<Breadcrumb>();
+
+ breadcrumbs.add(new Breadcrumb(path));
}
- public ViewId getParent() {
- return this.parent;
+ public List<Breadcrumb> getBreadcrumbs() {
+ return breadcrumbs;
}
public String getPath() {
- if (this.path == null) {
- StringBuilder buffer = new StringBuilder();
- if (this.parent != null) {
- String parentPath = this.parent.getPath();
- buffer.append(parentPath);
- if (!parentPath.equals(ROOT_VIEW_ID.getPath())) {
- buffer.append(PATH_SEPARATOR);
- }
- }
- buffer.append(this.name);
- this.path = buffer.toString();
- }
- return this.path;
+ return path;
}
@Override
@@ -80,18 +65,13 @@ public class ViewId {
ViewId viewId = (ViewId) o;
- if (!getPath().equals(viewId.getPath())) return false;
+ if (!path.equals(viewId.path)) return false;
return true;
}
@Override
public int hashCode() {
- return getPath().hashCode();
- }
-
- @Override
- public String toString() {
- return getPath();
+ return path.hashCode();
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewPath.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewPath.java
new file mode 100644
index 0000000..c3d82b8
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewPath.java
@@ -0,0 +1,75 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.coregui.client;
+
+import java.util.ArrayList;
+
+/**
+ * @author Greg Hinkle
+ */
+public class ViewPath {
+
+ private ArrayList<ViewId> viewPath = new ArrayList<ViewId>();
+
+ private int index = 0;
+
+ public ViewPath() {
+ }
+
+ public ViewPath(String pathString) {
+ for (String pe : pathString.split("/")) {
+ viewPath.add(new ViewId(pe));
+ }
+ }
+
+ public ArrayList<ViewId> getViewPath() {
+ return viewPath;
+ }
+
+
+ public ViewPath next() {
+ index++;
+ return this;
+ }
+
+ public ViewId getCurrent() {
+ if (index >= viewPath.size()) {
+ return null;
+ } else {
+ return viewPath.get(index);
+ }
+ }
+
+ public ViewId getNext() {
+ return viewPath.get(index + 1);
+ }
+
+ public boolean isEnd() {
+ return viewPath.size() <= index;
+ }
+
+ public boolean isCurrent(ViewId providedViewId) {
+ return !(isEnd() || providedViewId == null || !getCurrent().equals(providedViewId));
+ }
+
+
+ public boolean isNext(ViewId providedViewId) {
+ return ((index + 1) < viewPath.size() && providedViewId != null && getNext().equals(providedViewId));
+ }
+}
commit b8887dfa64a5651e7b2312060dfb1b3273799f3e
Author: Greg Hinkle <ghinkle(a)redhat.com>
Date: Thu Apr 22 10:53:03 2010 -0400
support for other components in the table footer (like popup menus)
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
index 3481775..2bec61e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
@@ -25,6 +25,7 @@ import com.smartgwt.client.data.SortSpecifier;
import com.smartgwt.client.types.Autofit;
import com.smartgwt.client.util.BooleanCallback;
import com.smartgwt.client.util.SC;
+import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.HTMLFlow;
import com.smartgwt.client.widgets.IButton;
import com.smartgwt.client.widgets.Label;
@@ -83,6 +84,7 @@ public class Table extends VLayout {
;
private ArrayList<TableActionInfo> tableActions = new ArrayList<TableActionInfo>();
+ private ArrayList<Canvas> extraWidgets = new ArrayList<Canvas>();
public Table() {
this(null, null, null, null, true);
@@ -146,8 +148,9 @@ public class Table extends VLayout {
}
@Override
- protected void onDraw() {
- super.onDraw();
+ protected void onInit() {
+ super.onInit();
+
// NOTE: It is essential that we wait to hide any excluded fields until after super.onDraw() is called, since
// super.onDraw() is what actually adds the fields to the ListGrid (based on what fields are defined in
@@ -189,6 +192,12 @@ public class Table extends VLayout {
tableAction.actionButton = button;
footer.addMember(button);
}
+
+ for (Canvas extraWidgetCanvas : extraWidgets) {
+ footer.addMember(extraWidgetCanvas);
+ }
+
+
footer.addMember(new LayoutSpacer());
IButton refreshButton = new IButton("Refresh");
@@ -327,6 +336,12 @@ public class Table extends VLayout {
tableActions.add(info);
}
+ public void addExtraWidget(Canvas canvas) {
+ this.extraWidgets.add(canvas);
+ }
+
+
+
private void refreshTableInfo() {
int count = this.listGrid.getSelection().length;
for (TableActionInfo tableAction : tableActions) {
commit a6dd778e3dd0fb14c943b67137d5de49fdb8ef17
Author: Greg Hinkle <ghinkle(a)redhat.com>
Date: Thu Apr 22 10:40:05 2010 -0400
ResourceType tree data source and view for either plugin page or type selector popup
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/type/ResourceTypePluginTreeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/type/ResourceTypePluginTreeDataSource.java
new file mode 100644
index 0000000..6f80d45
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/type/ResourceTypePluginTreeDataSource.java
@@ -0,0 +1,259 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.coregui.client.inventory.resource.type;
+
+import java.util.HashMap;
+import java.util.HashSet;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.data.DSRequest;
+import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSource;
+import com.smartgwt.client.data.fields.DataSourceTextField;
+import com.smartgwt.client.types.DSDataFormat;
+import com.smartgwt.client.types.DSProtocol;
+import com.smartgwt.client.widgets.tree.TreeNode;
+
+import org.rhq.core.domain.criteria.ResourceTypeCriteria;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.domain.util.PageControl;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.core.domain.util.PageOrdering;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.gwt.ResourceTypeGWTServiceAsync;
+
+/**
+ * @author Greg Hinkle
+ */
+public class ResourceTypePluginTreeDataSource extends DataSource {
+
+
+ private ResourceTypeGWTServiceAsync resourceTypeService = GWTServiceLookup.getResourceTypeGWTService();
+
+ public ResourceTypePluginTreeDataSource() {
+
+ setClientOnly(false);
+ setDataProtocol(DSProtocol.CLIENTCUSTOM);
+ setDataFormat(DSDataFormat.CUSTOM);
+
+
+ DataSourceTextField idField = new DataSourceTextField("id", "ID");
+ idField.setPrimaryKey(true);
+
+ DataSourceTextField parentIdField = new DataSourceTextField("parentId", "Parent ID");
+ parentIdField.setForeignKey("id");
+
+ DataSourceTextField resourceNameField = new DataSourceTextField("name", "Name");
+
+ DataSourceTextField resourceKeyField = new DataSourceTextField("plugin", "Plugin");
+
+ DataSourceTextField resourceTypeField = new DataSourceTextField("category", "Category");
+
+
+ setFields(idField, parentIdField, resourceNameField, resourceKeyField, resourceTypeField);
+ }
+
+ protected Object transformRequest(DSRequest request) {
+ DSResponse response = new DSResponse();
+ response.setAttribute("clientContext", request.getAttributeAsObject("clientContext"));
+ // Asume success
+ response.setStatus(0);
+ switch (request.getOperationType()) {
+ case FETCH:
+ executeFetch(request, response);
+ break;
+ default:
+ break;
+ }
+
+ return request.getData();
+ }
+
+
+ protected void executeFetch(final DSRequest request, final DSResponse response) {
+
+ String parentIdString = request.getCriteria().getAttributeAsString("parentId");
+ if (parentIdString != null) {
+ processResponse(request.getRequestId(), response);
+ } else {
+
+
+ ResourceTypeCriteria criteria = new ResourceTypeCriteria();
+ criteria.fetchParentResourceTypes(true);
+ criteria.setPageControl(PageControl.getUnlimitedInstance());
+
+ resourceTypeService.findResourceTypesByCriteria(criteria,
+ new AsyncCallback<PageList<ResourceType>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to load resource type tree data", caught);
+ }
+
+ public void onSuccess(PageList<ResourceType> result) {
+ response.setData(buildNodes(result));
+ processResponse(request.getRequestId(), response);
+ }
+ });
+ }
+ }
+
+
+ public static TreeNode[] buildNodes(PageList<ResourceType> result) {
+
+ HashMap<String, PluginTreeNode> pluginNodes = new HashMap<String, PluginTreeNode>();
+
+ HashSet<TreeNode> nodes = new HashSet<TreeNode>();
+ for (ResourceType type : result) {
+
+ PluginTreeNode pluginNode = pluginNodes.get(type.getPlugin());
+ if (pluginNode == null) {
+ pluginNode = new PluginTreeNode(type.getPlugin());
+ pluginNodes.put(type.getPlugin(), pluginNode);
+ nodes.add(pluginNode);
+ }
+
+
+ if (type.getParentResourceTypes() == null || type.getParentResourceTypes().isEmpty()) {
+ nodes.add(new ResourceTypeTreeNode(type, type.getPlugin()));
+ } else {
+ for (ResourceType parent : type.getParentResourceTypes()) {
+ nodes.add(new ResourceTypeTreeNode(type, String.valueOf(parent.getId())));
+ }
+ }
+ }
+
+ TreeNode[] treeNodes = nodes.toArray(new TreeNode[nodes.size()]);
+ return treeNodes;
+ }
+
+
+ /**
+ * Returns a prepopulated PageControl based on the provided DSRequest. This will set sort fields,
+ * pagination, but *not* filter fields.
+ *
+ * @param request the request to turn into a page control
+ * @return the page control for passing to criteria and other queries
+ */
+ protected PageControl getPageControl(DSRequest request) {
+ // Initialize paging.
+ PageControl pageControl;
+ if (request.getStartRow() == null || request.getEndRow() == null) {
+ pageControl = new PageControl();
+ } else {
+ pageControl = PageControl.getExplicitPageControl(request.getStartRow(), request.getEndRow() - request.getStartRow());
+ }
+
+ // Initialize sorting.
+ String sortBy = request.getAttribute("sortBy");
+ if (sortBy != null) {
+ String[] sorts = sortBy.split(",");
+ for (String sort : sorts) {
+ PageOrdering ordering = (sort.startsWith("-")) ? PageOrdering.DESC : PageOrdering.ASC;
+ String columnName = (ordering == PageOrdering.DESC) ? sort.substring(1) : sort;
+ pageControl.addDefaultOrderingField(columnName, ordering);
+ }
+ }
+
+ return pageControl;
+ }
+
+
+ public static class PluginTreeNode extends TreeNode {
+
+ String id;
+
+ PluginTreeNode(String pluginName) {
+
+ setID(pluginName);
+ this.id = pluginName;
+ setParentID(null);
+
+ setAttribute("name", pluginName);
+// setAttribute("plugin",pluginName);
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ PluginTreeNode that = (PluginTreeNode) o;
+
+ if (!id.equals(that.id)) return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return id.hashCode();
+ }
+ }
+
+ public static class ResourceTypeTreeNode extends TreeNode {
+
+ private ResourceType resourceType;
+ String id;
+ String parentId;
+
+ private ResourceTypeTreeNode(ResourceType resourceType, String parentId) {
+ this.resourceType = resourceType;
+
+ String id = String.valueOf(resourceType.getId());
+
+ setID(id);
+ this.id = id;
+ setParentID(parentId);
+ this.parentId = parentId;
+
+ setAttribute("id", id);
+ setAttribute("parentId", parentId);
+ setAttribute("name", resourceType.getName());
+ setAttribute("plugin", resourceType.getPlugin());
+ setAttribute("category", resourceType.getCategory().getDisplayName());
+
+ setIsFolder(true);
+ }
+
+
+ public ResourceType getResourceType() {
+ return resourceType;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ ResourceTypeTreeNode that = (ResourceTypeTreeNode) o;
+
+ if (!id.equals(that.id)) return false;
+ if (parentId != null ? !parentId.equals(that.parentId) : that.parentId != null) return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = id.hashCode();
+ result = 31 * result + (parentId != null ? parentId.hashCode() : 0);
+ return result;
+ }
+ }
+}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/type/ResourceTypeTreeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/type/ResourceTypeTreeDataSource.java
index dc1cbe9..356e565 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/type/ResourceTypeTreeDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/type/ResourceTypeTreeDataSource.java
@@ -32,6 +32,7 @@ import com.smartgwt.client.types.DSProtocol;
import com.smartgwt.client.widgets.tree.TreeNode;
import org.rhq.core.domain.criteria.ResourceTypeCriteria;
+import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
@@ -117,20 +118,18 @@ public class ResourceTypeTreeDataSource extends DataSource {
public static TreeNode[] buildNodes(PageList<ResourceType> result) {
- HashMap<String, PluginTreeNode> pluginNodes = new HashMap<String, PluginTreeNode>();
-
HashSet<TreeNode> nodes = new HashSet<TreeNode>();
- for (ResourceType type : result) {
- PluginTreeNode pluginNode = pluginNodes.get(type.getPlugin());
- if (pluginNode == null) {
- pluginNode = new PluginTreeNode(type.getPlugin());
- pluginNodes.put(type.getPlugin(), pluginNode);
- nodes.add(pluginNode);
- }
+ HashSet<ResourceType> platforms = new HashSet<ResourceType>();
+ HashSet<ResourceType> noParentNonPlatformNodes = new HashSet<ResourceType>();
+
+ for (ResourceType type : result) {
+ if (type.getCategory() != ResourceCategory.PLATFORM && (type.getParentResourceTypes() == null || type.getParentResourceTypes().isEmpty())) {
+ noParentNonPlatformNodes.add(type);
- if (type.getParentResourceTypes() == null || type.getParentResourceTypes().isEmpty()) {
+ } else if (type.getParentResourceTypes() == null || type.getParentResourceTypes().isEmpty()) {
+ platforms.add(type);
nodes.add(new ResourceTypeTreeNode(type, type.getPlugin()));
} else {
for (ResourceType parent : type.getParentResourceTypes()) {
@@ -139,6 +138,13 @@ public class ResourceTypeTreeDataSource extends DataSource {
}
}
+ for (ResourceType platform : platforms) {
+ for (ResourceType platformChild : noParentNonPlatformNodes) {
+ nodes.add(new ResourceTypeTreeNode(platformChild, String.valueOf(platform.getId())));
+ }
+ }
+
+
TreeNode[] treeNodes = nodes.toArray(new TreeNode[nodes.size()]);
return treeNodes;
}
commit e4d885fcfe2725f18a9a5416ad215757b4b38781
Author: Greg Hinkle <ghinkle(a)redhat.com>
Date: Thu Apr 22 10:39:16 2010 -0400
resource factory wizard fixes
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/factory/ConfigurationTemplateStep.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/factory/ConfigurationTemplateStep.java
index a9182ee..d619c3a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/factory/ConfigurationTemplateStep.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/factory/ConfigurationTemplateStep.java
@@ -74,11 +74,15 @@ public class ConfigurationTemplateStep implements WizardStep {
}
public String getName() {
- return "Select a Template";
+ return "New Resource";
}
public Configuration getConfiguration() {
- return templates.get(form.getValueAsString("template")).createConfiguration();
+ String template = form.getValueAsString("template");
+ if (template == null) {
+ template = "default";
+ }
+ return templates.get(template).createConfiguration();
}
public String getResourceName() {
commit 08943f5a60345a83d3eb5c25d88432f4235d69b2
Author: Greg Hinkle <ghinkle(a)redhat.com>
Date: Thu Apr 22 10:38:47 2010 -0400
support resource uninventory
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java
index d465cb8..214791b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java
@@ -18,6 +18,9 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.resource;
+import java.util.List;
+
+import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
@@ -29,6 +32,7 @@ import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.rpc.RPCResponse;
import com.smartgwt.client.widgets.grid.ListGridRecord;
+import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.criteria.ResourceCriteria;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.resource.Resource;
@@ -38,6 +42,7 @@ import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message;
/**
* @author Greg Hinkle
@@ -49,6 +54,7 @@ public class ResourceDatasource extends RPCDataSource<Resource> {
private ResourceGWTServiceAsync resourceService = GWTServiceLookup.getResourceService();
public ResourceDatasource() {
+ super();
DataSourceField idDataField = new DataSourceIntegerField("id", "ID", 20);
idDataField.setPrimaryKey(true);
@@ -84,7 +90,6 @@ public class ResourceDatasource extends RPCDataSource<Resource> {
}
public void executeFetch(final DSRequest request, final DSResponse response) {
- final long start = System.currentTimeMillis();
ResourceCriteria criteria = new ResourceCriteria();
criteria.setPageControl(getPageControl(request));
@@ -121,19 +126,48 @@ public class ResourceDatasource extends RPCDataSource<Resource> {
public void onSuccess(PageList<Resource> result) {
- System.out.println("Data retrieved in: " + (System.currentTimeMillis() - start));
- ListGridRecord[] records = buildRecords(result);
- response.setData(records);
- response.setTotalRows(result.getTotalSize()); // for paging to work we have to specify size of full result set
+ dataRetrieved(result, response, request);
+ }
+ });
+ }
+
+ @Override
+ protected void executeRemove(final DSRequest request, final DSResponse response) {
+ JavaScriptObject data = request.getData();
+ final ListGridRecord rec = new ListGridRecord(data);
+ final Resource resourceToDelete = copyValues(rec);
+
+
+ final int resourceId = resourceToDelete.getId();
+ resourceService.deleteResources(new int[]{resourceId}, new AsyncCallback<List<Integer>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to uninventory resource " + resourceId, caught);
+ response.setStatus(DSResponse.STATUS_FAILURE);
+ processResponse(request.getRequestId(), response);
+ }
+
+ public void onSuccess(List<Integer> result) {
+ CoreGUI.getMessageCenter().notify(new Message("Resource [" + resourceId + "] successfully uninventoried.", Message.Severity.Info));
+ response.setStatus(DSResponse.STATUS_SUCCESS);
processResponse(request.getRequestId(), response);
}
});
+
+
+ }
+
+ protected void dataRetrieved(PageList<Resource> result, DSResponse response, DSRequest request) {
+ ListGridRecord[] records = buildRecords(result);
+ response.setData(records);
+ response.setTotalRows(result.getTotalSize()); // for paging to work we have to specify size of full result set
+ processResponse(request.getRequestId(), response);
}
+
@Override
public Resource copyValues(ListGridRecord from) {
- return null; // TODO: Implement this method.
+ return new Resource(from.getAttributeAsInt("id"));
}
@Override
commit c6f186dd0a14f7b794aee2b907c0ee65a6c2ca99
Author: Greg Hinkle <ghinkle(a)redhat.com>
Date: Thu Apr 22 10:34:50 2010 -0400
data load for graphs outside of the graph list
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/SmallGraphView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/SmallGraphView.java
index f14f00f..db4fbf8 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/SmallGraphView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/SmallGraphView.java
@@ -18,7 +18,9 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring;
+import java.util.ArrayList;
import java.util.Date;
+import java.util.EnumSet;
import java.util.List;
import ca.nanometrics.gflot.client.Axis;
@@ -38,6 +40,7 @@ import ca.nanometrics.gflot.client.options.PointsSeriesOptions;
import ca.nanometrics.gflot.client.options.TickFormatter;
import com.google.gwt.i18n.client.DateTimeFormat;
+import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.types.AnimationEffect;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.HTMLFlow;
@@ -52,9 +55,19 @@ import com.smartgwt.client.widgets.events.MouseOutHandler;
import com.smartgwt.client.widgets.layout.HLayout;
import com.smartgwt.client.widgets.layout.VLayout;
+import org.rhq.core.domain.criteria.ResourceCriteria;
+import org.rhq.core.domain.measurement.DataType;
+import org.rhq.core.domain.measurement.DisplayType;
import org.rhq.core.domain.measurement.MeasurementConverterClient;
import org.rhq.core.domain.measurement.MeasurementDefinition;
import org.rhq.core.domain.measurement.composite.MeasurementDataNumericHighLowComposite;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGWTServiceAsync;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
/**
* @author Greg Hinkle
@@ -71,6 +84,9 @@ public class SmallGraphView extends VLayout {
private final Label hoverLabel = new Label();
private int resourceId;
+
+ private int definitionId;
+
private MeasurementDefinition definition;
private List<MeasurementDataNumericHighLowComposite> data;
@@ -79,6 +95,12 @@ public class SmallGraphView extends VLayout {
super();
}
+
+ public SmallGraphView(int resourceId, int definitionId) {
+ this.resourceId = resourceId;
+ this.definitionId = definitionId;
+ }
+
public SmallGraphView(int resourceId, MeasurementDefinition def, List<MeasurementDataNumericHighLowComposite> data) {
super();
this.resourceId = resourceId;
@@ -102,7 +124,59 @@ public class SmallGraphView extends VLayout {
c.destroy();
}
- drawGraph();
+ if (this.definition == null) {
+
+
+ ResourceGWTServiceAsync resourceService = GWTServiceLookup.getResourceService();
+
+ ResourceCriteria resourceCriteria = new ResourceCriteria();
+ resourceCriteria.addFilterId(resourceId);
+ resourceService.findResourcesByCriteria(resourceCriteria, new AsyncCallback<PageList<Resource>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to find resource for graph", caught);
+ }
+
+ public void onSuccess(PageList<Resource> result) {
+ ResourceTypeRepository.Cache.getInstance().getResourceTypes(
+ result.get(0).getResourceType().getId(), EnumSet.of(ResourceTypeRepository.MetadataType.measurements),
+ new ResourceTypeRepository.TypeLoadedCallback() {
+ public void onTypesLoaded(final ResourceType type) {
+
+ for (MeasurementDefinition def : type.getMetricDefinitions()) {
+ if (def.getId() == definitionId) {
+ SmallGraphView.this.definition = def;
+
+
+ GWTServiceLookup.getMeasurementDataService().findDataForResource(
+ resourceId,
+ new int[]{definitionId},
+ System.currentTimeMillis() - (1000L * 60 * 60 * 8),
+ System.currentTimeMillis(),
+ 60,
+ new AsyncCallback<List<List<MeasurementDataNumericHighLowComposite>>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to load data for graph", caught);
+ }
+
+ public void onSuccess(List<List<MeasurementDataNumericHighLowComposite>> result) {
+ SmallGraphView.this.data = result.get(0);
+
+
+ drawGraph();
+ }
+ });
+ }
+ }
+ }
+ });
+ }
+ });
+
+
+ } else {
+
+ drawGraph();
+ }
}
@@ -209,7 +283,7 @@ public class SmallGraphView extends VLayout {
liveGraphLink.setContents("Live Graph");
liveGraphLink.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent clickEvent) {
- LiveGraphView.displayAsDialog(resourceId,definition);
+ LiveGraphView.displayAsDialog(resourceId, definition);
}
});
titleLayout.addMember(liveGraphLink);
commit 5559a772b001d79d4ebd13d4518a279c4674caad
Author: Greg Hinkle <ghinkle(a)redhat.com>
Date: Thu Apr 22 10:33:42 2010 -0400
Fix ad queue redraw
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java
index 6ef0606..7402610 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java
@@ -69,8 +69,8 @@ public class ResourceAutodiscoveryView extends VLayout {
}
@Override
- protected void onDraw() {
- super.onDraw();
+ protected void onInit() {
+ super.onInit();
HLayout titleLayout = new HLayout(150);
commit 77eaa908d85e18f3419a101bbb4b9ef3b2b7f57a
Author: Greg Hinkle <ghinkle(a)redhat.com>
Date: Thu Apr 22 10:19:56 2010 -0400
gwt plugin config editing (connection settings)
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ConfigurationGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ConfigurationGWTService.java
index 66d9d5f..cbe4cc9 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ConfigurationGWTService.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ConfigurationGWTService.java
@@ -2,6 +2,7 @@ package org.rhq.enterprise.gui.coregui.client.gwt;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PluginConfigurationUpdate;
import org.rhq.core.domain.configuration.RawConfiguration;
import org.rhq.core.domain.configuration.ResourceConfigurationUpdate;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
@@ -26,6 +27,8 @@ public interface ConfigurationGWTService extends RemoteService {
ResourceConfigurationUpdate updateResourceConfiguration(int resourceId, Configuration configuration);
+ PluginConfigurationUpdate updatePluginConfiguration(int resourceId, Configuration configuration);
+
RawConfiguration dummy(RawConfiguration config);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/PluginConfigurationEditView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/PluginConfigurationEditView.java
new file mode 100644
index 0000000..715b0ed
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/PluginConfigurationEditView.java
@@ -0,0 +1,103 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.coregui.client.inventory.resource.detail.inventory;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.types.Overflow;
+import com.smartgwt.client.widgets.IButton;
+import com.smartgwt.client.widgets.events.ClickEvent;
+import com.smartgwt.client.widgets.events.ClickHandler;
+import com.smartgwt.client.widgets.layout.LayoutSpacer;
+import com.smartgwt.client.widgets.layout.VLayout;
+import com.smartgwt.client.widgets.toolbar.ToolStrip;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PluginConfigurationUpdate;
+import org.rhq.core.domain.configuration.ResourceConfigurationUpdate;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.components.configuration.ConfigurationEditor;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message;
+
+/**
+ * @author Greg Hinkle
+ */
+public class PluginConfigurationEditView extends VLayout {
+
+
+ private Resource resource;
+ private ConfigurationEditor editor;
+
+ public PluginConfigurationEditView(Resource resource) {
+ this.resource = resource;
+ }
+
+
+ @Override
+ protected void onDraw() {
+ super.onDraw();
+ build();
+ }
+
+ public void build() {
+
+ ToolStrip toolStrip = new ToolStrip();
+ toolStrip.setWidth100();
+
+ toolStrip.addMember(new LayoutSpacer());
+
+ IButton saveButton = new IButton("Save");
+ saveButton.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent clickEvent) {
+ save();
+ }
+ });
+// saveButton.disable();
+ toolStrip.addMember(saveButton);
+
+
+ editor = new ConfigurationEditor(resource.getId(), resource.getResourceType().getId(), ConfigurationEditor.ConfigType.plugin);
+ editor.setOverflow(Overflow.AUTO);
+
+
+ addMember(toolStrip);
+
+ addMember(editor);
+ }
+
+ private void save() {
+ Configuration updatedConfiguration = editor.getConfiguration();
+
+
+ GWTServiceLookup.getConfigurationService().updatePluginConfiguration(
+ resource.getId(), updatedConfiguration, new AsyncCallback<PluginConfigurationUpdate>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to update configuration",caught);
+ }
+
+ public void onSuccess(PluginConfigurationUpdate result) {
+ CoreGUI.getMessageCenter().notify(new Message("Connection settings updated for resource [" + resource.getName() + "]", Message.Severity.Info));
+
+ }
+ }
+ );
+
+ }
+}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ConfigurationGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ConfigurationGWTServiceImpl.java
index 16062f4..83c15b7 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ConfigurationGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ConfigurationGWTServiceImpl.java
@@ -2,6 +2,7 @@ package org.rhq.enterprise.gui.coregui.server.gwt;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PluginConfigurationUpdate;
import org.rhq.core.domain.configuration.RawConfiguration;
import org.rhq.core.domain.configuration.ResourceConfigurationUpdate;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
@@ -68,6 +69,13 @@ public class ConfigurationGWTServiceImpl extends AbstractGWTServiceImpl implemen
return SerialUtility.prepare(update, "ConfigurationService.updateResourceConfiguration");
}
+ public PluginConfigurationUpdate updatePluginConfiguration(int resourceId, Configuration configuration) {
+ PluginConfigurationUpdate update =
+ configurationManager.updatePluginConfiguration(getSessionSubject(), resourceId, configuration);
+
+ return SerialUtility.prepare(update, "ConfigurationService.updatePluginConfiguration");
+ }
+
public RawConfiguration dummy(RawConfiguration config) {
System.out.println(config.getPath());
commit 924d2919beed9ecfb8157740408c292f8dfb4194
Author: Greg Hinkle <ghinkle(a)redhat.com>
Date: Thu Apr 22 10:13:13 2010 -0400
New tag system for bundle system
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index 58c9124..72b7c30 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.83</db.schema.version>
+ <db.schema.version>2.85</db.schema.version>
</properties>
<dependencies>
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml b/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml
index 07cf080..ab97d61 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-
+
<dbsetup name="content-schema.xml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="urn:xmlns:rhq-dbsetup-schema">
@@ -10,7 +10,7 @@
<field ref="NAME"/>
</index>
</table>
-
+
<table name="RHQ_REPO_GROUP_TYPE">
<column name="ID" default="sequence-only" initial="10001" primarykey="true" required="true" type="INTEGER"/>
<column name="NAME" size="200" type="VARCHAR2" required="true"/>
@@ -22,16 +22,16 @@
<column name="ID" default="sequence-only" initial="10001" primarykey="true" required="true" type="INTEGER"/>
<column name="NAME" size="200" type="VARCHAR2" required="true"/>
<column name="DESCRIPTION" size="500" type="VARCHAR2" required="false"/>
-
+
<column name="REPO_GROUP_TYPE_ID" type="INTEGER" references="RHQ_REPO_GROUP_TYPE" required="true"/>
-
+
<index name="RHQ_REPO_GROUP_IDX" unique="true">
<field ref="NAME"/>
<field ref="REPO_GROUP_TYPE_ID"/>
</index>
</table>
-
+
<table name="RHQ_CONTENT_SOURCE_TYPE">
<column name="ID" default="sequence-only" initial="10001" primarykey="true" required="true" type="INTEGER"/>
<column name="NAME" size="200" type="VARCHAR2" required="true"/>
@@ -211,7 +211,7 @@
<column name="RESULTS" type="LONGVARCHAR" required="false"/>
<column name="CONTENT_SRC_ID" type="INTEGER" required="true" references="RHQ_CONTENT_SOURCE"/>
</table>
-
+
<table name="RHQ_REPO_SYNC">
<column name="ID" default="sequence-only" initial="10001" primarykey="true" required="true" type="INTEGER"/>
<column name="STATUS" type="VARCHAR2" size="16" required="true"/>
@@ -221,7 +221,7 @@
<column name="PERCENT_COMPLETE" type="LONG" required="false"/>
<column name="REPO_ID" type="INTEGER" required="true" references="RHQ_REPO"/>
</table>
-
+
<table name="RHQ_PACKAGE_INST_STEP">
<column name="ID" default="sequence-only" initial="10001" primarykey="true" required="true" type="INTEGER"/>
@@ -272,7 +272,7 @@
</primaryKey>
</constraint>
</table>
-
+
<table name="RHQ_REPO_REPO_RELATION_MAP">
<column name="REPO_ID" type="INTEGER" required="true" references="RHQ_REPO"/>
<column name="REPO_RELATION_ID" type="INTEGER" required="true" references="RHQ_REPO_RELATION"/>
@@ -285,7 +285,7 @@
</primaryKey>
</constraint>
</table>
-
+
<table name="RHQ_REPO_PKG_VERSION_MAP">
<column name="REPO_ID" type="INTEGER" required="true" references="RHQ_REPO"/>
@@ -363,11 +363,7 @@
</constraint>
</table>
- <table name="RHQ_TAG">
- <column name="ID" default="sequence-only" initial="10001" primarykey="true" required="true" type="INTEGER"/>
- <column name="NAME" size="200" type="VARCHAR2" required="true"/>
- <column name="DESCRIPTION" size="500" type="VARCHAR2" required="false"/>
- </table>
+
<table name="RHQ_DISTRIBUTION_FILE">
<column name="ID" default="sequence-only" initial="10001" primarykey="true" required="true" type="INTEGER"/>
@@ -377,25 +373,15 @@
<column name="MD5SUM" size="64" type="VARCHAR2" required="true"/>
<column name="LAST_MODIFIED" type="LONG" required="true"/>
<!--<column name="CTIME" type="LONG" required="true"/>-->
-
+
<index name="RHQ_DISTRIBUTION_FILE_IDX" unique="true">
<field ref="DISTRIBUTION_ID"/>
<field ref="RELATIVE_FILENAME"/>
</index>
</table>
-
- <table name="RHQ_REPO_TAG_MAP">
- <column name="REPO_ID" type="INTEGER" required="true" references="RHQ_REPO"/>
- <column name="TAG_ID" type="INTEGER" required="true" references="RHQ_TAG"/>
-
- <constraint name="RHQ_REPO_TAG_MAP_KEY">
- <primaryKey>
- <field ref="REPO_ID"/>
- <field ref="TAG_ID"/>
- </primaryKey>
- </constraint>
- </table>
+
+
<table name="RHQ_ADVISORY">
<column name="ID" default="sequence-only" initial="10001" primarykey="true" required="true" type="INTEGER"/>
@@ -406,69 +392,69 @@
<column name="DESCRIPTION" size="4000" type="VARCHAR2" required="false"/>
<column name="SYNOPSIS" size="4000" type="VARCHAR2" required="true"/>
<column name="TOPIC" size="4000" type="VARCHAR2" required="false"/>
- <column name="SOLUTION" size="4000" type="VARCHAR2" required="false"/>
- <column name="SEVERITY" size="64" type="VARCHAR2" required="false"/>
+ <column name="SOLUTION" size="4000" type="VARCHAR2" required="false"/>
+ <column name="SEVERITY" size="64" type="VARCHAR2" required="false"/>
<column name="ISSUE_DATE" type="LONG" required="false"/>
<column name="UPDATE_DATE" type="LONG" required="false"/>
<column name="CTIME" type="LONG" required="true"/>
<column name="LAST_MODIFIED" type="LONG" required="true"/>
-
+
<index name="RHQ_ADVISORY_NAME_UQ" unique="true">
<field ref="ADVISORY_NAME"/>
</index>
-
+
<index name="RHQ_ADVISORY_UQ" unique="true">
<field ref="ADVISORY"/>
</index>
-
+
<index name="RHQ_ADVISORY_UDATE_IDX" unique="false">
<field ref="UPDATE_DATE"/>
- </index>
+ </index>
</table>
-
+
<table name="RHQ_ADVISORY_PACKAGE">
<column name="ID" default="sequence-only" initial="10001" primarykey="true" required="true" type="INTEGER"/>
<column name="ADVISORY_ID" type="INTEGER" required="true" references="RHQ_ADVISORY"/>
<column name="PACKAGE_VERSION_ID" type="INTEGER" required="true" references="RHQ_PACKAGE_VERSION"/>
<column name="LAST_MODIFIED" type="LONG" required="true"/>
-
+
<index name="RHQ_ADVISORY_PKG_IDX" unique="true">
<field ref="ADVISORY_ID"/>
<field ref="PACKAGE_VERSION_ID"/>
</index>
</table>
-
+
<table name="RHQ_CVE">
<column name="ID" default="sequence-only" initial="101" primarykey="true" required="true" type="INTEGER"/>
<column name="NAME" size="64" type="VARCHAR2" required="true"/>
</table>
-
+
<table name="RHQ_ADVISORY_CVE">
<column name="ID" default="sequence-only" initial="10001" primarykey="true" required="true" type="INTEGER"/>
<column name="ADVISORY_ID" type="INTEGER" required="true" references="RHQ_ADVISORY"/>
<column name="CVE_ID" type="INTEGER" required="true" references="RHQ_CVE"/>
<column name="LAST_MODIFIED" type="LONG" required="false"/>
-
+
<index name="RHQ_ADVISORY_CVE_IDX" unique="true">
<field ref="ADVISORY_ID"/>
<field ref="CVE_ID"/>
</index>
</table>
-
+
<table name="RHQ_ADVISORY_BUGLIST">
<column name="ID" default="sequence-only" initial="10001" primarykey="true" required="true" type="INTEGER"/>
<column name="ADVISORY_ID" type="INTEGER" required="true" references="RHQ_ADVISORY"/>
<column name="BUG_ID" size="256" type="VARCHAR2" required="true"/>
<column name="LAST_MODIFIED" type="LONG" required="true"/>
-
+
<index name="RHQ_ADVISORY_BUG_IDX" unique="true">
<field ref="ADVISORY_ID"/>
<field ref="BUG_ID"/>
</index>
</table>
-
-
+
+
<table name="RHQ_REPO_ADVISORY">
<column name="REPO_ID" type="INTEGER" required="true" references="RHQ_REPO"/>
<column name="ADVISORY_ID" type="INTEGER" required="true" references="RHQ_ADVISORY"/>
@@ -481,16 +467,16 @@
</primaryKey>
</constraint>
</table>
-
+
<!-- BUNDLE_TYPE is things like "Cobbler profile" or "file-based bundle" or "puppet recipe" -->
<table name="RHQ_BUNDLE_TYPE">
<column name="ID" default="sequence-only" initial="10001" primarykey="true" required="true" type="INTEGER"/>
<column name="NAME" size="200" type="VARCHAR2" required="true"/>
<column name="RESOURCE_TYPE_ID" type="INTEGER" required="true" references="RHQ_RESOURCE_TYPE"/>
- <!-- This index is for constraint, not performance -->
- <index name="RHQ_BUNDLE_TYPE_UNIQUE" unique="true">
- <field ref="NAME"/>
+ <!-- This index is for constraint, not performance -->
+ <index name="RHQ_BUNDLE_TYPE_UNIQUE" unique="true">
+ <field ref="NAME"/>
</index>
</table>
@@ -498,15 +484,15 @@
<table name="RHQ_BUNDLE">
<column name="ID" default="sequence-only" initial="10001" primarykey="true" required="true" type="INTEGER"/>
<column name="NAME" size="200" type="VARCHAR2" required="true"/>
- <column name="DESCRIPTION" size="500" type="VARCHAR2" required="false"/>
+ <column name="DESCRIPTION" size="500" type="VARCHAR2" required="false"/>
<column name="BUNDLE_TYPE_ID" type="INTEGER" required="true" references="RHQ_BUNDLE_TYPE"/>
<column name="PACKAGE_TYPE_ID" type="INTEGER" required="true" references="RHQ_PACKAGE_TYPE"/>
<column name="REPO_ID" type="INTEGER" required="true" references="RHQ_REPO"/>
- <!-- This index is for constraint, not performance -->
+ <!-- This index is for constraint, not performance -->
<index name="RHQ_BUNDLE_UNIQUE" unique="true">
- <field ref="BUNDLE_TYPE_ID"/>
- <field ref="NAME"/>
+ <field ref="BUNDLE_TYPE_ID"/>
+ <field ref="NAME"/>
</index>
</table>
@@ -521,11 +507,11 @@
<column name="CONFIG_DEF_ID" type="INTEGER" required="false" references="RHQ_CONFIG_DEF" />
<column name="BUNDLE_ID" type="INTEGER" required="true" references="RHQ_BUNDLE"/>
- <!-- This index is for constraint, not performance -->
+ <!-- This index is for constraint, not performance -->
<index name="RHQ_BUNDLE_VERSION_UNIQUE" unique="true">
<field ref="BUNDLE_ID"/>
<field ref="NAME"/>
- <field ref="VERSION"/>
+ <field ref="VERSION"/>
</index>
</table>
@@ -548,7 +534,7 @@
<column name="ID" default="sequence-only" initial="10001" primarykey="true" required="true" type="INTEGER"/>
<column name="BUNDLE_VERSION_ID" type="INTEGER" required="true" references="RHQ_BUNDLE_VERSION"/>
<column name="PACKAGE_VERSION_ID" type="INTEGER" required="true" references="RHQ_PACKAGE_VERSION"/>
- </table>
+ </table>
<!-- A set of configuration values that are used to customize how a bundle version is installed -->
<table name="RHQ_BUNDLE_DEPLOY">
@@ -556,13 +542,13 @@
<column name="NAME" size="200" type="VARCHAR2" required="true"/>
<column name="DESCRIPTION" size="500" type="VARCHAR2" required="false"/>
<column name="CTIME" type="LONG" required="true"/>
- <column name="MTIME" type="LONG" required="true"/>
+ <column name="MTIME" type="LONG" required="true"/>
<column name="INSTALL_DIR" size="256" type="VARCHAR2" required="true"/>
<column name="CONFIG_ID" type="INTEGER" required="false" references="RHQ_CONFIG" />
<column name="BUNDLE_VERSION_ID" type="INTEGER" required="true" references="RHQ_BUNDLE_VERSION"/>
- <!-- This index is for constraint, not performance -->
- <index name="RHQ_BUNDLE_DEPLOY_DEF_UNIQUE" unique="true">
+ <!-- This index is for constraint, not performance -->
+ <index name="RHQ_BUNDLE_DEPLOY_UNIQUE" unique="true">
<field ref="BUNDLE_VERSION_ID"/>
<field ref="NAME"/>
<field ref="INSTALL_DIR"/>
@@ -572,14 +558,14 @@
<table name="RHQ_BUNDLE_GROUP_DEPLOY">
<column name="ID" type="INTEGER" required="true" default="sequence-only" initial="10001" primarykey="true"/>
<column name="GROUP_ID" type="INTEGER" required="true" references="RHQ_RESOURCE_GROUP"/>
- <column name="BUNDLE_DEPLOY_ID" type="INTEGER" required="true" references="RHQ_BUNDLE_DEPLOY" />
+ <column name="BUNDLE_DEPLOY_ID" type="INTEGER" required="true" references="RHQ_BUNDLE_DEPLOY" />
<column name="STATUS" type="VARCHAR2" required="true" size="16"/>
<column name="ERROR_MESSAGE" type="LONGVARCHAR" required="false"/>
<column name="SUBJECT_NAME" type="VARCHAR2" required="true" size="255"/>
<column name="CTIME" type="LONG" required="true"/>
<column name="MTIME" type="LONG" required="true"/>
</table>
-
+
<!-- Represents a bundle version that is deployed on a platform resource -->
<table name="RHQ_BUNDLE_RES_DEPLOY">
<column name="ID" default="sequence-only" initial="10001" primarykey="true" required="true" type="INTEGER"/>
@@ -588,14 +574,14 @@
<column name="IS_CURRENT" type="BOOLEAN" required="true"/>
<column name="STATUS" type="VARCHAR2" required="true" size="16"/>
<column name="CTIME" type="LONG" required="true"/>
- <column name="BUNDLE_GROUP_DEPLOY_ID" type="INTEGER" required="false" references="RHQ_BUNDLE_GROUP_DEPLOY"/>
+ <column name="BUNDLE_GROUP_DEPLOY_ID" type="INTEGER" required="false" references="RHQ_BUNDLE_GROUP_DEPLOY"/>
<index name="RHQ_DEPLOY_DEF_RESOURCE_IDX" unique="true">
<field ref="BUNDLE_DEPLOY_ID"/>
<field ref="RESOURCE_ID"/>
</index>
</table>
-
+
<table name="RHQ_BUNDLE_RES_DEP_HIST">
<column name="ID" default="sequence-only" initial="10001" primarykey="true" required="true" type="INTEGER"/>
<column name="BUNDLE_RES_DEPLOY_ID" type="INTEGER" required="true" references="RHQ_BUNDLE_RES_DEPLOY" />
@@ -604,7 +590,42 @@
<column name="AUDIT_ACTION" required="true" size="512" type="VARCHAR2"/>
<column name="AUDIT_STATUS" required="true" type="VARCHAR2" size="16"/>
<column name="AUDIT_MESSAGE" required="false" type="LONGVARCHAR"/>
- </table>
+ </table>
+
+
+ <!-- TAG mapping tables added in 2.85 -->
+ <table name="RHQ_TAGGING_BUNDLE_MAP">
+ <column name="BUNDLE_ID" type="INTEGER" references="RHQ_BUNDLE"/>
+ <column name="TAG_ID" type="INTEGER" references="RHQ_TAGGING"/>
+ <constraint name="RHQ_TAGGING_BUNDLE_MAP_KEY">
+ <primaryKey>
+ <field ref="BUNDLE_ID"/>
+ <field ref="TAG_ID"/>
+ </primaryKey>
+ </constraint>
+ </table>
+ <table name="RHQ_TAGGING_BND_VER_MAP">
+ <column name="BUNDLE_VERSION_ID" type="INTEGER" references="RHQ_BUNDLE_VERSION"/>
+ <column name="TAG_ID" type="INTEGER" references="RHQ_TAGGING"/>
+ <constraint name="RHQ_TAGGING_BND_VER_MAP_KEY">
+ <primaryKey>
+ <field ref="BUNDLE_VERSION_ID"/>
+ <field ref="TAG_ID"/>
+ </primaryKey>
+ </constraint>
+ </table>
+
+ <table name="RHQ_TAGGING_BND_DEP_MAP">
+ <column name="BUNDLE_DEPLOYMENT_ID" type="INTEGER" references="RHQ_BUNDLE_DEPLOY"/>
+ <column name="TAG_ID" type="INTEGER" references="RHQ_TAGGING"/>
+ <constraint name="RHQ_TAGGING_BND_DEP_MAP_KEY">
+ <primaryKey>
+ <field ref="BUNDLE_DEPLOYMENT_ID"/>
+ <field ref="TAG_ID"/>
+ </primaryKey>
+ </constraint>
+ </table>
+
</dbsetup>
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/dbsetup-schema.xsd b/modules/core/dbutils/src/main/scripts/dbsetup/dbsetup-schema.xsd
index 860f4c4..4422b8a 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/dbsetup-schema.xsd
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/dbsetup-schema.xsd
@@ -65,6 +65,7 @@
<xs:enumeration value="VARCHAR2"/>
<xs:enumeration value="DOUBLE"/>
<xs:enumeration value="TIMESTAMP"/>
+ <xs:enumeration value="LONGVARCHAR"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/inventory-schema.xml b/modules/core/dbutils/src/main/scripts/dbsetup/inventory-schema.xml
index 2f25ff1..3167457 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/inventory-schema.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/inventory-schema.xml
@@ -236,4 +236,34 @@
<column name="DTYPE" type="VARCHAR2" required="true" size="10"/>
</table>
+
+ <table name="RHQ_TAGGING">
+ <column name="ID" type="INTEGER" required="true" default="sequence-only" initial="10001" primarykey="true"/>
+ <column name="NAMESPACE" type="VARCHAR2" required="false" size="20"/>
+ <column name="SEMANTIC" type="VARCHAR2" required="false" size="50"/>
+ <column name="NAME" type="VARCHAR2" required="true" size="100"/>
+ </table>
+
+ <table name="RHQ_TAGGING_RESOURCE_MAP">
+ <column name="RESOURCE_ID" type="INTEGER" references="RHQ_RESOURCE"/>
+ <column name="TAG_ID" type="INTEGER" references="RHQ_TAGGING"/>
+ <constraint name="RHQ_TAGGING_RESOURCE_MAP_KEY">
+ <primaryKey>
+ <field ref="RESOURCE_ID"/>
+ <field ref="TAG_ID"/>
+ </primaryKey>
+ </constraint>
+ </table>
+
+ <table name="RHQ_TAGGING_RES_GRP_MAP">
+ <column name="RESOURCE_GROUP_ID" type="INTEGER" references="RHQ_RESOURCE_GROUP"/>
+ <column name="TAG_ID" type="INTEGER" references="RHQ_TAGGING"/>
+ <constraint name="RHQ_TAGGING_RES_GRP_MAP_KEY">
+ <primaryKey>
+ <field ref="RESOURCE_GROUP_ID"/>
+ <field ref="TAG_ID"/>
+ </primaryKey>
+ </constraint>
+ </table>
+
</dbsetup>
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/obsolete-schema.xml b/modules/core/dbutils/src/main/scripts/dbsetup/obsolete-schema.xml
index 1d0c194..596aad8 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/obsolete-schema.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/obsolete-schema.xml
@@ -44,5 +44,24 @@
</index>
</table>
+
+ <table name="RHQ_TAG" obsolete="true">
+ <column name="ID" default="sequence-only" initial="10001" primarykey="true" required="true" type="INTEGER"/>
+ <column name="NAME" size="200" type="VARCHAR2" required="true"/>
+ <column name="DESCRIPTION" size="500" type="VARCHAR2" required="false"/>
+ </table>
+
+ <table name="RHQ_REPO_TAG_MAP" obsolete="true">
+ <column name="REPO_ID" type="INTEGER" required="true" references="RHQ_REPO"/>
+ <column name="TAG_ID" type="INTEGER" required="true" references="RHQ_TAG"/>
+
+ <constraint name="RHQ_REPO_TAG_MAP_KEY">
+ <primaryKey>
+ <field ref="REPO_ID"/>
+ <field ref="TAG_ID"/>
+ </primaryKey>
+ </constraint>
+ </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 beeab4b..6550626 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -2706,10 +2706,18 @@
</schema-directSQL>
</schemaSpec>
+<<<<<<< HEAD
<schemaSpec version="2.83">
<schema-directSQL>
<statement desc="Creating table RHQ_SUBJECT_ROLE_LDAP_MAP">
CREATE TABLE RHQ_SUBJECT_ROLE_LDAP_MAP ( SUBJECT_ID INTEGER, ROLE_ID INTEGER )
+=======
+ <schemaSpec version="2.83">
+ <!-- The following constraint change shortens the constraint name < 30 chars for Oracle. -->
+ <schema-directSQL>
+ <statement targetDBVendor="postgresql" desc="Dropping RHQ_SUBJECT_ROLE_LDAP_MAP constraint RHQ_SUBJECT_ROLE_LDAP_MAPPING_KEY.">
+ ALTER TABLE RHQ_SUBJECT_ROLE_LDAP_MAP DROP CONSTRAINT RHQ_SUBJECT_ROLE_LDAP_MAPPING_KEY;
+>>>>>>> New tag system for bundle system
</statement>
<statement desc="Creating composite PK for RHQ_SUBJECT_ROLE_LDAP_MAP">
ALTER TABLE RHQ_SUBJECT_ROLE_LDAP_MAP
@@ -2733,6 +2741,245 @@
<schema-alterColumn table="RHQ_SUBJECT_ROLE_LDAP_MAP" column="ROLE_ID" nullable="FALSE" />
</schemaSpec>
+
+
+ <!-- Remove the old tagging system -->
+ <schemaSpec version="2.84">
+ <schema-dropTable table="RHQ_REPO_TAG_MAP"/>
+ <schema-dropTable table="RHQ_TAG"/>
+ </schemaSpec>
+
+ <!-- The new tagging system -->
+ <schemaSpec version="2.85">
+ <schema-directSQL>
+ <statement desc="Creating table RHQ_TAGGING">
+ CREATE TABLE RHQ_TAGGING ( ID INTEGER PRIMARY KEY)
+ </statement>
+ </schema-directSQL>
+ <schema-alterColumn table="RHQ_TAGGING" column="ID" nullable="FALSE" />
+ <schema-createSequence name="RHQ_TAGGING_ID_SEQ" initial="10001" />
+ <schema-addColumn table="RHQ_TAGGING" column="NAMESPACE" columnType="VARCHAR2" precision="20" />
+ <schema-alterColumn table="RHQ_TAGGING" column="NAMESPACE" nullable="TRUE" />
+ <schema-addColumn table="RHQ_TAGGING" column="SEMANTIC" columnType="VARCHAR2" precision="50" />
+ <schema-alterColumn table="RHQ_TAGGING" column="SEMANTIC" nullable="TRUE" />
+ <schema-addColumn table="RHQ_TAGGING" column="NAME" columnType="VARCHAR2" precision="100" />
+ <schema-alterColumn table="RHQ_TAGGING" column="NAME" nullable="FALSE" />
+
+
+
+
+ <schema-directSQL>
+ <statement>
+ CREATE TABLE RHQ_TAGGING_RESOURCE_MAP ( RESOURCE_ID INTEGER )
+ </statement>
+ </schema-directSQL>
+ <schema-alterColumn table="RHQ_TAGGING_RESOURCE_MAP" column="RESOURCE_ID" nullable="false" />
+ <schema-addColumn table="RHQ_TAGGING_RESOURCE_MAP" column="TAG_ID" columnType="INTEGER" />
+ <schema-alterColumn table="RHQ_TAGGING_RESOURCE_MAP" column="TAG_ID" nullable="false" />
+ <schema-directSQL>
+ <statement>
+ ALTER TABLE RHQ_TAGGING_RESOURCE_MAP
+ ADD CONSTRAINT RHQ_TAGGING_RESOURCE_MAP_KEY
+ PRIMARY KEY ( RESOURCE_ID, TAG_ID )
+ </statement>
+ <statement targetDBVendor="postgresql">
+ ALTER TABLE RHQ_TAGGING_RESOURCE_MAP
+ ADD CONSTRAINT RHQ_TAGGING_RESOURCE_MAP_RESOURCE_ID_FKEY
+ FOREIGN KEY ( RESOURCE_ID )
+ REFERENCES RHQ_RESOURCE ( ID )
+ </statement>
+ <statement targetDBVendor="oracle">
+ ALTER TABLE RHQ_TAGGING_RESOURCE_MAP
+ ADD FOREIGN KEY ( RESOURCE_ID )
+ REFERENCES RHQ_RESOURCE ( ID )
+ </statement>
+ <statement targetDBVendor="postgresql">
+ ALTER TABLE RHQ_TAGGING_RESOURCE_MAP
+ ADD CONSTRAINT RHQ_TAGGING_RESOURCE_MAP_TAG_ID_FKEY
+ FOREIGN KEY ( TAG_ID )
+ REFERENCES RHQ_TAGGING ( ID )
+ </statement>
+ <statement targetDBVendor="oracle">
+ ALTER TABLE RHQ_TAGGING_RESOURCE_MAP
+ ADD FOREIGN KEY ( TAG_ID )
+ REFERENCES RHQ_TAGGING ( ID )
+ </statement>
+ </schema-directSQL>
+
+
+
+ <schema-directSQL>
+ <statement>
+ CREATE TABLE RHQ_TAGGING_RES_GRP_MAP ( RESOURCE_GROUP_ID INTEGER )
+ </statement>
+ </schema-directSQL>
+ <schema-alterColumn table="RHQ_TAGGING_RES_GRP_MAP" column="RESOURCE_GROUP_ID" nullable="false" />
+ <schema-addColumn table="RHQ_TAGGING_RES_GRP_MAP" column="TAG_ID" columnType="INTEGER" />
+ <schema-alterColumn table="RHQ_TAGGING_RES_GRP_MAP" column="TAG_ID" nullable="false" />
+ <schema-directSQL>
+ <statement>
+ ALTER TABLE RHQ_TAGGING_RES_GRP_MAP
+ ADD CONSTRAINT RHQ_TAGGING_RES_GRP_MAP_KEY
+ PRIMARY KEY ( RESOURCE_GROUP_ID, TAG_ID )
+ </statement>
+ <statement targetDBVendor="postgresql">
+ ALTER TABLE RHQ_TAGGING_RES_GRP_MAP
+ ADD CONSTRAINT RHQ_TAGGING_RES_GRP_MAP_RESOURCE_GROUP_ID_FKEY
+ FOREIGN KEY ( RESOURCE_GROUP_ID )
+ REFERENCES RHQ_RESOURCE ( ID )
+ </statement>
+ <statement targetDBVendor="oracle">
+ ALTER TABLE RHQ_TAGGING_RES_GRP_MAP
+ ADD FOREIGN KEY ( RESOURCE_GROUP_ID )
+ REFERENCES RHQ_RESOURCE ( ID )
+ </statement>
+ <statement targetDBVendor="postgresql">
+ ALTER TABLE RHQ_TAGGING_RES_GRP_MAP
+ ADD CONSTRAINT RHQ_TAGGING_RES_GRP_MAP_TAG_ID_FKEY
+ FOREIGN KEY ( TAG_ID )
+ REFERENCES RHQ_TAGGING ( ID )
+ </statement>
+ <statement targetDBVendor="oracle">
+ ALTER TABLE RHQ_TAGGING_RES_GRP_MAP
+ ADD FOREIGN KEY ( TAG_ID )
+ REFERENCES RHQ_TAGGING ( ID )
+ </statement>
+ </schema-directSQL>
+
+
+
+
+ <schema-directSQL>
+ <statement>
+ CREATE TABLE RHQ_TAGGING_BUNDLE_MAP ( BUNDLE_ID INTEGER )
+ </statement>
+ </schema-directSQL>
+ <schema-alterColumn table="RHQ_TAGGING_BUNDLE_MAP" column="BUNDLE_ID" nullable="false" />
+ <schema-addColumn table="RHQ_TAGGING_BUNDLE_MAP" column="TAG_ID" columnType="INTEGER" />
+ <schema-alterColumn table="RHQ_TAGGING_BUNDLE_MAP" column="TAG_ID" nullable="false" />
+ <schema-directSQL>
+ <statement>
+ ALTER TABLE RHQ_TAGGING_BUNDLE_MAP
+ ADD CONSTRAINT RHQ_TAGGING_BUNDLE_MAP_KEY
+ PRIMARY KEY ( BUNDLE_ID, TAG_ID )
+ </statement>
+ <statement targetDBVendor="postgresql">
+ ALTER TABLE RHQ_TAGGING_BUNDLE_MAP
+ ADD CONSTRAINT RHQ_TAGGING_BUNDLE_MAP_BUNDLE_ID_FKEY
+ FOREIGN KEY ( BUNDLE_ID )
+ REFERENCES RHQ_RESOURCE ( ID )
+ </statement>
+ <statement targetDBVendor="oracle">
+ ALTER TABLE RHQ_TAGGING_BUNDLE_MAP
+ ADD FOREIGN KEY ( BUNDLE_ID )
+ REFERENCES RHQ_RESOURCE ( ID )
+ </statement>
+ <statement targetDBVendor="postgresql">
+ ALTER TABLE RHQ_TAGGING_BUNDLE_MAP
+ ADD CONSTRAINT RHQ_TAGGING_BUNDLE_MAP_TAG_ID_FKEY
+ FOREIGN KEY ( TAG_ID )
+ REFERENCES RHQ_TAGGING ( ID )
+ </statement>
+ <statement targetDBVendor="oracle">
+ ALTER TABLE RHQ_TAGGING_BUNDLE_MAP
+ ADD FOREIGN KEY ( TAG_ID )
+ REFERENCES RHQ_TAGGING ( ID )
+ </statement>
+ </schema-directSQL>
+
+
+
+
+
+
+
+ <schema-directSQL>
+ <statement>
+ CREATE TABLE RHQ_TAGGING_BND_VER_MAP ( BUNDLE_VERSION_ID INTEGER )
+ </statement>
+ </schema-directSQL>
+ <schema-alterColumn table="RHQ_TAGGING_BND_VER_MAP" column="BUNDLE_VERSION_ID" nullable="false" />
+ <schema-addColumn table="RHQ_TAGGING_BND_VER_MAP" column="TAG_ID" columnType="INTEGER" />
+ <schema-alterColumn table="RHQ_TAGGING_BND_VER_MAP" column="TAG_ID" nullable="false" />
+ <schema-directSQL>
+ <statement>
+ ALTER TABLE RHQ_TAGGING_BND_VER_MAP
+ ADD CONSTRAINT RHQ_TAGGING_BND_VER_MAP_KEY
+ PRIMARY KEY ( BUNDLE_VERSION_ID, TAG_ID )
+ </statement>
+ <statement targetDBVendor="postgresql">
+ ALTER TABLE RHQ_TAGGING_BND_VER_MAP
+ ADD CONSTRAINT RHQ_TAGGING_BND_VER_MAP_BUNDLE_VERSION_ID_FKEY
+ FOREIGN KEY ( BUNDLE_VERSION_ID )
+ REFERENCES RHQ_RESOURCE ( ID )
+ </statement>
+ <statement targetDBVendor="oracle">
+ ALTER TABLE RHQ_TAGGING_BND_VER_MAP
+ ADD FOREIGN KEY ( BUNDLE_VERSION_ID )
+ REFERENCES RHQ_RESOURCE ( ID )
+ </statement>
+ <statement targetDBVendor="postgresql">
+ ALTER TABLE RHQ_TAGGING_BND_VER_MAP
+ ADD CONSTRAINT RHQ_TAGGING_BND_VER_MAP_TAG_ID_FKEY
+ FOREIGN KEY ( TAG_ID )
+ REFERENCES RHQ_TAGGING ( ID )
+ </statement>
+ <statement targetDBVendor="oracle">
+ ALTER TABLE RHQ_TAGGING_BND_VER_MAP
+ ADD FOREIGN KEY ( TAG_ID )
+ REFERENCES RHQ_TAGGING ( ID )
+ </statement>
+ </schema-directSQL>
+
+
+
+
+ <schema-directSQL>
+ <statement>
+ CREATE TABLE RHQ_TAGGING_BND_DEP_MAP ( BUNDLE_DEPLOYMENT_ID INTEGER )
+ </statement>
+ </schema-directSQL>
+ <schema-alterColumn table="RHQ_TAGGING_BND_DEP_MAP" column="BUNDLE_DEPLOYMENT_ID" nullable="false" />
+ <schema-addColumn table="RHQ_TAGGING_BND_DEP_MAP" column="TAG_ID" columnType="INTEGER" />
+ <schema-alterColumn table="RHQ_TAGGING_BND_DEP_MAP" column="TAG_ID" nullable="false" />
+ <schema-directSQL>
+ <statement>
+ ALTER TABLE RHQ_TAGGING_BND_DEP_MAP
+ ADD CONSTRAINT RHQ_TAGGING_BND_DEP_MAP_KEY
+ PRIMARY KEY ( BUNDLE_DEPLOYMENT_ID, TAG_ID )
+ </statement>
+ <statement targetDBVendor="postgresql">
+ ALTER TABLE RHQ_TAGGING_BND_DEP_MAP
+ ADD CONSTRAINT RHQ_TAGGING_BND_DEP_MAP_BUNDLE_DEPLOYMENT_ID_FKEY
+ FOREIGN KEY ( BUNDLE_DEPLOYMENT_ID )
+ REFERENCES RHQ_RESOURCE ( ID )
+ </statement>
+ <statement targetDBVendor="oracle">
+ ALTER TABLE RHQ_TAGGING_BND_DEP_MAP
+ ADD FOREIGN KEY ( BUNDLE_DEPLOYMENT_ID )
+ REFERENCES RHQ_RESOURCE ( ID )
+ </statement>
+ <statement targetDBVendor="postgresql">
+ ALTER TABLE RHQ_TAGGING_BND_DEP_MAP
+ ADD CONSTRAINT RHQ_TAGGING_BND_DEP_MAP_TAG_ID_FKEY
+ FOREIGN KEY ( TAG_ID )
+ REFERENCES RHQ_TAGGING ( ID )
+ </statement>
+ <statement targetDBVendor="oracle">
+ ALTER TABLE RHQ_TAGGING_BND_DEP_MAP
+ ADD FOREIGN KEY ( TAG_ID )
+ REFERENCES RHQ_TAGGING ( ID )
+ </statement>
+ </schema-directSQL>
+
+
+
+
+
+
+
+ </schemaSpec>
+
</dbupgrade>
</target>
</project>
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/Bundle.java b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/Bundle.java
index 1a59123..11a1b2c 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/Bundle.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/Bundle.java
@@ -25,6 +25,7 @@ package org.rhq.core.domain.bundle;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
+import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
@@ -34,6 +35,7 @@ import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
+import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
@@ -46,6 +48,7 @@ import javax.xml.bind.annotation.XmlAccessorType;
import org.rhq.core.domain.content.PackageType;
import org.rhq.core.domain.content.Repo;
+import org.rhq.core.domain.tagging.Tag;
/**
* Defines a bundle of content that can be versioned.
@@ -97,6 +100,10 @@ public class Bundle implements Serializable {
@OneToMany(mappedBy = "bundle", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
private List<BundleVersion> bundleVersions = new ArrayList<BundleVersion>();
+ @ManyToMany(mappedBy = "bundles", fetch = FetchType.LAZY)
+ private Set<Tag> tags;
+
+
public Bundle() {
// for JPA use
}
@@ -169,6 +176,14 @@ public class Bundle implements Serializable {
this.bundleVersions = bundleVersions;
}
+ public Set<Tag> getTags() {
+ return tags;
+ }
+
+ public void setTags(Set<Tag> tags) {
+ this.tags = tags;
+ }
+
@Override
public String toString() {
return "Bundle[id=" + id + ",name=" + name + ",bundleType=" + bundleType + ",packageType=" + packageType + "]";
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeployment.java b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeployment.java
index 6df9bb2..081815b 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeployment.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeployment.java
@@ -25,6 +25,7 @@ package org.rhq.core.domain.bundle;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
+import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
@@ -34,6 +35,7 @@ import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
+import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
@@ -46,6 +48,7 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.tagging.Tag;
/**
* Defines a set of configuration values that can be used to deploy a bundle version somewhere. Once set the
@@ -100,6 +103,10 @@ public class BundleDeployment implements Serializable {
@OneToMany(mappedBy = "bundleDeployment", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
private List<BundleGroupDeployment> groupDeployments = new ArrayList<BundleGroupDeployment>();
+ @ManyToMany(mappedBy = "resources", fetch = FetchType.LAZY)
+ private Set<Tag> tags;
+
+
public BundleDeployment() {
// for JPA use
}
@@ -206,6 +213,14 @@ public class BundleDeployment implements Serializable {
this.groupDeployments = groupDeployments;
}
+ public Set<Tag> getTags() {
+ return tags;
+ }
+
+ public void setTags(Set<Tag> tags) {
+ this.tags = tags;
+ }
+
@Override
public String toString() {
return "BundleDeployment[id=" + id + ", name=" + name + "]";
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersion.java b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersion.java
index 6ce40e4..55cffad 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersion.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersion.java
@@ -25,6 +25,7 @@ package org.rhq.core.domain.bundle;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
+import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
@@ -34,6 +35,7 @@ import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
+import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
@@ -44,6 +46,7 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
+import org.rhq.core.domain.tagging.Tag;
/**
* Defines a versioned bundle of content that can be provisioned somewhere.
@@ -120,6 +123,9 @@ public class BundleVersion implements Serializable {
@OneToMany(mappedBy = "bundleVersion", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
private List<BundleFile> bundleFiles = new ArrayList<BundleFile>();
+ @ManyToMany(mappedBy = "resources", fetch = FetchType.LAZY)
+ private Set<Tag> tags;
+
public BundleVersion() {
// for JPA use
}
@@ -229,6 +235,14 @@ public class BundleVersion implements Serializable {
this.bundleFiles = bundleFiles;
}
+ public Set<Tag> getTags() {
+ return tags;
+ }
+
+ public void setTags(Set<Tag> tags) {
+ this.tags = tags;
+ }
+
@Override
public String toString() {
return "BundleVersion[id=" + id + ",name=" + name + ",version=" + version + ",bundle=" + bundle + "]";
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/common/Tag.java b/modules/core/domain/src/main/java/org/rhq/core/domain/common/Tag.java
deleted file mode 100644
index 1cb51e0..0000000
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/common/Tag.java
+++ /dev/null
@@ -1,121 +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.
- */
-package org.rhq.core.domain.common;
-
-import java.io.Serializable;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.SequenceGenerator;
-import javax.persistence.Table;
-
-/**
- * A generic tag that can be associated with domain objects such as
- * Repository, Content Source, Resource, Package etc.
- *
- * @author Sayli Karmarkar
- */
-@Entity
-@SequenceGenerator(name = "SEQ", sequenceName = "RHQ_TAG_ID_SEQ")
-@Table(name = "RHQ_TAG")
-public class Tag implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- @Column(name = "ID", nullable = false)
- @GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ")
- @Id
- private int id;
-
- @Column(name = "NAME", nullable = false)
- private String name;
-
- @Column(name = "DESCRIPTION", nullable = true)
- private String description;
-
- public Tag() {
- }
-
- public int getId() {
- return this.id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- /**
- * String representation of tag
- */
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- /**
- * Description of tag
- */
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- @Override
- public String toString() {
- return "Tag: [name=" + this.name + " , description=" + this.description + "]";
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
-
- if ((o == null) || (!(o instanceof Tag))) {
- return false;
- }
-
- Tag other = (Tag) o;
-
- if (!name.equals(other.name)) {
- return false;
- }
-
- return true;
- }
-
- @Override
- public int hashCode() {
- return name.hashCode();
- }
-
-}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/common/Taggable.java b/modules/core/domain/src/main/java/org/rhq/core/domain/common/Taggable.java
deleted file mode 100644
index 3c831dd..0000000
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/common/Taggable.java
+++ /dev/null
@@ -1,38 +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.
- */
-package org.rhq.core.domain.common;
-
-import java.util.Set;
-
-public interface Taggable {
-
- public Set<Tag> getTags();
-
- public void setTags(Set<Tag> tags);
-
- public boolean hasTag(Tag tag);
-
- public void addTag(Tag tag);
-
- public void removeTag(Tag tag);
-}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/Repo.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/Repo.java
index d934f8d..3d7b11a 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/Repo.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/Repo.java
@@ -48,10 +48,6 @@ import javax.persistence.Table;
import javax.persistence.Transient;
import javax.xml.bind.annotation.XmlTransient;
-import org.jetbrains.annotations.NotNull;
-
-import org.rhq.core.domain.common.Tag;
-import org.rhq.core.domain.common.Taggable;
import org.rhq.core.domain.resource.Resource;
/**
@@ -104,7 +100,7 @@ import org.rhq.core.domain.resource.Resource;
+ " WHERE rcs.repo.id = r.id) ") })
@SequenceGenerator(name = "SEQ", sequenceName = "RHQ_REPO_ID_SEQ")
@Table(name = "RHQ_REPO")
-public class Repo implements Serializable, Taggable {
+public class Repo implements Serializable {
// Constants --------------------------------------------
@@ -169,10 +165,6 @@ public class Repo implements Serializable, Taggable {
private Set<RepoRepoRelationship> repoRepoRelationships;
@XmlTransient
- @OneToMany(mappedBy = "repo", fetch = FetchType.LAZY)
- private Set<RepoTag> repoTags;
-
- @XmlTransient
@OneToMany(mappedBy = "repo", fetch = FetchType.LAZY, cascade = CascadeType.REMOVE)
@OrderBy("startTime DESC")
// latest appears first, oldest last
@@ -759,97 +751,6 @@ public class Repo implements Serializable, Taggable {
this.lastModifiedDate = System.currentTimeMillis();
}
- public Set<RepoTag> getRepoTags() {
- return repoTags;
- }
-
- public void setRepoTags(Set<RepoTag> tags) {
- this.repoTags = tags;
- }
-
- public boolean hasTag(Tag tag) {
- if ((this.repoTags == null) || (tag == null)) {
- return false;
- }
-
- for (RepoTag rt : this.repoTags) {
- if (tag.equals(rt.getRepoTagPK().getTag())) {
- return true;
- }
- }
- return false;
-
- }
-
- /**
- * The tags associated with this repo.
- */
- public Set<Tag> getTags() {
- HashSet<Tag> tags = new HashSet<Tag>();
-
- if (repoTags != null) {
- for (RepoTag rt : repoTags) {
- tags.add(rt.getRepoTagPK().getTag());
- }
- }
-
- return tags;
- }
-
- /**
- * Add a tag association with this repo.
- *
- * @param tag
- */
- public void addTag(Tag tag) {
- if (this.repoTags == null) {
- this.repoTags = new HashSet<RepoTag>();
- }
-
- RepoTag mapping = new RepoTag(this, tag);
- this.repoTags.add(mapping);
- }
-
- /**
- * Set tag associations with this repo.
- *
- * @param tags
- */
- public void setTags(Set<Tag> tags) {
- if (this.repoTags == null) {
- this.repoTags = new HashSet<RepoTag>();
- } else {
- this.repoTags.clear();
- }
-
- for (Tag t : tags) {
- RepoTag mapping = new RepoTag(this, t);
- this.repoTags.add(mapping);
- }
-
- }
-
- /**
- * Removes association with a tag, if it exists.
- */
- public void removeTag(Tag tag) {
- if ((this.repoTags == null) || (tag == null)) {
- return;
- }
-
- RepoTag doomed = null;
-
- for (RepoTag rt : this.repoTags) {
- if (tag.equals(rt.getRepoTagPK().getTag())) {
- doomed = rt;
- break;
- }
- }
-
- if (doomed != null) {
- this.repoTags.remove(doomed);
- }
- }
/**
* Set the sync status for this repo.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/RepoTag.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/RepoTag.java
deleted file mode 100644
index 6c65cc4..0000000
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/RepoTag.java
+++ /dev/null
@@ -1,129 +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.
- */
-package org.rhq.core.domain.content;
-
-import java.io.Serializable;
-
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.IdClass;
-import javax.persistence.JoinColumn;
-import javax.persistence.ManyToOne;
-import javax.persistence.Table;
-
-import org.rhq.core.domain.common.Tag;
-
-/**
- * This is the many-to-many entity that correlates a repo with a tag.
- * It is an explicit relationship mapping entity between {@link Repo}
- * and {@link Tag}.
- *
- * @author Sayli Karmarkar
- */
-
-@Entity
-(a)IdClass(RepoTagPK.class)
-@Table(name = "RHQ_REPO_TAG_MAP")
-public class RepoTag implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- /*
- * http://opensource.atlassian.com/projects/hibernate/browse/EJB-286 Hibernate seems to want these mappings in the
- * @IdClass and ignore these here, even though the mappings should be here and no mappings should be needed in the
- * @IdClass.
- */
- @Id
- @ManyToOne
- @JoinColumn(name = "REPO_ID", referencedColumnName = "ID", nullable = false, insertable = false, updatable = false)
- private Repo repo;
-
- @Id
- @ManyToOne
- @JoinColumn(name = "TAG_ID", referencedColumnName = "ID", nullable = false, insertable = false, updatable = false)
- private Tag tag;
-
- protected RepoTag() {
- }
-
- public RepoTag(Repo repo, Tag tag) {
- this.repo = repo;
- this.tag = tag;
- }
-
- public RepoTagPK getRepoTagPK() {
- return new RepoTagPK(repo, tag);
- }
-
- public void setRepoTagPK(RepoTagPK pk) {
- this.repo = pk.getRepo();
- this.tag = pk.getTag();
- }
-
- @Override
- public String toString() {
- StringBuilder str = new StringBuilder("RepoTag: ");
- str.append(", rp=[").append(this.repo).append("]");
- str.append(", tg=[").append(this.tag).append("]");
- return str.toString();
- }
-
- @Override
- public int hashCode() {
- int result = 1;
- result = (31 * result) + ((repo == null) ? 0 : repo.hashCode());
- result = (31 * result) + ((tag == null) ? 0 : tag.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if ((obj == null) || (!(obj instanceof RepoTag))) {
- return false;
- }
-
- final RepoTag other = (RepoTag) obj;
-
- if (repo == null) {
- if (repo != null) {
- return false;
- }
- } else if (!repo.equals(other.repo)) {
- return false;
- }
-
- if (tag == null) {
- if (tag != null) {
- return false;
- }
- } else if (!tag.equals(other.tag)) {
- return false;
- }
-
- return true;
- }
-}
\ No newline at end of file
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/RepoTagPK.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/RepoTagPK.java
deleted file mode 100644
index 7ac8dad..0000000
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/RepoTagPK.java
+++ /dev/null
@@ -1,122 +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.
- */
-package org.rhq.core.domain.content;
-
-import java.io.Serializable;
-
-import javax.persistence.JoinColumn;
-import javax.persistence.ManyToOne;
-
-import org.rhq.core.domain.common.Tag;
-
-/**
- * This is the composite primary key for the {@link RepoTag} entity. That entity is an explicit
- * many-to-many mapping table, so this composite key is simply the foreign keys to both ends of that relationship.
- *
- * @author Sayli Karmarkar
- */
-public class RepoTagPK implements Serializable {
- private static final long serialVersionUID = 1L;
-
- /*
- * http://opensource.atlassian.com/projects/hibernate/browse/EJB-286 Hibernate seems to want these mappings here,
- * even though this class is an @IdClass and it should not need the mappings here. The mappings belong in the
- * entity itself.
- */
-
- @JoinColumn(name = "REPO_ID", referencedColumnName = "ID", nullable = false)
- @ManyToOne
- private Repo repo;
-
- @JoinColumn(name = "TAG_ID", referencedColumnName = "ID", nullable = false)
- @ManyToOne
- private Tag tag;
-
- public RepoTagPK() {
- }
-
- public RepoTagPK(Repo repo, Tag tag) {
- this.repo = repo;
- this.tag = tag;
- }
-
- public Repo getRepo() {
- return repo;
- }
-
- public void setRepo(Repo repo) {
- this.repo = repo;
- }
-
- public Tag getTag() {
- return tag;
- }
-
- public void setTag(Tag tag) {
- this.tag = tag;
- }
-
- @Override
- public String toString() {
- return "RepoTagPK: repo=[" + repo + "]; tag=[" + tag + "]";
- }
-
- @Override
- public int hashCode() {
- int result = 1;
- result = (31 * result) + ((repo == null) ? 0 : repo.hashCode());
- result = (31 * result) + ((tag == null) ? 0 : tag.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if ((obj == null) || (!(obj instanceof RepoTagPK))) {
- return false;
- }
-
- final RepoTagPK other = (RepoTagPK) obj;
-
- if (repo == null) {
- if (other.repo != null) {
- return false;
- }
- } else if (!repo.equals(other.repo)) {
- return false;
- }
-
- if (tag == null) {
- if (other.tag != null) {
- return false;
- }
- } else if (!tag.equals(other.tag)) {
- return false;
- }
-
- return true;
- }
-}
\ No newline at end of file
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java
index ef94154..d77e1bf 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java
@@ -75,6 +75,7 @@ import org.rhq.core.domain.measurement.MeasurementSchedule;
import org.rhq.core.domain.measurement.ResourceAvailability;
import org.rhq.core.domain.operation.ResourceOperationHistory;
import org.rhq.core.domain.resource.group.ResourceGroup;
+import org.rhq.core.domain.tagging.Tag;
import org.rhq.core.domain.util.Summary;
/**
@@ -868,7 +869,7 @@ public class Resource implements Comparable<Resource>, Serializable {
private static final int UUID_LENGTH = 36;
/**
- * Helper for {@link #NATIVE_QUERY_FIND_MBIGUATION_LEVEL}.
+ * Helper for {@link #NATIVE_QUERY_FIND_DISAMBIGUATION_LEVEL}.
* We need to guard against concatenation with a NULL value which
* would yield a NULL result. We don't want that in that query, otherwise
* we'd get skewed results for combination of resources on different
@@ -1113,6 +1114,10 @@ public class Resource implements Comparable<Resource>, Serializable {
// @OneToMany(mappedBy = "resource", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
// private List<BundleResourceDeployment> resourceDeployments = new ArrayList<BundleResourceDeployment>();
+
+ @ManyToMany(mappedBy = "resources", fetch = FetchType.LAZY)
+ private Set<Tag> tags;
+
public Resource() {
}
@@ -1688,6 +1693,14 @@ public class Resource implements Comparable<Resource>, Serializable {
this.productVersion = productVersion;
}
+ public Set<Tag> getTags() {
+ return tags;
+ }
+
+ public void setTags(Set<Tag> tags) {
+ this.tags = tags;
+ }
+
public int compareTo(Resource that) {
return this.name.compareTo(that.getName());
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ResourceGroup.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ResourceGroup.java
index 6b25793..35804c8 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ResourceGroup.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ResourceGroup.java
@@ -33,6 +33,7 @@ import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
+import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
@@ -60,6 +61,7 @@ import org.rhq.core.domain.configuration.group.AbstractGroupConfigurationUpdate;
import org.rhq.core.domain.operation.GroupOperationHistory;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.domain.tagging.Tag;
/**
* A {@link Group} that contains {@link Resource}s. It cannot contain other groups.
@@ -446,6 +448,10 @@ public class ResourceGroup extends Group {
@OneToMany(mappedBy = "resourceGroup", cascade = { CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH })
private Set<AlertDefinition> alertDefinitions = new LinkedHashSet<AlertDefinition>();
+ @ManyToMany(mappedBy = "resourceGroups", fetch = FetchType.LAZY)
+ private Set<Tag> tags;
+
+
/* no-arg constructor required by EJB spec */
protected ResourceGroup() {
}
@@ -643,6 +649,14 @@ public class ResourceGroup extends Group {
this.alertDefinitions = alertDefinitions;
}
+ public Set<Tag> getTags() {
+ return tags;
+ }
+
+ public void setTags(Set<Tag> tags) {
+ this.tags = tags;
+ }
+
@PrePersist
@PreUpdate
void onPersist() {
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/tagging/Tag.java b/modules/core/domain/src/main/java/org/rhq/core/domain/tagging/Tag.java
new file mode 100644
index 0000000..3749413
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/tagging/Tag.java
@@ -0,0 +1,177 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.domain.tagging;
+
+import java.io.Serializable;
+import java.util.Set;
+
+import javax.persistence.Column;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.JoinTable;
+import javax.persistence.ManyToMany;
+import javax.persistence.SequenceGenerator;
+import javax.persistence.Table;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+
+import org.rhq.core.domain.bundle.Bundle;
+import org.rhq.core.domain.bundle.BundleDeployment;
+import org.rhq.core.domain.bundle.BundleVersion;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.group.ResourceGroup;
+
+
+/**
+ * @author Greg Hinkle
+ */
+@SequenceGenerator(name = "id", sequenceName = "RHQ_TAGGING_ID_SEQ")
+@Table(name = "RHQ_TAGGING")
+(a)XmlAccessorType(XmlAccessType.FIELD)
+public class Tag implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+
+ @Column(name = "ID", nullable = false)
+ @GeneratedValue(strategy = GenerationType.AUTO, generator = "RHQ_TAGGING_ID_SEQ")
+ @Id
+ private int id;
+
+
+ @Column(name = "NAMESPACE", nullable = true)
+ private String namespace;
+
+ @Column(name = "SEMANTIC", nullable = true)
+ private String semantic;
+
+ @Column(name = "NAME", nullable = false)
+ private String name;
+
+ @JoinTable(name = "RHQ_TAGGING_RESOURCE_MAP", joinColumns = { @JoinColumn(name = "TAG_ID") }, inverseJoinColumns = { @JoinColumn(name = "RESOURCE_ID") })
+ @ManyToMany
+ private Set<Resource> resources;
+
+
+ @JoinTable(name = "RHQ_TAGGING_RES_GRP_MAP", joinColumns = { @JoinColumn(name = "TAG_ID") }, inverseJoinColumns = { @JoinColumn(name = "RESOURCE_GROUP_ID") })
+ @ManyToMany
+ private Set<ResourceGroup> resourceGroups;
+
+ @JoinTable(name = "RHQ_TAGGING_BUNDLE_MAP", joinColumns = { @JoinColumn(name = "TAG_ID") }, inverseJoinColumns = { @JoinColumn(name = "BUNDLE_ID") })
+ @ManyToMany
+ private Set<Bundle> bundles;
+
+ @JoinTable(name = "RHQ_TAGGING_BND_VER_MAP", joinColumns = { @JoinColumn(name = "TAG_ID") }, inverseJoinColumns = { @JoinColumn(name = "BUNDLE_VERSION_ID") })
+ @ManyToMany
+ private Set<BundleVersion> bundleVersions;
+
+
+ @JoinTable(name = "RHQ_TAGGING_BND_DEP_MAP", joinColumns = { @JoinColumn(name = "TAG_ID") }, inverseJoinColumns = { @JoinColumn(name = "BUNDLE_DEPLOYMENT_ID") })
+ @ManyToMany
+ private Set<BundleDeployment> bundleDeployments;
+
+
+ protected Tag() {
+ }
+
+
+ public Tag(String namespace, String semantic, String name) {
+ this.namespace = namespace;
+ this.semantic = semantic;
+ this.name = name;
+ }
+
+ public Tag(String tag) {
+ // Tag format (namespace:)(semantic=)name
+ if (tag.contains(":")) {
+ namespace = tag.split(":")[0];
+ tag = tag.split(":")[1];
+ }
+ if (tag.contains("=")) {
+ semantic = tag.split("=")[0];
+ tag = tag.split("=")[1];
+ }
+ name = tag;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public String getNamespace() {
+ return namespace;
+ }
+
+ public void setNamespace(String namespace) {
+ this.namespace = namespace;
+ }
+
+ public String getSemantic() {
+ return semantic;
+ }
+
+ public void setSemantic(String semantic) {
+ this.semantic = semantic;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+
+ @Override
+ public String toString() {
+ return (namespace != null ? namespace + ":" : "") +
+ (semantic != null ? semantic + "=" : "") +
+ name;
+ }
+
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ Tag tag = (Tag) o;
+
+ if (!name.equals(tag.name)) return false;
+ if (namespace != null ? !namespace.equals(tag.namespace) : tag.namespace != null) return false;
+ if (semantic != null ? !semantic.equals(tag.semantic) : tag.semantic != null) return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = namespace != null ? namespace.hashCode() : 0;
+ result = 31 * result + (semantic != null ? semantic.hashCode() : 0);
+ result = 31 * result + name.hashCode();
+ return result;
+ }
+}
commit 4f1652c1684f0e7dd72696aff613b1f216448e11
Author: Greg Hinkle <ghinkle(a)redhat.com>
Date: Wed Apr 7 22:36:09 2010 -0400
Some UI work... new components, alert investigation work
avail display, etc.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml
index 613a4bc..51dcca6 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml
@@ -57,5 +57,6 @@
<servlet path="/BundleGWTService" class="org.rhq.enterprise.gui.coregui.server.gwt.BundleGWTServiceImpl"/>
<servlet path="/ResourceBossGWTService" class="org.rhq.enterprise.gui.coregui.server.gwt.ResourceBossGWTServiceImpl"/>
<servlet path="/AuthorizationGWTService" class="org.rhq.enterprise.gui.coregui.server.gwt.AuthorizationGWTServiceImpl"/>
+ <servlet path="/AvailabilityGWTService" class="org.rhq.enterprise.gui.coregui.server.gwt.AvailabilityGWTServiceImpl"/>
</module>
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AlertDefinitionsView.java
index 8f0ea70..d3ae574 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AlertDefinitionsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AlertDefinitionsView.java
@@ -19,10 +19,13 @@
package org.rhq.enterprise.gui.coregui.client.alert.definitions;
import com.smartgwt.client.data.Criteria;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
import com.smartgwt.client.widgets.layout.VLayout;
import org.rhq.core.domain.resource.Resource;
import org.rhq.enterprise.gui.coregui.client.components.table.Table;
+import org.rhq.enterprise.gui.coregui.client.components.table.TableAction;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.alert.AlertEditView;
/**
* @author Greg Hinkle
@@ -47,6 +50,13 @@ public class AlertDefinitionsView extends VLayout {
table.setDataSource(new AlertDefinitionsDataSource());
table.getListGrid().setUseAllDataSourceFields(true);
+
+ table.addTableAction("New", new TableAction() {
+ public void executeAction(ListGridRecord[] selection) {
+ new AlertEditView().displayAsDialog();
+ }
+ });
+
addMember(table);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/RadioGroupWithComponentsItem.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/RadioGroupWithComponentsItem.java
new file mode 100644
index 0000000..e9942bb
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/RadioGroupWithComponentsItem.java
@@ -0,0 +1,131 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.coregui.client.components.form;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.Window;
+import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.ValuesManager;
+import com.smartgwt.client.widgets.form.events.ItemChangedEvent;
+import com.smartgwt.client.widgets.form.events.ItemChangedHandler;
+import com.smartgwt.client.widgets.form.fields.CanvasItem;
+import com.smartgwt.client.widgets.form.fields.FormItem;
+import com.smartgwt.client.widgets.form.fields.RadioGroupItem;
+import com.smartgwt.client.widgets.form.fields.SelectItem;
+import com.smartgwt.client.widgets.form.fields.SpacerItem;
+import com.smartgwt.client.widgets.form.fields.TextItem;
+import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
+import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
+
+/**
+ * @author Greg Hinkle
+ */
+public class RadioGroupWithComponentsItem extends CanvasItem {
+
+ LinkedHashMap valueMap = new LinkedHashMap();
+ RGWCCanvas canvas;
+
+ DynamicForm form;
+
+ public RadioGroupWithComponentsItem(String name, String title, LinkedHashMap valueMap, DynamicForm form) {
+ super(name, title);
+ this.valueMap = valueMap;
+ this.form = form;
+ canvas = new RGWCCanvas();
+ setCanvas(canvas);
+ }
+
+
+ public class RGWCCanvas extends DynamicForm {
+
+ public RGWCCanvas() {
+ setNumCols(3);
+ }
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+
+ ArrayList<FormItem> items = new ArrayList<FormItem>();
+
+ for (final Object key : valueMap.keySet()) {
+
+ final String label = (String) key;
+
+ RadioGroupItem button = new RadioGroupItem(getName(), label);
+ button.setShowTitle(false);
+ button.setStartRow(true);
+ button.setValueMap(label);
+
+ items.add(button);
+
+
+
+ Object value = valueMap.get(key);
+ if (value instanceof Canvas) {
+ CanvasItem ci = new CanvasItem();
+ ci.setShowTitle(false);
+ ci.setCanvas((Canvas) value);
+ items.add(ci);
+ }
+
+ button.addChangedHandler(new ChangedHandler() {
+ public void onChanged(ChangedEvent changedEvent) {
+ form.setValue(getName(), label);
+ updateEnablement();
+ }
+ });
+ }
+ setItems(items.toArray(new FormItem[items.size()]));
+
+
+
+ addItemChangedHandler(new ItemChangedHandler() {
+ public void onItemChanged(ItemChangedEvent changedEvent) {
+ if (getName().equals(changedEvent.getItem().getName())) {
+ updateEnablement();
+ }
+ }
+ });
+ }
+
+ public void updateEnablement() {
+ String formValue = form.getValueAsString(getName());
+ for (Object key : valueMap.keySet()) {
+ Object value = valueMap.get(key);
+ if (value != null && value instanceof DynamicForm) {
+ for (FormItem item : ((DynamicForm)value).getFields()) {
+ item.setDisabled(!formValue.equals(key));
+
+ }
+
+// ((DynamicForm) value).setDisabled(!formValue.equals(key));
+ }
+ }
+ }
+ }
+
+
+
+
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
index e56c48f..3481775 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
@@ -49,6 +49,7 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
* @author Ian Springer
*/
public class Table extends VLayout {
+
private static final SelectionEnablement DEFAULT_SELECTION_ENABLEMENT = SelectionEnablement.ALWAYS;
private HTMLFlow title;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java
index 35c75be..2125a39 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java
@@ -41,37 +41,50 @@ import org.rhq.enterprise.gui.coregui.client.inventory.summary.SummaryCountsView
*/
public class DashboardView extends VLayout {
- private static String[] colors = new String[]{
- "FF6600", "808000", "008000", "008080", "0000FF", "666699",
- "FF0000", "FF9900", "99CC00", "339966", "33CCCC", "3366FF",
- "800080", "969696", "FF00FF", "FFCC00", "FFFF00", "00FF00",
- "00FFFF", "00CCFF", "993366", "C0C0C0", "FF99CC", "FFCC99",
- "FFFF99", "CCFFCC", "CCFFFF", "99CCFF", "CC99FF", "FFFFFF"
- };
+
+ boolean editMode = false;
+
+ PortalLayout portalLayout;
+ DynamicForm form;
+ ButtonItem addPortlet;
public DashboardView() {
setOverflow(Overflow.AUTO);
setPadding(5);
}
- public void onInit() {
+ public void redraw() {
+ for (Canvas c : getChildren()) {
+ c.destroy();
+ }
+
+ buildPortlets();
+ }
+
+ @Override
+ protected void onDraw() {
+ super.onDraw();
+ buildPortlets();
+ }
+
+ public void buildPortlets() {
setWidth100();
setHeight100();
- final PortalLayout portalLayout = new PortalLayout(2);
+ portalLayout = new PortalLayout(2);
portalLayout.setWidth100();
portalLayout.setHeight100();
- Portlet summaryPortlet = new Portlet();
+ Portlet summaryPortlet = new Portlet(editMode);
summaryPortlet.setTitle("Inventory Summary");
summaryPortlet.addItem(new SummaryCountsView());
summaryPortlet.setHeight(300);
portalLayout.addPortlet(summaryPortlet);
- Portlet adPortlet = new Portlet();
+ Portlet adPortlet = new Portlet(editMode);
adPortlet.setTitle("Auto Discovery Queue");
adPortlet.addItem(new ResourceAutodiscoveryView(true));
adPortlet.setHeight(250);
@@ -80,7 +93,7 @@ public class DashboardView extends VLayout {
// create portlets...
for (int i = 1; i <= 2; i++) {
- Portlet portlet = new Portlet();
+ Portlet portlet = new Portlet(editMode);
portlet.setTitle("Portlet");
// Label label = new Label();
@@ -96,15 +109,15 @@ public class DashboardView extends VLayout {
final VLayout vLayout = new VLayout(15);
- final DynamicForm form = new DynamicForm();
+ form = new DynamicForm();
form.setAutoWidth();
- form.setNumCols(5);
+ form.setNumCols(7);
final StaticTextItem numColItem = new StaticTextItem();
numColItem.setTitle("Columns");
numColItem.setValue(portalLayout.getMembers().length);
- ButtonItem addColumn = new ButtonItem("addColun", "Add Column");
+ ButtonItem addColumn = new ButtonItem("addColumn", "Add Column");
// addColumn.setIcon("silk/application_side_expand.png");
addColumn.setAutoFit(true);
addColumn.setStartRow(false);
@@ -140,7 +153,19 @@ public class DashboardView extends VLayout {
}
});
- final ButtonItem addPortlet = new ButtonItem("addPortlet", "Add Portlet");
+
+ final ButtonItem editButton = new ButtonItem("editable", editMode ? "View Mode" : "Edit Mode");
+ editButton.setAutoFit(true);
+ editButton.setStartRow(false);
+ editButton.setEndRow(false);
+ editButton.addClickHandler(new com.smartgwt.client.widgets.form.fields.events.ClickHandler() {
+ public void onClick(com.smartgwt.client.widgets.form.fields.events.ClickEvent clickEvent) {
+ editMode = !editMode;
+ redraw();
+ }
+ });
+
+ addPortlet = new ButtonItem("addPortlet", "Add Portlet");
addPortlet.setIcon("[skin]/images/actions/add.png");
addPortlet.setAutoFit(true);
@@ -149,7 +174,25 @@ public class DashboardView extends VLayout {
addPortlet.addClickHandler(new com.smartgwt.client.widgets.form.fields.events.ClickHandler() {
public void onClick(com.smartgwt.client.widgets.form.fields.events.ClickEvent event) {
- final Portlet newPortlet = new Portlet();
+ addPortlet();
+
+ }
+ });
+
+
+ if (editMode) {
+ form.setItems(numColItem, addPortlet, addColumn, removeColumn, editButton);
+ } else {
+ form.setItems(editButton);
+ }
+ addMember(form);
+ addMember(portalLayout);
+
+ }
+
+
+ private void addPortlet() {
+ final Portlet newPortlet = new Portlet(true);
newPortlet.setTitle("Portlet ");
// Label label = new Label();
@@ -211,14 +254,5 @@ public class DashboardView extends VLayout {
newPortlet.show();
}
}, 750);
- }
- });
-
-
- form.setItems(numColItem, addPortlet, addColumn, removeColumn);
-
- addMember(form);
- addMember(portalLayout);
-
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortalColumn.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortalColumn.java
index 18f729d..3eaf969 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortalColumn.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortalColumn.java
@@ -42,13 +42,13 @@ public class PortalColumn extends VStack {
setDropLineThickness(4);
Canvas dropLineProperties = new Canvas();
- dropLineProperties.setBackgroundColor("aqua");
+ dropLineProperties.setBackgroundColor("#4A5D75");
setDropLineProperties(dropLineProperties);
setShowDragPlaceHolder(true);
Canvas placeHolderProperties = new Canvas();
- placeHolderProperties.setBorder("2px solid 8289A6");
+ placeHolderProperties.setBorder("2px solid 4A5D75");
setPlaceHolderProperties(placeHolderProperties);
}
}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/Portlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/Portlet.java
index c0ec225..4fe028c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/Portlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/Portlet.java
@@ -52,39 +52,46 @@ public class Portlet extends Window {
}
};
- public Portlet() {
+ public Portlet(boolean showFrame) {
+
+ if (!showFrame) {
+ setShowHeader(false);
+ setShowEdges(false);
+ } else {
+ // customize the appearance and order of the controls in the window header
+ setHeaderControls(
+ HeaderControls.MINIMIZE_BUTTON,
+ HeaderControls.HEADER_LABEL,
+ new HeaderControl(HeaderControl.SETTINGS, settingsHandler),
+ new HeaderControl(HeaderControl.HELP, helpHandler),
+ HeaderControls.CLOSE_BUTTON
+ );
+
+ // show either a shadow, or translucency, when dragging a portlet
+ // (could do both at the same time, but these are not visually compatible effects)
+ // setShowDragShadow(true);
+ setDragOpacity(30);
+
+ // enable predefined component animation
+ setAnimateMinimize(true);
+
+ // Window is draggable with "outline" appearance by default.
+ // "target" is the solid appearance.
+ setDragAppearance(DragAppearance.TARGET);
+ setCanDrop(true);
+
+ setCanDragResize(true);
+ setResizeFrom("B");
- setShowShadow(false);
-
- // enable predefined component animation
- setAnimateMinimize(true);
-
- // Window is draggable with "outline" appearance by default.
- // "target" is the solid appearance.
- setDragAppearance(DragAppearance.OUTLINE);
- setCanDrop(true);
-
- // customize the appearance and order of the controls in the window header
- setHeaderControls(
- HeaderControls.MINIMIZE_BUTTON,
- HeaderControls.HEADER_LABEL,
- new HeaderControl(HeaderControl.SETTINGS, settingsHandler),
- new HeaderControl(HeaderControl.HELP, helpHandler),
- HeaderControls.CLOSE_BUTTON
- );
+ }
- // show either a shadow, or translucency, when dragging a portlet
- // (could do both at the same time, but these are not visually compatible effects)
- // setShowDragShadow(true);
- setDragOpacity(30);
+ setShowShadow(false);
// these settings enable the portlet to autosize its height only to fit its contents
// (since width is determined from the containing layout, not the portlet contents)
// setVPolicy(LayoutPolicy.NONE);
setOverflow(Overflow.VISIBLE);
- setCanDragResize(true);
- setResizeFrom("B");
}
public void setSettingsClickHandler(ClickHandler handler) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AvailabilityGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AvailabilityGWTService.java
new file mode 100644
index 0000000..fcb5a29
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AvailabilityGWTService.java
@@ -0,0 +1,36 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.coregui.client.gwt;
+
+import com.google.gwt.user.client.rpc.RemoteService;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.measurement.Availability;
+import org.rhq.core.domain.util.PageControl;
+import org.rhq.core.domain.util.PageList;
+
+/**
+ * @author Greg Hinkle
+ */
+public interface AvailabilityGWTService extends RemoteService {
+
+
+ PageList<Availability> findAvailabilityForResource(int resourceId, PageControl pc);
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java
index 84dbd42..d887f8c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java
@@ -84,6 +84,9 @@ public class GWTServiceLookup {
return secure(AuthorizationGWTServiceAsync.Util.getInstance());
}
+ public static AvailabilityGWTServiceAsync getAvailabilityService() {
+ return secure(AvailabilityGWTServiceAsync.Util.getInstance());
+ }
private static <T> T secure(Object sdt) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTitleBar.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTitleBar.java
index 4c9206e..426d84e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTitleBar.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTitleBar.java
@@ -42,6 +42,8 @@ public class ResourceTitleBar extends HLayout {
private static final String NOT_FAV_ICON = "Favorite_24.png";
private Resource resource;
+
+ private Img badge;
private Img favoriteButton;
private HTMLFlow title;
private Img availabilityImage;
@@ -51,6 +53,7 @@ public class ResourceTitleBar extends HLayout {
super();
setWidth100();
setHeight(30);
+ setPadding(5);
}
@Override
@@ -71,6 +74,9 @@ public class ResourceTitleBar extends HLayout {
}
});
+ badge = new Img("types/Service_up_24.png", 24, 24);
+
+ addMember(badge);
addMember(title);
addMember(availabilityImage);
addMember(favoriteButton);
@@ -79,7 +85,7 @@ public class ResourceTitleBar extends HLayout {
public void setResource(Resource resource) {
this.resource = resource;
- this.title.setContents("<h2>" + resource.getName() + "</h2>");
+ this.title.setContents("<span class=\"SectionHeader\">" + resource.getName() + "</span> <span class=\"subtitle\">" + resource.getResourceType().getName() + "</span>");
Set<Integer> favorites = CoreGUI.getUserPreferences().getFavoriteResources();
this.favorite = favorites.contains(resource.getId());
@@ -88,6 +94,11 @@ public class ResourceTitleBar extends HLayout {
this.availabilityImage.setSrc("resources/availability_" +
(resource.getCurrentAvailability().getAvailabilityType() == AvailabilityType.UP ? "green" : "red") +
"_24.png");
+
+ String category = this.resource.getResourceType().getCategory().getDisplayName();
+ String avail = resource.getCurrentAvailability().getAvailabilityType().name().toLowerCase();
+ badge.setSrc("types/" + category + "_" + avail + "_24.png");
+
markForRedraw();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/alert/AlertEditOldStyleView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/alert/AlertEditOldStyleView.java
new file mode 100644
index 0000000..74f8f17
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/alert/AlertEditOldStyleView.java
@@ -0,0 +1,206 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.coregui.client.inventory.resource.detail.alert;
+
+import java.util.LinkedHashMap;
+
+import com.smartgwt.client.widgets.Window;
+import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.ValuesManager;
+import com.smartgwt.client.widgets.form.fields.HeaderItem;
+import com.smartgwt.client.widgets.form.fields.RadioGroupItem;
+import com.smartgwt.client.widgets.form.fields.SelectItem;
+import com.smartgwt.client.widgets.form.fields.SpacerItem;
+import com.smartgwt.client.widgets.form.fields.TextAreaItem;
+import com.smartgwt.client.widgets.form.fields.TextItem;
+import com.smartgwt.client.widgets.layout.VLayout;
+
+import org.rhq.core.domain.alert.AlertPriority;
+import org.rhq.enterprise.gui.coregui.client.components.form.RadioGroupWithComponentsItem;
+
+/**
+ * @author Greg Hinkle
+ */
+public class AlertEditOldStyleView extends VLayout {
+
+ public AlertEditOldStyleView() {
+ setWidth100();
+ }
+
+
+ public void displayAsDialog() {
+ Window window = new Window();
+ window.setTitle("Alert Editor");
+ window.setWidth(800);
+ window.setHeight(800);
+ window.setIsModal(true);
+ window.setShowModalMask(true);
+ window.setCanDragResize(true);
+ window.centerInPage();
+ window.addItem(this);
+ window.show();
+ }
+
+
+ @Override
+ protected void onDraw() {
+ super.onDraw();
+
+ addMember(buildEditForm());
+
+
+ }
+
+
+ public DynamicForm buildEditForm() {
+
+ ValuesManager vm = new ValuesManager();
+ DynamicForm form = new DynamicForm();
+ form.setTitleSuffix("");
+ form.setValuesManager(vm);
+
+ HeaderItem alertPropertiesHeader = new HeaderItem();
+ alertPropertiesHeader.setValue("Alert Properties");
+
+ TextItem alertName = new TextItem("alertName", "Name");
+ alertName.setRequired(true);
+
+ TextAreaItem description = new TextAreaItem("alertDescription", "Description");
+
+ SelectItem priority = new SelectItem("alertPriority", "Priority");
+ LinkedHashMap<String, String> valueMap = new LinkedHashMap<String, String>();
+ valueMap.put(AlertPriority.LOW.name(), "Low");
+ valueMap.put(AlertPriority.MEDIUM.name(), "Medium");
+ valueMap.put(AlertPriority.HIGH.name(), "High");
+ priority.setValueMap(valueMap);
+ priority.setImageURLPrefix("alerts/Alert_");
+ priority.setImageURLSuffix("_16.png");
+ priority.setValue("LOW");
+
+
+
+ RadioGroupItem active = new RadioGroupItem("alertActive","Active");
+ active.setValueMap("Yes","No");
+ active.setValue("Yes");
+
+
+
+ HeaderItem conditionsHeader = new HeaderItem();
+ conditionsHeader.setValue("Alert Conditions");
+
+ LinkedHashMap valuesMap = new LinkedHashMap();
+
+ valuesMap.put("Metric", buildMetricSectionCavans(vm));
+
+ valuesMap.put("InventoryProperty", buildInventoryPropertySectionCavans(vm));
+ valuesMap.put("Event", "Events");
+ valuesMap.put("Configuration", "Configuration Change");
+
+
+ RadioGroupWithComponentsItem conditionGroup = new RadioGroupWithComponentsItem("radioTest", "Test", valuesMap, form);
+
+
+
+
+ form.setItems(alertPropertiesHeader, alertName, description, priority, active, conditionsHeader, conditionGroup);
+
+
+ return form;
+
+ }
+
+ private DynamicForm buildMetricSectionCavans(ValuesManager vm) {
+
+ DynamicForm form = new DynamicForm();
+ form.setTitleSuffix("");
+ form.setColWidths("10%");
+ form.setValuesManager(vm);
+
+
+ SelectItem metricSelect = new SelectItem("metric", "Metric");
+ metricSelect.setRequired(true);
+ metricSelect.setEmptyDisplayValue("Select...");
+ metricSelect.setValueMap("CPU Usage", "Free Memory", "Swap Used", "User CPU", "System CPU");
+
+
+ LinkedHashMap valueMap = new LinkedHashMap();
+
+
+ DynamicForm subForm1 = new DynamicForm();
+ subForm1.setTitleSuffix("");
+ subForm1.setValuesManager(vm);
+ subForm1.setNumCols(6);
+ SelectItem metricConditionComparison = new SelectItem("metricConditionKind", "is");
+ metricConditionComparison.setValueMap("> (greater than)", "= (equals)", "< (less than)");
+
+ TextItem metricConditionValue = new TextItem("metricConditionValue");
+ metricConditionValue.setShowTitle(false);
+ metricConditionValue.setHint("Absolute Value");
+
+ subForm1.setItems(metricConditionComparison, metricConditionValue);
+
+ valueMap.put("Value", subForm1);
+
+
+ DynamicForm subForm2 = new DynamicForm();
+ subForm2.setTitleSuffix("");
+ subForm2.setValuesManager(vm);
+ subForm2.setNumCols(8);
+ SelectItem baselineConditionComparison = new SelectItem("baselineConditionKind", "is");
+ baselineConditionComparison.setValueMap("> (greater than)", "= (equals)", "< (less than)");
+
+ TextItem baselineConditionValue = new TextItem("baselineConditionValue");
+ baselineConditionValue.setShowTitle(false);
+ baselineConditionValue.setHint("%");
+
+ SelectItem baselineRange = new SelectItem("baselineRange", "of");
+ baselineRange.setValueMap("25 MB (min value)", "78 MB (avg value)", "322 MB (Max Value)");
+
+ subForm2.setItems(baselineConditionComparison, baselineConditionValue, baselineRange);
+
+
+ valueMap.put("Baseline", subForm2);
+
+
+ valueMap.put("valueChanges", "Value Changes");
+
+
+ RadioGroupWithComponentsItem metricConditionType = new RadioGroupWithComponentsItem("metricConditionType", null, valueMap, form);
+ metricConditionType.setShowTitle(false);
+
+ form.setItems(metricSelect, new SpacerItem(), metricConditionType);
+ return form;
+ }
+
+
+ private DynamicForm buildInventoryPropertySectionCavans(ValuesManager vm) {
+ DynamicForm form = new DynamicForm();
+ form.setValuesManager(vm);
+
+
+ SelectItem inventoryProperty = new SelectItem("inventoryPropert", "Inventory Property");
+ inventoryProperty.setValueMap("OS Version", "Architecture", "Vendor", "RAM", "CPU Speed");
+ inventoryProperty.setHint("value changes");
+
+ form.setItems(inventoryProperty);
+
+
+ return form;
+ }
+}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/alert/AlertEditView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/alert/AlertEditView.java
new file mode 100644
index 0000000..4bc4a03
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/alert/AlertEditView.java
@@ -0,0 +1,302 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.coregui.client.inventory.resource.detail.alert;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.Window;
+import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.ValuesManager;
+import com.smartgwt.client.widgets.form.fields.BlurbItem;
+import com.smartgwt.client.widgets.form.fields.CanvasItem;
+import com.smartgwt.client.widgets.form.fields.FormItem;
+import com.smartgwt.client.widgets.form.fields.HeaderItem;
+import com.smartgwt.client.widgets.form.fields.RadioGroupItem;
+import com.smartgwt.client.widgets.form.fields.SelectItem;
+import com.smartgwt.client.widgets.form.fields.SpacerItem;
+import com.smartgwt.client.widgets.form.fields.TextAreaItem;
+import com.smartgwt.client.widgets.form.fields.TextItem;
+import com.smartgwt.client.widgets.form.fields.events.ClickEvent;
+import com.smartgwt.client.widgets.form.fields.events.ClickHandler;
+import com.smartgwt.client.widgets.layout.VLayout;
+
+import org.rhq.core.domain.alert.AlertConditionCategory;
+import org.rhq.core.domain.alert.AlertPriority;
+import org.rhq.enterprise.gui.coregui.client.components.form.RadioGroupWithComponentsItem;
+
+/**
+ * @author Greg Hinkle
+ */
+public class AlertEditView extends VLayout {
+
+ public AlertEditView() {
+ setWidth100();
+ }
+
+
+ public void displayAsDialog() {
+ Window window = new Window();
+ window.setTitle("Alert Editor");
+ window.setWidth(800);
+ window.setHeight(800);
+ window.setIsModal(true);
+ window.setShowModalMask(true);
+ window.setCanDragResize(true);
+ window.centerInPage();
+ window.addItem(this);
+ window.show();
+ }
+
+
+ @Override
+ protected void onDraw() {
+ super.onDraw();
+
+ addMember(buildEditForm());
+
+
+ }
+
+
+ public DynamicForm buildEditForm() {
+
+ ValuesManager vm = new ValuesManager();
+ DynamicForm form = new DynamicForm();
+ form.setNumCols(4);
+ form.setTitleSuffix("");
+ form.setValuesManager(vm);
+
+ HeaderItem alertPropertiesHeader = new HeaderItem();
+ alertPropertiesHeader.setValue("Alert Properties");
+
+ TextItem alertName = new TextItem("alertName", "Name");
+ alertName.setRequired(true);
+
+ TextAreaItem description = new TextAreaItem("alertDescription", "Description");
+
+ SelectItem priority = new SelectItem("alertPriority", "Priority");
+ LinkedHashMap<String, String> valueMap = new LinkedHashMap<String, String>();
+ valueMap.put(AlertPriority.LOW.name(), "Low");
+ valueMap.put(AlertPriority.MEDIUM.name(), "Medium");
+ valueMap.put(AlertPriority.HIGH.name(), "High");
+ priority.setValueMap(valueMap);
+
+ LinkedHashMap<String, String> iconMap = new LinkedHashMap<String, String>();
+ iconMap.put(AlertPriority.LOW.name(), AlertPriority.LOW.name());
+ iconMap.put(AlertPriority.MEDIUM.name(), AlertPriority.MEDIUM.name());
+ iconMap.put(AlertPriority.HIGH.name(), AlertPriority.HIGH.name());
+ priority.setValueIcons(iconMap);
+ priority.setImageURLPrefix("subsystems/alert/Alert_");
+ priority.setImageURLSuffix("_16.png");
+ priority.setValue("LOW");
+
+
+ RadioGroupItem active = new RadioGroupItem("alertActive", "Active");
+
+ active.setValueMap("Yes", "No");
+ active.setValue("Yes");
+
+
+ HeaderItem conditionsHeader = new HeaderItem();
+ conditionsHeader.setValue("Alert Conditions");
+
+
+ CanvasItem conditionOne = new CanvasItem("condition0");
+ conditionOne.setShowTitle(false);
+ conditionOne.setColSpan(4);
+ conditionOne.setCanvas(buildConditionSection(0));
+
+
+/*
+ LinkedHashMap valuesMap = new LinkedHashMap();
+ valuesMap.put("Metric", buildMetricSectionCavans(vm));
+ valuesMap.put("InventoryProperty", buildInventoryPropertySectionCavans(vm));
+ valuesMap.put("Event", "Events");
+ valuesMap.put("Configuration", "Configuration Change");
+ RadioGroupWithComponentsItem conditionGroup = new RadioGroupWithComponentsItem("radioTest", "Test", valuesMap, form);
+*/
+
+ form.setItems(alertPropertiesHeader, alertName, priority, description, active, conditionsHeader, conditionOne);
+
+
+ return form;
+
+ }
+
+
+ /*
+ AVAILABILITY("Resource Availability"), //
+ THRESHOLD("Measurement Threshold"), //
+ BASELINE("Measurement Baseline"), //
+ CHANGE("Measurement Value Change"), //
+ TRAIT("Measurement Trait"), //
+ CONTROL("Control Action"), //
+ ALERT("Alert Fired"), //
+ RESOURCE_CONFIG("Resource Configuration Property Value Change"), //
+ EVENT("Log Event");
+
+ */
+
+
+ private DynamicForm buildConditionSection(int ci) {
+
+ DynamicForm form = new DynamicForm();
+ form.setNumCols(3);
+ form.setColWidths("30","120","*");
+ ArrayList<FormItem> items = new ArrayList<FormItem>();
+
+
+//
+// RadioGroupItem conditionType = new RadioGroupItem("conditionType" + ci, "Condition Type");
+// conditionType.setImageURLPrefix("subsystems/");
+// conditionType.setImageURLSuffix("_16.png");
+
+ LinkedHashMap<String, String> valueMap = new LinkedHashMap<String, String>();
+ valueMap.put(AlertConditionCategory.AVAILABILITY.name(), AlertConditionCategory.AVAILABILITY.getDisplayName());
+ valueMap.put("metric", "Metric");
+ valueMap.put(AlertConditionCategory.TRAIT.name(), AlertConditionCategory.TRAIT.getDisplayName());
+ valueMap.put(AlertConditionCategory.CONTROL.name(), AlertConditionCategory.CONTROL.getDisplayName());
+ valueMap.put(AlertConditionCategory.EVENT.name(), AlertConditionCategory.EVENT.getDisplayName());
+// conditionType.setValueMap(valueMap);
+
+
+ LinkedHashMap<String, String> iconMap = new LinkedHashMap<String, String>();
+ iconMap.put(AlertConditionCategory.AVAILABILITY.name(), "availability/availability_red");
+ iconMap.put("metric", "monitor/Monitor_failed");
+ iconMap.put(AlertConditionCategory.TRAIT.name(), "inventory/Inventory");
+ iconMap.put(AlertConditionCategory.CONTROL.name(), "control/Operation");
+ iconMap.put(AlertConditionCategory.EVENT.name(), "event/Events_error");
+
+// conditionType.setValueIcons(iconMap);
+//// conditionType.setValueIconSize(24);http://localhost:7080/coregui/images/availability/availability_red
+// conditionType.setShowIcons(true);
+
+
+ for (final String key : valueMap.keySet()) {
+ BlurbItem icon = new BlurbItem();
+ icon.setColSpan(1);
+ icon.setEndRow(false);
+ icon.setValue(Canvas.imgHTML("subsystems/" + iconMap.get(key) + "_24.png"));
+ icon.setShowTitle(false);
+ icon.setWidth(30);
+ icon.setHeight(30);
+ items.add(icon);
+
+ final RadioGroupItem radio = new RadioGroupItem("conditionType" + ci);
+ radio.setStartRow(false);
+ radio.setShowTitle(false);
+ radio.setValueMap(valueMap.get(key));
+ items.add(radio);
+
+ icon.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent clickEvent) {
+ radio.setValue(key);
+ }
+ });
+
+ }
+
+
+
+ form.setItems(items.toArray(new FormItem[items.size()]));
+ return form;
+ }
+
+
+ private DynamicForm buildMetricSectionCavans(ValuesManager vm) {
+
+ DynamicForm form = new DynamicForm();
+ form.setTitleSuffix("");
+ form.setColWidths("10%");
+ form.setValuesManager(vm);
+
+
+ SelectItem metricSelect = new SelectItem("metric", "Metric");
+ metricSelect.setRequired(true);
+ metricSelect.setEmptyDisplayValue("Select...");
+ metricSelect.setValueMap("CPU Usage", "Free Memory", "Swap Used", "User CPU", "System CPU");
+
+
+ LinkedHashMap valueMap = new LinkedHashMap();
+
+
+ DynamicForm subForm1 = new DynamicForm();
+ subForm1.setTitleSuffix("");
+ subForm1.setValuesManager(vm);
+ subForm1.setNumCols(6);
+ SelectItem metricConditionComparison = new SelectItem("metricConditionKind", "is");
+ metricConditionComparison.setValueMap("> (greater than)", "= (equals)", "< (less than)");
+
+ TextItem metricConditionValue = new TextItem("metricConditionValue");
+ metricConditionValue.setShowTitle(false);
+ metricConditionValue.setHint("Absolute Value");
+
+ subForm1.setItems(metricConditionComparison, metricConditionValue);
+
+ valueMap.put("Value", subForm1);
+
+
+ DynamicForm subForm2 = new DynamicForm();
+ subForm2.setTitleSuffix("");
+ subForm2.setValuesManager(vm);
+ subForm2.setNumCols(8);
+ SelectItem baselineConditionComparison = new SelectItem("baselineConditionKind", "is");
+ baselineConditionComparison.setValueMap("> (greater than)", "= (equals)", "< (less than)");
+
+ TextItem baselineConditionValue = new TextItem("baselineConditionValue");
+ baselineConditionValue.setShowTitle(false);
+ baselineConditionValue.setHint("%");
+
+ SelectItem baselineRange = new SelectItem("baselineRange", "of");
+ baselineRange.setValueMap("25 MB (min value)", "78 MB (avg value)", "322 MB (Max Value)");
+
+ subForm2.setItems(baselineConditionComparison, baselineConditionValue, baselineRange);
+
+
+ valueMap.put("Baseline", subForm2);
+
+
+ valueMap.put("valueChanges", "Value Changes");
+
+
+ RadioGroupWithComponentsItem metricConditionType = new RadioGroupWithComponentsItem("metricConditionType", null, valueMap, form);
+ metricConditionType.setShowTitle(false);
+
+ form.setItems(metricSelect, new SpacerItem(), metricConditionType);
+ return form;
+ }
+
+
+ private DynamicForm buildInventoryPropertySectionCavans(ValuesManager vm) {
+ DynamicForm form = new DynamicForm();
+ form.setValuesManager(vm);
+
+
+ SelectItem inventoryProperty = new SelectItem("inventoryPropert", "Inventory Property");
+ inventoryProperty.setValueMap("OS Version", "Architecture", "Vendor", "RAM", "CPU Speed");
+ inventoryProperty.setHint("value changes");
+
+ form.setItems(inventoryProperty);
+
+
+ return form;
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/AvailabilityBarView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/AvailabilityBarView.java
new file mode 100644
index 0000000..0efea7e
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/AvailabilityBarView.java
@@ -0,0 +1,171 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.coregui.client.inventory.resource.detail.monitoring;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.widgets.HTMLFlow;
+import com.smartgwt.client.widgets.Img;
+import com.smartgwt.client.widgets.events.MouseOutEvent;
+import com.smartgwt.client.widgets.events.MouseOutHandler;
+import com.smartgwt.client.widgets.events.MouseOverEvent;
+import com.smartgwt.client.widgets.events.MouseOverHandler;
+import com.smartgwt.client.widgets.layout.HLayout;
+import com.smartgwt.client.widgets.layout.VLayout;
+
+import org.rhq.core.domain.measurement.Availability;
+import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.domain.measurement.MeasurementConverterClient;
+import org.rhq.core.domain.measurement.MeasurementUnits;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.util.PageControl;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.core.domain.util.PageOrdering;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+
+/**
+ * @author Greg Hinkle
+ */
+public class AvailabilityBarView extends HLayout {
+
+
+ private Resource resource;
+
+
+ public AvailabilityBarView(Resource resource) {
+ this.resource = resource;
+ setHeight(28);
+ setWidth100();
+ setMargin(10);
+ }
+
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+
+
+ PageControl pc = PageControl.getUnlimitedInstance();
+ pc.initDefaultOrderingField("av.startTime", PageOrdering.ASC);
+
+ GWTServiceLookup.getAvailabilityService().findAvailabilityForResource(
+ resource.getId(), pc,
+ new AsyncCallback<PageList<Availability>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to load availability history", caught);
+ }
+
+ public void onSuccess(PageList<Availability> result) {
+ update(result);
+ }
+ }
+ );
+ }
+
+ private void update(PageList<Availability> result) {
+
+ long start = result.get(0).getStartTime().getTime();
+ long end = result.get(result.size() - 1).getEndTime() != null ? result.get(result.size() - 1).getEndTime().getTime() : System.currentTimeMillis();
+
+ long diff = end - start;
+
+
+ Img leftCap = new Img("availBar/leftCap.png",8,28);
+ addMember(leftCap);
+
+ for (Availability a : result) {
+
+ long endTime = a.getEndTime() != null ? a.getEndTime().getTime() : System.currentTimeMillis();
+
+
+ double width = (((double) (endTime - a.getStartTime().getTime()) / diff) * 100);
+ String widthString = width + "%";
+ if (width == 0) {
+ widthString = "2px";
+ }
+
+
+ String imagePath = a.getAvailabilityType() == AvailabilityType.UP ? "availBar/up.png" : "availBar/down.png";
+
+
+
+ final Img section = new Img(imagePath);
+ section.setHeight(28);
+ section.setOpacity(60);
+ section.setWidth(widthString);
+
+ section.addMouseOverHandler(new MouseOverHandler() {
+ public void onMouseOver(MouseOverEvent mouseOverEvent) {
+ section.animateFade(100);
+ }
+ });
+ section.addMouseOutHandler(new MouseOutHandler() {
+ public void onMouseOut(MouseOutEvent mouseOutEvent) {
+ section.animateFade(60);
+ }
+ });
+
+
+ long duration = endTime - a.getStartTime().getTime();
+
+ String durationString = MeasurementConverterClient.format((double)duration, MeasurementUnits.MILLISECONDS, true);
+
+ section.setTooltip("<div style=\"white-space: nowrap;\"><b>Availability: </b>" + a.getAvailabilityType().name() +
+ "<br/><b>Start: </b>" + a.getStartTime() +
+ "<br/><b>End: </b>" + a.getEndTime() +
+ "<br/><b>Duration: </b>" + durationString);
+
+
+ addMember(section);
+
+ }
+ Img rightCap = new Img("availBar/rightCap.png",8,28);
+ addMember(rightCap);
+
+
+
+
+ /* StringBuffer buf = new StringBuffer("<table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr height=\"28\">");
+
+ buf.append("<td width=\"8px\" class=\"availBarLeftCap\"> </td>");
+
+
+ for (Availability a : result) {
+
+ long endTime = a.getEndTime() != null ? a.getEndTime().getTime() : System.currentTimeMillis();
+
+
+ double width = (((double) (endTime - a.getStartTime().getTime()) / diff) * 100);
+ String widthString = width + "%";
+ if (width == 0) {
+ widthString = "2px";
+ }
+
+ buf.append("<td width=\"" + widthString + "\" class=\"" + (a.getAvailabilityType() == AvailabilityType.UP ? "availBarUp" : "availBarDown") + "\"> </td>");
+ }
+ buf.append("<td width=\"8px\" class=\"availBarRightCap\"> </td>");
+ buf.append("</tr></table>");
+
+
+ HTMLFlow bar = new HTMLFlow(buf.toString());
+
+ addMember(bar);*/
+
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/GraphListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/GraphListView.java
index 71be91d..4076921 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/GraphListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/GraphListView.java
@@ -67,7 +67,9 @@ public class GraphListView extends VLayout implements ResourceSelectListener {
c.destroy();
}
- addMember(loadingLabel);
+ addMember(new AvailabilityBarView(resource));
+
+// addMember(loadingLabel);
addMember(new MeasurementRangeEditor());
@@ -131,7 +133,7 @@ public class GraphListView extends VLayout implements ResourceSelectListener {
private void buildGraph(MeasurementDefinition def, List<MeasurementDataNumericHighLowComposite> data) {
SmallGraphView graph = new SmallGraphView(resource.getId(), def, data);
- graph.setWidth("80%");
+ graph.setWidth("95%");
graph.setHeight(220);
addMember(graph);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/overview/ResourceOverviewView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/overview/ResourceOverviewView.java
index 3f5cf5f..bb01526 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/overview/ResourceOverviewView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/overview/ResourceOverviewView.java
@@ -43,10 +43,8 @@ public class ResourceOverviewView extends VLayout {
ResourceSummaryView summaryView = new ResourceSummaryView();
summaryView.onResourceSelected(resource);
- SimpleCollapsiblePanel summaryPanel = new SimpleCollapsiblePanel("Summary", summaryView);
-
- addMember(summaryPanel);
+ addMember(summaryView);
FullHTMLPane summaryPane = new FullHTMLPane("/rhq/resource/summary/overview-plain.xhtml?id=" + resource.getId());
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/overview/ResourceSummaryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/overview/ResourceSummaryView.java
index c2c2560..981fb60 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/overview/ResourceSummaryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/overview/ResourceSummaryView.java
@@ -28,6 +28,7 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.util.SC;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.FormItem;
+import com.smartgwt.client.widgets.form.fields.HeaderItem;
import com.smartgwt.client.widgets.form.fields.SpacerItem;
import com.smartgwt.client.widgets.form.fields.StaticTextItem;
@@ -128,6 +129,9 @@ public class ResourceSummaryView extends DynamicForm implements ResourceSelectLi
ArrayList<FormItem> formItems = new ArrayList<FormItem>();
ArrayList<String> itemIds = new ArrayList<String>();
+ HeaderItem headerItem = new HeaderItem("header", "Summary");
+ headerItem.setValue("Summary");
+ formItems.add(headerItem);
StaticTextItem typeItem = new StaticTextItem("typeItem", "Type");
typeItem.setTooltip("Plugin: " + type.getPlugin() + "\n<br>" + "Type: " + type.getName());
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AvailabilityGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AvailabilityGWTServiceImpl.java
new file mode 100644
index 0000000..cbf72c7
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AvailabilityGWTServiceImpl.java
@@ -0,0 +1,46 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.coregui.server.gwt;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.measurement.Availability;
+import org.rhq.core.domain.util.PageControl;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.enterprise.gui.coregui.client.gwt.AvailabilityGWTService;
+import org.rhq.enterprise.gui.coregui.server.util.SerialUtility;
+import org.rhq.enterprise.server.measurement.AvailabilityManagerLocal;
+import org.rhq.enterprise.server.util.LookupUtil;
+
+/**
+ * @author Greg Hinkle
+ */
+public class AvailabilityGWTServiceImpl extends AbstractGWTServiceImpl implements AvailabilityGWTService {
+
+
+ private AvailabilityManagerLocal availabilityManager = LookupUtil.getAvailabilityManager();
+
+ public PageList<Availability> findAvailabilityForResource(int resourceId, PageControl pc) {
+
+ return SerialUtility.prepare(
+ availabilityManager.findAvailabilityForResource(getSessionSubject(), resourceId, pc),
+ "AvailabilityService.findAvailabilityForResource"
+ );
+
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/CoreGUI.css b/modules/enterprise/gui/coregui/src/main/webapp/CoreGUI.css
index 63c2089..0efdaea 100644
--- a/modules/enterprise/gui/coregui/src/main/webapp/CoreGUI.css
+++ b/modules/enterprise/gui/coregui/src/main/webapp/CoreGUI.css
@@ -134,6 +134,38 @@ a:hover {
font-weight: bold;
}
+.subtitle {
+ color: #D6D6D6;
+ font-variant: small-caps;
+ font-weight: bold;
+ font-size: 12pt;
+}
+
+
+/* Availability Bar */
+.availBarLeftCap {
+ background-image: url("images/availBar/leftCap.png");
+ width: 8px;
+ height: 28px;
+}
+.availBarRightCap {
+ background-image: url("images/availBar/rightCap.png");
+ width: 8px;
+ height: 28px;
+}
+
+.availBarUp {
+ background-image: url("images/availBar/up.png");
+ background-repeat: repeat-x;
+ height: 28px;
+}
+
+.availBarDown {
+ background-image: url("images/availBar/down.png");
+ background-repeat: repeat-x;
+ height: 28px;
+}
+
.GraphTooltip {
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml b/modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml
index 4b75b04..10e8f01 100644
--- a/modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml
+++ b/modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml
@@ -72,6 +72,10 @@
<servlet-name>org.rhq.enterprise.gui.coregui.CoreGUI AuthorizationGWTService</servlet-name>
<servlet-class>org.rhq.enterprise.gui.coregui.server.gwt.AuthorizationGWTServiceImpl</servlet-class>
</servlet>
+ <servlet>
+ <servlet-name>org.rhq.enterprise.gui.coregui.CoreGUI AvailabilityGWTService</servlet-name>
+ <servlet-class>org.rhq.enterprise.gui.coregui.server.gwt.AvailabilityGWTServiceImpl</servlet-class>
+ </servlet>
<servlet-mapping>
<servlet-name>org.rhq.enterprise.gui.coregui.CoreGUI RoleGWTService</servlet-name>
@@ -135,4 +139,8 @@
<servlet-name>org.rhq.enterprise.gui.coregui.CoreGUI AuthorizationGWTService</servlet-name>
<url-pattern>/org.rhq.enterprise.gui.coregui.CoreGUI/AuthorizationGWTService</url-pattern>
</servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>org.rhq.enterprise.gui.coregui.CoreGUI AvailabilityGWTService</servlet-name>
+ <url-pattern>/org.rhq.enterprise.gui.coregui.CoreGUI/AvailabilityGWTService</url-pattern>
+ </servlet-mapping>
</web-app>
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/availBar/down.png b/modules/enterprise/gui/coregui/src/main/webapp/images/availBar/down.png
new file mode 100644
index 0000000..603506e
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/availBar/down.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/availBar/leftCap.png b/modules/enterprise/gui/coregui/src/main/webapp/images/availBar/leftCap.png
new file mode 100644
index 0000000..98b2d83
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/availBar/leftCap.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/availBar/rightCap.png b/modules/enterprise/gui/coregui/src/main/webapp/images/availBar/rightCap.png
new file mode 100644
index 0000000..26b7618
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/availBar/rightCap.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/availBar/unknown.png b/modules/enterprise/gui/coregui/src/main/webapp/images/availBar/unknown.png
new file mode 100644
index 0000000..f1b16bb
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/availBar/unknown.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/availBar/up.png b/modules/enterprise/gui/coregui/src/main/webapp/images/availBar/up.png
new file mode 100644
index 0000000..e80a229
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/availBar/up.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/alert/Alert_HIGH_16.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/alert/Alert_HIGH_16.png
new file mode 100644
index 0000000..2a91bfb
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/alert/Alert_HIGH_16.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/alert/Alert_LOW_16.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/alert/Alert_LOW_16.png
new file mode 100644
index 0000000..f7f04b3
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/alert/Alert_LOW_16.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/alert/Alert_MEDIUM_16.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/alert/Alert_MEDIUM_16.png
new file mode 100644
index 0000000..b470838
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/alert/Alert_MEDIUM_16.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/alert/Alerts_16.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/alert/Alerts_16.png
new file mode 100644
index 0000000..12611d4
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/alert/Alerts_16.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/availability/availability_green_16.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/availability/availability_green_16.png
new file mode 100644
index 0000000..f0bf623
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/availability/availability_green_16.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/availability/availability_green_24.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/availability/availability_green_24.png
new file mode 100644
index 0000000..68e0780
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/availability/availability_green_24.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/availability/availability_grey_16.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/availability/availability_grey_16.png
new file mode 100644
index 0000000..ae6fa45
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/availability/availability_grey_16.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/availability/availability_grey_24.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/availability/availability_grey_24.png
new file mode 100644
index 0000000..4a6461d
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/availability/availability_grey_24.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/availability/availability_red_16.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/availability/availability_red_16.png
new file mode 100644
index 0000000..8182778
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/availability/availability_red_16.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/availability/availability_red_24.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/availability/availability_red_24.png
new file mode 100644
index 0000000..a6c61e9
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/availability/availability_red_24.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/availability/availability_yellow_16.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/availability/availability_yellow_16.png
new file mode 100644
index 0000000..f766722
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/availability/availability_yellow_16.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/availability/availability_yellow_24.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/availability/availability_yellow_24.png
new file mode 100644
index 0000000..a1f0520
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/availability/availability_yellow_24.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/configure/Configure_16.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/configure/Configure_16.png
new file mode 100644
index 0000000..a7cf872
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/configure/Configure_16.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/configure/Configure_24.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/configure/Configure_24.png
new file mode 100644
index 0000000..20f8648
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/configure/Configure_24.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/configure/Configure_failed_16.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/configure/Configure_failed_16.png
new file mode 100644
index 0000000..3787b17
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/configure/Configure_failed_16.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/configure/Configure_grey_16.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/configure/Configure_grey_16.png
new file mode 100644
index 0000000..5f958d4
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/configure/Configure_grey_16.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/configure/Configure_ok_16.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/configure/Configure_ok_16.png
new file mode 100644
index 0000000..ec88330
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/configure/Configure_ok_16.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/content/Content_16.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/content/Content_16.png
new file mode 100644
index 0000000..78f3f34
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/content/Content_16.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/content/Content_24.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/content/Content_24.png
new file mode 100644
index 0000000..6605abb
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/content/Content_24.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/content/Content_cancel_16.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/content/Content_cancel_16.png
new file mode 100644
index 0000000..71acf67
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/content/Content_cancel_16.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/content/Content_failed_16.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/content/Content_failed_16.png
new file mode 100644
index 0000000..7562fd1
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/content/Content_failed_16.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/content/Content_grey_16.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/content/Content_grey_16.png
new file mode 100644
index 0000000..d6b67f9
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/content/Content_grey_16.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/content/Content_ok_16.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/content/Content_ok_16.png
new file mode 100644
index 0000000..7a38ba2
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/content/Content_ok_16.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/control/Operation_16.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/control/Operation_16.png
new file mode 100644
index 0000000..42a287d
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/control/Operation_16.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/control/Operation_24.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/control/Operation_24.png
new file mode 100644
index 0000000..1e71d72
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/control/Operation_24.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/control/Operation_cancel_16.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/control/Operation_cancel_16.png
new file mode 100644
index 0000000..49c230e
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/control/Operation_cancel_16.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/control/Operation_failed_16.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/control/Operation_failed_16.png
new file mode 100644
index 0000000..51504c1
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/control/Operation_failed_16.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/control/Operation_grey_16.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/control/Operation_grey_16.png
new file mode 100644
index 0000000..5d91fe5
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/control/Operation_grey_16.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/control/Operation_ok_16.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/control/Operation_ok_16.png
new file mode 100644
index 0000000..d03dba9
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/control/Operation_ok_16.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_11.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_11.png
new file mode 100644
index 0000000..065c9c3
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_11.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_16.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_16.png
new file mode 100644
index 0000000..2ef2843
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_16.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_24.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_24.png
new file mode 100644
index 0000000..c06974f
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_24.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_debug_16.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_debug_16.png
new file mode 100644
index 0000000..6c79244
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_debug_16.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_debug_24.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_debug_24.png
new file mode 100644
index 0000000..697458d
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_debug_24.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_debug_multi_16.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_debug_multi_16.png
new file mode 100644
index 0000000..481e3bb
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_debug_multi_16.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_debug_multi_24.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_debug_multi_24.png
new file mode 100644
index 0000000..427144d
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_debug_multi_24.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_error_16.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_error_16.png
new file mode 100644
index 0000000..2d23cd8
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_error_16.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_error_24.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_error_24.png
new file mode 100644
index 0000000..2407490
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_error_24.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_error_multi_16.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_error_multi_16.png
new file mode 100644
index 0000000..e8e0abe
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_error_multi_16.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_error_multi_24.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_error_multi_24.png
new file mode 100644
index 0000000..67f5028
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_error_multi_24.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_fatal_16.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_fatal_16.png
new file mode 100644
index 0000000..5e7c663
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_fatal_16.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_fatal_24.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_fatal_24.png
new file mode 100644
index 0000000..d94420a
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_fatal_24.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_fatal_multi_16.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_fatal_multi_16.png
new file mode 100644
index 0000000..93aa420
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_fatal_multi_16.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_fatal_multi_24.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_fatal_multi_24.png
new file mode 100644
index 0000000..f9379c6
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_fatal_multi_24.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_grey_16.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_grey_16.png
new file mode 100644
index 0000000..25ea0d4
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_grey_16.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_info_16.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_info_16.png
new file mode 100644
index 0000000..4f52c86
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_info_16.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_info_24.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_info_24.png
new file mode 100644
index 0000000..60ff249
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_info_24.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_info_multi_16.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_info_multi_16.png
new file mode 100644
index 0000000..2774a57
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_info_multi_16.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_info_multi_24.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_info_multi_24.png
new file mode 100644
index 0000000..d109d37
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_info_multi_24.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_warning_16.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_warning_16.png
new file mode 100644
index 0000000..e2193b8
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_warning_16.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_warning_24.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_warning_24.png
new file mode 100644
index 0000000..5b148a4
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_warning_24.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_warning_multi_16.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_warning_multi_16.png
new file mode 100644
index 0000000..840f632
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_warning_multi_16.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_warning_multi_24.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_warning_multi_24.png
new file mode 100644
index 0000000..e8de0f5
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/event/Events_warning_multi_24.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/inventory/Inventory_16.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/inventory/Inventory_16.png
new file mode 100644
index 0000000..c742e76
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/inventory/Inventory_16.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/inventory/Inventory_24.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/inventory/Inventory_24.png
new file mode 100644
index 0000000..d33e64d
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/inventory/Inventory_24.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/inventory/Inventory_grey_16.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/inventory/Inventory_grey_16.png
new file mode 100644
index 0000000..210bf59
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/inventory/Inventory_grey_16.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/monitor/Monitor_16.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/monitor/Monitor_16.png
new file mode 100644
index 0000000..b7868f6
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/monitor/Monitor_16.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/monitor/Monitor_24.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/monitor/Monitor_24.png
new file mode 100644
index 0000000..bbddb3b
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/monitor/Monitor_24.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/monitor/Monitor_failed_16.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/monitor/Monitor_failed_16.png
new file mode 100644
index 0000000..08f5024
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/monitor/Monitor_failed_16.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/monitor/Monitor_failed_24.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/monitor/Monitor_failed_24.png
new file mode 100644
index 0000000..df02550
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/monitor/Monitor_failed_24.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/monitor/Monitor_grey_16.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/monitor/Monitor_grey_16.png
new file mode 100644
index 0000000..19aa9bf
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/monitor/Monitor_grey_16.png differ
commit 1e6e1567abc0390a6b67e1d99ec0994c3fbf8536
Author: Greg Hinkle <ghinkle(a)redhat.com>
Date: Mon Mar 29 13:45:46 2010 -0400
Fixed IE6 form upload replacement
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml
index 7973bdd..613a4bc 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml
@@ -24,12 +24,12 @@
</generate-with>-->
- <replace-with class="at.bestsolution.gwt.util.impl.DynamicCallbackFormImpl">
- <when-type-is class="at.bestsolution.gwt.util.impl.DynamicCallbackFormImpl"/>
+ <replace-with class="org.rhq.enterprise.gui.coregui.client.components.upload.DynamicCallbackFormImpl">
+ <when-type-is class="org.rhq.enterprise.gui.coregui.client.components.upload.DynamicCallbackFormImpl"/>
</replace-with>
- <replace-with class="at.bestsolution.gwt.util.impl.DynamicCallbackFormImplIE6">
- <when-type-is class="at.bestsolution.gwt.util.impl.DynamicCallbackFormImpl"/>
+ <replace-with class="org.rhq.enterprise.gui.coregui.client.components.upload.DynamicCallbackFormImplIE6">
+ <when-type-is class="org.rhq.enterprise.gui.coregui.client.components.upload.DynamicCallbackFormImpl"/>
<when-property-is name="user.agent" value="ie6"/>
</replace-with>
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/CoreGUI.html b/modules/enterprise/gui/coregui/src/main/webapp/CoreGUI.html
index 37fa7dc..32b1682 100644
--- a/modules/enterprise/gui/coregui/src/main/webapp/CoreGUI.html
+++ b/modules/enterprise/gui/coregui/src/main/webapp/CoreGUI.html
@@ -6,7 +6,6 @@
<link rel="apple-touch-icon" href="/images/favicon.png" />
<script type="text/javascript">
- document.globalObj = window;
var isomorphicDir = "org.rhq.enterprise.gui.coregui.CoreGUI/sc/";
</script>
14 years, 1 month
[rhq] Branch 'gwt' - 2 commits - etc/classloaders-test etc/rhq-plugin-archetype etc/samples modules/core modules/enterprise modules/jopr modules/plugins
by ips
etc/classloaders-test/plugin1/pom.xml | 10 ---
etc/classloaders-test/plugin2/pom.xml | 10 ---
etc/rhq-plugin-archetype/src/main/resources/archetype-resources/pom.xml | 8 --
etc/samples/custom-serverplugin/pom.xml | 8 --
etc/samples/simplereport-serverplugin/pom.xml | 8 --
etc/samples/skeleton-plugin/pom.xml | 10 ---
modules/core/domain/pom.xml | 11 ---
modules/core/gui/pom.xml | 13 ----
modules/enterprise/gui/coregui/pom.xml | 18 -----
modules/jopr/etc/jbas5-ejb-client/pom.xml | 13 ----
modules/jopr/etc/jbas5-ejb2-mdb-test/pom.xml | 15 ----
modules/jopr/etc/jbas5-jnp-client/pom.xml | 15 ----
modules/jopr/tools/jbas5-plugin-descriptor-gen/pom.xml | 31 ++--------
modules/plugins/jboss-as-5/pom.xml | 3
14 files changed, 31 insertions(+), 142 deletions(-)
New commits:
commit 7248b7316dd54e8e5005dba16e2f22c9abe727b8
Merge: 86c0496... 76da7ab...
Author: Ian P. Springer <ips(a)jetengine.(none)>
Date: Wed Apr 28 10:53:21 2010 -0400
Merge branch 'gwt' of ssh://git.fedorahosted.org/git/rhq/rhq into gwt
commit 86c04961b7a7545881dff7083096fcfb4180171f
Author: Ian P. Springer <ips(a)jetengine.(none)>
Date: Wed Apr 28 10:51:40 2010 -0400
eradicate all snapshot repos and deps from our poms
diff --git a/etc/classloaders-test/plugin1/pom.xml b/etc/classloaders-test/plugin1/pom.xml
index 4afa6bb..4a22a3f 100644
--- a/etc/classloaders-test/plugin1/pom.xml
+++ b/etc/classloaders-test/plugin1/pom.xml
@@ -12,7 +12,7 @@
<packaging>jar</packaging>
<properties>
- <rhq.version>1.3.0-SNAPSHOT</rhq.version>
+ <rhq.version>3.0.0.B04</rhq.version>
</properties>
<dependencies>
@@ -229,9 +229,6 @@
<id>jboss</id>
<name>JBoss Repository</name>
<url>http://repository.jboss.org/maven2/</url>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
</repository>
</repositories>
@@ -240,9 +237,8 @@
<id>jboss</id>
<name>JBoss Plugin Repository</name>
<url>http://repository.jboss.org/maven2/</url>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
</pluginRepository>
</pluginRepositories>
+
</project>
+
diff --git a/etc/classloaders-test/plugin2/pom.xml b/etc/classloaders-test/plugin2/pom.xml
index b3ec17a..e7d8317 100644
--- a/etc/classloaders-test/plugin2/pom.xml
+++ b/etc/classloaders-test/plugin2/pom.xml
@@ -12,7 +12,7 @@
<packaging>jar</packaging>
<properties>
- <rhq.version>1.3.0-SNAPSHOT</rhq.version>
+ <rhq.version>3.0.0.B04</rhq.version>
</properties>
<dependencies>
@@ -229,9 +229,6 @@
<id>jboss</id>
<name>JBoss Repository</name>
<url>http://repository.jboss.org/maven2/</url>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
</repository>
</repositories>
@@ -240,9 +237,8 @@
<id>jboss</id>
<name>JBoss Plugin Repository</name>
<url>http://repository.jboss.org/maven2/</url>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
</pluginRepository>
</pluginRepositories>
+
</project>
+
diff --git a/etc/rhq-plugin-archetype/src/main/resources/archetype-resources/pom.xml b/etc/rhq-plugin-archetype/src/main/resources/archetype-resources/pom.xml
index aa877b6..e28af52 100644
--- a/etc/rhq-plugin-archetype/src/main/resources/archetype-resources/pom.xml
+++ b/etc/rhq-plugin-archetype/src/main/resources/archetype-resources/pom.xml
@@ -15,7 +15,7 @@
<description>RHQ Plugin</description>
<properties>
- <rhq.version>1.2.0.GA</rhq.version>
+ <rhq.version>3.0.0.B04</rhq.version>
</properties>
<dependencies>
@@ -168,9 +168,6 @@
<id>jboss</id>
<name>JBoss Repository</name>
<url>http://repository.jboss.org/maven2/</url>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
</repository>
</repositories>
@@ -179,9 +176,6 @@
<id>jboss</id>
<name>JBoss Plugin Repository</name>
<url>http://repository.jboss.org/maven2/</url>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
</pluginRepository>
</pluginRepositories>
diff --git a/etc/samples/custom-serverplugin/pom.xml b/etc/samples/custom-serverplugin/pom.xml
index 0adccf6..1a6df22 100644
--- a/etc/samples/custom-serverplugin/pom.xml
+++ b/etc/samples/custom-serverplugin/pom.xml
@@ -15,7 +15,7 @@
<description>A template for building a custom generic RHQ server plugin</description>
<properties>
- <rhq.version>3.0.0-SNAPSHOT</rhq.version>
+ <rhq.version>3.0.0.B04</rhq.version>
</properties>
<dependencies>
@@ -138,9 +138,6 @@
<id>jboss</id>
<name>JBoss Repository</name>
<url>http://repository.jboss.org/maven2/</url>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
</repository>
</repositories>
@@ -149,9 +146,6 @@
<id>jboss</id>
<name>JBoss Plugin Repository</name>
<url>http://repository.jboss.org/maven2/</url>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
</pluginRepository>
</pluginRepositories>
diff --git a/etc/samples/simplereport-serverplugin/pom.xml b/etc/samples/simplereport-serverplugin/pom.xml
index 15fcf0a..18f8c43 100644
--- a/etc/samples/simplereport-serverplugin/pom.xml
+++ b/etc/samples/simplereport-serverplugin/pom.xml
@@ -15,7 +15,7 @@
<description>A RHQ server plugin that periodically outputs a simple report containing some RHQ data</description>
<properties>
- <rhq.version>3.0.0-SNAPSHOT</rhq.version>
+ <rhq.version>3.0.0.B04</rhq.version>
</properties>
<dependencies>
@@ -138,9 +138,6 @@
<id>jboss</id>
<name>JBoss Repository</name>
<url>http://repository.jboss.org/maven2/</url>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
</repository>
</repositories>
@@ -149,9 +146,6 @@
<id>jboss</id>
<name>JBoss Plugin Repository</name>
<url>http://repository.jboss.org/maven2/</url>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
</pluginRepository>
</pluginRepositories>
diff --git a/etc/samples/skeleton-plugin/pom.xml b/etc/samples/skeleton-plugin/pom.xml
index 2236d81..0b32d6a 100644
--- a/etc/samples/skeleton-plugin/pom.xml
+++ b/etc/samples/skeleton-plugin/pom.xml
@@ -15,7 +15,7 @@
<description>A template for building a custom RHQ agent plugin</description>
<properties>
- <rhq.version>3.0.0-SNAPSHOT</rhq.version>
+ <rhq.version>3.0.0.B04</rhq.version>
</properties>
<dependencies>
@@ -230,9 +230,6 @@
<id>jboss</id>
<name>JBoss Repository</name>
<url>http://repository.jboss.org/maven2/</url>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
</repository>
</repositories>
@@ -241,9 +238,8 @@
<id>jboss</id>
<name>JBoss Plugin Repository</name>
<url>http://repository.jboss.org/maven2/</url>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
</pluginRepository>
</pluginRepositories>
+
</project>
+
diff --git a/modules/core/domain/pom.xml b/modules/core/domain/pom.xml
index 404c4d4..5f9b183 100644
--- a/modules/core/domain/pom.xml
+++ b/modules/core/domain/pom.xml
@@ -410,23 +410,14 @@
<id>jboss-deprecated-repository</id>
<name>JBoss Deprecated Maven Repository</name>
<url>https://repository.jboss.org/nexus/content/repositories/deprecated/</url>
- <layout>default</layout>
- <releases>
- <enabled>true</enabled>
- <updatePolicy>never</updatePolicy>
- </releases>
</repository>
<repository>
<id>codehaus</id>
<name>codehaus</name>
<url>http://repository.codehaus.org/</url>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
</repository>
- </repositories>
-
+ </repositories>
</project>
diff --git a/modules/core/gui/pom.xml b/modules/core/gui/pom.xml
index b84e35d..9890665 100644
--- a/modules/core/gui/pom.xml
+++ b/modules/core/gui/pom.xml
@@ -156,17 +156,6 @@
<layout>legacy</layout>
</repository>
- <!--
- <repository>
- <id>exadel-snapshots</id>
- <name>Exadel Snapshot Maven 2 Repo - for ajax4jsf and richfaces snapshots</name>
- <url>http://maven.exadel.com/</url>
- <releases>
- <enabled>false</enabled>
- </releases>
- </repository>
- -->
-
</repositories>
<profiles>
@@ -228,4 +217,4 @@
</profiles>
-</project>
\ No newline at end of file
+</project>
diff --git a/modules/enterprise/gui/coregui/pom.xml b/modules/enterprise/gui/coregui/pom.xml
index d498c61..73b2823 100644
--- a/modules/enterprise/gui/coregui/pom.xml
+++ b/modules/enterprise/gui/coregui/pom.xml
@@ -398,29 +398,15 @@
<repositories>
<repository>
<id>smartgwt</id>
- <name>SmartGWT</name>
+ <name>SmartGWT Releases</name>
<url>http://www.smartclient.com/maven2/</url>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
</repository>
<repository>
<id>codehaus</id>
- <name>codehaus</name>
+ <name>Codehaus Releases</name>
<url>http://repository.codehaus.org/</url>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
</repository>
-
- <!--
- <repository>
- <id>gflot</id>
- <name>GFlot</name>
- <url>http://codemonkey.dumontierlab.com/maven/repo/</url>
- </repository>
- -->
</repositories>
</project>
diff --git a/modules/jopr/etc/jbas5-ejb-client/pom.xml b/modules/jopr/etc/jbas5-ejb-client/pom.xml
index d96e29a..5219c3b 100644
--- a/modules/jopr/etc/jbas5-ejb-client/pom.xml
+++ b/modules/jopr/etc/jbas5-ejb-client/pom.xml
@@ -15,7 +15,7 @@
<description>a simple client for testing connecting to a JBAS5 instance via JNP, looking up the ProfileService EJB3 beans, and invoking some methods on them</description>
<properties>
- <jbossas.version>5.1.0-SNAPSHOT</jbossas.version>
+ <jbossas.version>6.0.0.M1</jbossas.version>
</properties>
<dependencyManagement>
@@ -275,17 +275,6 @@
<name>JBoss Repository</name>
<url>http://repository.jboss.org/maven2/</url>
</repository>
-<!--
- <repository>
- <id>jboss-snapshots</id>
- <name>JBoss Snapshot Repository</name>
- <url>http://snapshots.jboss.org/maven2/</url>
- <snapshots>
- <enabled>true</enabled>
- <updatePolicy>always</updatePolicy>
- </snapshots>
- </repository>
--->
</repositories>
</project>
diff --git a/modules/jopr/etc/jbas5-ejb2-mdb-test/pom.xml b/modules/jopr/etc/jbas5-ejb2-mdb-test/pom.xml
index 7d956c3..e7bdaf3 100644
--- a/modules/jopr/etc/jbas5-ejb2-mdb-test/pom.xml
+++ b/modules/jopr/etc/jbas5-ejb2-mdb-test/pom.xml
@@ -15,7 +15,7 @@
<description></description>
<properties>
- <jbossas.version>5.1.0-SNAPSHOT</jbossas.version>
+ <jbossas.version>6.0.0.M1</jbossas.version>
</properties>
<dependencyManagement>
@@ -295,18 +295,7 @@
<id>jboss</id>
<name>JBoss Repository</name>
<url>http://repository.jboss.org/maven2/</url>
- </repository>
-
- <repository>
- <id>jboss-snapshots</id>
- <name>JBoss Snapshot Repository</name>
- <url>http://snapshots.jboss.org/maven2/</url>
- <snapshots>
- <enabled>true</enabled>
- <updatePolicy>always</updatePolicy>
- </snapshots>
- </repository>
-
+ </repository>
</repositories>
</project>
diff --git a/modules/jopr/etc/jbas5-jnp-client/pom.xml b/modules/jopr/etc/jbas5-jnp-client/pom.xml
index 76f567f..0f95834 100644
--- a/modules/jopr/etc/jbas5-jnp-client/pom.xml
+++ b/modules/jopr/etc/jbas5-jnp-client/pom.xml
@@ -15,7 +15,7 @@
<description>a simple client for testing connecting to a JBAS5 instance via JNP and looking up the ProfileService</description>
<properties>
- <jbossas.version>5.1.0-SNAPSHOT</jbossas.version>
+ <jbossas.version>6.0.0.M1</jbossas.version>
</properties>
<dependencyManagement>
@@ -206,18 +206,7 @@
<id>jboss</id>
<name>JBoss Repository</name>
<url>http://repository.jboss.org/maven2/</url>
- </repository>
-
- <repository>
- <id>jboss-snapshots</id>
- <name>JBoss Snapshot Repository</name>
- <url>http://snapshots.jboss.org/maven2/</url>
- <snapshots>
- <enabled>true</enabled>
- <updatePolicy>always</updatePolicy>
- </snapshots>
- </repository>
-
+ </repository>
</repositories>
</project>
diff --git a/modules/jopr/tools/jbas5-plugin-descriptor-gen/pom.xml b/modules/jopr/tools/jbas5-plugin-descriptor-gen/pom.xml
index bab2df7..559e38d 100644
--- a/modules/jopr/tools/jbas5-plugin-descriptor-gen/pom.xml
+++ b/modules/jopr/tools/jbas5-plugin-descriptor-gen/pom.xml
@@ -7,38 +7,25 @@
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.jboss.on</groupId>
- <!-- Bypass the jopr-plugins-parent which can not have children. It must build after the plugins in order to execute integration tests on them. -->
- <artifactId>jopr-modules-parent</artifactId>
- <version>2.3.0-SNAPSHOT</version>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-parent</artifactId>
+ <version>3.0.0.B04</version>
</parent>
<groupId>org.jboss.on</groupId>
<artifactId>jopr-jbas5-plugin-descriptor-gen</artifactId>
<packaging>jar</packaging>
- <name>Jopr JBossAS 5.x Plugin Descriptor Generator</name>
- <description>A tool that connects to a JBoss Application Server 5.x instance's Profile Service and generates an RHQ plugin descriptor with a ResourceType for each ManagedComponent type that is deployed.</description>
+ <name>Jopr JBossAS 5.x/6.x Plugin Descriptor Generator</name>
+ <description>A tool that connects to a JBoss Application Server 5.x/6.x instance's Profile Service and generates an RHQ plugin descriptor with a ResourceType for each ManagedComponent type that is deployed.</description>
<scm>
- <connection>scm:git:ssh://git.fedorahosted.org/git/rhq.git/modules/plugins/jboss-as-5</connection>
- <developerConnection>
- scm:git:ssh://git.fedorahosted.org/git/rhq.git/modules/plugins/jboss-as-5
- </developerConnection>
+ <connection>scm:git:ssh://git.fedorahosted.org/git/rhq.git/modules/jopr/tools/jbas5-p...</connection>
+ <developerConnection>scm:git:ssh://git.fedorahosted.org/git/rhq.git/modules/jopr/tools/jbas5-p...</developerConnection>
</scm>
- <properties>
- <scm.module.path>modules/plugins/jboss-as-5/</scm.module.path>
-
- <!-- NOTE: If you are developing this plugin or using it with a snapshot EAP 5.0 build,
- you should do the following before building the plugin:
-
- 1) Checkout and build the EAP 5.0 branch
- (https://svn.jboss.org/repos/jbossas/branches/JBPAPP_5_0/).
- 2) Change the below property to "5.1.0-SNAPSHOT".
- 3) Uncomment the JBoss snapshot repo near the bottom of this POM.
- -->
- <jbossas.version>5.1.0-SNAPSHOT</jbossas.version>
+ <properties>
+ <jbossas.version>6.0.0.M1</jbossas.version>
</properties>
<dependencyManagement>
diff --git a/modules/plugins/jboss-as-5/pom.xml b/modules/plugins/jboss-as-5/pom.xml
index 5533c33..a0ade77 100644
--- a/modules/plugins/jboss-as-5/pom.xml
+++ b/modules/plugins/jboss-as-5/pom.xml
@@ -355,8 +355,7 @@
</dependency>
-->
<!-- Uncomment the below deps if you want to pull down the jboss-profileservice
- and jboss-system sources jars for debugging purposes. You will also need
- to make sure you have the JBoss snapshot repo in this POM or your settings.xml.
+ and jboss-system sources jars for debugging purposes.
-->
<!--
<dependency>
14 years, 1 month
[rhq] Branch 'gwt' - 22 commits - etc/modules modules/core modules/enterprise modules/plugins
by Jay Shaughnessy
etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/accordion.js | 498 +++----
etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/catalog.js | 658 +++++-----
etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/catalog.jsp-old | 188 +-
etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/common.js | 152 +-
etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/downloadAd.js | 108 -
etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/engine.js | 482 +++----
modules/core/dbutils/src/main/scripts/dbsetup/alert-schema.xml | 1
modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml | 2
modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml | 2
modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeploymentAction.java | 39
modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeploymentStatus.java | 2
modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleResourceDeploymentHistory.java | 13
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertDefinitionCriteria.java | 10
modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/bundle/BundleManagerProvider.java | 16
modules/core/plugin-container/src/main/java/org/rhq/core/pc/bundle/BundleManager.java | 42
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/BundleGWTService.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/BundleGWTServiceImpl.java | 3
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/AddLdapGroupsAction.java | 8
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/AddLdapGroupsFormPrepareAction.java | 143 ++
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/RemoveLdapGroupsAction.java | 6
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/ViewAction.java | 13
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/user/RegisterAction.java | 44
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/CustomContentUIBean.java | 2
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/paging/PagedListDataModel.java | 4
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/WebUserPreferences.java | 10
modules/enterprise/gui/portal-war/src/main/webapp/admin/role/AddLdapRoleGroups.jsp | 2
modules/enterprise/gui/portal-war/src/main/webapp/admin/role/RoleLdapGroupsForm.jsp | 263 +++
modules/enterprise/gui/portal-war/src/main/webapp/rhq/definition/group/list.xhtml | 2
modules/enterprise/gui/portal-war/src/main/webapp/rhq/inventory/browseGroups.xhtml | 8
modules/enterprise/gui/portal-war/src/main/webapp/rhq/inventory/browseResources.xhtml | 12
modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/listAlertHistory.xhtml | 6
modules/enterprise/server/jar/src/main/antlr3/org/rhq/enterprise/server/search/RHQL.g | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerBean.java | 103 -
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerLocal.java | 11
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java | 12
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerRemote.java | 19
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/LdapLoginModule.java | 10
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/CustomAlertSenderBackingBean.java | 9
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManager.java | 302 ----
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManagerBean.java | 426 ++++++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManagerLocal.java | 53
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java | 24
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java | 6
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java | 5
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/authz/test/RoleManagerBeanTest.java | 5
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java | 69 -
modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/OperationsBackingBean.java | 21
modules/plugins/ant-bundle/src/main/java/org/rhq/plugins/ant/AntBundlePluginComponent.java | 26
modules/plugins/ant-bundle/src/main/java/org/rhq/plugins/ant/DeploymentAuditorBuildListener.java | 29
modules/plugins/ant-bundle/src/test/java/org/rhq/plugins/ant/AntBundlePluginComponentTest.java | 21
modules/plugins/filetemplate-bundle/src/main/java/org/rhq/plugins/filetemplate/FileTemplateBundlePluginServerComponent.java | 10
51 files changed, 2217 insertions(+), 1691 deletions(-)
New commits:
commit 76da7ab3b3d7e7977b90c744a06f26b3780ff7f9
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Apr 28 10:42:46 2010 -0400
Refactor for change in audit API
diff --git a/modules/plugins/ant-bundle/src/main/java/org/rhq/plugins/ant/AntBundlePluginComponent.java b/modules/plugins/ant-bundle/src/main/java/org/rhq/plugins/ant/AntBundlePluginComponent.java
index 1309f79..65b151b 100644
--- a/modules/plugins/ant-bundle/src/main/java/org/rhq/plugins/ant/AntBundlePluginComponent.java
+++ b/modules/plugins/ant-bundle/src/main/java/org/rhq/plugins/ant/AntBundlePluginComponent.java
@@ -18,7 +18,11 @@
*/
package org.rhq.plugins.ant;
-import java.io.*;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -26,14 +30,17 @@ import java.util.Properties;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-
import org.apache.tools.ant.BuildListener;
import org.apache.tools.ant.Project;
+
import org.rhq.bundle.ant.AntLauncher;
import org.rhq.bundle.ant.BundleAntProject;
import org.rhq.bundle.ant.DeployPropertyNames;
import org.rhq.bundle.ant.LoggerAntBuildListener;
-import org.rhq.core.domain.bundle.*;
+import org.rhq.core.domain.bundle.BundleDeployment;
+import org.rhq.core.domain.bundle.BundleDeploymentStatus;
+import org.rhq.core.domain.bundle.BundleResourceDeployment;
+import org.rhq.core.domain.bundle.BundleVersion;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.Property;
import org.rhq.core.domain.configuration.PropertySimple;
@@ -105,20 +112,20 @@ public class AntBundlePluginComponent implements ResourceComponent, BundleFacet
List<BuildListener> buildListeners = new ArrayList();
LoggerAntBuildListener logger = new LoggerAntBuildListener(null, logFileOutput, Project.MSG_DEBUG);
buildListeners.add(logger);
- DeploymentAuditorBuildListener auditor = new DeploymentAuditorBuildListener(
- request.getBundleManagerProvider(), resourceDeployment);
+ DeploymentAuditorBuildListener auditor = new DeploymentAuditorBuildListener(request
+ .getBundleManagerProvider(), resourceDeployment);
buildListeners.add(auditor);
// Parse & execute the Ant script.
AntLauncher antLauncher = new AntLauncher();
BundleAntProject project = antLauncher.executeBundleDeployFile(recipeFile, null, antProps,
- buildListeners);
+ buildListeners);
// Send the diffs to the Server so it can store them as an entry in the deployment history.
BundleManagerProvider bundleManagerProvider = request.getBundleManagerProvider();
DeployDifferences diffs = project.getDeployDifferences();
- bundleManagerProvider.auditDeployment(resourceDeployment, BundleDeploymentAction.DEPLOYMENT_STEP,
- BundleDeploymentStatus.SUCCESS, diffs.toString());
+ bundleManagerProvider.auditDeployment(resourceDeployment, "Deployment Differences",
+ BundleDeploymentStatus.SUCCESS, diffs.toString());
} catch (Throwable t) {
if (log.isDebugEnabled()) {
try {
@@ -147,8 +154,7 @@ public class AntBundlePluginComponent implements ResourceComponent, BundleFacet
String installDir = bundleDeployment.getInstallDir();
if (installDir == null) {
- throw new IllegalStateException("Bundle deployment does not specify install dir: "
- + bundleDeployment);
+ throw new IllegalStateException("Bundle deployment does not specify install dir: " + bundleDeployment);
}
antProps.setProperty(DeployPropertyNames.DEPLOY_DIR, installDir);
diff --git a/modules/plugins/ant-bundle/src/main/java/org/rhq/plugins/ant/DeploymentAuditorBuildListener.java b/modules/plugins/ant-bundle/src/main/java/org/rhq/plugins/ant/DeploymentAuditorBuildListener.java
index 86bde70..d84b061 100644
--- a/modules/plugins/ant-bundle/src/main/java/org/rhq/plugins/ant/DeploymentAuditorBuildListener.java
+++ b/modules/plugins/ant-bundle/src/main/java/org/rhq/plugins/ant/DeploymentAuditorBuildListener.java
@@ -25,7 +25,7 @@ package org.rhq.plugins.ant;
import org.apache.tools.ant.BuildEvent;
import org.apache.tools.ant.BuildListener;
import org.apache.tools.ant.util.StringUtils;
-import org.rhq.core.domain.bundle.BundleDeploymentAction;
+
import org.rhq.core.domain.bundle.BundleDeploymentStatus;
import org.rhq.core.domain.bundle.BundleResourceDeployment;
import org.rhq.core.pluginapi.bundle.BundleManagerProvider;
@@ -40,8 +40,8 @@ public class DeploymentAuditorBuildListener implements BuildListener {
private BundleManagerProvider bundleManagerProvider;
private BundleResourceDeployment bundleResourceDeployment;
- public DeploymentAuditorBuildListener(BundleManagerProvider bundleManagerProvider,
- BundleResourceDeployment bundleResourceDeployment) {
+ public DeploymentAuditorBuildListener(BundleManagerProvider bundleManagerProvider,
+ BundleResourceDeployment bundleResourceDeployment) {
this.bundleManagerProvider = bundleManagerProvider;
this.bundleResourceDeployment = bundleResourceDeployment;
}
@@ -70,25 +70,25 @@ public class DeploymentAuditorBuildListener implements BuildListener {
auditEvent(event);
}
- public void messageLogged(BuildEvent event) {
+ public void messageLogged(BuildEvent event) {
return;
}
private void auditEvent(BuildEvent event) {
- BundleDeploymentStatus status = (event.getException() == null) ? BundleDeploymentStatus.SUCCESS :
- BundleDeploymentStatus.FAILURE;
- String message = createMessage(event);
+ BundleDeploymentStatus status = (event.getException() == null) ? BundleDeploymentStatus.SUCCESS
+ : BundleDeploymentStatus.FAILURE;
+ String action = createAction(event);
+ String message = createMessage(action, event);
try {
- this.bundleManagerProvider.auditDeployment(this.bundleResourceDeployment,
- BundleDeploymentAction.DEPLOYMENT_STEP, status, message);
+ this.bundleManagerProvider.auditDeployment(this.bundleResourceDeployment, "Build Event: " + action, status,
+ message);
} catch (Exception e) {
throw new RuntimeException(e);
}
return;
}
- @SuppressWarnings({"ThrowableResultOfMethodCallIgnored"})
- private static String createMessage(BuildEvent event) {
+ private static String createAction(BuildEvent event) {
StringBuilder msg = new StringBuilder();
if (event.getTarget() != null) {
msg.append("[").append(event.getTarget().getName()).append("] ");
@@ -98,6 +98,13 @@ public class DeploymentAuditorBuildListener implements BuildListener {
msg.append("<").append(event.getTask().getTaskName()).append("> ");
}
+ return msg.toString();
+ }
+
+ @SuppressWarnings( { "ThrowableResultOfMethodCallIgnored" })
+ private static String createMessage(String action, BuildEvent event) {
+ StringBuilder msg = new StringBuilder(action);
+
if (event.getMessage() != null) {
msg.append(event.getMessage());
}
diff --git a/modules/plugins/ant-bundle/src/test/java/org/rhq/plugins/ant/AntBundlePluginComponentTest.java b/modules/plugins/ant-bundle/src/test/java/org/rhq/plugins/ant/AntBundlePluginComponentTest.java
index 32b5f3e..d854208 100644
--- a/modules/plugins/ant-bundle/src/test/java/org/rhq/plugins/ant/AntBundlePluginComponentTest.java
+++ b/modules/plugins/ant-bundle/src/test/java/org/rhq/plugins/ant/AntBundlePluginComponentTest.java
@@ -28,26 +28,31 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
-import org.rhq.core.domain.bundle.*;
-import org.rhq.core.domain.content.PackageVersion;
-import org.rhq.core.pluginapi.bundle.BundleManagerProvider;
-import org.rhq.core.util.file.FileUtil;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+import org.rhq.core.domain.bundle.Bundle;
+import org.rhq.core.domain.bundle.BundleDeployment;
+import org.rhq.core.domain.bundle.BundleDeploymentStatus;
+import org.rhq.core.domain.bundle.BundleResourceDeployment;
+import org.rhq.core.domain.bundle.BundleType;
+import org.rhq.core.domain.bundle.BundleVersion;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.content.PackageType;
+import org.rhq.core.domain.content.PackageVersion;
import org.rhq.core.domain.content.Repo;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.pluginapi.bundle.BundleDeployRequest;
import org.rhq.core.pluginapi.bundle.BundleDeployResult;
+import org.rhq.core.pluginapi.bundle.BundleManagerProvider;
import org.rhq.core.pluginapi.inventory.ResourceContext;
import org.rhq.core.system.SystemInfoFactory;
+import org.rhq.core.util.file.FileUtil;
import org.rhq.core.util.stream.StreamUtil;
@Test
@@ -116,7 +121,7 @@ public class AntBundlePluginComponentTest {
/**
* Test a Ant script that includes all of the RHQ tasks.
- */
+ */
public void testAntBundle() throws Exception {
ResourceType resourceType = new ResourceType("testSimpleBundle", "plugin", ResourceCategory.SERVER, null);
BundleType bundleType = new BundleType("testSimpleBundle", resourceType);
@@ -147,7 +152,7 @@ public class AntBundlePluginComponentTest {
BundleDeployResult results = plugin.deployBundle(request);
- assertResultsSuccess(results);
+ assertResultsSuccess(results);
}
private void assertResultsSuccess(BundleDeployResult results) {
@@ -163,8 +168,8 @@ public class AntBundlePluginComponentTest {
}
private class MockBundleManagerProvider implements BundleManagerProvider {
- public void auditDeployment(BundleResourceDeployment deployment, BundleDeploymentAction action,
- BundleDeploymentStatus status, String message) throws Exception {
+ public void auditDeployment(BundleResourceDeployment deployment, String action, BundleDeploymentStatus status,
+ String message) throws Exception {
System.out.println("Auditing deployment step [" + message + "]...");
}
commit ae4b9e7a0d06bffcea37d7ffd1c594a111cc39f5
Merge: fde273a... 99bbe0c...
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Apr 28 10:24:07 2010 -0400
Merge branch 'gwt' into gwt-jay
Conflicts:
modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/bundle/BundleManagerProvider.java
modules/core/plugin-container/src/main/java/org/rhq/core/pc/bundle/BundleManager.java
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerRemote.java
diff --cc modules/core/plugin-container/src/main/java/org/rhq/core/pc/bundle/BundleManager.java
index cb7afc9,2f49887..9fc338c
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/bundle/BundleManager.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/bundle/BundleManager.java
@@@ -172,7 -170,8 +172,8 @@@ public class BundleManager extends Agen
}
BundleResourceDeploymentHistory history = new BundleResourceDeploymentHistory("Bundle Plugin", action, status,
message);
+ log.debug("Reporting deployment step [" + history + "] to Server...");
- getBundleServerService().addDeploymentHistory(bundleResourceeployment.getId(), history);
+ getBundleServerService().addDeploymentHistory(bundleResourceDeployment.getId(), history);
}
/**
commit 99bbe0c9418e00c6069dc773c087f9796d2b2853
Merge: 5bae003... 303467a...
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Apr 28 10:16:46 2010 -0400
Merge branch 'master' into gwt
commit 5bae003204b09ae6385d6aa6c89e391438f7184b
Merge: 5fcef68... 12e0c3d...
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Apr 28 10:15:59 2010 -0400
Merge branch 'gwt' of ssh://git.fedorahosted.org/git/rhq/rhq into gwt
commit fde273a84bde584f7cb965011cc1db0b4a5856ca
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Apr 28 10:12:56 2010 -0400
Some data model and API changes. (work in progress)
- remove enumeration BundleDeploymentAction in favor of free text actions
in the audits and increase the field size to 512. This field will act
as the action/summary to be displayed for each audit. Additional detail
will be in the auditMessage field.
- remove the ability to schedule a single resource deployment. This is an
API change, not a change to the data model.
- Remove the NO_CHANGE deployment status. SUCCESS will be used in its
place, when necessary. Add WARN status for WARN level auditing.
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml b/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml
index 1a31b70..07cf080 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml
@@ -601,7 +601,7 @@
<column name="BUNDLE_RES_DEPLOY_ID" type="INTEGER" required="true" references="RHQ_BUNDLE_RES_DEPLOY" />
<column name="SUBJECT_NAME" required="false" size="255" type="VARCHAR2"/>
<column name="AUDIT_TIME" required="true" type="LONG"/>
- <column name="AUDIT_ACTION" required="true" size="50" type="VARCHAR2"/>
+ <column name="AUDIT_ACTION" required="true" size="512" type="VARCHAR2"/>
<column name="AUDIT_STATUS" required="true" type="VARCHAR2" size="16"/>
<column name="AUDIT_MESSAGE" required="false" type="LONGVARCHAR"/>
</table>
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 d97a230..beeab4b 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -2614,7 +2614,7 @@
<schema-addColumn table="RHQ_BUNDLE_RES_DEP_HIST" column="SUBJECT_NAME" columnType="VARCHAR2" precision="255" />
<schema-addColumn table="RHQ_BUNDLE_RES_DEP_HIST" column="AUDIT_TIME" columnType="LONG" />
<schema-alterColumn table="RHQ_BUNDLE_RES_DEP_HIST" column="AUDIT_TIME" nullable="FALSE" />
- <schema-addColumn table="RHQ_BUNDLE_RES_DEP_HIST" column="AUDIT_ACTION" columnType="VARCHAR2" precision="50" />
+ <schema-addColumn table="RHQ_BUNDLE_RES_DEP_HIST" column="AUDIT_ACTION" columnType="VARCHAR2" precision="512" />
<schema-alterColumn table="RHQ_BUNDLE_RES_DEP_HIST" column="AUDIT_ACTION" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE_RES_DEP_HIST" column="AUDIT_STATUS" columnType="VARCHAR2" precision="16" />
<schema-alterColumn table="RHQ_BUNDLE_RES_DEP_HIST" column="AUDIT_STATUS" nullable="FALSE" />
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeploymentAction.java b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeploymentAction.java
deleted file mode 100644
index f43cb04..0000000
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeploymentAction.java
+++ /dev/null
@@ -1,39 +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.
- */
-package org.rhq.core.domain.bundle;
-
-/**
- * Bundle Deployment Actions that can be audited. The same action can be used multiple times in a single
- * deployment audit although the status may change Typically with different status' to along with the expected status messages of each.
- *
- * @author Jay Shaughnessy
- */
-public enum BundleDeploymentAction {
-
- DEPLOYMENT, // The actual deployment of the bundle: IN_PROGRESS | FAILURE | SUCCESS
- DEPLOYMENT_REQUESTED, // request processed: FAILURE | SUCCESS
- DEPLOYMENT_SCHEDULED, // request schedules: FAILURE | SUCCESS
- DEPLOYMENT_STEP, // A supplemental message at any point in the process: NO_CHANGE
- FILE_DOWNLOAD, // The file download preceding actualy deployment: IN_PROGRESS | FAILURE | SUCCESS
- POLICY_CHECK_FAIL
-}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeploymentStatus.java b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeploymentStatus.java
index 66f8f68..0c37294 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeploymentStatus.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeploymentStatus.java
@@ -34,7 +34,7 @@ public enum BundleDeploymentStatus {
INPROGRESS("In Progress"), //
SUCCESS("Success"), //
FAILURE("Failure"), //
- NOCHANGE("No Change");
+ WARN("Warning");
private String displayName;
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleResourceDeploymentHistory.java b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleResourceDeploymentHistory.java
index dcc418b..7064709 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleResourceDeploymentHistory.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleResourceDeploymentHistory.java
@@ -73,8 +73,7 @@ public class BundleResourceDeploymentHistory implements Serializable {
private Long auditTime = System.currentTimeMillis();
@Column(name = "AUDIT_ACTION", nullable = false)
- @Enumerated(EnumType.STRING)
- private BundleDeploymentAction auditAction;
+ private String auditAction;
@Column(name = "AUDIT_STATUS", nullable = false)
@Enumerated(EnumType.STRING)
@@ -87,8 +86,8 @@ public class BundleResourceDeploymentHistory implements Serializable {
protected BundleResourceDeploymentHistory() {
}
- public BundleResourceDeploymentHistory(String subjectName, BundleDeploymentAction auditAction,
- BundleDeploymentStatus auditStatus, String auditMessage) {
+ public BundleResourceDeploymentHistory(String subjectName, String auditAction, BundleDeploymentStatus auditStatus,
+ String auditMessage) {
this.subjectName = subjectName;
this.auditAction = auditAction;
@@ -120,11 +119,11 @@ public class BundleResourceDeploymentHistory implements Serializable {
this.auditTime = auditTime;
}
- public BundleDeploymentAction getAuditAction() {
- return this.auditAction;
+ public String getAuditAction() {
+ return auditAction;
}
- public void setAuditAction(BundleDeploymentAction auditAction) {
+ public void setAuditAction(String auditAction) {
this.auditAction = auditAction;
}
diff --git a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/bundle/BundleManagerProvider.java b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/bundle/BundleManagerProvider.java
index 00ba3d6..a0d6473 100644
--- a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/bundle/BundleManagerProvider.java
+++ b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/bundle/BundleManagerProvider.java
@@ -22,7 +22,6 @@ package org.rhq.core.pluginapi.bundle;
import java.io.OutputStream;
import java.util.List;
-import org.rhq.core.domain.bundle.BundleDeploymentAction;
import org.rhq.core.domain.bundle.BundleDeploymentStatus;
import org.rhq.core.domain.bundle.BundleResourceDeployment;
import org.rhq.core.domain.bundle.BundleVersion;
@@ -37,12 +36,14 @@ public interface BundleManagerProvider {
/**
* Bundle plugins call back into this manager to add progressive auditing of a deployment.
*
- * @param bundleVersion
- * @return the bundle files that are associated with the given bundle
+ * @param deployment The resource deployment tracking this bundle deployment
+ * @param action The audit action, a short summary easily displayed
+ * @param status Optional, defaults to SUCCESS
+ * @param message Optional, verbose message being audited, failure message, text file, etc
* @throws Exception
*/
- void auditDeployment(BundleResourceDeployment deployment, BundleDeploymentAction action,
- BundleDeploymentStatus status, String message) throws Exception;
+ void auditDeployment(BundleResourceDeployment deployment, String action, BundleDeploymentStatus status,
+ String message) throws Exception;
/**
* Bundle plugins call back into this manager to obtain the bundle files that belong to a given bundle version.
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/bundle/BundleManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/bundle/BundleManager.java
index 0b633d7..cb7afc9 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/bundle/BundleManager.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/bundle/BundleManager.java
@@ -40,7 +40,6 @@ import org.rhq.core.clientapi.agent.bundle.BundleScheduleRequest;
import org.rhq.core.clientapi.agent.bundle.BundleScheduleResponse;
import org.rhq.core.clientapi.server.bundle.BundleServerService;
import org.rhq.core.domain.bundle.BundleDeployment;
-import org.rhq.core.domain.bundle.BundleDeploymentAction;
import org.rhq.core.domain.bundle.BundleDeploymentStatus;
import org.rhq.core.domain.bundle.BundleResourceDeployment;
import org.rhq.core.domain.bundle.BundleResourceDeploymentHistory;
@@ -73,6 +72,10 @@ import org.rhq.core.util.MessageDigestGenerator;
public class BundleManager extends AgentService implements BundleAgentService, BundleManagerProvider, ContainerService {
private final Log log = LogFactory.getLog(BundleManager.class);
+ private final String AUDIT_ACTION_DEPLOYMENT = "Deployment";
+ private final String AUDIT_ACTION_DEPLOYMENT_SCHEDULED = "Deployment Scheduled";
+ private final String AUDIT_ACTION_FILE_DOWNLOAD = "File Download";
+
private PluginContainerConfiguration configuration;
public BundleManager() {
@@ -118,9 +121,8 @@ public class BundleManager extends AgentService implements BundleAgentService, B
}
int bundleHandlerResourceId = resources.iterator().next().getId();
- auditDeployment(resourceDeployment, BundleDeploymentAction.DEPLOYMENT_SCHEDULED,
- BundleDeploymentStatus.SUCCESS, "Scheduled deployment time: "
- + request.getRequestedDeployTimeAsString() + " (immediate)");
+ auditDeployment(resourceDeployment, AUDIT_ACTION_DEPLOYMENT_SCHEDULED, BundleDeploymentStatus.SUCCESS,
+ "Scheduled deployment time: " + request.getRequestedDeployTimeAsString() + " (immediate)");
// TODO: The logic below this point should be executed asynchronously in response to an actual
// scheduling mechanism. For now all deployments are "immediate" so just do it here.
@@ -142,7 +144,7 @@ public class BundleManager extends AgentService implements BundleAgentService, B
// deploy the bundle utilizing the bundle facet object
String deploymentMessage = "Deployment [" + bundleDeployment + "] to [" + resourceDeployment.getResource()
+ "]";
- auditDeployment(resourceDeployment, BundleDeploymentAction.DEPLOYMENT, BundleDeploymentStatus.INPROGRESS,
+ auditDeployment(resourceDeployment, AUDIT_ACTION_DEPLOYMENT, BundleDeploymentStatus.INPROGRESS,
deploymentMessage);
BundleDeployRequest deployRequest = new BundleDeployRequest();
@@ -163,14 +165,14 @@ public class BundleManager extends AgentService implements BundleAgentService, B
return response;
}
- public void auditDeployment(BundleResourceDeployment bundleResourceeployment, BundleDeploymentAction action,
+ public void auditDeployment(BundleResourceDeployment bundleResourceDeployment, String action,
BundleDeploymentStatus status, String message) {
if (null == status) {
- status = BundleDeploymentStatus.NOCHANGE;
+ status = BundleDeploymentStatus.SUCCESS;
}
BundleResourceDeploymentHistory history = new BundleResourceDeploymentHistory("Bundle Plugin", action, status,
message);
- getBundleServerService().addDeploymentHistory(bundleResourceeployment.getId(), history);
+ getBundleServerService().addDeploymentHistory(bundleResourceDeployment.getId(), history);
}
/**
@@ -188,8 +190,7 @@ public class BundleManager extends AgentService implements BundleAgentService, B
BundleVersion bundleVersion = bundleDeployment.getBundleVersion();
// download all the bundle files to the bundle plugin's tmp directory
- auditDeployment(resourceDeployment, BundleDeploymentAction.FILE_DOWNLOAD, BundleDeploymentStatus.INPROGRESS,
- null);
+ auditDeployment(resourceDeployment, AUDIT_ACTION_FILE_DOWNLOAD, BundleDeploymentStatus.INPROGRESS, null);
Map<PackageVersion, File> packageVersionFiles = new HashMap<PackageVersion, File>();
List<PackageVersion> packageVersions = getAllBundleVersionPackageVersions(bundleVersion);
@@ -199,17 +200,26 @@ public class BundleManager extends AgentService implements BundleAgentService, B
try {
verifyHash(packageVersion, packageFile);
} catch (Exception e) {
+
// file either doesn't exist or it hash doesn't match, download a new copy
packageFile.getParentFile().mkdirs();
FileOutputStream fos = new FileOutputStream(packageFile);
try {
- auditDeployment(resourceDeployment, BundleDeploymentAction.DEPLOYMENT_STEP,
- BundleDeploymentStatus.NOCHANGE, "Downloading [" + packageVersion + "]");
+ auditDeployment(resourceDeployment, "File Download [" + packageVersion.getDisplayName() + "]",
+ BundleDeploymentStatus.INPROGRESS, "Downloading [" + packageVersion + "]");
+
long size = getFileContent(packageVersion, fos);
+
if (packageVersion.getFileSize() != null && size != packageVersion.getFileSize().longValue()) {
- log.warn("Downloaded bundle file [" + packageVersion + "] but its size was [" + size
- + "] when it was expected to be [" + packageVersion.getFileSize() + "].");
+ String message = "Downloaded bundle file [" + packageVersion + "] but its size was [" + size
+ + "] when it was expected to be [" + packageVersion.getFileSize() + "].";
+ log.warn(message);
+ auditDeployment(resourceDeployment, "File Download [" + packageVersion.getDisplayName() + "]",
+ BundleDeploymentStatus.WARN, message);
}
+ auditDeployment(resourceDeployment, "File Download [" + packageVersion.getDisplayName() + "]",
+ BundleDeploymentStatus.SUCCESS, "Download complete for [" + packageVersion + "]");
+
} finally {
fos.close();
}
@@ -221,7 +231,7 @@ public class BundleManager extends AgentService implements BundleAgentService, B
packageVersionFiles.put(packageVersion, packageFile);
}
- auditDeployment(resourceDeployment, BundleDeploymentAction.FILE_DOWNLOAD, BundleDeploymentStatus.SUCCESS, null);
+ auditDeployment(resourceDeployment, AUDIT_ACTION_FILE_DOWNLOAD, BundleDeploymentStatus.SUCCESS, null);
return packageVersionFiles;
}
@@ -229,7 +239,7 @@ public class BundleManager extends AgentService implements BundleAgentService, B
private void completeDeployment(BundleResourceDeployment resourceDeployment, BundleDeploymentStatus status,
String message) {
getBundleServerService().setBundleDeploymentStatus(resourceDeployment.getId(), status);
- auditDeployment(resourceDeployment, BundleDeploymentAction.DEPLOYMENT, status, message);
+ auditDeployment(resourceDeployment, AUDIT_ACTION_DEPLOYMENT, status, message);
}
/**
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/BundleGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/BundleGWTService.java
index 59d0267..056caea 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/BundleGWTService.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/BundleGWTService.java
@@ -26,7 +26,6 @@ import com.google.gwt.user.client.rpc.RemoteService;
import org.rhq.core.domain.bundle.Bundle;
import org.rhq.core.domain.bundle.BundleDeployment;
import org.rhq.core.domain.bundle.BundleGroupDeployment;
-import org.rhq.core.domain.bundle.BundleResourceDeployment;
import org.rhq.core.domain.bundle.BundleType;
import org.rhq.core.domain.bundle.BundleVersion;
import org.rhq.core.domain.bundle.composite.BundleWithLatestVersionComposite;
@@ -63,9 +62,10 @@ public interface BundleGWTService extends RemoteService {
ArrayList<BundleType> getAllBundleTypes() throws Exception;
+ /*
BundleResourceDeployment scheduleBundleResourceDeployment(int bundleDeploymentId, int resourceId)
throws Exception;
+ */
- BundleGroupDeployment scheduleBundleGroupDeployment(int bundleDeploymentId, int resourceGroupId)
- throws Exception;
+ BundleGroupDeployment scheduleBundleGroupDeployment(int bundleDeploymentId, int resourceGroupId) throws Exception;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/BundleGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/BundleGWTServiceImpl.java
index e909dec..2b14ef5 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/BundleGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/BundleGWTServiceImpl.java
@@ -24,7 +24,6 @@ import java.util.HashMap;
import org.rhq.core.domain.bundle.Bundle;
import org.rhq.core.domain.bundle.BundleDeployment;
import org.rhq.core.domain.bundle.BundleGroupDeployment;
-import org.rhq.core.domain.bundle.BundleResourceDeployment;
import org.rhq.core.domain.bundle.BundleType;
import org.rhq.core.domain.bundle.BundleVersion;
import org.rhq.core.domain.bundle.composite.BundleWithLatestVersionComposite;
@@ -155,6 +154,7 @@ public class BundleGWTServiceImpl extends AbstractGWTServiceImpl implements Bund
return SerialUtility.prepare(results, "getAllBundleVersionFilenames");
}
+ /*
public BundleResourceDeployment scheduleBundleResourceDeployment(int bundleDeploymentId, int resourceId)
throws Exception {
try {
@@ -165,6 +165,7 @@ public class BundleGWTServiceImpl extends AbstractGWTServiceImpl implements Bund
throw new RuntimeException(ThrowableUtil.getAllMessages(e));
}
}
+ */
public BundleGroupDeployment scheduleBundleGroupDeployment(int bundleDeploymentId, int resourceGroupId)
throws Exception {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
index ca3e76b..bea8cde 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
@@ -46,7 +46,6 @@ import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.authz.Permission;
import org.rhq.core.domain.bundle.Bundle;
import org.rhq.core.domain.bundle.BundleDeployment;
-import org.rhq.core.domain.bundle.BundleDeploymentAction;
import org.rhq.core.domain.bundle.BundleDeploymentStatus;
import org.rhq.core.domain.bundle.BundleFile;
import org.rhq.core.domain.bundle.BundleGroupDeployment;
@@ -98,6 +97,9 @@ import org.rhq.enterprise.server.util.HibernateDetachUtility.SerializationType;
public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemote {
private final Log log = LogFactory.getLog(this.getClass());
+ private final String AUDIT_ACTION_DEPLOYMENT = "Deployment";
+ private final String AUDIT_ACTION_DEPLOYMENT_REQUESTED = "Deployment Requested";
+
@PersistenceContext(unitName = RHQConstants.PERSISTENCE_UNIT_NAME)
private EntityManager entityManager;
@@ -435,6 +437,9 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
return bundleFile;
}
+ /** TODO: Remove after we finalize the move to group only deployment in the public API
+ *
+ *
public BundleResourceDeployment scheduleBundleResourceDeployment(Subject subject, int bundleDeploymentId,
int resourceId) throws Exception {
BundleDeployment deployment = entityManager.find(BundleDeployment.class, bundleDeploymentId);
@@ -449,6 +454,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
return scheduleBundleResourceDeployment(subject, deployment, resource, null);
}
+ */
private BundleResourceDeployment scheduleBundleResourceDeployment(Subject subject, BundleDeployment deployment,
Resource resource, BundleGroupDeployment groupDeployment) throws Exception {
@@ -483,7 +489,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
// add the deployment request history (in a new trans)
BundleResourceDeploymentHistory history = new BundleResourceDeploymentHistory(subject.getName(),
- BundleDeploymentAction.DEPLOYMENT_REQUESTED, BundleDeploymentStatus.SUCCESS, "Requested deployment time: "
+ AUDIT_ACTION_DEPLOYMENT_REQUESTED, BundleDeploymentStatus.SUCCESS, "Requested deployment time: "
+ request.getRequestedDeployTimeAsString());
bundleManager.addBundleResourceDeploymentHistory(subject, resourceDeployment.getId(), history);
@@ -495,7 +501,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
// Handle Schedule Failures. This may include deployment failures for immediate deployment request
if (!response.isSuccess()) {
- history = new BundleResourceDeploymentHistory(subject.getName(), BundleDeploymentAction.DEPLOYMENT,
+ history = new BundleResourceDeploymentHistory(subject.getName(), AUDIT_ACTION_DEPLOYMENT,
BundleDeploymentStatus.FAILURE, response.getErrorMessage());
bundleManager.setBundleResourceDeploymentStatus(subject, resourceDeployment.getId(),
BundleDeploymentStatus.FAILURE);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerRemote.java
index ca22f58..54ac622 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerRemote.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerRemote.java
@@ -288,25 +288,6 @@ public interface BundleManagerRemote {
*/
/**
- * Deploy the bundle as described in the provided deployment to the specified resource.
- * Deployment is asynchronous so return of this method does not indicate deployments are complete. The
- * returned {@link BundleResourceDeployment} can be used to track the history of the deployment.
- *
- * TODO: Add the scheduling capability, currently it's Immediate.
- *
- * @param subject must be InventoryManager
- * @param bundleDeploymentId the BundleDeployment being used to guide the deployments
- * @param resourceId the target resource (must exist), typically platforms, for the deployments
- * @return the {@link BundleResourceDeployment} created to track the deployment.
- * @throws Exception
- */
- @WebMethod
- BundleResourceDeployment scheduleBundleResourceDeployment( //
- @WebParam(name = "subject") Subject subject, //
- @WebParam(name = "bundleDeploymentId") int bundleDeploymentId, //
- @WebParam(name = "resourceId") int resourceId) throws Exception;
-
- /**
* Deploy the bundle as described in the provided deployment to all of the resources in the
* specified resource group.
* Deployment is asynchronous so return of this method does not indicate deployments are complete. The
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 f2df079..6fa95ec 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
@@ -409,11 +409,6 @@ public class WebservicesManagerBean implements WebservicesRemote {
}
*/
- public BundleResourceDeployment scheduleBundleResourceDeployment(Subject subject, int bundleDeploymentId,
- int resourceId) throws Exception {
- return bundleManager.scheduleBundleResourceDeployment(subject, bundleDeploymentId, resourceId);
- }
-
public BundleGroupDeployment scheduleBundleGroupDeployment(Subject subject, int bundleDeploymentId,
int resourceGroupId) throws Exception {
return bundleManager.scheduleBundleGroupDeployment(subject, bundleDeploymentId, resourceGroupId);
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java
index d331636..7fc43f2 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java
@@ -37,7 +37,6 @@ import org.testng.annotations.Test;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.bundle.Bundle;
import org.rhq.core.domain.bundle.BundleDeployment;
-import org.rhq.core.domain.bundle.BundleDeploymentAction;
import org.rhq.core.domain.bundle.BundleDeploymentStatus;
import org.rhq.core.domain.bundle.BundleFile;
import org.rhq.core.domain.bundle.BundleGroupDeployment;
@@ -62,6 +61,7 @@ import org.rhq.core.domain.resource.InventoryStatus;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.domain.util.PageOrdering;
import org.rhq.enterprise.server.plugin.pc.MasterServerPluginContainer;
@@ -242,6 +242,13 @@ public class BundleManagerBeanTest extends UpdateSubsytemTestBase {
em.remove(em.getReference(Agent.class, ((Agent) removeMe).getId()));
}
+ // remove Resource Groups left over from test deployments
+ q = em.createQuery("SELECT rg FROM ResourceGroup rg WHERE rg.name LIKE '" + TEST_PREFIX + "%'");
+ doomed = q.getResultList();
+ for (Object removeMe : doomed) {
+ em.remove(em.getReference(ResourceGroup.class, ((ResourceGroup) removeMe).getId()));
+ }
+
getTransactionManager().commit();
em.close();
em = null;
@@ -607,42 +614,43 @@ public class BundleManagerBeanTest extends UpdateSubsytemTestBase {
config.put(new PropertySimple("bundletest.property", "bundletest.property value"));
BundleDeployment bd1 = createDeployment("one", bv1, "/test", config);
assertNotNull(bd1);
- Resource platformResource = createTestResource();
- BundleResourceDeployment bd = bundleManager.scheduleBundleResourceDeployment(overlord, bd1.getId(),
- platformResource.getId());
- assertNotNull(bd);
- assertEquals(bd1.getId(), bd.getBundleDeployment().getId());
- assertEquals(platformResource.getId(), bd.getResource().getId());
- assertEquals(BundleDeploymentStatus.INPROGRESS, bd.getStatus());
+ ResourceGroup platformResourceGroup = createTestResourceGroup();
+ BundleGroupDeployment bgd = bundleManager.scheduleBundleGroupDeployment(overlord, bd1.getId(),
+ platformResourceGroup.getId());
+ assertNotNull(bgd);
+ assertEquals(bd1.getId(), bgd.getBundleDeployment().getId());
+ assertEquals(platformResourceGroup.getId(), bgd.getGroup().getId());
+ assertEquals(BundleDeploymentStatus.INPROGRESS, bgd.getStatus());
BundleResourceDeploymentCriteria c = new BundleResourceDeploymentCriteria();
- c.addFilterId(bd.getId());
+ c.addFilterGroupDeploymentId(bgd.getId());
c.fetchHistories(true);
- List<BundleResourceDeployment> bds = bundleManager.findBundleResourceDeploymentsByCriteria(overlord, c);
- assertEquals(1, bds.size());
- assertEquals(bd.getId(), bds.get(0).getId());
- bd = bds.get(0);
- assertNotNull(bd.getBundleResourceDeploymentHistories());
- int size = bd.getBundleResourceDeploymentHistories().size();
+ List<BundleResourceDeployment> brds = bundleManager.findBundleResourceDeploymentsByCriteria(overlord, c);
+ assertEquals(1, brds.size());
+ assertEquals(1, bgd.getResourceDeployments().size());
+ assertEquals(bgd.getResourceDeployments().get(0).getId(), brds.get(0).getId());
+ BundleResourceDeployment brd = brds.get(0);
+ assertNotNull(brd.getBundleResourceDeploymentHistories());
+ int size = brd.getBundleResourceDeploymentHistories().size();
assertTrue(size > 0);
String auditMessage = "BundleTest-Message";
- bundleManager.addBundleResourceDeploymentHistory(overlord, bd.getId(), new BundleResourceDeploymentHistory(
- overlord.getName(), BundleDeploymentAction.DEPLOYMENT_STEP, BundleDeploymentStatus.NOCHANGE, auditMessage));
- bds = bundleManager.findBundleResourceDeploymentsByCriteria(overlord, c);
- assertEquals(1, bds.size());
- assertEquals(bd.getId(), bds.get(0).getId());
- bd = bds.get(0);
- assertNotNull(bd.getBundleResourceDeploymentHistories());
- assertTrue((size + 1) == bd.getBundleResourceDeploymentHistories().size());
+ bundleManager.addBundleResourceDeploymentHistory(overlord, bgd.getId(), new BundleResourceDeploymentHistory(
+ overlord.getName(), auditMessage, BundleDeploymentStatus.SUCCESS, auditMessage));
+ brds = bundleManager.findBundleResourceDeploymentsByCriteria(overlord, c);
+ assertEquals(1, brds.size());
+ assertEquals(bgd.getId(), brds.get(0).getId());
+ brd = brds.get(0);
+ assertNotNull(brd.getBundleResourceDeploymentHistories());
+ assertTrue((size + 1) == brd.getBundleResourceDeploymentHistories().size());
BundleResourceDeploymentHistory newHistory = null;
- for (BundleResourceDeploymentHistory h : bd.getBundleResourceDeploymentHistories()) {
+ for (BundleResourceDeploymentHistory h : brd.getBundleResourceDeploymentHistories()) {
if (auditMessage.equals(h.getAuditMessage())) {
newHistory = h;
break;
}
}
assertNotNull(newHistory);
- assertEquals(BundleDeploymentAction.DEPLOYMENT_STEP, newHistory.getAuditAction());
- assertEquals(BundleDeploymentStatus.NOCHANGE, newHistory.getAuditStatus());
+ assertEquals(auditMessage, newHistory.getAuditAction());
+ assertEquals(BundleDeploymentStatus.SUCCESS, newHistory.getAuditStatus());
}
@Test(enabled = TESTS_ENABLED)
@@ -839,10 +847,11 @@ public class BundleManagerBeanTest extends UpdateSubsytemTestBase {
}
// lifted from ResourceManagerBeanTest
- private Resource createTestResource() throws Exception {
+ private ResourceGroup createTestResourceGroup() throws Exception {
getTransactionManager().begin();
EntityManager em = getEntityManager();
+ ResourceGroup resourceGroup = null;
Resource resource = null;
try {
@@ -862,6 +871,10 @@ public class BundleManagerBeanTest extends UpdateSubsytemTestBase {
resource.setAgent(agent);
em.persist(resource);
+ resourceGroup = new ResourceGroup(TEST_PREFIX + "-group-" + System.currentTimeMillis());
+ resourceGroup.addExplicitResource(resource);
+ em.persist(resourceGroup);
+
getTransactionManager().commit();
} catch (Exception e) {
try {
@@ -874,6 +887,6 @@ public class BundleManagerBeanTest extends UpdateSubsytemTestBase {
em.close();
}
- return resource;
+ return resourceGroup;
}
}
diff --git a/modules/plugins/filetemplate-bundle/src/main/java/org/rhq/plugins/filetemplate/FileTemplateBundlePluginServerComponent.java b/modules/plugins/filetemplate-bundle/src/main/java/org/rhq/plugins/filetemplate/FileTemplateBundlePluginServerComponent.java
index c0521b1..334cc5c 100644
--- a/modules/plugins/filetemplate-bundle/src/main/java/org/rhq/plugins/filetemplate/FileTemplateBundlePluginServerComponent.java
+++ b/modules/plugins/filetemplate-bundle/src/main/java/org/rhq/plugins/filetemplate/FileTemplateBundlePluginServerComponent.java
@@ -23,7 +23,6 @@ import org.apache.commons.logging.LogFactory;
import org.rhq.bundle.filetemplate.recipe.RecipeParser;
import org.rhq.core.domain.bundle.BundleDeployment;
-import org.rhq.core.domain.bundle.BundleDeploymentAction;
import org.rhq.core.domain.bundle.BundleDeploymentStatus;
import org.rhq.core.domain.bundle.BundleResourceDeployment;
import org.rhq.core.domain.bundle.BundleVersion;
@@ -71,17 +70,16 @@ public class FileTemplateBundlePluginServerComponent implements ResourceComponen
request.getBundleManagerProvider().auditDeployment(
resourceDeployment,
- BundleDeploymentAction.DEPLOYMENT_STEP,
- BundleDeploymentStatus.NOCHANGE,
+ "Configuration Variable Replacement",
+ BundleDeploymentStatus.SUCCESS,
"setting replacement variable values using [" + bundleDeployment.getConfiguration().toString(true)
+ "]");
recipeContext.setReplacementVariableValues(bundleDeployment.getConfiguration());
parser.setReplaceReplacementVariables(true);
- request.getBundleManagerProvider().auditDeployment(resourceDeployment,
- BundleDeploymentAction.DEPLOYMENT_STEP, BundleDeploymentStatus.NOCHANGE,
- "Parsing Recipe using context [" + recipeContext + "]");
+ request.getBundleManagerProvider().auditDeployment(resourceDeployment, "Parse Recipe",
+ BundleDeploymentStatus.SUCCESS, "Parsing Recipe using context [" + recipeContext + "]");
parser.parseRecipe(recipeContext);
} catch (Throwable t) {
log.error("Failed to deploy bundle [" + request + "]", t);
commit 303467aeda8d90b48cb68581d53211c774a82fd5
Author: Joseph Marques <joseph(a)redhat.com>
Date: Wed Apr 28 10:06:54 2010 -0400
BA-586918 - fix for ClassCastException when using AlertDefinitionCriteria when filtering by either alertTemplateParentId or alertTemplateResourceTypeId
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertDefinitionCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertDefinitionCriteria.java
index c3992cb..e553ca8 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertDefinitionCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertDefinitionCriteria.java
@@ -29,8 +29,8 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
-import org.rhq.core.domain.alert.AlertPriority;
import org.rhq.core.domain.alert.AlertDefinition;
+import org.rhq.core.domain.alert.AlertPriority;
import org.rhq.core.domain.util.PageOrdering;
/**
@@ -46,8 +46,8 @@ public class AlertDefinitionCriteria extends Criteria {
private String filterName;
private String filterDescription;
private AlertPriority filterPriority;
- private String filterAlertTemplateParentId; // requires overrides
- private String filterAlertTemplateResourceTypeId; // requires overrides
+ private Integer filterAlertTemplateParentId; // requires overrides
+ private Integer filterAlertTemplateResourceTypeId; // requires overrides
private String filterAlertTemplateResourceTypeName; // requires overrides
private List<Integer> filterResourceIds; // requires overrides
private Boolean filterEnabled;
@@ -90,11 +90,11 @@ public class AlertDefinitionCriteria extends Criteria {
this.filterPriority = filterPriority;
}
- public void addFilterAlertTemplateParentId(String filterAlertTemplateParentId) {
+ public void addFilterAlertTemplateParentId(Integer filterAlertTemplateParentId) {
this.filterAlertTemplateParentId = filterAlertTemplateParentId;
}
- public void addFilterAlertTemplateResourceTypeId(String filterAlertTemplateResourceTypeId) {
+ public void addFilterAlertTemplateResourceTypeId(Integer filterAlertTemplateResourceTypeId) {
this.filterAlertTemplateResourceTypeId = filterAlertTemplateResourceTypeId;
}
commit 1851fe41127d4fb136b88184189efc37439f8677
Author: Joseph Marques <joseph(a)redhat.com>
Date: Wed Apr 28 03:12:49 2010 -0400
BZ-586676: fix for alert>history sub-tab as a result of changes to dbsetup
* alert entity no longer refers to the subject entity via foreign key relationship, update Facelet accordingly
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/listAlertHistory.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/listAlertHistory.xhtml
index b708ab7..0d0a46d 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/listAlertHistory.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/listAlertHistory.xhtml
@@ -174,16 +174,16 @@
<f:facet name="header">
<h:outputText styleClass="headerText" value="Ack by" />
</f:facet>
- <h:outputText value="#{item.alert.ackBy.name}" title="#{item.alert.ackBy.firstName} #{item.alert.ackBy.lastName}"/>
+ <h:outputText value="#{item.alert.acknowledgingSubject}" />
</rich:column>
<rich:column>
<f:facet name="header">
- <onc:sortableColumnHeader sort="a.ackTime">
+ <onc:sortableColumnHeader sort="a.acknowledgeTime">
<h:outputText styleClass="headerText" value="Ack date" />
</onc:sortableColumnHeader>
</f:facet>
- <h:outputText value="#{item.alert.ackTime}">
+ <h:outputText value="#{item.alert.acknowledgeTime}">
<f:converter converterId="RelativeDurationConverter" />
</h:outputText>
</rich:column>
commit 605b051d37b98be46f183e3d2bce214d256507f5
Author: Joseph Marques <joseph(a)redhat.com>
Date: Wed Apr 28 01:29:18 2010 -0400
move logging message to DEBUG level
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/WebUserPreferences.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/WebUserPreferences.java
index c0abd7e..e2414a7 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/WebUserPreferences.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/WebUserPreferences.java
@@ -777,7 +777,7 @@ public class WebUserPreferences extends SubjectPreferencesBase {
pageControlProperties.add(field.getOrdering().toString());
pageControlProperties.add(field.getField());
}
- System.out.println("setPageControl(" + view + ", " + pageControl + ")");
+ log.debug("setPageControl(" + view + ", " + pageControl + ")");
setPreference(view.toString(), pageControlProperties);
}
commit 20fe0ece0175e24f2a8905c3a666011802decea5
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Tue Apr 27 18:44:32 2010 -0400
BZ 584355: i)refactored ldap auth classes to be more consitently defined.ii)modified exception handling.
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/AddLdapGroupsAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/AddLdapGroupsAction.java
index fe91d46..036f8c1 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/AddLdapGroupsAction.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/AddLdapGroupsAction.java
@@ -35,13 +35,16 @@ import org.rhq.enterprise.gui.legacy.action.BaseAction;
import org.rhq.enterprise.gui.legacy.action.BaseValidatorForm;
import org.rhq.enterprise.gui.legacy.util.RequestUtils;
import org.rhq.enterprise.gui.legacy.util.SessionUtils;
-import org.rhq.enterprise.server.authz.RoleManagerLocal;
+import org.rhq.enterprise.server.resource.group.LdapGroupManagerLocal;
import org.rhq.enterprise.server.util.LookupUtil;
/**
* An Action that adds resource groups for a role.
*/
public class AddLdapGroupsAction extends BaseAction {
+
+ LdapGroupManagerLocal ldapManager = LookupUtil.getLdapGroupManager();
+
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception {
Log log = LogFactory.getLog(AddLdapGroupsAction.class.getName());
@@ -75,8 +78,7 @@ public class AddLdapGroupsAction extends BaseAction {
log.debug("adding group [" + id + "] for role [" + roleId + "]");
}
- RoleManagerLocal roleManager = LookupUtil.getRoleManager();
- roleManager.addLdapGroupsToRole(RequestUtils.getSubject(request), roleId, pendingGroupIds);
+ ldapManager.addLdapGroupsToRole(RequestUtils.getSubject(request), roleId, pendingGroupIds);
log.debug("removing pending group list");
SessionUtils.removeList(session, Constants.PENDING_RESGRPS_SES_ATTR);
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/AddLdapGroupsFormPrepareAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/AddLdapGroupsFormPrepareAction.java
index 39fe62e..6cbbfce 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/AddLdapGroupsFormPrepareAction.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/AddLdapGroupsFormPrepareAction.java
@@ -28,6 +28,7 @@ import java.util.Properties;
import java.util.Set;
import java.util.TreeMap;
+import javax.ejb.EJBException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -55,7 +56,7 @@ import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.authz.RoleManagerLocal;
import org.rhq.enterprise.server.exception.LdapCommunicationException;
import org.rhq.enterprise.server.exception.LdapFilterException;
-import org.rhq.enterprise.server.resource.group.LdapGroupManager;
+import org.rhq.enterprise.server.resource.group.LdapGroupManagerLocal;
import org.rhq.enterprise.server.system.SystemManagerLocal;
import org.rhq.enterprise.server.util.LookupUtil;
@@ -65,6 +66,9 @@ import org.rhq.enterprise.server.util.LookupUtil;
public class AddLdapGroupsFormPrepareAction extends TilesAction {
final String LDAP_GROUP_CACHE = "ldapGroupCache";
+ RoleManagerLocal roleManager = LookupUtil.getRoleManager();
+ LdapGroupManagerLocal ldapManager = LookupUtil.getLdapGroupManager();
+
public ActionForward execute(ComponentContext context, ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception {
Log log = LogFactory.getLog(AddLdapGroupsFormPrepareAction.class.getName());
@@ -111,16 +115,16 @@ public class AddLdapGroupsFormPrepareAction extends TilesAction {
try { //defend against ldap communication runtime difficulties.
if (cachedAvailableLdapGroups == null) {
- allGroups = LdapGroupManager.getInstance().findAvailableGroups();
+ // allGroups = LdapGroupManagerBean.getInstance().findAvailableGroups();
+ allGroups = ldapManager.findAvailableGroups();
} else {//reuse cached.
allGroups = cachedAvailableLdapGroups;
}
//store unmodified list in session.
cachedAvailableLdapGroups = allGroups;
- RoleManagerLocal roleManager = LookupUtil.getRoleManager();
//retrieve currently assigned groups
- assignedList = roleManager.findLdapGroupsByRole(role.getId(), PageControl.getUnlimitedInstance());
+ assignedList = ldapManager.findLdapGroupsByRole(role.getId(), PageControl.getUnlimitedInstance());
//trim already defined from all groups returned.
allGroups = filterExisting(assignedList, allGroups);
@@ -217,6 +221,30 @@ public class AddLdapGroupsFormPrepareAction extends TilesAction {
availableGroups.setTotalSize(groupLookup.size());
availableGroups.setPageControl(pca);
+ } catch (EJBException ejx) {
+ //this is the exception type thrown now that we use SLSB.Local methods
+ // mine out other exceptions
+ Exception cause = ejx.getCausedByException();
+ if (cause == null) {
+ ActionMessages actionMessages = new ActionMessages();
+ actionMessages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("errors.cam.general"));
+ saveErrors(request, actionMessages);
+ } else {
+ if (cause instanceof LdapFilterException) {
+ ActionMessages actionMessages = new ActionMessages();
+ actionMessages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(
+ "admin.role.LdapGroupFilterMessage"));
+ saveErrors(request, actionMessages);
+ } else if (cause instanceof LdapCommunicationException) {
+ ActionMessages actionMessages = new ActionMessages();
+ SystemManagerLocal manager = LookupUtil.getSystemManager();
+ Properties options = manager.getSystemConfiguration();
+ String providerUrl = options.getProperty(RHQConstants.LDAPUrl, "(unavailable)");
+ actionMessages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(
+ "admin.role.LdapCommunicationMessage", providerUrl));
+ saveErrors(request, actionMessages);
+ }
+ }
} catch (LdapFilterException lce) {
ActionMessages actionMessages = new ActionMessages();
actionMessages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("admin.role.LdapGroupFilterMessage"));
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/RemoveLdapGroupsAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/RemoveLdapGroupsAction.java
index fb359c6..48ab1c5 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/RemoveLdapGroupsAction.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/RemoveLdapGroupsAction.java
@@ -31,12 +31,16 @@ import org.rhq.core.util.collection.ArrayUtils;
import org.rhq.enterprise.gui.legacy.Constants;
import org.rhq.enterprise.gui.legacy.action.BaseAction;
import org.rhq.enterprise.gui.legacy.util.RequestUtils;
+import org.rhq.enterprise.server.resource.group.LdapGroupManagerLocal;
import org.rhq.enterprise.server.util.LookupUtil;
/**
* An Action that retrieves data to facilitate display of the form for removing groups to a role.
*/
public class RemoveLdapGroupsAction extends BaseAction {
+
+ LdapGroupManagerLocal ldapManager = LookupUtil.getLdapGroupManager();
+
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception {
Log log = LogFactory.getLog(RemoveLdapGroupsAction.class.getName());
@@ -46,7 +50,7 @@ public class RemoveLdapGroupsAction extends BaseAction {
int[] groupIds = ArrayUtils.unwrapArray(rmForm.getLdapGroups());
log.debug("removing groups " + groupIds + "] for role [" + roleId + "]");
- LookupUtil.getRoleManager().removeLdapGroupsFromRole(RequestUtils.getSubject(request), roleId, groupIds);
+ ldapManager.removeLdapGroupsFromRole(RequestUtils.getSubject(request), roleId, groupIds);
RequestUtils.setConfirmation(request, "admin.role.confirm.RemoveLdapGroups");
return returnSuccess(request, mapping, Constants.ROLE_PARAM, roleId);
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/ViewAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/ViewAction.java
index 3414dab..b2e884e 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/ViewAction.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/ViewAction.java
@@ -45,6 +45,7 @@ import org.rhq.enterprise.gui.legacy.action.WorkflowPrepareAction;
import org.rhq.enterprise.gui.legacy.util.RequestUtils;
import org.rhq.enterprise.gui.util.WebUtility;
import org.rhq.enterprise.server.authz.RoleManagerLocal;
+import org.rhq.enterprise.server.resource.group.LdapGroupManagerLocal;
import org.rhq.enterprise.server.resource.group.ResourceGroupManagerLocal;
import org.rhq.enterprise.server.util.LookupUtil;
@@ -52,6 +53,11 @@ import org.rhq.enterprise.server.util.LookupUtil;
* An Action that retrieves a specific role. This is executed when you view a specific role.
*/
public class ViewAction extends WorkflowPrepareAction {
+
+ LdapGroupManagerLocal ldapManager = LookupUtil.getLdapGroupManager();
+ RoleManagerLocal roleManager = LookupUtil.getRoleManager();
+ ResourceGroupManagerLocal groupManager = LookupUtil.getResourceGroupManager();
+
/**
*/
public ActionForward workflow(ComponentContext context, ActionMapping mapping, ActionForm form,
@@ -75,8 +81,8 @@ public class ViewAction extends WorkflowPrepareAction {
log.trace("group page control: " + pcg);
log.trace("ldap group page control: " + pcldap);
- RoleManagerLocal roleManager = LookupUtil.getRoleManager();
- ResourceGroupManagerLocal groupManager = LookupUtil.getResourceGroupManager();
+ // RoleManagerLocal roleManager = LookupUtil.getRoleManager();
+ // ResourceGroupManagerLocal groupManager = LookupUtil.getResourceGroupManager();
// get all the role permissions
Set<Permission> permissions = roleManager.getPermissions(roleId);
@@ -91,6 +97,7 @@ public class ViewAction extends WorkflowPrepareAction {
// get the subjects attached to the role
log.trace("getting users for role [" + roleId + "]");
+ // PageList<Subject> users = roleManager.findSubjectsByRole(roleId, pcu);
PageList<Subject> users = roleManager.findSubjectsByRole(roleId, pcu);
request.setAttribute(Constants.ROLE_USERS_ATTR, users);
@@ -104,7 +111,7 @@ public class ViewAction extends WorkflowPrepareAction {
request.setAttribute(Constants.NUM_RESGRPS_ATTR, new Integer(groups.getTotalSize()));
}
- PageList<LdapGroup> ldapGroups = roleManager.findLdapGroupsByRole(roleId, pcldap);
+ PageList<LdapGroup> ldapGroups = ldapManager.findLdapGroupsByRole(roleId, pcldap);
request.setAttribute(Constants.ROLE_LDAPGRPS_ATTR, ldapGroups);
if (ldapGroups == null) {
request.setAttribute(Constants.NUM_LDAPGRPS_ATTR, new Integer(0));
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/user/RegisterAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/user/RegisterAction.java
index 9d4ec7a..91980ad 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/user/RegisterAction.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/user/RegisterAction.java
@@ -23,6 +23,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Properties;
+import javax.ejb.EJBException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
@@ -44,10 +45,9 @@ import org.rhq.enterprise.gui.legacy.util.RequestUtils;
import org.rhq.enterprise.gui.legacy.util.SessionUtils;
import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.auth.SubjectManagerLocal;
-import org.rhq.enterprise.server.authz.RoleManagerLocal;
import org.rhq.enterprise.server.exception.LdapCommunicationException;
import org.rhq.enterprise.server.exception.LdapFilterException;
-import org.rhq.enterprise.server.resource.group.LdapGroupManager;
+import org.rhq.enterprise.server.resource.group.LdapGroupManagerLocal;
import org.rhq.enterprise.server.system.SystemManagerLocal;
import org.rhq.enterprise.server.util.LookupUtil;
@@ -55,6 +55,11 @@ import org.rhq.enterprise.server.util.LookupUtil;
* Registers a user. Triggered when authenticated via LDAP.
*/
public class RegisterAction extends BaseAction {
+
+ SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager();
+ SystemManagerLocal systemManager = LookupUtil.getSystemManager();
+ LdapGroupManagerLocal ldapManager = LookupUtil.getLdapGroupManager();
+
/**
* Create the user with the attributes specified in the given <code>NewForm</code> and save it into the session
* attribute <code>Constants.USER_ATTR</code>.
@@ -96,7 +101,6 @@ public class RegisterAction extends BaseAction {
String password = (String) session.getAttribute(Constants.PASSWORD_SES_ATTR);
session.removeAttribute(Constants.PASSWORD_SES_ATTR);
- SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager();
Subject superuser = subjectManager.getOverlord();
// create the subject, but don't add a principal since LDAP will handle authentication
@@ -118,8 +122,7 @@ public class RegisterAction extends BaseAction {
parms.put(Constants.USER_PARAM, newSubject.getId());
//BZ-580127: only do group authz check if one or both of group filter fields is set
- SystemManagerLocal manager = LookupUtil.getSystemManager();
- Properties options = manager.getSystemConfiguration();
+ Properties options = systemManager.getSystemConfiguration();
String groupFilter = (String) options.getProperty(RHQConstants.LDAPGroupFilter, "");
String groupMember = (String) options.getProperty(RHQConstants.LDAPGroupMember, "");
if ((groupFilter.trim().length() > 0) || (groupMember.trim().length() > 0)) {
@@ -127,11 +130,32 @@ public class RegisterAction extends BaseAction {
String provider = LookupUtil.getSystemManager().getSystemConfiguration().getProperty(
RHQConstants.JAASProvider);
if (RHQConstants.LDAPJAASProvider.equals(provider)) {
- List<String> groupNames = new ArrayList(LdapGroupManager.getInstance().findAvailableGroupsFor(
- newSubject.getName()));
- RoleManagerLocal roleManager = LookupUtil.getRoleManager();
- roleManager.assignRolesToLdapSubject(newSubject.getId(), groupNames);
-
+ List<String> groupNames = new ArrayList(ldapManager.findAvailableGroupsFor(newSubject.getName()));
+ ldapManager.assignRolesToLdapSubject(newSubject.getId(), groupNames);
+ }
+ } catch (EJBException ejx) {
+ //this is the exception type thrown now that we use SLSB.Local methods
+ // mine out other exceptions
+ Exception cause = ejx.getCausedByException();
+ if (cause == null) {
+ ActionMessages actionMessages = new ActionMessages();
+ actionMessages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("errors.cam.general"));
+ saveErrors(request, actionMessages);
+ } else {
+ if (cause instanceof LdapFilterException) {
+ ActionMessages actionMessages = new ActionMessages();
+ actionMessages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(
+ "admin.role.LdapGroupFilterMessage"));
+ saveErrors(request, actionMessages);
+ } else if (cause instanceof LdapCommunicationException) {
+ ActionMessages actionMessages = new ActionMessages();
+ SystemManagerLocal manager = LookupUtil.getSystemManager();
+ options = manager.getSystemConfiguration();
+ String providerUrl = options.getProperty(RHQConstants.LDAPUrl, "(unavailable)");
+ actionMessages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(
+ "admin.role.LdapCommunicationMessage", providerUrl));
+ saveErrors(request, actionMessages);
+ }
}
} catch (LdapFilterException lce) {
ActionMessages actionMessages = new ActionMessages();
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerBean.java
index 8e4d96e..00d4c31 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerBean.java
@@ -20,9 +20,7 @@ package org.rhq.enterprise.server.authz;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collections;
import java.util.HashSet;
-import java.util.LinkedList;
import java.util.List;
import java.util.Set;
@@ -40,7 +38,6 @@ import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.authz.Permission;
import org.rhq.core.domain.authz.Role;
import org.rhq.core.domain.criteria.RoleCriteria;
-import org.rhq.core.domain.resource.group.LdapGroup;
import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
@@ -91,29 +88,6 @@ public class RoleManagerBean implements RoleManagerLocal, RoleManagerRemote {
return roles;
}
- @Override
- public PageList<LdapGroup> findLdapGroupsByRole(int roleId, PageControl pageControl) {
- Role role = entityManager.find(Role.class, roleId);
- if (role == null) {
- throw new IllegalArgumentException("Could not find role[" + roleId + "] to lookup ldap Groups on");
- }
- return new PageList<LdapGroup>(role.getLdapGroups(), role.getLdapGroups().size(), pageControl);
- }
-
- public PageList<LdapGroup> findLdapGroups(PageControl pc) {
-
- pc.initDefaultOrderingField("g.name");
-
- String queryName = LdapGroup.QUERY_FIND_ALL;
- Query queryCount = PersistenceUtility.createCountQuery(entityManager, queryName);
- Query query = PersistenceUtility.createQueryWithOrderBy(entityManager, queryName, pc);
-
- long count = (Long) queryCount.getSingleResult();
- // List<Role> roles = query.getResultList();
- List<LdapGroup> groups = query.getResultList();
- return new PageList<LdapGroup>(groups, (int) count, pc);
- }
-
/**
* @see org.rhq.enterprise.server.authz.RoleManagerLocal#findRoles(PageControl)
*/
@@ -466,83 +440,6 @@ public class RoleManagerBean implements RoleManagerLocal, RoleManagerRemote {
}
}
- /**
- * @see org.rhq.enterprise.server.authz.RoleManagerLocal#addResourceGroupsToRole(Subject, int, int[])
- */
- @RequiredPermission(Permission.MANAGE_SECURITY)
- public void addLdapGroupsToRole(Subject subject, int roleId, List<String> groupIds) {
- if ((groupIds != null) && (groupIds.size() > 0)) {
- Role role = entityManager.find(Role.class, roleId);
- if (role == null) {
- throw new IllegalArgumentException("Could not find role[" + roleId + "] to add resourceGroups to");
- }
- role.getLdapGroups().size(); // load them in
-
- for (String groupId : groupIds) {
- LdapGroup group = new LdapGroup();
- group.setName(groupId);
- if (role == null) {
- throw new IllegalArgumentException("Tried to add ldapGroup[" + groupId + "] to role[" + roleId
- + "], but resourceGroup was not found");
- }
- role.addLdapGroup(group);
- }
- }
- }
-
- /**
- * @see org.rhq.enterprise.server.authz.RoleManagerLocal#removeLdapGroupsFromRole(Subject, int, int[])
- */
-
- @RequiredPermission(Permission.MANAGE_SECURITY)
- public void removeLdapGroupsFromRole(Subject subject, int roleId, int[] groupIds) {
- if ((groupIds != null) && (groupIds.length > 0)) {
- Role role = entityManager.find(Role.class, roleId);
- if (role == null) {
- throw new IllegalArgumentException("Could not find role[" + roleId + "] to remove resourceGroups from");
- }
- role.getLdapGroups().size(); // load them in
-
- for (Integer groupId : groupIds) {
- LdapGroup doomedGroup = entityManager.find(LdapGroup.class, groupId);
- if (doomedGroup == null) {
- throw new IllegalArgumentException("Tried to remove doomedGroup[" + groupId + "] from role["
- + roleId + "], but subject was not found");
- }
- role.removeLdapGroup(doomedGroup);
- }
-
- Query purgeQuery = entityManager.createNamedQuery(LdapGroup.DELETE_BY_ID);
-
- List<Integer> ids = new LinkedList<Integer>();
- for (int i : groupIds) {
- ids.add(i);
- }
- purgeQuery.setParameter("ids", ids);
- purgeQuery.executeUpdate();
- }
- }
-
- private List<Role> findRolesByLdapGroupNames(List<String> ldapGroupNames) {
- if (ldapGroupNames.isEmpty()) {
- return Collections.EMPTY_LIST;
- }
- Query query = entityManager.createNamedQuery(LdapGroup.FIND_BY_ROLES_GROUP_NAMES);
- query.setParameter("names", ldapGroupNames);
- return (List<Role>) query.getResultList();
- }
-
- public void assignRolesToLdapSubject(int subjectId, List<String> ldapGroupNames) {
- Subject sub = entityManager.find(Subject.class, subjectId);
- List<Role> roles = findRolesByLdapGroupNames(ldapGroupNames);
- sub.getRoles().clear();
- sub.getLdapRoles().clear();
- for (Role role : roles) {
- sub.addRole(role);
- sub.addLdapRole(role);
- }
- }
-
private void processDependentPermissions(Role role) {
/*
* if you can control user/roles, then you can give yourself permissions, too; so we might as well
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerLocal.java
index b89020f..58f962a 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerLocal.java
@@ -18,7 +18,6 @@
*/
package org.rhq.enterprise.server.authz;
-import java.util.List;
import java.util.Set;
import javax.ejb.Local;
@@ -27,7 +26,6 @@ import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.authz.Permission;
import org.rhq.core.domain.authz.Role;
import org.rhq.core.domain.criteria.RoleCriteria;
-import org.rhq.core.domain.resource.group.LdapGroup;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
@@ -161,8 +159,6 @@ public interface RoleManagerLocal {
Role getRole(Subject subject, int roleId);
- PageList<LdapGroup> findLdapGroupsByRole(int roleId, PageControl pageControl);
-
PageList<Role> findSubjectAssignedRoles(Subject subject, int subjectId, PageControl pc);
//This is a proxy of getAvailableRolesForSubject but without pendingRoleIds as required by remote spec
@@ -202,8 +198,6 @@ public interface RoleManagerLocal {
void addRolesToResourceGroup(Subject subject, int groupId, int[] roleIds);
- void addLdapGroupsToRole(Subject subject, int roleId, List<String> groupIds);
-
/**
* Removes the given resource groups from the given role.
*
@@ -215,11 +209,6 @@ public interface RoleManagerLocal {
void removeRolesFromResourceGroup(Subject subject, int groupId, int[] roleIds);
- void removeLdapGroupsFromRole(Subject subject, int roleId, int[] groupIds);
-
PageList<Role> findRolesByCriteria(Subject subject, RoleCriteria criteria);
- void assignRolesToLdapSubject(int subjectId, List<String> ldapGroupNames);
-
- PageList<LdapGroup> findLdapGroups(PageControl pc);
}
\ No newline at end of file
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/LdapLoginModule.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/LdapLoginModule.java
index d6fcaa7..d6e6ae8 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/LdapLoginModule.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/LdapLoginModule.java
@@ -45,7 +45,7 @@ import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.server.auth.SubjectManagerLocal;
import org.rhq.enterprise.server.authz.RoleManagerLocal;
-import org.rhq.enterprise.server.resource.group.LdapGroupManager;
+import org.rhq.enterprise.server.resource.group.LdapGroupManagerLocal;
import org.rhq.enterprise.server.util.LookupUtil;
import org.rhq.enterprise.server.util.security.UntrustedSSLSocketFactory;
@@ -94,6 +94,8 @@ import org.rhq.enterprise.server.util.security.UntrustedSSLSocketFactory;
public class LdapLoginModule extends UsernamePasswordLoginModule {
private Log log = LogFactory.getLog(LdapLoginModule.class);
+ LdapGroupManagerLocal ldapManager = LookupUtil.getLdapGroupManager();
+
// The delimimiter to use when specifiying multiple BaseDN's.
private static final String BASEDN_DELIMITER = ";";
@@ -218,11 +220,11 @@ public class LdapLoginModule extends UsernamePasswordLoginModule {
//BUT still must always return true as authz is handled by RHQ if roles/groups correct
//retrieve all ldap groups that this user is authorized for based on ldap group filter and group member settings
- Set<String> authorizedLdapGroups = LdapGroupManager.getInstance().findAvailableGroupsFor(userName);
+ Set<String> authorizedLdapGroups = ldapManager.findAvailableGroupsFor(userName);
RoleManagerLocal roleManager = LookupUtil.getRoleManager();
//find all currently mapped ldap groups
- PageList<LdapGroup> allCurrentLdapGroupsRegistered = roleManager.findLdapGroups(PageControl
+ PageList<LdapGroup> allCurrentLdapGroupsRegistered = ldapManager.findLdapGroups(PageControl
.getUnlimitedInstance());
//find all roles for currently mapped ldap groups.
@@ -239,7 +241,7 @@ public class LdapLoginModule extends UsernamePasswordLoginModule {
//else add this subject back to all AuthoriziedLdapGroups
//lookup all roles that map to the authorizedLdapGroup names
List authorizedList = new ArrayList(authorizedLdapGroups);
- roleManager.assignRolesToLdapSubject(ldapSubject.getId(), authorizedList);
+ ldapManager.assignRolesToLdapSubject(ldapSubject.getId(), authorizedList);
}
return true;
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManager.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManager.java
deleted file mode 100644
index e372777..0000000
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManager.java
+++ /dev/null
@@ -1,304 +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.enterprise.server.resource.group;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-
-import javax.naming.Context;
-import javax.naming.NamingEnumeration;
-import javax.naming.NamingException;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.InvalidSearchFilterException;
-import javax.naming.directory.SearchControls;
-import javax.naming.directory.SearchResult;
-import javax.naming.ldap.InitialLdapContext;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.rhq.enterprise.server.RHQConstants;
-import org.rhq.enterprise.server.exception.LdapCommunicationException;
-import org.rhq.enterprise.server.exception.LdapFilterException;
-import org.rhq.enterprise.server.system.SystemManagerLocal;
-import org.rhq.enterprise.server.util.LookupUtil;
-import org.rhq.enterprise.server.util.security.UntrustedSSLSocketFactory;
-
-/**
- * @author paji
- */
-public class LdapGroupManager {
- private static final LdapGroupManager INSTANCE = new LdapGroupManager();
- private static final String BASEDN_DELIMITER = ";";
- private Log log = LogFactory.getLog(LdapGroupManager.class);
-
- private LdapGroupManager() {
- }
-
- public static LdapGroupManager getInstance() {
- return INSTANCE;
- }
-
- public Set<Map<String, String>> findAvailableGroups() {
- SystemManagerLocal manager = LookupUtil.getSystemManager();
-
- Properties options = manager.getSystemConfiguration();
- String groupFilter = (String) options.get(RHQConstants.LDAPGroupFilter);
- String filter = String.format("(%s)", groupFilter);
-
- return buildGroup(options, filter);
- }
-
- public Set<String> findAvailableGroupsFor(String userName) {
- SystemManagerLocal manager = LookupUtil.getSystemManager();
- Properties options = manager.getSystemConfiguration();
- String groupFilter = (String) options.getProperty(RHQConstants.LDAPGroupFilter, "");
- String groupMember = (String) options.getProperty(RHQConstants.LDAPGroupMember, "");
- String userDN = getUserDN(options, userName);
- //TODO: spinder 4/21/10 put in error/debug logging messages for badly formatted filter combinations
- String filter = "";
- //form assumes examples where groupFilter is like 'objecclass=groupOfNames' and groupMember is 'member'
- // to produce ldaf filter like (&(objecclass=groupOfNames)(member=cn=Administrator,ou=People,dc=test,dc=com))
- filter = String.format("(&(%s)(%s=%s))", groupFilter, groupMember, userDN);
-
- Set<Map<String, String>> matched = buildGroup(options, filter);
-
- Set<String> ldapSet = new HashSet<String>();
- for (Map<String, String> match : matched) {
- ldapSet.add(match.get("id"));
- }
- return ldapSet;
- }
-
- private String getUserDN(Properties options, String userName) {
- // Load our LDAP specific properties
- Properties env = getProperties(options);
-
- // Load the BaseDN
- // Load the BaseDN
- String baseDN = (String) options.get(RHQConstants.LDAPBaseDN);
-
- // Load the LoginProperty
- String loginProperty = (String) options.get(RHQConstants.LDAPLoginProperty);
- if (loginProperty == null) {
- // Use the default
- loginProperty = "cn";
- }
- // Load any information we may need to bind
- String bindDN = (String) options.get(RHQConstants.LDAPBindDN);
- String bindPW = (String) options.get(RHQConstants.LDAPBindPW);
-
- // Load any search filter
- String searchFilter = (String) options.get(RHQConstants.LDAPFilter);
- if (bindDN != null) {
- env.setProperty(Context.SECURITY_PRINCIPAL, bindDN);
- env.setProperty(Context.SECURITY_CREDENTIALS, bindPW);
- env.setProperty(Context.SECURITY_AUTHENTICATION, "simple");
- }
-
- try {
- InitialLdapContext ctx = new InitialLdapContext(env, null);
- SearchControls searchControls = getSearchControls();
-
- // Add the search filter if specified. This only allows for a single search filter.. i.e. foo=bar.
- String filter;
- if ((searchFilter != null) && (searchFilter.length() != 0)) {
- filter = "(&(" + loginProperty + "=" + userName + ")" + "(" + searchFilter + "))";
- } else {
- filter = "(" + loginProperty + "=" + userName + ")";
- }
-
- log.debug("Using LDAP filter=" + filter);
-
- // Loop through each configured base DN. It may be useful
- // in the future to allow for a filter to be configured for
- // each BaseDN, but for now the filter will apply to all.
- String[] baseDNs = baseDN.split(BASEDN_DELIMITER);
- for (int x = 0; x < baseDNs.length; x++) {
- NamingEnumeration answer = ctx.search(baseDNs[x], filter, searchControls);
- if (!answer.hasMoreElements()) { //BZ:582471- ldap api bug change
- log.debug("User " + userName + " not found for BaseDN " + baseDNs[x]);
- // Nothing found for this DN, move to the next one if we have one.
- continue;
- }
-
- // We use the first match
- SearchResult si = (SearchResult) answer.next();
-
- // Construct the UserDN
- String userDN = si.getName() + "," + baseDNs[x];
- return userDN;
- }
-
- // If we try all the BaseDN's and have not found a match, return false
- return "";
- } catch (NamingException e) {
- throw new RuntimeException(e);
- }
- }
-
- /**
- * @throws NamingException
- * @see org.jboss.security.auth.spi.UsernamePasswordLoginModule#validatePassword(java.lang.String,java.lang.String)
- */
- protected Set<Map<String, String>> buildGroup(Properties options, String filter) {
- Set<Map<String, String>> ret = new HashSet<Map<String, String>>();
- // Load our LDAP specific properties
- Properties env = getProperties(options);
-
- // Load the BaseDN
- String baseDN = (String) options.get(RHQConstants.LDAPBaseDN);
-
- // Load the LoginProperty
- String loginProperty = (String) options.get(RHQConstants.LDAPLoginProperty);
- if (loginProperty == null) {
- // Use the default
- loginProperty = "cn";
- }
- // Load any information we may need to bind
- String bindDN = (String) options.get(RHQConstants.LDAPBindDN);
- String bindPW = (String) options.get(RHQConstants.LDAPBindPW);
- if (bindDN != null) {
- env.setProperty(Context.SECURITY_PRINCIPAL, bindDN);
- env.setProperty(Context.SECURITY_CREDENTIALS, bindPW);
- env.setProperty(Context.SECURITY_AUTHENTICATION, "simple");
- }
- try {
- InitialLdapContext ctx = new InitialLdapContext(env, null);
- SearchControls searchControls = getSearchControls();
- /*String filter = "(&(objectclass=groupOfUniqueNames)(uniqueMember=uid=" + userName
- + ",ou=People, dc=rhndev, dc=redhat, dc=com))";*/
-
- // Loop through each configured base DN. It may be useful
- // in the future to allow for a filter to be configured for
- // each BaseDN, but for now the filter will apply to all.
- String[] baseDNs = baseDN.split(BASEDN_DELIMITER);
-
- for (int x = 0; x < baseDNs.length; x++) {
- NamingEnumeration answer = ctx.search(baseDNs[x], filter, searchControls);
- boolean ldapApiEnumerationBugEncountered = false;
- while ((!ldapApiEnumerationBugEncountered) && answer.hasMoreElements()) {//BZ:582471- ldap api bug change
- // We use the first match
- SearchResult si = null;
- try {
- si = (SearchResult) answer.next();
- } catch (NullPointerException npe) {
- ldapApiEnumerationBugEncountered = true;
- break;
- }
- Map<String, String> entry = new HashMap<String, String>();
- String name = (String) si.getAttributes().get("cn").get();
- name = name.trim();
- Attribute desc = si.getAttributes().get("description");
- String description = desc != null ? (String) desc.get() : "";
- description = description.trim();
- entry.put("id", name);
- entry.put("name", name);
- entry.put("description", description);
- ret.add(entry);
- }
- }
- } catch (NamingException e) {
- if (e instanceof InvalidSearchFilterException) {
- InvalidSearchFilterException fException = (InvalidSearchFilterException) e;
- String message = "The ldap group filter defined is invalid ";
- log.error(message, fException);
- throw new LdapFilterException(message + " " + fException.getMessage());
- }
- //TODO: check for ldap connection/unavailable/etc. exceptions.
- else {
- log.error("LDAP communication error: " + e.getMessage(), e);
- throw new LdapCommunicationException(e);
- }
- }
-
- return ret;
- }
-
- /**
- * Load a default set of properties to use when connecting to the LDAP server. If basic authentication is needed,
- * the caller must set Context.SECURITY_PRINCIPAL, Context.SECURITY_CREDENTIALS and Context.SECURITY_AUTHENTICATION
- * appropriately.
- *
- * @return properties that are to be used when connecting to LDAP server
- */
- private Properties getProperties(Properties options) {
- Properties env = new Properties(options);
- // Set our default factory name if one is not given
- String factoryName = env.getProperty(RHQConstants.LDAPFactory);
- env.setProperty(Context.INITIAL_CONTEXT_FACTORY, factoryName);
-
- // Setup SSL if requested
- String protocol = env.getProperty(RHQConstants.LDAPProtocol);
- if ((protocol != null) && protocol.equals("ssl")) {
- String ldapSocketFactory = env.getProperty("java.naming.ldap.factory.socket");
- if (ldapSocketFactory == null) {
- env.put("java.naming.ldap.factory.socket", UntrustedSSLSocketFactory.class.getName());
- }
- env.put(Context.SECURITY_PROTOCOL, "ssl");
- }
-
- // Set the LDAP url
- String providerUrl = env.getProperty(RHQConstants.LDAPUrl);
- if (providerUrl == null) {
- providerUrl = "ldap://localhost:" + (((protocol != null) && protocol.equals("ssl")) ? "636" : "389");
- }
-
- env.setProperty(Context.PROVIDER_URL, providerUrl);
-
- // Follow referrals automatically
- env.setProperty(Context.REFERRAL, "ignore"); //BZ:582471- active directory query change
-
- return env;
- }
-
- /**
- * A simple method to construct a SearchControls object for use when doing LDAP searches. All of the defaults are
- * used, with the exception of the scope, which is set to SUBTREE rather than the default of ONE_LEVEL
- *
- * @return controls what is searched in LDAP
- */
- private SearchControls getSearchControls() {
- // Set the scope to subtree, default is one-level
- int scope = SearchControls.SUBTREE_SCOPE;
-
- // No limit on the time waiting for a response
- int timeLimit = 0;
-
- // No limit on the number of entries returned
- long countLimit = 0;
-
- // Attributes to return.
- String[] returnedAttributes = null;
-
- // Don't return the object
- boolean returnObject = false;
-
- // No dereferencing during the search
- boolean deference = false;
-
- SearchControls constraints = new SearchControls(scope, countLimit, timeLimit, returnedAttributes, returnObject,
- deference);
- return constraints;
- }
-}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManagerBean.java
new file mode 100644
index 0000000..63e36db
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManagerBean.java
@@ -0,0 +1,426 @@
+/*
+ * 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.resource.group;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import javax.ejb.EJB;
+import javax.ejb.Stateless;
+import javax.naming.Context;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.InvalidSearchFilterException;
+import javax.naming.directory.SearchControls;
+import javax.naming.directory.SearchResult;
+import javax.naming.ldap.InitialLdapContext;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.Query;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.authz.Permission;
+import org.rhq.core.domain.authz.Role;
+import org.rhq.core.domain.resource.group.LdapGroup;
+import org.rhq.core.domain.util.PageControl;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.core.server.PersistenceUtility;
+import org.rhq.enterprise.server.RHQConstants;
+import org.rhq.enterprise.server.auth.SubjectManagerLocal;
+import org.rhq.enterprise.server.authz.RequiredPermission;
+import org.rhq.enterprise.server.exception.LdapCommunicationException;
+import org.rhq.enterprise.server.exception.LdapFilterException;
+import org.rhq.enterprise.server.system.SystemManagerLocal;
+import org.rhq.enterprise.server.util.security.UntrustedSSLSocketFactory;
+
+/**
+ * This bean provides functionality to manipulate the ldap auth/authz funcitonality.
+ * That is, adding/modifying/deleting ldap group/users and their
+ * associated subjects and permissions are performed by this manager.
+ * @author paji
+ * @author Simeon Pinder
+ */
+@Stateless
+public class LdapGroupManagerBean implements LdapGroupManagerLocal {
+
+ // private static final LdapGroupManagerBean INSTANCE = new LdapGroupManagerBean();
+ private Log log = LogFactory.getLog(LdapGroupManagerBean.class);
+
+ private static final String BASEDN_DELIMITER = ";";
+
+ @PersistenceContext(unitName = RHQConstants.PERSISTENCE_UNIT_NAME)
+ private EntityManager entityManager;
+
+ @EJB
+ private SubjectManagerLocal subjectManager;
+
+ @EJB
+ private SystemManagerLocal systemManager;
+
+ public Set<Map<String, String>> findAvailableGroups() {
+ Properties options = systemManager.getSystemConfiguration();
+ String groupFilter = (String) options.get(RHQConstants.LDAPGroupFilter);
+ String filter = String.format("(%s)", groupFilter);
+
+ return buildGroup(options, filter);
+ }
+
+ public Set<String> findAvailableGroupsFor(String userName) {
+ Properties options = systemManager.getSystemConfiguration();
+ String groupFilter = (String) options.getProperty(RHQConstants.LDAPGroupFilter, "");
+ String groupMember = (String) options.getProperty(RHQConstants.LDAPGroupMember, "");
+ String userDN = getUserDN(options, userName);
+ //TODO: spinder 4/21/10 put in error/debug logging messages for badly formatted filter combinations
+ String filter = "";
+ //form assumes examples where groupFilter is like 'objecclass=groupOfNames' and groupMember is 'member'
+ // to produce ldaf filter like (&(objecclass=groupOfNames)(member=cn=Administrator,ou=People,dc=test,dc=com))
+ filter = String.format("(&(%s)(%s=%s))", groupFilter, groupMember, userDN);
+
+ Set<Map<String, String>> matched = buildGroup(options, filter);
+
+ Set<String> ldapSet = new HashSet<String>();
+ for (Map<String, String> match : matched) {
+ ldapSet.add(match.get("id"));
+ }
+ return ldapSet;
+ }
+
+ /**
+ * @see org.rhq.enterprise.server.authz.RoleManagerLocal#addResourceGroupsToRole(Subject, int, int[])
+ */
+ @RequiredPermission(Permission.MANAGE_SECURITY)
+ public void addLdapGroupsToRole(Subject subject, int roleId, List<String> groupIds) {
+ if ((groupIds != null) && (groupIds.size() > 0)) {
+ Role role = entityManager.find(Role.class, roleId);
+ if (role == null) {
+ throw new IllegalArgumentException("Could not find role[" + roleId + "] to add resourceGroups to");
+ }
+ role.getLdapGroups().size(); // load them in
+
+ for (String groupId : groupIds) {
+ LdapGroup group = new LdapGroup();
+ group.setName(groupId);
+ if (role == null) {
+ throw new IllegalArgumentException("Tried to add ldapGroup[" + groupId + "] to role[" + roleId
+ + "], but resourceGroup was not found");
+ }
+ role.addLdapGroup(group);
+ }
+ }
+ }
+
+ /**
+ * @see org.rhq.enterprise.server.authz.RoleManagerLocal#removeLdapGroupsFromRole(Subject, int, int[])
+ */
+
+ @RequiredPermission(Permission.MANAGE_SECURITY)
+ public void removeLdapGroupsFromRole(Subject subject, int roleId, int[] groupIds) {
+ if ((groupIds != null) && (groupIds.length > 0)) {
+ Role role = entityManager.find(Role.class, roleId);
+ if (role == null) {
+ throw new IllegalArgumentException("Could not find role[" + roleId + "] to remove resourceGroups from");
+ }
+ role.getLdapGroups().size(); // load them in
+
+ for (Integer groupId : groupIds) {
+ LdapGroup doomedGroup = entityManager.find(LdapGroup.class, groupId);
+ if (doomedGroup == null) {
+ throw new IllegalArgumentException("Tried to remove doomedGroup[" + groupId + "] from role["
+ + roleId + "], but subject was not found");
+ }
+ role.removeLdapGroup(doomedGroup);
+ }
+
+ Query purgeQuery = entityManager.createNamedQuery(LdapGroup.DELETE_BY_ID);
+
+ List<Integer> ids = new LinkedList<Integer>();
+ for (int i : groupIds) {
+ ids.add(i);
+ }
+ purgeQuery.setParameter("ids", ids);
+ purgeQuery.executeUpdate();
+ }
+ }
+
+ private List<Role> findRolesByLdapGroupNames(List<String> ldapGroupNames) {
+ if (ldapGroupNames.isEmpty()) {
+ return Collections.EMPTY_LIST;
+ }
+ Query query = entityManager.createNamedQuery(LdapGroup.FIND_BY_ROLES_GROUP_NAMES);
+ query.setParameter("names", ldapGroupNames);
+ return (List<Role>) query.getResultList();
+ }
+
+ public void assignRolesToLdapSubject(int subjectId, List<String> ldapGroupNames) {
+ Subject sub = entityManager.find(Subject.class, subjectId);
+ List<Role> roles = findRolesByLdapGroupNames(ldapGroupNames);
+ sub.getRoles().clear();
+ sub.getLdapRoles().clear();
+ for (Role role : roles) {
+ sub.addRole(role);
+ sub.addLdapRole(role);
+ }
+ }
+
+ @Override
+ public PageList<LdapGroup> findLdapGroupsByRole(int roleId, PageControl pageControl) {
+ Role role = entityManager.find(Role.class, roleId);
+ if (role == null) {
+ throw new IllegalArgumentException("Could not find role[" + roleId + "] to lookup ldap Groups on");
+ }
+ return new PageList<LdapGroup>(role.getLdapGroups(), role.getLdapGroups().size(), pageControl);
+ }
+
+ public PageList<LdapGroup> findLdapGroups(PageControl pc) {
+
+ pc.initDefaultOrderingField("g.name");
+
+ String queryName = LdapGroup.QUERY_FIND_ALL;
+ Query queryCount = PersistenceUtility.createCountQuery(entityManager, queryName);
+ Query query = PersistenceUtility.createQueryWithOrderBy(entityManager, queryName, pc);
+
+ long count = (Long) queryCount.getSingleResult();
+ // List<Role> roles = query.getResultList();
+ List<LdapGroup> groups = query.getResultList();
+ return new PageList<LdapGroup>(groups, (int) count, pc);
+ }
+
+ private String getUserDN(Properties options, String userName) {
+ // Load our LDAP specific properties
+ Properties env = getProperties(options);
+
+ // Load the BaseDN
+ // Load the BaseDN
+ String baseDN = (String) options.get(RHQConstants.LDAPBaseDN);
+
+ // Load the LoginProperty
+ String loginProperty = (String) options.get(RHQConstants.LDAPLoginProperty);
+ if (loginProperty == null) {
+ // Use the default
+ loginProperty = "cn";
+ }
+ // Load any information we may need to bind
+ String bindDN = (String) options.get(RHQConstants.LDAPBindDN);
+ String bindPW = (String) options.get(RHQConstants.LDAPBindPW);
+
+ // Load any search filter
+ String searchFilter = (String) options.get(RHQConstants.LDAPFilter);
+ if (bindDN != null) {
+ env.setProperty(Context.SECURITY_PRINCIPAL, bindDN);
+ env.setProperty(Context.SECURITY_CREDENTIALS, bindPW);
+ env.setProperty(Context.SECURITY_AUTHENTICATION, "simple");
+ }
+
+ try {
+ InitialLdapContext ctx = new InitialLdapContext(env, null);
+ SearchControls searchControls = getSearchControls();
+
+ // Add the search filter if specified. This only allows for a single search filter.. i.e. foo=bar.
+ String filter;
+ if ((searchFilter != null) && (searchFilter.length() != 0)) {
+ filter = "(&(" + loginProperty + "=" + userName + ")" + "(" + searchFilter + "))";
+ } else {
+ filter = "(" + loginProperty + "=" + userName + ")";
+ }
+
+ log.debug("Using LDAP filter=" + filter);
+
+ // Loop through each configured base DN. It may be useful
+ // in the future to allow for a filter to be configured for
+ // each BaseDN, but for now the filter will apply to all.
+ String[] baseDNs = baseDN.split(BASEDN_DELIMITER);
+ for (int x = 0; x < baseDNs.length; x++) {
+ NamingEnumeration answer = ctx.search(baseDNs[x], filter, searchControls);
+ if (!answer.hasMoreElements()) { //BZ:582471- ldap api bug change
+ log.debug("User " + userName + " not found for BaseDN " + baseDNs[x]);
+ // Nothing found for this DN, move to the next one if we have one.
+ continue;
+ }
+
+ // We use the first match
+ SearchResult si = (SearchResult) answer.next();
+
+ // Construct the UserDN
+ String userDN = si.getName() + "," + baseDNs[x];
+ return userDN;
+ }
+
+ // If we try all the BaseDN's and have not found a match, return false
+ return "";
+ } catch (NamingException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * @throws NamingException
+ * @see org.jboss.security.auth.spi.UsernamePasswordLoginModule#validatePassword(java.lang.String,java.lang.String)
+ */
+ protected Set<Map<String, String>> buildGroup(Properties options, String filter) {
+ Set<Map<String, String>> ret = new HashSet<Map<String, String>>();
+ // Load our LDAP specific properties
+ Properties env = getProperties(options);
+
+ // Load the BaseDN
+ String baseDN = (String) options.get(RHQConstants.LDAPBaseDN);
+
+ // Load the LoginProperty
+ String loginProperty = (String) options.get(RHQConstants.LDAPLoginProperty);
+ if (loginProperty == null) {
+ // Use the default
+ loginProperty = "cn";
+ }
+ // Load any information we may need to bind
+ String bindDN = (String) options.get(RHQConstants.LDAPBindDN);
+ String bindPW = (String) options.get(RHQConstants.LDAPBindPW);
+ if (bindDN != null) {
+ env.setProperty(Context.SECURITY_PRINCIPAL, bindDN);
+ env.setProperty(Context.SECURITY_CREDENTIALS, bindPW);
+ env.setProperty(Context.SECURITY_AUTHENTICATION, "simple");
+ }
+ try {
+ InitialLdapContext ctx = new InitialLdapContext(env, null);
+ SearchControls searchControls = getSearchControls();
+ /*String filter = "(&(objectclass=groupOfUniqueNames)(uniqueMember=uid=" + userName
+ + ",ou=People, dc=rhndev, dc=redhat, dc=com))";*/
+
+ // Loop through each configured base DN. It may be useful
+ // in the future to allow for a filter to be configured for
+ // each BaseDN, but for now the filter will apply to all.
+ String[] baseDNs = baseDN.split(BASEDN_DELIMITER);
+
+ for (int x = 0; x < baseDNs.length; x++) {
+ NamingEnumeration answer = ctx.search(baseDNs[x], filter, searchControls);
+ boolean ldapApiEnumerationBugEncountered = false;
+ while ((!ldapApiEnumerationBugEncountered) && answer.hasMoreElements()) {//BZ:582471- ldap api bug change
+ // We use the first match
+ SearchResult si = null;
+ try {
+ si = (SearchResult) answer.next();
+ } catch (NullPointerException npe) {
+ ldapApiEnumerationBugEncountered = true;
+ break;
+ }
+ Map<String, String> entry = new HashMap<String, String>();
+ String name = (String) si.getAttributes().get("cn").get();
+ name = name.trim();
+ Attribute desc = si.getAttributes().get("description");
+ String description = desc != null ? (String) desc.get() : "";
+ description = description.trim();
+ entry.put("id", name);
+ entry.put("name", name);
+ entry.put("description", description);
+ ret.add(entry);
+ }
+ }
+ } catch (NamingException e) {
+ if (e instanceof InvalidSearchFilterException) {
+ InvalidSearchFilterException fException = (InvalidSearchFilterException) e;
+ String message = "The ldap group filter defined is invalid ";
+ log.error(message, fException);
+ throw new LdapFilterException(message + " " + fException.getMessage());
+ }
+ //TODO: check for ldap connection/unavailable/etc. exceptions.
+ else {
+ log.error("LDAP communication error: " + e.getMessage(), e);
+ throw new LdapCommunicationException(e);
+ }
+ }
+
+ return ret;
+ }
+
+ /**
+ * Load a default set of properties to use when connecting to the LDAP server. If basic authentication is needed,
+ * the caller must set Context.SECURITY_PRINCIPAL, Context.SECURITY_CREDENTIALS and Context.SECURITY_AUTHENTICATION
+ * appropriately.
+ *
+ * @return properties that are to be used when connecting to LDAP server
+ */
+ private Properties getProperties(Properties options) {
+ Properties env = new Properties(options);
+ // Set our default factory name if one is not given
+ String factoryName = env.getProperty(RHQConstants.LDAPFactory);
+ env.setProperty(Context.INITIAL_CONTEXT_FACTORY, factoryName);
+
+ // Setup SSL if requested
+ String protocol = env.getProperty(RHQConstants.LDAPProtocol);
+ if ((protocol != null) && protocol.equals("ssl")) {
+ String ldapSocketFactory = env.getProperty("java.naming.ldap.factory.socket");
+ if (ldapSocketFactory == null) {
+ env.put("java.naming.ldap.factory.socket", UntrustedSSLSocketFactory.class.getName());
+ }
+ env.put(Context.SECURITY_PROTOCOL, "ssl");
+ }
+
+ // Set the LDAP url
+ String providerUrl = env.getProperty(RHQConstants.LDAPUrl);
+ if (providerUrl == null) {
+ providerUrl = "ldap://localhost:" + (((protocol != null) && protocol.equals("ssl")) ? "636" : "389");
+ }
+
+ env.setProperty(Context.PROVIDER_URL, providerUrl);
+
+ // Follow referrals automatically
+ env.setProperty(Context.REFERRAL, "ignore"); //BZ:582471- active directory query change
+
+ return env;
+ }
+
+ /**
+ * A simple method to construct a SearchControls object for use when doing LDAP searches. All of the defaults are
+ * used, with the exception of the scope, which is set to SUBTREE rather than the default of ONE_LEVEL
+ *
+ * @return controls what is searched in LDAP
+ */
+ private SearchControls getSearchControls() {
+ // Set the scope to subtree, default is one-level
+ int scope = SearchControls.SUBTREE_SCOPE;
+
+ // No limit on the time waiting for a response
+ int timeLimit = 0;
+
+ // No limit on the number of entries returned
+ long countLimit = 0;
+
+ // Attributes to return.
+ String[] returnedAttributes = null;
+
+ // Don't return the object
+ boolean returnObject = false;
+
+ // No dereferencing during the search
+ boolean deference = false;
+
+ SearchControls constraints = new SearchControls(scope, countLimit, timeLimit, returnedAttributes, returnObject,
+ deference);
+ return constraints;
+ }
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManagerLocal.java
new file mode 100644
index 0000000..6709b32
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManagerLocal.java
@@ -0,0 +1,53 @@
+/*
+ * 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.server.resource.group;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.ejb.Local;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.resource.group.LdapGroup;
+import org.rhq.core.domain.util.PageControl;
+import org.rhq.core.domain.util.PageList;
+
+/**
+ * A manager that provides methods for creating, updating, deleting, and querying {@link LdapGroup}s.
+ *
+ * @author Simeon Pinder
+ */
+@Local
+public interface LdapGroupManagerLocal {
+
+ PageList<LdapGroup> findLdapGroupsByRole(int roleId, PageControl pageControl);
+
+ PageList<LdapGroup> findLdapGroups(PageControl pc);
+
+ void addLdapGroupsToRole(Subject subject, int roleId, List<String> groupIds);
+
+ void removeLdapGroupsFromRole(Subject subject, int roleId, int[] groupIds);
+
+ void assignRolesToLdapSubject(int subjectId, List<String> ldapGroupNames);
+
+ Set<Map<String, String>> findAvailableGroups();
+
+ Set<String> findAvailableGroupsFor(String userName);
+}
\ No newline at end of file
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
index c21526a..e5171e9 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
@@ -155,6 +155,8 @@ import org.rhq.enterprise.server.resource.ResourceTypeManagerLocal;
import org.rhq.enterprise.server.resource.ResourceTypeManagerRemote;
import org.rhq.enterprise.server.resource.cluster.ClusterManagerBean;
import org.rhq.enterprise.server.resource.cluster.ClusterManagerLocal;
+import org.rhq.enterprise.server.resource.group.LdapGroupManagerBean;
+import org.rhq.enterprise.server.resource.group.LdapGroupManagerLocal;
import org.rhq.enterprise.server.resource.group.ResourceGroupManagerBean;
import org.rhq.enterprise.server.resource.group.ResourceGroupManagerLocal;
import org.rhq.enterprise.server.resource.group.definition.GroupDefinitionExpressionBuilderManagerBean;
@@ -655,4 +657,8 @@ public final class LookupUtil {
return lookupLocal(DataAccessManagerBean.class);
}
+ public static LdapGroupManagerLocal getLdapGroupManager() {
+ return lookupLocal(LdapGroupManagerBean.class);
+ }
+
}
\ No newline at end of file
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/authz/test/RoleManagerBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/authz/test/RoleManagerBeanTest.java
index 2315ee8..c0ae4d9 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/authz/test/RoleManagerBeanTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/authz/test/RoleManagerBeanTest.java
@@ -33,6 +33,7 @@ import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.server.auth.SubjectManagerLocal;
import org.rhq.enterprise.server.authz.PermissionException;
import org.rhq.enterprise.server.authz.RoleManagerLocal;
+import org.rhq.enterprise.server.resource.group.LdapGroupManagerLocal;
import org.rhq.enterprise.server.test.AbstractEJB3Test;
import org.rhq.enterprise.server.util.LookupUtil;
@@ -43,6 +44,7 @@ import org.rhq.enterprise.server.util.LookupUtil;
public class RoleManagerBeanTest extends AbstractEJB3Test {
private SubjectManagerLocal subjectManager;
private RoleManagerLocal roleManager;
+ private LdapGroupManagerLocal ldapManager;
/**
* Prepares things for the entire test class.
@@ -51,6 +53,7 @@ public class RoleManagerBeanTest extends AbstractEJB3Test {
public void beforeClass() {
roleManager = LookupUtil.getRoleManager();
subjectManager = LookupUtil.getSubjectManager();
+ ldapManager = LookupUtil.getLdapGroupManager();
}
/**
@@ -263,7 +266,7 @@ public class RoleManagerBeanTest extends AbstractEJB3Test {
LdapGroup group = new LdapGroup();
group.setName("Foo");
role.addLdapGroup(group);
- assert roleManager.findLdapGroupsByRole(role.getId(), PageControl.getUnlimitedInstance()).size() == 1 : "Ldap Group Foo Should be assigned";
+ assert ldapManager.findLdapGroupsByRole(role.getId(), PageControl.getUnlimitedInstance()).size() == 1 : "Ldap Group Foo Should be assigned";
} finally {
getTransactionManager().rollback();
}
commit 03be63bc157f46c0c6192e25063da5fcf6b76e73
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Apr 27 16:35:00 2010 -0400
oops, referring to a table that no longer exists
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 145b8e2..1837d73 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/alert-schema.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/alert-schema.xml
@@ -124,7 +124,6 @@
<column name="ID" default="sequence-only" initial="10001"
primarykey="true" required="true" type="INTEGER"/>
<column name="ALERT_DEFINITION_ID" required="false" type="INTEGER" references="RHQ_ALERT_DEFINITION(ID)"/>
- <column name="TEMPLATE_ID" required="false" type="INTEGER" references="RHQ_ALERT_NOTIF_TEMPL(ID)"/>
<column name="SENDER_CONFIG_ID" required="false" type="INTEGER" references="RHQ_CONFIG(ID)"/>
<column name="SENDER_NAME" required="true" size="100" type="VARCHAR2" />
</table>
commit e2e2e300fa0fe5441b962cd7c109e13a2c2f8eb9
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Apr 27 16:25:52 2010 -0400
improve debug logging for pagination/sorting issues, so that root cause can more readily be determined in the future
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/WebUserPreferences.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/WebUserPreferences.java
index a939ab4..c0abd7e 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/WebUserPreferences.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/WebUserPreferences.java
@@ -693,16 +693,21 @@ public class WebUserPreferences extends SubjectPreferencesBase {
}
public PageControl getPageControl(PageControlView view) {
- return getPageControl(view, 15);
+ PageControl results = getPageControl(view, 15);
+ log.debug("getPageControl(" + view + ") " + results);
+ return results;
}
public PageControl getPageControl(PageControlView view, int defaultPageSize) {
if (view == PageControlView.NONE) {
+ log.debug("getPageControl(" + view + ") -> PageControl.getUnlimitedInstance()");
return PageControl.getUnlimitedInstance();
}
List<String> pageControlProperties = getPreferenceAsList(view.toString());
+ log.debug("getPageControl(" + view + ") -> pageControlProperties: " + pageControlProperties);
if (pageControlProperties.size() == 0) {
+ log.debug("getPageControl(" + view + ") -> getDefaultPageControl for empty properties");
PageControl defaultControl = getDefaultPageControl(view, defaultPageSize);
return defaultControl;
} else {
@@ -722,6 +727,7 @@ public class WebUserPreferences extends SubjectPreferencesBase {
i += 2;
}
+ log.debug("getPageControl(" + view + ") -> " + pageControl);
if (view.isUnlimited() && pageSize != PageControl.SIZE_UNLIMITED) {
// make sure pageSize for an unlimited view is actually unlimited
@@ -739,6 +745,7 @@ public class WebUserPreferences extends SubjectPreferencesBase {
* persist and load just fine because the logic in this method and its counterpart
* setPageControl are kept in sync
*/
+ log.debug("getPageControl(" + view + ") -> getDefaultPageControl for exception: " + t.getMessage());
pageControl = getDefaultPageControl(view, defaultPageSize);
}
return pageControl;
@@ -770,6 +777,7 @@ public class WebUserPreferences extends SubjectPreferencesBase {
pageControlProperties.add(field.getOrdering().toString());
pageControlProperties.add(field.getField());
}
+ System.out.println("setPageControl(" + view + ", " + pageControl + ")");
setPreference(view.toString(), pageControlProperties);
}
commit 85f04f40d6ca346279b916804e3c23a486ba98a8
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Apr 27 16:25:19 2010 -0400
do now swallow the error message when their appears to be an error handling PageControl data
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/paging/PagedListDataModel.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/paging/PagedListDataModel.java
index adbc7cf..ca3f353 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/paging/PagedListDataModel.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/paging/PagedListDataModel.java
@@ -340,9 +340,7 @@ public abstract class PagedListDataModel<T> extends DataModel {
* ordering (though the underlying SLSB may add a default ordering downstream).
*/
resetToDefaults(pc);
- if (log.isTraceEnabled()) {
- log.trace(pageControlView + ": Received error[" + t.getMessage() + "], resetting to " + pc);
- }
+ log.error(pageControlView + ": Received error[" + t.getMessage() + "], resetting to " + pc);
tryQueryAgain = true;
}
commit d568a683944cbb81c717589f7c8c1a341a0ae433
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Apr 27 16:24:38 2010 -0400
BZ-584149 fix for broken sorting on the inventory browser (resources and groups)
* CriteriaQueryGenerator now automatically prepends the alias to the ordering fields when building the query
* needed to remove explicit alias identifier from the sortableColumnHeader definitions
* also, updated CriteriaQueryGenerator to support sorting by column ordinals (required by group browser's availability columns)
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/inventory/browseGroups.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/inventory/browseGroups.xhtml
index 65be544..70d9821 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/inventory/browseGroups.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/inventory/browseGroups.xhtml
@@ -144,7 +144,7 @@
<rich:column>
<f:facet name="header">
- <onc:sortableColumnHeader sort="rg.name">
+ <onc:sortableColumnHeader sort="name">
<h:outputText styleClass="headerText" value="Name" />
</onc:sortableColumnHeader>
</f:facet>
@@ -157,7 +157,7 @@
<rich:column>
<f:facet name="header">
- <onc:sortableColumnHeader sort="rg.resourceType.name">
+ <onc:sortableColumnHeader sort="resourceType.name">
<h:outputText styleClass="headerText" value="Group Type" />
</onc:sortableColumnHeader>
</f:facet>
@@ -167,7 +167,7 @@
<rich:column>
<f:facet name="header">
- <onc:sortableColumnHeader sort="rg.resourceType.plugin">
+ <onc:sortableColumnHeader sort="resourceType.plugin">
<h:outputText styleClass="headerText" value="Plugin" />
</onc:sortableColumnHeader>
</f:facet>
@@ -177,7 +177,7 @@
<rich:column>
<f:facet name="header">
- <onc:sortableColumnHeader sort="rg.description">
+ <onc:sortableColumnHeader sort="description">
<h:outputText styleClass="headerText" value="Description" />
</onc:sortableColumnHeader>
</f:facet>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/inventory/browseResources.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/inventory/browseResources.xhtml
index 90d45c0..3a4c7ea 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/inventory/browseResources.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/inventory/browseResources.xhtml
@@ -157,7 +157,7 @@
<rich:column>
<f:facet name="header">
- <onc:sortableColumnHeader sort="r.name">
+ <onc:sortableColumnHeader sort="name">
<h:outputText styleClass="headerText" value="Name" />
</onc:sortableColumnHeader>
</f:facet>
@@ -178,7 +178,7 @@
<rich:column>
<f:facet name="header">
- <onc:sortableColumnHeader sort="r.resourceType.category">
+ <onc:sortableColumnHeader sort="resourceType.category">
<h:outputText styleClass="headerText" value="Category" />
</onc:sortableColumnHeader>
</f:facet>
@@ -188,7 +188,7 @@
<rich:column>
<f:facet name="header">
- <onc:sortableColumnHeader sort="r.resourceType.name">
+ <onc:sortableColumnHeader sort="resourceType.name">
<h:outputText styleClass="headerText" value="Type" />
</onc:sortableColumnHeader>
</f:facet>
@@ -198,7 +198,7 @@
<rich:column>
<f:facet name="header">
- <onc:sortableColumnHeader sort="r.resourceType.plugin">
+ <onc:sortableColumnHeader sort="resourceType.plugin">
<h:outputText styleClass="headerText" value="Plugin" />
</onc:sortableColumnHeader>
</f:facet>
@@ -208,7 +208,7 @@
<rich:column>
<f:facet name="header">
- <onc:sortableColumnHeader sort="r.description">
+ <onc:sortableColumnHeader sort="description">
<h:outputText styleClass="headerText" value="Description" />
</onc:sortableColumnHeader>
</f:facet>
@@ -218,7 +218,7 @@
<rich:column>
<f:facet name="header">
- <onc:sortableColumnHeader sort="r.currentAvailability.availabilityType">
+ <onc:sortableColumnHeader sort="currentAvailability.availabilityType">
<h:outputText styleClass="headerText" value="Availability" />
</onc:sortableColumnHeader>
</f:facet>
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java
index ff71760..2272f12 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java
@@ -302,15 +302,15 @@ public final class CriteriaQueryGenerator {
String fieldName = orderingField.getField();
String override = criteria.getJPQLSortOverride(fieldName);
- if (override == null) {
- override = alias + "." + fieldName;
- } else {
- override = alias + "." + override;
- }
+ String suffix = (override == null) ? fieldName : override;
+
+ // if the suffix is numerical, do not prefix the alias
+ // this allows us to sort by column ordinal, which is required for availability on the group browser
+ String sortFragment = (isNumber(suffix)) ? suffix : (alias + "." + suffix);
PageOrdering ordering = orderingField.getOrdering();
- results.append(override).append(' ').append(ordering);
+ results.append(sortFragment).append(' ').append(ordering);
}
}
results.append(NL);
@@ -319,6 +319,18 @@ public final class CriteriaQueryGenerator {
return results.toString();
}
+ private boolean isNumber(String input) {
+ if (input == null) {
+ return false;
+ }
+ for (char next : input.toCharArray()) {
+ if (Character.isDigit(next) == false) {
+ return false;
+ }
+ }
+ return true;
+ }
+
public List<String> getFetchFields(Criteria criteria) {
List<String> results = new ArrayList<String>();
for (Field fetchField : getFields(criteria, Criteria.Type.FETCH)) {
commit dbd83ebec16eafff8561e524cd089998c98ba356
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Apr 27 15:08:41 2010 -0400
fix sorting bug on the group definitions list page
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/definition/group/list.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/definition/group/list.xhtml
index 41f8728..61f9d89 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/definition/group/list.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/definition/group/list.xhtml
@@ -26,8 +26,6 @@
<ui:define name="content">
<h:form id="groupDefinitionsListForm">
- <input type="hidden" name="id" value="${param.id}"/>
-
<h:panelGrid columns="1" styleClass="data-table">
<ui:param name="groupDefinitionsDataModel" value="#{ListGroupDefinitionsUIBean.dataModel}"/>
commit 83c335c60db630d29b8a4155a86bd2f19e8dcbce
Merge: 2443ddf... 5fcef68...
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Apr 27 14:14:53 2010 -0400
Merge branch 'gwt' into gwt-jay
commit 2443ddfecc7c1a0d9e6728ec7f643cadec14e9fd
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Apr 27 13:51:56 2010 -0400
LT commit
diff --git a/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/accordion.js b/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/accordion.js
index 0bb7325..1c1ee6b 100644
--- a/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/accordion.js
+++ b/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/accordion.js
@@ -1,249 +1,249 @@
-/* Copyright 2006 Sun Microsystems, Inc. All rights reserved. You may not modify, use, reproduce, or distribute this software except in compliance with the terms of the License at: http://developer.sun.com/berkeley_license.html
-$Id: accordion.js,v 1.22 2006/05/03 22:00:32 inder Exp $ */
-
-function AccordionMenu () {
-
- dojo.event.topic.subscribe("/accordion", this, this.handleEvent);
-
- var displayPortWidth = 100;
- var HEIGHT = 400;
-
- var EXPANDED_HEIGHT = 125;
- var ITEM_HEIGHT = 55;
- var INCREMENT = 10;
-
- var timeout = 5; // in ms
-
- var accordion = document.getElementById("accordionBody");
- var divs = [];
- var oExpandedIndex = -1;
- var nExpandedIndex = -1;
- var oHeight = ITEM_HEIGHT;
- var nHeight = ITEM_HEIGHT;
- var tHeight = 165;
- var expanding = false;
- var categories;
-
- // while control the inline debug statements
- var debug = false;
- var status = document.getElementById("status");
-
- function Row(id, div, defaultHeight) {
- this.id = id;
- this.div = div;
- //this.height = height;
- this.h = defaultHeight;
- this.div.style.height = defaultHeight + "px"
- }
-
- Row.prototype.setHeight = function(nH) {
- this.h = nH;
- this.div.style.height = nH + "px";
- // re-adjust for ie in that it does not follow the boxmodel
- if (this.div.offsetHeight > nH) {
- this.div.style.height = (nH - (this.div.offsetHeight - nH)) + 'px';
- }
- }
-
- Row.prototype.getTotalHeight = function() {
- return this.div.offsetHeight;
- }
-
- Row.prototype.getHeight = function() {
- return this.h;
- }
-
- this.handleEvent = function(args) {
- if (args.type) {
- if (args.type == 'expand') {
- var targetRow = args.targetRow;
- initiateExpansion(targetRow);
- }
- }
- }
-
- this.load = function(lcategories) {
- categories = lcategories;
- // create all the rows
- for (var l=0; l < categories.length; l++) {
- var row = createRow(l,"accordionRow", ITEM_HEIGHT);
- createLinks(row.div, categories[l].name, l, "accordionLink");
- divs.push(row);
- }
- }
-
- function showStatus() {
- if (debug) {
- var stat = "oExpandedIndex=" + oExpandedIndex + " " ;
- for (var i=0; i < divs.length; i++) {
- stat = stat + i + "=" + divs[i].getTotalHeight() + " ";
- }
- status.innerHTML = stat + " total height=" + accordion.offsetHeight;
- var totalH = 0;
- var tH = 0;
- for (var i=0; i < divs.length; i++) {
- totalH = totalH + divs[i].getHeight();
- tH = tH + divs[i].getTotalHeight();
- }
- }
- }
-
- this.showCategory = function(catid) {
- for (var l=0; l < categories.length; l++) {
- if (catid == categories[l].name) {
- // now tell the scroller to load the first product
- initiateExpansion(l);
- if (categories[l].products[0]) {
- dojo.event.topic.publish("/catalog", {type:"showProducts", productId:categories[l].products[0].id});
- }
- break;
- }
- }
- }
-
- this.showFirstCategory = function() {
- initiateExpansion(0);
- if (categories[0].products[0]) {
- dojo.event.topic.publish("/catalog", {type:"showProducts", productId:categories[0].products[0].id});
- }
- }
-
- this.loadCategoryItem = function(pid, itemId) {
- // find the right product and expand the accordion
- for (var l=0; l < categories.length; l++) {
- // now tell the scroller to load the first product
- for (var il=0; il < categories[l].products.length; il++) {
- if (categories[l].products[il].id == pid ) {
- initiateExpansion(l);
- break;
- }
- }
- }
- dojo.event.topic.publish("/catalog", {type:"showItemDetails", productId: pid , itemId: itemId});
- }
-
- function initiateExpansion(id) {
- // jump out if we are in progress
- if (!expanding && oExpandedIndex != Number(id)) {
- expanding = true;
- nExpandedIndex = Number(id);
- if (oExpandedIndex != -1) {
- var targetDiv = divs[oExpandedIndex].div;
- if (targetDiv && targetDiv.childNodes) {
- for (var l = targetDiv.childNodes.length -1; l >= 0 ; l--) {
- targetDiv.removeChild(targetDiv.childNodes[l]);
- }
- }
- createLinks(divs[oExpandedIndex].div, categories[oExpandedIndex].name, oExpandedIndex, "accordionLink");
- }
- expandRow(id);
- }
- }
-
- function expandRow() {
- if (expanding) {
- showStatus();
- //
- if (nHeight < EXPANDED_HEIGHT) {
- nHeight = nHeight + INCREMENT;
- divs[nExpandedIndex].setHeight(nHeight);
- if (oExpandedIndex != -1) {
- if (tHeight >= ITEM_HEIGHT) {
- oHeight = oHeight - INCREMENT;
- // take all out of the old expanded
- } else {
- oHeight = oHeight - INCREMENT;
- }
- divs[oExpandedIndex].setHeight(oHeight);
- }
- // default exapnd here
- } else if (oExpandedIndex != -1 && oHeight > ITEM_HEIGHT) {
- oHeight = oHeight - INCREMENT;
- divs[oExpandedIndex].setHeight(oHeight);
- } else {
- // set the contents of the new menu
- var targetDiv = divs[nExpandedIndex].div;
- if (targetDiv && targetDiv.childNodes) {
- for (var l = targetDiv.childNodes.length -1; l >= 0 ; l--) {
- targetDiv.removeChild(targetDiv.childNodes[l]);
- }
- }
- divs[nExpandedIndex].div.appendChild(document.createTextNode(categories[nExpandedIndex].name));
- divs[nExpandedIndex].div.appendChild(document.createElement("p"));
- for (var l= 0; l < categories[nExpandedIndex].products.length; l++) {
- var span = document.createElement("span");
- span.className = "accordionProduct";
- var link = document.createElement("a");
- var target = categories[nExpandedIndex].products[l].id;
- link.id = target;
- link.className = "accordionLink";
- // some browsers aren't setting the styles for hovers so forcing them
- link.setAttribute("onmouseover", "this.className='accordionLinkHover';");
- link.setAttribute("onmouseout", "this.className='accordionLink';");
- dojo.event.connect(link, "onclick", function(evt) {
- this._target = target
- var src;
- if (evt.target) {
- src = evt.target;
- } else if (evt.srcElement) {
- src = evt.srcElement;
- }
- //src.parentNode.className = "accordionLinkSelected";
- // set this so the next time around it can be removed;
- dojo.event.topic.publish("/catalog", {type:"showProducts", productId:src.id});
- });
- link.appendChild(document.createTextNode(categories[nExpandedIndex].products[l].name));
- span.appendChild(link);
- divs[nExpandedIndex].div.appendChild(span);
- if (l < categories[nExpandedIndex].products.length - 1) {
- divs[nExpandedIndex].div.appendChild(document.createElement("p"));
- }
- link = null;
- }
- expanding = false;
- oExpandedIndex = nExpandedIndex;
- nExpandedIndex = -1;
- oHeight = nHeight;
- nHeight = ITEM_HEIGHT;
- return;
- }
-
- setTimeout(expandRow, timeout);
- }
- }
-
- function createLinks(tDiv, text, id, linkStyle) {
- var link = document.createElement("a");
- link.className = linkStyle;
- link.appendChild(document.createTextNode(text));
- link.setAttribute("id", id);
- if (link.attachEvent) {
- link.attachEvent('onmouseover',function(e){initiateExpansion(e.srcElement.getAttribute("id"));});
- } else if (link.addEventListener) {
- link.addEventListener('mouseover',function(e){initiateExpansion(e.currentTarget.getAttribute("id"));}, true);
- }
- tDiv.appendChild(link);
- }
-
- function createRow(id, rowStyle, height) {
- var nDiv = document.createElement("div");
- nDiv.className = rowStyle;
- var row;
- var cell;
- if (accordion.insertRow) {
- row = accordion.insertRow(accordion.rows.length);
-
- } else {
- row = document.createElement("tr");
- accordion.appendChild(row);
- }
- if (row.inserCell) {
- cell = row.insertCell(0);
- } else {
- cell = document.createElement("td");
- row.appendChild(cell);
- }
- cell.appendChild(nDiv);
- return new Row(id, nDiv, height);
- }
-}
+/* Copyright 2006 Sun Microsystems, Inc. All rights reserved. You may not modify, use, reproduce, or distribute this software except in compliance with the terms of the License at: http://developer.sun.com/berkeley_license.html
+$Id: accordion.js,v 1.22 2006/05/03 22:00:32 inder Exp $ */
+
+function AccordionMenu () {
+
+ dojo.event.topic.subscribe("/accordion", this, this.handleEvent);
+
+ var displayPortWidth = 100;
+ var HEIGHT = 400;
+
+ var EXPANDED_HEIGHT = 125;
+ var ITEM_HEIGHT = 55;
+ var INCREMENT = 10;
+
+ var timeout = 5; // in ms
+
+ var accordion = document.getElementById("accordionBody");
+ var divs = [];
+ var oExpandedIndex = -1;
+ var nExpandedIndex = -1;
+ var oHeight = ITEM_HEIGHT;
+ var nHeight = ITEM_HEIGHT;
+ var tHeight = 165;
+ var expanding = false;
+ var categories;
+
+ // while control the inline debug statements
+ var debug = false;
+ var status = document.getElementById("status");
+
+ function Row(id, div, defaultHeight) {
+ this.id = id;
+ this.div = div;
+ //this.height = height;
+ this.h = defaultHeight;
+ this.div.style.height = defaultHeight + "px"
+ }
+
+ Row.prototype.setHeight = function(nH) {
+ this.h = nH;
+ this.div.style.height = nH + "px";
+ // re-adjust for ie in that it does not follow the boxmodel
+ if (this.div.offsetHeight > nH) {
+ this.div.style.height = (nH - (this.div.offsetHeight - nH)) + 'px';
+ }
+ }
+
+ Row.prototype.getTotalHeight = function() {
+ return this.div.offsetHeight;
+ }
+
+ Row.prototype.getHeight = function() {
+ return this.h;
+ }
+
+ this.handleEvent = function(args) {
+ if (args.type) {
+ if (args.type == 'expand') {
+ var targetRow = args.targetRow;
+ initiateExpansion(targetRow);
+ }
+ }
+ }
+
+ this.load = function(lcategories) {
+ categories = lcategories;
+ // create all the rows
+ for (var l=0; l < categories.length; l++) {
+ var row = createRow(l,"accordionRow", ITEM_HEIGHT);
+ createLinks(row.div, categories[l].name, l, "accordionLink");
+ divs.push(row);
+ }
+ }
+
+ function showStatus() {
+ if (debug) {
+ var stat = "oExpandedIndex=" + oExpandedIndex + " " ;
+ for (var i=0; i < divs.length; i++) {
+ stat = stat + i + "=" + divs[i].getTotalHeight() + " ";
+ }
+ status.innerHTML = stat + " total height=" + accordion.offsetHeight;
+ var totalH = 0;
+ var tH = 0;
+ for (var i=0; i < divs.length; i++) {
+ totalH = totalH + divs[i].getHeight();
+ tH = tH + divs[i].getTotalHeight();
+ }
+ }
+ }
+
+ this.showCategory = function(catid) {
+ for (var l=0; l < categories.length; l++) {
+ if (catid == categories[l].name) {
+ // now tell the scroller to load the first product
+ initiateExpansion(l);
+ if (categories[l].products[0]) {
+ dojo.event.topic.publish("/catalog", {type:"showProducts", productId:categories[l].products[0].id});
+ }
+ break;
+ }
+ }
+ }
+
+ this.showFirstCategory = function() {
+ initiateExpansion(0);
+ if (categories[0].products[0]) {
+ dojo.event.topic.publish("/catalog", {type:"showProducts", productId:categories[0].products[0].id});
+ }
+ }
+
+ this.loadCategoryItem = function(pid, itemId) {
+ // find the right product and expand the accordion
+ for (var l=0; l < categories.length; l++) {
+ // now tell the scroller to load the first product
+ for (var il=0; il < categories[l].products.length; il++) {
+ if (categories[l].products[il].id == pid ) {
+ initiateExpansion(l);
+ break;
+ }
+ }
+ }
+ dojo.event.topic.publish("/catalog", {type:"showItemDetails", productId: pid , itemId: itemId});
+ }
+
+ function initiateExpansion(id) {
+ // jump out if we are in progress
+ if (!expanding && oExpandedIndex != Number(id)) {
+ expanding = true;
+ nExpandedIndex = Number(id);
+ if (oExpandedIndex != -1) {
+ var targetDiv = divs[oExpandedIndex].div;
+ if (targetDiv && targetDiv.childNodes) {
+ for (var l = targetDiv.childNodes.length -1; l >= 0 ; l--) {
+ targetDiv.removeChild(targetDiv.childNodes[l]);
+ }
+ }
+ createLinks(divs[oExpandedIndex].div, categories[oExpandedIndex].name, oExpandedIndex, "accordionLink");
+ }
+ expandRow(id);
+ }
+ }
+
+ function expandRow() {
+ if (expanding) {
+ showStatus();
+ //
+ if (nHeight < EXPANDED_HEIGHT) {
+ nHeight = nHeight + INCREMENT;
+ divs[nExpandedIndex].setHeight(nHeight);
+ if (oExpandedIndex != -1) {
+ if (tHeight >= ITEM_HEIGHT) {
+ oHeight = oHeight - INCREMENT;
+ // take all out of the old expanded
+ } else {
+ oHeight = oHeight - INCREMENT;
+ }
+ divs[oExpandedIndex].setHeight(oHeight);
+ }
+ // default exapnd here
+ } else if (oExpandedIndex != -1 && oHeight > ITEM_HEIGHT) {
+ oHeight = oHeight - INCREMENT;
+ divs[oExpandedIndex].setHeight(oHeight);
+ } else {
+ // set the contents of the new menu
+ var targetDiv = divs[nExpandedIndex].div;
+ if (targetDiv && targetDiv.childNodes) {
+ for (var l = targetDiv.childNodes.length -1; l >= 0 ; l--) {
+ targetDiv.removeChild(targetDiv.childNodes[l]);
+ }
+ }
+ divs[nExpandedIndex].div.appendChild(document.createTextNode(categories[nExpandedIndex].name));
+ divs[nExpandedIndex].div.appendChild(document.createElement("p"));
+ for (var l= 0; l < categories[nExpandedIndex].products.length; l++) {
+ var span = document.createElement("span");
+ span.className = "accordionProduct";
+ var link = document.createElement("a");
+ var target = categories[nExpandedIndex].products[l].id;
+ link.id = target;
+ link.className = "accordionLink";
+ // some browsers aren't setting the styles for hovers so forcing them
+ link.setAttribute("onmouseover", "this.className='accordionLinkHover';");
+ link.setAttribute("onmouseout", "this.className='accordionLink';");
+ dojo.event.connect(link, "onclick", function(evt) {
+ this._target = target
+ var src;
+ if (evt.target) {
+ src = evt.target;
+ } else if (evt.srcElement) {
+ src = evt.srcElement;
+ }
+ //src.parentNode.className = "accordionLinkSelected";
+ // set this so the next time around it can be removed;
+ dojo.event.topic.publish("/catalog", {type:"showProducts", productId:src.id});
+ });
+ link.appendChild(document.createTextNode(categories[nExpandedIndex].products[l].name));
+ span.appendChild(link);
+ divs[nExpandedIndex].div.appendChild(span);
+ if (l < categories[nExpandedIndex].products.length - 1) {
+ divs[nExpandedIndex].div.appendChild(document.createElement("p"));
+ }
+ link = null;
+ }
+ expanding = false;
+ oExpandedIndex = nExpandedIndex;
+ nExpandedIndex = -1;
+ oHeight = nHeight;
+ nHeight = ITEM_HEIGHT;
+ return;
+ }
+
+ setTimeout(expandRow, timeout);
+ }
+ }
+
+ function createLinks(tDiv, text, id, linkStyle) {
+ var link = document.createElement("a");
+ link.className = linkStyle;
+ link.appendChild(document.createTextNode(text));
+ link.setAttribute("id", id);
+ if (link.attachEvent) {
+ link.attachEvent('onmouseover',function(e){initiateExpansion(e.srcElement.getAttribute("id"));});
+ } else if (link.addEventListener) {
+ link.addEventListener('mouseover',function(e){initiateExpansion(e.currentTarget.getAttribute("id"));}, true);
+ }
+ tDiv.appendChild(link);
+ }
+
+ function createRow(id, rowStyle, height) {
+ var nDiv = document.createElement("div");
+ nDiv.className = rowStyle;
+ var row;
+ var cell;
+ if (accordion.insertRow) {
+ row = accordion.insertRow(accordion.rows.length);
+
+ } else {
+ row = document.createElement("tr");
+ accordion.appendChild(row);
+ }
+ if (row.inserCell) {
+ cell = row.insertCell(0);
+ } else {
+ cell = document.createElement("td");
+ row.appendChild(cell);
+ }
+ cell.appendChild(nDiv);
+ return new Row(id, nDiv, height);
+ }
+}
diff --git a/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/catalog.js b/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/catalog.js
index dafa49d..4bdfc69 100644
--- a/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/catalog.js
+++ b/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/catalog.js
@@ -1,329 +1,329 @@
-/* Copyright 2006 Sun Microsystems, Inc. All rights reserved. You may not modify, use, reproduce, or distribute this software except in compliance with the terms of the License at: http://developer.sun.com/berkeley_license.html
-$Id: catalog.js,v 1.21 2007/01/17 22:16:44 basler Exp $ */
-
-var ac;
-var is;
-var controller;
-//var debug=true;
-
-function getApplicationContextRoot() {
- var urlArray=window.location.toString().split("/", 4);
- return "/" + urlArray[3];
-}
-
-var applicationContextRoot=getApplicationContextRoot();
-
-function initCatalog() {
- ac = new AccordionMenu();
- is = new ImageScroller();
- is.load();
- controller = new CatalogController();
- // wire in a listener for the rating component
- dojo.event.connect("before", bpui.rating, "doClick", controller, "modifyState");
- controller.initialize();
-}
-
-function CatalogController() {
- dojo.event.topic.subscribe("/catalog", this, handleEvent);
-
- // this object structure contains a list of the products and chunks that have been loaded
- var pList = new ProductList();
-
- var CHUNK_SIZE=7;
- var initalRating;
- var initalItem;
- var originalURL;
-
- // using this for some browsers that do not support innerHTML
- var useDOMInjection = false;
-
- var infoName = document.getElementById("infopaneName");
- var infoRating = document.getElementById("infopaneRating");
- var infoPrice = document.getElementById("infopanePrice");
- var infoBuyNow = document.getElementById("infopaneBuyNow");
- var infoShortDescription = document.getElementById("infopaneShortDescription");
- var infoDescription = document.getElementById("infopaneDescription");
- // for paypal
- var buyNowAmount = document.getElementById("buyNow1_amount");
- var buyNowItemName = document.getElementById("buyNow1_item_name");
-
- function handleEvent(args) {
- if (args.type == "showingItem") {
- // update the id on the ratring component
- if (typeof bpui != 'undefined') {
- var groupId = is.getGroupId();
- window.location.href= originalURL + "#" + groupId + "," + args.id;
- if (typeof bpui.rating != 'undefined') {
- // update the rating
- bpui.rating.state["rating"].bindings["itemId"]=args.id;
- bpui.rating.modifyDisplay("rating", args.rating, true);
- // get the currrent item
- showItemDetails(args.id);
- } else {
- initalItem = args.id;
- initalRating = args.rating;
- }
- } else {
- // things haven't been loaded to set the inital rating
- initalItem = args.id;
- initalRating = args.rating;
- }
- } else if (args.type == "getChunk") {
- populateItems(args.id, args.index, args.currentChunk, false);
-
- } else if (args.type == "showItemDetails") {
- showProductDetails(args.productId, args.itemId);
-
- } else if (args.type == "showProducts") {
- is.reset();
- populateItems(args.productId, 0, 0, true);
- }
- }
-
- function showItemDetails(id) {
- var i = is.getItems().get(id);
- setNodeText(infoName, i.name + "<br/><a href='javascript:controller.disableItem("" + id + "","" + i.name + "")'><font size='-1' color='white'><i>Flag as inappropriate</i></font></a>");
- setNodeText(infoPrice, i.price);
- setNodeText(infoShortDescription, i.shortDescription);
- setNodeText(infoDescription, i.description);
- // update the paypal
- buyNowAmount.value = i.price;
- buyNowItemName.value = i.name;
- }
-
- function setNodeText(t, text) {
- if (useDOMInjection) {
- t.lastChild.nodeValue = text;
- } else {
- t.innerHTML = text;
- }
- }
-
- this.initialize = function() {
- // check whether the innerHTML changes can be used in the infopane
- infoName.innerHTML = " ";
- if (!useDOMInjection && infoName.innerHTML != " ") {
- useDOMInjection = true;
-
- infoName.appendChild(document.createTextNode("Name"));
- infoPrice.appendChild(document.createTextNode("$0.00"));
- infoShortDescription.appendChild(document.createTextNode("<description>"));
- infoDescription.appendChild(document.createTextNode("<description>"));
- }
-
- var ratingInstance = bpui.rating.state["rating"];
- ratingInstance.grade = initalRating;
- bpui.rating.state["rating"].bindings["itemId"]=initalItem;
- bpui.rating.modifyDisplay("rating", initalRating, true);
- loadAccordion();
- }
-
-
- this.modifyState = function(arg, rating) {
- var itemId = initalItem;
- if (typeof bpui.rating.state["rating"].bindings["itemId"] != 'undefined') {
- itemId = bpui.rating.state["rating"].bindings["itemId"];
- }
- // set the cached rating to the new rating that was set.
- is.getItems().get(itemId).rating = rating;
- }
-
-
- function loadAccordion () {
- // go out and get the categories
- // this should be made more geric
- var bindArgs = {
- url: applicationContextRoot + "/catalog?command=categories&format=json",
- mimetype: "text/json",
- load: function(type,json) {
- ac.load(json);
- processURLParameters();
- },
- error: ajaxBindError
- };
- dojo.io.bind(bindArgs);
- }
-
- // this needs to happen after we have loaded the accordion data
- function processURLParameters() {
- originalURL = decodeURIComponent(window.location.href);
- var params = {};
- // look for the params
- if (originalURL.indexOf("#") != -1) {
- var qString = originalURL.split('#')[1];
- var args = qString.split(',');
- originalURL = originalURL.split('#')[0];
- ac.loadCategoryItem(args[0], args[1]);
- return;
- } else if (originalURL.indexOf("?") != -1) {
- var qString = originalURL.split('?')[1];
- // get rid of any bookmarking stuff
- if (qString.indexOf("#") != -1) {
- qString = qString.split('#')[0];
- originalURL = originalURL.split('#')[0];
- window.location.href = originalURL;
- }
- ps = qString.split('&');
- // now go through and create the params map as an object literal
- for (var i in ps) {
- var t = ps[i].split('=');
- params[t[0]] = t[1];
- }
- // first check for the item in product
- if (typeof params.itemId != 'undefined' && typeof params.pid != 'undefined') {
- ac.loadCategoryItem(params.pid, params.itemId);
- // next if there is a catid definition then do it
- } else if (typeof params.catid != 'undefined') {
- ac.showCategory(params.catid);
- }
- } else {
- // nothing is selected
- ac.showFirstCategory();
- }
- }
-
-
-
- function showProductDetails(pid, itemId) {
- is.reset();
- is.showProgressIndicator();
- var bindArgs = {
- url: applicationContextRoot + "/catalog?command=itemInChunk&pid=" + pid + "&itemId=" + itemId + "&length=" + CHUNK_SIZE,
- mimetype: "text/xml",
- load: function(type,data,postProcessHandler) {
- processProductData(data,true, pid, itemId);
- showItemDetails(itemId);
- is.doMaximize();
- },
- error: ajaxBindError
- };
- dojo.io.bind(bindArgs);
- }
-
-
-
- function populateItems(pid, index, neededChunk, showImage) {
- is.showProgressIndicator();
- is.setGroupId(pid);
- printDebug("populateItems - need to make sure displaying - pid=" + pid + " Chunk=" + neededChunk);
-
- // check to see if relevant scroller page is already loaded
- if(!is.containsChunk(pid + "_" + neededChunk)) {
-
- // not loaded, so see if it is in the cache
- if (pList.hasChunk(pid, neededChunk)) {
- // in cache, so add chunk to scroller
- printDebug("**** adding chunk from cache - pid=" + pid + " Chunk=" + neededChunk);
- is.addChunk(pid + "_" + neededChunk);
- is.addItems(pList.getChunk(pid, neededChunk));
-
- // show first image if you have it
- if(showImage && is.getScrollerItems().length > 0) {
- is.showImage(is.getScrollerItems()[0].id);
- }
-
- } else {
- // not in cache so load it
- startRetIndex=(neededChunk * CHUNK_SIZE);
-
- printDebug("**** retrieving chunk from server - pid=" + pid + " currentIndex=" + index + " startIndex=" + startRetIndex + " Chunk=" + neededChunk);
- var bindArgs = {
- url: applicationContextRoot + "/catalog?command=items&pid=" + pid + "&start=" + startRetIndex + "&length=" + CHUNK_SIZE,
- mimetype: "text/xml",
- load: function(type,data,postProcessHandler) {
- processProductData(data, showImage, pid, null, neededChunk);
- },
- error: ajaxBindError
- };
- dojo.io.bind(bindArgs);
- }
- } else {
- printDebug("*** items already showing");
- }
-
- }
-
-
- function processProductData(responseXML, showImage, pid, iId, chunkId) {
- var items = [];
- var count = responseXML.getElementsByTagName("item").length;
- for (var loop=0; loop < count ; loop++) {
-
- var item = responseXML.getElementsByTagName("item")[loop];
- var itemId = item.getElementsByTagName("id")[0].firstChild.nodeValue;
- var name = item.getElementsByTagName("name")[0].firstChild.nodeValue;
- var thumbURL = item.getElementsByTagName("image-tb-url")[0].firstChild.nodeValue;
- var imageURL = item.getElementsByTagName("image-url")[0].firstChild.nodeValue;
- var description = item.getElementsByTagName("description")[0].firstChild.nodeValue;
- var price = item.getElementsByTagName("price")[0].firstChild.nodeValue;
- var rating = item.getElementsByTagName("rating")[0].firstChild.nodeValue;
- var shortDescription;
- if (description.length > 71) {
- shortDescription = description.substring(0,71) + "...";
- } else {
- shortDescription = description;
- }
- var i = {id: itemId, name: name, image: imageURL, thumbnail: thumbURL, shortDescription: shortDescription, description: description, price:price, rating: rating};
- items.push(i);
- }
-
- // cache the chunks
- pList.addChunk(pid, chunkId, items);
- is.addItems(items);
- is.addChunk(pid + "_" + chunkId);
-
- if (showImage && iId == null) {
- is.setGroupId(pid);
- is.showImage(items[0].id);
- } else {
- is.setGroupId(pid);
- is.showImage(iId);
- }
- is.hideProgressIndicator();
- }
-
- function ProductList() {
- var _plist = this;
- var map = new Map();
-
- this.addChunk = function(pid, chunkNumber, items) {
- map.put(pid + "_" + chunkNumber, items, true);
- }
-
- this.getChunk = function(pid, chunkNumber) {
- return map.get(pid + "_" + chunkNumber);
- }
-
- this.hasChunk = function(pid, chunkNumber) {
- return (map.get(pid + "_" + chunkNumber) != null);
- }
-
- this.contents = function() {
- return map.contents();
- }
- }
-
-
- this.disableItem=function(itemId, itemName) {
- // go out and get the categories
- // this should be made more geric
- if (confirm("Are you sure you want to effectively remove this item from Petstore?")) {
- var bindArgs = {
- url: applicationContextRoot + "/catalog?command=disable&id=" + itemId,
- mimetype: "text/xml",
- load: function(type,json) {
- //alert("The item named '" + itemName + "' has been disabled!");
- pList = new ProductList();
- is.reset();
- populateItems(is.getGroupId(), 0, 0, true);
- },
- error: ajaxBindError
- };
- dojo.io.bind(bindArgs);
- }
- }
-
-
-}
-
-
+/* Copyright 2006 Sun Microsystems, Inc. All rights reserved. You may not modify, use, reproduce, or distribute this software except in compliance with the terms of the License at: http://developer.sun.com/berkeley_license.html
+$Id: catalog.js,v 1.21 2007/01/17 22:16:44 basler Exp $ */
+
+var ac;
+var is;
+var controller;
+//var debug=true;
+
+function getApplicationContextRoot() {
+ var urlArray=window.location.toString().split("/", 4);
+ return "/" + urlArray[3];
+}
+
+var applicationContextRoot=getApplicationContextRoot();
+
+function initCatalog() {
+ ac = new AccordionMenu();
+ is = new ImageScroller();
+ is.load();
+ controller = new CatalogController();
+ // wire in a listener for the rating component
+ dojo.event.connect("before", bpui.rating, "doClick", controller, "modifyState");
+ controller.initialize();
+}
+
+function CatalogController() {
+ dojo.event.topic.subscribe("/catalog", this, handleEvent);
+
+ // this object structure contains a list of the products and chunks that have been loaded
+ var pList = new ProductList();
+
+ var CHUNK_SIZE=7;
+ var initalRating;
+ var initalItem;
+ var originalURL;
+
+ // using this for some browsers that do not support innerHTML
+ var useDOMInjection = false;
+
+ var infoName = document.getElementById("infopaneName");
+ var infoRating = document.getElementById("infopaneRating");
+ var infoPrice = document.getElementById("infopanePrice");
+ var infoBuyNow = document.getElementById("infopaneBuyNow");
+ var infoShortDescription = document.getElementById("infopaneShortDescription");
+ var infoDescription = document.getElementById("infopaneDescription");
+ // for paypal
+ var buyNowAmount = document.getElementById("buyNow1_amount");
+ var buyNowItemName = document.getElementById("buyNow1_item_name");
+
+ function handleEvent(args) {
+ if (args.type == "showingItem") {
+ // update the id on the ratring component
+ if (typeof bpui != 'undefined') {
+ var groupId = is.getGroupId();
+ window.location.href= originalURL + "#" + groupId + "," + args.id;
+ if (typeof bpui.rating != 'undefined') {
+ // update the rating
+ bpui.rating.state["rating"].bindings["itemId"]=args.id;
+ bpui.rating.modifyDisplay("rating", args.rating, true);
+ // get the currrent item
+ showItemDetails(args.id);
+ } else {
+ initalItem = args.id;
+ initalRating = args.rating;
+ }
+ } else {
+ // things haven't been loaded to set the inital rating
+ initalItem = args.id;
+ initalRating = args.rating;
+ }
+ } else if (args.type == "getChunk") {
+ populateItems(args.id, args.index, args.currentChunk, false);
+
+ } else if (args.type == "showItemDetails") {
+ showProductDetails(args.productId, args.itemId);
+
+ } else if (args.type == "showProducts") {
+ is.reset();
+ populateItems(args.productId, 0, 0, true);
+ }
+ }
+
+ function showItemDetails(id) {
+ var i = is.getItems().get(id);
+ setNodeText(infoName, i.name + "<br/><a href='javascript:controller.disableItem("" + id + "","" + i.name + "")'><font size='-1' color='white'><i>Flag as inappropriate</i></font></a>");
+ setNodeText(infoPrice, i.price);
+ setNodeText(infoShortDescription, i.shortDescription);
+ setNodeText(infoDescription, i.description);
+ // update the paypal
+ buyNowAmount.value = i.price;
+ buyNowItemName.value = i.name;
+ }
+
+ function setNodeText(t, text) {
+ if (useDOMInjection) {
+ t.lastChild.nodeValue = text;
+ } else {
+ t.innerHTML = text;
+ }
+ }
+
+ this.initialize = function() {
+ // check whether the innerHTML changes can be used in the infopane
+ infoName.innerHTML = " ";
+ if (!useDOMInjection && infoName.innerHTML != " ") {
+ useDOMInjection = true;
+
+ infoName.appendChild(document.createTextNode("Name"));
+ infoPrice.appendChild(document.createTextNode("$0.00"));
+ infoShortDescription.appendChild(document.createTextNode("<description>"));
+ infoDescription.appendChild(document.createTextNode("<description>"));
+ }
+
+ var ratingInstance = bpui.rating.state["rating"];
+ ratingInstance.grade = initalRating;
+ bpui.rating.state["rating"].bindings["itemId"]=initalItem;
+ bpui.rating.modifyDisplay("rating", initalRating, true);
+ loadAccordion();
+ }
+
+
+ this.modifyState = function(arg, rating) {
+ var itemId = initalItem;
+ if (typeof bpui.rating.state["rating"].bindings["itemId"] != 'undefined') {
+ itemId = bpui.rating.state["rating"].bindings["itemId"];
+ }
+ // set the cached rating to the new rating that was set.
+ is.getItems().get(itemId).rating = rating;
+ }
+
+
+ function loadAccordion () {
+ // go out and get the categories
+ // this should be made more geric
+ var bindArgs = {
+ url: applicationContextRoot + "/catalog?command=categories&format=json",
+ mimetype: "text/json",
+ load: function(type,json) {
+ ac.load(json);
+ processURLParameters();
+ },
+ error: ajaxBindError
+ };
+ dojo.io.bind(bindArgs);
+ }
+
+ // this needs to happen after we have loaded the accordion data
+ function processURLParameters() {
+ originalURL = decodeURIComponent(window.location.href);
+ var params = {};
+ // look for the params
+ if (originalURL.indexOf("#") != -1) {
+ var qString = originalURL.split('#')[1];
+ var args = qString.split(',');
+ originalURL = originalURL.split('#')[0];
+ ac.loadCategoryItem(args[0], args[1]);
+ return;
+ } else if (originalURL.indexOf("?") != -1) {
+ var qString = originalURL.split('?')[1];
+ // get rid of any bookmarking stuff
+ if (qString.indexOf("#") != -1) {
+ qString = qString.split('#')[0];
+ originalURL = originalURL.split('#')[0];
+ window.location.href = originalURL;
+ }
+ ps = qString.split('&');
+ // now go through and create the params map as an object literal
+ for (var i in ps) {
+ var t = ps[i].split('=');
+ params[t[0]] = t[1];
+ }
+ // first check for the item in product
+ if (typeof params.itemId != 'undefined' && typeof params.pid != 'undefined') {
+ ac.loadCategoryItem(params.pid, params.itemId);
+ // next if there is a catid definition then do it
+ } else if (typeof params.catid != 'undefined') {
+ ac.showCategory(params.catid);
+ }
+ } else {
+ // nothing is selected
+ ac.showFirstCategory();
+ }
+ }
+
+
+
+ function showProductDetails(pid, itemId) {
+ is.reset();
+ is.showProgressIndicator();
+ var bindArgs = {
+ url: applicationContextRoot + "/catalog?command=itemInChunk&pid=" + pid + "&itemId=" + itemId + "&length=" + CHUNK_SIZE,
+ mimetype: "text/xml",
+ load: function(type,data,postProcessHandler) {
+ processProductData(data,true, pid, itemId);
+ showItemDetails(itemId);
+ is.doMaximize();
+ },
+ error: ajaxBindError
+ };
+ dojo.io.bind(bindArgs);
+ }
+
+
+
+ function populateItems(pid, index, neededChunk, showImage) {
+ is.showProgressIndicator();
+ is.setGroupId(pid);
+ printDebug("populateItems - need to make sure displaying - pid=" + pid + " Chunk=" + neededChunk);
+
+ // check to see if relevant scroller page is already loaded
+ if(!is.containsChunk(pid + "_" + neededChunk)) {
+
+ // not loaded, so see if it is in the cache
+ if (pList.hasChunk(pid, neededChunk)) {
+ // in cache, so add chunk to scroller
+ printDebug("**** adding chunk from cache - pid=" + pid + " Chunk=" + neededChunk);
+ is.addChunk(pid + "_" + neededChunk);
+ is.addItems(pList.getChunk(pid, neededChunk));
+
+ // show first image if you have it
+ if(showImage && is.getScrollerItems().length > 0) {
+ is.showImage(is.getScrollerItems()[0].id);
+ }
+
+ } else {
+ // not in cache so load it
+ startRetIndex=(neededChunk * CHUNK_SIZE);
+
+ printDebug("**** retrieving chunk from server - pid=" + pid + " currentIndex=" + index + " startIndex=" + startRetIndex + " Chunk=" + neededChunk);
+ var bindArgs = {
+ url: applicationContextRoot + "/catalog?command=items&pid=" + pid + "&start=" + startRetIndex + "&length=" + CHUNK_SIZE,
+ mimetype: "text/xml",
+ load: function(type,data,postProcessHandler) {
+ processProductData(data, showImage, pid, null, neededChunk);
+ },
+ error: ajaxBindError
+ };
+ dojo.io.bind(bindArgs);
+ }
+ } else {
+ printDebug("*** items already showing");
+ }
+
+ }
+
+
+ function processProductData(responseXML, showImage, pid, iId, chunkId) {
+ var items = [];
+ var count = responseXML.getElementsByTagName("item").length;
+ for (var loop=0; loop < count ; loop++) {
+
+ var item = responseXML.getElementsByTagName("item")[loop];
+ var itemId = item.getElementsByTagName("id")[0].firstChild.nodeValue;
+ var name = item.getElementsByTagName("name")[0].firstChild.nodeValue;
+ var thumbURL = item.getElementsByTagName("image-tb-url")[0].firstChild.nodeValue;
+ var imageURL = item.getElementsByTagName("image-url")[0].firstChild.nodeValue;
+ var description = item.getElementsByTagName("description")[0].firstChild.nodeValue;
+ var price = item.getElementsByTagName("price")[0].firstChild.nodeValue;
+ var rating = item.getElementsByTagName("rating")[0].firstChild.nodeValue;
+ var shortDescription;
+ if (description.length > 71) {
+ shortDescription = description.substring(0,71) + "...";
+ } else {
+ shortDescription = description;
+ }
+ var i = {id: itemId, name: name, image: imageURL, thumbnail: thumbURL, shortDescription: shortDescription, description: description, price:price, rating: rating};
+ items.push(i);
+ }
+
+ // cache the chunks
+ pList.addChunk(pid, chunkId, items);
+ is.addItems(items);
+ is.addChunk(pid + "_" + chunkId);
+
+ if (showImage && iId == null) {
+ is.setGroupId(pid);
+ is.showImage(items[0].id);
+ } else {
+ is.setGroupId(pid);
+ is.showImage(iId);
+ }
+ is.hideProgressIndicator();
+ }
+
+ function ProductList() {
+ var _plist = this;
+ var map = new Map();
+
+ this.addChunk = function(pid, chunkNumber, items) {
+ map.put(pid + "_" + chunkNumber, items, true);
+ }
+
+ this.getChunk = function(pid, chunkNumber) {
+ return map.get(pid + "_" + chunkNumber);
+ }
+
+ this.hasChunk = function(pid, chunkNumber) {
+ return (map.get(pid + "_" + chunkNumber) != null);
+ }
+
+ this.contents = function() {
+ return map.contents();
+ }
+ }
+
+
+ this.disableItem=function(itemId, itemName) {
+ // go out and get the categories
+ // this should be made more geric
+ if (confirm("Are you sure you want to effectively remove this item from Petstore?")) {
+ var bindArgs = {
+ url: applicationContextRoot + "/catalog?command=disable&id=" + itemId,
+ mimetype: "text/xml",
+ load: function(type,json) {
+ //alert("The item named '" + itemName + "' has been disabled!");
+ pList = new ProductList();
+ is.reset();
+ populateItems(is.getGroupId(), 0, 0, true);
+ },
+ error: ajaxBindError
+ };
+ dojo.io.bind(bindArgs);
+ }
+ }
+
+
+}
+
+
diff --git a/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/catalog.jsp-old b/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/catalog.jsp-old
index 851744b..13914ed 100644
--- a/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/catalog.jsp-old
+++ b/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/catalog.jsp-old
@@ -1,95 +1,95 @@
-<%-- Copyright 2006 Sun Microsystems, Inc. All rights reserved. You may not modify, use, reproduce, or distribute this software except in compliance with the terms of the License at: http://developer.sun.com/berkeley_license.html
-$Id: catalog.jsp,v 1.20 2006/12/01 21:38:40 basler Exp $ --%>
-<script type="text/javascript" src="common.js"></script>
-<script type="text/javascript" src="scroller.js"></script>
-<link rel="stylesheet" type="text/css" href="scroller.css"></link>
-<script type="text/javascript" src="accordion.js"></script>
-<link rel="stylesheet" type="text/css" href="accordion.css"></link>
-<script type="text/javascript" src="catalog.js"></script>
-<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
-<%@taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
-<%@taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
-<%@taglib prefix="ui" uri="http://java.sun.com/blueprints/ui" %>
-<body>
-<jsp:include page="banner.jsp" />
-<script type="text/javascript">
- dojo.event.connect(window, "onload", function(){initCatalog();});
-</script>
-<center>
- <table border="0">
- <tr>
- <td>
- <table id="accordion">
- <tr id="accordionTitle" class="accordionTitle"><td>Pets</td></tr>
- <tr><td>
- <table id="accordionBody" border="0" class="accordionBody">
- </table>
- </td></tr>
- </table>
- </td>
- <td style="min-width:500px;">
- <div id="CatalogBrowser">
- <table width="500px"border="1" class="slider" >
- <tr height="415" valign="top">
- <td id="bodySpace" border="0" align="center"></td>
- </tr>
- <tr id="targetRow">
- <td width="500px" height="70px" align="top">
- <div class="nav" id="right_button">
- <img src="${pageContext.request.contextPath}/images/right.gif" name="nextRoll" title="Show More Items" border="0">
- </div>
- <div class="nav" id="left_button">
- <img src="${pageContext.request.contextPath}/images/left.gif" name="previousRoll" title="Show Previous Items" border="0">
- </div>
- <div id="infopane" class="infopane">
- <table class="infopaneTable">
- <tr>
- <td id="infopaneName" class="infopaneTitle">
- </td>
- <td id="infopaneRating" class="infopaneRating">
- <f:view>
- <ui:rating id="rating" maxGrade="5" includeNotInterested="false" includeClear="false"
- hoverTexts="#{RatingBean.ratingText}" notInterestedHoverText="Not Interested" clearHoverText="Clear Rating"
- grade="#{RatingBean.grade}"/>
- <f:verbatim></td><td id="infopanePrice" class="infopanePrice"></td><td id="infopanePayPal" class="infopanePayPal"></f:verbatim>
- <ui:buyNow business="donate(a)animalfoundation.com" id="buyNow1" itemName="Buy Item One"
- amount="100.00" quantity="1" type="BuyNow" postData="#{PayPalBean.postData}" target="paypal"/>
- </f:view>
- </td>
- <td id="infopaneIndicator" class="infopaneIndicator">
- </td>
- <td id="infopaneDetailsIcon">
- </td>
- </tr>
- <tr>
- <td id="infopaneShortDescription" colspan="7" class="infopaneShortDescription">
- </td>
- </tr>
- <tr style="height:20px">
- <td></td>
- </tr>
- <tr>
- <td id="infopaneDescription" colspan="6" class="infopaneDescription">
- </td>
- </tr>
- </table>
- </div>
- </td>
- </tr>
- </table>
- </td>
- <td style="vertical-align:top; width:300px; text-align:right;">
- <div id="downloadAds">
- <jsp:include page="download.jsp" />
- </div>
- </td>
- </tr>
- </table>
- </div>
- <div id="status" style="text-align:left"></div> <div id="status_2"></div>
- <div id="dstatus"></div>
- <div id="injection_point"></div>
-</center>
-<jsp:include page="footer.jsp" />
-</body>
+<%-- Copyright 2006 Sun Microsystems, Inc. All rights reserved. You may not modify, use, reproduce, or distribute this software except in compliance with the terms of the License at: http://developer.sun.com/berkeley_license.html
+$Id: catalog.jsp,v 1.20 2006/12/01 21:38:40 basler Exp $ --%>
+<script type="text/javascript" src="common.js"></script>
+<script type="text/javascript" src="scroller.js"></script>
+<link rel="stylesheet" type="text/css" href="scroller.css"></link>
+<script type="text/javascript" src="accordion.js"></script>
+<link rel="stylesheet" type="text/css" href="accordion.css"></link>
+<script type="text/javascript" src="catalog.js"></script>
+<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<%@taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
+<%@taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
+<%@taglib prefix="ui" uri="http://java.sun.com/blueprints/ui" %>
+<body>
+<jsp:include page="banner.jsp" />
+<script type="text/javascript">
+ dojo.event.connect(window, "onload", function(){initCatalog();});
+</script>
+<center>
+ <table border="0">
+ <tr>
+ <td>
+ <table id="accordion">
+ <tr id="accordionTitle" class="accordionTitle"><td>Pets</td></tr>
+ <tr><td>
+ <table id="accordionBody" border="0" class="accordionBody">
+ </table>
+ </td></tr>
+ </table>
+ </td>
+ <td style="min-width:500px;">
+ <div id="CatalogBrowser">
+ <table width="500px"border="1" class="slider" >
+ <tr height="415" valign="top">
+ <td id="bodySpace" border="0" align="center"></td>
+ </tr>
+ <tr id="targetRow">
+ <td width="500px" height="70px" align="top">
+ <div class="nav" id="right_button">
+ <img src="${pageContext.request.contextPath}/images/right.gif" name="nextRoll" title="Show More Items" border="0">
+ </div>
+ <div class="nav" id="left_button">
+ <img src="${pageContext.request.contextPath}/images/left.gif" name="previousRoll" title="Show Previous Items" border="0">
+ </div>
+ <div id="infopane" class="infopane">
+ <table class="infopaneTable">
+ <tr>
+ <td id="infopaneName" class="infopaneTitle">
+ </td>
+ <td id="infopaneRating" class="infopaneRating">
+ <f:view>
+ <ui:rating id="rating" maxGrade="5" includeNotInterested="false" includeClear="false"
+ hoverTexts="#{RatingBean.ratingText}" notInterestedHoverText="Not Interested" clearHoverText="Clear Rating"
+ grade="#{RatingBean.grade}"/>
+ <f:verbatim></td><td id="infopanePrice" class="infopanePrice"></td><td id="infopanePayPal" class="infopanePayPal"></f:verbatim>
+ <ui:buyNow business="donate(a)animalfoundation.com" id="buyNow1" itemName="Buy Item One"
+ amount="100.00" quantity="1" type="BuyNow" postData="#{PayPalBean.postData}" target="paypal"/>
+ </f:view>
+ </td>
+ <td id="infopaneIndicator" class="infopaneIndicator">
+ </td>
+ <td id="infopaneDetailsIcon">
+ </td>
+ </tr>
+ <tr>
+ <td id="infopaneShortDescription" colspan="7" class="infopaneShortDescription">
+ </td>
+ </tr>
+ <tr style="height:20px">
+ <td></td>
+ </tr>
+ <tr>
+ <td id="infopaneDescription" colspan="6" class="infopaneDescription">
+ </td>
+ </tr>
+ </table>
+ </div>
+ </td>
+ </tr>
+ </table>
+ </td>
+ <td style="vertical-align:top; width:300px; text-align:right;">
+ <div id="downloadAds">
+ <jsp:include page="download.jsp" />
+ </div>
+ </td>
+ </tr>
+ </table>
+ </div>
+ <div id="status" style="text-align:left"></div> <div id="status_2"></div>
+ <div id="dstatus"></div>
+ <div id="injection_point"></div>
+</center>
+<jsp:include page="footer.jsp" />
+</body>
</html>
\ No newline at end of file
diff --git a/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/common.js b/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/common.js
index 0becd96..03a3ba2 100644
--- a/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/common.js
+++ b/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/common.js
@@ -1,77 +1,77 @@
-
- function ajaxBindError(type, errObj) {
- // can't use the error page, because unless and exception in the internal servlet container
- // nullpointer exceptions will be thrown
- //window.location="./systemerror.jsp?message=" + errObj.message;
-
- alert("An Exception has been encountered on the server side during an Ajax request. Please see the server logs for more information " + errObj.message);
- }
-
-
- function debugProperties(namex) {
- var listx="";
- var ob=namex;
- for(xx in ob) {
- listx += xx + " = " + ob[xx] + "<br/>"
- }
- //document.write(listx);
- alert(listx);
- }
-
-
- function printDebug(argx) {
- if (typeof debug != 'undefined') {
- document.getElementById("status").innerHTML = argx + "<br\>" + document.getElementById("status").innerHTML;
- }
- }
-
-
- function Map() {
- var size = 0;
- var keys = [];
- var values = [];
-
- this.put = function(key, value, replace) {
- if (this.get(key) == null) {
- keys[size] = key;
- values[size] = value;
- size++;
- } else if (replace) {
- for (i=0; i < size; i++) {
- if (keys[i] == key) {
- values[i] = value;
- }
- }
- }
- }
-
- this.get = function(key) {
- for (i=0; i < size; i++) {
- if (keys[i] == key) {
- return values[i];
- }
- }
- return null;
- }
-
- this.clear = function() {
- size = 0;
- keys = [];
- values = [];
- }
-
- // return keys show can show main image
- this.getKeys = function() {
- return keys;
- }
-
- // dump contents of map keys as string
- this.contents = function() {
- var retx="";
- for(ii=0; ii < size; ii++) {
- retx += keys[ii] + ", ";
- }
- return retx;
- }
-
+
+ function ajaxBindError(type, errObj) {
+ // can't use the error page, because unless and exception in the internal servlet container
+ // nullpointer exceptions will be thrown
+ //window.location="./systemerror.jsp?message=" + errObj.message;
+
+ alert("An Exception has been encountered on the server side during an Ajax request. Please see the server logs for more information " + errObj.message);
+ }
+
+
+ function debugProperties(namex) {
+ var listx="";
+ var ob=namex;
+ for(xx in ob) {
+ listx += xx + " = " + ob[xx] + "<br/>"
+ }
+ //document.write(listx);
+ alert(listx);
+ }
+
+
+ function printDebug(argx) {
+ if (typeof debug != 'undefined') {
+ document.getElementById("status").innerHTML = argx + "<br\>" + document.getElementById("status").innerHTML;
+ }
+ }
+
+
+ function Map() {
+ var size = 0;
+ var keys = [];
+ var values = [];
+
+ this.put = function(key, value, replace) {
+ if (this.get(key) == null) {
+ keys[size] = key;
+ values[size] = value;
+ size++;
+ } else if (replace) {
+ for (i=0; i < size; i++) {
+ if (keys[i] == key) {
+ values[i] = value;
+ }
+ }
+ }
+ }
+
+ this.get = function(key) {
+ for (i=0; i < size; i++) {
+ if (keys[i] == key) {
+ return values[i];
+ }
+ }
+ return null;
+ }
+
+ this.clear = function() {
+ size = 0;
+ keys = [];
+ values = [];
+ }
+
+ // return keys show can show main image
+ this.getKeys = function() {
+ return keys;
+ }
+
+ // dump contents of map keys as string
+ this.contents = function() {
+ var retx="";
+ for(ii=0; ii < size; ii++) {
+ retx += keys[ii] + ", ";
+ }
+ return retx;
+ }
+
}
\ No newline at end of file
diff --git a/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/downloadAd.js b/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/downloadAd.js
index 3feb219..65855c2 100644
--- a/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/downloadAd.js
+++ b/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/downloadAd.js
@@ -1,54 +1,54 @@
-dojo.require("dojo.io");
-function checkAdPage() {
- var bindArgs = {
- // check to see if an updated page is available
- URL: "http://localhost:8080/petstore/downloadAd.txt",
- mimetype: "text/plain",
- load: returnFunctionx,
- error: ajaxBindError};
-
- // dispatch the request
- dojo.io.bind(bindArgs);
-}
-
-function returnFunctionx(type, data, evt) {
- // statically setup popup for simple case
- // check return of the dojo call to make sure it is valid
- if (evt.readyState == 4) {
- if (evt.status == 200) {
- alert("data = " + data);
- document.getElementById("downloadAds").innerHTML=data;
- }
- }
-}
-
-
-var req;
-
-function checkAdPageMark() {
- // calculate arrow and border image location
- req=initRequest();
-
- url="http://blueprints.dev.java.net/petstore/downloadAd.txt",
- req.onreadystatechange = returnFunctionxMark;
- req.open("GET", url, true);
- req.send(null);
-}
-
-
-function returnFunctionxMark() {
- if (req.readyState == 4) {
- if (req.status == 200) {
- alert("data = " + req.responseText);
- document.getElementById("downloadAds").innerHTML=req.responseText;
- }
- }
-}
-
-initRequest=function() {
- if (window.XMLHttpRequest) {
- return new XMLHttpRequest();
- } else if (window.ActiveXObject) {
- return new ActiveXObject("Microsoft.XMLHTTP");
- }
-}
+dojo.require("dojo.io");
+function checkAdPage() {
+ var bindArgs = {
+ // check to see if an updated page is available
+ URL: "http://localhost:8080/petstore/downloadAd.txt",
+ mimetype: "text/plain",
+ load: returnFunctionx,
+ error: ajaxBindError};
+
+ // dispatch the request
+ dojo.io.bind(bindArgs);
+}
+
+function returnFunctionx(type, data, evt) {
+ // statically setup popup for simple case
+ // check return of the dojo call to make sure it is valid
+ if (evt.readyState == 4) {
+ if (evt.status == 200) {
+ alert("data = " + data);
+ document.getElementById("downloadAds").innerHTML=data;
+ }
+ }
+}
+
+
+var req;
+
+function checkAdPageMark() {
+ // calculate arrow and border image location
+ req=initRequest();
+
+ url="http://blueprints.dev.java.net/petstore/downloadAd.txt",
+ req.onreadystatechange = returnFunctionxMark;
+ req.open("GET", url, true);
+ req.send(null);
+}
+
+
+function returnFunctionxMark() {
+ if (req.readyState == 4) {
+ if (req.status == 200) {
+ alert("data = " + req.responseText);
+ document.getElementById("downloadAds").innerHTML=req.responseText;
+ }
+ }
+}
+
+initRequest=function() {
+ if (window.XMLHttpRequest) {
+ return new XMLHttpRequest();
+ } else if (window.ActiveXObject) {
+ return new ActiveXObject("Microsoft.XMLHTTP");
+ }
+}
diff --git a/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/engine.js b/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/engine.js
index e43d49b..0e5b14e 100644
--- a/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/engine.js
+++ b/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/engine.js
@@ -1,241 +1,241 @@
-/* Copyright 2006 Sun Microsystems, Inc. All rights reserved. You may not modify, use, reproduce, or distribute this software except in compliance with the terms of the License at: http://developer.sun.com/berkeley_license.html
-$Id: engine.js,v 1.10 2006/05/03 22:00:32 inder Exp $ */
-
-function Engine () {
-
- /**
- *
- * Load template text aloing with an associated script
- *
- * Argument p properties are as follows:
- *
- * url : Not required but used if you want to get the template from
- * something other than the injection serlvet. For example if
- * you want to load content directly from a a JSP or HTML file.
- *
- * p.template : Not required if you specficy a url property Otherewise this
- * is the name of the template file.
- *
- * p.initFunction: Not required. This function or function pointer will be called
- * after the template text and script are loaded. The result of
- * the evaluated script will be accessible in the context of
- * this function.
- *
- * p.injectionPoint: Not required. This is the id of an element into. If this is
- * not specfied a div will be created under the roon node of
- * the document and the template will be injected into it.
- * Content is injected by setting the innerHTML property
- * of an element to the template text.
- */
- this.inject = function (p) {
- var targetUrl;
- if (!p.url) targetUrl = "controller?command=content&target=/" + p.template;
- else targetUrl = p.url;
- var templateArgs = {
- url: targetUrl,
- mimetype: "text/html",
- load: function(type, data) {
- //if no parent is given append to the document root
- var nData = includeEmbeddedResources(data, p.initFunction );
- if (!p.injectionPoint) {
- var injectionPoint = document.createElement("div");
- injectionPoint.innerHTML = nData;
- document.firstChild.appendChild(injectionPoint);
- } else {
- p.injectionPoint.innerHTML = nData;
- }
- if (p.script) {
- // now load the associated JavaScript
- loadScript(p.script,p.initFunction);
- }
- }
- };
- dojo.io.bind(templateArgs);
- }
-
- function loadScript(targetURL,callback) {
- var templateArgs = {
- url: targetURL,
- mimetype: "text/plain",
- load: callback
- };
- dojo.io.bind(templateArgs);
- }
-
- /**
- * If were returning an text document remove any script in the
- * the document and add it to the global scope using a time out.
- */
- function includeEmbeddedResources(target, initFunction) {
- var bodyText = "";
- var embeddedScripts = [];
- var embeddedStyles = [];
- var scriptReferences = [];
- var styleReferences = [];
- var styles = [];
- // recursively go through and weed out the scripts
- // TODO: Use some better REGEX processing
- // TODO: Also support single quotes
- while (target.indexOf("<script") != -1) {
- var realStart = target.indexOf("<script");
- var scriptSourceStart = target.indexOf("src=", (realStart));
- var scriptElementEnd = target.indexOf(">", realStart);
- var end = target.indexOf("</script>", (realStart)) + "</script>".length;
- if (realStart != -1 && scriptSourceStart != -1) {
- var scriptSourceName;
- var scriptSourceLinkStart= scriptSourceStart + 5;
- var scriptSourceLinkEnd= target.indexOf("\"", (scriptSourceLinkStart + 1));
- if (scriptSourceStart < scriptElementEnd) {
- scriptSourceName = target.substring(scriptSourceLinkStart, scriptSourceLinkEnd);
- // prevent multiple inclusions of dojo.js.
- // there is no way you would get to this point without dojo being included
- if (scriptSourceName.indexOf("dojo.js") == -1) {
- scriptReferences.push(scriptSourceName);
- }
- }
- }
- // now remove the script body
- var scriptBodyStart = scriptElementEnd + 1;
- var sBody = target.substring(scriptBodyStart, end - "</script>".length);
- if (sBody.length > 0) {
- embeddedScripts.push(sBody);
- }
- //remove script
- target = target.substring(0, realStart) + target.substring(end, target.length);
- }
-
- while (target.indexOf("<style") != -1) {
- var realStart = target.indexOf("<style");
- var styleElementEnd = target.indexOf(">", realStart);
- var end = target.indexOf("</style>", (realStart)) ;
- var styleBodyStart = styleElementEnd + 1;
- var sBody = target.substring(styleBodyStart, end);
- if (sBody.length > 0) {
- embeddedStyles.push(sBody);
- }
- //remove style
- target = target.substring(0, realStart) + target.substring(end + "</style>".length, target.length);
- }
- // get the links
- while (target.indexOf("<link") != -1) {
- var realStart = target.indexOf("<link");
- var styleSourceStart = target.indexOf("href=", (realStart));
- var styleElementEnd = target.indexOf(">", realStart) +1;
- if (realStart != -1 && styleSourceStart != -1) {
- var styletSourceName;
- var styleSourceLinkStart= styleSourceStart + 6;
- var styleSourceLinkEnd= target.indexOf("\"", (styleSourceLinkStart + 1));
- if (styleSourceStart < styleElementEnd) {
- styleSourceName = target.substring(styleSourceLinkStart, styleSourceLinkEnd);
- styleReferences.push(styleSourceName);
- }
- //remove style
- target = target.substring(0, realStart) + target.substring(styleElementEnd, target.length);
- }
- }
-
- var head = document.getElementsByTagName("head")[0];
-
- // inject the links
- for(var loop = 0; loop < styleReferences.length; loop++) {
- var link = document.createElement("link");
- link.href = styleReferences[loop];
- link.type = "text/css";
- link.rel = "stylesheet";
- head.appendChild(link);
- }
-
- var stylesElement;
- if (embeddedStyles.length > 0) {
- stylesElement = document.createElement("style");
- stylesElement.type="text/css";
- var stylesText;
- for(var loop = 0; loop < embeddedStyles.length; loop++) {
- stylesText = stylesText + embeddedStyles[loop];
- }
- if (document.styleSheets[0].cssText) {
- document.styleSheets[0].cssText = document.styleSheets[0].cssText + stylesText;
- } else {
- stylesElement.appendChild(document.createTextNode(stylesText));
- head.appendChild(stylesElement);
- }
- }
-
- scriptLoader(scriptReferences, 0, function() {
- this.embeddedScripts = embeddedScripts;
- // evaluate the embedded javascripts in the order they were added
- // consider using an onload handler
- for(var loop = 0; loop < embeddedScripts.length; loop++) {
- //alert("evaluating " + embeddedScripts[loop]);
- var script = embeddedScripts[loop];
- // append to the script a method to call the scriptLoaderCallback
- eval(script);
- if (loop == (embeddedScripts.length -1)) {
- initFunction();
- }
- }
- });
-
- return target;
- }
-
-
- /**
- * Load the scripts in order and load them one after on another
- */
- function scriptLoader(scripts, index, callbackFunction) {
- var head = document.getElementsByTagName("head").item(0);
- var scriptElement = document.createElement("script");
- scriptElement.id = "c_script_" + index;
- scriptElement.type = "text/javascript";
-
- var loadHandler = function () {
- if (index < scripts.length && index != scripts.length -1) {
- scriptLoader(scripts, ++index, callbackFunction);
- } else {
- callbackFunction();
- }
- }
- if (typeof scriptElement.onreadystatechange != 'undefined') {
- scriptElement.onreadystatechange = function () {
- if (this.readyState == 'loaded') {
- loadHandler();
- }
- };
- }
- scriptElement.onload = loadHandler;
-
- // Safari not seeing the onload event and does not support the onreadystate
- if (navigator.userAgent.toLowerCase().indexOf("safari") != -1) {
- scriptElement.src = scripts[index];
- setTimeout(loadHandler, 0);
- }
- head.appendChild(scriptElement);
- setTimeout("document.getElementById('c_script_" + index + "').src ='" + scripts[index] + "'", 0);
-
- scriptElement = null;
- head = null;
- }
-
- /**
- * If were returning an XML document remove any script in the
- * the document and add it to the global scope using a time out.
- */
- function includeEmbeddedScripts(xmlDocument) {
- var items = new Array();
- var xmlDocument = document.getElementsByTagName("script");
-
- for(var loop = 0; loop < targets.length; loop++) {
- var children = targets[loop].childNodes;
- var iScript = "";
- for(var innerLoop = 0; innerLoop < children.length; innerLoop++) {
- iScript += children[innerLoop].data;
- }
- items.add(iScript);
- children[loop].parentNode.removeChild(children[loop]);
- }
- for(var loop = 0; loop < items.length; loop++) {
- setTimeout(items[loop],0);
- }
- }
-}
+/* Copyright 2006 Sun Microsystems, Inc. All rights reserved. You may not modify, use, reproduce, or distribute this software except in compliance with the terms of the License at: http://developer.sun.com/berkeley_license.html
+$Id: engine.js,v 1.10 2006/05/03 22:00:32 inder Exp $ */
+
+function Engine () {
+
+ /**
+ *
+ * Load template text aloing with an associated script
+ *
+ * Argument p properties are as follows:
+ *
+ * url : Not required but used if you want to get the template from
+ * something other than the injection serlvet. For example if
+ * you want to load content directly from a a JSP or HTML file.
+ *
+ * p.template : Not required if you specficy a url property Otherewise this
+ * is the name of the template file.
+ *
+ * p.initFunction: Not required. This function or function pointer will be called
+ * after the template text and script are loaded. The result of
+ * the evaluated script will be accessible in the context of
+ * this function.
+ *
+ * p.injectionPoint: Not required. This is the id of an element into. If this is
+ * not specfied a div will be created under the roon node of
+ * the document and the template will be injected into it.
+ * Content is injected by setting the innerHTML property
+ * of an element to the template text.
+ */
+ this.inject = function (p) {
+ var targetUrl;
+ if (!p.url) targetUrl = "controller?command=content&target=/" + p.template;
+ else targetUrl = p.url;
+ var templateArgs = {
+ url: targetUrl,
+ mimetype: "text/html",
+ load: function(type, data) {
+ //if no parent is given append to the document root
+ var nData = includeEmbeddedResources(data, p.initFunction );
+ if (!p.injectionPoint) {
+ var injectionPoint = document.createElement("div");
+ injectionPoint.innerHTML = nData;
+ document.firstChild.appendChild(injectionPoint);
+ } else {
+ p.injectionPoint.innerHTML = nData;
+ }
+ if (p.script) {
+ // now load the associated JavaScript
+ loadScript(p.script,p.initFunction);
+ }
+ }
+ };
+ dojo.io.bind(templateArgs);
+ }
+
+ function loadScript(targetURL,callback) {
+ var templateArgs = {
+ url: targetURL,
+ mimetype: "text/plain",
+ load: callback
+ };
+ dojo.io.bind(templateArgs);
+ }
+
+ /**
+ * If were returning an text document remove any script in the
+ * the document and add it to the global scope using a time out.
+ */
+ function includeEmbeddedResources(target, initFunction) {
+ var bodyText = "";
+ var embeddedScripts = [];
+ var embeddedStyles = [];
+ var scriptReferences = [];
+ var styleReferences = [];
+ var styles = [];
+ // recursively go through and weed out the scripts
+ // TODO: Use some better REGEX processing
+ // TODO: Also support single quotes
+ while (target.indexOf("<script") != -1) {
+ var realStart = target.indexOf("<script");
+ var scriptSourceStart = target.indexOf("src=", (realStart));
+ var scriptElementEnd = target.indexOf(">", realStart);
+ var end = target.indexOf("</script>", (realStart)) + "</script>".length;
+ if (realStart != -1 && scriptSourceStart != -1) {
+ var scriptSourceName;
+ var scriptSourceLinkStart= scriptSourceStart + 5;
+ var scriptSourceLinkEnd= target.indexOf("\"", (scriptSourceLinkStart + 1));
+ if (scriptSourceStart < scriptElementEnd) {
+ scriptSourceName = target.substring(scriptSourceLinkStart, scriptSourceLinkEnd);
+ // prevent multiple inclusions of dojo.js.
+ // there is no way you would get to this point without dojo being included
+ if (scriptSourceName.indexOf("dojo.js") == -1) {
+ scriptReferences.push(scriptSourceName);
+ }
+ }
+ }
+ // now remove the script body
+ var scriptBodyStart = scriptElementEnd + 1;
+ var sBody = target.substring(scriptBodyStart, end - "</script>".length);
+ if (sBody.length > 0) {
+ embeddedScripts.push(sBody);
+ }
+ //remove script
+ target = target.substring(0, realStart) + target.substring(end, target.length);
+ }
+
+ while (target.indexOf("<style") != -1) {
+ var realStart = target.indexOf("<style");
+ var styleElementEnd = target.indexOf(">", realStart);
+ var end = target.indexOf("</style>", (realStart)) ;
+ var styleBodyStart = styleElementEnd + 1;
+ var sBody = target.substring(styleBodyStart, end);
+ if (sBody.length > 0) {
+ embeddedStyles.push(sBody);
+ }
+ //remove style
+ target = target.substring(0, realStart) + target.substring(end + "</style>".length, target.length);
+ }
+ // get the links
+ while (target.indexOf("<link") != -1) {
+ var realStart = target.indexOf("<link");
+ var styleSourceStart = target.indexOf("href=", (realStart));
+ var styleElementEnd = target.indexOf(">", realStart) +1;
+ if (realStart != -1 && styleSourceStart != -1) {
+ var styletSourceName;
+ var styleSourceLinkStart= styleSourceStart + 6;
+ var styleSourceLinkEnd= target.indexOf("\"", (styleSourceLinkStart + 1));
+ if (styleSourceStart < styleElementEnd) {
+ styleSourceName = target.substring(styleSourceLinkStart, styleSourceLinkEnd);
+ styleReferences.push(styleSourceName);
+ }
+ //remove style
+ target = target.substring(0, realStart) + target.substring(styleElementEnd, target.length);
+ }
+ }
+
+ var head = document.getElementsByTagName("head")[0];
+
+ // inject the links
+ for(var loop = 0; loop < styleReferences.length; loop++) {
+ var link = document.createElement("link");
+ link.href = styleReferences[loop];
+ link.type = "text/css";
+ link.rel = "stylesheet";
+ head.appendChild(link);
+ }
+
+ var stylesElement;
+ if (embeddedStyles.length > 0) {
+ stylesElement = document.createElement("style");
+ stylesElement.type="text/css";
+ var stylesText;
+ for(var loop = 0; loop < embeddedStyles.length; loop++) {
+ stylesText = stylesText + embeddedStyles[loop];
+ }
+ if (document.styleSheets[0].cssText) {
+ document.styleSheets[0].cssText = document.styleSheets[0].cssText + stylesText;
+ } else {
+ stylesElement.appendChild(document.createTextNode(stylesText));
+ head.appendChild(stylesElement);
+ }
+ }
+
+ scriptLoader(scriptReferences, 0, function() {
+ this.embeddedScripts = embeddedScripts;
+ // evaluate the embedded javascripts in the order they were added
+ // consider using an onload handler
+ for(var loop = 0; loop < embeddedScripts.length; loop++) {
+ //alert("evaluating " + embeddedScripts[loop]);
+ var script = embeddedScripts[loop];
+ // append to the script a method to call the scriptLoaderCallback
+ eval(script);
+ if (loop == (embeddedScripts.length -1)) {
+ initFunction();
+ }
+ }
+ });
+
+ return target;
+ }
+
+
+ /**
+ * Load the scripts in order and load them one after on another
+ */
+ function scriptLoader(scripts, index, callbackFunction) {
+ var head = document.getElementsByTagName("head").item(0);
+ var scriptElement = document.createElement("script");
+ scriptElement.id = "c_script_" + index;
+ scriptElement.type = "text/javascript";
+
+ var loadHandler = function () {
+ if (index < scripts.length && index != scripts.length -1) {
+ scriptLoader(scripts, ++index, callbackFunction);
+ } else {
+ callbackFunction();
+ }
+ }
+ if (typeof scriptElement.onreadystatechange != 'undefined') {
+ scriptElement.onreadystatechange = function () {
+ if (this.readyState == 'loaded') {
+ loadHandler();
+ }
+ };
+ }
+ scriptElement.onload = loadHandler;
+
+ // Safari not seeing the onload event and does not support the onreadystate
+ if (navigator.userAgent.toLowerCase().indexOf("safari") != -1) {
+ scriptElement.src = scripts[index];
+ setTimeout(loadHandler, 0);
+ }
+ head.appendChild(scriptElement);
+ setTimeout("document.getElementById('c_script_" + index + "').src ='" + scripts[index] + "'", 0);
+
+ scriptElement = null;
+ head = null;
+ }
+
+ /**
+ * If were returning an XML document remove any script in the
+ * the document and add it to the global scope using a time out.
+ */
+ function includeEmbeddedScripts(xmlDocument) {
+ var items = new Array();
+ var xmlDocument = document.getElementsByTagName("script");
+
+ for(var loop = 0; loop < targets.length; loop++) {
+ var children = targets[loop].childNodes;
+ var iScript = "";
+ for(var innerLoop = 0; innerLoop < children.length; innerLoop++) {
+ iScript += children[innerLoop].data;
+ }
+ items.add(iScript);
+ children[loop].parentNode.removeChild(children[loop]);
+ }
+ for(var loop = 0; loop < items.length; loop++) {
+ setTimeout(items[loop],0);
+ }
+ }
+}
commit 5fcef6805ab1a3976c88ce24f184e236a6ebf975
Merge: 2024dac... 051595c...
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Apr 27 13:51:25 2010 -0400
Merge branch 'master' into gwt
commit 2024dacbc934ccb3dddda8efba303b2a8d00d3ee
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Apr 27 13:51:18 2010 -0400
LT commit
diff --git a/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/accordion.js b/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/accordion.js
index 0bb7325..1c1ee6b 100644
--- a/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/accordion.js
+++ b/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/accordion.js
@@ -1,249 +1,249 @@
-/* Copyright 2006 Sun Microsystems, Inc. All rights reserved. You may not modify, use, reproduce, or distribute this software except in compliance with the terms of the License at: http://developer.sun.com/berkeley_license.html
-$Id: accordion.js,v 1.22 2006/05/03 22:00:32 inder Exp $ */
-
-function AccordionMenu () {
-
- dojo.event.topic.subscribe("/accordion", this, this.handleEvent);
-
- var displayPortWidth = 100;
- var HEIGHT = 400;
-
- var EXPANDED_HEIGHT = 125;
- var ITEM_HEIGHT = 55;
- var INCREMENT = 10;
-
- var timeout = 5; // in ms
-
- var accordion = document.getElementById("accordionBody");
- var divs = [];
- var oExpandedIndex = -1;
- var nExpandedIndex = -1;
- var oHeight = ITEM_HEIGHT;
- var nHeight = ITEM_HEIGHT;
- var tHeight = 165;
- var expanding = false;
- var categories;
-
- // while control the inline debug statements
- var debug = false;
- var status = document.getElementById("status");
-
- function Row(id, div, defaultHeight) {
- this.id = id;
- this.div = div;
- //this.height = height;
- this.h = defaultHeight;
- this.div.style.height = defaultHeight + "px"
- }
-
- Row.prototype.setHeight = function(nH) {
- this.h = nH;
- this.div.style.height = nH + "px";
- // re-adjust for ie in that it does not follow the boxmodel
- if (this.div.offsetHeight > nH) {
- this.div.style.height = (nH - (this.div.offsetHeight - nH)) + 'px';
- }
- }
-
- Row.prototype.getTotalHeight = function() {
- return this.div.offsetHeight;
- }
-
- Row.prototype.getHeight = function() {
- return this.h;
- }
-
- this.handleEvent = function(args) {
- if (args.type) {
- if (args.type == 'expand') {
- var targetRow = args.targetRow;
- initiateExpansion(targetRow);
- }
- }
- }
-
- this.load = function(lcategories) {
- categories = lcategories;
- // create all the rows
- for (var l=0; l < categories.length; l++) {
- var row = createRow(l,"accordionRow", ITEM_HEIGHT);
- createLinks(row.div, categories[l].name, l, "accordionLink");
- divs.push(row);
- }
- }
-
- function showStatus() {
- if (debug) {
- var stat = "oExpandedIndex=" + oExpandedIndex + " " ;
- for (var i=0; i < divs.length; i++) {
- stat = stat + i + "=" + divs[i].getTotalHeight() + " ";
- }
- status.innerHTML = stat + " total height=" + accordion.offsetHeight;
- var totalH = 0;
- var tH = 0;
- for (var i=0; i < divs.length; i++) {
- totalH = totalH + divs[i].getHeight();
- tH = tH + divs[i].getTotalHeight();
- }
- }
- }
-
- this.showCategory = function(catid) {
- for (var l=0; l < categories.length; l++) {
- if (catid == categories[l].name) {
- // now tell the scroller to load the first product
- initiateExpansion(l);
- if (categories[l].products[0]) {
- dojo.event.topic.publish("/catalog", {type:"showProducts", productId:categories[l].products[0].id});
- }
- break;
- }
- }
- }
-
- this.showFirstCategory = function() {
- initiateExpansion(0);
- if (categories[0].products[0]) {
- dojo.event.topic.publish("/catalog", {type:"showProducts", productId:categories[0].products[0].id});
- }
- }
-
- this.loadCategoryItem = function(pid, itemId) {
- // find the right product and expand the accordion
- for (var l=0; l < categories.length; l++) {
- // now tell the scroller to load the first product
- for (var il=0; il < categories[l].products.length; il++) {
- if (categories[l].products[il].id == pid ) {
- initiateExpansion(l);
- break;
- }
- }
- }
- dojo.event.topic.publish("/catalog", {type:"showItemDetails", productId: pid , itemId: itemId});
- }
-
- function initiateExpansion(id) {
- // jump out if we are in progress
- if (!expanding && oExpandedIndex != Number(id)) {
- expanding = true;
- nExpandedIndex = Number(id);
- if (oExpandedIndex != -1) {
- var targetDiv = divs[oExpandedIndex].div;
- if (targetDiv && targetDiv.childNodes) {
- for (var l = targetDiv.childNodes.length -1; l >= 0 ; l--) {
- targetDiv.removeChild(targetDiv.childNodes[l]);
- }
- }
- createLinks(divs[oExpandedIndex].div, categories[oExpandedIndex].name, oExpandedIndex, "accordionLink");
- }
- expandRow(id);
- }
- }
-
- function expandRow() {
- if (expanding) {
- showStatus();
- //
- if (nHeight < EXPANDED_HEIGHT) {
- nHeight = nHeight + INCREMENT;
- divs[nExpandedIndex].setHeight(nHeight);
- if (oExpandedIndex != -1) {
- if (tHeight >= ITEM_HEIGHT) {
- oHeight = oHeight - INCREMENT;
- // take all out of the old expanded
- } else {
- oHeight = oHeight - INCREMENT;
- }
- divs[oExpandedIndex].setHeight(oHeight);
- }
- // default exapnd here
- } else if (oExpandedIndex != -1 && oHeight > ITEM_HEIGHT) {
- oHeight = oHeight - INCREMENT;
- divs[oExpandedIndex].setHeight(oHeight);
- } else {
- // set the contents of the new menu
- var targetDiv = divs[nExpandedIndex].div;
- if (targetDiv && targetDiv.childNodes) {
- for (var l = targetDiv.childNodes.length -1; l >= 0 ; l--) {
- targetDiv.removeChild(targetDiv.childNodes[l]);
- }
- }
- divs[nExpandedIndex].div.appendChild(document.createTextNode(categories[nExpandedIndex].name));
- divs[nExpandedIndex].div.appendChild(document.createElement("p"));
- for (var l= 0; l < categories[nExpandedIndex].products.length; l++) {
- var span = document.createElement("span");
- span.className = "accordionProduct";
- var link = document.createElement("a");
- var target = categories[nExpandedIndex].products[l].id;
- link.id = target;
- link.className = "accordionLink";
- // some browsers aren't setting the styles for hovers so forcing them
- link.setAttribute("onmouseover", "this.className='accordionLinkHover';");
- link.setAttribute("onmouseout", "this.className='accordionLink';");
- dojo.event.connect(link, "onclick", function(evt) {
- this._target = target
- var src;
- if (evt.target) {
- src = evt.target;
- } else if (evt.srcElement) {
- src = evt.srcElement;
- }
- //src.parentNode.className = "accordionLinkSelected";
- // set this so the next time around it can be removed;
- dojo.event.topic.publish("/catalog", {type:"showProducts", productId:src.id});
- });
- link.appendChild(document.createTextNode(categories[nExpandedIndex].products[l].name));
- span.appendChild(link);
- divs[nExpandedIndex].div.appendChild(span);
- if (l < categories[nExpandedIndex].products.length - 1) {
- divs[nExpandedIndex].div.appendChild(document.createElement("p"));
- }
- link = null;
- }
- expanding = false;
- oExpandedIndex = nExpandedIndex;
- nExpandedIndex = -1;
- oHeight = nHeight;
- nHeight = ITEM_HEIGHT;
- return;
- }
-
- setTimeout(expandRow, timeout);
- }
- }
-
- function createLinks(tDiv, text, id, linkStyle) {
- var link = document.createElement("a");
- link.className = linkStyle;
- link.appendChild(document.createTextNode(text));
- link.setAttribute("id", id);
- if (link.attachEvent) {
- link.attachEvent('onmouseover',function(e){initiateExpansion(e.srcElement.getAttribute("id"));});
- } else if (link.addEventListener) {
- link.addEventListener('mouseover',function(e){initiateExpansion(e.currentTarget.getAttribute("id"));}, true);
- }
- tDiv.appendChild(link);
- }
-
- function createRow(id, rowStyle, height) {
- var nDiv = document.createElement("div");
- nDiv.className = rowStyle;
- var row;
- var cell;
- if (accordion.insertRow) {
- row = accordion.insertRow(accordion.rows.length);
-
- } else {
- row = document.createElement("tr");
- accordion.appendChild(row);
- }
- if (row.inserCell) {
- cell = row.insertCell(0);
- } else {
- cell = document.createElement("td");
- row.appendChild(cell);
- }
- cell.appendChild(nDiv);
- return new Row(id, nDiv, height);
- }
-}
+/* Copyright 2006 Sun Microsystems, Inc. All rights reserved. You may not modify, use, reproduce, or distribute this software except in compliance with the terms of the License at: http://developer.sun.com/berkeley_license.html
+$Id: accordion.js,v 1.22 2006/05/03 22:00:32 inder Exp $ */
+
+function AccordionMenu () {
+
+ dojo.event.topic.subscribe("/accordion", this, this.handleEvent);
+
+ var displayPortWidth = 100;
+ var HEIGHT = 400;
+
+ var EXPANDED_HEIGHT = 125;
+ var ITEM_HEIGHT = 55;
+ var INCREMENT = 10;
+
+ var timeout = 5; // in ms
+
+ var accordion = document.getElementById("accordionBody");
+ var divs = [];
+ var oExpandedIndex = -1;
+ var nExpandedIndex = -1;
+ var oHeight = ITEM_HEIGHT;
+ var nHeight = ITEM_HEIGHT;
+ var tHeight = 165;
+ var expanding = false;
+ var categories;
+
+ // while control the inline debug statements
+ var debug = false;
+ var status = document.getElementById("status");
+
+ function Row(id, div, defaultHeight) {
+ this.id = id;
+ this.div = div;
+ //this.height = height;
+ this.h = defaultHeight;
+ this.div.style.height = defaultHeight + "px"
+ }
+
+ Row.prototype.setHeight = function(nH) {
+ this.h = nH;
+ this.div.style.height = nH + "px";
+ // re-adjust for ie in that it does not follow the boxmodel
+ if (this.div.offsetHeight > nH) {
+ this.div.style.height = (nH - (this.div.offsetHeight - nH)) + 'px';
+ }
+ }
+
+ Row.prototype.getTotalHeight = function() {
+ return this.div.offsetHeight;
+ }
+
+ Row.prototype.getHeight = function() {
+ return this.h;
+ }
+
+ this.handleEvent = function(args) {
+ if (args.type) {
+ if (args.type == 'expand') {
+ var targetRow = args.targetRow;
+ initiateExpansion(targetRow);
+ }
+ }
+ }
+
+ this.load = function(lcategories) {
+ categories = lcategories;
+ // create all the rows
+ for (var l=0; l < categories.length; l++) {
+ var row = createRow(l,"accordionRow", ITEM_HEIGHT);
+ createLinks(row.div, categories[l].name, l, "accordionLink");
+ divs.push(row);
+ }
+ }
+
+ function showStatus() {
+ if (debug) {
+ var stat = "oExpandedIndex=" + oExpandedIndex + " " ;
+ for (var i=0; i < divs.length; i++) {
+ stat = stat + i + "=" + divs[i].getTotalHeight() + " ";
+ }
+ status.innerHTML = stat + " total height=" + accordion.offsetHeight;
+ var totalH = 0;
+ var tH = 0;
+ for (var i=0; i < divs.length; i++) {
+ totalH = totalH + divs[i].getHeight();
+ tH = tH + divs[i].getTotalHeight();
+ }
+ }
+ }
+
+ this.showCategory = function(catid) {
+ for (var l=0; l < categories.length; l++) {
+ if (catid == categories[l].name) {
+ // now tell the scroller to load the first product
+ initiateExpansion(l);
+ if (categories[l].products[0]) {
+ dojo.event.topic.publish("/catalog", {type:"showProducts", productId:categories[l].products[0].id});
+ }
+ break;
+ }
+ }
+ }
+
+ this.showFirstCategory = function() {
+ initiateExpansion(0);
+ if (categories[0].products[0]) {
+ dojo.event.topic.publish("/catalog", {type:"showProducts", productId:categories[0].products[0].id});
+ }
+ }
+
+ this.loadCategoryItem = function(pid, itemId) {
+ // find the right product and expand the accordion
+ for (var l=0; l < categories.length; l++) {
+ // now tell the scroller to load the first product
+ for (var il=0; il < categories[l].products.length; il++) {
+ if (categories[l].products[il].id == pid ) {
+ initiateExpansion(l);
+ break;
+ }
+ }
+ }
+ dojo.event.topic.publish("/catalog", {type:"showItemDetails", productId: pid , itemId: itemId});
+ }
+
+ function initiateExpansion(id) {
+ // jump out if we are in progress
+ if (!expanding && oExpandedIndex != Number(id)) {
+ expanding = true;
+ nExpandedIndex = Number(id);
+ if (oExpandedIndex != -1) {
+ var targetDiv = divs[oExpandedIndex].div;
+ if (targetDiv && targetDiv.childNodes) {
+ for (var l = targetDiv.childNodes.length -1; l >= 0 ; l--) {
+ targetDiv.removeChild(targetDiv.childNodes[l]);
+ }
+ }
+ createLinks(divs[oExpandedIndex].div, categories[oExpandedIndex].name, oExpandedIndex, "accordionLink");
+ }
+ expandRow(id);
+ }
+ }
+
+ function expandRow() {
+ if (expanding) {
+ showStatus();
+ //
+ if (nHeight < EXPANDED_HEIGHT) {
+ nHeight = nHeight + INCREMENT;
+ divs[nExpandedIndex].setHeight(nHeight);
+ if (oExpandedIndex != -1) {
+ if (tHeight >= ITEM_HEIGHT) {
+ oHeight = oHeight - INCREMENT;
+ // take all out of the old expanded
+ } else {
+ oHeight = oHeight - INCREMENT;
+ }
+ divs[oExpandedIndex].setHeight(oHeight);
+ }
+ // default exapnd here
+ } else if (oExpandedIndex != -1 && oHeight > ITEM_HEIGHT) {
+ oHeight = oHeight - INCREMENT;
+ divs[oExpandedIndex].setHeight(oHeight);
+ } else {
+ // set the contents of the new menu
+ var targetDiv = divs[nExpandedIndex].div;
+ if (targetDiv && targetDiv.childNodes) {
+ for (var l = targetDiv.childNodes.length -1; l >= 0 ; l--) {
+ targetDiv.removeChild(targetDiv.childNodes[l]);
+ }
+ }
+ divs[nExpandedIndex].div.appendChild(document.createTextNode(categories[nExpandedIndex].name));
+ divs[nExpandedIndex].div.appendChild(document.createElement("p"));
+ for (var l= 0; l < categories[nExpandedIndex].products.length; l++) {
+ var span = document.createElement("span");
+ span.className = "accordionProduct";
+ var link = document.createElement("a");
+ var target = categories[nExpandedIndex].products[l].id;
+ link.id = target;
+ link.className = "accordionLink";
+ // some browsers aren't setting the styles for hovers so forcing them
+ link.setAttribute("onmouseover", "this.className='accordionLinkHover';");
+ link.setAttribute("onmouseout", "this.className='accordionLink';");
+ dojo.event.connect(link, "onclick", function(evt) {
+ this._target = target
+ var src;
+ if (evt.target) {
+ src = evt.target;
+ } else if (evt.srcElement) {
+ src = evt.srcElement;
+ }
+ //src.parentNode.className = "accordionLinkSelected";
+ // set this so the next time around it can be removed;
+ dojo.event.topic.publish("/catalog", {type:"showProducts", productId:src.id});
+ });
+ link.appendChild(document.createTextNode(categories[nExpandedIndex].products[l].name));
+ span.appendChild(link);
+ divs[nExpandedIndex].div.appendChild(span);
+ if (l < categories[nExpandedIndex].products.length - 1) {
+ divs[nExpandedIndex].div.appendChild(document.createElement("p"));
+ }
+ link = null;
+ }
+ expanding = false;
+ oExpandedIndex = nExpandedIndex;
+ nExpandedIndex = -1;
+ oHeight = nHeight;
+ nHeight = ITEM_HEIGHT;
+ return;
+ }
+
+ setTimeout(expandRow, timeout);
+ }
+ }
+
+ function createLinks(tDiv, text, id, linkStyle) {
+ var link = document.createElement("a");
+ link.className = linkStyle;
+ link.appendChild(document.createTextNode(text));
+ link.setAttribute("id", id);
+ if (link.attachEvent) {
+ link.attachEvent('onmouseover',function(e){initiateExpansion(e.srcElement.getAttribute("id"));});
+ } else if (link.addEventListener) {
+ link.addEventListener('mouseover',function(e){initiateExpansion(e.currentTarget.getAttribute("id"));}, true);
+ }
+ tDiv.appendChild(link);
+ }
+
+ function createRow(id, rowStyle, height) {
+ var nDiv = document.createElement("div");
+ nDiv.className = rowStyle;
+ var row;
+ var cell;
+ if (accordion.insertRow) {
+ row = accordion.insertRow(accordion.rows.length);
+
+ } else {
+ row = document.createElement("tr");
+ accordion.appendChild(row);
+ }
+ if (row.inserCell) {
+ cell = row.insertCell(0);
+ } else {
+ cell = document.createElement("td");
+ row.appendChild(cell);
+ }
+ cell.appendChild(nDiv);
+ return new Row(id, nDiv, height);
+ }
+}
diff --git a/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/catalog.js b/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/catalog.js
index dafa49d..4bdfc69 100644
--- a/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/catalog.js
+++ b/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/catalog.js
@@ -1,329 +1,329 @@
-/* Copyright 2006 Sun Microsystems, Inc. All rights reserved. You may not modify, use, reproduce, or distribute this software except in compliance with the terms of the License at: http://developer.sun.com/berkeley_license.html
-$Id: catalog.js,v 1.21 2007/01/17 22:16:44 basler Exp $ */
-
-var ac;
-var is;
-var controller;
-//var debug=true;
-
-function getApplicationContextRoot() {
- var urlArray=window.location.toString().split("/", 4);
- return "/" + urlArray[3];
-}
-
-var applicationContextRoot=getApplicationContextRoot();
-
-function initCatalog() {
- ac = new AccordionMenu();
- is = new ImageScroller();
- is.load();
- controller = new CatalogController();
- // wire in a listener for the rating component
- dojo.event.connect("before", bpui.rating, "doClick", controller, "modifyState");
- controller.initialize();
-}
-
-function CatalogController() {
- dojo.event.topic.subscribe("/catalog", this, handleEvent);
-
- // this object structure contains a list of the products and chunks that have been loaded
- var pList = new ProductList();
-
- var CHUNK_SIZE=7;
- var initalRating;
- var initalItem;
- var originalURL;
-
- // using this for some browsers that do not support innerHTML
- var useDOMInjection = false;
-
- var infoName = document.getElementById("infopaneName");
- var infoRating = document.getElementById("infopaneRating");
- var infoPrice = document.getElementById("infopanePrice");
- var infoBuyNow = document.getElementById("infopaneBuyNow");
- var infoShortDescription = document.getElementById("infopaneShortDescription");
- var infoDescription = document.getElementById("infopaneDescription");
- // for paypal
- var buyNowAmount = document.getElementById("buyNow1_amount");
- var buyNowItemName = document.getElementById("buyNow1_item_name");
-
- function handleEvent(args) {
- if (args.type == "showingItem") {
- // update the id on the ratring component
- if (typeof bpui != 'undefined') {
- var groupId = is.getGroupId();
- window.location.href= originalURL + "#" + groupId + "," + args.id;
- if (typeof bpui.rating != 'undefined') {
- // update the rating
- bpui.rating.state["rating"].bindings["itemId"]=args.id;
- bpui.rating.modifyDisplay("rating", args.rating, true);
- // get the currrent item
- showItemDetails(args.id);
- } else {
- initalItem = args.id;
- initalRating = args.rating;
- }
- } else {
- // things haven't been loaded to set the inital rating
- initalItem = args.id;
- initalRating = args.rating;
- }
- } else if (args.type == "getChunk") {
- populateItems(args.id, args.index, args.currentChunk, false);
-
- } else if (args.type == "showItemDetails") {
- showProductDetails(args.productId, args.itemId);
-
- } else if (args.type == "showProducts") {
- is.reset();
- populateItems(args.productId, 0, 0, true);
- }
- }
-
- function showItemDetails(id) {
- var i = is.getItems().get(id);
- setNodeText(infoName, i.name + "<br/><a href='javascript:controller.disableItem("" + id + "","" + i.name + "")'><font size='-1' color='white'><i>Flag as inappropriate</i></font></a>");
- setNodeText(infoPrice, i.price);
- setNodeText(infoShortDescription, i.shortDescription);
- setNodeText(infoDescription, i.description);
- // update the paypal
- buyNowAmount.value = i.price;
- buyNowItemName.value = i.name;
- }
-
- function setNodeText(t, text) {
- if (useDOMInjection) {
- t.lastChild.nodeValue = text;
- } else {
- t.innerHTML = text;
- }
- }
-
- this.initialize = function() {
- // check whether the innerHTML changes can be used in the infopane
- infoName.innerHTML = " ";
- if (!useDOMInjection && infoName.innerHTML != " ") {
- useDOMInjection = true;
-
- infoName.appendChild(document.createTextNode("Name"));
- infoPrice.appendChild(document.createTextNode("$0.00"));
- infoShortDescription.appendChild(document.createTextNode("<description>"));
- infoDescription.appendChild(document.createTextNode("<description>"));
- }
-
- var ratingInstance = bpui.rating.state["rating"];
- ratingInstance.grade = initalRating;
- bpui.rating.state["rating"].bindings["itemId"]=initalItem;
- bpui.rating.modifyDisplay("rating", initalRating, true);
- loadAccordion();
- }
-
-
- this.modifyState = function(arg, rating) {
- var itemId = initalItem;
- if (typeof bpui.rating.state["rating"].bindings["itemId"] != 'undefined') {
- itemId = bpui.rating.state["rating"].bindings["itemId"];
- }
- // set the cached rating to the new rating that was set.
- is.getItems().get(itemId).rating = rating;
- }
-
-
- function loadAccordion () {
- // go out and get the categories
- // this should be made more geric
- var bindArgs = {
- url: applicationContextRoot + "/catalog?command=categories&format=json",
- mimetype: "text/json",
- load: function(type,json) {
- ac.load(json);
- processURLParameters();
- },
- error: ajaxBindError
- };
- dojo.io.bind(bindArgs);
- }
-
- // this needs to happen after we have loaded the accordion data
- function processURLParameters() {
- originalURL = decodeURIComponent(window.location.href);
- var params = {};
- // look for the params
- if (originalURL.indexOf("#") != -1) {
- var qString = originalURL.split('#')[1];
- var args = qString.split(',');
- originalURL = originalURL.split('#')[0];
- ac.loadCategoryItem(args[0], args[1]);
- return;
- } else if (originalURL.indexOf("?") != -1) {
- var qString = originalURL.split('?')[1];
- // get rid of any bookmarking stuff
- if (qString.indexOf("#") != -1) {
- qString = qString.split('#')[0];
- originalURL = originalURL.split('#')[0];
- window.location.href = originalURL;
- }
- ps = qString.split('&');
- // now go through and create the params map as an object literal
- for (var i in ps) {
- var t = ps[i].split('=');
- params[t[0]] = t[1];
- }
- // first check for the item in product
- if (typeof params.itemId != 'undefined' && typeof params.pid != 'undefined') {
- ac.loadCategoryItem(params.pid, params.itemId);
- // next if there is a catid definition then do it
- } else if (typeof params.catid != 'undefined') {
- ac.showCategory(params.catid);
- }
- } else {
- // nothing is selected
- ac.showFirstCategory();
- }
- }
-
-
-
- function showProductDetails(pid, itemId) {
- is.reset();
- is.showProgressIndicator();
- var bindArgs = {
- url: applicationContextRoot + "/catalog?command=itemInChunk&pid=" + pid + "&itemId=" + itemId + "&length=" + CHUNK_SIZE,
- mimetype: "text/xml",
- load: function(type,data,postProcessHandler) {
- processProductData(data,true, pid, itemId);
- showItemDetails(itemId);
- is.doMaximize();
- },
- error: ajaxBindError
- };
- dojo.io.bind(bindArgs);
- }
-
-
-
- function populateItems(pid, index, neededChunk, showImage) {
- is.showProgressIndicator();
- is.setGroupId(pid);
- printDebug("populateItems - need to make sure displaying - pid=" + pid + " Chunk=" + neededChunk);
-
- // check to see if relevant scroller page is already loaded
- if(!is.containsChunk(pid + "_" + neededChunk)) {
-
- // not loaded, so see if it is in the cache
- if (pList.hasChunk(pid, neededChunk)) {
- // in cache, so add chunk to scroller
- printDebug("**** adding chunk from cache - pid=" + pid + " Chunk=" + neededChunk);
- is.addChunk(pid + "_" + neededChunk);
- is.addItems(pList.getChunk(pid, neededChunk));
-
- // show first image if you have it
- if(showImage && is.getScrollerItems().length > 0) {
- is.showImage(is.getScrollerItems()[0].id);
- }
-
- } else {
- // not in cache so load it
- startRetIndex=(neededChunk * CHUNK_SIZE);
-
- printDebug("**** retrieving chunk from server - pid=" + pid + " currentIndex=" + index + " startIndex=" + startRetIndex + " Chunk=" + neededChunk);
- var bindArgs = {
- url: applicationContextRoot + "/catalog?command=items&pid=" + pid + "&start=" + startRetIndex + "&length=" + CHUNK_SIZE,
- mimetype: "text/xml",
- load: function(type,data,postProcessHandler) {
- processProductData(data, showImage, pid, null, neededChunk);
- },
- error: ajaxBindError
- };
- dojo.io.bind(bindArgs);
- }
- } else {
- printDebug("*** items already showing");
- }
-
- }
-
-
- function processProductData(responseXML, showImage, pid, iId, chunkId) {
- var items = [];
- var count = responseXML.getElementsByTagName("item").length;
- for (var loop=0; loop < count ; loop++) {
-
- var item = responseXML.getElementsByTagName("item")[loop];
- var itemId = item.getElementsByTagName("id")[0].firstChild.nodeValue;
- var name = item.getElementsByTagName("name")[0].firstChild.nodeValue;
- var thumbURL = item.getElementsByTagName("image-tb-url")[0].firstChild.nodeValue;
- var imageURL = item.getElementsByTagName("image-url")[0].firstChild.nodeValue;
- var description = item.getElementsByTagName("description")[0].firstChild.nodeValue;
- var price = item.getElementsByTagName("price")[0].firstChild.nodeValue;
- var rating = item.getElementsByTagName("rating")[0].firstChild.nodeValue;
- var shortDescription;
- if (description.length > 71) {
- shortDescription = description.substring(0,71) + "...";
- } else {
- shortDescription = description;
- }
- var i = {id: itemId, name: name, image: imageURL, thumbnail: thumbURL, shortDescription: shortDescription, description: description, price:price, rating: rating};
- items.push(i);
- }
-
- // cache the chunks
- pList.addChunk(pid, chunkId, items);
- is.addItems(items);
- is.addChunk(pid + "_" + chunkId);
-
- if (showImage && iId == null) {
- is.setGroupId(pid);
- is.showImage(items[0].id);
- } else {
- is.setGroupId(pid);
- is.showImage(iId);
- }
- is.hideProgressIndicator();
- }
-
- function ProductList() {
- var _plist = this;
- var map = new Map();
-
- this.addChunk = function(pid, chunkNumber, items) {
- map.put(pid + "_" + chunkNumber, items, true);
- }
-
- this.getChunk = function(pid, chunkNumber) {
- return map.get(pid + "_" + chunkNumber);
- }
-
- this.hasChunk = function(pid, chunkNumber) {
- return (map.get(pid + "_" + chunkNumber) != null);
- }
-
- this.contents = function() {
- return map.contents();
- }
- }
-
-
- this.disableItem=function(itemId, itemName) {
- // go out and get the categories
- // this should be made more geric
- if (confirm("Are you sure you want to effectively remove this item from Petstore?")) {
- var bindArgs = {
- url: applicationContextRoot + "/catalog?command=disable&id=" + itemId,
- mimetype: "text/xml",
- load: function(type,json) {
- //alert("The item named '" + itemName + "' has been disabled!");
- pList = new ProductList();
- is.reset();
- populateItems(is.getGroupId(), 0, 0, true);
- },
- error: ajaxBindError
- };
- dojo.io.bind(bindArgs);
- }
- }
-
-
-}
-
-
+/* Copyright 2006 Sun Microsystems, Inc. All rights reserved. You may not modify, use, reproduce, or distribute this software except in compliance with the terms of the License at: http://developer.sun.com/berkeley_license.html
+$Id: catalog.js,v 1.21 2007/01/17 22:16:44 basler Exp $ */
+
+var ac;
+var is;
+var controller;
+//var debug=true;
+
+function getApplicationContextRoot() {
+ var urlArray=window.location.toString().split("/", 4);
+ return "/" + urlArray[3];
+}
+
+var applicationContextRoot=getApplicationContextRoot();
+
+function initCatalog() {
+ ac = new AccordionMenu();
+ is = new ImageScroller();
+ is.load();
+ controller = new CatalogController();
+ // wire in a listener for the rating component
+ dojo.event.connect("before", bpui.rating, "doClick", controller, "modifyState");
+ controller.initialize();
+}
+
+function CatalogController() {
+ dojo.event.topic.subscribe("/catalog", this, handleEvent);
+
+ // this object structure contains a list of the products and chunks that have been loaded
+ var pList = new ProductList();
+
+ var CHUNK_SIZE=7;
+ var initalRating;
+ var initalItem;
+ var originalURL;
+
+ // using this for some browsers that do not support innerHTML
+ var useDOMInjection = false;
+
+ var infoName = document.getElementById("infopaneName");
+ var infoRating = document.getElementById("infopaneRating");
+ var infoPrice = document.getElementById("infopanePrice");
+ var infoBuyNow = document.getElementById("infopaneBuyNow");
+ var infoShortDescription = document.getElementById("infopaneShortDescription");
+ var infoDescription = document.getElementById("infopaneDescription");
+ // for paypal
+ var buyNowAmount = document.getElementById("buyNow1_amount");
+ var buyNowItemName = document.getElementById("buyNow1_item_name");
+
+ function handleEvent(args) {
+ if (args.type == "showingItem") {
+ // update the id on the ratring component
+ if (typeof bpui != 'undefined') {
+ var groupId = is.getGroupId();
+ window.location.href= originalURL + "#" + groupId + "," + args.id;
+ if (typeof bpui.rating != 'undefined') {
+ // update the rating
+ bpui.rating.state["rating"].bindings["itemId"]=args.id;
+ bpui.rating.modifyDisplay("rating", args.rating, true);
+ // get the currrent item
+ showItemDetails(args.id);
+ } else {
+ initalItem = args.id;
+ initalRating = args.rating;
+ }
+ } else {
+ // things haven't been loaded to set the inital rating
+ initalItem = args.id;
+ initalRating = args.rating;
+ }
+ } else if (args.type == "getChunk") {
+ populateItems(args.id, args.index, args.currentChunk, false);
+
+ } else if (args.type == "showItemDetails") {
+ showProductDetails(args.productId, args.itemId);
+
+ } else if (args.type == "showProducts") {
+ is.reset();
+ populateItems(args.productId, 0, 0, true);
+ }
+ }
+
+ function showItemDetails(id) {
+ var i = is.getItems().get(id);
+ setNodeText(infoName, i.name + "<br/><a href='javascript:controller.disableItem("" + id + "","" + i.name + "")'><font size='-1' color='white'><i>Flag as inappropriate</i></font></a>");
+ setNodeText(infoPrice, i.price);
+ setNodeText(infoShortDescription, i.shortDescription);
+ setNodeText(infoDescription, i.description);
+ // update the paypal
+ buyNowAmount.value = i.price;
+ buyNowItemName.value = i.name;
+ }
+
+ function setNodeText(t, text) {
+ if (useDOMInjection) {
+ t.lastChild.nodeValue = text;
+ } else {
+ t.innerHTML = text;
+ }
+ }
+
+ this.initialize = function() {
+ // check whether the innerHTML changes can be used in the infopane
+ infoName.innerHTML = " ";
+ if (!useDOMInjection && infoName.innerHTML != " ") {
+ useDOMInjection = true;
+
+ infoName.appendChild(document.createTextNode("Name"));
+ infoPrice.appendChild(document.createTextNode("$0.00"));
+ infoShortDescription.appendChild(document.createTextNode("<description>"));
+ infoDescription.appendChild(document.createTextNode("<description>"));
+ }
+
+ var ratingInstance = bpui.rating.state["rating"];
+ ratingInstance.grade = initalRating;
+ bpui.rating.state["rating"].bindings["itemId"]=initalItem;
+ bpui.rating.modifyDisplay("rating", initalRating, true);
+ loadAccordion();
+ }
+
+
+ this.modifyState = function(arg, rating) {
+ var itemId = initalItem;
+ if (typeof bpui.rating.state["rating"].bindings["itemId"] != 'undefined') {
+ itemId = bpui.rating.state["rating"].bindings["itemId"];
+ }
+ // set the cached rating to the new rating that was set.
+ is.getItems().get(itemId).rating = rating;
+ }
+
+
+ function loadAccordion () {
+ // go out and get the categories
+ // this should be made more geric
+ var bindArgs = {
+ url: applicationContextRoot + "/catalog?command=categories&format=json",
+ mimetype: "text/json",
+ load: function(type,json) {
+ ac.load(json);
+ processURLParameters();
+ },
+ error: ajaxBindError
+ };
+ dojo.io.bind(bindArgs);
+ }
+
+ // this needs to happen after we have loaded the accordion data
+ function processURLParameters() {
+ originalURL = decodeURIComponent(window.location.href);
+ var params = {};
+ // look for the params
+ if (originalURL.indexOf("#") != -1) {
+ var qString = originalURL.split('#')[1];
+ var args = qString.split(',');
+ originalURL = originalURL.split('#')[0];
+ ac.loadCategoryItem(args[0], args[1]);
+ return;
+ } else if (originalURL.indexOf("?") != -1) {
+ var qString = originalURL.split('?')[1];
+ // get rid of any bookmarking stuff
+ if (qString.indexOf("#") != -1) {
+ qString = qString.split('#')[0];
+ originalURL = originalURL.split('#')[0];
+ window.location.href = originalURL;
+ }
+ ps = qString.split('&');
+ // now go through and create the params map as an object literal
+ for (var i in ps) {
+ var t = ps[i].split('=');
+ params[t[0]] = t[1];
+ }
+ // first check for the item in product
+ if (typeof params.itemId != 'undefined' && typeof params.pid != 'undefined') {
+ ac.loadCategoryItem(params.pid, params.itemId);
+ // next if there is a catid definition then do it
+ } else if (typeof params.catid != 'undefined') {
+ ac.showCategory(params.catid);
+ }
+ } else {
+ // nothing is selected
+ ac.showFirstCategory();
+ }
+ }
+
+
+
+ function showProductDetails(pid, itemId) {
+ is.reset();
+ is.showProgressIndicator();
+ var bindArgs = {
+ url: applicationContextRoot + "/catalog?command=itemInChunk&pid=" + pid + "&itemId=" + itemId + "&length=" + CHUNK_SIZE,
+ mimetype: "text/xml",
+ load: function(type,data,postProcessHandler) {
+ processProductData(data,true, pid, itemId);
+ showItemDetails(itemId);
+ is.doMaximize();
+ },
+ error: ajaxBindError
+ };
+ dojo.io.bind(bindArgs);
+ }
+
+
+
+ function populateItems(pid, index, neededChunk, showImage) {
+ is.showProgressIndicator();
+ is.setGroupId(pid);
+ printDebug("populateItems - need to make sure displaying - pid=" + pid + " Chunk=" + neededChunk);
+
+ // check to see if relevant scroller page is already loaded
+ if(!is.containsChunk(pid + "_" + neededChunk)) {
+
+ // not loaded, so see if it is in the cache
+ if (pList.hasChunk(pid, neededChunk)) {
+ // in cache, so add chunk to scroller
+ printDebug("**** adding chunk from cache - pid=" + pid + " Chunk=" + neededChunk);
+ is.addChunk(pid + "_" + neededChunk);
+ is.addItems(pList.getChunk(pid, neededChunk));
+
+ // show first image if you have it
+ if(showImage && is.getScrollerItems().length > 0) {
+ is.showImage(is.getScrollerItems()[0].id);
+ }
+
+ } else {
+ // not in cache so load it
+ startRetIndex=(neededChunk * CHUNK_SIZE);
+
+ printDebug("**** retrieving chunk from server - pid=" + pid + " currentIndex=" + index + " startIndex=" + startRetIndex + " Chunk=" + neededChunk);
+ var bindArgs = {
+ url: applicationContextRoot + "/catalog?command=items&pid=" + pid + "&start=" + startRetIndex + "&length=" + CHUNK_SIZE,
+ mimetype: "text/xml",
+ load: function(type,data,postProcessHandler) {
+ processProductData(data, showImage, pid, null, neededChunk);
+ },
+ error: ajaxBindError
+ };
+ dojo.io.bind(bindArgs);
+ }
+ } else {
+ printDebug("*** items already showing");
+ }
+
+ }
+
+
+ function processProductData(responseXML, showImage, pid, iId, chunkId) {
+ var items = [];
+ var count = responseXML.getElementsByTagName("item").length;
+ for (var loop=0; loop < count ; loop++) {
+
+ var item = responseXML.getElementsByTagName("item")[loop];
+ var itemId = item.getElementsByTagName("id")[0].firstChild.nodeValue;
+ var name = item.getElementsByTagName("name")[0].firstChild.nodeValue;
+ var thumbURL = item.getElementsByTagName("image-tb-url")[0].firstChild.nodeValue;
+ var imageURL = item.getElementsByTagName("image-url")[0].firstChild.nodeValue;
+ var description = item.getElementsByTagName("description")[0].firstChild.nodeValue;
+ var price = item.getElementsByTagName("price")[0].firstChild.nodeValue;
+ var rating = item.getElementsByTagName("rating")[0].firstChild.nodeValue;
+ var shortDescription;
+ if (description.length > 71) {
+ shortDescription = description.substring(0,71) + "...";
+ } else {
+ shortDescription = description;
+ }
+ var i = {id: itemId, name: name, image: imageURL, thumbnail: thumbURL, shortDescription: shortDescription, description: description, price:price, rating: rating};
+ items.push(i);
+ }
+
+ // cache the chunks
+ pList.addChunk(pid, chunkId, items);
+ is.addItems(items);
+ is.addChunk(pid + "_" + chunkId);
+
+ if (showImage && iId == null) {
+ is.setGroupId(pid);
+ is.showImage(items[0].id);
+ } else {
+ is.setGroupId(pid);
+ is.showImage(iId);
+ }
+ is.hideProgressIndicator();
+ }
+
+ function ProductList() {
+ var _plist = this;
+ var map = new Map();
+
+ this.addChunk = function(pid, chunkNumber, items) {
+ map.put(pid + "_" + chunkNumber, items, true);
+ }
+
+ this.getChunk = function(pid, chunkNumber) {
+ return map.get(pid + "_" + chunkNumber);
+ }
+
+ this.hasChunk = function(pid, chunkNumber) {
+ return (map.get(pid + "_" + chunkNumber) != null);
+ }
+
+ this.contents = function() {
+ return map.contents();
+ }
+ }
+
+
+ this.disableItem=function(itemId, itemName) {
+ // go out and get the categories
+ // this should be made more geric
+ if (confirm("Are you sure you want to effectively remove this item from Petstore?")) {
+ var bindArgs = {
+ url: applicationContextRoot + "/catalog?command=disable&id=" + itemId,
+ mimetype: "text/xml",
+ load: function(type,json) {
+ //alert("The item named '" + itemName + "' has been disabled!");
+ pList = new ProductList();
+ is.reset();
+ populateItems(is.getGroupId(), 0, 0, true);
+ },
+ error: ajaxBindError
+ };
+ dojo.io.bind(bindArgs);
+ }
+ }
+
+
+}
+
+
diff --git a/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/catalog.jsp-old b/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/catalog.jsp-old
index 851744b..13914ed 100644
--- a/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/catalog.jsp-old
+++ b/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/catalog.jsp-old
@@ -1,95 +1,95 @@
-<%-- Copyright 2006 Sun Microsystems, Inc. All rights reserved. You may not modify, use, reproduce, or distribute this software except in compliance with the terms of the License at: http://developer.sun.com/berkeley_license.html
-$Id: catalog.jsp,v 1.20 2006/12/01 21:38:40 basler Exp $ --%>
-<script type="text/javascript" src="common.js"></script>
-<script type="text/javascript" src="scroller.js"></script>
-<link rel="stylesheet" type="text/css" href="scroller.css"></link>
-<script type="text/javascript" src="accordion.js"></script>
-<link rel="stylesheet" type="text/css" href="accordion.css"></link>
-<script type="text/javascript" src="catalog.js"></script>
-<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
-<%@taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
-<%@taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
-<%@taglib prefix="ui" uri="http://java.sun.com/blueprints/ui" %>
-<body>
-<jsp:include page="banner.jsp" />
-<script type="text/javascript">
- dojo.event.connect(window, "onload", function(){initCatalog();});
-</script>
-<center>
- <table border="0">
- <tr>
- <td>
- <table id="accordion">
- <tr id="accordionTitle" class="accordionTitle"><td>Pets</td></tr>
- <tr><td>
- <table id="accordionBody" border="0" class="accordionBody">
- </table>
- </td></tr>
- </table>
- </td>
- <td style="min-width:500px;">
- <div id="CatalogBrowser">
- <table width="500px"border="1" class="slider" >
- <tr height="415" valign="top">
- <td id="bodySpace" border="0" align="center"></td>
- </tr>
- <tr id="targetRow">
- <td width="500px" height="70px" align="top">
- <div class="nav" id="right_button">
- <img src="${pageContext.request.contextPath}/images/right.gif" name="nextRoll" title="Show More Items" border="0">
- </div>
- <div class="nav" id="left_button">
- <img src="${pageContext.request.contextPath}/images/left.gif" name="previousRoll" title="Show Previous Items" border="0">
- </div>
- <div id="infopane" class="infopane">
- <table class="infopaneTable">
- <tr>
- <td id="infopaneName" class="infopaneTitle">
- </td>
- <td id="infopaneRating" class="infopaneRating">
- <f:view>
- <ui:rating id="rating" maxGrade="5" includeNotInterested="false" includeClear="false"
- hoverTexts="#{RatingBean.ratingText}" notInterestedHoverText="Not Interested" clearHoverText="Clear Rating"
- grade="#{RatingBean.grade}"/>
- <f:verbatim></td><td id="infopanePrice" class="infopanePrice"></td><td id="infopanePayPal" class="infopanePayPal"></f:verbatim>
- <ui:buyNow business="donate(a)animalfoundation.com" id="buyNow1" itemName="Buy Item One"
- amount="100.00" quantity="1" type="BuyNow" postData="#{PayPalBean.postData}" target="paypal"/>
- </f:view>
- </td>
- <td id="infopaneIndicator" class="infopaneIndicator">
- </td>
- <td id="infopaneDetailsIcon">
- </td>
- </tr>
- <tr>
- <td id="infopaneShortDescription" colspan="7" class="infopaneShortDescription">
- </td>
- </tr>
- <tr style="height:20px">
- <td></td>
- </tr>
- <tr>
- <td id="infopaneDescription" colspan="6" class="infopaneDescription">
- </td>
- </tr>
- </table>
- </div>
- </td>
- </tr>
- </table>
- </td>
- <td style="vertical-align:top; width:300px; text-align:right;">
- <div id="downloadAds">
- <jsp:include page="download.jsp" />
- </div>
- </td>
- </tr>
- </table>
- </div>
- <div id="status" style="text-align:left"></div> <div id="status_2"></div>
- <div id="dstatus"></div>
- <div id="injection_point"></div>
-</center>
-<jsp:include page="footer.jsp" />
-</body>
+<%-- Copyright 2006 Sun Microsystems, Inc. All rights reserved. You may not modify, use, reproduce, or distribute this software except in compliance with the terms of the License at: http://developer.sun.com/berkeley_license.html
+$Id: catalog.jsp,v 1.20 2006/12/01 21:38:40 basler Exp $ --%>
+<script type="text/javascript" src="common.js"></script>
+<script type="text/javascript" src="scroller.js"></script>
+<link rel="stylesheet" type="text/css" href="scroller.css"></link>
+<script type="text/javascript" src="accordion.js"></script>
+<link rel="stylesheet" type="text/css" href="accordion.css"></link>
+<script type="text/javascript" src="catalog.js"></script>
+<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<%@taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
+<%@taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
+<%@taglib prefix="ui" uri="http://java.sun.com/blueprints/ui" %>
+<body>
+<jsp:include page="banner.jsp" />
+<script type="text/javascript">
+ dojo.event.connect(window, "onload", function(){initCatalog();});
+</script>
+<center>
+ <table border="0">
+ <tr>
+ <td>
+ <table id="accordion">
+ <tr id="accordionTitle" class="accordionTitle"><td>Pets</td></tr>
+ <tr><td>
+ <table id="accordionBody" border="0" class="accordionBody">
+ </table>
+ </td></tr>
+ </table>
+ </td>
+ <td style="min-width:500px;">
+ <div id="CatalogBrowser">
+ <table width="500px"border="1" class="slider" >
+ <tr height="415" valign="top">
+ <td id="bodySpace" border="0" align="center"></td>
+ </tr>
+ <tr id="targetRow">
+ <td width="500px" height="70px" align="top">
+ <div class="nav" id="right_button">
+ <img src="${pageContext.request.contextPath}/images/right.gif" name="nextRoll" title="Show More Items" border="0">
+ </div>
+ <div class="nav" id="left_button">
+ <img src="${pageContext.request.contextPath}/images/left.gif" name="previousRoll" title="Show Previous Items" border="0">
+ </div>
+ <div id="infopane" class="infopane">
+ <table class="infopaneTable">
+ <tr>
+ <td id="infopaneName" class="infopaneTitle">
+ </td>
+ <td id="infopaneRating" class="infopaneRating">
+ <f:view>
+ <ui:rating id="rating" maxGrade="5" includeNotInterested="false" includeClear="false"
+ hoverTexts="#{RatingBean.ratingText}" notInterestedHoverText="Not Interested" clearHoverText="Clear Rating"
+ grade="#{RatingBean.grade}"/>
+ <f:verbatim></td><td id="infopanePrice" class="infopanePrice"></td><td id="infopanePayPal" class="infopanePayPal"></f:verbatim>
+ <ui:buyNow business="donate(a)animalfoundation.com" id="buyNow1" itemName="Buy Item One"
+ amount="100.00" quantity="1" type="BuyNow" postData="#{PayPalBean.postData}" target="paypal"/>
+ </f:view>
+ </td>
+ <td id="infopaneIndicator" class="infopaneIndicator">
+ </td>
+ <td id="infopaneDetailsIcon">
+ </td>
+ </tr>
+ <tr>
+ <td id="infopaneShortDescription" colspan="7" class="infopaneShortDescription">
+ </td>
+ </tr>
+ <tr style="height:20px">
+ <td></td>
+ </tr>
+ <tr>
+ <td id="infopaneDescription" colspan="6" class="infopaneDescription">
+ </td>
+ </tr>
+ </table>
+ </div>
+ </td>
+ </tr>
+ </table>
+ </td>
+ <td style="vertical-align:top; width:300px; text-align:right;">
+ <div id="downloadAds">
+ <jsp:include page="download.jsp" />
+ </div>
+ </td>
+ </tr>
+ </table>
+ </div>
+ <div id="status" style="text-align:left"></div> <div id="status_2"></div>
+ <div id="dstatus"></div>
+ <div id="injection_point"></div>
+</center>
+<jsp:include page="footer.jsp" />
+</body>
</html>
\ No newline at end of file
diff --git a/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/common.js b/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/common.js
index 0becd96..03a3ba2 100644
--- a/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/common.js
+++ b/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/common.js
@@ -1,77 +1,77 @@
-
- function ajaxBindError(type, errObj) {
- // can't use the error page, because unless and exception in the internal servlet container
- // nullpointer exceptions will be thrown
- //window.location="./systemerror.jsp?message=" + errObj.message;
-
- alert("An Exception has been encountered on the server side during an Ajax request. Please see the server logs for more information " + errObj.message);
- }
-
-
- function debugProperties(namex) {
- var listx="";
- var ob=namex;
- for(xx in ob) {
- listx += xx + " = " + ob[xx] + "<br/>"
- }
- //document.write(listx);
- alert(listx);
- }
-
-
- function printDebug(argx) {
- if (typeof debug != 'undefined') {
- document.getElementById("status").innerHTML = argx + "<br\>" + document.getElementById("status").innerHTML;
- }
- }
-
-
- function Map() {
- var size = 0;
- var keys = [];
- var values = [];
-
- this.put = function(key, value, replace) {
- if (this.get(key) == null) {
- keys[size] = key;
- values[size] = value;
- size++;
- } else if (replace) {
- for (i=0; i < size; i++) {
- if (keys[i] == key) {
- values[i] = value;
- }
- }
- }
- }
-
- this.get = function(key) {
- for (i=0; i < size; i++) {
- if (keys[i] == key) {
- return values[i];
- }
- }
- return null;
- }
-
- this.clear = function() {
- size = 0;
- keys = [];
- values = [];
- }
-
- // return keys show can show main image
- this.getKeys = function() {
- return keys;
- }
-
- // dump contents of map keys as string
- this.contents = function() {
- var retx="";
- for(ii=0; ii < size; ii++) {
- retx += keys[ii] + ", ";
- }
- return retx;
- }
-
+
+ function ajaxBindError(type, errObj) {
+ // can't use the error page, because unless and exception in the internal servlet container
+ // nullpointer exceptions will be thrown
+ //window.location="./systemerror.jsp?message=" + errObj.message;
+
+ alert("An Exception has been encountered on the server side during an Ajax request. Please see the server logs for more information " + errObj.message);
+ }
+
+
+ function debugProperties(namex) {
+ var listx="";
+ var ob=namex;
+ for(xx in ob) {
+ listx += xx + " = " + ob[xx] + "<br/>"
+ }
+ //document.write(listx);
+ alert(listx);
+ }
+
+
+ function printDebug(argx) {
+ if (typeof debug != 'undefined') {
+ document.getElementById("status").innerHTML = argx + "<br\>" + document.getElementById("status").innerHTML;
+ }
+ }
+
+
+ function Map() {
+ var size = 0;
+ var keys = [];
+ var values = [];
+
+ this.put = function(key, value, replace) {
+ if (this.get(key) == null) {
+ keys[size] = key;
+ values[size] = value;
+ size++;
+ } else if (replace) {
+ for (i=0; i < size; i++) {
+ if (keys[i] == key) {
+ values[i] = value;
+ }
+ }
+ }
+ }
+
+ this.get = function(key) {
+ for (i=0; i < size; i++) {
+ if (keys[i] == key) {
+ return values[i];
+ }
+ }
+ return null;
+ }
+
+ this.clear = function() {
+ size = 0;
+ keys = [];
+ values = [];
+ }
+
+ // return keys show can show main image
+ this.getKeys = function() {
+ return keys;
+ }
+
+ // dump contents of map keys as string
+ this.contents = function() {
+ var retx="";
+ for(ii=0; ii < size; ii++) {
+ retx += keys[ii] + ", ";
+ }
+ return retx;
+ }
+
}
\ No newline at end of file
diff --git a/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/downloadAd.js b/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/downloadAd.js
index 3feb219..65855c2 100644
--- a/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/downloadAd.js
+++ b/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/downloadAd.js
@@ -1,54 +1,54 @@
-dojo.require("dojo.io");
-function checkAdPage() {
- var bindArgs = {
- // check to see if an updated page is available
- URL: "http://localhost:8080/petstore/downloadAd.txt",
- mimetype: "text/plain",
- load: returnFunctionx,
- error: ajaxBindError};
-
- // dispatch the request
- dojo.io.bind(bindArgs);
-}
-
-function returnFunctionx(type, data, evt) {
- // statically setup popup for simple case
- // check return of the dojo call to make sure it is valid
- if (evt.readyState == 4) {
- if (evt.status == 200) {
- alert("data = " + data);
- document.getElementById("downloadAds").innerHTML=data;
- }
- }
-}
-
-
-var req;
-
-function checkAdPageMark() {
- // calculate arrow and border image location
- req=initRequest();
-
- url="http://blueprints.dev.java.net/petstore/downloadAd.txt",
- req.onreadystatechange = returnFunctionxMark;
- req.open("GET", url, true);
- req.send(null);
-}
-
-
-function returnFunctionxMark() {
- if (req.readyState == 4) {
- if (req.status == 200) {
- alert("data = " + req.responseText);
- document.getElementById("downloadAds").innerHTML=req.responseText;
- }
- }
-}
-
-initRequest=function() {
- if (window.XMLHttpRequest) {
- return new XMLHttpRequest();
- } else if (window.ActiveXObject) {
- return new ActiveXObject("Microsoft.XMLHTTP");
- }
-}
+dojo.require("dojo.io");
+function checkAdPage() {
+ var bindArgs = {
+ // check to see if an updated page is available
+ URL: "http://localhost:8080/petstore/downloadAd.txt",
+ mimetype: "text/plain",
+ load: returnFunctionx,
+ error: ajaxBindError};
+
+ // dispatch the request
+ dojo.io.bind(bindArgs);
+}
+
+function returnFunctionx(type, data, evt) {
+ // statically setup popup for simple case
+ // check return of the dojo call to make sure it is valid
+ if (evt.readyState == 4) {
+ if (evt.status == 200) {
+ alert("data = " + data);
+ document.getElementById("downloadAds").innerHTML=data;
+ }
+ }
+}
+
+
+var req;
+
+function checkAdPageMark() {
+ // calculate arrow and border image location
+ req=initRequest();
+
+ url="http://blueprints.dev.java.net/petstore/downloadAd.txt",
+ req.onreadystatechange = returnFunctionxMark;
+ req.open("GET", url, true);
+ req.send(null);
+}
+
+
+function returnFunctionxMark() {
+ if (req.readyState == 4) {
+ if (req.status == 200) {
+ alert("data = " + req.responseText);
+ document.getElementById("downloadAds").innerHTML=req.responseText;
+ }
+ }
+}
+
+initRequest=function() {
+ if (window.XMLHttpRequest) {
+ return new XMLHttpRequest();
+ } else if (window.ActiveXObject) {
+ return new ActiveXObject("Microsoft.XMLHTTP");
+ }
+}
diff --git a/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/engine.js b/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/engine.js
index e43d49b..0e5b14e 100644
--- a/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/engine.js
+++ b/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/engine.js
@@ -1,241 +1,241 @@
-/* Copyright 2006 Sun Microsystems, Inc. All rights reserved. You may not modify, use, reproduce, or distribute this software except in compliance with the terms of the License at: http://developer.sun.com/berkeley_license.html
-$Id: engine.js,v 1.10 2006/05/03 22:00:32 inder Exp $ */
-
-function Engine () {
-
- /**
- *
- * Load template text aloing with an associated script
- *
- * Argument p properties are as follows:
- *
- * url : Not required but used if you want to get the template from
- * something other than the injection serlvet. For example if
- * you want to load content directly from a a JSP or HTML file.
- *
- * p.template : Not required if you specficy a url property Otherewise this
- * is the name of the template file.
- *
- * p.initFunction: Not required. This function or function pointer will be called
- * after the template text and script are loaded. The result of
- * the evaluated script will be accessible in the context of
- * this function.
- *
- * p.injectionPoint: Not required. This is the id of an element into. If this is
- * not specfied a div will be created under the roon node of
- * the document and the template will be injected into it.
- * Content is injected by setting the innerHTML property
- * of an element to the template text.
- */
- this.inject = function (p) {
- var targetUrl;
- if (!p.url) targetUrl = "controller?command=content&target=/" + p.template;
- else targetUrl = p.url;
- var templateArgs = {
- url: targetUrl,
- mimetype: "text/html",
- load: function(type, data) {
- //if no parent is given append to the document root
- var nData = includeEmbeddedResources(data, p.initFunction );
- if (!p.injectionPoint) {
- var injectionPoint = document.createElement("div");
- injectionPoint.innerHTML = nData;
- document.firstChild.appendChild(injectionPoint);
- } else {
- p.injectionPoint.innerHTML = nData;
- }
- if (p.script) {
- // now load the associated JavaScript
- loadScript(p.script,p.initFunction);
- }
- }
- };
- dojo.io.bind(templateArgs);
- }
-
- function loadScript(targetURL,callback) {
- var templateArgs = {
- url: targetURL,
- mimetype: "text/plain",
- load: callback
- };
- dojo.io.bind(templateArgs);
- }
-
- /**
- * If were returning an text document remove any script in the
- * the document and add it to the global scope using a time out.
- */
- function includeEmbeddedResources(target, initFunction) {
- var bodyText = "";
- var embeddedScripts = [];
- var embeddedStyles = [];
- var scriptReferences = [];
- var styleReferences = [];
- var styles = [];
- // recursively go through and weed out the scripts
- // TODO: Use some better REGEX processing
- // TODO: Also support single quotes
- while (target.indexOf("<script") != -1) {
- var realStart = target.indexOf("<script");
- var scriptSourceStart = target.indexOf("src=", (realStart));
- var scriptElementEnd = target.indexOf(">", realStart);
- var end = target.indexOf("</script>", (realStart)) + "</script>".length;
- if (realStart != -1 && scriptSourceStart != -1) {
- var scriptSourceName;
- var scriptSourceLinkStart= scriptSourceStart + 5;
- var scriptSourceLinkEnd= target.indexOf("\"", (scriptSourceLinkStart + 1));
- if (scriptSourceStart < scriptElementEnd) {
- scriptSourceName = target.substring(scriptSourceLinkStart, scriptSourceLinkEnd);
- // prevent multiple inclusions of dojo.js.
- // there is no way you would get to this point without dojo being included
- if (scriptSourceName.indexOf("dojo.js") == -1) {
- scriptReferences.push(scriptSourceName);
- }
- }
- }
- // now remove the script body
- var scriptBodyStart = scriptElementEnd + 1;
- var sBody = target.substring(scriptBodyStart, end - "</script>".length);
- if (sBody.length > 0) {
- embeddedScripts.push(sBody);
- }
- //remove script
- target = target.substring(0, realStart) + target.substring(end, target.length);
- }
-
- while (target.indexOf("<style") != -1) {
- var realStart = target.indexOf("<style");
- var styleElementEnd = target.indexOf(">", realStart);
- var end = target.indexOf("</style>", (realStart)) ;
- var styleBodyStart = styleElementEnd + 1;
- var sBody = target.substring(styleBodyStart, end);
- if (sBody.length > 0) {
- embeddedStyles.push(sBody);
- }
- //remove style
- target = target.substring(0, realStart) + target.substring(end + "</style>".length, target.length);
- }
- // get the links
- while (target.indexOf("<link") != -1) {
- var realStart = target.indexOf("<link");
- var styleSourceStart = target.indexOf("href=", (realStart));
- var styleElementEnd = target.indexOf(">", realStart) +1;
- if (realStart != -1 && styleSourceStart != -1) {
- var styletSourceName;
- var styleSourceLinkStart= styleSourceStart + 6;
- var styleSourceLinkEnd= target.indexOf("\"", (styleSourceLinkStart + 1));
- if (styleSourceStart < styleElementEnd) {
- styleSourceName = target.substring(styleSourceLinkStart, styleSourceLinkEnd);
- styleReferences.push(styleSourceName);
- }
- //remove style
- target = target.substring(0, realStart) + target.substring(styleElementEnd, target.length);
- }
- }
-
- var head = document.getElementsByTagName("head")[0];
-
- // inject the links
- for(var loop = 0; loop < styleReferences.length; loop++) {
- var link = document.createElement("link");
- link.href = styleReferences[loop];
- link.type = "text/css";
- link.rel = "stylesheet";
- head.appendChild(link);
- }
-
- var stylesElement;
- if (embeddedStyles.length > 0) {
- stylesElement = document.createElement("style");
- stylesElement.type="text/css";
- var stylesText;
- for(var loop = 0; loop < embeddedStyles.length; loop++) {
- stylesText = stylesText + embeddedStyles[loop];
- }
- if (document.styleSheets[0].cssText) {
- document.styleSheets[0].cssText = document.styleSheets[0].cssText + stylesText;
- } else {
- stylesElement.appendChild(document.createTextNode(stylesText));
- head.appendChild(stylesElement);
- }
- }
-
- scriptLoader(scriptReferences, 0, function() {
- this.embeddedScripts = embeddedScripts;
- // evaluate the embedded javascripts in the order they were added
- // consider using an onload handler
- for(var loop = 0; loop < embeddedScripts.length; loop++) {
- //alert("evaluating " + embeddedScripts[loop]);
- var script = embeddedScripts[loop];
- // append to the script a method to call the scriptLoaderCallback
- eval(script);
- if (loop == (embeddedScripts.length -1)) {
- initFunction();
- }
- }
- });
-
- return target;
- }
-
-
- /**
- * Load the scripts in order and load them one after on another
- */
- function scriptLoader(scripts, index, callbackFunction) {
- var head = document.getElementsByTagName("head").item(0);
- var scriptElement = document.createElement("script");
- scriptElement.id = "c_script_" + index;
- scriptElement.type = "text/javascript";
-
- var loadHandler = function () {
- if (index < scripts.length && index != scripts.length -1) {
- scriptLoader(scripts, ++index, callbackFunction);
- } else {
- callbackFunction();
- }
- }
- if (typeof scriptElement.onreadystatechange != 'undefined') {
- scriptElement.onreadystatechange = function () {
- if (this.readyState == 'loaded') {
- loadHandler();
- }
- };
- }
- scriptElement.onload = loadHandler;
-
- // Safari not seeing the onload event and does not support the onreadystate
- if (navigator.userAgent.toLowerCase().indexOf("safari") != -1) {
- scriptElement.src = scripts[index];
- setTimeout(loadHandler, 0);
- }
- head.appendChild(scriptElement);
- setTimeout("document.getElementById('c_script_" + index + "').src ='" + scripts[index] + "'", 0);
-
- scriptElement = null;
- head = null;
- }
-
- /**
- * If were returning an XML document remove any script in the
- * the document and add it to the global scope using a time out.
- */
- function includeEmbeddedScripts(xmlDocument) {
- var items = new Array();
- var xmlDocument = document.getElementsByTagName("script");
-
- for(var loop = 0; loop < targets.length; loop++) {
- var children = targets[loop].childNodes;
- var iScript = "";
- for(var innerLoop = 0; innerLoop < children.length; innerLoop++) {
- iScript += children[innerLoop].data;
- }
- items.add(iScript);
- children[loop].parentNode.removeChild(children[loop]);
- }
- for(var loop = 0; loop < items.length; loop++) {
- setTimeout(items[loop],0);
- }
- }
-}
+/* Copyright 2006 Sun Microsystems, Inc. All rights reserved. You may not modify, use, reproduce, or distribute this software except in compliance with the terms of the License at: http://developer.sun.com/berkeley_license.html
+$Id: engine.js,v 1.10 2006/05/03 22:00:32 inder Exp $ */
+
+function Engine () {
+
+ /**
+ *
+ * Load template text aloing with an associated script
+ *
+ * Argument p properties are as follows:
+ *
+ * url : Not required but used if you want to get the template from
+ * something other than the injection serlvet. For example if
+ * you want to load content directly from a a JSP or HTML file.
+ *
+ * p.template : Not required if you specficy a url property Otherewise this
+ * is the name of the template file.
+ *
+ * p.initFunction: Not required. This function or function pointer will be called
+ * after the template text and script are loaded. The result of
+ * the evaluated script will be accessible in the context of
+ * this function.
+ *
+ * p.injectionPoint: Not required. This is the id of an element into. If this is
+ * not specfied a div will be created under the roon node of
+ * the document and the template will be injected into it.
+ * Content is injected by setting the innerHTML property
+ * of an element to the template text.
+ */
+ this.inject = function (p) {
+ var targetUrl;
+ if (!p.url) targetUrl = "controller?command=content&target=/" + p.template;
+ else targetUrl = p.url;
+ var templateArgs = {
+ url: targetUrl,
+ mimetype: "text/html",
+ load: function(type, data) {
+ //if no parent is given append to the document root
+ var nData = includeEmbeddedResources(data, p.initFunction );
+ if (!p.injectionPoint) {
+ var injectionPoint = document.createElement("div");
+ injectionPoint.innerHTML = nData;
+ document.firstChild.appendChild(injectionPoint);
+ } else {
+ p.injectionPoint.innerHTML = nData;
+ }
+ if (p.script) {
+ // now load the associated JavaScript
+ loadScript(p.script,p.initFunction);
+ }
+ }
+ };
+ dojo.io.bind(templateArgs);
+ }
+
+ function loadScript(targetURL,callback) {
+ var templateArgs = {
+ url: targetURL,
+ mimetype: "text/plain",
+ load: callback
+ };
+ dojo.io.bind(templateArgs);
+ }
+
+ /**
+ * If were returning an text document remove any script in the
+ * the document and add it to the global scope using a time out.
+ */
+ function includeEmbeddedResources(target, initFunction) {
+ var bodyText = "";
+ var embeddedScripts = [];
+ var embeddedStyles = [];
+ var scriptReferences = [];
+ var styleReferences = [];
+ var styles = [];
+ // recursively go through and weed out the scripts
+ // TODO: Use some better REGEX processing
+ // TODO: Also support single quotes
+ while (target.indexOf("<script") != -1) {
+ var realStart = target.indexOf("<script");
+ var scriptSourceStart = target.indexOf("src=", (realStart));
+ var scriptElementEnd = target.indexOf(">", realStart);
+ var end = target.indexOf("</script>", (realStart)) + "</script>".length;
+ if (realStart != -1 && scriptSourceStart != -1) {
+ var scriptSourceName;
+ var scriptSourceLinkStart= scriptSourceStart + 5;
+ var scriptSourceLinkEnd= target.indexOf("\"", (scriptSourceLinkStart + 1));
+ if (scriptSourceStart < scriptElementEnd) {
+ scriptSourceName = target.substring(scriptSourceLinkStart, scriptSourceLinkEnd);
+ // prevent multiple inclusions of dojo.js.
+ // there is no way you would get to this point without dojo being included
+ if (scriptSourceName.indexOf("dojo.js") == -1) {
+ scriptReferences.push(scriptSourceName);
+ }
+ }
+ }
+ // now remove the script body
+ var scriptBodyStart = scriptElementEnd + 1;
+ var sBody = target.substring(scriptBodyStart, end - "</script>".length);
+ if (sBody.length > 0) {
+ embeddedScripts.push(sBody);
+ }
+ //remove script
+ target = target.substring(0, realStart) + target.substring(end, target.length);
+ }
+
+ while (target.indexOf("<style") != -1) {
+ var realStart = target.indexOf("<style");
+ var styleElementEnd = target.indexOf(">", realStart);
+ var end = target.indexOf("</style>", (realStart)) ;
+ var styleBodyStart = styleElementEnd + 1;
+ var sBody = target.substring(styleBodyStart, end);
+ if (sBody.length > 0) {
+ embeddedStyles.push(sBody);
+ }
+ //remove style
+ target = target.substring(0, realStart) + target.substring(end + "</style>".length, target.length);
+ }
+ // get the links
+ while (target.indexOf("<link") != -1) {
+ var realStart = target.indexOf("<link");
+ var styleSourceStart = target.indexOf("href=", (realStart));
+ var styleElementEnd = target.indexOf(">", realStart) +1;
+ if (realStart != -1 && styleSourceStart != -1) {
+ var styletSourceName;
+ var styleSourceLinkStart= styleSourceStart + 6;
+ var styleSourceLinkEnd= target.indexOf("\"", (styleSourceLinkStart + 1));
+ if (styleSourceStart < styleElementEnd) {
+ styleSourceName = target.substring(styleSourceLinkStart, styleSourceLinkEnd);
+ styleReferences.push(styleSourceName);
+ }
+ //remove style
+ target = target.substring(0, realStart) + target.substring(styleElementEnd, target.length);
+ }
+ }
+
+ var head = document.getElementsByTagName("head")[0];
+
+ // inject the links
+ for(var loop = 0; loop < styleReferences.length; loop++) {
+ var link = document.createElement("link");
+ link.href = styleReferences[loop];
+ link.type = "text/css";
+ link.rel = "stylesheet";
+ head.appendChild(link);
+ }
+
+ var stylesElement;
+ if (embeddedStyles.length > 0) {
+ stylesElement = document.createElement("style");
+ stylesElement.type="text/css";
+ var stylesText;
+ for(var loop = 0; loop < embeddedStyles.length; loop++) {
+ stylesText = stylesText + embeddedStyles[loop];
+ }
+ if (document.styleSheets[0].cssText) {
+ document.styleSheets[0].cssText = document.styleSheets[0].cssText + stylesText;
+ } else {
+ stylesElement.appendChild(document.createTextNode(stylesText));
+ head.appendChild(stylesElement);
+ }
+ }
+
+ scriptLoader(scriptReferences, 0, function() {
+ this.embeddedScripts = embeddedScripts;
+ // evaluate the embedded javascripts in the order they were added
+ // consider using an onload handler
+ for(var loop = 0; loop < embeddedScripts.length; loop++) {
+ //alert("evaluating " + embeddedScripts[loop]);
+ var script = embeddedScripts[loop];
+ // append to the script a method to call the scriptLoaderCallback
+ eval(script);
+ if (loop == (embeddedScripts.length -1)) {
+ initFunction();
+ }
+ }
+ });
+
+ return target;
+ }
+
+
+ /**
+ * Load the scripts in order and load them one after on another
+ */
+ function scriptLoader(scripts, index, callbackFunction) {
+ var head = document.getElementsByTagName("head").item(0);
+ var scriptElement = document.createElement("script");
+ scriptElement.id = "c_script_" + index;
+ scriptElement.type = "text/javascript";
+
+ var loadHandler = function () {
+ if (index < scripts.length && index != scripts.length -1) {
+ scriptLoader(scripts, ++index, callbackFunction);
+ } else {
+ callbackFunction();
+ }
+ }
+ if (typeof scriptElement.onreadystatechange != 'undefined') {
+ scriptElement.onreadystatechange = function () {
+ if (this.readyState == 'loaded') {
+ loadHandler();
+ }
+ };
+ }
+ scriptElement.onload = loadHandler;
+
+ // Safari not seeing the onload event and does not support the onreadystate
+ if (navigator.userAgent.toLowerCase().indexOf("safari") != -1) {
+ scriptElement.src = scripts[index];
+ setTimeout(loadHandler, 0);
+ }
+ head.appendChild(scriptElement);
+ setTimeout("document.getElementById('c_script_" + index + "').src ='" + scripts[index] + "'", 0);
+
+ scriptElement = null;
+ head = null;
+ }
+
+ /**
+ * If were returning an XML document remove any script in the
+ * the document and add it to the global scope using a time out.
+ */
+ function includeEmbeddedScripts(xmlDocument) {
+ var items = new Array();
+ var xmlDocument = document.getElementsByTagName("script");
+
+ for(var loop = 0; loop < targets.length; loop++) {
+ var children = targets[loop].childNodes;
+ var iScript = "";
+ for(var innerLoop = 0; innerLoop < children.length; innerLoop++) {
+ iScript += children[innerLoop].data;
+ }
+ items.add(iScript);
+ children[loop].parentNode.removeChild(children[loop]);
+ }
+ for(var loop = 0; loop < items.length; loop++) {
+ setTimeout(items[loop],0);
+ }
+ }
+}
commit 051595ca85f346a5f4f673632b2be17c62c2af25
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Apr 27 13:23:22 2010 -0400
suppress debugging statement
diff --git a/modules/enterprise/server/jar/src/main/antlr3/org/rhq/enterprise/server/search/RHQL.g b/modules/enterprise/server/jar/src/main/antlr3/org/rhq/enterprise/server/search/RHQL.g
index 4fa879e..6816a1e 100644
--- a/modules/enterprise/server/jar/src/main/antlr3/org/rhq/enterprise/server/search/RHQL.g
+++ b/modules/enterprise/server/jar/src/main/antlr3/org/rhq/enterprise/server/search/RHQL.g
@@ -75,7 +75,7 @@ tokens {
*/
searchExpression
- : conditionalExpression { System.out.println($conditionalExpression.tree.toStringTree()); }
+ : conditionalExpression { /* System.out.println($conditionalExpression.tree.toStringTree()); */ }
;
conditionalExpression
commit b3751bd05aca5af3d7fdf12971953231ffe491ac
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Apr 27 13:03:37 2010 -0400
if possible, use the resource-specific ancestry to populate relative resource drop-down
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/CustomContentUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/CustomContentUIBean.java
index eb7d500..64bf25a 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/CustomContentUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/CustomContentUIBean.java
@@ -77,6 +77,8 @@ public class CustomContentUIBean extends EnterpriseFacesContextUIBean {
customBackingBean.setWebUser(getSubject());
customBackingBean.setContext(FacesContextUtility.getRequiredRequestParameter("context"));
customBackingBean.setContextId(FacesContextUtility.getRequiredRequestParameter("contextId"));
+ customBackingBean.setContextSubId(FacesContextUtility.getOptionalRequestParameter("contextSubId",
+ (String) null));
customBackingBean.loadView();
outjectBean(backingBeanName, customBackingBean);
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/CustomAlertSenderBackingBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/CustomAlertSenderBackingBean.java
index 2f8b323..848765f 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/CustomAlertSenderBackingBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/CustomAlertSenderBackingBean.java
@@ -36,6 +36,7 @@ public class CustomAlertSenderBackingBean {
protected Subject webUser;
protected String context;
protected String contextId;
+ protected String contextSubId;
public Configuration getAlertParameters() {
return alertParameters;
@@ -69,6 +70,14 @@ public class CustomAlertSenderBackingBean {
this.contextId = contextId;
}
+ public String getContextSubId() {
+ return contextSubId;
+ }
+
+ public void setContextSubId(String contextSubId) {
+ this.contextSubId = contextSubId;
+ }
+
public void loadView() {
}
diff --git a/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/OperationsBackingBean.java b/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/OperationsBackingBean.java
index 7fd8cc1..2880800 100644
--- a/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/OperationsBackingBean.java
+++ b/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/OperationsBackingBean.java
@@ -18,6 +18,7 @@
*/
package org.rhq.enterprise.server.plugins.alertOperations;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
@@ -100,8 +101,24 @@ public class OperationsBackingBean extends CustomAlertSenderBackingBean {
descendantTypeId = get(OperationInfo.Constants.RELATIVE_DESCENDANT_TYPE_ID, "none");
ResourceType contextType = computeResourceTypeFromContext(); // should not be null
- List<ResourceType> ancestors = LookupUtil.getResourceTypeManager().getResourceTypeAncestorsWithOperations(
- getOverlord(), contextType.getId());
+ List<ResourceType> ancestors = null;
+ if (context.equals("resource")) {
+ try {
+ List<Resource> ancestry = LookupUtil.getResourceManager().getResourceLineage(
+ Integer.parseInt(contextSubId));
+ ancestors = new ArrayList<ResourceType>();
+ for (Resource next : ancestry) {
+ ancestors.add(next.getResourceType());
+ }
+ } catch (Throwable t) {
+ // ignore, we'll default to a different loading style below
+ }
+ }
+
+ if (ancestors == null) { // if not in the resource content or fallback if resource ancestry loading bombs
+ ancestors = LookupUtil.getResourceTypeManager().getResourceTypeAncestorsWithOperations(getOverlord(),
+ contextType.getId());
+ }
load(ancestorTypeOptions, ancestors);
if (ancestorTypeId.equals("none") == false) {
commit 901a44092dd5031653ac056bd9fd925dc97ab43e
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Apr 21 13:36:48 2010 -0400
bz535436 - removed all usages of collection.toArray in InventoryManager to avoid concurrency bug.
now using synchronized block that should protect against this.
(cherry picked from commit ac4460c69494fc6720de5d9ba03af5c6b89ed989)
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java
index f4785f8..8b6cf68 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java
@@ -1821,7 +1821,9 @@ public class InventoryManager extends AgentService implements ContainerService,
* @param listener instance to notify of change events
*/
public void addInventoryEventListener(InventoryEventListener listener) {
- this.inventoryEventListeners.add(listener);
+ synchronized (this.inventoryEventListeners) {
+ this.inventoryEventListeners.add(listener);
+ }
}
/**
@@ -1830,7 +1832,21 @@ public class InventoryManager extends AgentService implements ContainerService,
* @param listener instance to remove from event notification
*/
public void removeInventoryEventListener(InventoryEventListener listener) {
- this.inventoryEventListeners.remove(listener);
+ synchronized (this.inventoryEventListeners) {
+ this.inventoryEventListeners.remove(listener);
+ }
+ }
+
+ /**
+ * Always use this before accessing the event listeners because this ensures
+ * thread safety.
+ *
+ * @return all inventory event listeners
+ */
+ private Set<InventoryEventListener> getInventoryEventListeners() {
+ synchronized (this.inventoryEventListeners) {
+ return new HashSet<InventoryEventListener>(this.inventoryEventListeners);
+ }
}
/**
@@ -1844,8 +1860,7 @@ public class InventoryManager extends AgentService implements ContainerService,
return;
}
- InventoryEventListener[] iteratorSafeListeners = new InventoryEventListener[inventoryEventListeners.size()];
- iteratorSafeListeners = inventoryEventListeners.toArray(iteratorSafeListeners);
+ Set<InventoryEventListener> iteratorSafeListeners = getInventoryEventListeners();
for (InventoryEventListener listener : iteratorSafeListeners) {
// Catch anything to make sure we don't stop firing to other listeners
try {
@@ -1868,8 +1883,7 @@ public class InventoryManager extends AgentService implements ContainerService,
log.debug("Firing activated for resource: " + resource);
}
- InventoryEventListener[] iteratorSafeListeners = new InventoryEventListener[inventoryEventListeners.size()];
- iteratorSafeListeners = inventoryEventListeners.toArray(iteratorSafeListeners);
+ Set<InventoryEventListener> iteratorSafeListeners = getInventoryEventListeners();
for (InventoryEventListener listener : iteratorSafeListeners) {
// Catch anything to make sure we don't stop firing to other listeners
try {
@@ -1893,8 +1907,7 @@ public class InventoryManager extends AgentService implements ContainerService,
log.debug("Firing deactivated for resource: " + resource);
}
- InventoryEventListener[] iteratorSafeListeners = new InventoryEventListener[inventoryEventListeners.size()];
- iteratorSafeListeners = inventoryEventListeners.toArray(iteratorSafeListeners);
+ Set<InventoryEventListener> iteratorSafeListeners = getInventoryEventListeners();
for (InventoryEventListener listener : iteratorSafeListeners) {
// Catch anything to make sure we don't stop firing to other listeners
try {
@@ -1917,8 +1930,7 @@ public class InventoryManager extends AgentService implements ContainerService,
return;
}
- InventoryEventListener[] iteratorSafeListeners = new InventoryEventListener[inventoryEventListeners.size()];
- iteratorSafeListeners = inventoryEventListeners.toArray(iteratorSafeListeners);
+ Set<InventoryEventListener> iteratorSafeListeners = getInventoryEventListeners();
for (InventoryEventListener listener : iteratorSafeListeners) {
// Catch anything to make sure we don't stop firing to other listeners
try {
commit bdbc5d990cd959005e9a7355fc1ba5c1296187d7
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Tue Apr 27 12:49:48 2010 -0400
BZ 584994:i)pagination fix ii)added ldapgroupform iii)cache ldap group list
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/AddLdapGroupsFormPrepareAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/AddLdapGroupsFormPrepareAction.java
index bd38c20..39fe62e 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/AddLdapGroupsFormPrepareAction.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/AddLdapGroupsFormPrepareAction.java
@@ -19,11 +19,14 @@
package org.rhq.enterprise.gui.admin.role;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.NavigableSet;
import java.util.Properties;
import java.util.Set;
+import java.util.TreeMap;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -43,6 +46,7 @@ import org.rhq.core.domain.authz.Role;
import org.rhq.core.domain.resource.group.LdapGroup;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
+import org.rhq.core.domain.util.PageOrdering;
import org.rhq.enterprise.gui.legacy.Constants;
import org.rhq.enterprise.gui.legacy.util.RequestUtils;
import org.rhq.enterprise.gui.legacy.util.SessionUtils;
@@ -59,6 +63,8 @@ import org.rhq.enterprise.server.util.LookupUtil;
* An Action that retrieves data to facilitate display of the form for adding groups to a role.
*/
public class AddLdapGroupsFormPrepareAction extends TilesAction {
+ final String LDAP_GROUP_CACHE = "ldapGroupCache";
+
public ActionForward execute(ComponentContext context, ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception {
Log log = LogFactory.getLog(AddLdapGroupsFormPrepareAction.class.getName());
@@ -76,6 +82,9 @@ public class AddLdapGroupsFormPrepareAction extends TilesAction {
RequestUtils.setError(request, Constants.ERR_ROLE_NOT_FOUND);
return null;
}
+ //use cached LDAP group list to avoid hitting ldap server each time ui pref changed.
+ Set<Map<String, String>> cachedAvailableLdapGroups = null;
+ cachedAvailableLdapGroups = (Set<Map<String, String>>) request.getSession().getAttribute(LDAP_GROUP_CACHE);
addForm.setR(role.getId());
@@ -93,21 +102,31 @@ public class AddLdapGroupsFormPrepareAction extends TilesAction {
PageList<Map<String, String>> pendingGroups = new PageList<Map<String, String>>(pendingSet, 0, pcp);
PageList<Map<String, String>> availableGroups = new PageList<Map<String, String>>(availableGroupsSet, 0, pca);
/* pending groups are those on the right side of the "add
- * to list" widget- awaiting association with the rolewhen the form's "ok" button is clicked. */
+ * to list" widget- awaiting association with the role when the form's "ok" button is clicked. */
pendingGroupIds = SessionUtils.getListAsListStr(request.getSession(), Constants.PENDING_RESGRPS_SES_ATTR);
log.trace("getting pending groups for role [" + roleId + ")");
String name = "foo";
try { //defend against ldap communication runtime difficulties.
- allGroups = LdapGroupManager.getInstance().findAvailableGroups();
- RoleManagerLocal roleManager = LookupUtil.getRoleManager();
+ if (cachedAvailableLdapGroups == null) {
+ allGroups = LdapGroupManager.getInstance().findAvailableGroups();
+ } else {//reuse cached.
+ allGroups = cachedAvailableLdapGroups;
+ }
+ //store unmodified list in session.
+ cachedAvailableLdapGroups = allGroups;
+
+ RoleManagerLocal roleManager = LookupUtil.getRoleManager();
+ //retrieve currently assigned groups
assignedList = roleManager.findLdapGroupsByRole(role.getId(), PageControl.getUnlimitedInstance());
+ //trim already defined from all groups returned.
allGroups = filterExisting(assignedList, allGroups);
Set<String> pendingIds = new HashSet<String>(pendingGroupIds);
+ //retrieve pending information
pendingSet = findPendingGroups(pendingIds, allGroups);
pendingGroups = new PageList<Map<String, String>>(pendingSet, pendingSet.size(), pcp);
@@ -118,6 +137,86 @@ public class AddLdapGroupsFormPrepareAction extends TilesAction {
availableGroupsSet = findAvailableGroups(pendingIds, allGroups);
availableGroups = new PageList<Map<String, String>>(availableGroupsSet, availableGroupsSet.size(), pca);
+
+ //We cannot reuse the PageControl mechanism as there are no database calls to retrieve list
+ // must replicate paging using existing web params, formula etc.
+
+ //determine count to return up to 15|30|45 and page index
+ int returnAmount = pca.getPageSize();
+ int returnIndex = pca.getPageNumber();
+
+ //determine sort order
+ PageOrdering sortOrder = pca.getPrimarySortOrder();
+ if (sortOrder == null) {
+ sortOrder = PageOrdering.ASC;
+ pca.setPrimarySortOrder(sortOrder);//reset on pc
+ }
+
+ //determine which column to sort on
+ String sortColumn = pca.getPrimarySortColumn();
+ if (sortColumn == null) {
+ sortColumn = "lg.name";
+ pca.setPrimarySort(sortColumn, sortOrder);//reset on pc
+ }
+
+ //now sort based off these values and populate sizedAvailableGroups accordingly
+ ArrayList<Map<String, String>> groupsValues = availableGroups.getValues();
+
+ //store maps based off the keys and sort()
+ Map<Integer, Map> groupLookup = new HashMap<Integer, Map>();
+ TreeMap<String, Integer> groupNames = new TreeMap<String, Integer>();
+ TreeMap<String, Integer> groupDescriptions = new TreeMap<String, Integer>();
+ for (int i = 0; i < groupsValues.size(); i++) {
+ Map<String, String> entry = groupsValues.get(i);
+ Integer key = Integer.valueOf(i);
+ groupLookup.put(key, entry);
+ groupNames.put(entry.get("name"), key);
+ groupDescriptions.put(entry.get("description"), key);
+ }
+
+ //do calculations to determine how many sorted values to return.
+ int start, end;
+ start = (int) (returnIndex * returnAmount);
+ end = start + returnAmount;
+ PageList<Map<String, String>> sizedAvailableGroups = new PageList<Map<String, String>>();
+
+ //detect sort order
+ boolean descending = false;
+ if (sortOrder.DESC == sortOrder) {
+ descending = true;
+ }
+ //use sort column to determine which list to use
+ if (sortColumn.equalsIgnoreCase("lg.name")) {
+ int i = 0;
+ NavigableSet<String> keyList = groupNames.navigableKeySet();
+ if (descending) {
+ keyList = groupNames.descendingKeySet();
+ }
+ for (String key : keyList) {
+ if ((i >= start) && (i < end)) {
+ sizedAvailableGroups.add(groupLookup.get(groupNames.get(key)));
+ }
+ i++;
+ }
+ } else {
+ int i = 0;
+ NavigableSet<String> keyList = groupDescriptions.navigableKeySet();
+ if (descending) {
+ keyList = groupNames.descendingKeySet();
+ }
+ for (String key : keyList) {
+ if ((i >= start) && (i < end)) {
+ sizedAvailableGroups.add(groupLookup.get(groupDescriptions.get(key)));
+ }
+ i++;
+ }
+ }
+ //make sizedAvailableGroup the new reference to return.
+ availableGroups = sizedAvailableGroups;
+ //populate pagination elements for loaded elements.
+ availableGroups.setTotalSize(groupLookup.size());
+ availableGroups.setPageControl(pca);
+
} catch (LdapFilterException lce) {
ActionMessages actionMessages = new ActionMessages();
actionMessages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("admin.role.LdapGroupFilterMessage"));
@@ -136,7 +235,9 @@ public class AddLdapGroupsFormPrepareAction extends TilesAction {
request.setAttribute(Constants.PENDING_RESGRPS_ATTR, pendingGroups);
request.setAttribute(Constants.NUM_PENDING_RESGRPS_ATTR, new Integer(pendingGroups.getTotalSize()));
request.setAttribute(Constants.AVAIL_RESGRPS_ATTR, availableGroups);
- request.setAttribute(Constants.NUM_AVAIL_RESGRPS_ATTR, new Integer(availableGroups.getTotalSize()));
+ request.setAttribute(Constants.NUM_AVAIL_RESGRPS_ATTR, new Integer(allGroups.size()));
+ //store cachedAvailableGroups in session so trim down ldap communication chatter.
+ request.getSession().setAttribute(LDAP_GROUP_CACHE, cachedAvailableLdapGroups);
return null;
}
@@ -175,4 +276,4 @@ public class AddLdapGroupsFormPrepareAction extends TilesAction {
}
return ret;
}
-}
\ No newline at end of file
+}
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/admin/role/AddLdapRoleGroups.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/admin/role/AddLdapRoleGroups.jsp
index 93ec22e..4341a5e 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/admin/role/AddLdapRoleGroups.jsp
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/admin/role/AddLdapRoleGroups.jsp
@@ -13,7 +13,7 @@
<tiles:insert definition=".portlet.error"/>
-<tiles:insert page="/admin/role/RoleGroupsForm.jsp">
+<tiles:insert page="/admin/role/RoleLdapGroupsForm.jsp">
<tiles:put name="availableResGrps" beanName="AvailableResGrps"/>
<tiles:put name="numAvailableResGrps" beanName="NumAvailableResGrps"/>
<tiles:put name="pendingResGrps" beanName="PendingResGrps"/>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/admin/role/RoleLdapGroupsForm.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/admin/role/RoleLdapGroupsForm.jsp
new file mode 100644
index 0000000..2880f22
--- /dev/null
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/admin/role/RoleLdapGroupsForm.jsp
@@ -0,0 +1,263 @@
+<%@ page language="java" %>
+<%@ page errorPage="/common/Error.jsp" %>
+<%@ taglib uri="http://jakarta.apache.org/struts/tags-html-el" prefix="html" %>
+<%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles" prefix="tiles" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<%@ taglib uri="/WEB-INF/tld/display.tld" prefix="display" %>
+
+<tiles:importAttribute name="availableResGrps"/>
+<tiles:importAttribute name="numAvailableResGrps"/>
+<tiles:importAttribute name="pendingResGrps"/>
+<tiles:importAttribute name="numPendingResGrps"/>
+
+<script language="JavaScript" src="<html:rewrite page="/js/addRemoveWidget.js"/>" type="text/javascript"></script>
+<c:set var="widgetInstanceName" value="addGroups"/>
+
+<script type="text/javascript">
+var pageData = new Array();
+initializeWidgetProperties('<c:out value="${widgetInstanceName}"/>');
+widgetProperties = getWidgetProperties('<c:out value="${widgetInstanceName}"/>');
+</script>
+
+<c:url var="selfPnaAction" value="/admin/role/RoleAdmin.do">
+ <c:param name="mode" value="addLdapGroups"/>
+ <c:param name="r" value="${Role.id}"/>
+ <c:if test="${not empty param.psa}">
+ <c:param name="psa" value="${param.psa}"/>
+ </c:if>
+ <c:if test="${not empty param.soa}">
+ <c:param name="soa" value="${param.soa}"/>
+ </c:if>
+ <c:if test="${not empty param.sca}">
+ <c:param name="sca" value="${param.sca}"/>
+ </c:if>
+ <c:if test="${not empty param.psp}">
+ <c:param name="psp" value="${param.psp}"/>
+ </c:if>
+ <c:if test="${not empty param.pnp}">
+ <c:param name="pnp" value="${param.pnp}"/>
+ </c:if>
+ <c:if test="${not empty param.sop}">
+ <c:param name="sop" value="${param.sop}"/>
+ </c:if>
+ <c:if test="${not empty param.scp}">
+ <c:param name="scp" value="${param.scp}"/>
+ </c:if>
+</c:url>
+
+<c:url var="selfPnpAction" value="/admin/role/RoleAdmin.do">
+ <c:param name="mode" value="addLdapGroups"/>
+ <c:param name="r" value="${Role.id}"/>
+ <c:if test="${not empty param.psa}">
+ <c:param name="psa" value="${param.psa}"/>
+ </c:if>
+ <c:if test="${not empty param.pna}">
+ <c:param name="pna" value="${param.pna}"/>
+ </c:if>
+ <c:if test="${not empty param.soa}">
+ <c:param name="soa" value="${param.soa}"/>
+ </c:if>
+ <c:if test="${not empty param.sca}">
+ <c:param name="sca" value="${param.sca}"/>
+ </c:if>
+ <c:if test="${not empty param.psp}">
+ <c:param name="psp" value="${param.psp}"/>
+ </c:if>
+ <c:if test="${not empty param.sop}">
+ <c:param name="sop" value="${param.sop}"/>
+ </c:if>
+ <c:if test="${not empty param.scp}">
+ <c:param name="scp" value="${param.scp}"/>
+ </c:if>
+</c:url>
+
+<c:url var="selfPsaAction" value="/admin/role/RoleAdmin.do">
+ <c:param name="mode" value="addLdapGroups"/>
+ <c:param name="r" value="${Role.id}"/>
+ <c:if test="${not empty param.pna}">
+ <c:param name="pna" value="${param.pna}"/>
+ </c:if>
+ <c:if test="${not empty param.soa}">
+ <c:param name="soa" value="${param.soa}"/>
+ </c:if>
+ <c:if test="${not empty param.sca}">
+ <c:param name="sca" value="${param.sca}"/>
+ </c:if>
+ <c:if test="${not empty param.pnp}">
+ <c:param name="pnp" value="${param.pnp}"/>
+ </c:if>
+ <c:if test="${not empty param.psp}">
+ <c:param name="psp" value="${param.psp}"/>
+ </c:if>
+ <c:if test="${not empty param.sop}">
+ <c:param name="sop" value="${param.sop}"/>
+ </c:if>
+ <c:if test="${not empty param.scp}">
+ <c:param name="scp" value="${param.scp}"/>
+ </c:if>
+</c:url>
+
+
+<c:url var="selfPspAction" value="/admin/role/RoleAdmin.do">
+ <c:param name="mode" value="addLdapGroups"/>
+ <c:param name="r" value="${Role.id}"/>
+ <c:if test="${not empty param.pna}">
+ <c:param name="pna" value="${param.pna}"/>
+ </c:if>
+ <c:if test="${not empty param.psa}">
+ <c:param name="psa" value="${param.psa}"/>
+ </c:if>
+ <c:if test="${not empty param.soa}">
+ <c:param name="soa" value="${param.soa}"/>
+ </c:if>
+ <c:if test="${not empty param.sca}">
+ <c:param name="sca" value="${param.sca}"/>
+ </c:if>
+ <c:if test="${not empty param.pnp}">
+ <c:param name="pnp" value="${param.pnp}"/>
+ </c:if>
+ <c:if test="${not empty param.sop}">
+ <c:param name="sop" value="${param.sop}"/>
+ </c:if>
+ <c:if test="${not empty param.scp}">
+ <c:param name="scp" value="${param.scp}"/>
+ </c:if>
+</c:url>
+
+<c:url var="selfPaAction" value="/admin/role/RoleAdmin.do">
+ <c:param name="mode" value="addLdapGroups"/>
+ <c:param name="r" value="${Role.id}"/>
+ <c:if test="${not empty param.pna}">
+ <c:param name="pna" value="${param.pna}"/>
+ </c:if>
+ <c:if test="${not empty param.psa}">
+ <c:param name="psa" value="${param.psa}"/>
+ </c:if>
+ <c:if test="${not empty param.pnp}">
+ <c:param name="pnp" value="${param.pnp}"/>
+ </c:if>
+ <c:if test="${not empty param.psp}">
+ <c:param name="psp" value="${param.psp}"/>
+ </c:if>
+ <c:if test="${not empty param.sop}">
+ <c:param name="sop" value="${param.sop}"/>
+ </c:if>
+ <c:if test="${not empty param.scp}">
+ <c:param name="scp" value="${param.scp}"/>
+ </c:if>
+</c:url>
+
+<c:url var="selfPpAction" value="/admin/role/RoleAdmin.do">
+ <c:param name="mode" value="addLdapGroups"/>
+ <c:param name="r" value="${Role.id}"/>
+ <c:if test="${not empty param.pna}">
+ <c:param name="pna" value="${param.pna}"/>
+ </c:if>
+ <c:if test="${not empty param.psa}">
+ <c:param name="psa" value="${param.psa}"/>
+ </c:if>
+ <c:if test="${not empty param.soa}">
+ <c:param name="soa" value="${param.soa}"/>
+ </c:if>
+ <c:if test="${not empty param.sca}">
+ <c:param name="sca" value="${param.sca}"/>
+ </c:if>
+ <c:if test="${not empty param.pnp}">
+ <c:param name="pnp" value="${param.pnp}"/>
+ </c:if>
+ <c:if test="${not empty param.psp}">
+ <c:param name="psp" value="${param.psp}"/>
+ </c:if>
+</c:url>
+
+
+<!-- SELECT & ADD -->
+<table width="100%" cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td width="50%" valign="top">
+
+<tiles:insert definition=".header.tab">
+ <tiles:put name="tabKey" value="admin.role.groups.GroupsTab"/>
+ <tiles:put name="useFromSideBar" value="true"/>
+</tiles:insert>
+
+ </td>
+ <td><html:img page="/images/spacer.gif" width="40" height="1" border="0"/></td>
+ <td>
+
+<tiles:insert definition=".header.tab">
+ <tiles:put name="tabKey" value="admin.role.groups.AssignToRoleTab"/>
+ <tiles:put name="useToSideBar" value="true"/>
+</tiles:insert>
+
+ </td>
+ </tr>
+ <tr>
+ <!-- SELECT COLUMN -->
+ <td width="50%" valign="top">
+ <!-- TABLED LIST CONTENTS (SELECT COLUMN) -->
+ <div id="<c:out value="${widgetInstanceName}"/>FromDiv">
+
+ <display:table padRows="true" rightSidebar="true" items="${AvailableResGrps}" var="group" action="${selfPaAction}"
+ postfix="a"
+ styleId="fromTable" width="100%" cellpadding="0" cellspacing="0" border="0">
+ <display:column width="1%" property="id" title="<input type=\"checkbox\" onclick=\"ToggleAll(this, widgetProperties)\" name=\"fromToggleAll\">" isLocalizedTitle="false" styleClass="ListCellCheckbox" headerStyleClass="ListHeaderCheckbox">
+ <display:checkboxdecorator name="availableGroup" onclick="ToggleSelection(this, widgetProperties)" styleClass="availableListMember"/>
+ </display:column>
+ <display:column property="name" title="common.header.Group" sortAttr="lg.name" width="50%"/>
+ <display:column property="description" title="common.header.Description" sortAttr="lg.description" width="50%"/>
+ </display:table>
+
+ </div>
+ <!-- / -->
+
+<tiles:insert definition=".toolbar.new">
+ <tiles:put name="useFromSideBar" value="true"/>
+ <tiles:put name="pageList" beanName="AvailableResGrps"/>
+ <tiles:put name="pageAction" beanName="selfPsaAction"/>
+ <tiles:put name="postfix" value="a"/>
+</tiles:insert>
+
+ </td>
+ <!-- / SELECT COLUMN -->
+
+ <!-- ADD/REMOVE COLUMN -->
+ <td id="<c:out value="${widgetInstanceName}"/>AddRemoveButtonTd">
+ <div id="AddButtonDiv" align="left"><html:img page="/images/fb_addarrow_gray.gif" border="0" titleKey="AddToList.ClickToAdd"/></div>
+ <br> <br>
+ <div id="RemoveButtonDiv" align="right"><html:img page="/images/fb_removearrow_gray.gif" border="0" titleKey="AddToList.ClickToRemove"/></div>
+ </td>
+ <!-- / ADD/REMOVE COLUMN -->
+
+ <!-- ADD COLUMN -->
+ <td width="50%" valign="top">
+ <!-- TABLED LIST CONTENTS (SELECT COLUMN) -->
+ <div id='<c:out value="${widgetInstanceName}"/>ToDiv'>
+
+ <display:table padRows="true" leftSidebar="true" items="${PendingResGrps}" var="group" action="${selfPpAction}"
+ postfix="p"
+ styleId="toTable" width="100%" cellpadding="0" cellspacing="0" border="0">
+ <display:column width="1%" property="id" title="<input type=\"checkbox\" onclick=\"ToggleAll(this, widgetProperties)\" name=\"toToggleAll\">" isLocalizedTitle="false" styleClass="ListCellCheckbox" headerStyleClass="ListHeaderCheckbox">
+ <display:checkboxdecorator name="pendingGroup" onclick="ToggleSelection(this, widgetProperties)" styleClass="pendingListMember"/>
+ </display:column>
+ <display:column property="name" title="common.header.Group" sortAttr="lg.name" width="50%"/>
+ <display:column property="description" title="common.header.Description" width="50%" sortAttr="lg.description"/>
+ </display:table>
+
+ </div>
+ <!-- / -->
+
+<tiles:insert definition=".toolbar.new">
+ <tiles:put name="newButtonKey" value="admin.role.groups.NewResourceGroupButton"/>
+ <tiles:put name="useToSideBar" value="true"/>
+ <tiles:put name="pageList" beanName="PendingResGrps"/>
+ <tiles:put name="pageAction" beanName="selfPspAction"/>
+ <tiles:put name="postfix" value="p"/>
+</tiles:insert>
+
+ </td>
+ <!-- / ADD COLUMN -->
+
+ </tr>
+</table>
+<!-- / SELECT & ADD -->
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManager.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManager.java
index 0478fd8..e372777 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManager.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManager.java
@@ -208,8 +208,10 @@ public class LdapGroupManager {
}
Map<String, String> entry = new HashMap<String, String>();
String name = (String) si.getAttributes().get("cn").get();
+ name = name.trim();
Attribute desc = si.getAttributes().get("description");
String description = desc != null ? (String) desc.get() : "";
+ description = description.trim();
entry.put("id", name);
entry.put("name", name);
entry.put("description", description);
14 years, 1 month