mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-05-05 21:27:47 +08:00
Merge remote-tracking branch 'wechat/develop' into develop
This commit is contained in:
commit
f0f21e1432
2
pom.xml
2
pom.xml
@ -134,7 +134,7 @@
|
||||
<dependency>
|
||||
<groupId>org.jodd</groupId>
|
||||
<artifactId>jodd-http</artifactId>
|
||||
<version>5.1.6</version>
|
||||
<version>5.2.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -1,4 +1,4 @@
|
||||
package cn.binarywang.wx.graal;
|
||||
package com.github.binarywang.wx.graal;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@ -26,12 +26,12 @@ import java.util.TreeSet;
|
||||
* @author outersky
|
||||
*/
|
||||
@SupportedAnnotationTypes("lombok.Data")
|
||||
@SupportedSourceVersion(SourceVersion.RELEASE_7)
|
||||
@SupportedSourceVersion(SourceVersion.RELEASE_8)
|
||||
public class GraalProcessor extends AbstractProcessor {
|
||||
private static final String REFLECTION_CONFIG_JSON = "reflection-config.json";
|
||||
private static final String NATIVE_IMAGE_PROPERTIES = "native-image.properties";
|
||||
|
||||
private SortedSet<String> classSet = new TreeSet<>();
|
||||
private final SortedSet<String> classSet = new TreeSet<>();
|
||||
private String shortestPackageName = null;
|
||||
|
||||
@Override
|
@ -1 +1 @@
|
||||
cn.binarywang.wx.graal.GraalProcessor
|
||||
com.github.binarywang.wx.graal.GraalProcessor
|
||||
|
@ -165,7 +165,7 @@
|
||||
<version>3.5.1</version>
|
||||
<configuration>
|
||||
<annotationProcessors>
|
||||
cn.binarywang.wx.graal.GraalProcessor,lombok.launch.AnnotationProcessorHider$AnnotationProcessor,lombok.launch.AnnotationProcessorHider$ClaimingProcessor
|
||||
com.github.binarywang.wx.graal.GraalProcessor,lombok.launch.AnnotationProcessorHider$AnnotationProcessor,lombok.launch.AnnotationProcessorHider$ClaimingProcessor
|
||||
</annotationProcessors>
|
||||
<annotationProcessorPaths>
|
||||
<path>
|
||||
|
@ -3,10 +3,7 @@ package me.chanjar.weixin.common.util;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import org.dom4j.Document;
|
||||
import org.dom4j.DocumentException;
|
||||
import org.dom4j.Element;
|
||||
import org.dom4j.Node;
|
||||
import org.dom4j.*;
|
||||
import org.dom4j.io.SAXReader;
|
||||
import org.dom4j.tree.DefaultText;
|
||||
import org.xml.sax.SAXException;
|
||||
@ -50,14 +47,16 @@ public class XmlUtils {
|
||||
}
|
||||
|
||||
private static Object element2MapOrString(Element element) {
|
||||
Map<String, Object> result = Maps.newHashMap();
|
||||
|
||||
final List<Node> content = element.content();
|
||||
if (content.size() <= 1) {
|
||||
final Set<String> names = names(content);
|
||||
|
||||
// 判断节点下有无非文本节点(非Text和CDATA),如无,直接取Text文本内容
|
||||
if (names.size() < 1) {
|
||||
return element.getText();
|
||||
}
|
||||
|
||||
final Set<String> names = names(content);
|
||||
Map<String, Object> result = Maps.newHashMap();
|
||||
if (names.size() == 1) {
|
||||
// 说明是个列表,各个子对象是相同的name
|
||||
List<Object> list = Lists.newArrayList();
|
||||
@ -90,7 +89,8 @@ public class XmlUtils {
|
||||
private static Set<String> names(List<Node> nodes) {
|
||||
Set<String> names = Sets.newHashSet();
|
||||
for (Node node : nodes) {
|
||||
if (node instanceof DefaultText) {
|
||||
// 如果节点类型是Text或CDATA跳过
|
||||
if (node instanceof DefaultText || node instanceof CDATA) {
|
||||
continue;
|
||||
}
|
||||
names.add(node.getName());
|
||||
|
@ -19,6 +19,7 @@ import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
* .
|
||||
@ -47,7 +48,7 @@ public class JoddHttpMediaDownloadRequestExecutor extends BaseMediaDownloadReque
|
||||
request.withConnectionProvider(requestHttp.getRequestHttpClient());
|
||||
|
||||
HttpResponse response = request.send();
|
||||
response.charset(StringPool.UTF_8);
|
||||
response.charset(StandardCharsets.UTF_8.name());
|
||||
|
||||
String contentType = response.header("Content-Type");
|
||||
if (contentType != null && contentType.startsWith("application/json")) {
|
||||
|
@ -14,6 +14,7 @@ import me.chanjar.weixin.common.util.http.RequestHttp;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
* .
|
||||
@ -35,7 +36,7 @@ public class JoddHttpMediaUploadRequestExecutor extends MediaUploadRequestExecut
|
||||
request.withConnectionProvider(requestHttp.getRequestHttpClient());
|
||||
request.form("media", file);
|
||||
HttpResponse response = request.send();
|
||||
response.charset(StringPool.UTF_8);
|
||||
response.charset(StandardCharsets.UTF_8.name());
|
||||
|
||||
String responseContent = response.bodyText();
|
||||
WxError error = WxError.fromJson(responseContent, wxType);
|
||||
|
@ -11,6 +11,7 @@ import me.chanjar.weixin.common.util.http.RequestHttp;
|
||||
import me.chanjar.weixin.common.util.http.SimpleGetRequestExecutor;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
* .
|
||||
@ -38,7 +39,7 @@ public class JoddHttpSimpleGetRequestExecutor extends SimpleGetRequestExecutor<H
|
||||
}
|
||||
request.withConnectionProvider(requestHttp.getRequestHttpClient());
|
||||
HttpResponse response = request.send();
|
||||
response.charset(StringPool.UTF_8);
|
||||
response.charset(StandardCharsets.UTF_8.name());
|
||||
|
||||
return handleResponse(wxType, response.bodyText());
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import me.chanjar.weixin.common.util.http.RequestHttp;
|
||||
import me.chanjar.weixin.common.util.http.SimplePostRequestExecutor;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
* .
|
||||
@ -37,7 +38,7 @@ public class JoddHttpSimplePostRequestExecutor extends SimplePostRequestExecutor
|
||||
request.bodyText(postEntity);
|
||||
}
|
||||
HttpResponse response = request.send();
|
||||
response.charset(StringPool.UTF_8);
|
||||
response.charset(StandardCharsets.UTF_8.name());
|
||||
|
||||
return this.handleResponse(wxType, response.bodyText());
|
||||
}
|
||||
|
@ -119,7 +119,7 @@
|
||||
<version>3.5.1</version>
|
||||
<configuration>
|
||||
<annotationProcessors>
|
||||
cn.binarywang.wx.graal.GraalProcessor,lombok.launch.AnnotationProcessorHider$AnnotationProcessor,lombok.launch.AnnotationProcessorHider$ClaimingProcessor
|
||||
com.github.binarywang.wx.graal.GraalProcessor,lombok.launch.AnnotationProcessorHider$AnnotationProcessor,lombok.launch.AnnotationProcessorHider$ClaimingProcessor
|
||||
</annotationProcessors>
|
||||
<annotationProcessorPaths>
|
||||
<path>
|
||||
|
@ -126,7 +126,7 @@
|
||||
<version>3.5.1</version>
|
||||
<configuration>
|
||||
<annotationProcessors>
|
||||
cn.binarywang.wx.graal.GraalProcessor,lombok.launch.AnnotationProcessorHider$AnnotationProcessor,lombok.launch.AnnotationProcessorHider$ClaimingProcessor
|
||||
com.github.binarywang.wx.graal.GraalProcessor,lombok.launch.AnnotationProcessorHider$AnnotationProcessor,lombok.launch.AnnotationProcessorHider$ClaimingProcessor
|
||||
</annotationProcessors>
|
||||
<annotationProcessorPaths>
|
||||
<path>
|
||||
|
@ -115,7 +115,7 @@
|
||||
<version>3.5.1</version>
|
||||
<configuration>
|
||||
<annotationProcessors>
|
||||
cn.binarywang.wx.graal.GraalProcessor,lombok.launch.AnnotationProcessorHider$AnnotationProcessor,lombok.launch.AnnotationProcessorHider$ClaimingProcessor
|
||||
com.github.binarywang.wx.graal.GraalProcessor,lombok.launch.AnnotationProcessorHider$AnnotationProcessor,lombok.launch.AnnotationProcessorHider$ClaimingProcessor
|
||||
</annotationProcessors>
|
||||
<annotationProcessorPaths>
|
||||
<path>
|
||||
|
@ -1,6 +1,7 @@
|
||||
package me.chanjar.weixin.mp.api;
|
||||
|
||||
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||
import lombok.AllArgsConstructor;
|
||||
import me.chanjar.weixin.common.api.WxErrorExceptionHandler;
|
||||
import me.chanjar.weixin.common.api.WxMessageDuplicateChecker;
|
||||
import me.chanjar.weixin.common.api.WxMessageInMemoryDuplicateChecker;
|
||||
@ -49,6 +50,7 @@ import java.util.concurrent.*;
|
||||
*
|
||||
* @author Daniel Qian
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
public class WxMpMessageRouter {
|
||||
private static final int DEFAULT_THREAD_POOL_SIZE = 100;
|
||||
protected final Logger log = LoggerFactory.getLogger(WxMpMessageRouter.class);
|
||||
|
@ -12,6 +12,7 @@ import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.common.util.http.RequestHttp;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
* Created by ecoolper on 2017/5/5.
|
||||
@ -31,7 +32,7 @@ public class MaterialDeleteJoddHttpRequestExecutor extends MaterialDeleteRequest
|
||||
|
||||
request.query("media_id", materialId);
|
||||
HttpResponse response = request.send();
|
||||
response.charset(StringPool.UTF_8);
|
||||
response.charset(StandardCharsets.UTF_8.name());
|
||||
String responseContent = response.bodyText();
|
||||
WxError error = WxError.fromJson(responseContent, WxType.MP);
|
||||
if (error.getErrorCode() != 0) {
|
||||
|
@ -7,6 +7,7 @@ import jodd.http.HttpResponse;
|
||||
import jodd.http.ProxyInfo;
|
||||
import jodd.util.StringPool;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.chanjar.weixin.common.enums.WxType;
|
||||
import me.chanjar.weixin.common.error.WxError;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
@ -18,12 +19,13 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
* Created by ecoolper on 2017/5/5.
|
||||
*/
|
||||
@Slf4j
|
||||
public class MaterialNewsInfoJoddHttpRequestExecutor extends MaterialNewsInfoRequestExecutor<HttpConnectionProvider, ProxyInfo> {
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
public MaterialNewsInfoJoddHttpRequestExecutor(RequestHttp requestHttp) {
|
||||
super(requestHttp);
|
||||
}
|
||||
@ -38,10 +40,10 @@ public class MaterialNewsInfoJoddHttpRequestExecutor extends MaterialNewsInfoReq
|
||||
.withConnectionProvider(requestHttp.getRequestHttpClient())
|
||||
.body(WxGsonBuilder.create().toJson(ImmutableMap.of("media_id", materialId)));
|
||||
HttpResponse response = request.send();
|
||||
response.charset(StringPool.UTF_8);
|
||||
response.charset(StandardCharsets.UTF_8.name());
|
||||
|
||||
String responseContent = response.bodyText();
|
||||
this.logger.debug("响应原始数据:{}", responseContent);
|
||||
log.debug("响应原始数据:{}", responseContent);
|
||||
WxError error = WxError.fromJson(responseContent, WxType.MP);
|
||||
if (error.getErrorCode() != 0) {
|
||||
throw new WxErrorException(error);
|
||||
|
@ -17,6 +17,7 @@ import me.chanjar.weixin.mp.bean.material.WxMpMaterialUploadResult;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@ -50,7 +51,7 @@ public class MaterialUploadJoddHttpRequestExecutor extends MaterialUploadRequest
|
||||
}
|
||||
|
||||
HttpResponse response = request.send();
|
||||
response.charset(StringPool.UTF_8);
|
||||
response.charset(StandardCharsets.UTF_8.name());
|
||||
String responseContent = response.bodyText();
|
||||
WxError error = WxError.fromJson(responseContent, WxType.MP);
|
||||
if (error.getErrorCode() != 0) {
|
||||
|
@ -13,6 +13,7 @@ import me.chanjar.weixin.common.util.http.RequestHttp;
|
||||
import me.chanjar.weixin.mp.bean.material.WxMpMaterialVideoInfoResult;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
* Created by ecoolper on 2017/5/5.
|
||||
@ -32,7 +33,7 @@ public class MaterialVideoInfoJoddHttpRequestExecutor extends MaterialVideoInfoR
|
||||
|
||||
request.query("media_id", materialId);
|
||||
HttpResponse response = request.send();
|
||||
response.charset(StringPool.UTF_8);
|
||||
response.charset(StandardCharsets.UTF_8.name());
|
||||
String responseContent = response.bodyText();
|
||||
WxError error = WxError.fromJson(responseContent, WxType.MP);
|
||||
if (error.getErrorCode() != 0) {
|
||||
|
@ -37,7 +37,7 @@ public class MaterialVoiceAndImageDownloadJoddHttpRequestExecutor extends Materi
|
||||
|
||||
request.query("media_id", materialId);
|
||||
HttpResponse response = request.send();
|
||||
response.charset(StringPool.UTF_8);
|
||||
response.charset(StandardCharsets.UTF_8.name());
|
||||
try (InputStream inputStream = new ByteArrayInputStream(response.bodyBytes())) {
|
||||
// 下载媒体文件出错
|
||||
byte[] responseContent = IOUtils.toByteArray(inputStream);
|
||||
|
@ -14,6 +14,7 @@ import me.chanjar.weixin.mp.bean.material.WxMediaImgUploadResult;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
* Created by ecoolper on 2017/5/5.
|
||||
@ -39,7 +40,7 @@ public class MediaImgUploadHttpRequestExecutor extends MediaImgUploadRequestExec
|
||||
|
||||
request.form("media", data);
|
||||
HttpResponse response = request.send();
|
||||
response.charset(StringPool.UTF_8);
|
||||
response.charset(StandardCharsets.UTF_8.name());
|
||||
String responseContent = response.bodyText();
|
||||
WxError error = WxError.fromJson(responseContent, WxType.MP);
|
||||
if (error.getErrorCode() != 0) {
|
||||
|
@ -19,6 +19,7 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
@ -47,7 +48,7 @@ public class QrCodeJoddHttpRequestExecutor extends QrCodeRequestExecutor<HttpCon
|
||||
request.withConnectionProvider(requestHttp.getRequestHttpClient());
|
||||
|
||||
HttpResponse response = request.send();
|
||||
response.charset(StringPool.UTF_8);
|
||||
response.charset(StandardCharsets.UTF_8.name());
|
||||
String contentTypeHeader = response.header("Content-Type");
|
||||
if (MimeTypes.MIME_TEXT_PLAIN.equals(contentTypeHeader)) {
|
||||
String responseContent = response.bodyText();
|
||||
|
@ -122,7 +122,7 @@
|
||||
<version>3.5.1</version>
|
||||
<configuration>
|
||||
<annotationProcessors>
|
||||
cn.binarywang.wx.graal.GraalProcessor,lombok.launch.AnnotationProcessorHider$AnnotationProcessor,lombok.launch.AnnotationProcessorHider$ClaimingProcessor
|
||||
com.github.binarywang.wx.graal.GraalProcessor,lombok.launch.AnnotationProcessorHider$AnnotationProcessor,lombok.launch.AnnotationProcessorHider$ClaimingProcessor
|
||||
</annotationProcessors>
|
||||
<annotationProcessorPaths>
|
||||
<path>
|
||||
|
@ -19,6 +19,7 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
@ -49,7 +50,7 @@ public class MaQrCodeJoddHttpRequestExecutor extends MaQrCodeRequestExecutor<Htt
|
||||
request.withConnectionProvider(requestHttp.getRequestHttpClient());
|
||||
|
||||
HttpResponse response = request.send();
|
||||
response.charset(StringPool.UTF_8);
|
||||
response.charset(StandardCharsets.UTF_8.name());
|
||||
String contentTypeHeader = response.header("Content-Type");
|
||||
if (MimeTypes.MIME_TEXT_PLAIN.equals(contentTypeHeader)) {
|
||||
String responseContent = response.bodyText();
|
||||
|
@ -102,7 +102,7 @@
|
||||
<version>3.5.1</version>
|
||||
<configuration>
|
||||
<annotationProcessors>
|
||||
cn.binarywang.wx.graal.GraalProcessor,lombok.launch.AnnotationProcessorHider$AnnotationProcessor,lombok.launch.AnnotationProcessorHider$ClaimingProcessor
|
||||
com.github.binarywang.wx.graal.GraalProcessor,lombok.launch.AnnotationProcessorHider$AnnotationProcessor,lombok.launch.AnnotationProcessorHider$ClaimingProcessor
|
||||
</annotationProcessors>
|
||||
<annotationProcessorPaths>
|
||||
<path>
|
||||
|
Loading…
Reference in New Issue
Block a user