use of javax.ws.rs.DELETE in project iaf by ibissource.
the class ShowScheduler method PutSchedules.
@DELETE
@RolesAllowed({ "IbisDataAdmin", "IbisAdmin", "IbisTester" })
@Path("/schedules/{groupName}/{jobName}")
@Relation("schedules")
@Produces(MediaType.APPLICATION_JSON)
public Response PutSchedules(@PathParam("jobName") String jobName, @QueryParam("groupName") String groupName) throws ApiException {
initBase(servletConfig);
DefaultIbisManager manager = (DefaultIbisManager) ibisManager;
SchedulerHelper sh = manager.getSchedulerHelper();
Scheduler scheduler;
try {
scheduler = sh.getScheduler();
} catch (SchedulerException e) {
throw new ApiException("Cannot find scheduler");
}
try {
String commandIssuedBy = servletConfig.getInitParameter("remoteHost");
commandIssuedBy += servletConfig.getInitParameter("remoteAddress");
commandIssuedBy += servletConfig.getInitParameter("remoteUser");
log.info("delete job jobName [" + jobName + "] groupName [" + groupName + "] " + commandIssuedBy);
scheduler.deleteJob(jobName, groupName);
} catch (Exception e) {
throw new ApiException("Failed to delete job");
}
return Response.status(Response.Status.OK).build();
}
use of javax.ws.rs.DELETE in project iaf by ibissource.
the class Init method getAllResources.
@GET
@PermitAll
@Path("/")
@Produces(MediaType.APPLICATION_JSON)
public Response getAllResources(@QueryParam("allowedRoles") boolean displayAllowedRoles) {
List<Object> JSONresources = new ArrayList<Object>();
Map<String, Object> HALresources = new HashMap<String, Object>();
Map<String, Object> resources = new HashMap<String, Object>(1);
ResourceMethodRegistry registry = (ResourceMethodRegistry) dispatcher.getRegistry();
StringBuffer requestPath = httpServletRequest.getRequestURL();
if (requestPath.substring(requestPath.length() - 1).equals("/"))
requestPath.setLength(requestPath.length() - 1);
for (Map.Entry<String, List<ResourceInvoker>> entry : registry.getBounded().entrySet()) {
for (ResourceInvoker invoker : entry.getValue()) {
Method method = invoker.getMethod();
String relation = null;
if (method.getDeclaringClass() == getClass()) {
continue;
}
if (method.getDeclaringClass().getName().endsWith("ShowMonitors") && !AppConstants.getInstance().getBoolean("monitoring.enabled", false)) {
continue;
}
Map<String, Object> resource = new HashMap<String, Object>(4);
if (method.isAnnotationPresent(GET.class))
resource.put("type", "GET");
else if (method.isAnnotationPresent(POST.class))
resource.put("type", "POST");
else if (method.isAnnotationPresent(PUT.class))
resource.put("type", "PUT");
else if (method.isAnnotationPresent(DELETE.class))
resource.put("type", "DELETE");
Path path = method.getAnnotation(Path.class);
if (path != null) {
String p = path.value();
if (!p.startsWith("/"))
p = "/" + p;
resource.put("href", requestPath + p);
}
RolesAllowed rolesAllowed = method.getAnnotation(RolesAllowed.class);
if (rolesAllowed != null && displayAllowedRoles) {
resource.put("allowed", rolesAllowed.value());
}
if ((HATEOASImplementation.equalsIgnoreCase("hal"))) {
if (method.isAnnotationPresent(Relation.class))
relation = method.getAnnotation(Relation.class).value();
if (relation != null) {
if (HALresources.containsKey(relation)) {
Object prevRelation = HALresources.get(relation);
List<Object> tmpList = null;
if (prevRelation instanceof List)
tmpList = (List) prevRelation;
else {
tmpList = new ArrayList<Object>();
tmpList.add(prevRelation);
}
tmpList.add(resource);
HALresources.put(relation, tmpList);
} else
HALresources.put(relation, resource);
}
} else {
if (method.isAnnotationPresent(Relation.class))
resource.put("rel", method.getAnnotation(Relation.class).value());
JSONresources.add(resource);
}
}
}
if ((HATEOASImplementation.equalsIgnoreCase("hal")))
resources.put(ResourceKey, HALresources);
else
resources.put(ResourceKey, JSONresources);
return Response.status(Response.Status.CREATED).entity(resources).build();
}
use of javax.ws.rs.DELETE in project habot by ghys.
the class HABotResource method unsetCardBookmark.
@DELETE
@Path("/cards/{cardUID}/bookmark")
@ApiOperation(value = "Removes the bookmark on a card.")
@ApiResponses(value = { @ApiResponse(code = 200, message = "OK"), @ApiResponse(code = 404, message = "The card with the provided UID doesn't exist"), @ApiResponse(code = 500, message = "An error occured") })
public Response unsetCardBookmark(@PathParam("cardUID") @ApiParam(value = "cardUID", required = true) String cardUID) {
Card card = this.cardRegistry.get(cardUID);
if (card == null) {
return Response.status(Status.NOT_FOUND).build();
}
card.setBookmark(false);
this.cardRegistry.update(card);
return Response.ok().build();
}
use of javax.ws.rs.DELETE in project ligoj-api by ligoj.
the class SubscriptionResource method delete.
/**
* Delete entity and cascaded associations : parameters, events then subscription.
*
* @param id
* the entity identifier.
* @param deleteRemoteData
* When <code>true</code>, remote data will be also destroyed.
* @throws Exception
* When the delete fails. Managed at JAX-RS level.
*/
@Path("{id:\\d+}/{deleteRemoteData}")
@DELETE
public void delete(@PathParam("id") final int id, @PathParam("deleteRemoteData") final boolean deleteRemoteData) throws Exception {
final Subscription entity = checkVisibleSubscription(id);
checkManagedProject(entity.getProject().getId());
// Delete the events
eventRepository.deleteAllBy("subscription", entity);
// Delegate the deletion
deleteWithTasks(entity.getNode().getId(), id, deleteRemoteData);
parameterValueResource.deleteBySubscription(id);
repository.delete(entity);
}
use of javax.ws.rs.DELETE in project 2TDSS-Digital by thiagoyama.
the class SelecaoResource method apagar.
@DELETE
@Path("{id}")
public void apagar(@PathParam("id") int codigo) {
try {
dao.remover(codigo);
dao.commit();
} catch (Exception e) {
e.printStackTrace();
throw new WebApplicationException(Status.INTERNAL_SERVER_ERROR);
}
}
Aggregations