Java Code Examples for javax.ws.rs.DELETE

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project Ivory, under directory /prism/src/main/java/org/apache/ivory/resource/channel/.

Source file: HTTPChannel.java

  22 
vote

private String getHttpMethod(Method method){
  PUT put=method.getAnnotation(PUT.class);
  if (put != null)   return HttpMethod.PUT;
  POST post=method.getAnnotation(POST.class);
  if (post != null)   return HttpMethod.POST;
  DELETE delete=method.getAnnotation(DELETE.class);
  if (delete != null)   return HttpMethod.DELETE;
  return HttpMethod.GET;
}
 

Example 2

From project action-core, under directory /src/main/java/com/ning/metrics/action/endpoint/.

Source file: HdfsBrowser.java

  20 
vote

@DELETE @Produces(MediaType.TEXT_PLAIN) @Timed public Response delete(@QueryParam("path") final String outputPath,@QueryParam("recursive") @DefaultValue("false") final boolean recursive) throws IOException {
  try {
    hdfsWriter.delete(outputPath,recursive);
    return Response.ok().build();
  }
 catch (  IOException e) {
    final String message=StringUtils.split(e.getMessage(),'\n')[0];
    log.warn("Unable to delete [{}]: {}",outputPath,message);
    return Response.serverError().header("Warning","199 " + message).cacheControl(cacheControl).build();
  }
}
 

Example 3

From project airlift, under directory /jaxrs/src/test/java/io/airlift/jaxrs/.

Source file: TestOverrideMethodFilterInHttpServer.java

  19 
vote

@Test public void testDeleteViaQueryParam() throws Exception {
  client.execute(buildRequestWithQueryParam(POST,DELETE),createStatusResponseHandler());
  assertFalse(resource.postCalled(),"POST");
  assertTrue(resource.deleteCalled(),"DELETE");
  assertFalse(resource.putCalled(),"PUT");
  assertFalse(resource.getCalled(),"GET");
}
 

Example 4

From project Arecibo, under directory /aggregator/src/main/java/com/ning/arecibo/aggregator/rest/.

Source file: EventAggregatorEndPoint.java

  19 
vote

@DELETE @Produces(MediaType.TEXT_HTML) public Response delete(@PathParam("name") String name){
  log.info("Got a delete request for %s",UriBuilder.fromResource(EventAggregatorEndPoint.class).build());
  AggregatorImpl def=registry.getAggregatorImpl(name);
  if (def != null) {
    try {
      log.info("deleting aggregator %s",name);
      service.unregister(def.getAggregator().getFullName());
    }
 catch (    RemoteException e) {
      log.warn(e);
    }
    return Response.ok().build();
  }
 else {
    return Response.ok(registry).build();
  }
}
 

Example 5

From project ATHENA, under directory /core/web-resources/src/main/java/org/fracturedatlas/athena/web/resource/.

Source file: FieldResource.java

  19 
vote

@DELETE @Path("/{propFieldId}/values/{propValueId}") public Object deleteValue(@PathParam("propFieldId") String propFieldId,@PathParam("propValueId") String propValueId) throws Exception {
  if (propFieldManager.deletePropValue(propFieldId,propValueId)) {
    return Response.noContent().build();
  }
 else {
    return Response.status(404).build();
  }
}
 

Example 6

From project candlepin, under directory /src/main/java/org/candlepin/auth/interceptor/.

Source file: SecurityInterceptor.java

  19 
vote

/** 
 * Scans the method annotations for RESTEasy annotations, to determine the HTTP verbs used. We'll assume this is the required access type, but any Verify annotation which specifies an access type can override this later.
 * @param invocation method invocation object
 * @return the required minimum access type
 */
private Access getAssumedAccessType(MethodInvocation invocation){
  Access minimumLevel=Access.READ_ONLY;
  for (  Annotation annotation : invocation.getMethod().getAnnotations()) {
    if (annotation instanceof PUT || annotation instanceof POST || annotation instanceof DELETE) {
      minimumLevel=Access.ALL;
      break;
    }
  }
  return minimumLevel;
}
 

Example 7

From project chukwa, under directory /src/main/java/org/apache/hadoop/chukwa/datacollection/agent/rest/.

Source file: AdaptorController.java

  19 
vote

/** 
 * Remove an adaptor from the agent
 * @param context ServletContext
 * @param adaptorId id of adaptor to remove.
 * @return Response object
 */
@DELETE @Path("/{adaptorId}") @Produces({"text/plain"}) public Response removeAdaptor(@Context ServletContext context,@PathParam("adaptorId") String adaptorId){
  ChukwaAgent agent=(ChukwaAgent)context.getAttribute("ChukwaAgent");
  if (adaptorId == null) {
    return badRequestResponse("Missing adaptorId.");
  }
  if (agent.getAdaptor(adaptorId) == null) {
    return badRequestResponse("Invalid adaptorId: " + adaptorId);
  }
  agent.stopAdaptor(adaptorId,true);
  return Response.ok().build();
}
 

Example 8

From project Cilia_1, under directory /framework/remote/src/main/java/fr/liglab/adele/cilia/remote/impl/.

Source file: AdminChainREST.java

  19 
vote

/** 
 * Delete a mediation chain. 
 * @param id The ID of the chain to be deleted
 * @return true if chain is successful deleted, false if it does not exist.
 */
