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


Java Post类代码示例

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


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

示例1: Info

import org.restlet.resource.Post; //导入依赖的package包/类
@Post
public Map<String, Object> Info(String json) {
	Map<String, Object> ret;
	ObjectMapper mapper = new ObjectMapper();
		try {
			JsonNode root = mapper.readTree(json);

			String addr = root.get("group_addr").asText();
			IMulticastREST mc = (IMulticastREST)getContext().getAttributes().get(IMulticastREST.class.getCanonicalName());
			ret = mc.getGroupInfo(addr);
		} 
		catch (IOException e) {
			e.printStackTrace();
			return new HashMap<String, Object>();
		}

		return ret;
}
 
开发者ID:hexec,项目名称:floodlight-simple-multicast,代码行数:19,代码来源:GroupInfoResource.java

示例2: createEvent

import org.restlet.resource.Post; //导入依赖的package包/类
@Post
public CreatedBean createEvent(EventCreateEntity entity) throws SQLException {
	ValidationUtils.verifyGroup(getRequest(), ApiV1.ADMIN);
	ValidationErrors err = new ValidationErrors();
	
	if (entity == null) throw new BadEntityException("ENTITY_NOT_FOUND");
	
	err.verifyFieldEmptyness("name", entity.name, 3, 200);
	err.verifyFieldEmptyness("description", entity.description, 3, 2048);
	
	err.checkErrors("CREATE_EVENT_ERROR");
	
	EventBean data = new EventBean();
	data.setDescription(entity.description);
	data.setName(entity.name);
	data.setReservedToAffiliates(entity.reserved_to_affiliates);
	data.setReservedToPartners(entity.reserved_to_partners);
	data.setStatus(entity.status);
	data.setMinimumViews(entity.minimum_views);
	data.setMinimumFollowers(entity.minimum_followers);
	
	return new CreatedBean(mEvents.insert(data));
}
 
开发者ID:FightForSub,项目名称:FFS-Api,代码行数:24,代码来源:EventsResource.java

示例3: createMonitor

