Java Examples for javax.ws.rs.DELETE

The following java examples will help you to understand the usage of javax.ws.rs.DELETE. These source code samples are taken from different open source projects.

Example 1
Project: jerseytest-master  File: TodoResource.java View source code
@DELETE
@Path("/{todo}")
public void removeTodo(@PathParam("todo") String todoToRemove) {
    todoService.removeTodo(todoToRemove);
}
Example 2
Project: dataverse-master  File: HarvestingServer.java View source code
@DELETE
@Path("{specname}")
public Response deleteOaiSet(@PathParam("specname") String spec, @QueryParam("key") String apiKey) {
    OAISet set = null;
    try {
        set = oaiSetService.findBySpec(spec);
    } catch (Exception ex) {
        logger.warning("Exception caught looking up OAI set " + spec + ": " + ex.getMessage());
        return error(Response.Status.BAD_REQUEST, "Internal error: failed to look up OAI set " + spec + ".");
    }
    if (set == null) {
        return error(Response.Status.NOT_FOUND, "OAI set " + spec + " not found.");
    }
    try {
        oaiSetService.setDeleteInProgress(set.getId());
        oaiSetService.remove(set.getId());
    } catch (Exception ex) {
        return error(Response.Status.BAD_REQUEST, "Internal error: failed to delete OAI set " + spec + "; " + ex.getMessage());
    }
    return ok("OAI Set " + spec + " deleted");
}
Example 3
Project: eclipselink.runtime-master  File: EntityResource.java View source code
@DELETE
@Path("{type}/{id}/{attribute}")
public Response removeAttribute(@PathParam("version") String version, @PathParam("context") String persistenceUnit, @PathParam("type") String type, @PathParam("id") String id, @PathParam("attribute") String attribute, @Context HttpHeaders hh, @Context UriInfo ui) {
    setRequestUniqueId();
    return removeAttributeInternal(version, persistenceUnit, type, id, attribute, hh, ui);
}
Example 4
Project: fenixedu-cms-master  File: SiteResource.java View source code
@DELETE
@Produces(MediaType.APPLICATION_JSON)
@Path("/{oid}")
public Response deleteSite(@PathParam("oid") Site site) {
    site.delete();
    return Response.ok().build();
}
Example 5
Project: keycloak-master  File: OIDCClientRegistrationProvider.java View source code
@DELETE
@Path("{clientId}")
public void deleteOIDC(@PathParam("clientId") String clientId) {
    delete(clientId);
}
Example 6
Project: bennu-master  File: ExternalApplicationResource.java View source code
@DELETE
@Path("/{app}")
public Response delete(@PathParam("app") ExternalApplication app) {
    verifyAndGetRequestAuthor(app);
    atomic(() -> {
        app.setDeleted();
    });
    return ok();
}
Example 7
Project: sql-layer-master  File: EntityResource.java View source code
@DELETE
@Path("/" + IDENTIFIERS_MULTI)
public Response deleteEntity(@Context HttpServletRequest request, @PathParam("entity") String entity, @Context final UriInfo uri) {
    final TableName tableName = parseTableName(request, entity);
    checkTableAccessible(reqs.securityService, request, tableName);
    try {
        reqs.restDMLService.delete(tableName, getPKString(uri));
        return RestResponseBuilder.forRequest(request).status(Response.Status.NO_CONTENT).build();
    } catch (Exception e) {
        throw RestResponseBuilder.forRequest(request).wrapException(e);
    }
}
Example 8
Project: AIDR-master  File: DocumentResource.java View source code
@DELETE
@Path("{id}")
@Produces(MediaType.APPLICATION_JSON)
public Response deleteDocument(@PathParam("id") Long id) {
    try {
        int result = documentLocalEJB.deleteDocument(id);
        logger.info("deleted count = " + result);
    } catch (RuntimeException e) {
        return Response.ok(new ResponseWrapper(TaggerAPIConfigurator.getInstance().getProperty(TaggerAPIConfigurationProperty.STATUS_CODE_FAILED), "Error while deleting Document.")).build();
    }
    return Response.ok(new ResponseWrapper(TaggerAPIConfigurator.getInstance().getProperty(TaggerAPIConfigurationProperty.STATUS_CODE_SUCCESS))).build();
}
Example 9
Project: Payara-master  File: TemplateCommandDeleteResource.java View source code
@DELETE
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.APPLICATION_FORM_URLENCODED })
public Response processDeleteLegacyFormat(ParameterMap data) {
    if (data == null) {
        data = new ParameterMap();
    }
    if (data.containsKey("error")) {
        String errorMessage = localStrings.getLocalString("rest.request.parsing.error", "Unable to parse the input entity. Please check the syntax.");
        throw new WebApplicationException(ResourceUtil.getResponse(400, /*parsing error*/
        errorMessage, requestHeaders, uriInfo));
    }
    return executeCommandLegacyFormat(preprocessData(data));
}
Example 10
Project: glassfish-main-master  File: TemplateCommandDeleteResource.java View source code
@DELETE
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.APPLICATION_FORM_URLENCODED })
public Response processDelete(ParameterMap data) {
    if (data == null) {
        data = new ParameterMap();
    }
    if (data.containsKey("error")) {
        String errorMessage = localStrings.getLocalString("rest.request.parsing.error", "Unable to parse the input entity. Please check the syntax.");
        throw new WebApplicationException(ResourceUtil.getResponse(400, /*parsing error*/
        errorMessage, requestHeaders, uriInfo));
    }
    return executeCommand(preprocessData(data));
}
Example 11
Project: p4-master  File: Conf.java View source code
@DELETE
@Path("/user")
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
public Response deleteUser(@FormParam("userID") String userID) {
    logger.debug("Called deleteUser...");
    ResponseBuilder rb;
    ConfigurationManager.getUserInstance().deleteUser(userID);
    rb = Response.status(Status.OK);
    return rb.build();
}
Example 12
Project: ecms-develop-master  File: MockRestService.java View source code
@DELETE
@Path("/guest")
@Produces(MediaType.TEXT_PLAIN)
public Response remove(@QueryParam("name") @DefaultValue("anonymous") String name) {
    if (!guests.contains(name)) {
        throw new WebApplicationException(Response.Status.NOT_FOUND);
    }
    guests.remove(name);
    return Response.ok("Removed " + name, MediaType.TEXT_PLAIN).cacheControl(cc).build();
}
Example 13
Project: airlift-master  File: PersonResource.java View source code
@DELETE
public Response delete(@PathParam("id") String id) {
    Preconditions.checkNotNull(id, "id must not be null");
    if (!store.delete(id)) {
        return Response.status(Response.Status.NOT_FOUND).build();
    }
    return Response.noContent().build();
}
Example 14
Project: libreplan-master  File: OrderElementServiceREST.java View source code
@Override
@DELETE
@Path("/{code}/")
@Transactional
public Response removeOrderElement(@PathParam("code") String code) {
    try {
        OrderElement orderElement = orderElementDAO.findByCode(code);
        String errorMessage = checkRemovalValidation(orderElement);
        if (errorMessage != null) {
            return Response.status(Status.FORBIDDEN).entity(new ErrorDTO(errorMessage)).build();
        }
        if (orderElement.isOrder()) {
            orderModel.remove((Order) orderElement);
        } else {
            Order order = orderDAO.loadOrderAvoidingProxyFor(orderElement);
            orderModel.initEdit(order, null);
            order = orderModel.getOrder();
            orderElement = findOrderElement(order, orderElement.getId());
            OrderLineGroup parent = orderElement.getParent();
            parent.remove(orderElement);
            orderElement.detachFromParent();
            if (!parent.isOrder() && parent.getChildren().isEmpty()) {
                OrderElement newElement = parent.toLeaf();
                if (!order.isCodeAutogenerated()) {
                    newElement.setCode(UUID.randomUUID().toString());
                }
                parent.getParent().replace(parent, newElement);
                parent.detachFromParent();
            }
            orderModel.save();
        }
        return Response.ok().build();
    } catch (InstanceNotFoundException e) {
        return Response.status(Status.NOT_FOUND).build();
    }
}
Example 15
Project: keywhiz-master  File: GroupsResource.java View source code
/**
   * Delete Group by ID
   *
   * @excludeParams user
   * @param groupId the ID of the Group to be deleted
   *
   * @description Deletes a single Group if found.
   * Used by Keywhiz CLI and the web ui.
   * @responseMessage 200 Found and deleted Group with given ID
   * @responseMessage 404 Group with given ID not Found
   */