@DELETE @Produces("application/json") public String deleteChain(@PathParam("chainid") String id){
  boolean res=admin.deleteChain(id);
  if (res) {
    return "{result : true}";
  }
  return "{result : false}";
}
 

Example 9

From project cloud-management, under directory /src/main/java/com/proofpoint/cloudmanagement/service/.

Source file: InstanceResource.java

  19 
vote

@DELETE public Response deleteInstance(@PathParam("id") String instanceId){
  checkNotNull(instanceId,"Instance ID cannot be null");
  for (  InstanceConnector instanceConnector : instanceConnectorMap.values()) {
    if (instanceConnector.destroyInstance(instanceId) == InstanceDestructionStatus.DESTROYED) {
      return Response.noContent().build();
    }
  }
  return Response.status(Status.NOT_FOUND).build();
}
 

Example 10

From project curator, under directory /curator-x-discovery-server/src/main/java/com/netflix/curator/x/discovery/server/rest/.

Source file: DiscoveryResource.java

  19 
vote

@DELETE @Path("v1/service/{name}/{id}") public Response removeService(@PathParam("name") String name,@PathParam("id") String id){
  try {
    ServiceInstance<T> instance=context.getServiceDiscovery().queryForInstance(name,id);
    if (instance != null) {
      context.getServiceDiscovery().unregisterService(instance);
    }
  }
 catch (  Exception e) {
    log.error("Trying to delete service",e);
    return Response.serverError().build();
  }
  return Response.ok().build();
}
 

Example 11

From project data-access, under directory /src/org/pentaho/platform/dataaccess/datasource/wizard/service/impl/.

Source file: ConnectionService.java

  19 
vote

@DELETE @Path("/delete") @Consumes({APPLICATION_JSON}) public Response deleteConnection(Connection connection) throws ConnectionServiceException {
  try {
    boolean success=service.deleteConnection(connection);
    if (success) {
      return Response.ok().build();
    }
 else {
      return Response.serverError().build();
    }
  }
 catch (  Throwable t) {
    t.printStackTrace();
    return Response.serverError().build();
  }
}
 

Example 12

From project fast-http, under directory /src/main/java/org/neo4j/smack/routing/.

Source file: AnnotationBasedRoutingDefinition.java

  19 
vote

private void setupRoutes(){
  for (  Method m : underlyingObject.getClass().getMethods()) {
    if (m.isAnnotationPresent(GET.class)) {
      addRoute(m,InvocationVerb.GET);
    }
    if (m.isAnnotationPresent(PUT.class)) {
      addRoute(m,InvocationVerb.PUT);
    }
    if (m.isAnnotationPresent(POST.class)) {
      addRoute(m,InvocationVerb.POST);
    }
    if (m.isAnnotationPresent(DELETE.class)) {
      addRoute(m,InvocationVerb.DELETE);
    }
    if (m.isAnnotationPresent(HEAD.class)) {
      addRoute(m,InvocationVerb.HEAD);
    }
  }
}
 

Example 13

From project gatein-management, under directory /rest/src/main/java/org/gatein/management/rest/.

Source file: RestController.java

  19 
vote

private Response validateRequest(HttpManagedRequest request){
  String operationName=request.getOperationName();
  String httpMethod=request.getHttpMethod();
  MediaType mediaType=ContentTypeUtils.getMediaType(request.getContentType());
  if (operationName.equals(OperationNames.READ_RESOURCE)) {
    if (!httpMethod.equals(HttpMethod.GET)) {
      return badRequest("Request must be a GET.",operationName,mediaType);
    }
  }
 else   if (operationName.equals(OperationNames.ADD_RESOURCE)) {
    if (!httpMethod.equals(HttpMethod.POST)) {
      return badRequest("Request must be a POST.",operationName,mediaType);
    }
  }
 else   if (operationName.equals(OperationNames.UPDATE_RESOURCE)) {
    if (!httpMethod.equals(HttpMethod.PUT)) {
      return badRequest("Request must be a POST.",operationName,mediaType);
    }
  }
 else   if (operationName.equals(OperationNames.REMOVE_RESOURCE)) {
    if (!httpMethod.equals(HttpMethod.DELETE)) {
      return badRequest("Request must be a DELETE.",operationName,mediaType);
    }
  }
  return null;
}
 

Example 14

From project gmc, under directory /src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/resources/v1_0/.

Source file: ClustersResource.java

  19 
vote

@Path("{" + PATH_PARAM_CLUSTER_NAME + "}") @DELETE public Response unregisterCluster(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName){
  if (clusterName == null || clusterName.isEmpty()) {
    throw new GlusterValidationException("Parameter [" + FORM_PARAM_CLUSTER_NAME + "] is missing in request!");
  }
  ClusterInfo cluster=clusterService.getCluster(clusterName);
  if (cluster == null) {
    throw new GlusterValidationException("Cluster [" + clusterName + "] does not exist!");
  }
  clusterService.unregisterCluster(cluster);
  return noContentResponse();
}
 

Example 15

From project hcatalog, under directory /webhcat/svr/src/main/java/org/apache/hcatalog/templeton/.

Source file: Server.java

  19 
vote

/** 
 * Drop an hcat table.
 */
