org.restlet.resource.Delete Java Examples

The following examples show how to use org.restlet.resource.Delete. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ObjectsOidEventsEid.java    From vicinity-gateway-api with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Cancel subscription to the channel.
 * 
 * @return statusMessage {@link StatusMessage StatusMessage} with the result of the operation.
 */
@Delete
public Representation remove(Representation entity) {
	String attrOid = getAttribute(ATTR_OID);
	String attrEid = getAttribute(ATTR_EID);
	String callerOid = getRequest().getChallengeResponse().getIdentifier();
	Map<String, String> queryParams = getQuery().getValuesMap();
	
	Logger logger = (Logger) getContext().getAttributes().get(Api.CONTEXT_LOGGER);
	
	if (attrEid == null){
		logger.info("EID: " + attrEid + " Given identifier does not exist.");
		throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, 
				"Invalid identifier.");
	}
	
	String body = getRequestBody(entity, logger);
	
	CommunicationManager communicationManager 
					= (CommunicationManager) getContext().getAttributes().get(Api.CONTEXT_COMMMANAGER);
	
	return new JsonRepresentation(communicationManager.unsubscribeFromEventChannel(callerOid, attrOid, attrEid, 
			queryParams, body).buildMessage().toString());
}
 
Example #2
Source File: ObjectsOidActionsAidTasksTid.java    From vicinity-gateway-api with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Deletes the given task to perform an action.
 */
@Delete
public Representation remove(Representation entity) {
	String attrOid = getAttribute(ATTR_OID);
	String attrAid = getAttribute(ATTR_AID);
	String attrTid = getAttribute(ATTR_TID);
	String callerOid = getRequest().getChallengeResponse().getIdentifier();
	Map<String, String> queryParams = getQuery().getValuesMap();
	
	Logger logger = (Logger) getContext().getAttributes().get(Api.CONTEXT_LOGGER);
	
	if (attrOid == null || attrAid == null || attrTid == null){
		logger.info("OID: " + attrOid + " AID: " + attrAid + " TID: " + attrTid 
				+ " Given identifier does not exist.");
		throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, 
				"Given identifier does not exist.");
	}
	
	String body = getRequestBody(entity, logger);
	
	return deleteActionTask(callerOid, attrOid, attrAid, attrTid, queryParams, body);
}
 
Example #3
Source File: PlatformDeletePropertiesResource.java    From scava with Eclipse Public License 2.0 6 votes vote down vote up
@Delete
public Representation deletePlatformProperties() {
	Platform platform = Platform.getInstance();
	
	String key = (String) getRequest().getAttributes().get("key");
	
	System.out.println("Delete platform properties ...");
	
	ProjectRepository projectRepo = platform.getProjectRepositoryManager().getProjectRepository();
	
	Properties properties = projectRepo.getProperties().findOneByKey(key);
	if (properties != null) {
		projectRepo.getProperties().remove(properties);
		platform.getProjectRepositoryManager().getProjectRepository().getProperties().sync();
	}
	
	StringRepresentation rep = new StringRepresentation(properties.getDbObject().toString());
	rep.setMediaType(MediaType.APPLICATION_JSON);
	getResponse().setStatus(Status.SUCCESS_OK);
	return rep;
}
 
Example #4
Source File: MirrorMakerManagerRestletResource.java    From uReplicator with Apache License 2.0 6 votes vote down vote up
@Override
@Delete
public Representation delete() {
  final String instanceName = (String) getRequest().getAttributes().get("instanceName");
  if (instanceName == null) {
    return new StringRepresentation("Instance name is required to blacklist");
  }
  // blacklist a worker
  try {
    _helixMirrorMakerManager.blacklistInstance(instanceName);
    return new StringRepresentation(String.format("Instance %s is blacklisted", instanceName));
  } catch (Exception e) {
    LOGGER.error("Got error during processing Delete request", e);
    getResponse().setStatus(Status.SERVER_ERROR_INTERNAL);
    return new StringRepresentation(String
        .format("Failed to blacklist instance %s, with exception: %s", instanceName, e));
  }
}
 
Example #5
Source File: StaticFlowEntryPusherResource.java    From floodlight_with_topoguard with Apache License 2.0 6 votes vote down vote up
@Delete
@LogMessageDoc(level="ERROR",
    message="Error deleting flow mod request: {request}",
    explanation="An invalid delete request was sent to static flow pusher",
    recommendation="Fix the format of the static flow mod request")
