use of javax.ws.rs.DELETE in project opennms by OpenNMS.
the class ForeignSourceRestService method deletePendingForeignSource.
/**
* <p>deletePendingForeignSource</p>
*
* @param foreignSource a {@link java.lang.String} object.
* @return a {@link javax.ws.rs.core.Response} object.
*/
@DELETE
@Path("{foreignSource}")
@Transactional
public Response deletePendingForeignSource(@PathParam("foreignSource") final String foreignSource) {
writeLock();
try {
ForeignSource fs = getForeignSource(foreignSource);
LOG.debug("deletePendingForeignSource: deleting foreign source {}", foreignSource);
m_pendingForeignSourceRepository.delete(fs);
return Response.accepted().build();
} finally {
writeUnlock();
}
}
use of javax.ws.rs.DELETE in project opennms by OpenNMS.
the class ForeignSourceRestService method deleteDeployedForeignSource.
/**
* <p>deleteDeployedForeignSource</p>
*
* @param foreignSource a {@link java.lang.String} object.
* @return a {@link javax.ws.rs.core.Response} object.
*/
@DELETE
@Path("deployed/{foreignSource}")
@Transactional
public Response deleteDeployedForeignSource(@PathParam("foreignSource") final String foreignSource) {
writeLock();
try {
ForeignSource fs = getForeignSource(foreignSource);
LOG.debug("deleteDeployedForeignSource: deleting foreign source {}", foreignSource);
if ("default".equals(foreignSource)) {
m_deployedForeignSourceRepository.resetDefaultForeignSource();
} else {
m_deployedForeignSourceRepository.delete(fs);
}
return Response.accepted().build();
} finally {
writeUnlock();
}
}
use of javax.ws.rs.DELETE in project opennms by OpenNMS.
the class NodeRestService method deleteNode.
/**
* <p>deleteNode</p>
*
* @param nodeCriteria a {@link java.lang.String} object.
* @return a {@link javax.ws.rs.core.Response} object.
*/
@DELETE
@Path("{nodeCriteria}")
public Response deleteNode(@PathParam("nodeCriteria") final String nodeCriteria) {
writeLock();
try {
final OnmsNode node = m_nodeDao.get(nodeCriteria);
if (node == null)
throw getException(Status.BAD_REQUEST, "Node {} was not found.", nodeCriteria);
LOG.debug("deleteNode: deleting node {}", nodeCriteria);
Event e = EventUtils.createDeleteNodeEvent("OpenNMS.REST", node.getId(), -1L);
sendEvent(e);
return Response.noContent().build();
} finally {
writeUnlock();
}
}
use of javax.ws.rs.DELETE in project opennms by OpenNMS.
the class OnmsMonitoredServiceResource method deleteService.
/**
* <p>deleteService</p>
*
* @param nodeCriteria a {@link java.lang.String} object.
* @param ipAddress a {@link java.lang.String} object.
* @param serviceName a {@link java.lang.String} object.
* @return a {@link javax.ws.rs.core.Response} object.
*/
@DELETE
@Path("{service}")
public Response deleteService(@PathParam("nodeCriteria") final String nodeCriteria, @PathParam("ipAddress") final String ipAddress, @PathParam("service") final String serviceName) {
writeLock();
try {
OnmsNode node = m_nodeDao.get(nodeCriteria);
if (node == null)
throw getException(Status.BAD_REQUEST, "Node {} was not found.", nodeCriteria);
OnmsIpInterface intf = node.getIpInterfaceByIpAddress(ipAddress);
if (intf == null)
throw getException(Status.BAD_REQUEST, "IP Interface {} was not found on node {}.", ipAddress, nodeCriteria);
OnmsMonitoredService service = intf.getMonitoredServiceByServiceType(serviceName);
if (service == null)
throw getException(Status.CONFLICT, "Monitored Service {} was not found on IP Interface {} and node {}.", serviceName, ipAddress, nodeCriteria);
LOG.debug("deleteService: deleting service {} from node {}", serviceName, nodeCriteria);
Event e = EventUtils.createDeleteServiceEvent("OpenNMS.REST", node.getId(), ipAddress, serviceName, -1L);
sendEvent(e);
return Response.noContent().build();
} finally {
writeUnlock();
}
}
use of javax.ws.rs.DELETE 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