本文整理汇总了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;
}
示例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));
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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\"}";
}
示例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;
}
示例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");
}
示例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) + "\"}");
}
}
示例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\"}");
}
示例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\"}";
}
示例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("");
}
}
}