public String del(String fmJson) {
    IStorageSourceService storageSource =
            (IStorageSourceService)getContext().getAttributes().
                get(IStorageSourceService.class.getCanonicalName());
    String fmName = null;
    if (fmJson == null) {
        return "{\"status\" : \"Error! No data posted.\"}";
    }
    try {
        fmName = StaticFlowEntries.getEntryNameFromJson(fmJson);
        if (fmName == null) {
            return "{\"status\" : \"Error deleting entry, no name provided\"}";
        }
    } catch (IOException e) {
        log.error("Error deleting flow mod request: " + fmJson, e);
        return "{\"status\" : \"Error deleting entry, see log for details\"}";
    }

    storageSource.deleteRowAsync(StaticFlowEntryPusher.TABLE_NAME, fmName);
    return "{\"status\" : \"Entry " + fmName + " deleted\"}";
}
 
Example #6
Source File: EventsEid.java    From vicinity-gateway-api with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Used by an Agent/Adapter that is capable of generating events to de-activate an event channel. This will 
 * prohibit any other new objects to subscribe to that channel, and the objects that are already subscribed are 
 * notified and removed from subscription list.
 * 
 * @return statusMessage {@link StatusMessage StatusMessage} with the result of the operation.
 */
@Delete
public Representation remove(Representation entity) {
	String attrEid = getAttribute(ATTR_EID);
	String callerOid = getRequest().getChallengeResponse().getIdentifier();
	Map<String, String> queryParams = getQuery().getValuesMap();
	
	Logger logger = (Logger) getContext().getAttributes().get(Api.CONTEXT_LOGGER);
	
	if (attrEid == null){
		logger.info("EID: " + attrEid + " Invalid identifier.");
		throw new ResourceException(Status.CLIENT_ERROR_NOT_FOUND, 
				"Invalid identifier.");
	}
	
	String body = getRequestBody(entity, logger);
	
	CommunicationManager communicationManager 
					= (CommunicationManager) getContext().getAttributes().get(Api.CONTEXT_COMMMANAGER);
	
	StatusMessage statusMessage = communicationManager.deactivateEventChannel(callerOid, attrEid, queryParams, body);
	
	return new JsonRepresentation(statusMessage.buildMessage().toString());
}
 
Example #7
Source File: PoolsResource.java    From floodlight_with_topoguard with Apache License 2.0 5 votes vote down vote up
@Delete
public int removePool() {
    
    String poolId = (String) getRequestAttributes().get("pool");
           
    ILoadBalancerService lbs =
            (ILoadBalancerService)getContext().getAttributes().
                get(ILoadBalancerService.class.getCanonicalName());

    return lbs.removePool(poolId);
}
 
Example #8
Source File: CalendarRuleResource.java    From FoxBPM with Apache License 2.0 5 votes vote down vote up
@Delete
public String deleteCalendarRule() {
	// 获取参数
	String id = getAttribute("calendarruleId");
	WorkCalendarService workCalendarService = ProcessEngineManagement.getDefaultProcessEngine().getService(WorkCalendarService.class);
	workCalendarService.deleteCalendarRule(id);
	return "SUCCESS";
}
 
Example #9
Source File: CalendarTypeResource.java    From FoxBPM with Apache License 2.0 5 votes vote down vote up
@Delete
public String deleteCalendarType() {
	// 获取参数
	String id = getAttribute("calendartypeId");
	WorkCalendarService workCalendarService = ProcessEngineManagement.getDefaultProcessEngine().getService(WorkCalendarService.class);
	workCalendarService.deleteCalendarType(id);
	return "SUCCESS";
}
 
Example #10
Source File: CalendarPartResource.java    From FoxBPM with Apache License 2.0 5 votes vote down vote up
@Delete
public String deleteCalendarPart() {
	// 获取参数
	String id = getAttribute("calendarpartId");
	WorkCalendarService workCalendarService = ProcessEngineManagement.getDefaultProcessEngine().getService(WorkCalendarService.class);
	workCalendarService.deleteCalendarPart(id);
	return "SUCCESS";
}
 
Example #11
Source File: DeploymentResource.java    From FoxBPM with Apache License 2.0 5 votes vote down vote up
@Delete
public String deleteDeployment(){
	String deploymentId = getAttribute("deploymentId");
	ModelService modelService = FoxBpmUtil.getProcessEngine().getModelService();
	modelService.deleteDeployment(deploymentId);
	return "SUCCESS";
}
 