@DELETE @Path("ddl/database/{db}/table/{table}") @Produces(MediaType.APPLICATION_JSON) public Response dropTable(@PathParam("db") String db,@PathParam("table") String table,@QueryParam("ifExists") boolean ifExists,@QueryParam("group") String group,@QueryParam("permissions") String permissions) throws HcatException, NotAuthorizedException, BusyException, BadParam, ExecuteException, IOException {
  verifyUser();
  verifyDdlParam(db,":db");
  verifyDdlParam(table,":table");
  HcatDelegator d=new HcatDelegator(appConf,execService);
  return d.dropTable(getUser(),db,table,ifExists,group,permissions);
}
 

Example 16

From project HiTune_1, under directory /chukwa-hitune-dist/src/java/org/apache/hadoop/chukwa/rest/resource/.

Source file: ViewResource.java

  19 
vote

@DELETE @Path("delete/{owner}/vid/{vid}") public ReturnCodeBean deleteView(@Context HttpServletRequest request,@PathParam("owner") String owner,@PathParam("vid") String vid){
  try {
    if (owner.intern() == request.getRemoteUser().intern()) {
      log.info("owner: " + owner + " vid: "+ vid);
      ViewStore vs=new ViewStore(owner,vid);
      vs.delete();
    }
 else {
      throw new WebApplicationException(Response.status(Response.Status.FORBIDDEN).entity("View delete failed.").build());
    }
  }
 catch (  Exception e) {
    log.error(ExceptionUtil.getStackTrace(e));
    throw new WebApplicationException(Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("View delete failed.").build());
  }
  return new ReturnCodeBean(ReturnCodeBean.SUCCESS,"Deleted");
}
 

Example 17

From project HMS, under directory /controller/src/main/java/org/apache/hms/controller/rest/.

Source file: ConfigManager.java

  19 
vote

@DELETE @Path("blueprint/{name}") public Response deleteStack(@PathParam("name") String name){
  ZooKeeper zk=Controller.getInstance().getZKInstance();
  try {
    String path=ZookeeperUtil.getConfigManifestPath(name);
    Stat current=zk.exists(path,false);
    zk.delete(path,current.getVersion());
  }
 catch (  Exception e) {
    LOG.error(ExceptionUtil.getStackTrace(e));
    throw new WebApplicationException(500);
  }
  Response res=Response.noContent().build();
  return res;
}
 

Example 18

From project hoop, under directory /hoop-server/src/main/java/com/cloudera/hoop/.

Source file: Hoop.java

  19 
vote

/** 
 * Binding to handle all DELETE requests.
 * @param user principal making the request.
 * @param path path for the DELETE request.
 * @param recursive indicates if the delete is recursive, default is <code>false</code>
 * @param doAs user being impersonated, defualt value is none. It can be usedonly if the current user is a Hoop proxyuser.
 * @return the request response.
 * @throws IOException thrown if an IO error occurred. Thrown exceptions arehandled by  {@link HoopExceptionProvider}.
 * @throws HadoopException thrwon if a Hadoop releated error occurred. Thrownexceptions are handled by  {@link HoopExceptionProvider}.
 */
@DELETE @Path("{path:.*}") @Produces(MediaType.APPLICATION_JSON) public Response delete(@Context Principal user,@PathParam("path") FsPathParam path,@QueryParam(DeleteRecursiveParam.NAME) @DefaultValue(DeleteRecursiveParam.DEFAULT) DeleteRecursiveParam recursive,@QueryParam(DoAsParam.NAME) @DefaultValue(DoAsParam.DEFAULT) DoAsParam doAs) throws IOException, HadoopException {
  path.makeAbsolute();
  MDC.put("op","DELETE");
  AUDIT_LOG.info("[{}] recursive [{}]",path,recursive);
  FSDelete command=new FSDelete(path.value(),recursive.value());
  JSONObject json=fsExecute(user,doAs.value(),command);
  return Response.ok(json).type(MediaType.APPLICATION_JSON).build();
}
 

Example 19

From project huahin-manager, under directory /src/main/java/org/huahinframework/manager/rest/service/.

Source file: JobService.java

  19 
vote

/** 
 * @return {@link JSONObject}
 */
@Path("/kill/id/{" + JOBID + "}") @DELETE @Produces(MediaType.APPLICATION_JSON) public JSONObject killJobId(@PathParam(JOBID) String jobId){
  Map<String,String> status=new HashMap<String,String>();
  try {
    JobClient jobClient=new JobClient(getJobConf());
    JobStatus[] jobStatuses=jobClient.getAllJobs();
    for (    JobStatus jobStatus : jobStatuses) {
      if (jobStatus.getJobID().toString().equals(jobId)) {
        RunningJob runningJob=jobClient.getJob(jobStatus.getJobID());
        if (runningJob == null) {
          break;
        }
        runningJob.killJob();
        status.put(Response.STATUS,"Killed job " + jobId);
        break;
      }
    }
  }
 catch (  IOException e) {
    e.printStackTrace();
    log.error(e);
    status.put(Response.STATUS,e.getMessage());
  }
  if (status.isEmpty()) {
    status.put(Response.STATUS,"Could not find job " + jobId);
  }
  return new JSONObject(status);
}
 

Example 20

From project iserve, under directory /iserve-parent/iserve-sal-rest/src/main/java/uk/ac/open/kmi/iserve/sal/rest/resource/.

Source file: DocumentResource.java

  19 
vote