import org.restlet.resource.Post; //导入依赖的package包/类
@Put
@Post
public LBMonitor createMonitor(String postData) {

    LBMonitor monitor=null;
    try {
        monitor=jsonToMonitor(postData);
    } catch (IOException e) {
        log.error("Could not parse JSON {}", e.getMessage());
    }
    
    ILoadBalancerService lbs =
            (ILoadBalancerService)getContext().getAttributes().
                get(ILoadBalancerService.class.getCanonicalName());
    
    String monitorId = (String) getRequestAttributes().get("monitor");
    if (monitorId != null)
        return lbs.updateMonitor(monitor);
    else
        return lbs.createMonitor(monitor);
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:22,代码来源:MonitorsResource.java

示例4: createVip

import org.restlet.resource.Post; //导入依赖的package包/类
@Put
@Post
public LBVip createVip(String postData) {

    LBVip vip=null;
    try {
        vip=jsonToVip(postData);
    } catch (IOException e) {
        log.error("Could not parse JSON {}", e.getMessage());
    }
    
    ILoadBalancerService lbs =
            (ILoadBalancerService)getContext().getAttributes().
                get(ILoadBalancerService.class.getCanonicalName());
    
    String vipId = (String) getRequestAttributes().get("vip");
    if (vipId != null)
        return lbs.updateVip(vip);
    else
        return lbs.createVip(vip);
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:22,代码来源:VipsResource.java

示例5: createPool

import org.restlet.resource.Post; //导入依赖的package包/类
@Put
@Post
public LBPool createPool(String postData) {        

    LBPool pool=null;
    try {
        pool=jsonToPool(postData);
    } catch (IOException e) {
        log.error("Could not parse JSON {}", e.getMessage());
    }
    
    ILoadBalancerService lbs =
            (ILoadBalancerService)getContext().getAttributes().
                get(ILoadBalancerService.class.getCanonicalName());
    
    String poolId = (String) getRequestAttributes().get("pool");
    if (poolId != null)
        return lbs.updatePool(pool);
    else        
        return lbs.createPool(pool);
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:22,代码来源:PoolsResource.java

示例6: createMember

import org.restlet.resource.Post; //导入依赖的package包/类
@Put
@Post
public LBMember createMember(String postData) {        

    LBMember member=null;
    try {
        member=jsonToMember(postData);
    } catch (IOException e) {
        log.error("Could not parse JSON {}", e.getMessage());
    }
    
    ILoadBalancerService lbs =
            (ILoadBalancerService)getContext().getAttributes().
                get(ILoadBalancerService.class.getCanonicalName());
    
    String memberId = (String) getRequestAttributes().get("member");
    if (memberId != null)
        return lbs.updateMember(member);
    else        
        return lbs.createMember(member);
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:22,代码来源:MembersResource.java

示例7: del

import org.restlet.resource.Post; //导入依赖的package包/类
@Post
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,代码来源:StaticFlowEntryDeleteResource.java

示例8: notify

import org.restlet.resource.Post; //导入依赖的package包/类
@Post("json")
public Map<String,Object> notify(String entity) throws Exception {
    List<StorageSourceNotification> notifications = null;
    ObjectMapper mapper = new ObjectMapper();
    notifications = 
        mapper.readValue(entity, 
                new TypeReference<List<StorageSourceNotification>>(){});
    
    IStorageSourceService storageSource = 
        (IStorageSourceService)getContext().getAttributes().
            get(IStorageSourceService.class.getCanonicalName());
    storageSource.notifyListeners(notifications);
    
    HashMap<String, Object> model = new HashMap<String,Object>();
    model.put("output", "OK");
    return model;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:18,代码来源:StorageNotifyResource.java

示例9: config

import org.restlet.resource.Post; //导入依赖的package包/类
@Post
@Put
public Object config() {
	IStatisticsService statisticsService = (IStatisticsService) getContext().getAttributes().get(IStatisticsService.class.getCanonicalName());

	if (getReference().getPath().contains(SwitchStatisticsWebRoutable.ENABLE_STR)) {
		statisticsService.collectStatistics(true);
		return Collections.singletonMap("statistics-collection", "enabled");
	}
	
	if (getReference().getPath().contains(SwitchStatisticsWebRoutable.DISABLE_STR)) {
		statisticsService.collectStatistics(false);
		return Collections.singletonMap("statistics-collection", "disabled");
	}

	return Collections.singletonMap("ERROR", "Unimplemented configuration option");
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:18,代码来源:ConfigResource.java

示例10: store

import org.restlet.resource.Post; //导入依赖的package包/类
/**
 * Takes a Firewall Rule string in JSON format and parses it into
 * our firewall rule data structure, then adds it to the firewall.
 * @param fmJson The Firewall rule entry in JSON format.
 * @return A string status message
 */
@Post
public String store(String fmJson) {
	IFirewallService firewall =
			(IFirewallService)getContext().getAttributes().
			get(IFirewallService.class.getCanonicalName());

	FirewallRule rule = jsonToFirewallRule(fmJson);
	if (rule == null) {
		return "{\"status\" : \"Error! Could not parse firewall rule, see log for details.\"}";
	}
	String status = null;
	if (checkRuleExists(rule, firewall.getRules())) {
		status = "Error! A similar firewall rule already exists.";
		log.error(status);
		return ("{\"status\" : \"" + status + "\"}");
	} else {
		// add rule to firewall
		firewall.addRule(rule);
		status = "Rule added";
		return ("{\"status\" : \"" + status + "\", \"rule-id\" : \""+ Integer.toString(rule.ruleid) + "\"}");
	}
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:29,代码来源:FirewallRulesResource.java

示例11: handlePost

import org.restlet.resource.Post; //导入依赖的package包/类
@Post
public String handlePost(String fmJson) {
	IFirewallService firewall = getFirewallService();

	String newMask;
	try {
		newMask = jsonExtractSubnetMask(fmJson);
	} catch (IOException e) {
		log.error("Error parsing new subnet mask: " + fmJson, e);
		setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
		return "{\"status\" : \"Error! Could not parse new subnet mask, see log for details.\"}";
	}

	firewall.setSubnetMask(newMask);

	setStatus(Status.SUCCESS_OK);
	return ("{\"status\" : \"subnet mask set\"}");
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:19,代码来源:FirewallSubnetMaskResource.java

示例12: del

import org.restlet.resource.Post; //导入依赖的package包/类
@Post
@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,代码来源:StaticFlowEntryDeleteResource.java

示例13: postFormData

import org.restlet.resource.Post; //导入依赖的package包/类
@Post
public void postFormData(final Representation entity) {
    ExtensionTokenManager tokenManager = getTokenManager();
    if (tokenManager.authenticationRequired()) {
        getResponse().setStatus(Status.CLIENT_ERROR_UNAUTHORIZED);
    } else {
        Form form = new Form(entity);
        final String emailAddress = form.getFirstValue(FORM_INPUT_EMAIL_ADDRESS);
        if (StringUtils.isNotBlank(emailAddress)) {
            TestEmailNotifier testNotifier = (TestEmailNotifier) getContext().getAttributes()
                    .get(EmailExtensionConstants.CONTEXT_ATTRIBUTE_KEY_TEST_NOTIFIER);
            testNotifier.setEmailAddress(emailAddress);
            testNotifier.run();
            testNotifier.setEmailAddress("");
        }
    }
}
 
开发者ID:blackducksoftware,项目名称:hub-email-extension,代码行数:18,代码来源:EmailTestServerResource.java


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