@Path("{groupId}")
@Timed
@ExceptionMetered
@DELETE
public Response deleteGroup(@Auth User user, @PathParam("groupId") LongParam groupId) {
    logger.info("User '{}' deleting group id={}.", user, groupId);
    Optional<Group> group = groupDAO.getGroupById(groupId.get());
    if (!group.isPresent()) {
        throw new NotFoundException("Group not found.");
    }
    groupDAO.deleteGroup(group.get());
    auditLog.recordEvent(new Event(Instant.now(), EventTag.GROUP_DELETE, user.getName(), group.get().getName()));
    return Response.noContent().build();
}
Example 16
Project: abiquo-master  File: TemplateResource.java View source code
/**
     * delete
     */
@DELETE
public void deleteTemplate(@PathParam(EnterpriseRepositoryResource.ENTERPRISE_REPOSITORY) final String idEnterprise, @PathParam(TemplateResource.TEMPLATE) final String ovfIdIn) {
    final String ovfId = ovfUrl(ovfIdIn);
    service.delete(idEnterprise, ovfId);
}
Example 17
Project: kaleido-repository-master  File: FileStoreController.java View source code
/**
    * remove a resource
    * 
    * @param store
    * @param resource
    * @throws FileStoreNotFoundException
    * @throws ResourceNotFoundException
    * @throws ResourceException
    */