@DELETE @Path("/{id}") @Produces({MediaType.TEXT_HTML}) public String deleteDocumentById(@PathParam("id") String id) throws DocumentException, LogException {
  if (security.getUserPrincipal() == null) {
    throw new MappableContainerException(new AuthenticationException("Authentication credentials are required\r\n","iServe SAL RESTful API"));
  }
  String userFoafId=security.getUserPrincipal().getName();
  String uriString=documentManager.deleteDocumentById(id);
  logManager.log(userFoafId,LOG.ITEM_DELETING,uriString,new Date(),"REST");
  String htmlString="<html>\n  <head>\n    <meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">\n  </head>\n" + "  <body>\nA document is removed from <a href='" + uriString + "'>"+ uriString+ "</a>\n  </body>\n</html>";
  return htmlString;
}
 

Example 21

From project jbpm-form-builder, under directory /jbpm-gwt-form-builder/src/main/java/org/jbpm/formbuilder/server/.

Source file: RESTFileService.java

  19 
vote

@DELETE @Path("/package/{pkgName}/{fileName}") public Response deleteFile(@Context HttpServletRequest request,@PathParam("pkgName") String packageName,@PathParam("fileName") String fileName){
  setContext(request.getSession().getServletContext());
  try {
    fileService.deleteFile(packageName,fileName);
    return Response.noContent().build();
  }
 catch (  FileException e) {
    return error("Problem deleting file in guvnor",e);
  }
}
 

Example 22

From project jersey-ahc-client, under directory /src/test/java/org/sonatype/spice/jersey/client/ahc/tests/tests/.

Source file: AuthTest.java

  19 
vote

@DELETE public void delete(@Context HttpHeaders h){
  requestCount++;
  String value=h.getRequestHeaders().getFirst("Authorization");
  if (value == null) {
    assertEquals(1,requestCount);
    throw new WebApplicationException(Response.status(401).header("WWW-Authenticate","Basic realm=\"WallyWorld\"").build());
  }
 else {
    assertTrue(requestCount > 1);
  }
}
 

Example 23

From project litle-sdk-for-java, under directory /lib/apache-cxf-2.5.2/samples/jax_rs/basic/src/main/java/demo/jaxrs/server/.

Source file: CustomerService.java

  19 
vote

@DELETE @Path("/customers/{id}/") public Response deleteCustomer(@PathParam("id") String id){
  System.out.println("----invoking deleteCustomer, Customer id is: " + id);
  long idNumber=Long.parseLong(id);
  Customer c=customers.get(idNumber);
  Response r;
  if (c != null) {
    r=Response.ok().build();
    customers.remove(idNumber);
  }
 else {
    r=Response.notModified().build();
  }
  return r;
}
 

Example 24

From project lyo.core, under directory /OSLC4JStockQuote/src/org/eclipse/lyo/oslc4j/stockquote/resources/.

Source file: StockQuoteResource.java

  19 
vote

@DELETE @Path("{stockQuoteId}") public Response deleteStockQuote(@PathParam("stockQuoteId") final String stockQuoteId){
  final StockQuote stockQuote=Persistence.deleteStockQuote(stockQuoteId);
  if (stockQuote != null) {
    return Response.noContent().build();
  }
  throw new WebApplicationException(Status.NOT_FOUND);
}
 

Example 25

From project lyo.rio, under directory /OSLC4JChangeManagement/src/org/eclipse/lyo/oslc4j/changemanagement/resources/.

Source file: ChangeRequestResource.java

  19 
vote

@DELETE @Path("{changeRequestId}") public Response deleteChangeRequest(@PathParam("changeRequestId") final String changeRequestId){
  final ChangeRequest changeRequest=Persistence.deleteChangeRequest(changeRequestId);
  if (changeRequest != null) {
    return Response.noContent().build();
  }
  throw new WebApplicationException(Status.NOT_FOUND);
}
 

Example 26

From project lyo.server, under directory /org.eclipse.lyo.server.oauth.webapp/src/main/java/org/eclipse/lyo/server/oauth/webapp/services/.

Source file: ConsumersService.java

  19 
vote

/** 
 * Deletes an OAuth consumer.
 * @param key the consumer key
 * @return the HTTP response
 */
@DELETE @Path("/{key}") public Response removeConsumer(@PathParam("key") String key){
  CSRFPrevent.check(httpRequest);
  try {
    if (!OAuthConfiguration.getInstance().getApplication().isAdminSession(httpRequest)) {
      return Response.status(Status.FORBIDDEN).type(MediaType.TEXT_PLAIN).entity("You must be an administrator.").build();
    }
    OAuthConfiguration.getInstance().getConsumerStore().removeConsumer(key);
    return Response.noContent().build();
  }
 catch (  ConsumerStoreException e) {
    return handleConsumerStoreException(e);
  }
catch (  OAuthProblemException e) {
    return Response.status(Status.SERVICE_UNAVAILABLE).build();
  }
}
 

Example 27

From project nuxeo-filesystem-connectors, under directory /nuxeo-webdav/src/main/java/org/nuxeo/ecm/webdav/resource/.

Source file: ExistingResource.java

  19 
vote

@DELETE public Response delete() throws Exception {
  if (backend.isLocked(doc.getRef()) && !backend.canUnlock(doc.getRef())) {
    return Response.status(423).build();
  }
  try {
    backend.removeItem(doc.getRef());
    backend.saveChanges();
    return Response.status(204).build();
  }
 catch (  ClientException e) {
    log.error("Can't remove item: " + doc.getPathAsString() + e.getMessage());
    log.debug(e);
    backend.discardChanges();
    return Response.status(FORBIDDEN).build();
  }
}
 

Example 28

