当前位置: 首页>>代码示例>>Java>>正文


Java Delete类代码示例

本文整理汇总了Java中org.restlet.resource.Delete的典型用法代码示例。如果您正苦于以下问题:Java Delete类的具体用法?Java Delete怎么用?Java Delete使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Delete类属于org.restlet.resource包,在下文中一共展示了Delete类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: del

import org.restlet.resource.Delete; //导入依赖的package包/类
@Delete
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\"}";
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:23,代码来源:StaticFlowEntryPusherResource.java

示例2: del

import org.restlet.resource.Delete; //导入依赖的package包/类
@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\"}";
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:27,代码来源:StaticFlowEntryPusherResource.java

示例3: del

import org.restlet.resource.Delete; //导入依赖的package包/类
@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\"}";
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:27,代码来源:StaticFlowEntryPusherResource.java

示例4: delete

import org.restlet.resource.Delete; //导入依赖的package包/类
@Override
@Delete
public Representation delete() {
  final String topicName = (String) getRequest().getAttributes().get("topicName");
  if (_autoTopicWhitelistingManager != null) {
    _autoTopicWhitelistingManager.addIntoBlacklist(topicName);
  }
  if (!_helixMirrorMakerManager.isTopicExisted(topicName)) {
    getResponse().setStatus(Status.CLIENT_ERROR_NOT_FOUND);
    return new StringRepresentation(
        String.format("Failed to delete not existed topic: %s", topicName));
  }
  try {
    _helixMirrorMakerManager.deleteTopicInMirrorMaker(topicName);
    return new StringRepresentation(
        String.format("Successfully finished delete topic: %s", topicName));
  } catch (Exception e) {
    getResponse().setStatus(Status.SERVER_ERROR_INTERNAL);
    LOGGER.error("Failed to delete topic: {}, with exception: {}", topicName, e);
    return new StringRepresentation(
        String.format("Failed to delete topic: %s, with exception: %s", topicName, e));
  }
}
 
开发者ID:uber,项目名称:uReplicator,代码行数:24,代码来源:TopicManagementRestletResource.java

示例5: removeDescription

import org.restlet.resource.Delete; //导入依赖的package包/类
@Delete
public Representation removeDescription() throws JAXBException, ResourceException, IOException {
    
    String acceptType = "";
    int size = getClientInfo().getAcceptedMediaTypes().size();
    if (size > 0) {
        acceptType = getClientInfo().getAcceptedMediaTypes().get(0).getMetadata().getSubType();
    }
    else acceptType = MediaType.APPLICATION_JSON.getSubType();

    String subsId = (String) getRequest().getAttributes().get("subscriptionID");
    System.out.println("CO 10: DELETE AVAILABILITY SUBSCRIPTION: subscriptionId = '" + subsId + "'");
    
    UnsubscribeContextAvailabilityRequest ucar = new UnsubscribeContextAvailabilityRequest();
    ucar.setSubscriptionId(subsId);        
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.enable(SerializationFeature.INDENT_OUTPUT);
    InputStream stream = new ByteArrayInputStream(objectMapper.writeValueAsBytes(ucar));

    Resource05_AvailabilitySubscriptionDeletion ras = new Resource05_AvailabilitySubscriptionDeletion();
    StringRepresentation result = ras.unsubscribeJsonHandler(stream, acceptType);
    return result;

}
 
开发者ID:UniSurreyIoT,项目名称:fiware-iot-discovery-ngsi9,代码行数:25,代码来源:Resource10_AvailabilitySubscription.java

示例6: delete

import org.restlet.resource.Delete; //导入依赖的package包/类
/**
 * URI Mappings:
 * - "/segments/{tableName}/{segmentName}", "/segments/{tableName}/{segmentName}/":
 *   Delete the specified segment from the specified table.
 *
 * - "/segments/{tableName}/", "/segments/{tableName}":
 *   Delete all the segments from the specified table.
 *
 * {@inheritDoc}
 * @see org.restlet.resource.ServerResource#delete()
 */
@Override
@Delete
public Representation delete() {
  Representation rep;
  try {
    final String tableName = (String) getRequest().getAttributes().get("tableName");
    final String segmentName = (String) getRequest().getAttributes().get("segmentName");

    LOGGER.info("Getting segment deletion request, tableName: " + tableName + " segmentName: " + segmentName);
    rep = deleteSegment(tableName, segmentName);
  } catch (final Exception e) {
    rep = exceptionToStringRepresentation(e);
    LOGGER.error("Caught exception while processing delete request", e);
    setStatus(Status.SERVER_ERROR_INTERNAL);
  }
  return rep;
}
 
开发者ID:Hanmourang,项目名称:Pinot,代码行数:29,代码来源:PinotSegmentUploadRestletResource.java