@DELETE
@Path("{store}/{resource}")
public void removeResource(@PathParam("store") final String store, @PathParam("resource") final String resource) throws FileStoreNotFoundException, ResourceNotFoundException, ResourceException {
    findFileStore(store).remove(resource);
}
Example 18
Project: visuwall-master  File: SessionsResource.java View source code
@DELETE
@Produces({ MediaType.APPLICATION_JSON, "application/javascript", MediaType.APPLICATION_XML, MediaType.APPLICATION_OCTET_STREAM })
public void deleteSession(@PathParam("session") String session, @Context UriInfo ui) {
    ZooKeeperService.close(contextPath, session);
}
Example 19
Project: thermospy-master  File: LogSessionResource.java View source code
@DELETE
@Timed
@UnitOfWork
@Path("/{id}")
public Response delete(@PathParam("id") IntParam id) {
    LogSession s = controller.getLogSession();
    if (s != null && s.getId() == id.get()) {
        controller.setLogSession(null);
    }
    temperatureEntryDao.deleteAllBySessionId(id.get());
    boolean result = sessionDao.delete(id.get());
    if (result)
        return Response.ok(id.get()).build();
    else
        return Response.serverError().build();
}
Example 20
Project: linshare-core-master  File: ThreadRestServiceImpl.java View source code
@Path("/")
@DELETE
@ApiOperation(value = "Delete a thread.", response = WorkGroupDto.class)
@ApiResponses({ @ApiResponse(code = 403, message = "User isn't admin.") })
@Override
public WorkGroupDto delete(WorkGroupDto thread) throws BusinessException {
    return threadFacade.delete(thread.getUuid());
}
Example 21
Project: stickypunch-master  File: SafariPushResource.java View source code
@DELETE
@Path("/devices/{deviceToken}/registrations/{websitePushId}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response disableRegistration(@Context HttpHeaders headers, @PathParam("deviceToken") String deviceToken, @PathParam("websitePushId") String websitePushId) throws Exception {
    Optional<String> userIdOptional = extractandUserId(headers);
    if (!auth(userIdOptional, Optional.of(deviceToken))) {
        return Response.status(Response.Status.FORBIDDEN).build();
    }
    updateUserId(userIdOptional, false, websitePushId, deviceToken);
    return Response.ok().build();
}
Example 22
Project: iaf-master  File: Init.java View source code
@GET
@Path("/")
@Produces(MediaType.APPLICATION_JSON)
public Response getAllResources() {
    List<Object> resources = new ArrayList<Object>();
    ResourceMethodRegistry registry = (ResourceMethodRegistry) dispatcher.getRegistry();
    for (Map.Entry<String, List<ResourceInvoker>> entry : registry.getBounded().entrySet()) {
        for (ResourceInvoker invoker : entry.getValue()) {
            Method method = invoker.getMethod();
            if (method.getDeclaringClass() == getClass()) {
                continue;
            }
            Map<String, Object> resource = new HashMap<String, Object>(3);
            if (method.isAnnotationPresent(GET.class))
                resource.put("method", "GET");
            else if (method.isAnnotationPresent(POST.class))
                resource.put("method", "POST");
            else if (method.isAnnotationPresent(PUT.class))
                resource.put("method", "PUT");
            else if (method.isAnnotationPresent(DELETE.class))
                resource.put("method", "DELETE");
            Path path = method.getAnnotation(Path.class);
            if (path != null) {
                resource.put("path", path.value());
            }
            RolesAllowed rolesAllowed = method.getAnnotation(RolesAllowed.class);
            if (rolesAllowed != null) {
                resource.put("allowed", rolesAllowed.value());
            }
            resources.add(resource);
        }
    }
    return Response.status(Response.Status.CREATED).entity(resources).build();
}
Example 23
Project: dcache-master  File: FileResources.java View source code
@DELETE
@Path("{value : .*}")
@Produces(MediaType.APPLICATION_JSON)
public Response deleteFileEntry(@PathParam("value") String value) throws CacheException {
    PnfsHandler handler = ServletContextHandlerAttributes.getPnfsHandler(ctx);
    PathMapper pathMapper = ServletContextHandlerAttributes.getPathMapper(ctx);
    FsPath path = pathMapper.asDcachePath(request, value);
    try {
        handler.deletePnfsEntry(path.toString(), EnumSet.of(FileType.REGULAR));
    } catch (FileNotFoundCacheException e) {
        throw new NotFoundException(e);
    } catch (PermissionDeniedCacheException e) {
        if (Subjects.isNobody(ServletContextHandlerAttributes.getSubject())) {
            throw new NotAuthorizedException(e);
        } else {
            throw new ForbiddenException(e);
        }
    } catch (JSONExceptionIllegalArgumentException | CacheException |  e) {
        throw new BadRequestException(e);
    } catch (Exception e) {
        throw new InternalServerErrorException(e);
    }
    return successfulResponse(Response.Status.OK);
}
Example 24
Project: usergrid-master  File: CollectionResource.java View source code
/**
     * Delete settings for a collection.
     */
