diff --git a/src/main/java/neatlogic/framework/bootstrap/ModuleInitializer.java b/src/main/java/neatlogic/framework/bootstrap/ModuleInitializer.java index 78f39dbc07b7d44ff930367bf8fad4006cead822..8ac64226310af1125be1bca3b20ca52a886e237c 100644 --- a/src/main/java/neatlogic/framework/bootstrap/ModuleInitializer.java +++ b/src/main/java/neatlogic/framework/bootstrap/ModuleInitializer.java @@ -129,7 +129,8 @@ public class ModuleInitializer implements WebApplicationInitializer { Resource[] resources = resolver.getResources("classpath*:neatlogic/**/*-servlet-context.xml"); for (Resource resource : resources) { String path = resource.getURL().getPath(); - path = path.substring(path.indexOf("!") + 1); +// path = path.substring(path.indexOf("!") + 1); + path = path.substring(path.lastIndexOf("/neatlogic/") + 1); SAXReader reader = new SAXReader(); Document document = reader.read(resource.getURL()); Element rootE = document.getRootElement(); @@ -291,18 +292,22 @@ public class ModuleInitializer implements WebApplicationInitializer { List errorList = new ArrayList<>(); Map> moduleVersionListMap = new HashMap<>(); //检查changelog下合法版本 - Resource[] resources = resolver.getResources("classpath*:neatlogic/resources/*/changelog/*/"); + Resource[] resources = resolver.getResources("classpath*:neatlogic/resources/*/changelog/*/*"); for (Resource resource : resources) { //目前 String fileName = resource.getURL().getPath().substring(0, resource.getURL().getPath().lastIndexOf("/")); String version = fileName.substring(fileName.lastIndexOf("/") + 1); if (!Objects.equals("changelog", version) && StringUtils.isNotBlank(version)) { String path = resource.getURL().getPath(); - path = path.substring(path.indexOf("!") + 1); +// path = path.substring(path.indexOf("!") + 1); + path = path.substring(path.lastIndexOf("/neatlogic/resources/")); if (StringUtils.isNotBlank(path)) { String moduleId = path.split("/")[3]; if (version.matches("\\d{4}-\\d{2}-\\d{2}(-\\d{2})?")) { - moduleVersionListMap.computeIfAbsent(moduleId, k -> new ArrayList<>()).add(version); + List list = moduleVersionListMap.computeIfAbsent(moduleId, k -> new ArrayList<>()); + if (!list.contains(version)) { + list.add(version); + } } else { errorList.add(path); } diff --git a/src/main/java/neatlogic/framework/i18n/ReloadableJsonBundleMessageSource.java b/src/main/java/neatlogic/framework/i18n/ReloadableJsonBundleMessageSource.java index 5c178160f2345c167395111a305595e5129f22f4..cd4122862488cd78a98351293a39c3d3a0d29c64 100644 --- a/src/main/java/neatlogic/framework/i18n/ReloadableJsonBundleMessageSource.java +++ b/src/main/java/neatlogic/framework/i18n/ReloadableJsonBundleMessageSource.java @@ -28,8 +28,10 @@ import org.springframework.lang.Nullable; import org.springframework.util.PropertiesPersister; import org.springframework.util.StringUtils; +import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; +import java.io.InputStreamReader; import java.text.MessageFormat; import java.util.*; import java.util.concurrent.ConcurrentHashMap; @@ -481,11 +483,26 @@ public class ReloadableJsonBundleMessageSource extends AbstractResourceBasedMess } private Map readJsonFile(Resource resource) throws IOException { - try (InputStream inputStream = resource.getInputStream()) { - byte[] bytes = new byte[inputStream.available()]; - inputStream.read(bytes); - String json = new String(bytes); - JSONObject rawJsonObject = JSON.parseObject(json); +// try (InputStream inputStream = resource.getInputStream()) { +// byte[] bytes = new byte[inputStream.available()]; +// inputStream.read(bytes); +// String json = new String(bytes); +// JSONObject rawJsonObject = JSON.parseObject(json); +// Map flattenedMap = new HashMap<>(); +// flattenMap("", rawJsonObject, flattenedMap); +// return flattenedMap; +// } + try ( + InputStream inputStream = resource.getInputStream(); + InputStreamReader inputStreamReader = new InputStreamReader(inputStream); + BufferedReader bufferedReader = new BufferedReader(inputStreamReader); + ) { + StringBuilder stringBuilder = new StringBuilder(); + String line = null; + while((line = bufferedReader.readLine()) != null) { + stringBuilder.append(line); + } + JSONObject rawJsonObject = JSON.parseObject(stringBuilder.toString()); Map flattenedMap = new HashMap<>(); flattenMap("", rawJsonObject, flattenedMap); return flattenedMap; diff --git a/src/main/java/neatlogic/module/framework/startup/DocumentOnlineInitializeIndexHandler.java b/src/main/java/neatlogic/module/framework/startup/DocumentOnlineInitializeIndexHandler.java index 3da0a5f48d1f154d82b4bde1bf67037b114f441f..355b20c898ba3b40cb62159045fb087dc3328e1e 100644 --- a/src/main/java/neatlogic/module/framework/startup/DocumentOnlineInitializeIndexHandler.java +++ b/src/main/java/neatlogic/module/framework/startup/DocumentOnlineInitializeIndexHandler.java @@ -158,8 +158,10 @@ public class DocumentOnlineInitializeIndexHandler extends StartupBase { } } String path = resource.getURL().getPath(); - int separatorIndex = path.indexOf("!/"); - String filePath = path.substring(separatorIndex + 2); +// int separatorIndex = path.indexOf("!/"); +// String filePath = path.substring(separatorIndex + 2); + int separatorIndex = path.lastIndexOf("/neatlogic/resources/"); + String filePath = path.substring(separatorIndex + 1); if (existingFilePathList.contains(filePath)) { logger.error($.t("nmfs.documentonlineinitializeindexhandler.executeforalltenant.error", filePath)); System.exit(1);