Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

LPS-30463 Add developer mode

  • Loading branch information...
commit e8fe89853dccee2db4114cf7574b891840bb474b 1 parent 811c07a
@shinnlok shinnlok authored brianchandotcom committed
View
5 webs/resources-importer-web/docroot/WEB-INF/liferay-plugin-package.properties
@@ -8,4 +8,7 @@ change-log=
page-url=http://www.liferay.com
author=Liferay, Inc.
licenses=LGPL
-liferay-versions=6.2.0
+liferay-versions=6.2.0
+
+portal-dependency-jars=\
+ commons-lang.jar
View
22 ...docroot/WEB-INF/src/com/liferay/resourcesimporter/messaging/HotDeployMessageListener.java
@@ -32,6 +32,7 @@
import com.liferay.resourcesimporter.util.Importer;
import com.liferay.resourcesimporter.util.ImporterException;
import com.liferay.resourcesimporter.util.LARImporter;
+import com.liferay.resourcesimporter.util.PortletPropsValues;
import com.liferay.resourcesimporter.util.ResourceImporter;
import java.io.IOException;
@@ -45,6 +46,8 @@
import javax.servlet.ServletContext;
+import org.apache.commons.lang.time.StopWatch;
+
/**
* @author Ryan Park
* @author Raymond Augé
@@ -137,7 +140,9 @@ else if ((resourcePaths != null) && !resourcePaths.isEmpty()) {
importer.afterPropertiesSet();
- if (importer.getGroupId() == 0) {
+ if (!PortletPropsValues.DEVELOPER_MODE_ENABLED &&
+ importer.isExisting()) {
+
if (_log.isInfoEnabled()) {
_log.info(
"Group or layout set prototype already exists " +
@@ -147,14 +152,23 @@ else if ((resourcePaths != null) && !resourcePaths.isEmpty()) {
continue;
}
+ StopWatch stopWatch = null;
+
if (_log.isInfoEnabled()) {
- _log.info(
- "Importing resources from " + servletContextName +
- " to group " + importer.getGroupId());
+ stopWatch = new StopWatch();
+
+ stopWatch.start();
}
importer.importResources();
+ if (_log.isInfoEnabled()) {
+ _log.info(
+ "Importing resources from " + servletContextName +
+ " to group " + importer.getGroupId() + " takes " +
+ stopWatch.getTime() + " ms");
+ }
+
Message newMessage = new Message();
newMessage.put("companyId", company.getCompanyId());
View
82 ...ces-importer-web/docroot/WEB-INF/src/com/liferay/resourcesimporter/util/BaseImporter.java
@@ -51,25 +51,31 @@ public void afterPropertiesSet() throws Exception {
Group group = null;
if (targetClassName.equals(LayoutSetPrototype.class.getName())) {
- if (!hasLayoutSetPrototype(companyId, targetValue)) {
- LayoutSetPrototype layoutSetPrototype =
+ LayoutSetPrototype layoutSetPrototype = getLayoutSetPrototype(
+ companyId, targetValue);
+
+ if (layoutSetPrototype != null) {
+ existing = true;
+ }
+ else {
+ layoutSetPrototype =
LayoutSetPrototypeLocalServiceUtil.addLayoutSetPrototype(
userId, companyId, getTargetValueMap(),
StringPool.BLANK, true, true, new ServiceContext());
+ }
- group = layoutSetPrototype.getGroup();
+ group = layoutSetPrototype.getGroup();
- privateLayout = true;
- targetClassPK = layoutSetPrototype.getLayoutSetPrototypeId();
- }
+ privateLayout = true;
+ targetClassPK = layoutSetPrototype.getLayoutSetPrototypeId();
}
else if (targetClassName.equals(Group.class.getName())) {
if (targetValue.equals(GroupConstants.GUEST)) {
- Group guestGroup = GroupLocalServiceUtil.getGroup(
+ group = GroupLocalServiceUtil.getGroup(
companyId, GroupConstants.GUEST);
List<Layout> layouts = LayoutLocalServiceUtil.getLayouts(
- guestGroup.getGroupId(), false,
+ group.getGroupId(), false,
LayoutConstants.DEFAULT_PARENT_LAYOUT_ID, false, 0, 1);
if (!layouts.isEmpty()) {
@@ -81,39 +87,41 @@ else if (targetClassName.equals(Group.class.getName())) {
List<String> portletIds = layoutTypePortlet.getPortletIds();
if (portletIds.size() != 2) {
- return;
+ existing = true;
}
for (String portletId : portletIds) {
if (!portletId.equals("47") &&
!portletId.equals("58")) {
- return;
+ existing = true;
}
}
}
-
- group = guestGroup;
- }
- else if (!hasGroup(companyId, targetValue)) {
- group = GroupLocalServiceUtil.addGroup(
- userId, GroupConstants.DEFAULT_PARENT_GROUP_ID,
- StringPool.BLANK, 0, targetValue, StringPool.BLANK,
- GroupConstants.TYPE_SITE_OPEN, null, true, true,
- new ServiceContext());
}
+ else {
+ group = GroupLocalServiceUtil.fetchGroup(
+ companyId, targetValue);
- if (group != null) {
- privateLayout = false;
- targetClassPK = group.getGroupId();
+ if (group != null) {
+ existing = true;
+ }
+ else {
+ group = GroupLocalServiceUtil.addGroup(
+ userId, GroupConstants.DEFAULT_PARENT_GROUP_ID,
+ StringPool.BLANK, 0, targetValue, StringPool.BLANK,
+ GroupConstants.TYPE_SITE_OPEN, null, true, true,
+ new ServiceContext());
+ }
}
- }
- if (group == null) {
- return;
+ privateLayout = false;
+ targetClassPK = group.getGroupId();
}
- groupId = group.getGroupId();
+ if (group != null) {
+ groupId = group.getGroupId();
+ }
}
public long getGroupId() {
@@ -134,6 +142,10 @@ public long getTargetClassPK() {
return targetValueMap;
}
+ public boolean isExisting() {
+ return existing;
+ }
+
public void setCompanyId(long companyId) {
this.companyId = companyId;
}
@@ -158,17 +170,8 @@ public void setTargetValue(String targetValue) {
this.targetValue = targetValue;
}
- protected boolean hasGroup(long companyId, String name) throws Exception {
- Group group = GroupLocalServiceUtil.fetchGroup(companyId, name);
-
- if (group != null) {
- return true;
- }
-
- return false;
- }
-
- protected boolean hasLayoutSetPrototype(long companyId, String name)
+ protected LayoutSetPrototype getLayoutSetPrototype(
+ long companyId, String name)
throws Exception {
Locale locale = LocaleUtil.getDefault();
@@ -179,14 +182,15 @@ protected boolean hasLayoutSetPrototype(long companyId, String name)
for (LayoutSetPrototype layoutSetPrototype : layoutSetPrototypes) {
if (name.equals(layoutSetPrototype.getName(locale))) {
- return true;
+ return layoutSetPrototype;
}
}
- return false;
+ return null;
}
protected long companyId;
+ protected boolean existing;
protected long groupId;
protected boolean privateLayout;
protected String resourcesDir;
View
16 ...porter-web/docroot/WEB-INF/src/com/liferay/resourcesimporter/util/FileSystemImporter.java
@@ -35,6 +35,7 @@
import com.liferay.portal.service.LayoutLocalServiceUtil;
import com.liferay.portal.service.LayoutSetLocalServiceUtil;
import com.liferay.portal.service.LayoutSetPrototypeLocalServiceUtil;
+import com.liferay.portal.service.RepositoryLocalServiceUtil;
import com.liferay.portal.service.ServiceContext;
import com.liferay.portal.service.ThemeLocalServiceUtil;
import com.liferay.portal.util.PortalUtil;
@@ -416,7 +417,8 @@ protected void doAddJournalStructures(
nameMap, null, xsd, serviceContext);
addJournalTemplates(
- journalStructure.getStructureId(), _JOURNAL_TEMPLATES_DIR_NAME + name);
+ journalStructure.getStructureId(),
+ _JOURNAL_TEMPLATES_DIR_NAME + name);
if (Validator.isNull(parentStructureId)) {
addJournalStructures(
@@ -590,6 +592,14 @@ protected String processJournalArticleContent(String content)
}
protected void setupAssets() throws Exception {
+ RepositoryLocalServiceUtil.deleteRepositories(groupId);
+
+ JournalArticleLocalServiceUtil.deleteArticles(groupId);
+
+ JournalTemplateLocalServiceUtil.deleteTemplates(groupId);
+
+ JournalStructureLocalServiceUtil.deleteStructures(groupId);
+
addDLFileEntries(_DL_DOCUMENTS_DIR_NAME);
addJournalArticles(
@@ -723,10 +733,10 @@ protected void updateLayoutSetThemeId(JSONObject sitemapJSONObject)
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/";
View
2  ...sources-importer-web/docroot/WEB-INF/src/com/liferay/resourcesimporter/util/Importer.java
@@ -30,6 +30,8 @@
public void importResources() throws Exception;
+ public boolean isExisting();
+
public void setCompanyId(long companyId);
public void setResourcesDir(String resourcesDir);
View
25 ...importer-web/docroot/WEB-INF/src/com/liferay/resourcesimporter/util/PortletPropsKeys.java
@@ -0,0 +1,25 @@
+/**
+ * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ */
+
+package com.liferay.resourcesimporter.util;
+
+/**
+ * @author Shinn Lok
+ */
+public interface PortletPropsKeys {
+
+ public static final String DEVELOPER_MODE_ENABLED =
+ "developer.mode.enabled";
+
+}
View
28 ...porter-web/docroot/WEB-INF/src/com/liferay/resourcesimporter/util/PortletPropsValues.java
@@ -0,0 +1,28 @@
+/**
+ * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ */
+
+package com.liferay.resourcesimporter.util;
+
+import com.liferay.portal.kernel.util.GetterUtil;
+import com.liferay.util.portlet.PortletProps;
+
+/**
+ * @author Shinn Lok
+ */
+public class PortletPropsValues {
+
+ public static final boolean DEVELOPER_MODE_ENABLED = GetterUtil.getBoolean(
+ PortletProps.get(PortletPropsKeys.DEVELOPER_MODE_ENABLED));
+
+}
View
3  webs/resources-importer-web/docroot/WEB-INF/src/portlet.properties
@@ -0,0 +1,3 @@
+include-and-override=portlet-ext.properties
+
+developer.mode.enabled=false
Please sign in to comment.
Something went wrong with that request. Please try again.