Browse Source

REPORT-57806 主题获取

【问题原因】
主题文件下载后读取失败

【改动思路】
同上
research/11.0
Starryi 3 years ago
parent
commit
3eac188cf8
  1. 17
      designer-form/src/main/java/com/fr/design/mainframe/share/util/DownloadUtils.java

17
designer-form/src/main/java/com/fr/design/mainframe/share/util/DownloadUtils.java

@ -1,7 +1,6 @@
package com.fr.design.mainframe.share.util; package com.fr.design.mainframe.share.util;
import com.fr.base.theme.FormTheme; import com.fr.base.theme.FormTheme;
import com.fr.base.theme.TemplateTheme;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.extra.PluginConstants; import com.fr.design.extra.PluginConstants;
import com.fr.form.share.base.CancelCheck; import com.fr.form.share.base.CancelCheck;
@ -15,7 +14,6 @@ import com.fr.stable.StringUtils;
import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLReaderHelper; import com.fr.stable.xml.XMLReaderHelper;
import com.fr.stable.xml.XMLableReader; import com.fr.stable.xml.XMLableReader;
import com.fr.third.javax.xml.stream.XMLStreamException;
import com.fr.third.org.apache.http.HttpEntity; import com.fr.third.org.apache.http.HttpEntity;
import com.fr.third.org.apache.http.HttpException; import com.fr.third.org.apache.http.HttpException;
import com.fr.third.org.apache.http.HttpStatus; import com.fr.third.org.apache.http.HttpStatus;
@ -30,11 +28,12 @@ import com.fr.third.org.apache.http.impl.client.HttpClients;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import javax.crypto.Cipher; import javax.crypto.Cipher;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.security.KeyFactory; import java.security.KeyFactory;
import java.security.interfaces.RSAPublicKey; import java.security.interfaces.RSAPublicKey;
@ -147,8 +146,16 @@ public class DownloadUtils {
} }
if (fileRes.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { if (fileRes.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
HttpEntity entity = fileRes.getEntity(); HttpEntity entity = fileRes.getEntity();
InputStream content = entity.getContent();
XMLableReader reader = XMLReaderHelper.createXMLableReader(content, XMLPrintWriter.XML_ENCODER); BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(entity.getContent()));
StringBuilder stringBuilder = new StringBuilder();
String line;
while ((line = bufferedReader.readLine()) != null) {
stringBuilder.append(line);
}
String content = stringBuilder.toString();
XMLableReader reader = XMLReaderHelper.createXMLableReader(new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8)), XMLPrintWriter.XML_ENCODER);
FormTheme theme = new FormTheme(); FormTheme theme = new FormTheme();
reader.readXMLObject(theme); reader.readXMLObject(theme);

Loading…
Cancel
Save