Browse files

LPS-30590 Replace file placeholders in templates

  • Loading branch information...
1 parent 0968519 commit e0d43efb7be954d3ce1854727ce8cf732e5b93b2 @shinnlok shinnlok committed with brianchandotcom Oct 29, 2012
View
46 ...porter-web/docroot/WEB-INF/src/com/liferay/resourcesimporter/util/FileSystemImporter.java
@@ -452,6 +452,8 @@ protected void doAddJournalTemplates(
String xsl = StringUtil.read(inputStream);
+ xsl = replaceFileEntryURL(xsl);
+
setServiceContext(fileName);
JournalTemplate journalTemplate =
@@ -586,25 +588,7 @@ protected JSONObject getJSONObject(String fileName) throws Exception {
protected String processJournalArticleContent(String content)
throws Exception {
- Matcher matcher = _fileEntryPattern.matcher(content);
-
- while (matcher.find()) {
- String fileName = matcher.group(1);
-
- FileEntry fileEntry = _fileEntries.get(fileName);
-
- String fileEntryURL = StringPool.BLANK;
-
- if (fileEntry != null) {
- fileEntryURL = DLUtil.getPreviewURL(
- fileEntry, fileEntry.getFileVersion(), null,
- StringPool.BLANK);
- }
-
- content = matcher.replaceFirst(fileEntryURL);
-
- matcher.reset(content);
- }
+ content = replaceFileEntryURL(content);
if (content.contains("<?xml version=\"1.0\"")) {
return content;
@@ -629,6 +613,30 @@ protected String processJournalArticleContent(String content)
return sb.toString();
}
+ protected String replaceFileEntryURL(String content) throws Exception {
+ Matcher matcher = _fileEntryPattern.matcher(content);
+
+ while (matcher.find()) {
+ String fileName = matcher.group(1);
+
+ FileEntry fileEntry = _fileEntries.get(fileName);
+
+ String fileEntryURL = StringPool.BLANK;
+
+ if (fileEntry != null) {
+ fileEntryURL = DLUtil.getPreviewURL(
+ fileEntry, fileEntry.getFileVersion(), null,
+ StringPool.BLANK);
+ }
+
+ content = matcher.replaceFirst(fileEntryURL);
+
+ matcher.reset(content);
+ }
+
+ return content;
+ }
+
protected void setServiceContext(String name) {
String[] assetTagNames = _assetTagNames.get(name);

0 comments on commit e0d43ef

Please sign in to comment.