private void saveConfigInfoIntoCache(String configType, String configInfo, IPath portalDir) { IPath versionsInfoPath = null; if (configType.equals(CONFIG_TYPE_VERSION)) { versionsInfoPath = LiferayServerCore.getDefault().getStateLocation().append("version.properties"); } else if (configType.equals(CONFIG_TYPE_SERVER)) { versionsInfoPath = LiferayServerCore.getDefault().getStateLocation().append("serverInfos.properties"); } if (versionsInfoPath != null) { File versionInfoFile = versionsInfoPath.toFile(); if (configInfo != null) { String portalDirKey = CoreUtil.createStringDigest(portalDir.toPortableString()); Properties properties = new Properties(); try (FileInputStream fileInput = new FileInputStream(versionInfoFile)) { properties.load(fileInput); } catch (Exception e) { } try (FileOutputStream fileOutput = new FileOutputStream(versionInfoFile)) { properties.put(portalDirKey, configInfo); properties.store(fileOutput, StringPool.EMPTY); } catch (Exception e) { LiferayServerCore.logError(e); } } } }
private IPath getConfigInfoPath(String configType) { IPath configInfoPath = null; if (configType.equals(CONFIG_TYPE_VERSION)) { configInfoPath = LiferayServerCore.getDefault().getStateLocation().append("version.properties"); } else if (configType.equals(CONFIG_TYPE_SERVER)) { configInfoPath = LiferayServerCore.getDefault().getStateLocation().append("serverInfos.properties"); } if (!clearedConfigInfoCacheOnce) { configInfoPath.toFile().delete(); clearedConfigInfoCacheOnce = true; } return configInfoPath; }