From project odata4j, under directory /odata4j-core/src/main/java/org/odata4j/producer/resources/.

Source file: EntityRequestResource.java

  19 
vote

@DELETE public Response deleteEntity(@Context ContextResolver<ODataProducer> producerResolver,@PathParam("entitySetName") String entitySetName,@PathParam("id") String id){
  log.info(String.format("getEntity(%s,%s)",entitySetName,id));
  ODataProducer producer=producerResolver.getContext(ODataProducer.class);
  OEntityKey entityKey=OEntityKey.parse(id);
  producer.deleteEntity(entitySetName,entityKey);
  return Response.ok().header(ODataConstants.Headers.DATA_SERVICE_VERSION,ODataConstants.DATA_SERVICE_VERSION_HEADER).build();
}
 

Example 29

From project Openbravo-POS-iPhone-App, under directory /OpenbravoPOS_PDA/src-pda/com/openbravo/pos/pda/restresources/.

Source file: TicketResource.java

  19 
vote

@DELETE @Path("/deleteTicketIfEmpty") public void deleteTicketIfEmpty(@QueryParam("place") String placeId){
  TicketInfo ticket=manager.findTicket(placeId);
  if (ticket != null && ticket.getLines().isEmpty()) {
    manager.deleteTicket(placeId);
  }
}
 

Example 30

From project platform_3, under directory /jaxrs/src/test/java/com/proofpoint/jaxrs/.

Source file: TestOverrideMethodFilterInHttpServer.java

  19 
vote

@Test public void testDeleteViaQueryParam() throws Exception {
  client.execute(buildRequestWithQueryParam(POST,DELETE),createStatusResponseHandler());
  assertFalse(resource.postCalled(),"POST");
  assertTrue(resource.deleteCalled(),"DELETE");
  assertFalse(resource.putCalled(),"PUT");
  assertFalse(resource.getCalled(),"GET");
}
 

Example 31

From project rest-support, under directory /hudson-rest-api/src/main/java/org/hudsonci/rest/api/project/.

Source file: ProjectsResource.java

  19 
vote

@DELETE @Path("{projectName}") public void deleteProject(final @PathParam("projectName") String projectName) throws Exception {
  log.debug("Deleting project: {}",projectName);
  AbstractProject project=support.getProject(projectName);
  project.checkPermission(DELETE);
  project.delete();
}
 

Example 32

From project resty-gwt, under directory /restygwt/src/main/java/org/fusesource/restygwt/rebind/.

Source file: RestServiceClassCreator.java

  19 
vote

private String getRestMethod(JMethod method) throws UnableToCompleteException {
  String restMethod=null;
  if (method.getAnnotation(DELETE.class) != null) {
    restMethod=METHOD_DELETE;
  }
 else   if (method.getAnnotation(GET.class) != null) {
    restMethod=METHOD_GET;
  }
 else   if (method.getAnnotation(HEAD.class) != null) {
    restMethod=METHOD_HEAD;
  }
 else   if (method.getAnnotation(OPTIONS.class) != null) {
    restMethod=METHOD_OPTIONS;
  }
 else   if (method.getAnnotation(POST.class) != null) {
    restMethod=METHOD_POST;
  }
 else   if (method.getAnnotation(PUT.class) != null) {
    restMethod=METHOD_PUT;
  }
 else   if (method.getAnnotation(JSONP.class) != null) {
    restMethod=METHOD_JSONP;
  }
 else {
    restMethod=method.getName();
    if (!REST_METHODS.contains(restMethod)) {
      error("Invalid rest method. It must either have a lower case rest method name or have a javax rs method annotation: " + method.getReadableDeclaration());
    }
  }
  return restMethod;
}
 

Example 33

From project RSB, under directory /src/main/java/eu/openanalytics/rsb/component/.

Source file: ResultsResource.java

  19 
vote

@Path("/{jobId}") @DELETE public Response deleteSingleResult(@PathParam("applicationName") final String applicationName,@PathParam("jobId") final String jobId,@Context final HttpHeaders httpHeaders,@Context final UriInfo uriInfo) throws URISyntaxException, IOException {
  validateApplicationName(applicationName);
  validateJobId(jobId);
  if (!resultStore.deleteByApplicationNameAndJobId(applicationName,UUID.fromString(jobId))) {
    throw new WebApplicationException(Status.NOT_FOUND);
  }
  return Response.noContent().build();
}
 

Example 34

From project s-ramp, under directory /s-ramp-atom/src/main/java/org/overlord/sramp/atom/services/.

Source file: ArtifactResource.java

  19 
vote

/** 
 * Called to delete an s-ramp artifact from the repository.
 * @param model
 * @param type
 * @param uuid
 * @throws SrampAtomException
 */
@DELETE @Path("{model}/{type}/{uuid}") public void delete(@PathParam("model") String model,@PathParam("type") String type,@PathParam("uuid") String uuid) throws SrampAtomException {
  try {
    ArtifactType artifactType=ArtifactType.valueOf(model,type);
    PersistenceManager persistenceManager=PersistenceFactory.newInstance();
    persistenceManager.deleteArtifact(uuid,artifactType);
  }
 catch (  Throwable e) {
    throw new SrampAtomException(e);
  }
}
 

Example 35

From project saiku, under directory /saiku-core/saiku-web/src/main/java/org/saiku/web/rest/resources/.

Source file: BasicRepositoryResource.java

  19 
vote