Example #12
Source File: FirewallRulesResource.java    From floodlight_with_topoguard with Apache License 2.0 5 votes vote down vote up
/**
 * Takes a Firewall Rule string in JSON format and parses it into
 * our firewall rule data structure, then deletes it from the firewall.
 * @param fmJson The Firewall rule entry in JSON format.
 * @return A string status message
 */

@Delete
public String remove(String fmJson) {
    IFirewallService firewall =
            (IFirewallService)getContext().getAttributes().
            get(IFirewallService.class.getCanonicalName());

    FirewallRule rule;
    try {
        rule = jsonToFirewallRule(fmJson);
    } catch (IOException e) {
        log.error("Error parsing firewall rule: " + fmJson, e);
        return "{\"status\" : \"Error! Could not parse firewall rule, see log for details.\"}";
    }
    String status = null;
    boolean exists = false;
    Iterator<FirewallRule> iter = firewall.getRules().iterator();
    while (iter.hasNext()) {
        FirewallRule r = iter.next();
        if (r.ruleid == rule.ruleid) {
            exists = true;
            break;
        }
    }
    if (!exists) {
        status = "Error! Can't delete, a rule with this ID doesn't exist.";
        log.error(status);
    } else {
        // delete rule from firewall
        firewall.deleteRule(rule.ruleid);
        status = "Rule deleted";
    }
    return ("{\"status\" : \"" + status + "\"}");
}
 
Example #13
Source File: MembersResource.java    From floodlight_with_topoguard with Apache License 2.0 5 votes vote down vote up
@Delete
public int removeMember() {
    
    String memberId = (String) getRequestAttributes().get("member");
           
    ILoadBalancerService lbs =
            (ILoadBalancerService)getContext().getAttributes().
                get(ILoadBalancerService.class.getCanonicalName());

    return lbs.removeMember(memberId);
}
 
Example #14
Source File: VipsResource.java    From floodlight_with_topoguard with Apache License 2.0 5 votes vote down vote up
@Delete
public int removeVip() {
    
    String vipId = (String) getRequestAttributes().get("vip");
    
    ILoadBalancerService lbs =
            (ILoadBalancerService)getContext().getAttributes().
                get(ILoadBalancerService.class.getCanonicalName());

    return lbs.removeVip(vipId);
}
 
Example #15
Source File: NoOp.java    From floodlight_with_topoguard with Apache License 2.0 5 votes vote down vote up
/**
 * Does nothing and returns 200 OK with a status message
 * 
 * @return status: ok
 */
@Get
@Put
@Post
@Delete
public String noOp(String postdata) {
    setStatus(Status.SUCCESS_OK);
    return "{\"status\":\"ok\"}";
}
 
Example #16
Source File: HostResource.java    From floodlight_with_topoguard with Apache License 2.0 5 votes vote down vote up
@Delete
public String deleteHost() {
    String port = (String) getRequestAttributes().get("port");
    IVirtualNetworkService vns =
            (IVirtualNetworkService)getContext().getAttributes().
                get(IVirtualNetworkService.class.getCanonicalName());
    vns.deleteHost(null, port);
    setStatus(Status.SUCCESS_OK);
    return "{\"status\":\"ok\"}";
}
 
Example #17
Source File: NetworkResource.java    From floodlight_with_topoguard with Apache License 2.0 5 votes vote down vote up
@Delete
public String deleteNetwork() {
    IVirtualNetworkService vns =
            (IVirtualNetworkService)getContext().getAttributes().
                get(IVirtualNetworkService.class.getCanonicalName());
    String guid = (String) getRequestAttributes().get("network");
    vns.deleteNetwork(guid);
    setStatus(Status.SUCCESS_OK);
    return "{\"status\":\"ok\"}";
}
 
Example #18
Source File: MonitorsResource.java    From floodlight_with_topoguard with Apache License 2.0 5 votes vote down vote up
@Delete
public int removeMonitor() {
    
    String monitorId = (String) getRequestAttributes().get("monitor");
    
    ILoadBalancerService lbs =
            (ILoadBalancerService)getContext().getAttributes().
                get(ILoadBalancerService.class.getCanonicalName());

    return lbs.removeMonitor(monitorId);
}
 
