private void updateImplicitMembership(Subject subject, Resource resource) { /* * if this is a new root resource, it could not have been a member of some group - explicitly or implicitly */ if (resource.getParentResource() == null) { return; } groupManager.updateImplicitGroupMembership(subject, resource); }
private void rememberFailure(Resource resource) { failedResources.add(resource); Resource parentResource = resource.getParentResource(); Set<ResourceType> failedResourceTypesInParent = failedResourceTypesPerParent.get(parentResource); if (failedResourceTypesInParent == null) { failedResourceTypesInParent = new HashSet<ResourceType>(); failedResourceTypesPerParent.put(parentResource, failedResourceTypesInParent); } failedResourceTypesInParent.add(resource.getResourceType()); }
@Override @Nullable public Resource getParentResource(int resourceId) { Resource resource = entityManager.find(Resource.class, resourceId); if (resource == null) { throw new ResourceNotFoundException(resourceId); } Resource parent = resource.getParentResource(); if (parent != null) { parent.getId(); // Important: This ensures Hibernate actually populates parent's fields. } return parent; }
@Override public Resource getResourceTree(int rootResourceId, boolean recursive) { Subject overlord = subjectManager.getOverlord(); Resource root = getResourceById(overlord, rootResourceId); if (root != null) { prefetchResource(root, recursive); // load the parent - note we only load the root resource's parent if (root.getParentResource() != null) { root.getParentResource().getId(); } } return root; }
/** * Returns the base server or service of the specified <code>resource</code>. * * @param resource * @return the base server or service of the specified <code>resource</code>. * @throws IllegalArgumentException if <code>resource</code> is null */ public static Resource getBaseServerOrService(Resource resource) { if (resource == null) { throw new IllegalArgumentException("resource is null"); } Resource current, parent = resource; do { current = parent; parent = current.getParentResource(); } while (parent != null && parent.getResourceType().getCategory() != PLATFORM); return current; }
@Nullable public ResourceContainer getResourceContainer(CanonicalResourceKey canonicalId) { ResourceContainer resourceContainer = null; for (Map.Entry<String, ResourceContainer> entry : resourceContainersByUUID.entrySet()) { ResourceContainer container = entry.getValue(); Resource resource = container.getResource(); if (resource != null) { Resource parent = resource.getParentResource(); if (parent != null) { try { CanonicalResourceKey currentCanonicalId = new CanonicalResourceKey(resource, parent); if (currentCanonicalId.equals(canonicalId)) { resourceContainer = container; break; } } catch (PluginContainerException ignore) { // TODO not sure what to do here, when would this ever happen? for now, ignore } } } } return resourceContainer; }
currentResourceId = resourceId; while (!resourceIdToStorageNodeMap.containsKey(currentResourceId)) { currentResourceId = entityManager.find(Resource.class, currentResourceId).getParentResource() .getId();
Resource parentResource = this.getParentResource();
private Set<Resource> findDuplicitSiblingResources(Resource resource, ResourceUpgradeReport upgradeReport) { Resource parent = resource.getParentResource(); if (parent == null) { //there is only a single platform resource on an agent return Collections.emptySet(); } Set<Resource> ret = new HashSet<Resource>(); for (Resource sibling : parent.getChildResources()) { //we'd have a resource key conflict if there was a resource //of the same type under the same parent that would have the same //resource key. if (upgradeReport.getNewResourceKey() != null && sibling.getResourceType().equals(resource.getResourceType()) && !sibling.getUuid().equals(resource.getUuid())) { if (sibling.getResourceKey().equals(upgradeReport.getNewResourceKey())) { ret.add(sibling); } } } return ret; }
public CanonicalResourceKey(Resource resource, Resource parent) throws PluginContainerException { if (resource == null) { throw new PluginContainerException("resource must not be null"); } if (parent == null) { throw new PluginContainerException("parent must not be null"); } this.resourceKeyTypePlugin = new KeyTypePlugin(resource.getResourceKey(), resource.getResourceType()); this.ancestorKeyTypePlugins = new ArrayList<KeyTypePlugin>(5); while (parent != null) { KeyTypePlugin ktp = new KeyTypePlugin(parent.getResourceKey(), parent.getResourceType()); this.ancestorKeyTypePlugins.add(ktp); parent = parent.getParentResource(); } }
if (null == resource.getParentResource()) { LOG.info("Enabling a platform is not allowed, skipping platform resource with id [" + resourceId + "]"); continue;
if ((resource.getParentResource() != null) && (resource.getParentResource().getInventoryStatus() != InventoryStatus.COMMITTED)) { throw new IllegalStateException("Cannot commit resource [" + resource + "] to inventory, because its parent resource [" + resource.getParentResource() + "] has not yet been committed.");
child.getParentResource().getId();
private void prefetchResource(Resource resource, boolean recursive) { if (resource == null) { return; // Nothing to do on invalid input } resource.getId(); resource.getPluginConfiguration().getNotes(); // Initialize the lazy plugin config // Init the lazy parent... // Don't fetch the parent's children, otherwise we'll end up in infinite recursion. prefetchResource(resource.getParentResource(), false); if (recursive) { // Recurse... for (Resource child : resource.getChildResources()) { prefetchResource(child, true); } } }
if (!platforms.contains(server.getParentResource())) { AgentClient agentClient = agentManager.getAgentClient(server.getAgent()); if (agentClient != null) {
Resource parentResource = resource.getParentResource(); ResourceContainer parentContainer;
rwt.setDescription(res.getDescription()); rwt.setAvailability(res.getCurrentAvailability().getAvailabilityType().toString()); Resource parent = res.getParentResource(); if (parent != null) { rwt.setParentId(parent.getId());
Resource parentResource = this.resourceManager.getResourceById(creator, resource.getParentResource() .getId()); resource.setAgent(parentResource.getAgent());
/** * @see #constructResource(int, String, String, String, Integer, int, AvailabilityType) * * @param original the resource * @return the initialized resource flyweight */ public ResourceFlyweight constructResource(Resource original) { int id = original.getId(); String name = original.getName(); String uuid = original.getUuid(); String resourceKey = original.getResourceKey(); Resource parent = original.getParentResource(); ResourceType type = original.getResourceType(); ResourceAvailability avail = original.getCurrentAvailability(); return constructResource(id, name, uuid, resourceKey, parent != null ? parent.getId() : null, type.getId(), avail != null ? avail.getAvailabilityType() : AvailabilityType.UNKNOWN); }
private static Resource convertToPojoResource(Resource resource, boolean includeDescendants) { Resource pojoResource = new Resource(resource.getId()); pojoResource.setUuid(resource.getUuid()); pojoResource.setResourceKey(resource.getResourceKey()); pojoResource.setResourceType(resource.getResourceType()); pojoResource.setMtime(resource.getMtime()); pojoResource.setInventoryStatus(resource.getInventoryStatus()); Configuration pcCopy = resource.getPluginConfiguration(); if (pcCopy != null) { pcCopy = pcCopy.deepCopy(); } pojoResource.setPluginConfiguration(pcCopy); pojoResource.setName(resource.getName()); pojoResource.setDescription(resource.getDescription()); pojoResource.setLocation(resource.getLocation()); pojoResource.setVersion(resource.getVersion()); if (resource.getParentResource() != null) { pojoResource.setParentResource(convertToPojoResource(resource.getParentResource(), false)); } if (includeDescendants) { for (Resource childResource : resource.getChildResources()) { if (isVisibleInInventory(childResource)) { pojoResource.addChildResource(convertToPojoResource(childResource, true)); } } } return pojoResource; }