/** 
 * Delete Query.
 * @param queryName - The name of the query.
 * @return A GONE Status if the query was deleted, otherwise it will return a NOT FOUND Status code.
 */
@DELETE @Produces({"application/json"}) @Path("/{queryname}") public Status deleteQuery(@PathParam("queryname") String queryName){
  try {
    if (repo != null) {
      if (!queryName.endsWith(".saiku")) {
        queryName+=".saiku";
      }
      FileObject queryFile=repo.resolveFile(queryName);
      if (queryFile.delete()) {
        return (Status.GONE);
      }
    }
    throw new Exception("Cannot delete query file:" + queryName);
  }
 catch (  Exception e) {
    log.error("Cannot delete query (" + queryName + ")",e);
    return (Status.NOT_FOUND);
  }
}
 

Example 36

From project saiku-adhoc, under directory /saiku-adhoc-core/src/main/java/org/saiku/adhoc/rest/.

Source file: QueryResource.java

  19 
vote

@DELETE @Path("/{queryname}/COLUMNS/CATEGORY/{category}/COLUMN/{column}/POSITION/{position}") public Status removeColumn(@PathParam("queryname") String sessionId,@PathParam("category") String category,@PathParam("column") String businessColumn,@PathParam("position") Integer position){
  if (log.isDebugEnabled()) {
    log.debug("REST:DELETE " + sessionId + " removeColumn position="+ position+ " category="+ category+ " column="+ businessColumn);
  }
  try {
    editorService.removeColumn(sessionId,category,businessColumn,position);
    return Status.OK;
  }
 catch (  Exception e) {
    log.error("Cannot remove column " + businessColumn + " from query ("+ sessionId+ ")",e);
    return Status.INTERNAL_SERVER_ERROR;
  }
}
 

Example 37

From project security_1, under directory /security-rest/security-rest-api/src/main/java/org/sonatype/security/rest/privileges/.

Source file: PrivilegePlexusResource.java

  19 
vote

/** 
 * Removes a security privilege.
 * @param privilegeId The Id of the privilege to be removed.
 */
@Override @DELETE @ResourceMethodSignature(pathParams={@PathParam("privilegeId")}) public void delete(Context context,Request request,Response response) throws ResourceException {
  Privilege priv;
  try {
    AuthorizationManager authzManager=getSecuritySystem().getAuthorizationManager(PRIVILEGE_SOURCE);
    priv=authzManager.getPrivilege(getPrivilegeId(request));
    if (priv.getType().equals(ApplicationPrivilegeDescriptor.TYPE)) {
      throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST,"Cannot delete an application type privilege");
    }
 else {
      authzManager.deletePrivilege(getPrivilegeId(request));
    }
  }
 catch (  NoSuchPrivilegeException e) {
    throw new ResourceException(Status.CLIENT_ERROR_NOT_FOUND,e.getMessage());
  }
catch (  NoSuchAuthorizationManagerException e) {
    this.getLogger().warn("Could not found AuthorizationManager: " + PRIVILEGE_SOURCE,e);
    throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST,"Authorization Manager for: " + PRIVILEGE_SOURCE + " could not be found.");
  }
}
 

Example 38

From project service-discovery, under directory /server/src/main/java/com/nesscomputing/service/discovery/server/resources/.

Source file: StaticAnnouncementResource.java

  19 
vote

@DELETE @Path("/{id}") public Response deleteStaticAnnouncement(@PathParam("id") final UUID serviceId){
  final ServiceInformation victim=findStaticAnnouncement(serviceId);
  if (victim == null) {
    return Response.status(Status.NOT_FOUND).build();
  }
  discoveryClient.unannounce(victim);
  return Response.noContent().build();
}
 

Example 39

From project servicemix4-features, under directory /examples/cxf/cxf-jaxrs/src/main/java/org/apache/servicemix/examples/cxf/jaxrs/.

Source file: CustomerService.java

  19 
vote

@DELETE @Path("/customers/{id}/") public Response deleteCustomer(@PathParam("id") String id){
  System.out.println("----invoking deleteCustomer, Customer id is: " + id);
  long idNumber=Long.parseLong(id);
  Customer c=customers.get(idNumber);
  Response r;
  if (c != null) {
    r=Response.ok().build();
    customers.remove(idNumber);
  }
 else {
    r=Response.notModified().build();
  }
  return r;
}
 

Example 40

From project smart-cms, under directory /webservice-modules/webservice-resources/src/main/java/com/smartitengineering/cms/ws/resources/content/.

Source file: ContentResource.java

  19 
vote

@DELETE public Response delete(@HeaderParam(HttpHeaders.IF_MATCH) EntityTag etag){
  LOGGER.info("Deleting a content");
  if (content == null) {
    throw new WebApplicationException(Response.Status.NOT_FOUND);
  }
  if (etag == null) {
    return Response.status(Response.Status.PRECONDITION_FAILED).build();
  }
  ResponseBuilder builder=getContext().getRequest().evaluatePreconditions(tag);
  if (builder == null) {
    WriteableContent writeableContent=SmartContentAPI.getInstance().getContentLoader().getWritableContent(content);
    try {
      writeableContent.delete();
      builder=Response.ok();
    }
 catch (    Exception ex) {
      LOGGER.error("Could not delete due to server error!",ex);
      builder=Response.serverError();
    }
  }
  return builder.build();
}
 

Example 41

From project social, under directory /component/service/src/main/java/org/exoplatform/social/service/rest/api/.

