当前位置: 首页>>代码示例>>Java>>正文


Java Representation.getText方法代码示例

本文整理汇总了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));
  }
}
 
开发者ID:uber,项目名称:uReplicator,代码行数:26,代码来源:TopicManagementRestletResource.java

示例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));
  }
}
 
开发者ID:uber,项目名称:uReplicator,代码行数:38,代码来源:TopicManagementRestletResource.java


注:本文中的org.restlet.representation.Representation.getText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。