本文整理匯總了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));
}
}