use of org.opennms.netmgt.model.OnmsEntity in project opennms by OpenNMS.
the class OnmsSnmpInterfaceResource method deleteSnmpInterface.
/**
* <p>deleteSnmpInterface</p>
*
* @param nodeCriteria a {@link java.lang.String} object.
* @param ifIndex a int.
* @return a {@link javax.ws.rs.core.Response} object.
*/
@DELETE
@Path("{ifIndex}")
public Response deleteSnmpInterface(@PathParam("nodeCriteria") final String nodeCriteria, @PathParam("ifIndex") final int ifIndex) {
writeLock();
try {
final OnmsNode node = m_nodeDao.get(nodeCriteria);
if (node == null)
throw getException(Status.BAD_REQUEST, "Node {} was not found.", nodeCriteria);
final OnmsEntity snmpInterface = node.getSnmpInterfaceWithIfIndex(ifIndex);
if (snmpInterface == null)
throw getException(Status.BAD_REQUEST, "Can't find SNMP interface with ifIndex {} for node {}", Integer.toString(ifIndex), nodeCriteria);
LOG.debug("deletSnmpInterface: deleting interface with ifIndex {} from node {}", ifIndex, nodeCriteria);
node.getSnmpInterfaces().remove(snmpInterface);
m_nodeDao.saveOrUpdate(node);
// TODO Add important events here
return Response.noContent().build();
} finally {
writeUnlock();
}
}
Aggregations