Source file: ActivityResources.java

  19 
vote

/** 
 * Delete an existing activity by its Id using the DELETE method. The deleted activity information will be returned in the JSON format.
 * @param uriInfo the uri request uri
 * @param portalContainerName The associated portal container name.
 * @param activityId The specified activity Id.
 * @param format The expected returned format.
 * @anchor SOCref.DevelopersReferences.RestService_APIs_v1alpha3.ActivityResource.Activity.Delete
 * @authentication
 * @request {code} DELETE: http://localhost:8080/rest/private/api/social/v1-alpha3/portal/activity/1a2b3c4d5e6f7g8h9i.json {code}
 * @response {code:json} { "id": "1a2b3c4d5e6f7g8h9j", "title": "Hello World!!!", "appId": "", "type": "exosocial:core", "postedTime": 123456789, //timestamp "createdAt": "Fri Jun 17 06:42:26 +0000 2011", //The Date follows ISO 8601 "priority": 0.5, //between 0.0 and 1.0, higher value => higher priority. "templateParams": {}, "titleId": "", "identityId": "123456789abcdefghi", //the identity id of the user who created this activity "liked": true, //is liked (favorites) by this authenticated identity "likedByIdentities": ["identityId1", "identityId2"], "posterIdentity": {}, //optional "comments": [{}, {}, {}], //optional "totalNumberOfComments": 1234, //if comments is required, the total number of comments "activityStream": { "type": "user", // or "space" "prettyId": "root", // or space_abcde "faviconURL": "http://demo3.exoplatform.org/favicons/exo-default.jpg", "title": "Activity Stream of Root Root", "permaLink": "http://localhost:8080/profile/root" } //optional } {code}
 * @return a response object
 */
@DELETE @Path("activity/{activityId}.{format}") @Produces(MediaType.APPLICATION_JSON) public Response deleteExistingActivityById(@Context UriInfo uriInfo,@PathParam("portalContainerName") String portalContainerName,@PathParam("activityId") String activityId,@PathParam("format") String format){
  RestChecker.checkAuthenticatedRequest();
  PortalContainer portalContainer=RestChecker.checkValidPortalContainerName(portalContainerName);
  MediaType mediaType=RestChecker.checkSupportedFormat(format,SUPPORTED_FORMAT);
  Identity authenticatedUserIdentity=Util.getAuthenticatedUserIdentity(portalContainerName);
  ActivityManager activityManager=Util.getActivityManager(portalContainerName);
  ExoSocialActivity existingActivity=null;
  try {
    existingActivity=activityManager.getActivity(activityId);
  }
 catch (  UndeclaredThrowableException undeclaredThrowableException) {
    if (undeclaredThrowableException.getCause() instanceof ActivityStorageException) {
      throw new WebApplicationException(Response.Status.NOT_FOUND);
    }
 else {
      throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
    }
  }
  if (!SecurityManager.canDeleteActivity(portalContainer,authenticatedUserIdentity,existingActivity)) {
    throw new WebApplicationException(Response.Status.FORBIDDEN);
  }
  activityManager.deleteActivity(existingActivity);
  HashMap<String,String> resultJson=new HashMap<String,String>();
  resultJson.put("id",existingActivity.getId());
  return Util.getResponse(resultJson,uriInfo,mediaType,Response.Status.OK);
}
 

Example 42

From project SOCIETIES-SCE-Services, under directory /3rdPartyServices/DisasterManagement/YouRNotAlone/src/main/java/org/societies/thirdPartyServices/disaster/youRNotAloneServer/.

Source file: VolunteerServer.java

  19 
vote

@DELETE public Response deleteVolunteer(){
  Response res;
  Volunteer v=YouRNotAloneDAO.instance.getVO().getVolunteers().remove(id);
  if (v == null) {
    res=Response.noContent().build();
    throw new RuntimeException("Delete: Todo with " + id + " not found");
  }
 else   res=Response.ok().build();
  return res;
}
 

Example 43

From project templeton, under directory /src/java/org/apache/hcatalog/templeton/.

Source file: Server.java

  19 
vote

/** 
 * Drop an hcat table.
 */
@DELETE @Path("ddl/database/{db}/table/{table}") @Produces(MediaType.APPLICATION_JSON) public Response dropTable(@PathParam("db") String db,@PathParam("table") String table,@QueryParam("ifExists") boolean ifExists,@QueryParam("group") String group,@QueryParam("permissions") String permissions) throws HcatException, NotAuthorizedException, BusyException, BadParam, ExecuteException, IOException {
  verifyUser();
  verifyDdlParam(db,":db");
  verifyDdlParam(table,":table");
  HcatDelegator d=new HcatDelegator(appConf,execService);
  return d.dropTable(getUser(),db,table,ifExists,group,permissions);
}
 

Example 44

From project usergrid-stack, under directory /rest/src/main/java/org/usergrid/rest/applications/queues/.

Source file: QueueSubscriberResource.java

  19 
vote

@DELETE public JSONWithPadding executeDelete(@Context UriInfo ui,@QueryParam("callback") @DefaultValue("callback") String callback) throws Exception {
  logger.info("QueueSubscriberResource.executeDelete: " + queuePath);
  if (StringUtils.isNotBlank(subscriberPath)) {
    return new JSONWithPadding(mq.unsubscribeFromQueue(queuePath,subscriberPath),callback);
  }
  return null;
}
 

