<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head><style type="text/css"><!-- #msg DL { border : 1px #006 solid; background-color : #369; padding : 6px; color : #fff; } #msg DT { float : left; width : 6em; font-weight : bold; } #msg DL, #msg DT, #msg UL, #msg LI { font-family : arial,helvetica,sans-serif; font-size : 10pt; } h3 { font-family : arial,helvetica,sans-serif; font-size : 10pt; font-weight : bold; } #msg PRE { overflow : auto; white-space : normal; background-color : #ffc; border : 1px #fc0 solid; padding : 6px; } #msg UL, PRE, .diff { overflow : auto; } #patch h4 { font-family : arial,helvetica,sans-serif; font-size : 10pt; } #patch h4 { padding: 8px; background : #369; color : #fff; margin : 0; } #patch .propset h4, #patch .binary h4 {margin: 0;} #patch pre {padding:0;line-height:1.2em;margin:0;} #patch .diff {background:#eeeeee;padding: 0 0 10px 0;} #patch .propset .diff, #patch .binary .diff {padding: 10px 0;} #patch span {display:block;padding:0 10px;} #patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;} #patch .add {background:#ddffdd;} #patch .rem {background:#ffdddd;} #patch .lines, .info {color:#888888;background:#ffffff;} .diff { width : 100%; } #msg DL { border : 1px #006 solid; background-color : #369; padding : 6px; color : #fff; } #msg DT { float : left; width : 6em; font-weight : bold; } #msg DL, #msg DT, #msg UL, #msg LI { font-family : arial,helvetica,sans-serif; font-size : 10pt; } h3 { font-family : arial,helvetica,sans-serif; font-size : 10pt; font-weight : bold; } #msg PRE { overflow : auto; white-space : normal; background-color : #ffc; border : 1px #fc0 solid; padding : 6px; } #msg UL, PRE, .diff { overflow : auto; } #patch h4 { font-family : arial,helvetica,sans-serif; font-size : 10pt; } #patch h4 { padding: 8px; background : #369; color : #fff; margin : 0; } #patch .propset h4, #patch .binary h4 {margin: 0;} #patch pre {padding:0;line-height:1.2em;margin:0;} #patch .diff {background:#eeeeee;padding: 0 0 10px 0;} #patch .propset .diff, #patch .binary .diff {padding: 10px 0;} #patch span {display:block;padding:0 10px;} #patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;} #patch .add {background:#ddffdd;} #patch .rem {background:#ffdddd;} #patch .lines, .info {color:#888888;background:#ffffff;} .diff { width : 100%; } --></style> <title>[rhq-project.org rhq] [3586] [RHQ-1909] - enable recursive bit to be toggled on existing group definitions, and update the implicit resource lists of all managed dynagroups as appropriate; </title> </head> <body> <div id="msg"> <dl> <dt>Revision</dt> <dd>3586</dd> <dt>Author</dt> <dd>jmarques</dd> <dt>Date</dt> <dd>2009-04-01 13:19:48 -0500 (Wed, 01 Apr 2009)</dd> </dl> <h3>Log Message</h3> <pre>[RHQ-1909] - enable recursive bit to be toggled on existing group definitions, and update the implicit resource lists of all managed dynagroups as appropriate; </pre> <h3>Modified Paths</h3> <ul> <li><a href="#rhqtrunkmodulesenterpriseguiportalwarsrcmainjavaorgrhqenterpriseguiinventorygroupEditGroupGeneralPropertiesUIBeanjava">rhq/trunk/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/group/EditGroupGeneralPropertiesUIBean.java</a></li> <li><a href="#rhqtrunkmodulesenterpriseguiportalwarsrcmainwebapprhqdefinitiongroupeditgeneralxhtml">rhq/trunk/modules/enterprise/gui/portal-war/src/main/webapp/rhq/definition/group/edit-general.xhtml</a></li> <li><a href="#rhqtrunkmodulesenterpriseserverjarsrcmainjavaorgrhqenterpriseserverresourcegroupResourceGroupManagerBeanjava">rhq/trunk/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java</a></li> <li><a href="#rhqtrunkmodulesenterpriseserverjarsrcmainjavaorgrhqenterpriseserverresourcegroupResourceGroupManagerLocaljava">rhq/trunk/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerLocal.java</a></li> <li><a href="#rhqtrunkmodulesenterpriseserverjarsrcmainjavaorgrhqenterpriseserverresourcegroupdefinitionGroupDefinitionManagerBeanjava">rhq/trunk/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java</a></li> </ul> <h3>Added Paths</h3> <ul> <li><a href="#rhqtrunkmodulesenterpriseserverjarsrcmainjavaorgrhqenterpriseserverresourcegroupRecursivityChangeTypejava">rhq/trunk/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/RecursivityChangeType.java</a></li> </ul> </div> <div id="patch"> <h3>Diff</h3> <a id="rhqtrunkmodulesenterpriseguiportalwarsrcmainjavaorgrhqenterpriseguiinventorygroupEditGroupGeneralPropertiesUIBeanjava"></a> <div class="modfile"><h4>Modified: rhq/trunk/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/group/EditGroupGeneralPropertiesUIBean.java (3585 => 3586)</h4> <pre class="diff"> <span class="info">--- rhq/trunk/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/group/EditGroupGeneralPropertiesUIBean.java 2009-04-01 18:08:41 UTC (rev 3585) +++ rhq/trunk/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/group/EditGroupGeneralPropertiesUIBean.java 2009-04-01 18:19:48 UTC (rev 3586) </span><span class="lines">@@ -66,6 +66,7 @@ </span><span class="cx"> resourceGroup.setRecursive(this.recursive); try { </span><span class="add">+ // pass null to let the method try to figure out the change </span><span class="cx"> this.resourceGroupManager.updateResourceGroup(subject, resourceGroup); } catch (ResourceGroupUpdateException rgue) { FacesContextUtility.addMessage(FacesMessage.SEVERITY_ERROR, "Problem updating group: " + rgue.getMessage()); </span></pre></div> <a id="rhqtrunkmodulesenterpriseguiportalwarsrcmainwebapprhqdefinitiongroupeditgeneralxhtml"></a> <div class="modfile"><h4>Modified: rhq/trunk/modules/enterprise/gui/portal-war/src/main/webapp/rhq/definition/group/edit-general.xhtml (3585 => 3586)</h4> <pre class="diff"> <span class="info">--- rhq/trunk/modules/enterprise/gui/portal-war/src/main/webapp/rhq/definition/group/edit-general.xhtml 2009-04-01 18:08:41 UTC (rev 3585) +++ rhq/trunk/modules/enterprise/gui/portal-war/src/main/webapp/rhq/definition/group/edit-general.xhtml 2009-04-01 18:19:48 UTC (rev 3586) </span><span class="lines">@@ -32,14 +32,44 @@ </span><span class="cx"> </f:facet> <h:panelGrid columns="2" styleClass="general-props-table" columnClasses="general-prop-cell"> </span><span class="add">+ + <h:panelGroup layout="block"> </span><span class="cx"> <h:panelGroup styleClass="BlockLabel">Name <h:panelGroup styleClass="required-marker-text"> *</h:panelGroup>: </h:panelGroup> </span><span class="rem">- <h:inputText id="name" value="#{EditGroupDefinitionGeneralPropertiesUIBean.name}" size="60" maxlength="100" /> </span><span class="add">+ </h:panelGroup> </span><span class="cx"> </span><span class="add">+ <h:panelGroup layout="block"> + <h:inputText id="name" value="#{EditGroupDefinitionGeneralPropertiesUIBean.name}" required="true" size="60" maxlength="100"> + <f:validateLength maximum="100"/> + </h:inputText> + <h:message for="name" showDetail="true" errorClass="WarnBlock"/> + </h:panelGroup> + + <h:panelGroup layout="block"> </span><span class="cx"> <h:panelGroup styleClass="BlockLabel">Description:</h:panelGroup> </span><span class="rem">- <h:inputText id="description" value="#{EditGroupDefinitionGeneralPropertiesUIBean.description}" size="60" maxlength="1000" /> </span><span class="add">+ </h:panelGroup> + + <h:panelGroup layout="block"> + <h:inputText id="description" value="#{EditGroupDefinitionGeneralPropertiesUIBean.description}" size="60" maxlength="1000"> + <f:validateLength maximum="1000"/> + </h:inputText> + <h:message for="description" showDetail="true" errorClass="WarnBlock"/> + </h:panelGroup> + + <h:panelGroup layout="block"> + <h:panelGroup styleClass="BlockLabel">Recursive:</h:panelGroup> + </h:panelGroup> + + <h:panelGroup layout="block"> + <h:selectBooleanCheckbox id="recursive" value="#{EditGroupDefinitionGeneralPropertiesUIBean.recursive}" /> + <h:outputText value=" Warning: changing the recursivity of a group can be an expensive operation" /> + </h:panelGroup> + + <rich:spacer /> + </span><span class="cx"> </h:panelGrid> </span><span class="add">+ </span><span class="cx"> </rich:panel> <!-- =================== GROUP DEFINITION CONDITIONS =================== --> </span></pre></div> <a id="rhqtrunkmodulesenterpriseserverjarsrcmainjavaorgrhqenterpriseserverresourcegroupRecursivityChangeTypejava"></a> <div class="addfile"><h4>Added: rhq/trunk/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/RecursivityChangeType.java (0 => 3586)</h4> <pre class="diff"> <span class="info">--- rhq/trunk/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/RecursivityChangeType.java (rev 0) +++ rhq/trunk/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/RecursivityChangeType.java 2009-04-01 18:19:48 UTC (rev 3586) </span><span class="lines">@@ -0,0 +1,5 @@ </span><span class="add">+package org.rhq.enterprise.server.resource.group; + +public enum RecursivityChangeType { + None, AddedRecursion, RemovedRecursion; +} </span><span class="cx">Property changes on: rhq/trunk/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/RecursivityChangeType.java ___________________________________________________________________ </span></pre></div> <a id="svnmimetype"></a> <div class="addfile"><h4>Added: svn:mime-type ( => )</h4> <pre class="diff"> <span class="info"> Modified: rhq/trunk/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java </span><span class="cx">=================================================================== </span><span class="rem">--- rhq/trunk/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java 2009-04-01 18:08:41 UTC (rev 3585) </span><span class="add">+++ rhq/trunk/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java 2009-04-01 18:19:48 UTC (rev 3586) </span><span class="lines">@@ -157,13 +157,16 @@ </span><span class="cx"> return group.getId(); } </span><span class="rem">- enum ResourceGroupChangeType { - None, AddedRecursion, RemovedRecursion; </span><span class="add">+ @RequiredPermission(Permission.MANAGE_INVENTORY) + public ResourceGroup updateResourceGroup(Subject user, ResourceGroup group) + throws ResourceGroupAlreadyExistsException, ResourceGroupUpdateException { + return updateResourceGroup(user, group, null); </span><span class="cx"> } @RequiredPermission(Permission.MANAGE_INVENTORY) </span><span class="rem">- public ResourceGroup updateResourceGroup(Subject user, ResourceGroup group) </span><span class="add">+ public ResourceGroup updateResourceGroup(Subject user, ResourceGroup group, RecursivityChangeType changeType) </span><span class="cx"> throws ResourceGroupAlreadyExistsException, ResourceGroupUpdateException { </span><span class="add">+ </span><span class="cx"> Query query = entityManager.createNamedQuery(ResourceGroup.QUERY_FIND_BY_NAME); query.setParameter("name", group.getName()); </span><span class="lines">@@ -181,16 +184,18 @@ </span><span class="cx"> // user is changing the name of the group, this is OK } </span><span class="rem">- ResourceGroupChangeType changeType = ResourceGroupChangeType.None; - ResourceGroup attachedGroup = entityManager.find(ResourceGroup.class, group.getId()); - if (attachedGroup.isRecursive() == true && group.isRecursive() == false) { - // making a recursive group into a "normal" group - changeType = ResourceGroupChangeType.RemovedRecursion; - } else if (attachedGroup.isRecursive() == false && group.isRecursive() == true) { - // making a "normal" group into a recursive group - changeType = ResourceGroupChangeType.AddedRecursion; - } else { - // recursive bit didn't change </span><span class="add">+ if (changeType == null) { + ResourceGroup attachedGroup = entityManager.find(ResourceGroup.class, groupId); + changeType = RecursivityChangeType.None; + if (attachedGroup.isRecursive() == true && group.isRecursive() == false) { + // making a recursive group into a "normal" group + changeType = RecursivityChangeType.RemovedRecursion; + } else if (attachedGroup.isRecursive() == false && group.isRecursive() == true) { + // making a "normal" group into a recursive group + changeType = RecursivityChangeType.AddedRecursion; + } else { + // recursive bit didn't change + } </span><span class="cx"> } long time = System.currentTimeMillis(); </span><span class="lines">@@ -198,9 +203,11 @@ </span><span class="cx"> group.setModifiedBy(user); ResourceGroup newlyAttachedGroup = entityManager.merge(group); </span><span class="rem">- if (changeType == ResourceGroupChangeType.AddedRecursion) { </span><span class="add">+ if (changeType == RecursivityChangeType.AddedRecursion) { + newlyAttachedGroup.setRecursive(true); </span><span class="cx"> enableRecursivityForGroup(user, groupId); </span><span class="rem">- } else if (changeType == ResourceGroupChangeType.RemovedRecursion) { </span><span class="add">+ } else if (changeType == RecursivityChangeType.RemovedRecursion) { + newlyAttachedGroup.setRecursive(false); </span><span class="cx"> resourceGroupManager.clearImplicitResources(groupId); makeImplicitMirrorExplicit(groupId); } </span><span class="lines">@@ -829,7 +836,7 @@ </span><span class="cx"> */ private void addResourcesToGroupHelper(ResourceGroup group, ResourceIdFlyWeight fly, boolean alreadyInExplicit) { // both groups get the resource added to the explicit list </span><span class="rem">- if (alreadyInExplicit) { </span><span class="add">+ if (alreadyInExplicit == false) { </span><span class="cx"> // but if we know we're already in the explicit list, skip this and continue processing group.addExplicitResource(fly); } </span></pre></div> <a id="rhqtrunkmodulesenterpriseserverjarsrcmainjavaorgrhqenterpriseserverresourcegroupResourceGroupManagerLocaljava"></a> <div class="modfile"><h4>Modified: rhq/trunk/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerLocal.java (3585 => 3586)</h4> <pre class="diff"> <span class="info">--- rhq/trunk/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerLocal.java 2009-04-01 18:08:41 UTC (rev 3585) +++ rhq/trunk/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerLocal.java 2009-04-01 18:19:48 UTC (rev 3586) </span><span class="lines">@@ -43,6 +43,9 @@ </span><span class="cx"> public interface ResourceGroupManagerLocal { int createResourceGroup(Subject user, ResourceGroup group) throws ResourceGroupAlreadyExistsException; </span><span class="add">+ ResourceGroup updateResourceGroup(Subject user, ResourceGroup group, RecursivityChangeType changeType) + throws ResourceGroupAlreadyExistsException, ResourceGroupUpdateException; + </span><span class="cx"> ResourceGroup updateResourceGroup(Subject user, ResourceGroup group) throws ResourceGroupAlreadyExistsException, ResourceGroupUpdateException; </span></pre></div> <a id="rhqtrunkmodulesenterpriseserverjarsrcmainjavaorgrhqenterpriseserverresourcegroupdefinitionGroupDefinitionManagerBeanjava"></a> <div class="modfile"><h4>Modified: rhq/trunk/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java (3585 => 3586)</h4> <pre class="diff"> <span class="info">--- rhq/trunk/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java 2009-04-01 18:08:41 UTC (rev 3585) +++ rhq/trunk/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java 2009-04-01 18:19:48 UTC (rev 3586) </span><span class="lines">@@ -63,6 +63,7 @@ </span><span class="cx"> import org.rhq.enterprise.server.authz.RequiredPermission; import org.rhq.enterprise.server.resource.ResourceManagerLocal; import org.rhq.enterprise.server.resource.ResourceTypeNotFoundException; </span><span class="add">+import org.rhq.enterprise.server.resource.group.RecursivityChangeType; </span><span class="cx"> import org.rhq.enterprise.server.resource.group.ResourceGroupAlreadyExistsException; import org.rhq.enterprise.server.resource.group.ResourceGroupManagerLocal; import org.rhq.enterprise.server.resource.group.ResourceGroupUpdateException; </span><span class="lines">@@ -192,14 +193,6 @@ </span><span class="cx"> public GroupDefinition updateGroupDefinition(Subject subject, GroupDefinition groupDefinition) throws GroupDefinitionAlreadyExistsException, GroupDefinitionUpdateException, InvalidExpressionException, ResourceGroupUpdateException { </span><span class="rem">- try { - if (getById(groupDefinition.getId()).isRecursive() != groupDefinition.isRecursive()) { - throw new GroupDefinitionUpdateException("Can not change the " - + (groupDefinition.isRecursive() ? "" : "non-") + "recursive nature of this group definition"); - } - } catch (GroupDefinitionNotFoundException gdnfe) { - throw new GroupDefinitionUpdateException(gdnfe.getMessage()); - } </span><span class="cx"> boolean nameChanged = false; try { </span><span class="lines">@@ -213,23 +206,35 @@ </span><span class="cx"> evaluator.addExpression(expression); } </span><span class="rem">- if (nameChanged) { - String oldGroupDefinitionName = null; - GroupDefinition attachedGroupDefinition = null; - try { - attachedGroupDefinition = getById(groupDefinition.getId()); - oldGroupDefinitionName = attachedGroupDefinition.getName(); - } catch (GroupDefinitionNotFoundException gdnfe) { - throw new GroupDefinitionUpdateException(gdnfe.getMessage()); - } </span><span class="add">+ RecursivityChangeType changeType = RecursivityChangeType.None; + GroupDefinition attachedGroupDefinition = null; + try { + attachedGroupDefinition = getById(groupDefinition.getId()); + } catch (GroupDefinitionNotFoundException gdnfe) { + throw new GroupDefinitionUpdateException(gdnfe.getMessage()); + } + if (groupDefinition.isRecursive() == true && attachedGroupDefinition.isRecursive() == false) { + // making a recursive group into a "normal" group + changeType = RecursivityChangeType.AddedRecursion; + } else if (groupDefinition.isRecursive() == false && attachedGroupDefinition.isRecursive() == true) { + // making a "normal" group into a recursive group + changeType = RecursivityChangeType.RemovedRecursion; + } else { + // recursive bit didn't change + } </span><span class="cx"> </span><span class="add">+ if (nameChanged || changeType != RecursivityChangeType.None) { + String oldGroupDefinitionName = attachedGroupDefinition.getName(); </span><span class="cx"> Subject overlord = subjectManager.getOverlord(); for (ResourceGroup dynaGroup : attachedGroupDefinition.getManagedResourceGroups()) { String dynaGroupName = dynaGroup.getName(); String newDynaGroupName = updateDynaGroupName(oldGroupDefinitionName, groupDefinition.getName(), dynaGroupName); dynaGroup.setName(newDynaGroupName); </span><span class="rem">- resourceGroupManager.updateResourceGroup(overlord, dynaGroup); </span><span class="add">+ // do not set recursive bit here + // the update method will figure out whether to flip it by inspecting its managing GroupDefinition + //dynaGroup.setRecursive(groupDefinition.isRecursive()); + resourceGroupManager.updateResourceGroup(overlord, dynaGroup, changeType); </span><span class="cx"> } } </span><span class="lines">@@ -238,7 +243,6 @@ </span><span class="cx"> } catch (Exception e) { throw new GroupDefinitionUpdateException(e); } </span><span class="rem">- </span><span class="cx"> } // return boolean indicating whether the name of this group definition is changing </span> </pre> </div> </div> </body> </html> |