From: <cc...@rh...> - 2009-07-30 23:23:45
|
<!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] [4667] bring back RHQ-2110</title> </head> <body> <div id="msg"> <dl> <dt>Revision</dt> <dd>4667</dd> <dt>Author</dt> <dd>ccrouch</dd> <dt>Date</dt> <dd>2009-07-30 18:23:26 -0500 (Thu, 30 Jul 2009)</dd> </dl> <h3>Log Message</h3> <pre>bring back RHQ-2110</pre> <h3>Modified Paths</h3> <ul> <li><a href="#rhqbranchesRHQ_1_2_0_GA_PERFmodulesenterpriseserverjarsrcmainjavaorgrhqenterpriseserverresourcegroupResourceGroupManagerBeanjava">rhq/branches/RHQ_1_2_0_GA_PERF/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java</a></li> </ul> </div> <div id="patch"> <h3>Diff</h3> <a id="rhqbranchesRHQ_1_2_0_GA_PERFmodulesenterpriseserverjarsrcmainjavaorgrhqenterpriseserverresourcegroupResourceGroupManagerBeanjava"></a> <div class="modfile"><h4>Modified: rhq/branches/RHQ_1_2_0_GA_PERF/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java (4666 => 4667)</h4> <pre class="diff"> <span class="info">--- rhq/branches/RHQ_1_2_0_GA_PERF/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java 2009-07-30 23:14:45 UTC (rev 4666) +++ rhq/branches/RHQ_1_2_0_GA_PERF/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java 2009-07-30 23:23:26 UTC (rev 4667) </span><span class="lines">@@ -378,10 +378,17 @@ </span><span class="cx"> @RequiredPermission(Permission.MANAGE_INVENTORY) public void addResourcesToGroup(Subject subject, Integer groupId, Integer[] resourceIds) throws ResourceGroupNotFoundException, ResourceGroupUpdateException { </span><span class="rem">- List<Integer> resourceIdList = Arrays.asList(resourceIds); </span><span class="add">+ </span><span class="cx"> boolean isRecursive = isRecursive(groupId); // will perform check for group existence </span><span class="rem">- addResourcesToGroupImplicit(subject, groupId, resourceIdList, true, isRecursive); - addResourcesToGroupExplicit(subject, groupId, resourceIdList, isRecursive); </span><span class="add">+ + // batch the removes to prevent the ORA error about IN clauses containing more than 1000 items + for (int batchIndex = 0; batchIndex < resourceIds.length; batchIndex += 1000) { + Integer[] batchIdArray = ArrayUtils.copyOfRange(resourceIds, batchIndex, batchIndex + 1000); + List<Integer> batchIds = Arrays.asList(batchIdArray); + + addResourcesToGroupImplicit(subject, groupId, batchIds, true, isRecursive); + addResourcesToGroupExplicit(subject, groupId, batchIds, isRecursive); + } </span><span class="cx"> } private void addResourcesToGroupExplicit(Subject subject, Integer groupId, List<Integer> resourceIds, </span><span class="lines">@@ -505,12 +512,24 @@ </span><span class="cx"> @RequiredPermission(Permission.MANAGE_INVENTORY) public void removeResourcesFromGroup(Subject subject, Integer groupId, Integer[] resourceIds) throws ResourceGroupNotFoundException, ResourceGroupUpdateException { </span><span class="add">+ </span><span class="cx"> if (resourceIds == null || resourceIds.length == 0) { return; } boolean isRecursive = isRecursive(groupId); // will perform check for group existence </span><span class="add">+ // batch the removes to prevent the ORA error about IN clauses containing more than 1000 items + for (int batchIndex = 0; batchIndex < resourceIds.length; batchIndex += 1000) { + Integer[] batchIdArray = ArrayUtils.copyOfRange(resourceIds, batchIndex, batchIndex + 1000); + + removeResourcesFromGroup_helper(subject, groupId, batchIdArray, isRecursive); + } + } + + private void removeResourcesFromGroup_helper(Subject subject, Integer groupId, Integer[] resourceIds, + boolean isRecursive) throws ResourceGroupNotFoundException, ResourceGroupUpdateException { + </span><span class="cx"> List<Integer> nonMembersToBeRemoved = getNonMemberExplicitResources(groupId, Arrays.asList(resourceIds)); if (nonMembersToBeRemoved.size() != 0) { throw new ResourceGroupUpdateException("Can not remove resources[" + nonMembersToBeRemoved </span> </pre> </div> </div> </body> </html> |