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