示例7: deleteLease

import org.restlet.resource.Delete; //导入依赖的package包/类
@Delete
public Representation deleteLease(Map<String, String> data) {
    try {
        if (data.containsKey("user")) {
            int ipVersion = Integer.parseInt(data.get("version"));
            List<IPAddress> addrs = IPAddresses.forClient(Clients.dao.queryForId(data.get("client")), ipVersion);
            for (IPAddress addr : addrs) {
                addr.client = Clients.NONE;
                IPAddresses.dao.update(addr);
            }
        } else {
            if (!getRequestAttributes().containsKey("id"))
                return clientError("INVALID_REQUEST", Status.CLIENT_ERROR_BAD_REQUEST);
            IPAddress ipAddress = IPAddresses.dao.queryForId(getAttribute("id"));
            ipAddress.client = null;
            ipAddress.connection = null;
            IPAddresses.dao.update(ipAddress);
        }
    } catch (SQLException ex) {
        Logger.getLogger(getClass()).error("Failed to modify address lease", ex);
    }

    return error();
}
 
开发者ID:Neutrinet,项目名称:ISP-ng,代码行数:25,代码来源:AddressLease.java

示例8: delete

import org.restlet.resource.Delete; //导入依赖的package包/类
@Delete
public Representation delete() {
    try {
        if (!getRequestAttributes().containsKey("client"))
            return clientError("MALFORMED_REQUEST", Status.CLIENT_ERROR_BAD_REQUEST);

        Client c = Clients.dao.queryForId(getAttribute("client"));
        if (!Policy.get().canModify(getSessionToken().get().getUser(), c)) {
            return clientError("FORBIDDEN", Status.CLIENT_ERROR_BAD_REQUEST);
        }
        Clients.dao.delete(c);

        return DEFAULT_SUCCESS;
    } catch (Exception ex) {
        Logger.getLogger(getClass()).error("Failed to delete client", ex);
    }

    return clientError("UNKNOWN_ERROR", Status.SERVER_ERROR_INTERNAL);
}
 
开发者ID:Neutrinet,项目名称:ISP-ng,代码行数:20,代码来源:VPNClient.java

示例9: deleteLease

import org.restlet.resource.Delete; //导入依赖的package包/类
@Delete
public Representation deleteLease() {
    if (!getRequestAttributes().containsKey("id"))
        return clientError("INVALID_REQUEST", Status.CLIENT_ERROR_BAD_REQUEST);

    try {
        be.neutrinet.ispng.vpn.ip.SubnetLease sl = SubnetLeases.dao.queryForId(getAttribute("id"));
        SubnetLeases.dao.delete(sl);

        if (!getRequestAttributes().containsKey("shallow")) {
            IPSubnets.dao.delete(sl.subnet);
        }

        return new JacksonRepresentation<>(sl);
    } catch (SQLException ex) {
        Logger.getLogger(getClass()).error("Failed to delete subnet lease", ex);
    }

    return DEFAULT_ERROR;
}
 
开发者ID:Neutrinet,项目名称:ISP-ng,代码行数:21,代码来源:SubnetLease.java

示例10: removeConnection

import org.restlet.resource.Delete; //导入依赖的package包/类
@Delete
public Representation removeConnection() {
    String connectionId = getRequestAttributes().get("id").toString();
    if (connectionId == null || connectionId.isEmpty()) {
        return clientError("INVALID_INPUT", Status.CLIENT_ERROR_BAD_REQUEST);
    }

    try {
        List<Connection> connections = Connections.dao.queryForEq("id", connectionId);
        for (Connection c : connections) {
            if (c.active) {
                Manager.get().dropConnection(c);
            }

            Connections.dao.delete(c);
        }
        return DEFAULT_SUCCESS;
    } catch (Exception ex) {
        return clientError("INVALID_INPUT", Status.CLIENT_ERROR_BAD_REQUEST);
    }
}
 
开发者ID:Neutrinet,项目名称:ISP-ng,代码行数:22,代码来源:VPNConnections.java

示例11: deleteKey

import org.restlet.resource.Delete; //导入依赖的package包/类
@Delete
public Representation deleteKey(Map<String, String> data) {
    if (!data.containsKey("email")) {
        return clientError("MALFORMED_REQUEST", Status.CLIENT_ERROR_BAD_REQUEST);
    }

    try {
        List<be.neutrinet.ispng.vpn.admin.UnlockKey> keys = UnlockKeys.dao.queryForEq("email", data.get("email"));

        UnlockKeys.dao.delete(keys);

        return DEFAULT_SUCCESS;
    } catch (Exception ex) {
        Logger.getLogger(getClass()).error("Failed to delete unlock key", ex);
        return DEFAULT_ERROR;
    }
}
 