Example 45

From project ws, under directory /exo.ws.rest.ext/src/main/java/org/exoplatform/services/rest/ext/proxy/.

Source file: ProxyService.java

  19 
vote

@DELETE public Response doProxyDelete(@Context HttpHeaders headers,@Context UriInfo uriInfo,@QueryParam("url") String urlParam){
  if (urlParam == null) {
    IllegalArgumentException e=new IllegalArgumentException("'url' parameter not found in proxy request");
    throw new WebApplicationException(e,createErrorResponse(e,404));
  }
  try {
    URL url=new URL(urlParam);
    HTTPConnection conn=new HTTPConnection(url);
    conn.setTimeout(DEFAULT_CONNECT_TIMEOUT_MS);
    NVPair[] headerPairs=toNVPair(headers.getRequestHeaders(),Collections.singleton(new CaseInsensitiveStringWrapper(HttpHeaders.HOST)));
    conn.setAllowUserInteraction(false);
    NVPair credentials=getCredentials(url);
    if (credentials != null) {
      conn.addBasicAuthorization(null,credentials.getName(),credentials.getValue());
    }
    HTTPResponse resp=conn.Delete(url.getFile(),headerPairs);
    if (resp.getStatusCode() >= 300) {
      if (LOG.isDebugEnabled()) {
        LOG.debug("DELETE. received status " + resp.getStatusCode() + ", "+ resp.getReasonLine());
        byte[] data=resp.getData();
        if (data != null) {
          LOG.debug("DELETE. Text : " + new String(data));
        }
      }
    }
    return createResponse(resp);
  }
 catch (  MalformedURLException mue) {
    throw new WebApplicationException(mue,createErrorResponse(mue,400));
  }
catch (  ProtocolNotSuppException pnse) {
    throw new WebApplicationException(pnse,createErrorResponse(pnse,400));
  }
catch (  IOException ioe) {
    throw new WebApplicationException(ioe,createErrorResponse(ioe,500));
  }
catch (  ModuleException me) {
    throw new WebApplicationException(me,createErrorResponse(me,500));
  }
}
 

Example 46

From project zanata, under directory /zanata-war/src/main/java/org/zanata/rest/service/.

Source file: GlossaryService.java

  19 
vote

/** 
 * Delete all glossary terms with the specified locale.
 * @param targetLocale The target locale to delete glossary entries from.
 * @return The following response status codes will be returned from thisoperation:<br> OK(200) - If the glossary entries were successfully deleted. UNAUTHORIZED(401) - If the user does not have the proper permissions to perform this operation.<br> INTERNAL SERVER ERROR(500) - If there is an unexpected error in the server while performing this operation.
 */
@Override @DELETE @Path("/{locale}") @Restrict("#{s:hasPermission('', 'glossary-delete')}") public Response deleteGlossary(@PathParam("locale") LocaleId targetLocale){
  ResponseBuilder response=request.evaluatePreconditions();
  if (response != null) {
    return response.build();
  }
  int rowCount=glossaryDAO.deleteAllEntries(targetLocale);
  log.info("Glossary delete (" + targetLocale + "): "+ rowCount);
  return Response.ok().build();
}
 

Example 47

From project zen-project, under directory /zen-webservice/src/main/java/com/nominanuda/hyperapi/.

Source file: HyperApiIntrospector.java

  19 
vote

public @Nullable Annotation findHttpMethod(Method method){
  Annotation[] methodAnnotations=method.getAnnotations();
  for (  Annotation a : methodAnnotations) {
    if (a instanceof GET || a instanceof POST || a instanceof PUT|| a instanceof DELETE) {
      return a;
    }
  }
  return null;
}
 

Example 48

From project zk-service-registry-server, under directory /lib/zk-service-registry-server/zookeeper-3.3.3/src/contrib/rest/src/java/org/apache/zookeeper/server/jersey/resources/.

Source file: ZNodeResource.java

  19 
vote

@DELETE @Produces({MediaType.APPLICATION_JSON,"application/javascript",MediaType.APPLICATION_XML,MediaType.APPLICATION_OCTET_STREAM}) public void deleteZNode(@PathParam("path") String path,@DefaultValue("-1") @QueryParam("version") String versionParam,@Context UriInfo ui) throws InterruptedException, KeeperException {
  ensurePathNotNull(path);
  int version;
  try {
    version=Integer.parseInt(versionParam);
  }
 catch (  NumberFormatException e) {
    throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST).entity(new ZError(ui.getRequestUri().toString(),path + " bad version " + versionParam)).build());
  }
  zk.delete(path,version);
}
 

Example 49

From project zookeeper, under directory /src/contrib/rest/src/java/org/apache/zookeeper/server/jersey/resources/.

Source file: ZNodeResource.java

  19 
vote

@DELETE @Produces({MediaType.APPLICATION_JSON,"application/javascript",MediaType.APPLICATION_XML,MediaType.APPLICATION_OCTET_STREAM}) public void deleteZNode(@PathParam("path") String path,@DefaultValue("-1") @QueryParam("version") String versionParam,@Context UriInfo ui) throws InterruptedException, KeeperException {
  ensurePathNotNull(path);
  int version;
  try {
    version=Integer.parseInt(versionParam);
  }
 catch (  NumberFormatException e) {
    throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST).entity(new ZError(ui.getRequestUri().toString(),path + " bad version " + versionParam)).build());
  }
  zk.delete(path,version);
}