本文整理汇总了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\"}";
}
示例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\"}";
}
示例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\"}";
}
示例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));
}
}
示例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;
}
示例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();
}
示例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);
}
示例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;
}
示例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);
}
}
示例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;
}
}
示例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();
}
示例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";
}
示例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;
}
示例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());
}