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