Browse Source

Pull request #9130: REPORT-71790 操作系统为Cp1252编码 读取中文乱码

Merge in DESIGN/design from ~HADES/design:release/11.0 to release/11.0

* commit '7d6a2263d04359a3e381cb756156456a21b4fba0':
  REPORT-71790 操作系统为Cp1252编码 读取中文乱码
newui
Hades 2 years ago
parent
commit
76c5071396
  1. 2
      designer-base/src/main/java/com/fr/design/DesignerEnvManager.java
  2. 18
      designer-base/src/main/java/com/fr/exit/ConfigToPropMigrator.java
  3. 40
      designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java

2
designer-base/src/main/java/com/fr/design/DesignerEnvManager.java

@ -2220,7 +2220,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
writer.attr("layoutTemplateStyle", this.getLayoutTemplateStyle()); writer.attr("layoutTemplateStyle", this.getLayoutTemplateStyle());
writer.attr("showServerDatasetAuthTip", this.isShowServerDatasetAuthTip()); writer.attr("showServerDatasetAuthTip", this.isShowServerDatasetAuthTip());
writer.attr("useOptimizedUPM4Adapter", this.isUseOptimizedUPM4Adapter()); writer.attr("useOptimizedUPM4Adapter", this.isUseOptimizedUPM4Adapter());
writer.attr("propertiesUsable", false); writer.attr("propertiesUsable", this.isPropertiesUsable());
writer.end(); writer.end();
} }

18
designer-base/src/main/java/com/fr/exit/ConfigToPropMigrator.java

