modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java | 4 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerLocal.java | 4 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerRemote.java | 5 - modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBean.java | 47 +++++----- 4 files changed, 29 insertions(+), 31 deletions(-)
New commits: commit 499b716d200ce8696a7e34e3ee75b1148b33a508 Merge: d6ba7b1... bf0f95c... Author: hudson auto wnstb@yahoo.com Date: Wed Jul 21 22:03:10 2010 -0400
Merge branch 'release-3.0.0-test-build' of ssh://git.fedorahosted.org/git/rhq/rhq into release-3.0.0-test-build
commit d6ba7b1ab1a8fe54e3fa65bbfff0b53181e0c020 Merge: 76bbed4... 09963f3... Author: Jay Shaughnessy jshaughn@redhat.com Date: Wed Jul 21 17:39:06 2010 -0400
Merge branch 'release-3.0.0' into release-3.0.0-work
commit 76bbed4c0d1362c83356f0382cd99700b8c07e41 Author: Jay Shaughnessy jshaughn@redhat.com Date: Wed Jul 21 17:37:20 2010 -0400
[bz 616978] extend transactional timeout to compensate for removal of an obsolete type with a large number of doomed resources.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBean.java index 1cc1b44..64e9afd 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBean.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBean.java @@ -49,6 +49,8 @@ import javax.sql.DataSource; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory;
+import org.jboss.annotation.ejb.TransactionTimeout; + import org.rhq.core.clientapi.agent.metadata.PluginDependencyGraph; import org.rhq.core.clientapi.agent.metadata.PluginMetadataManager; import org.rhq.core.clientapi.agent.metadata.SubCategoriesMetadataParser; @@ -429,7 +431,7 @@ public class ResourceMetadataManagerBean implements ResourceMetadataManagerLocal return; }
- private void updateTypes(Set<ResourceType> resourceTypes) throws Exception { + private void updateTypes(Set<ResourceType> resourceTypes) throws Exception { // Only process the type if it is a non-runs-inside type (i.e. not a child of some other type X at this same // level in the type hierarchy). runs-inside types which we skip here will get processed at the next level down // when we recursively process type X's children. @@ -462,8 +464,10 @@ public class ResourceMetadataManagerBean implements ResourceMetadataManagerLocal } }
+ // up timeout to 60 minutes in case of large inventories @SuppressWarnings("unchecked") @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) + @TransactionTimeout(60 * 60) public void removeObsoleteTypesInNewTransaction(String pluginName) { try { Query query = entityManager.createNamedQuery(ResourceType.QUERY_FIND_BY_PLUGIN); @@ -512,8 +516,7 @@ public class ResourceMetadataManagerBean implements ResourceMetadataManagerLocal }
private void removeResourceTypes(Subject overlord, Set<ResourceType> candidateTypes, - Set<ResourceType> typesToBeRemoved) - throws Exception { + Set<ResourceType> typesToBeRemoved) throws Exception { for (ResourceType candidateType : candidateTypes) { // Remove obsolete descendant types first. Set<ResourceType> childTypes = candidateType.getChildResourceTypes(); @@ -533,7 +536,7 @@ public class ResourceMetadataManagerBean implements ResourceMetadataManagerLocal }
private void removeResourceType(Subject overlord, ResourceType existingType) { - log.info("Removing ResourceType [" + toConciseString(existingType) + "]..."); + log.info("Removing ResourceType [" + toConciseString(existingType) + "]...");
if (entityManager.contains(existingType)) { entityManager.refresh(existingType); @@ -635,8 +638,8 @@ public class ResourceMetadataManagerBean implements ResourceMetadataManagerLocal
ResourceType existingType; try { - existingType = resourceTypeManager.getResourceTypeByNameAndPlugin(resourceType.getName(), - resourceType.getPlugin()); + existingType = resourceTypeManager.getResourceTypeByNameAndPlugin(resourceType.getName(), resourceType + .getPlugin()); } catch (NonUniqueResultException nure) { log.debug("Found more than one existing ResourceType for " + resourceType); // TODO: Delete the redundant ResourceTypes to get the DB into a valid state. @@ -701,8 +704,8 @@ public class ResourceMetadataManagerBean implements ResourceMetadataManagerLocal // above already took care of any modifications to the ResourceSubCategories themselves). } else if (newSubCat == null) { if (oldSubCat != null) { - log.debug("Metadata update: Subcategory of ResourceType [" + resourceType.getName() - + "] changed from " + oldSubCat + " to " + newSubCat); + log.debug("Metadata update: Subcategory of ResourceType [" + resourceType.getName() + "] changed from " + + oldSubCat + " to " + newSubCat); existingType.setSubCategory(null); } } else { @@ -762,14 +765,14 @@ public class ResourceMetadataManagerBean implements ResourceMetadataManagerLocal if (log.isDebugEnabled()) { if (existingType != null) { log.debug("Setting parent types on existing type: " + existingType + " to [" - + newType.getParentResourceTypes() + "] - current parent types are [" - + existingType.getParentResourceTypes() + "]..."); + + newType.getParentResourceTypes() + "] - current parent types are [" + + existingType.getParentResourceTypes() + "]..."); } else { - log.debug("Setting parent types on new type: " + newType - + " to [" + newType.getParentResourceTypes() + "]..."); + log.debug("Setting parent types on new type: " + newType + " to [" + newType.getParentResourceTypes() + + "]..."); } } - + Set<ResourceType> newParentTypes = newType.getParentResourceTypes(); newType.setParentResourceTypes(new HashSet<ResourceType>()); Set<ResourceType> originalExistingParentTypes = new HashSet<ResourceType>(); @@ -778,7 +781,7 @@ public class ResourceMetadataManagerBean implements ResourceMetadataManagerLocal } for (ResourceType newParentType : newParentTypes) { try { - boolean isExistingParent = originalExistingParentTypes.remove(newParentType); + boolean isExistingParent = originalExistingParentTypes.remove(newParentType); if (existingType == null || !isExistingParent) { ResourceType realParentType = (ResourceType) entityManager.createNamedQuery( ResourceType.QUERY_FIND_BY_NAME_AND_PLUGIN).setParameter("name", newParentType.getName()) @@ -786,19 +789,19 @@ public class ResourceMetadataManagerBean implements ResourceMetadataManagerLocal ResourceType type = (existingType != null) ? existingType : newType; if (existingType != null) { log.info("Adding ResourceType [" + toConciseString(type) + "] as child of ResourceType [" - + toConciseString(realParentType) + "]..."); + + toConciseString(realParentType) + "]..."); } realParentType.addChildResourceType(type); } } catch (NoResultException nre) { - throw new RuntimeException("Couldn't persist type [" + newType - + "] because parent [" + newParentType + "] wasn't already persisted."); + throw new RuntimeException("Couldn't persist type [" + newType + "] because parent [" + newParentType + + "] wasn't already persisted."); } }
for (ResourceType obsoleteParentType : originalExistingParentTypes) { log.info("Removing type [" + toConciseString(existingType) + "] from parent type [" - + toConciseString(obsoleteParentType) + "]..."); + + toConciseString(obsoleteParentType) + "]..."); obsoleteParentType.removeChildResourceType(existingType); moveResourcesToNewParent(existingType, obsoleteParentType, newParentTypes); } @@ -810,7 +813,8 @@ public class ResourceMetadataManagerBean implements ResourceMetadataManagerLocal return (type != null) ? (type.getPlugin() + ":" + type.getName() + "(id=" + type.getId() + ")") : "null"; }
- private void moveResourcesToNewParent(ResourceType existingType, ResourceType obsoleteParentType, Set<ResourceType> newParentTypes) { + private void moveResourcesToNewParent(ResourceType existingType, ResourceType obsoleteParentType, + Set<ResourceType> newParentTypes) { Subject overlord = subjectManager.getOverlord(); ResourceCriteria criteria = new ResourceCriteria(); criteria.addFilterResourceTypeId(existingType.getId()); @@ -818,8 +822,7 @@ public class ResourceMetadataManagerBean implements ResourceMetadataManagerLocal List<Resource> resources = resourceManager.findResourcesByCriteria(overlord, criteria); for (Resource resource : resources) { Resource newParent = null; - newParentTypes: - for (ResourceType newParentType : newParentTypes) { + newParentTypes: for (ResourceType newParentType : newParentTypes) { Resource ancestorResource = resource.getParentResource(); while (ancestorResource != null) { if (ancestorResource.getResourceType().equals(newParentType)) { @@ -846,7 +849,7 @@ public class ResourceMetadataManagerBean implements ResourceMetadataManagerLocal newParent.addChildResource(resource); } else { log.debug("We were unable to move " + resource + " from invalid parent " + resource.getParentResource() - + " to a new valid parent with one of the following types: " + newParentTypes); + + " to a new valid parent with one of the following types: " + newParentTypes); } } }
commit 09963f393cdfd19d2a54d9b6985259a22aa4ecac Author: John Mazzitelli mazz@redhat.com Date: Wed Jul 21 17:34:03 2010 -0400
BZ 614886 three things one, change view check to CONFIG_READ check for resource two, change view check to *group* CONFIG_READ check three, remove getConfiguration from remote interface
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java index 99e2d5a..a691bd1 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java @@ -272,7 +272,7 @@ public class ConfigurationManagerBean implements ConfigurationManagerLocal, Conf throw new NoResultException("Cannot get live configuration for unknown resource [" + resourceId + "]"); }
- if (!authorizationManager.canViewResource(subject, resource.getId())) { + if (!authorizationManager.hasResourcePermission(subject, Permission.CONFIGURE_READ, resource.getId())) { throw new PermissionException("User [" + subject.getName() + "] does not have permission to view resource configuration for [" + resource + "]"); } @@ -1980,7 +1980,7 @@ public class ConfigurationManagerBean implements ConfigurationManagerLocal, Conf GroupResourceConfigurationUpdate update = getGroupResourceConfigurationById(configurationUpdateId);
int groupId = update.getGroup().getId(); - if (authorizationManager.canViewGroup(subject, groupId) == false) { + if (authorizationManager.hasGroupPermission(subject, Permission.CONFIGURE_READ, groupId) == false) { throw new PermissionException("User[" + subject.getName() + "] does not have permission to view group resourceConfiguration[id=" + configurationUpdateId + "]"); } diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerLocal.java index 4242153..6a1c114 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerLocal.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerLocal.java @@ -381,6 +381,8 @@ public interface ConfigurationManagerLocal { */ void checkForTimedOutConfigurationUpdateRequests();
+ public Configuration getConfiguration(Subject subject, int configurationId); + // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // // The following are shared with the Remote Interface @@ -392,8 +394,6 @@ public interface ConfigurationManagerLocal { public GroupResourceConfigurationUpdate getGroupResourceConfigurationUpdate(Subject subject, int configurationUpdateId);
- public Configuration getConfiguration(Subject subject, int configurationId); - /** * Get the current plugin configuration for the {@link Resource} with the given id, or <code>null</code> if the * resource's plugin configuration is not yet initialized. diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerRemote.java index b25fa9d..b4836c6 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerRemote.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerRemote.java @@ -65,11 +65,6 @@ public interface ConfigurationManagerRemote { @WebParam(name = "subject") Subject subject, // @WebParam(name = "configurationUpdateId") int configurationUpdateId);
- @WebMethod - Configuration getConfiguration( // - @WebParam(name = "subject") Subject subject, // - @WebParam(name = "configurationId") int configurationId); - /** * Get the current plugin configuration for the {@link Resource} with the given id, or <code>null</code> if the * resource's plugin configuration is not yet initialized.
rhq-commits@lists.fedorahosted.org