use of org.opennms.netmgt.model.OnmsCategory in project opennms by OpenNMS.
the class NodeRestService method getCategoryForNode.
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{nodeCriteria}/categories/{categoryName}")
public OnmsCategory getCategoryForNode(@PathParam("nodeCriteria") String nodeCriteria, @PathParam("categoryName") String categoryName) {
OnmsNode node = m_nodeDao.get(nodeCriteria);
if (node == null) {
throw getException(Status.BAD_REQUEST, "Node {} was not found.", nodeCriteria);
}
final OnmsCategory cat = getCategory(node, categoryName);
if (cat == null) {
throw getException(Status.NOT_FOUND, "Can't find category {} for node {}.", categoryName, nodeCriteria);
}
return cat;
}
use of org.opennms.netmgt.model.OnmsCategory in project opennms by OpenNMS.
the class DefaultGroupService method getAuthorizedCategoriesAsString.
@Override
public List<String> getAuthorizedCategoriesAsString(String groupName) {
List<OnmsCategory> categories = getAuthorizedCategories(groupName);
List<String> categoryNames = new ArrayList<String>(categories.size());
for (OnmsCategory category : categories) {
categoryNames.add(category.getName());
}
return categoryNames;
}
use of org.opennms.netmgt.model.OnmsCategory in project opennms by OpenNMS.
the class DefaultSiteStatusServiceIT method createOutageForNodeInCategory.
private void createOutageForNodeInCategory(String categoryName) {
OnmsCategory category = m_categoryDao.findByName(categoryName);
Collection<OnmsNode> nodes = m_nodeDao.findByCategory(category);
assertNotNull(nodes);
assertFalse(nodes.isEmpty());
/*
* There should only be 1 node per category based on the set of
* default nodes that are stored in {@link DatabasePopulator}
*/
assertEquals(1, nodes.size());
OnmsNode node = nodes.iterator().next();
node.visit(new AbstractEntityVisitor() {
@Override
public void visitMonitoredService(OnmsMonitoredService monSvc) {
createOutageForService(monSvc);
}
});
}
Aggregations