當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。