added getAdministratorUsername method in ScopeHelper, moved to Java7
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portal/custom-portal-handler@94129 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
9e80d27a5d
commit
b138d0ae37
10
.classpath
10
.classpath
|
@ -12,16 +12,16 @@
|
|||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
|
||||
<attributes>
|
||||
<attribute name="owner.project.facets" value="java"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<faceted-project>
|
||||
<installed facet="java" version="1.6"/>
|
||||
<installed facet="jst.utility" version="1.0"/>
|
||||
<installed facet="java" version="1.7"/>
|
||||
</faceted-project>
|
||||
|
|
|
@ -9,8 +9,13 @@
|
|||
<Change>Removed GCF Dependency</Change>
|
||||
<Change>Logging with sl4j Enabled</Change>
|
||||
</Changeset>
|
||||
<Changeset component="org.gcube.portal.custom-portal-handler.1-4-0"
|
||||
<Changeset component="org.gcube.portal.custom-portal-handler.1-4-0"
|
||||
date="2014-03-4">
|
||||
<Change>Added possibility to create programmatically layouts with framed portlets</Change>
|
||||
<Change>Added possibility to create programmatically layouts with
|
||||
framed portlets</Change>
|
||||
</Changeset>
|
||||
<Changeset component="org.gcube.portal.custom-portal-handler.1-5-0"
|
||||
date="2014-04-02">
|
||||
<Change>Added getAdministratorUsername method in ScopeHelper</Change>
|
||||
</Changeset>
|
||||
</ReleaseNotes>
|
10
pom.xml
10
pom.xml
|
@ -10,7 +10,7 @@
|
|||
|
||||
<groupId>org.gcube.portal</groupId>
|
||||
<artifactId>custom-portal-handler</artifactId>
|
||||
<version>1.4.0-SNAPSHOT</version>
|
||||
<version>1.5.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>Custom Portal Handler</name>
|
||||
<description>
|
||||
|
@ -24,8 +24,8 @@
|
|||
</scm>
|
||||
<properties>
|
||||
<distroDirectory>distro</distroDirectory>
|
||||
<maven.compiler.source>1.6</maven.compiler.source>
|
||||
<maven.compiler.target>1.6</maven.compiler.target>
|
||||
<maven.compiler.source>1.7</maven.compiler.source>
|
||||
<maven.compiler.target>1.7</maven.compiler.target>
|
||||
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
|
@ -93,8 +93,8 @@
|
|||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.0</version>
|
||||
<configuration>
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
|
|
|
@ -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<User> 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue