private void excludeThoseWithoutOperations(List<ResourceType> types) { Iterator<ResourceType> iterator = types.iterator(); while (iterator.hasNext()) { ResourceType next = iterator.next(); Set<OperationDefinition> operations = next.getOperationDefinitions(); if (operations == null || operations.isEmpty()) { iterator.remove(); } } }
public static OperationDefinition getOperationDefinition(ResourceType type, String operationName) { for (OperationDefinition operationDefinition : type.getOperationDefinitions()) { if (operationDefinition.getName().equals(operationName)) { return operationDefinition; } } return null; }
@Override public boolean isResourceOperationSupported(Subject subject, int resourceId) { Resource resource; try { resource = getResourceIfAuthorized(subject, resourceId); } catch (PermissionException e) { // notice we caught this exception before propogating it up to the EJB layer, so // our transaction is not rolled back if (LOG.isDebugEnabled()) { LOG.debug("isOperationSupported: User cannot control resource: " + resourceId); } return false; } catch (Exception e) { if (LOG.isDebugEnabled()) { LOG.debug("isOperationSupported: Resource does not exist: " + resourceId); } return false; } Set<OperationDefinition> defs = resource.getResourceType().getOperationDefinitions(); return (defs != null) && (defs.size() > 0); }
private OperationContext getOperationContext(Resource resource) { if (resource.getResourceType().getOperationDefinitions() == null || resource.getResourceType().getOperationDefinitions().isEmpty()) { return null; } if (resource.getId() == 0) { log.info("Resource ID is 0! Operation features will not work until the resource is synced with server"); } return new OperationContextImpl(resource.getId(), operationManager); }
/** * Return the parameter definition for the operation with the name passed * @param operationName Name of the operation to look for * @return A configuration definition or null on failure */ ConfigurationDefinition getParameterDefinitionsForOperation(String operationName) { ResourceType type = context.getResourceType(); Set<OperationDefinition> operationDefinitions = type.getOperationDefinitions(); for (OperationDefinition definition : operationDefinitions) { if (definition.getName().equals(operationName)) { return definition.getParametersConfigurationDefinition(); } } return null; }
/** * Returns the operation definition for the operation with the specified name on the * {@link org.rhq.core.domain.resource.Resource} with the specified id. * * @param resourceId a <code>Resource</code> id * @param operationName an operation name * * @return the operation definition for the operation with the specified name on the <code>Resource</code> with the * specified id * * @throws PluginContainerException if the resource type could not be determined for the specified <code> * Resource</code> id */ @Nullable private OperationDefinition getOperationDefinition(int resourceId, String operationName) throws PluginContainerException { ResourceType resourceType = getResourceType(resourceId); Set<OperationDefinition> operationDefinitions = resourceType.getOperationDefinitions(); if (operationDefinitions != null) { for (OperationDefinition operationDefinition : operationDefinitions) { if (operationDefinition.getName().equals(operationName)) { return operationDefinition; } } } return null; }
@Override public boolean isGroupOperationSupported(Subject subject, int resourceGroupId) { ResourceGroup group; try { group = resourceGroupManager.getResourceGroupById(subject, resourceGroupId, null); if (group.getGroupCategory() == GroupCategory.MIXED) { return false; } } catch (ResourceGroupNotFoundException e) { if (LOG.isDebugEnabled()) { LOG.debug("isGroupOperationSupported: group does not exist: " + resourceGroupId); } return false; } catch (PermissionException pe) { // notice we caught this exception before propogating it up to the EJB layer, so // our transaction is not rolled back if (LOG.isDebugEnabled()) { LOG.debug("isGroupOperationSupported: User cannot view (and thus) control group: " + resourceGroupId); } return false; } if (!authorizationManager.hasGroupPermission(subject, Permission.CONTROL, group.getId())) { if (LOG.isDebugEnabled()) { LOG.debug("isGroupOperationSupported: User cannot control group: " + group); } return false; } Set<OperationDefinition> defs = group.getResourceType().getOperationDefinitions(); return (defs != null) && (defs.size() > 0); }
private OperationDefinition validateOperationNameAndParameters(ResourceType resourceType, String operationName, Configuration parameters) { Set<OperationDefinition> operationDefinitions = resourceType.getOperationDefinitions(); OperationDefinition matchingOperationDefinition = null; for (OperationDefinition operationDefinition : operationDefinitions) { if (operationDefinition.getName().equals(operationName)) { matchingOperationDefinition = operationDefinition; break; } } if (matchingOperationDefinition == null) { throw new IllegalArgumentException("[" + operationName + "] is not a valid operation name for Resources of type [" + resourceType.getName() + "]."); } ConfigurationDefinition parametersDefinition = matchingOperationDefinition .getParametersConfigurationDefinition(); List<String> errors = ConfigurationUtility.validateConfiguration(parameters, parametersDefinition); if (!errors.isEmpty()) { throw new IllegalArgumentException("Parameters for [" + operationName + "] on Resource of type [" + resourceType.getName() + "] are not valid: " + errors); } return matchingOperationDefinition; }
if (resourceType.getOperationDefinitions() != null) { for (OperationDefinition def : resourceType.getOperationDefinitions()) { exportWriter.printf("%s <operation>%s</operation>\n", indent, def.getName());
Set<OperationDefinition> existingDefinitions = existingType.getOperationDefinitions(); Set<OperationDefinition> newDefinitions = newType.getOperationDefinitions();
if (builder==null) { Set<OperationDefinition> opDefList = resourceType.getOperationDefinitions(); List<OperationDefinitionRest> resultList = new ArrayList<OperationDefinitionRest>(opDefList.size());
if (operation.equals("-list")) { ResourceType rt = getTypeForResourceId(); Set<OperationDefinition> opDefs = rt.getOperationDefinitions(); for (OperationDefinition def : opDefs) { System.out.println(def.getName() + " : " + def.getDescription());
+ "] does not support the measurement collection facet but defines metrics."); if (!resourceType.getOperationDefinitions().isEmpty() && !OperationFacet.class.isAssignableFrom(componentClazz)) { success = false;