diff --git a/.classpath b/.classpath index d430d8b..b96f5b8 100644 --- a/.classpath +++ b/.classpath @@ -12,16 +12,16 @@ - - - - - + + + + + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index 884eab3..6249222 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -1,13 +1,12 @@ -#Sat Dec 22 19:34:21 CET 2012 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.compliance=1.7 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.source=1.6 +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml index c78d932..4f92af5 100644 --- a/.settings/org.eclipse.wst.common.project.facet.core.xml +++ b/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -1,5 +1,5 @@ - + diff --git a/distro/changelog.xml b/distro/changelog.xml index 7d8e7cc..213b45c 100644 --- a/distro/changelog.xml +++ b/distro/changelog.xml @@ -9,8 +9,13 @@ Removed GCF Dependency Logging with sl4j Enabled - - Added possibility to create programmatically layouts with framed portlets + Added possibility to create programmatically layouts with + framed portlets + + + Added getAdministratorUsername method in ScopeHelper \ No newline at end of file diff --git a/pom.xml b/pom.xml index ad654dc..0eff1ee 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ org.gcube.portal custom-portal-handler - 1.4.0-SNAPSHOT + 1.5.0-SNAPSHOT jar Custom Portal Handler @@ -24,8 +24,8 @@ distro - 1.6 - 1.6 + 1.7 + 1.7 UTF-8 UTF-8 @@ -93,8 +93,8 @@ maven-compiler-plugin 3.0 - 1.6 - 1.6 + 1.7 + 1.7 diff --git a/src/main/java/org/gcube/portal/custom/scopemanager/scopehelper/ScopeHelper.java b/src/main/java/org/gcube/portal/custom/scopemanager/scopehelper/ScopeHelper.java index 317bed6..4c32927 100644 --- a/src/main/java/org/gcube/portal/custom/scopemanager/scopehelper/ScopeHelper.java +++ b/src/main/java/org/gcube/portal/custom/scopemanager/scopehelper/ScopeHelper.java @@ -3,6 +3,7 @@ package org.gcube.portal.custom.scopemanager.scopehelper; import java.io.File; import java.io.FileInputStream; import java.io.IOException; +import java.util.List; import java.util.Properties; import javax.portlet.PortletSession; @@ -20,9 +21,15 @@ import com.liferay.portal.kernel.log.LogFactoryUtil; import com.liferay.portal.kernel.util.WebKeys; import com.liferay.portal.model.Group; import com.liferay.portal.model.Organization; +import com.liferay.portal.model.Role; import com.liferay.portal.model.User; +import com.liferay.portal.security.auth.PrincipalThreadLocal; +import com.liferay.portal.security.permission.PermissionChecker; +import com.liferay.portal.security.permission.PermissionCheckerFactoryUtil; +import com.liferay.portal.security.permission.PermissionThreadLocal; import com.liferay.portal.service.GroupLocalServiceUtil; import com.liferay.portal.service.OrganizationLocalServiceUtil; +import com.liferay.portal.service.RoleLocalServiceUtil; import com.liferay.portal.service.UserLocalServiceUtil; import com.liferay.portal.theme.ThemeDisplay; @@ -45,7 +52,7 @@ public class ScopeHelper { public static final String CURR_ORG = "CURR_RE_NAME"; - public static final String MAIL = "supportmail"; + public static final String MAIL = "notificationSenderEmail"; public static void setContext(RenderRequest request) { setContext(request, USERNAME_ATTRIBUTE); @@ -148,14 +155,14 @@ public class ScopeHelper { props.load( fis); toReturn = props.getProperty(MAIL); if (toReturn == null || toReturn.compareTo("")==0) { - toReturn = "support_team@d4science.org"; + toReturn = "do-not-reply@isti.cnr.it"; _log.error("Property "+MAIL+" in $CATALINA_HOME/conf/gcube-data.properties was not found, returning default support mailing address " + toReturn); } else _log.trace("Found Mail Support address: " + toReturn ); } //catch exception in case properties file does not exist catch(IOException e) { - toReturn = "support_team@d4science.org"; + toReturn = "do-not-reply@isti.cnr.it"; _log.error("gcube-data.properties file not found under $CATALINA_HOME/conf dir, returning default support mailing address " + toReturn); return toReturn; } @@ -180,4 +187,31 @@ public class ScopeHelper { public static String getRootConfigFromGCore() { return PortalContext.getConfiguration().getInfrastructureName(); } + + /** + * return one of the Administrators Username from LiferayDB + */ + public static String getAdministratorUsername() { + + String toReturn = ""; + + try { + Role adminRole = RoleLocalServiceUtil.getRole(OrganizationsUtil.getCompany().getCompanyId(),"Administrator"); + List adminUsers = UserLocalServiceUtil.getRoleUsers(adminRole.getRoleId()); + if (adminUsers != null && adminUsers.size() > 0) + toReturn = adminUsers.get(0).getScreenName(); + else + _log.warn("No users with Administrator Role in this portal!"); + } + //catch exception in case properties file does not exist + catch(Exception e) { + toReturn = "Exception"; + _log.error("No users with Administrator Role in this portal, returning " + toReturn); + e.printStackTrace(); + return toReturn; + } + _log.debug("Returning ADMIN username=" + toReturn ); + return toReturn; + } + }