/** * Initializes two <code>Hashtable</code> objects that are used to substitute $dlg_comp_id$root * macros in URL and absolute path expressions. * * @param mainRootPath * The given main component root directory path. */ protected void initSubstitutionTables(String mainRootPath) { Enumeration<String> idList = _installationTable.keys(); while (idList.hasMoreElements()) { String id = idList.nextElement(); String compIdRootUrlRegEx = componentIdRootRegExp(id, DELEGATE_ROOT_URL_SUFFIX_REGEX); String compIdRootRegEx = componentIdRootRegExp(id, DELEGATE_ROOT_SUFFIX_REGEX); // put 1 entry for URL and absolute path String rootPath = _installationTable.get(id); String rootPathUrl = FileUtil.localPathToFileUrl(rootPath); _urlSubstitutionTable.put(compIdRootUrlRegEx, rootPathUrl); _pathSubstitutionTable.put(compIdRootRegEx, rootPath); } }
/** * Substitutes '$main_root_url' and '$main_root' macros in a given string. * * @param source * The given source string. * @param mainRootPath * The given main component root directory path. * @return The result string with all the 'main' macros substituted and all '\' characters * replaced with '/' characters. */ protected static String substituteMainRootInString(String source, String mainRootPath) { String result = source; // substitute '$main_root_url' String replacement = StringUtil.toRegExpReplacement(FileUtil.localPathToFileUrl(mainRootPath)); result = result.replaceAll(MAIN_ROOT_URL_REGEX, replacement); // substitute '$main_root' replacement = StringUtil.toRegExpReplacement(mainRootPath); result = result.replaceAll(MAIN_ROOT_REGEX, replacement); return result.trim().replace('\\', '/'); }
/** * Substitutes '$dlg_comp_id$root_url' and '$dlg_comp_id$root' macros in a given string for a * given delegate component. * * @param source * The given source string. * @param compId * The given component ID. * @param compRootPath * The given component root directory path. * @return The result string with all the 'delegate' macros substituted and all '\' characters * replaced with '/' characters. */ protected static String substituteCompIdRootInString(String source, String compId, String compRootPath) { String result = source; // substitute '$dlg_comp_id$root_url' String regExp = componentIdRootRegExp(compId, DELEGATE_ROOT_URL_SUFFIX_REGEX); String fileUrl = FileUtil.localPathToFileUrl(compRootPath); String replacement = StringUtil.toRegExpReplacement(fileUrl); result = result.replaceAll(regExp, replacement); // substitute '$dlg_comp_id$root' regExp = componentIdRootRegExp(compId, DELEGATE_ROOT_SUFFIX_REGEX); replacement = StringUtil.toRegExpReplacement(compRootPath); result = result.replaceAll(regExp, replacement); return result.trim().replace('\\', '/'); }
File file = fileList.next(); String replacement = FileUtil.localPathToFileUrl(_mainRootPath); FileUtil.replaceStringInFile(file, MAIN_ROOT_URL_REGEX, replacement);
if (mainRootPath != null) { String replacement = FileUtil.localPathToFileUrl(mainRootPath); FileUtil.replaceStringInFile(file, InstallationProcessor.MAIN_ROOT_URL_REGEX, replacement); replacement = FileUtil.localPathToFileUrl(compRootPath); FileUtil.replaceStringInFile(file, regExp, replacement);