Search in sources :

Example 1 with OnmsEntity

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();
    }
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) OnmsEntity(org.opennms.netmgt.model.OnmsEntity) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE)

Aggregations

DELETE (javax.ws.rs.DELETE)1 Path (javax.ws.rs.Path)1 OnmsEntity (org.opennms.netmgt.model.OnmsEntity)1 OnmsNode (org.opennms.netmgt.model.OnmsNode)1