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 String getConfigInfoFromCache(String configType, IPath portalDir) { File configInfoFile = getConfigInfoPath(configType).toFile(); String portalDirKey = CoreUtil.createStringDigest(portalDir.toPortableString()); Properties properties = new Properties(); if (configInfoFile.exists()) { try (FileInputStream fileInput = new FileInputStream(configInfoFile)) { properties.load(fileInput); String configInfo = (String) properties.get(portalDirKey); if (!CoreUtil.isNullOrEmpty(configInfo)) { return configInfo; } } catch (IOException e) { LiferayServerCore.logError(e); } } return null; }