當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。