use of org.opennms.web.category.Category in project opennms by OpenNMS.
the class AvailabilityRestService method getCategory.
@GET
@Path("/categories/{category}")
public Category getCategory(@PathParam("category") final String categoryName) {
try {
final String category = URLDecoder.decode(categoryName, StandardCharsets.UTF_8.name());
final Category cat = CategoryModel.getInstance().getCategory(category);
if (cat == null) {
throw getException(Status.NOT_FOUND, "Category {} was not found.", categoryName);
}
return cat;
} catch (final IOException e) {
LOG.warn("Failed to get availability data for category {}: {}", categoryName, e.getMessage(), e);
throw getException(Status.INTERNAL_SERVER_ERROR, "Failed to get availability data for category {} : {}", categoryName, e.getMessage());
}
}
use of org.opennms.web.category.Category in project opennms by OpenNMS.
the class AvailabilityRestService method getCategoryNode.
@GET
@Path("/categories/{category}/nodes/{nodeId}")
public AvailabilityNode getCategoryNode(@PathParam("category") final String categoryName, @PathParam("nodeId") final Long nodeId) {
try {
final String category = URLDecoder.decode(categoryName, StandardCharsets.UTF_8.name());
final Category cat = CategoryModel.getInstance().getCategory(category);
if (cat == null) {
throw getException(Status.NOT_FOUND, "Category {} was not found.", categoryName);
}
final AvailabilityNode node = cat.getNode(nodeId);
if (node == null) {
throw getException(Status.NOT_FOUND, "Node {} was not found for category {}.", Long.toString(nodeId), categoryName);
}
return getAvailabilityNode(node.getId().intValue());
} catch (final Exception e) {
LOG.warn("Failed to get availability data for category {}: {}", categoryName, e.getMessage(), e);
throw getException(Status.INTERNAL_SERVER_ERROR, "Failed to get availability data for category {} : {}", categoryName, e.getMessage());
}
}
use of org.opennms.web.category.Category in project opennms by OpenNMS.
the class AvailabilityRestService method getCategoryNodes.
@GET
@Path("/categories/{category}/nodes")
public NodeList getCategoryNodes(@PathParam("category") final String categoryName) {
try {
final String category = URLDecoder.decode(categoryName, StandardCharsets.UTF_8.name());
final Category cat = CategoryModel.getInstance().getCategory(category);
if (cat == null) {
throw getException(Status.NOT_FOUND, "Category {} was not found.", categoryName);
}
return cat.getNodes();
} catch (final IOException e) {
LOG.warn("Failed to get availability data for category {}: {}", categoryName, e.getMessage(), e);
throw getException(Status.INTERNAL_SERVER_ERROR, "Failed to get availability data for category {} : {}", categoryName, e.getMessage());
}
}
Aggregations