diff --git a/README.md b/README.md
index aa74269..65c388a 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
liferay-javamelody
=========================
-Plugin for JavaMelody to monitor performance in a [Liferay](http://www.liferay.com/) server 7.0 or later.
+Plugin for JavaMelody to monitor performance in a [Liferay](http://www.liferay.com/) server 6.1 or later.
See https://github.com/javamelody/javamelody/wiki
diff --git a/pom.xml b/pom.xml
index eed7634..a7b33ed 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
net.bull.javamelody
liferay-javamelody-hook
- 1.64.0
+ 1.63.1
war
Liferay JavaMelody Plugin
@@ -61,8 +61,8 @@
maven-compiler-plugin
3.1
-
- 1.8
+
+ 1.6
@@ -137,15 +137,16 @@
provided
- com.liferay.portal
- com.liferay.portal.kernel
- 2.21.0
+ com.liferay.portal
+ portal-service
+ 6.1.0
provided
- org.quartz-scheduler
- quartz
- 2.2.3
+ com.liferay.portal
+ com.liferay.portal.kernel
+ 2.21.0
+ provided
diff --git a/src/main/java/net/bull/javamelody/LiferayMonitoringFilter.java b/src/main/java/net/bull/javamelody/LiferayMonitoringFilter.java
index c470417..9e02d87 100644
--- a/src/main/java/net/bull/javamelody/LiferayMonitoringFilter.java
+++ b/src/main/java/net/bull/javamelody/LiferayMonitoringFilter.java
@@ -40,6 +40,8 @@
* @author Emeric Vernat
*/
public class LiferayMonitoringFilter extends PluginMonitoringFilter {
+ private boolean liferay7;
+
/** {@inheritDoc} */
@Override
public String getApplicationType() {
@@ -106,8 +108,23 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha
}
private boolean isAdmin(HttpServletRequest httpRequest) throws PortalException, SystemException {
- final long userId = PortalUtil.getUserId(httpRequest);
- final long companyId = PortalUtil.getDefaultCompanyId();
- return UserLocalServiceUtil.hasRoleUser(companyId, RoleConstants.ADMINISTRATOR, userId, true);
+ try {
+ if (!liferay7) {
+ // for liferay 6
+ final long userId = com.liferay.portal.util.PortalUtil.getUserId(httpRequest);
+ final long companyId = com.liferay.portal.util.PortalUtil.getDefaultCompanyId();
+ return com.liferay.portal.service.UserLocalServiceUtil.hasRoleUser(companyId,
+ com.liferay.portal.model.RoleConstants.ADMINISTRATOR, userId, true);
+ }
+ } catch (final NoClassDefFoundError e) {
+ liferay7 = true;
+ }
+ if (liferay7) {
+ // for liferay 7
+ final long userId = PortalUtil.getUserId(httpRequest);
+ final long companyId = PortalUtil.getDefaultCompanyId();
+ return UserLocalServiceUtil.hasRoleUser(companyId, RoleConstants.ADMINISTRATOR, userId, true);
+ }
+ return false;
}
}
diff --git a/src/main/webapp/WEB-INF/liferay-plugin-package.properties b/src/main/webapp/WEB-INF/liferay-plugin-package.properties
index 9e1edbc..0864a17 100644
--- a/src/main/webapp/WEB-INF/liferay-plugin-package.properties
+++ b/src/main/webapp/WEB-INF/liferay-plugin-package.properties
@@ -8,7 +8,7 @@ page-url=https://github.com/javamelody/javamelody/wiki
author=Emeric Vernat
licenses=ASL
# compatibility "6.1+" is currently like "6.1.1+,6.1.20+,6.2.0+" (6.1 CE GA2+,6.1 EE GA2+, and 6.2 CE GA1+)
-liferay-versions=7.0.0+
+liferay-versions=6.1+,7.0.0+
# security-manager required by the App Manager of Liferay Marketplace
#security-manager-enabled=true