开发者ID:Neutrinet,项目名称:ISP-ng,代码行数:18,代码来源:UnlockKey.java

示例12: deleteTunnel

import org.restlet.resource.Delete; //导入依赖的package包/类
@Delete("json")
public String deleteTunnel(String tunnelParams) {
    ISegmentRoutingService segmentRoutingService =
            (ISegmentRoutingService) getContext().getAttributes().
                    get(ISegmentRoutingService.class.getCanonicalName());
    ObjectMapper mapper = new ObjectMapper();
    SegmentRouterTunnelRESTParams createParams = null;
    try {
        if (tunnelParams != null) {
            createParams = mapper.readValue(tunnelParams,
                    SegmentRouterTunnelRESTParams.class);
        }
    } catch (IOException ex) {
        log.error("Exception occurred parsing inbound JSON", ex);
        return "fail";
    }
    log.debug("deleteTunnel with Id {}", createParams.getTunnel_id());
    removeTunnelMessages result = segmentRoutingService.removeTunnel(
            createParams.getTunnel_id());
    return result.name()+" "+result.toString();
}
 
开发者ID:opennetworkinglab,项目名称:spring-open,代码行数:22,代码来源:SegmentRouterTunnelResource.java

示例13: deletePolicy

import org.restlet.resource.Delete; //导入依赖的package包/类
@Delete("json")
public String deletePolicy(String policyParams) {
    ISegmentRoutingService segmentRoutingService =
            (ISegmentRoutingService) getContext().getAttributes().
                    get(ISegmentRoutingService.class.getCanonicalName());
    ObjectMapper mapper = new ObjectMapper();
    SegmentRouterPolicyRESTParams createParams = null;
    try {
        if (policyParams != null) {
            createParams = mapper.readValue(policyParams,
                    SegmentRouterPolicyRESTParams.class);
        }
    } catch (IOException ex) {
        log.error("Exception occurred parsing inbound JSON", ex);
        return "fail";
    }

    log.debug("deletePolicy with Id {}", createParams.getPolicy_id());
    boolean result = segmentRoutingService.removePolicy(
            createParams.getPolicy_id());
    return (result == true) ? "deleted" : "fail";
}
 
开发者ID:opennetworkinglab,项目名称:spring-open,代码行数:23,代码来源:SegmentRouterPolicyResource.java

示例14: remove

import org.restlet.resource.Delete; //导入依赖的package包/类
/**
 * Deletes a single high-level intent.
 *
 * @return a null Representation.
 */
@Delete("json")
public Representation remove() {
    IPathCalcRuntimeService pathRuntime =
        (IPathCalcRuntimeService) getContext().getAttributes()
            .get(IPathCalcRuntimeService.class.getCanonicalName());

    String intentId = (String) getRequestAttributes().get("intent-id");
    List<String> intentIds = Arrays.asList(intentId);

    if (pathRuntime.removeApplicationIntents(APPLICATION_ID, intentIds)) {
        setStatus(Status.SUCCESS_NO_CONTENT);
    } else {
        setStatus(Status.SERVER_ERROR_INTERNAL);
    }

    return null;
}
 
开发者ID:opennetworkinglab,项目名称:spring-open,代码行数:23,代码来源:IntentHighObjectResource.java

示例15: deleteGadget

import org.restlet.resource.Delete; //导入依赖的package包/类
/**
 * Deletes the specified gadget from the specified dashboard when invoked as
 * a DELETE request.
 * 
 * @param dashboardId
 *            ID of the dashboard hosting the gadget
 * @param gadgetId
 *            ID of the gadget to remove
 * @param request
 *            the request object (used for providing the locale)
 * @return a {@code Response} with details on the request's success or
 *         failure
 */
@Delete
@AnonymousAllowed
public void deleteGadget() {
	Request request = getRequest();
	Map<String, Object> attrs = request.getAttributes();
	DashboardId dashboardId = DashboardId.valueOf(attrs.get("dashboardId"));
	GadgetId gadgetId = GadgetId.valueOf(attrs.get("gadgetId"));

	final GadgetRequestContext requestContext = gadgetRequestContextFactory.get(request);

	if (!permissionService.isWritableBy(dashboardId, requestContext.getViewer())) {
		log.warn("GadgetResource: DELETE: prevented gadget delete due to insufficient permission");
		getResponse().setStatus(Status.CLIENT_ERROR_UNAUTHORIZED);
		return;
	}

	deleteGadgetHandler.deleteGadget(dashboardId, requestContext, gadgetId, getResponse());
}
 
开发者ID:devacfr,项目名称:spring-restlet,代码行数:32,代码来源:GadgetResource.java


注:本文中的org.restlet.resource.Delete类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。