Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: shinnlok/liferay-plugins
...
head fork: liferay/liferay-plugins
compare: c4dc8db500
  • 2 commits
  • 2 files changed
  • 0 commit comments
  • 2 contributors
View
50 ...porter-web/docroot/WEB-INF/src/com/liferay/resourcesimporter/util/FileSystemImporter.java
@@ -76,9 +76,7 @@
public void importResources() throws Exception {
_resourcesDir = new File(resourcesDir);
- if (!_resourcesDir.exists() || !_resourcesDir.isDirectory() ||
- !_resourcesDir.canRead()) {
-
+ if (!_resourcesDir.isDirectory() || !_resourcesDir.canRead()) {
throw new IllegalArgumentException(
"Unaccessible resource directory " + resourcesDir);
}
@@ -91,9 +89,7 @@ protected void addDLFileEntries(String fileEntriesDirName)
File dlDocumentsDir = new File(_resourcesDir, fileEntriesDirName);
- if (!dlDocumentsDir.exists() || !dlDocumentsDir.isDirectory()||
- !dlDocumentsDir.canRead()) {
-
+ if (!dlDocumentsDir.isDirectory()|| !dlDocumentsDir.canRead()) {
return;
}
@@ -123,8 +119,7 @@ protected void addJournalArticles(
File journalArticlesDir = new File(_resourcesDir, articlesDirName);
- if (!journalArticlesDir.exists() ||
- !journalArticlesDir.isDirectory() ||
+ if (!journalArticlesDir.isDirectory() ||
!journalArticlesDir.canRead()) {
return;
@@ -157,8 +152,7 @@ protected void addJournalStructures(
File journalStructuresDir = new File(_resourcesDir, structuresDirName);
- if (!journalStructuresDir.exists() ||
- !journalStructuresDir.isDirectory() ||
+ if (!journalStructuresDir.isDirectory() ||
!journalStructuresDir.canRead()) {
return;
@@ -190,8 +184,7 @@ protected void addJournalTemplates(
File journalTemplatesDir = new File(_resourcesDir, templatesDirName);
- if (!journalTemplatesDir.exists() ||
- !journalTemplatesDir.isDirectory() ||
+ if (!journalTemplatesDir.isDirectory() ||
!journalTemplatesDir.canRead()) {
return;
@@ -423,12 +416,12 @@ protected void doAddJournalStructures(
nameMap, null, xsd, serviceContext);
addJournalTemplates(
- journalStructure.getStructureId(), "/journal/templates/" + name);
+ journalStructure.getStructureId(), _JOURNAL_TEMPLATES_DIR_NAME + name);
if (Validator.isNull(parentStructureId)) {
addJournalStructures(
journalStructure.getStructureId(),
- "/journal/structures/" + name);
+ _JOURNAL_STRUCTURES_DIR_NAME + name);
}
}
@@ -450,7 +443,7 @@ protected void doAddJournalTemplates(
addJournalArticles(
journalStructureId, journalTemplate.getTemplateId(),
- "/journal/articles/" + name);
+ _JOURNAL_ARTICLES_DIR_NAME + name);
}
protected void doImportResources() throws Exception {
@@ -513,18 +506,13 @@ protected JSONObject getJSONObject(InputStream inputStream)
protected String getName(String fileName) {
int x = fileName.lastIndexOf(StringPool.SLASH);
-
- if (x < 0) {
- x = 0;
- }
-
int y = fileName.lastIndexOf(StringPool.PERIOD);
if (y < 0) {
y = fileName.length();
}
- return fileName.substring(x, y);
+ return fileName.substring(x + 1, y);
}
protected Map<Locale, String> getNameMap(String name) {
@@ -602,14 +590,14 @@ protected String processJournalArticleContent(String content)
}
protected void setupAssets() throws Exception {
- addDLFileEntries("/document_library/documents");
+ addDLFileEntries(_DL_DOCUMENTS_DIR_NAME);
addJournalArticles(
- StringPool.BLANK, StringPool.BLANK, "/journal/articles");
+ StringPool.BLANK, StringPool.BLANK, _JOURNAL_ARTICLES_DIR_NAME);
- addJournalStructures(StringPool.BLANK, "/journal/structures");
+ addJournalStructures(StringPool.BLANK, _JOURNAL_STRUCTURES_DIR_NAME);
- addJournalTemplates(StringPool.BLANK, "/journal/templates");
+ addJournalTemplates(StringPool.BLANK, _JOURNAL_TEMPLATES_DIR_NAME);
}
protected void setupSettings(InputStream inputStream) throws Exception {
@@ -730,6 +718,18 @@ protected void updateLayoutSetThemeId(JSONObject sitemapJSONObject)
protected ServiceContext serviceContext;
+ private static final String _DL_DOCUMENTS_DIR_NAME =
+ "/document_library/documents/";
+
+ private static final String _JOURNAL_ARTICLES_DIR_NAME =
+ "/journal/articles/";
+
+ private static final String _JOURNAL_STRUCTURES_DIR_NAME =
+ "/journal/structures/";
+
+ private static final String _JOURNAL_TEMPLATES_DIR_NAME =
+ "/journal/templates/";
+
private String _defaultLayoutTemplateId;
private Map<String, FileEntry> _fileEntries =
new HashMap<String, FileEntry>();
View
64 ...importer-web/docroot/WEB-INF/src/com/liferay/resourcesimporter/util/ResourceImporter.java
@@ -44,23 +44,15 @@ protected void addDLFileEntries(String fileEntriesDirName)
}
for (String resourcePath : resourcePaths) {
- URL resourceURL = servletContext.getResource(resourcePath);
-
- String path = resourceURL.getPath();
-
- if (path.endsWith(StringPool.SLASH)) {
+ if (resourcePath.endsWith(StringPool.SLASH)) {
continue;
}
- URLConnection urlConnection = resourceURL.openConnection();
-
- String name = resourceURL.getFile();
+ String name = getName(resourcePath);
- int pos = name.lastIndexOf(StringPool.SLASH);
+ URL url = servletContext.getResource(resourcePath);
- if (pos != -1) {
- name = name.substring(pos + 1);
- }
+ URLConnection urlConnection = url.openConnection();
doAddDLFileEntries(
name, urlConnection.getInputStream(),
@@ -83,23 +75,15 @@ protected void addJournalArticles(
}
for (String resourcePath : resourcePaths) {
- URL resourceURL = servletContext.getResource(resourcePath);
-
- String path = resourceURL.getPath();
-
- if (path.endsWith(StringPool.SLASH)) {
+ if (resourcePath.endsWith(StringPool.SLASH)) {
continue;
}
- URLConnection urlConnection = resourceURL.openConnection();
-
- String name = resourceURL.getFile();
+ String name = getName(resourcePath);
- int pos = name.lastIndexOf(StringPool.SLASH);
+ URL resourceURL = servletContext.getResource(resourcePath);
- if (pos != -1) {
- name = name.substring(pos + 1);
- }
+ URLConnection urlConnection = resourceURL.openConnection();
doAddJournalArticles(
journalStructureId, journalTemplateId, name,
@@ -121,23 +105,15 @@ protected void addJournalStructures(
}
for (String resourcePath : resourcePaths) {
- URL resourceURL = servletContext.getResource(resourcePath);
-
- String path = resourceURL.getPath();
-
- if (path.endsWith(StringPool.SLASH)) {
+ if (resourcePath.endsWith(StringPool.SLASH)) {
continue;
}
- URLConnection urlConnection = resourceURL.openConnection();
-
- String name = resourceURL.getFile();
+ String name = getName(resourcePath);
- int pos = name.lastIndexOf(StringPool.SLASH);
+ URL resourceURL = servletContext.getResource(resourcePath);
- if (pos != -1) {
- name = name.substring(pos + 1);
- }
+ URLConnection urlConnection = resourceURL.openConnection();
doAddJournalStructures(
parentStructureId, name, urlConnection.getInputStream());
@@ -158,23 +134,15 @@ protected void addJournalTemplates(
}
for (String resourcePath : resourcePaths) {
- URL resourceURL = servletContext.getResource(resourcePath);
-
- String path = resourceURL.getPath();
-
- if (path.endsWith(StringPool.SLASH)) {
+ if (resourcePath.endsWith(StringPool.SLASH)) {
continue;
}
- URLConnection urlConnection = resourceURL.openConnection();
-
- String name = resourceURL.getFile();
+ String name = getName(resourcePath);
- int pos = name.lastIndexOf(StringPool.SLASH);
+ URL resourceURL = servletContext.getResource(resourcePath);
- if (pos != -1) {
- name = name.substring(pos + 1);
- }
+ URLConnection urlConnection = resourceURL.openConnection();
doAddJournalTemplates(
journalStructureId, name, urlConnection.getInputStream());

No commit comments for this range

Something went wrong with that request. Please try again.