/** * Takes a list of castor generated MibObj objects iterates over them creating corresponding * MibObject objects and adding them to the supplied MibObject list. * * @param groupName TODO * @param groupIfType TODO * @param objectList List of MibObject objects parsed from 'datacollection-config.xml' * @param mibObjectList List of MibObject objects currently being built */ private void processObjectList( final String groupName, final String groupIfType, final List<MibObj> objectList, final List<MibObject> mibObjectList) { for (final MibObj mibObj : objectList) { // Create a MibObject from the castor MibObj final MibObject aMibObject = new MibObject(); aMibObject.setGroupName(groupName); aMibObject.setGroupIfType(groupIfType); aMibObject.setOid(mibObj.getOid()); aMibObject.setAlias(mibObj.getAlias()); aMibObject.setType(mibObj.getType()); aMibObject.setInstance(mibObj.getInstance()); aMibObject.setMaxval(mibObj.getMaxval()); aMibObject.setMinval(mibObj.getMinval()); final ResourceType resourceType = getConfiguredResourceTypes().get(mibObj.getInstance()); if (resourceType != null) { aMibObject.setResourceType(resourceType); } // Add the MIB object provided it isn't already in the list if (!mibObjectList.contains(aMibObject)) { mibObjectList.add(aMibObject); } } }
private static void validateResourceTypes( final FileReloadContainer<DatacollectionConfig> container, final Set<String> allowedResourceTypes) { final String configuredString; if (allowedResourceTypes.size() == 0) { configuredString = "(none)"; } else { configuredString = StringUtils.join(allowedResourceTypes, ", "); } final String allowableValues = "any positive number, 'ifIndex', or any of the configured resourceTypes: " + configuredString; for (final SnmpCollection collection : container.getObject().getSnmpCollectionCollection()) { final Groups groups = collection.getGroups(); if (groups != null) { for (final Group group : groups.getGroupCollection()) { for (final MibObj mibObj : group.getMibObjCollection()) { final String instance = mibObj.getInstance(); if (instance == null) continue; if (MibObject.INSTANCE_IFINDEX.equals(instance)) continue; if (allowedResourceTypes.contains(instance)) continue; try { // Check to see if the value is a non-negative integer if (Integer.parseInt(instance.trim()) >= 0) { continue; } } catch (NumberFormatException e) { } // XXX this should be a better exception throw new IllegalArgumentException( "instance '" + instance + "' invalid in mibObj definition for OID '" + mibObj.getOid() + "' in collection '" + collection.getName() + "' for group '" + group.getName() + "'. Allowable instance values: " + allowableValues); } } } } }