@ -10,6 +10,8 @@ import com.fr.workspace.WorkContext;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStreamWriter;
import java.nio.charset.StandardCharsets;
import java.sql.Blob; import java.sql.Blob;
import java.sql.Connection; import java.sql.Connection;
import java.sql.DriverManager; import java.sql.DriverManager;
@ -62,9 +64,9 @@ public class ConfigToPropMigrator {
initDirectory(); initDirectory();
try (Connection c = DriverManager.getConnection(url); try (Connection c = DriverManager.getConnection(url);
FileOutputStream entityOut = new FileOutputStream(PropertiesConstants.ENTITY_PROP_PATH); OutputStreamWriter xmlEntityOut = new OutputStreamWriter(new FileOutputStream(PropertiesConstants.XML_ENTITY_PROP_PATH), StandardCharsets.UTF_8);
FileOutputStream classHelperOut = new FileOutputStream(PropertiesConstants.CLASS_NAME_PROP_PATH); OutputStreamWriter entityOut = new OutputStreamWriter(new FileOutputStream(PropertiesConstants.ENTITY_PROP_PATH), StandardCharsets.UTF_8);
FileOutputStream xmlEntityOut = new FileOutputStream(PropertiesConstants.XML_ENTITY_PROP_PATH)) { OutputStreamWriter classHelperOut = new OutputStreamWriter(new FileOutputStream(PropertiesConstants.CLASS_NAME_PROP_PATH), StandardCharsets.UTF_8)) {
processClassOrEntity(c, new Properties(), SELECT_FOR_ENTITY, entityOut); processClassOrEntity(c, new Properties(), SELECT_FOR_ENTITY, entityOut);
processClassOrEntity(c, new Properties(), SELECT_FOR_CLASSNAME, classHelperOut); processClassOrEntity(c, new Properties(), SELECT_FOR_CLASSNAME, classHelperOut);
@ -84,7 +86,7 @@ public class ConfigToPropMigrator {
} }
} }
private void processClassOrEntity(Connection c, Properties map, String sql, FileOutputStream outputStream) throws SQLException, IOException { private void processClassOrEntity(Connection c, Properties map, String sql, OutputStreamWriter writer) throws SQLException, IOException {
PreparedStatement query = c.prepareStatement(sql); PreparedStatement query = c.prepareStatement(sql);
ResultSet resultSet = query.executeQuery(); ResultSet resultSet = query.executeQuery();
while (resultSet.next()) { while (resultSet.next()) {
@ -94,19 +96,19 @@ public class ConfigToPropMigrator {
map.setProperty(id, value); map.setProperty(id, value);
} }
} }
map.store(outputStream, null); map.store(writer, null);
} }
private void processXmlEntity(Connection c, Properties map, FileOutputStream outputStream) throws SQLException, IOException { private void processXmlEntity(Connection c, Properties map, OutputStreamWriter writer) throws SQLException, IOException {
PreparedStatement query = c.prepareStatement(SELECT_FOR_XML_ENTITY); PreparedStatement query = c.prepareStatement(SELECT_FOR_XML_ENTITY);
ResultSet resultSet = query.executeQuery(); ResultSet resultSet = query.executeQuery();
while (resultSet.next()) { while (resultSet.next()) {
String id = resultSet.getString(1); String id = resultSet.getString(1);
Blob value = resultSet.getBlob(2); Blob value = resultSet.getBlob(2);
byte[] bytes = value.getBytes(1L, (int) value.length()); byte[] bytes = value.getBytes(1L, (int) value.length());
map.setProperty(id, new String(bytes)); map.setProperty(id, new String(bytes, StandardCharsets.UTF_8));
} }
map.store(outputStream, null); map.store(writer, null);
} }
public void deletePropertiesCache() { public void deletePropertiesCache() {

40
designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java

@ -158,26 +158,26 @@ public class DesignerStartup extends Activator {
private void registerDaoSelector() { private void registerDaoSelector() {
// 注入设计器db cache 是否可用 // 注入设计器db cache 是否可用
DaoSelectorFactory.registerDaoSelector(() -> false); DesignerWorkspaceInfo info = WorkspaceUtils.getWorkspaceInfo();
// DesignerWorkspaceInfo info = WorkspaceUtils.getWorkspaceInfo(); if (info.getType() == DesignerWorkspaceType.Remote) {
// if (info.getType() == DesignerWorkspaceType.Remote) { DaoSelectorFactory.registerDaoSelector(() -> false);
// } else { } else {
// String webInfPath = WorkspaceUtils.getWorkspaceInfo().getPath(); String webInfPath = WorkspaceUtils.getWorkspaceInfo().getPath();
// String dbConfigPath = StableUtils.pathJoin(webInfPath, ProjectConstants.CONFIG_DIRECTORY, String dbConfigPath = StableUtils.pathJoin(webInfPath, ProjectConstants.CONFIG_DIRECTORY,
// EncryptionConstants.PROPERTY_NAME); EncryptionConstants.PROPERTY_NAME);
// String entityPath = generatePath(webInfPath, PropertiesConstants.ENTITY_PROP); String entityPath = generatePath(webInfPath, PropertiesConstants.ENTITY_PROP);
// String xmlEntityPath = generatePath(webInfPath, PropertiesConstants.XML_ENTITY_PROP); String xmlEntityPath = generatePath(webInfPath, PropertiesConstants.XML_ENTITY_PROP);
// String classNamePath = generatePath(webInfPath, PropertiesConstants.CLASS_NAME_PROP); String classNamePath = generatePath(webInfPath, PropertiesConstants.CLASS_NAME_PROP);
// // 校验 平台迁移文件/缓存文件 // 校验 平台迁移文件/缓存文件
// boolean existPropCache = new File(entityPath).exists() && new File(xmlEntityPath).exists() && new File(classNamePath).exists(); boolean existPropCache = new File(entityPath).exists() && new File(xmlEntityPath).exists() && new File(classNamePath).exists();
// DaoSelectorFactory.registerDaoSelector(() -> DesignerEnvManager.getEnvManager().isPropertiesUsable() DaoSelectorFactory.registerDaoSelector(() -> DesignerEnvManager.getEnvManager().isPropertiesUsable()
// && OptimizeUtil.isOpen() && OptimizeUtil.isOpen()
// && existPropCache && existPropCache
// // demo启动时 前后目录可能会不一致 造成读取缓存失败 // demo启动时 前后目录可能会不一致 造成读取缓存失败
// && !startupArgsValue.getValue().isDemo() && !startupArgsValue.getValue().isDemo()
// && !new File(dbConfigPath).exists()); && !new File(dbConfigPath).exists());
//
// } }
} }
private String generatePath(String webInfPath, String name) { private String generatePath(String webInfPath, String name) {

Loading…
Cancel
Save