diff --git a/pom.xml b/pom.xml
index 957559a..3fa172b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -7,7 +7,7 @@
com.chinaunicom.ebtp
mall-ebtp-cloud-parent
- 2.0.1-SNAPSHOT
+ 2.1.1-SNAPSHOT
com.chinaunicom.mall.ebtp
@@ -20,7 +20,7 @@
com.chinaunicom.mall.ebtp
uboot-core
- 2.0.1-SNAPSHOT
+ 2.1.1-SNAPSHOT
diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/feign/client/DocumentCenterService.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/feign/client/DocumentCenterService.java
index 87fbd34..104406c 100644
--- a/src/main/java/com/chinaunicom/mall/ebtp/extend/feign/client/DocumentCenterService.java
+++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/feign/client/DocumentCenterService.java
@@ -1,7 +1,6 @@
package com.chinaunicom.mall.ebtp.extend.feign.client;
import com.chinaunicom.mall.ebtp.extend.feign.client.factory.DocumentCenterServiceFallbackFactory;
-import com.chinaunicom.mall.ebtp.extend.feign.config.FeignConfiguration;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@@ -14,8 +13,7 @@ import org.springframework.web.bind.annotation.RequestParam;
*/
@FeignClient(value = "${mconfig.feign.name.documentcenter}",
- fallbackFactory = DocumentCenterServiceFallbackFactory.class,
- configuration = FeignConfiguration.class)
+ fallbackFactory = DocumentCenterServiceFallbackFactory.class)
public interface DocumentCenterService {
/**
diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/feign/config/FeignConfiguration.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/feign/config/FeignConfiguration.java
deleted file mode 100644
index 596a4ac..0000000
--- a/src/main/java/com/chinaunicom/mall/ebtp/extend/feign/config/FeignConfiguration.java
+++ /dev/null
@@ -1,95 +0,0 @@
-package com.chinaunicom.mall.ebtp.extend.feign.config;
-
-import com.alibaba.fastjson.JSONObject;
-import feign.RequestInterceptor;
-import feign.RequestTemplate;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang.StringUtils;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.http.HttpHeaders;
-import org.springframework.web.context.request.RequestContextHolder;
-import org.springframework.web.context.request.ServletRequestAttributes;
-
-import javax.servlet.http.HttpServletRequest;
-import java.io.BufferedReader;
-import java.io.DataOutputStream;
-import java.io.InputStreamReader;
-import java.net.HttpURLConnection;
-import java.net.URL;
-
-@Slf4j
-@Configuration
-public class FeignConfiguration implements RequestInterceptor {
-
- @Value("${document.clientHttpUrl}")
- private String clientHttpUrl;
-
- @Override
- public void apply(RequestTemplate requestTemplate) {
- ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
- if (attributes != null) {
- HttpServletRequest request = attributes.getRequest();
- log.info("token=======requestTemplate.headers" + requestTemplate.headers());
- String access_token = request.getHeader("Authorization");
- log.info("token=======" + access_token);
- if (access_token == null || StringUtils.isBlank(access_token)) {
- access_token = getAccessToken();
- log.info("token=======access_token===" + access_token);
- requestTemplate.header(HttpHeaders.AUTHORIZATION, "Bearer " + access_token);
- }
- } else {
- String access_token = getAccessToken();
- log.info("token=======attributes==null===" + access_token);
- requestTemplate.header(HttpHeaders.AUTHORIZATION, "Bearer " + access_token);
- }
- }
-
- private String getAccessToken() {
- StringBuffer strBf = new StringBuffer();
- try {
- URL realUrl = new URL(clientHttpUrl);
- //将realUrl以 open方法返回的urlConnection 连接强转为HttpURLConnection连接 (标识一个url所引用的远程对象连接)
- HttpURLConnection connection = (HttpURLConnection) realUrl.openConnection();// 此时cnnection只是为一个连接对象,待连接中
- //设置连接输出流为true,默认false (post请求是以流的方式隐式的传递参数)
- connection.setDoOutput(true);
- //设置连接输入流为true
- connection.setDoInput(true);
- //设置请求方式为post
- connection.setRequestMethod("POST");
- //post请求缓存设为false
- connection.setUseCaches(false);
- //设置该HttpURLConnection实例是否自动执行重定向
- connection.setInstanceFollowRedirects(true);
- //设置请求头里面的各个属性 (以下为设置内容的类型,设置为经过urlEncoded编码过的from参数)
- connection.setRequestProperty("Content-Type", "application/json;charset=utf-8");
- //建立连接 (请求未开始,直到connection.getInputStream()方法调用时才发起,以上各个参数设置需在此方法之前进行)
- connection.connect();
- //创建输入输出流,用于往连接里面输出携带的参数,(输出内容为?后面的内容)
- DataOutputStream dataout = new DataOutputStream(connection.getOutputStream());
-// String query = data.toString();
-// //将参数输出到连接
-// dataout.write(query.getBytes("UTF-8"));
- // 输出完成后刷新并关闭流
- dataout.flush();
- dataout.close(); // 重要且易忽略步骤 (关闭流,切记!)
- BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"));
- String lines;
- while ((lines = reader.readLine()) != null) {
- lines = new String(lines.getBytes(), "utf-8");
- strBf.append(lines);
- }
- reader.close();
- connection.disconnect();
- log.info("toke返回数据:---------------------- " + strBf.toString());
- } catch (Exception e) {
- log.info("toke返回数据:---------------------- " + e.getMessage());
- }
- JSONObject json = JSONObject.parseObject(strBf.toString());
- if ((boolean) json.get("success")) {
- return ((JSONObject) json.get("data")).get("value").toString();
- }
- return null;
- }
-}
-
diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/signature/service/impl/ExpertSignatureServiceImpl.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/signature/service/impl/ExpertSignatureServiceImpl.java
index 722b64e..18f1151 100644
--- a/src/main/java/com/chinaunicom/mall/ebtp/extend/signature/service/impl/ExpertSignatureServiceImpl.java
+++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/signature/service/impl/ExpertSignatureServiceImpl.java
@@ -125,20 +125,18 @@ public class ExpertSignatureServiceImpl implements ExpertSignatureService {
File f = new File(path + "merged.pdf");
FileOutputStream fos = null;
- FontSettings.getDefaultInstance().setFontsFolder(fontAddress, true);
try {
+ FontSettings.getDefaultInstance().setFontsFolder(fontAddress, true);
fos = new FileOutputStream(f);
com.aspose.words.Document doc = new com.aspose.words.Document(path + "merged.docx");
doc.save(fos, SaveFormat.PDF);
+ fos.flush();
} catch (Exception e) {
log.info(ExceptionUtil.stacktraceToString(e));
} finally {
- source.close();
- addObj.close();
- if (fos != null) {
- fos.flush();
- fos.close();
- }
+ IOUtils.closeQuietly(source);
+ IOUtils.closeQuietly(addObj);
+ IOUtils.closeQuietly(fos);
}