本文整理匯總了Java中org.restlet.resource.Put類的典型用法代碼示例。如果您正苦於以下問題:Java Put類的具體用法?Java Put怎麽用?Java Put使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Put類屬於org.restlet.resource包,在下文中一共展示了Put類的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: Create
import org.restlet.resource.Put; //導入依賴的package包/類
@Put
public String Create(String json) {
boolean 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.createGroup(addr);
}
catch (IOException e) {
e.printStackTrace();
return new String("error");
}
if (ret)
return new String("group created");
else
return new String("group already existing");
}
示例2: sendDiscoverPacket
import org.restlet.resource.Put; //導入依賴的package包/類
@Put("json")
public String sendDiscoverPacket() {
IPathVerificationService pvs =
(IPathVerificationService) getContext().getAttributes().get(IPathVerificationService.class.getCanonicalName());
String srcSwitch = (String) getRequestAttributes().get("src_switch");
String port = (String) getRequestAttributes().get("src_port");
String dstSwitch = (String) getRequestAttributes().get("dst_switch");
logger.debug("asking {} to send a discovery packet out port {} with destination {}.", new Object[]{srcSwitch, port, dstSwitch});
if (dstSwitch == null) {
DatapathId d = DatapathId.of(srcSwitch);
int p = Integer.parseInt(port);
pvs.sendDiscoveryMessage(d, OFPort.of(p));
} else {
pvs.sendDiscoveryMessage(DatapathId.of(srcSwitch), OFPort.of(new Integer(port)), DatapathId.of(dstSwitch));
}
return null;
}
示例3: updateScore
import org.restlet.resource.Put; //導入依賴的package包/類
@Put
public Status updateScore(UpdateScoreEntity entity) throws SQLException {
if (entity == null) throw new BadEntityException("ENTITY_NOT_FOUND");
if (mEvents.getEvent(mEventId) == null) throw new NotFoundException("EVENT_NOT_FOUND");
if (!mEvents.roundExists(mEventId, mRoundId)) throw new NotFoundException("ROUND_NOT_FOUND");
if (mEvents.getRegistered(mEventId, mUserId) == null) throw new NotFoundException("USER_NOT_REGISTERED");
if (mEvents.getScore(mRoundId, mUserId) != null) mEvents.updateScore(mRoundId, mUserId, entity.score);
else mEvents.addScore(mRoundId, mUserId, entity.score);
try {
mRabbitMQManager.basicPublish("Pub", "", null, new TopicPacket("event-score-v1." + mEventId, new UpdateScoreMessage(mEventId, mRoundId, mUserId, entity.score)));
} catch (IOException e) {
Server.LOGGER.log(Level.SEVERE, "Cannot send publish to RabbitMQ", e);
}
return Status.SUCCESS_OK;
}
示例4: updateEvent
import org.restlet.resource.Put; //導入依賴的package包/類
@Put
public Status updateEvent(UpdateEventEntity 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("EVENT_UPDATE_ERROR");
EventBean bean = mEvents.getEvent(mEventId);
if (bean == null) throw new NotFoundException("EVENT_NOT_FOUND");
bean.setCurrent(entity.current);
bean.setDescription(entity.description);
bean.setName(entity.name);
bean.setReservedToAffiliates(entity.reserved_to_affiliates);
bean.setReservedToPartners(entity.reserved_to_partners);
bean.setStatus(entity.status);
bean.setMinimumViews(entity.minimum_views);
bean.setMinimumFollowers(entity.minimum_followers);
mEvents.update(bean);
return Status.SUCCESS_OK;
}
示例5: updatePariticipationStatus
import org.restlet.resource.Put; //導入依賴的package包/類
@Put
public Status updatePariticipationStatus(EmailValidationBean bean) throws SQLException {
if (bean == null) throw new BadEntityException("EVENT_NOT_FOUND");
ValidationErrors err = new ValidationErrors();
err.verifyFieldEmptyness("key", bean.key, 5, 36);
err.checkErrors("INVALID_KEY");
AccountBean acc = (AccountBean) getRequest().getAttributes().get("account");
UserStatus status = mEvents.getUserStatusFromEmailKey(mEventId, acc.getTwitchId(), bean.key);
if (status == null) throw new NotFoundException("UNKNOWN_KEY");
if (status != UserStatus.AWAITING_FOR_EMAIL_VALIDATION) throw new ConflictException("BAD_STATUS");
mEvents.updateUser(mEventId, acc.getTwitchId(), UserStatus.VALIDATED);
try {
EventBean event = mEvents.getEvent(mEventId);
MimeMessage message = mEmailsService.generateMime("Validez votre compte!",
mValidatedEmail.replaceAll("\\{EVENT_NAME\\}", event.getName())
.replaceAll("\\{EVENT_ID\\}", event.getId() + ""), "text/html", acc.getEmail());
mEmailsService.sendEmail(message);
} catch (MessagingException e) {
Main.LOGGER.log(Level.SEVERE, "Cannot send email.", e);
}
return Status.SUCCESS_OK;
}
示例6: addHost
import org.restlet.resource.Put; //導入依賴的package包/類
@Put
public String addHost(String postData) {
IVirtualNetworkService vns =
(IVirtualNetworkService)getContext().getAttributes().
get(IVirtualNetworkService.class.getCanonicalName());
HostDefinition host = new HostDefinition();
host.port = (String) getRequestAttributes().get("port");
host.guid = (String) getRequestAttributes().get("network");
try {
jsonToHostDefinition(postData, host);
} catch (IOException e) {
log.error("Could not parse JSON {}", e.getMessage());
}
vns.addHost(MacAddress.of(host.mac), host.guid, host.port);
setStatus(Status.SUCCESS_OK);
return "{\"status\":\"ok\"}";
}
示例7: createMonitor
import org.restlet.resource.Put; //導入依賴的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);
}
示例8: createVip
import org.restlet.resource.Put; //導入依賴的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);
}
示例9: createPool
import org.restlet.resource.Put; //導入依賴的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);
}
示例10: createMember
import org.restlet.resource.Put; //導入依賴的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);
}
示例11: config
import org.restlet.resource.Put; //導入依賴的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");
}
示例12: addHost
import org.restlet.resource.Put; //導入依賴的package包/類
@Put
public String addHost(String postData) {
IVirtualNetworkService vns =
(IVirtualNetworkService)getContext().getAttributes().
get(IVirtualNetworkService.class.getCanonicalName());
HostDefinition host = new HostDefinition();
host.port = (String) getRequestAttributes().get("port");
host.guid = (String) getRequestAttributes().get("network");
try {
jsonToHostDefinition(postData, host);
} catch (IOException e) {
log.error("Could not parse JSON {}", e.getMessage());
}
vns.addHost(MACAddress.valueOf(host.mac), host.guid, host.port);
setStatus(Status.SUCCESS_OK);
return "{\"status\":\"ok\"}";
}
示例13: handlePut
import org.restlet.resource.Put; //導入依賴的package包/類
@Put("json")
public Representation handlePut(Representation entity) {
String path = getReference().getPath();
String dbname = getDatabaseName(path);
String pathWithFirstAndLastSlashRemoved = path.replaceAll("^/", "").replaceAll("/$", "");
if (pathWithFirstAndLastSlashRemoved.equals(dbname)) {
// must be a PUT /target request
return handleCreateTargetPut(dbname);
}
else if (!dbNameExists(dbname)) {
return databaseNotFound();
}
else if (path.contains("/_local/")) {
return handleLocalPut(dbname);
} else {
getResponse().setStatus(Status.SERVER_ERROR_INTERNAL);
return new StringRepresentation("{\"message\": \"Server error for request: " + getMethod() + " " + path + "\"}", MediaType.TEXT_PLAIN);
}
}
示例14: put
import org.restlet.resource.Put; //導入依賴的package包/類
@Override
@Put("json")
public Representation put(Representation entity) {
try {
String jsonRequest = entity.getText();
TopicPartition topicPartitionInfo = TopicPartition.init(jsonRequest);
if (_autoTopicWhitelistingManager != null) {
_autoTopicWhitelistingManager.removeFromBlacklist(topicPartitionInfo.getTopic());
}
if (_helixMirrorMakerManager.isTopicExisted(topicPartitionInfo.getTopic())) {
_helixMirrorMakerManager.expandTopicInMirrorMaker(topicPartitionInfo);
return new StringRepresentation(
String.format("Successfully expand topic: %s", topicPartitionInfo));
} else {
getResponse().setStatus(Status.CLIENT_ERROR_NOT_FOUND);
return new StringRepresentation(String.format(
"Failed to expand topic, topic: %s is not existed!", topicPartitionInfo.getTopic()));
}
} catch (IOException e) {
LOGGER.error("Got error during processing Put request", e);
getResponse().setStatus(Status.SERVER_ERROR_INTERNAL);
return new StringRepresentation(
String.format("Failed to expand topic, with exception: %s", e));
}
}