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


Java Get类代码示例

本文整理汇总了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;
    }
}
 
开发者ID:rtr-nettest,项目名称:open-rmbt,代码行数:22,代码来源:VersionResource.java

示例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;
    }
}
 
开发者ID:rtr-nettest,项目名称:open-rmbt,代码行数:22,代码来源:VersionResource.java

示例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();
}
 
开发者ID:rtr-nettest,项目名称:open-rmbt,代码行数:23,代码来源:ChoicesResource.java

示例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;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:23,代码来源:PerfMonDataResource.java

示例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() + " }";
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:24,代码来源:PerfMonToggleResource.java

示例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();
        }
    };
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:23,代码来源:DeviceEntityResource.java

示例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;
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:22,代码来源:DirectedLinksResource.java

示例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;
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:25,代码来源:ListStaticFlowEntriesResource.java

示例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.\"}'";
        }
    }
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:25,代码来源:ClearStaticFlowEntriesResource.java

示例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;
}
 
开发者ID:telstra,项目名称:open-kilda,代码行数:28,代码来源:MetersResource.java

示例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;
}
 
开发者ID:telstra,项目名称:open-kilda,代码行数:30,代码来源:FlowsResource.java

示例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);
}
 
开发者ID:FightForSub,项目名称:FFS-Api,代码行数:11,代码来源:MeEventsResource.java

示例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;
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:13,代码来源:ControllerSwitchesResource.java

示例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);
}
 
开发者ID:FightForSub,项目名称:FFS-Api,代码行数:12,代码来源:EventUserResource.java

示例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;
}
 
开发者ID:FightForSub,项目名称:FFS-Api,代码行数:13,代码来源:LoginResource.java


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