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


Java TaskUtil.prettyFormatJsonToLog方法代码示例

本文整理汇总了Java中com.intellij.tasks.impl.TaskUtil.prettyFormatJsonToLog方法的典型用法代码示例。如果您正苦于以下问题:Java TaskUtil.prettyFormatJsonToLog方法的具体用法?Java TaskUtil.prettyFormatJsonToLog怎么用?Java TaskUtil.prettyFormatJsonToLog使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.tasks.impl.TaskUtil的用法示例。


在下文中一共展示了TaskUtil.prettyFormatJsonToLog方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleResponse

import com.intellij.tasks.impl.TaskUtil; //导入方法依赖的package包/类
@Override
public T handleResponse(HttpResponse response) throws IOException {
  int statusCode = response.getStatusLine().getStatusCode();
  if (!isSuccessful(statusCode)) {
    if (statusCode == HttpStatus.SC_NOT_FOUND && myIgnoreNotFound) {
      return null;
    }
    throw RequestFailedException.forStatusCode(statusCode);
  }
  try {
    if (LOG.isDebugEnabled()) {
      String content = getResponseContentAsString(response);
      TaskUtil.prettyFormatJsonToLog(LOG, content);
      return myGson.fromJson(content, myClass);
    }
    else {
      return myGson.fromJson(getResponseContentAsReader(response), myClass);
    }
  }
  catch (JsonSyntaxException e) {
    LOG.warn("Malformed server response", e);
    return null;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:TaskResponseUtil.java

示例2: 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

示例3: handleResponse

import com.intellij.tasks.impl.TaskUtil; //导入方法依赖的package包/类
@Override
public T handleResponse(HttpResponse response) throws IOException
{
	int statusCode = response.getStatusLine().getStatusCode();
	if(!isSuccessful(statusCode))
	{
		if(statusCode == HttpStatus.SC_NOT_FOUND && myIgnoreNotFound)
		{
			return null;
		}
		throw RequestFailedException.forStatusCode(statusCode);
	}
	try
	{
		if(LOG.isDebugEnabled())
		{
			String content = getResponseContentAsString(response);
			TaskUtil.prettyFormatJsonToLog(LOG, content);
			return myGson.fromJson(content, myClass);
		}
		else
		{
			return myGson.fromJson(getResponseContentAsReader(response), myClass);
		}
	}
	catch(JsonSyntaxException e)
	{
		LOG.warn("Malformed server response", e);
		return null;
	}
}
 
开发者ID:consulo,项目名称:consulo-tasks,代码行数:32,代码来源:TaskResponseUtil.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

示例5: handleResponse

import com.intellij.tasks.impl.TaskUtil; //导入方法依赖的package包/类
@Override
public T handleResponse(HttpResponse response) throws IOException
{
	int statusCode = response.getStatusLine().getStatusCode();
	if(!isSuccessful(statusCode))
	{
		if(statusCode == HttpStatus.SC_NOT_FOUND && myIgnoreNotFound)
		{
			return null;
		}
		throw RequestFailedException.forStatusCode(statusCode);
	}
	try
	{
		if(LOG.isDebugEnabled())
		{
			String content = getResponseContentAsString(response);
			TaskUtil.prettyFormatJsonToLog(LOG, content);
			return myGson.fromJson(content, myClass);
		}
		return myGson.fromJson(getResponseContentAsReader(response), myClass);
	}
	catch(JsonSyntaxException e)
	{
		LOG.warn("Malformed server response", e);
		return null;
	}
}
 
开发者ID:consulo,项目名称:consulo-tasks,代码行数:29,代码来源:ResponseUtil.java


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