本文整理匯總了Java中org.restlet.resource.Get類的典型用法代碼示例。如果您正苦於以下問題:Java Get類的具體用法?Java Get怎麽用?Java Get使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Get類屬於org.restlet.resource包,在下文中一共展示了Get類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: request
import org.restlet.resource.Get; //導入依賴的package包/類
@Get("json")
public String request(final String entity)
{
try
{
final JSONObject answer = new JSONObject();
answer.put("version", RevisionHelper.getVerboseRevision());
answer.put("system_UUID", getSetting("system_UUID",""));
final Series<Parameter> ctxParams = getContext().getParameters();
final String hostId = ctxParams.getFirstValue("HOST_ID");
if (hostId != null)
answer.put("host",hostId);
return answer.toString();
}
catch (JSONException e)
{
e.printStackTrace();
return null;
}
}
示例2: request
import org.restlet.resource.Get; //導入依賴的package包/類
@Get("json")
public String request(final String entity)
{
addAllowOrigin();
try
{
final JSONObject answer = new JSONObject();
answer.put("version", RevisionHelper.getVerboseRevision());
answer.put("system_UUID", getSetting("system_UUID",""));
final Series<Parameter> ctxParams = getContext().getParameters();
final String hostId = ctxParams.getFirstValue("HOST_ID");
if (hostId != null)
answer.put("host",hostId);
return answer.toString();
}
catch (JSONException e)
{
e.printStackTrace();
return null;
}
}
示例3: request
import org.restlet.resource.Get; //導入依賴的package包/類
@Get("json")
public String request(final String entity) throws JSONException
{
QueryParser qp = new QueryParser();
Form parameters = getRequest().getResourceRef().getQueryAsForm();
qp.parseQuery(parameters);
List<String> fields = Arrays.asList(new String[]{"country_geoip"});
final JSONObject answer = new JSONObject();
final JSONArray countries = new JSONArray(queryDB("upper(msim.country)", "t.mobile_network_id", "mccmnc2name msim ON msim.uid", qp));
final JSONArray provider = new JSONArray(queryDB("mprov.name", "t.mobile_provider_id", "provider mprov ON mprov.uid", qp));
final JSONArray providerN = new JSONArray(queryDB("prov.name", "t.provider_id", "provider prov ON prov.uid", qp));
answer.put("country_mobile", countries);
answer.put("provider_mobile", provider);
answer.put("provider", providerN);
return answer.toString();
}
示例4: handleApiQuery
import org.restlet.resource.Get; //導入依賴的package包/類
@Get("json")
public CumulativeTimeBucket handleApiQuery() {
IPktInProcessingTimeService pktinProcTime =
(IPktInProcessingTimeService)getContext().getAttributes().
get(IPktInProcessingTimeService.class.getCanonicalName());
setStatus(Status.SUCCESS_OK, "OK");
// If the user is requesting this they must think that it is enabled,
// so lets enable it to prevent from erroring out
if (!pktinProcTime.isEnabled()){
pktinProcTime.setEnabled(true);
logger.warn("Requesting performance monitor data when performance monitor is disabled. Turning it on");
}
// Allocate output object
if (pktinProcTime.isEnabled()) {
CumulativeTimeBucket ctb = pktinProcTime.getCtb();
ctb.computeAverages();
return ctb;
}
return null;
}
示例5: retrieve
import org.restlet.resource.Get; //導入依賴的package包/類
@Get("json")
public String retrieve() {
IPktInProcessingTimeService pktinProcTime =
(IPktInProcessingTimeService)getContext().getAttributes().
get(IPktInProcessingTimeService.class.getCanonicalName());
String param = ((String)getRequestAttributes().get("perfmonstate")).toLowerCase();
if (param.equals("reset")) {
// We cannot reset something that is disabled, so enable it first.
if(!pktinProcTime.isEnabled()){
pktinProcTime.setEnabled(true);
}
pktinProcTime.getCtb().reset();
} else {
if (param.equals("enable") || param.equals("true")) {
pktinProcTime.setEnabled(true);
} else if (param.equals("disable") || param.equals("false")) {
pktinProcTime.setEnabled(false);
}
}
setStatus(Status.SUCCESS_OK, "OK");
return "{ \"enabled\" : " + pktinProcTime.isEnabled() + " }";
}
示例6: hasNext
import org.restlet.resource.Get; //導入依賴的package包/類
@Get("json")
public Iterator<Entity[]> getDeviceEntities() {
final Iterator<? extends IDevice> devices = super.getDevices();
return new Iterator<Entity[]>() {
@Override
public boolean hasNext() {
return devices.hasNext();
}
@Override
public Entity[] next() {
Device d = (Device)devices.next();
return d.getEntities();
}
@Override
public void remove() {
throw new UnsupportedOperationException();
}
};
}
示例7: retrieve
import org.restlet.resource.Get; //導入依賴的package包/類
@Get("json")
public Set<LinkWithType> retrieve() {
ILinkDiscoveryService ld = (ILinkDiscoveryService)getContext().getAttributes().
get(ILinkDiscoveryService.class.getCanonicalName());
Map<Link, LinkInfo> links = new HashMap<Link, LinkInfo>();
Set<LinkWithType> returnLinkSet = new HashSet<LinkWithType>();
if (ld != null) {
links.putAll(ld.getLinks());
for (Link link: links.keySet()) {
LinkInfo info = links.get(link);
LinkType type = ld.getLinkType(link, info);
if (type == LinkType.DIRECT_LINK || type == LinkType.TUNNEL) {
LinkWithType lwt = new LinkWithType(link,
type,LinkDirection.UNIDIRECTIONAL);
returnLinkSet.add(lwt);
}
}
}
return returnLinkSet;
}
示例8: ListStaticFlowEntries
import org.restlet.resource.Get; //導入依賴的package包/類
@Get("json")
public OFFlowModMap ListStaticFlowEntries() {
IStaticFlowEntryPusherService sfpService =
(IStaticFlowEntryPusherService)getContext().getAttributes().
get(IStaticFlowEntryPusherService.class.getCanonicalName());
String param = (String) getRequestAttributes().get("switch");
if (log.isDebugEnabled())
log.debug("Listing all static flow entires for switch: " + param);
if (param.toLowerCase().equals("all")) {
return new OFFlowModMap(sfpService.getFlows());
} else {
try {
Map<String, Map<String, OFFlowMod>> retMap = new HashMap<String, Map<String, OFFlowMod>>();
retMap.put(param, sfpService.getFlows(DatapathId.of(param)));
return new OFFlowModMap(retMap);
} catch (NumberFormatException e){
setStatus(Status.CLIENT_ERROR_BAD_REQUEST, ControllerSwitchesResource.DPID_ERROR);
}
}
return null;
}
示例9: ClearStaticFlowEntries
import org.restlet.resource.Get; //導入依賴的package包/類
@Get("json")
public String ClearStaticFlowEntries() {
IStaticFlowEntryPusherService sfpService =
(IStaticFlowEntryPusherService)getContext().getAttributes().
get(IStaticFlowEntryPusherService.class.getCanonicalName());
String param = (String) getRequestAttributes().get("switch");
if (log.isDebugEnabled())
log.debug("Clearing all static flow entires for switch: " + param);
if (param.toLowerCase().equals("all")) {
sfpService.deleteAllFlows();
return "{\"status\":\"Deleted all flows.\"}";
} else {
try {
sfpService.deleteFlowsForSwitch(DatapathId.of(param));
return "{\"status\":\"Deleted all flows for switch " + param + ".\"}";
} catch (NumberFormatException e){
setStatus(Status.CLIENT_ERROR_BAD_REQUEST,
ControllerSwitchesResource.DPID_ERROR);
return "'{\"status\":\"Could not delete flows requested! See controller log for details.\"}'";
}
}
}
示例10: getMeters
import org.restlet.resource.Get; //導入依賴的package包/類
@Get("json")
@SuppressWarnings("unchecked")
public Map<Long, Object> getMeters() {
Map<Long, Object> response = new HashMap<>();
String switchId = (String) this.getRequestAttributes().get("switch_id");
logger.debug("Get meters for switch: {}", switchId);
ISwitchManager switchManager = (ISwitchManager) getContext().getAttributes()
.get(ISwitchManager.class.getCanonicalName());
try {
OFMeterConfigStatsReply replay = switchManager.dumpMeters(DatapathId.of(switchId));
logger.debug("Meters from switch {} received: {}", switchId, replay);
if (replay != null) {
for (OFMeterConfig entry : replay.getEntries()) {
response.put(entry.getMeterId(), entry);
}
}
} catch (IllegalArgumentException exception) {
String messageString = "No such switch";
logger.error("{}: {}", messageString, switchId, exception);
MessageError responseMessage = new MessageError(DEFAULT_CORRELATION_ID, System.currentTimeMillis(),
ErrorType.PARAMETERS_INVALID.toString(), messageString, exception.getMessage());
response.putAll(MAPPER.convertValue(responseMessage, Map.class));
}
return response;
}
示例11: getFlows
import org.restlet.resource.Get; //導入依賴的package包/類
@Get("json")
@SuppressWarnings("unchecked")
public Map<String, Object> getFlows() {
Map<String, Object> response = new HashMap<>();
String switchId = (String) this.getRequestAttributes().get("switch_id");
logger.debug("Get flows for switch: {}", switchId);
ISwitchManager switchManager = (ISwitchManager) getContext().getAttributes()
.get(ISwitchManager.class.getCanonicalName());
try {
OFFlowStatsReply replay = switchManager.dumpFlowTable(DatapathId.of(switchId));
logger.debug("OF_STATS: {}", replay);
if (replay != null) {
for (OFFlowStatsEntry entry : replay.getEntries()) {
String key = String.format("flow-0x%s",
Long.toHexString(entry.getCookie().getValue()).toUpperCase());
response.put(key, buildFlowStat(entry));
}
}
} catch (IllegalArgumentException exception) {
String messageString = "No such switch";
logger.error("{}: {}", messageString, switchId, exception);
MessageError responseMessage = new MessageError(DEFAULT_CORRELATION_ID, System.currentTimeMillis(),
ErrorType.PARAMETERS_INVALID.toString(), messageString, exception.getMessage());
response.putAll(MAPPER.convertValue(responseMessage, Map.class));
}
return response;
}
示例12: getEvents
import org.restlet.resource.Get; //導入依賴的package包/類
@Get
public List<AccountEventBean> getEvents() throws SQLException {
String statusStr = getQuery().getFirstValue("status");
UserStatus status = UserStatus.VALIDATED;
try {
if (statusStr != null) status = UserStatus.valueOf(statusStr);
} catch (Exception e) {}
return statusStr == null ? mEvents.getEventsForAccount(((AccountBean) getRequest().getAttributes().get("account")).getTwitchId())
: mEvents.getEventsForAccountAndStatus(((AccountBean) getRequest().getAttributes().get("account")).getTwitchId(), status);
}
示例13: retrieve
import org.restlet.resource.Get; //導入依賴的package包/類
@Get("json")
public Set<DatapathIDJsonSerializerWrapper> retrieve(){
IOFSwitchService switchService =
(IOFSwitchService) getContext().getAttributes().
get(IOFSwitchService.class.getCanonicalName());
Set<DatapathIDJsonSerializerWrapper> dpidSets = new HashSet<DatapathIDJsonSerializerWrapper>();
for(IOFSwitch sw: switchService.getAllSwitchMap().values()) {
dpidSets.add(new DatapathIDJsonSerializerWrapper(sw.getId(), sw.getInetAddress().toString(), sw.getConnectedSince().getTime()));
}
return dpidSets;
}
示例14: getUser
import org.restlet.resource.Get; //導入依賴的package包/類
@Get
public UserRepresentation getUser() throws SQLException {
AccountStatusBean bean = mEvents.getRegistered(mEventId, mUserId);
if (bean == null) throw new NotFoundException("USER_NOT_REGISTERED");
Object obj = getRequest().getAttributes().get("account");
boolean isModerator = obj == null ? false : ((AccountBean) obj).getGrade() >= ApiV1.MODERATOR;
return isModerator ? new UserRepresentation(bean.getTwitchId(), bean.getViews(), bean.getFollowers(), bean.getGrade(), bean.getUsername(), bean.getEmail(), bean.getUrl(), bean.getLogo(), bean.getBroadcasterType(), bean.status)
: new UserRepresentation(bean.getTwitchId(), bean.getViews(), bean.getFollowers(), bean.getGrade(), bean.getUsername(), null, bean.getUrl(), bean.getLogo(), null, bean.status);
}
示例15: validateEmail
import org.restlet.resource.Get; //導入依賴的package包/類
@Get
public Status validateEmail() throws SQLException {
String code = getQuery().getValues("code");
if (code == null) throw new BadEntityException("CODE_NOT_FOUND");
AccountBean bean = mAccounts.getFromValidationCode(code);
if (bean != null) {
if (bean.getGrade() != 0) throw new ConflictException("CODE_ALREADY_VALIDATED");
bean.setGrade(ApiV1.USER);
mAccounts.update(bean);
} else throw new NotFoundException("CODE_UNKNOWN");
return Status.SUCCESS_OK;
}