當前位置: 首頁>>代碼示例>>Java>>正文


Java TaskUtil.prettyFormatXmlToLog方法代碼示例

本文整理匯總了Java中com.intellij.tasks.impl.TaskUtil.prettyFormatXmlToLog方法的典型用法代碼示例。如果您正苦於以下問題:Java TaskUtil.prettyFormatXmlToLog方法的具體用法?Java TaskUtil.prettyFormatXmlToLog怎麽用?Java TaskUtil.prettyFormatXmlToLog使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.intellij.tasks.impl.TaskUtil的用法示例。


在下文中一共展示了TaskUtil.prettyFormatXmlToLog方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: doREST

import com.intellij.tasks.impl.TaskUtil; //導入方法依賴的package包/類
HttpMethod doREST(String request, boolean post) throws Exception {
  HttpClient client = login(new PostMethod(getUrl() + "/rest/user/login"));
  String uri = getUrl() + request;
  HttpMethod method = post ? new PostMethod(uri) : new GetMethod(uri);
  configureHttpMethod(method);
  int status = client.executeMethod(method);
  if (status == 400) {
    InputStream string = method.getResponseBodyAsStream();
    Element element = new SAXBuilder(false).build(string).getRootElement();
    TaskUtil.prettyFormatXmlToLog(LOG, element);
    if ("error".equals(element.getName())) {
      throw new Exception(element.getText());
    }
  }
  return method;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:17,代碼來源:YouTrackRepository.java

示例2: Response

import com.intellij.tasks.impl.TaskUtil; //導入方法依賴的package包/類
public Response(@NotNull InputStream stream) throws Exception {
  final Element root = new SAXBuilder().build(stream).getRootElement();
  TaskUtil.prettyFormatXmlToLog(LOG, root);
  @NotNull final Element highlight = root.getChild("highlight");
  //assert highlight != null : "no '/IntelliSense/highlight' element in YouTrack response";
  myHighlightRanges = ContainerUtil.map(highlight.getChildren("range"), new Function<Element, HighlightRange>() {
    @Override
    public HighlightRange fun(Element range) {
      return new HighlightRange(range);
    }
  });

  @NotNull final Element suggest = root.getChild("suggest");
  //assert suggest != null : "no '/IntelliSense/suggest' element in YouTrack response";
  myCompletionItems = ContainerUtil.map(suggest.getChildren("item"), new Function<Element, CompletionItem>() {
    @Override
    public CompletionItem fun(Element item) {
      return new CompletionItem(item);
    }
  });
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:22,代碼來源:YouTrackIntellisense.java

示例3: executeMethod

import com.intellij.tasks.impl.TaskUtil; //導入方法依賴的package包/類
private String executeMethod(HttpMethod method) throws Exception {
  LOG.debug("URI is " + method.getURI());
  String responseBody;
  try {
    getHttpClient().executeMethod(method);
    Header contentType = method.getResponseHeader("Content-Type");
    if (contentType != null && contentType.getValue().contains("charset")) {
      // ISO-8859-1 if charset wasn't specified in response
      responseBody = StringUtil.notNullize(method.getResponseBodyAsString());
    }
    else {
      InputStream stream = method.getResponseBodyAsStream();
      responseBody = stream == null? "": StreamUtil.readText(stream, "utf-8");
    }
  }
  finally {
    method.releaseConnection();
  }
  switch (getResponseType()) {
    case XML:
      TaskUtil.prettyFormatXmlToLog(LOG, responseBody);
      break;
    case JSON:
      TaskUtil.prettyFormatJsonToLog(LOG, responseBody);
      break;
    default:
      LOG.debug(responseBody);
  }
  LOG.debug("Status code is " + method.getStatusCode());
  if (method.getStatusCode() != HttpStatus.SC_OK) {
    throw new Exception("Request failed with HTTP error: " + method.getStatusText());
  }
  return responseBody;
}
 
開發者ID:consulo,項目名稱:consulo-tasks,代碼行數:35,代碼來源:GenericRepository.java

示例4: prettyFormatResponseToLog

import com.intellij.tasks.impl.TaskUtil; //導入方法依賴的package包/類
public static void prettyFormatResponseToLog(@NotNull Logger logger, @NotNull HttpMethod response)
{
	if(logger.isDebugEnabled() && response.hasBeenUsed())
	{
		try
		{
			String content = TaskResponseUtil.getResponseContentAsString(response);
			org.apache.commons.httpclient.Header header = response.getRequestHeader(HTTP.CONTENT_TYPE);
			String contentType = header == null ? "text/plain" : header.getElements()[0].getName().toLowerCase(Locale.ENGLISH);
			if(contentType.contains("xml"))
			{
				TaskUtil.prettyFormatXmlToLog(logger, content);
			}
			else if(contentType.contains("json"))
			{
				TaskUtil.prettyFormatJsonToLog(logger, content);
			}
			else
			{
				logger.debug(content);
			}
		}
		catch(IOException e)
		{
			logger.error(e);
		}
	}
}
 
開發者ID:consulo,項目名稱:consulo-tasks,代碼行數:29,代碼來源:TaskResponseUtil.java


注:本文中的com.intellij.tasks.impl.TaskUtil.prettyFormatXmlToLog方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。