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 GroupRestService method deleteGroup.
@DELETE
@Path("{groupName}")
public Response deleteGroup(@PathParam("groupName") final String groupName) {
writeLock();
try {
final OnmsGroup group = getOnmsGroup(groupName);
LOG.debug("deleteGroup: deleting group {}", group);
m_groupService.deleteGroup(groupName);
return Response.noContent().build();
} finally {
writeUnlock();
}
}
use of javax.ws.rs.DELETE in project opennms by OpenNMS.
the class GroupRestService method removeUser.
@DELETE
@Path("{groupName}/users/{userName}")
public Response removeUser(@PathParam("groupName") final String groupName, @PathParam("userName") final String userName) {
writeLock();
try {
final OnmsGroup group = getOnmsGroup(groupName);
if (group.getUsers().contains(userName)) {
group.removeUser(userName);
m_groupService.saveGroup(group);
return Response.noContent().build();
} else {
throw getException(Status.BAD_REQUEST, "User with name '{}' does not exist in group '{}'", userName, groupName);
}
} 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 removeCategoryFromNode.
@DELETE
@Path("/{nodeCriteria}/categories/{categoryName}")
public Response removeCategoryFromNode(@PathParam("nodeCriteria") String nodeCriteria, @PathParam("categoryName") String categoryName) {
writeLock();
try {
OnmsNode node = m_nodeDao.get(nodeCriteria);
if (node == null) {
throw getException(Status.BAD_REQUEST, "Node {} was not found.", nodeCriteria);
}
OnmsCategory category = getCategory(node, categoryName);
if (category == null) {
throw getException(Status.BAD_REQUEST, "Category {} not found on node {}", categoryName, nodeCriteria);
}
LOG.debug("deleteCaegory: deleting category {} from node {}", categoryName, nodeCriteria);
node.getCategories().remove(category);
m_nodeDao.saveOrUpdate(node);
return Response.noContent().build();
} finally {
writeUnlock();
}
}
Aggregations