本文整理汇总了Java中org.restlet.representation.Representation.getText方法的典型用法代码示例。如果您正苦于以下问题:Java Representation.getText方法的具体用法?Java Representation.getText怎么用?Java Representation.getText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.restlet.representation.Representation
的用法示例。
在下文中一共展示了Representation.getText方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: put
import org.restlet.representation.Representation; //导入方法依赖的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));
}
}
示例2: post
import org.restlet.representation.Representation; //导入方法依赖的package包/类
@Override
@Post("json")
public Representation post(Representation entity) {
try {
final String topicName = (String) getRequest().getAttributes().get("topicName");
String jsonRequest = entity.getText();
TopicPartition topicPartitionInfo = null;
if ((jsonRequest == null || jsonRequest.isEmpty()) && topicName != null
&& _srcKafkaBrokerTopicObserver != null) {
// Only triggered when srcKafkaObserver is there and curl call has no json blob.
topicPartitionInfo = _srcKafkaBrokerTopicObserver.getTopicPartition(topicName);
if (topicPartitionInfo == null) {
return new StringRepresentation(String.format(
"Failed to add new topic: %s, it's not exsited in source kafka cluster!", topicName));
}
} else {
topicPartitionInfo = TopicPartition.init(jsonRequest);
}
if (_autoTopicWhitelistingManager != null) {
_autoTopicWhitelistingManager.removeFromBlacklist(topicPartitionInfo.getTopic());
}
if (_helixMirrorMakerManager.isTopicExisted(topicPartitionInfo.getTopic())) {
getResponse().setStatus(Status.CLIENT_ERROR_NOT_FOUND);
return new StringRepresentation(String.format(
"Failed to add new topic: %s, it is already existed!", topicPartitionInfo.getTopic()));
} else {
_helixMirrorMakerManager.addTopicToMirrorMaker(topicPartitionInfo);
return new StringRepresentation(
String.format("Successfully add new topic: %s", topicPartitionInfo));
}
} catch (IOException e) {
LOGGER.error("Got error during processing Post request", e);
getResponse().setStatus(Status.SERVER_ERROR_INTERNAL);
return new StringRepresentation(
String.format("Failed to add new topic, with exception: %s", e));
}
}