@Override public boolean equals(Object obj) { if (this == obj) { return true; } if ((obj == null) || !(obj instanceof OperationDefinition)) { return false; } OperationDefinition that = (OperationDefinition) obj; return this.name.equals(that.name) && this.resourceType.equals(that.resourceType); }
@Override public boolean equals(Object other) { if (other == this) { return true; } if (!(other instanceof Children)) { return false; } Children o = (Children) other; return (parentResourceUuid == null ? o.parentResourceUuid == null : parentResourceUuid .equals(o.parentResourceUuid)) && resourceType.equals(o.resourceType); } }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (!(o instanceof ProductVersion)) { return false; } ProductVersion that = (ProductVersion) o; if (!resourceType.equals(that.resourceType)) { return false; } if (!version.equals(that.version)) { return false; } return true; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null || !(obj instanceof EventDefinition)) return false; EventDefinition that = (EventDefinition) obj; if ((resourceType != null) ? (!resourceType.equals(that.resourceType)) : (that.resourceType != null)) { return false; } if ((name != null ? (!name.equals(that.name)) : (that.name != null))) { return false; } if (id != 0 && that.id != 0 && id != that.id) { return false; } return true; }
@Override public boolean equals(Object o) { if (this == o) { return true; } if ((o == null) || (!(o instanceof MeasurementDefinition))) { return false; } MeasurementDefinition that = (MeasurementDefinition) o; if (!name.equals(that.name)) { return false; } if ((resourceType != null) ? (!resourceType.equals(that.resourceType)) : (that.resourceType != null)) { return false; } if (rawNumericType != that.rawNumericType) { return false; } return true; }
/** * Equality for drift templates is defined as having the same resource type and the * same name. * * @param o The object against which to compare * @return True if the arugment is a DriftDefinitionTemplate and has the same resource * type and name as this template. */ @Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof DriftDefinitionTemplate)) return false; DriftDefinitionTemplate that = (DriftDefinitionTemplate) o; if (name != null ? !name.equals(that.name) : that.name != null) return false; if (resourceType != null ? !resourceType.equals(that.resourceType) : that.resourceType != null) return false; return true; }
return false; } else if (!resourceType.equals(other.resourceType)) { return false;
@Override public boolean equals(Object o) { if (this == o) { return true; } if ((o == null) || (getClass() != o.getClass())) { return false; } DiscoveredResourceDetails that = (DiscoveredResourceDetails) o; if (!resourceKey.equals(that.resourceKey)) { return false; } if (!resourceType.equals(that.resourceType)) { return false; } return true; }
/** * Returns the Resource type with the specified name and plugin, or null if no such Resource type exists. * * @param resourceTypeName the Resource type name * @param pluginName the name of the plugin that defines the Resource type * * @return the Resource type with the specified name and plugin, or null if no such Resource type exists */ @Nullable public ResourceType getType(String resourceTypeName, String pluginName) { ResourceType searchType = new ResourceType(resourceTypeName, pluginName, null, null); synchronized (this.typesLock) { for (ResourceType type : types) { if (type.equals(searchType)) { return type; } } } return null; }
@Override public boolean accept(Resource resource) { return (resource.getResourceType().equals(resourceType) && resource.getResourceKey().equals(resourceKey)); }
@Nullable public ResourceType getType(ResourceType resourceType) { if (TEST_PLATFORM_TYPE.equals(resourceType)) { return TEST_PLATFORM_TYPE; } return getType(resourceType.getName(), resourceType.getPlugin()); }
public static Resource getChildResource(Resource parent, ResourceType type, String key) { for (Resource resource : parent.getChildResources()) { if (resource.getResourceType().equals(type) && resource.getResourceKey().equals(key)) { return resource; } } return null; }
private void removeStaleResources(Resource parent, ResourceType childResourceType, Map<String, Resource> mergedResources) { Set<Resource> existingChildResources = parent.getChildResources(); for (Resource existingChildResource : existingChildResources) { // NOTE: If inside Agent, only remove Resources w/ id == 0. Other Resources may still exist in the // the Server's inventory. if (existingChildResource.getResourceType().equals(childResourceType) && !mergedResources.containsKey(existingChildResource.getUuid()) && (existingChildResource.getId() == 0 || !this.pluginContainerConfiguration.isInsideAgent())) { log.info("Removing stale resource [" + existingChildResource + "]"); this.inventoryManager.removeResourceAndIndicateIfScanIsNeeded(existingChildResource, true); } } } }
private boolean matches(Resource newResource, Resource existingResource) { try { return ((existingResource.getId() != 0) && (existingResource.getId() == newResource.getId())) || (existingResource.getUuid().equals(newResource.getUuid())) || (existingResource.getResourceType().equals(newResource.getResourceType()) && existingResource .getResourceKey().equals(newResource.getResourceKey())); } catch (RuntimeException e) { log.error("Runtime error while attempting to compare existing Resource " + existingResource + " to new Resource " + newResource); throw e; } }
private void validateTemplateForNewDef(DriftDefinition driftDef, Resource resource) { if (driftDef.getTemplate() == null) { return; } DriftDefinitionTemplate template = entityManager.find(DriftDefinitionTemplate.class, driftDef.getTemplate().getId()); if (template == null) { throw new IllegalArgumentException("Cannot create drift definition with template " + DriftDefinitionTemplate.class.getSimpleName() + "[" + driftDef.getTemplate().getName() + "] that has not been saved"); } if (!template.getResourceType().equals(resource.getResourceType())) { throw new IllegalArgumentException("Cannot create drift definition with template " + DriftDefinitionTemplate.class.getSimpleName() + "[" + driftDef.getTemplate().getName() + "] that is from a different resource type, " + template.getResourceType()); } }
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; }
if (!res.getResourceType().equals(resourceGroup.getResourceType())) { Response.ResponseBuilder status = Response.status(Response.Status.CONFLICT); status.type(mediaType);
private Set<Resource> getResourcesWithType(ResourceType type, Set<Resource> resources) { Set<Resource> result = new HashSet<Resource>(); if (resources == null) { return result; } for (Resource resource : resources) { // If we're looking for SERVERs and we've hit a SERVICE, skip it as it doesn't match and // we won't find SERVERs below a SERVICE if (ResourceCategory.SERVER == type.getCategory() && ResourceCategory.SERVICE == resource.getResourceType().getCategory()) { continue; } Set<Resource> children = getContainerChildren(resource); result.addAll(getResourcesWithType(type, children)); if (type.equals(resource.getResourceType())) { ResourceContainer container = getResourceContainer(resource); result.add((container == null) ? resource : container.getResource()); } } return result; }
private Resource getDiscoveredResource() { ResourceContainer parentResourceContainer = inventoryManager.getResourceContainer(parentResourceId); Resource parentResource = parentResourceContainer.getResource(); for (Resource childResource : parentResource.getChildResources()) { if (childResource.getResourceType().equals(report.getResourceType()) && childResource.getResourceKey().equals(report.getResourceKey())) { return childResource; } } return null; }
if (resourceType.equals(PluginMetadataManager.TEST_PLATFORM_TYPE)) { return Thread.currentThread().getContextClassLoader();