@DELETE
@Path("{itemName}/_settings")
@Produces({ MediaType.APPLICATION_JSON, "application/javascript" })
@RequireApplicationAccess
@JSONP
public ApiResponse executeDeleteOnSettingsWithCollectionName(@Context UriInfo ui, @PathParam("itemName") PathSegment itemName, String body, @QueryParam("callback") @DefaultValue("callback") String callback) throws Exception {
    if (logger.isTraceEnabled()) {
        logger.trace("CollectionResource.executeDeleteOnSettingsWithCollectionName");
    }
    addItemToServiceContext(ui, itemName);
    ApiResponse response = createApiResponse();
    response.setAction("delete");
    response.setApplication(services.getApplication());
    response.setParams(ui.getQueryParameters());
    emf.getEntityManager(services.getApplicationId()).deleteCollectionSettings(itemName.getPath().toLowerCase());
    return response;
}
Example 25
Project: fiware-rss-master  File: ExpenditureLimitServer.java View source code
/**
     * Delete expenditure limits for a provider
     * 
     * @param aggregator
     * @param appProvider
     * @param service,
     * @param currency,
     * @param type
     * 
     * @return
     * @throws Exception
     */
@WebMethod
@DELETE
@Path("/{aggregatorId}/{appProvider}")
public Response deleteProviderExpLimits(@PathParam("aggregatorId") final String aggregator, @PathParam("appProvider") final String appProvider, @QueryParam("service") String service, @QueryParam("currency") String currency, @QueryParam("type") String type) throws Exception {
    ExpenditureLimitServer.logger.debug("Into deleteUserExpCtrl method");
    // check security
    checker.checkCurrentUserPermissions();
    expLimitManager.deleteProviderLimits(aggregator, appProvider, service, currency, type);
    // Building response
    ResponseBuilder rb = Response.status(Response.Status.NO_CONTENT.getStatusCode());
    return rb.build();
}