Example #19
Source File: AnalysisDeleteTaskResource.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
@Delete
public Representation deleteAnalysisTask() {
	Platform platform = Platform.getInstance();
	AnalysisTaskService service = platform.getAnalysisRepositoryManager().getTaskService();
	
	String analysisTaskId = getQueryValue("analysisTaskId");

	AnalysisTask task = service.deleteAnalysisTask(analysisTaskId);

	StringRepresentation rep = new StringRepresentation(task.getDbObject().toString());
	rep.setMediaType(MediaType.APPLICATION_JSON);
	getResponse().setStatus(Status.SUCCESS_OK);
	return rep;
}
 
Example #20
Source File: AdminRestletResource.java    From uReplicator with Apache License 2.0 5 votes vote down vote up
@Delete
public Representation delete() {
  final String opt = (String) getRequest().getAttributes().get("opt");
  JSONObject responseJson = new JSONObject();
  if ("worker_number_override".equalsIgnoreCase(opt)) {
    Form queryParams = getRequest().getResourceRef().getQueryAsForm();
    String routeString = queryParams.getFirstValue("route", true);
    if (StringUtils.isEmpty(routeString)) {
      getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
      responseJson.put("status", Status.CLIENT_ERROR_BAD_REQUEST.getCode());
      responseJson.put("message", String.format("missing parameter route"));
    } else {
      if (_helixMirrorMakerManager.getRouteWorkerOverride().containsKey(routeString)) {
        _helixMirrorMakerManager.updateRouteWorkerOverride(routeString, -1);
        responseJson.put("worker_number_override", _helixMirrorMakerManager.getRouteWorkerOverride());
        responseJson.put("status", Status.SUCCESS_OK.getCode());
      } else {
        responseJson.put("message", String.format("route override not exists"));
        responseJson.put("status", Status.SUCCESS_OK.getCode());
      }
    }
  } else {
    LOGGER.info("No valid input!");
    responseJson.put("opt", "No valid input!");
  }
  return new StringRepresentation(responseJson.toJSONString());
}
 
Example #21
Source File: GeoWaveOperationServiceWrapper.java    From geowave with Apache License 2.0 4 votes vote down vote up
@Delete("form|json:json")
public Representation restDelete(final Representation request) throws Exception {
  return handleRequestWithPayload(HttpMethod.DELETE, request);
}
 
Example #22
Source File: TicketGrantingTicketResource.java    From springboot-shiro-cas-mybatis with MIT License 4 votes vote down vote up
/**
 * Removes the TGT.
 */
@Delete
public void removeRepresentations() {
    this.centralAuthenticationService.destroyTicketGrantingTicket(this.ticketGrantingTicketId);
    getResponse().setStatus(Status.SUCCESS_OK);
}
 
Example #23
Source File: TicketGrantingTicketResource.java    From cas4.0.x-server-wechat with Apache License 2.0 4 votes vote down vote up
@Delete
public void removeRepresentations() {
    this.centralAuthenticationService.destroyTicketGrantingTicket(this.ticketGrantingTicketId);
    getResponse().setStatus(Status.SUCCESS_OK);
}
 
Example #24
Source File: TopicResource.java    From ontopia with Apache License 2.0 4 votes vote down vote up
@Delete
public void removeTopic() {
	getController(TopicController.class).remove(resolve());
	store.commit();
}
 
Example #25
Source File: TopicNameResource.java    From ontopia with Apache License 2.0 4 votes vote down vote up
@Delete
public void removeTopicName() {
	getController(TopicNameController.class).remove(resolve());
	store.commit();
}
 
Example #26
Source File: OccurrenceResource.java    From ontopia with Apache License 2.0 4 votes vote down vote up
@Delete
public void removeOccurrence() {
	getController(OccurrenceController.class).remove(resolve());
	store.commit();
}
 
Example #27
Source File: TopicMapResource.java    From ontopia with Apache License 2.0 4 votes vote down vote up
@Delete
public void removeTopicMap() {
	store.close();
	getController(TopicMapController.class).remove(getTopicMapReference());
}
 
Example #28
Source File: AssociationResource.java    From ontopia with Apache License 2.0 4 votes vote down vote up
@Delete
public void removeAssociation() {
	getController(AssociationController.class).remove(resolve());
	store.commit();
}
 
Example #29
Source File: VariantResource.java    From ontopia with Apache License 2.0 4 votes vote down vote up
@Delete
public void removeVariantName() {
	getController(VariantNameController.class).remove(resolve());
	store.commit();
}
 
Example #30
Source File: RoleResource.java    From ontopia with Apache License 2.0 4 votes vote down vote up
@Delete
public void removeAssociationRole() {
	getController(RoleController.class).remove(resolve());
}