mavenized and added isAdmin method
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/vo-management/usermanagement-core@79706 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
0753869623
commit
56524117aa
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry including="**/*.java" kind="src" output="target/classes" path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/LIFERAY_LIBS"/>
|
||||
<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"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
|
@ -0,0 +1,29 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>usermanagement-core</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.maven.ide.eclipse.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.maven.ide.eclipse.maven2Nature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -0,0 +1,7 @@
|
|||
#Sat Dec 08 16:14:14 CET 2012
|
||||
eclipse.preferences.version=1
|
||||
encoding//src/main/java=UTF-8
|
||||
encoding//src/main/resources=UTF-8
|
||||
encoding//src/test/java=UTF-8
|
||||
encoding//src/test/resources=UTF-8
|
||||
encoding/<project>=UTF-8
|
|
@ -0,0 +1,9 @@
|
|||
#Fri Jul 26 17:34:06 CEST 2013
|
||||
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.compliance=1.6
|
||||
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
|
|
@ -0,0 +1,5 @@
|
|||
#Sat Dec 08 16:14:13 CET 2012
|
||||
activeProfiles=
|
||||
eclipse.preferences.version=1
|
||||
resolveWorkspaceProjects=true
|
||||
version=1
|
|
@ -0,0 +1,9 @@
|
|||
#Wed Aug 25 12:47:12 CEST 2010
|
||||
activeProfiles=
|
||||
eclipse.preferences.version=1
|
||||
fullBuildGoals=process-test-resources
|
||||
includeModules=false
|
||||
resolveWorkspaceProjects=true
|
||||
resourceFilterGoals=process-resources resources\:testResources
|
||||
skipCompilerPlugin=true
|
||||
version=1
|
|
@ -0,0 +1 @@
|
|||
TODO
|
|
@ -0,0 +1,6 @@
|
|||
gCube System - License
|
||||
------------------------------------------------------------
|
||||
|
||||
The gCube/gCore software is licensed as Free Open Source software conveying to the EUPL (http://ec.europa.eu/idabc/eupl).
|
||||
The software and documentation is provided by its authors/distributors "as is" and no expressed or
|
||||
implied warranty is given for its use, quality or fitness for a particular case.
|
|
@ -0,0 +1,8 @@
|
|||
Kanchanna Ramasamy Balraj (Kanchanna.RamasamyBalraj@eng.it), ENG,
|
||||
Engineering Ingegneria Informatica S.p.A.
|
||||
|
||||
Giulio Galiero (Giulio.Galiero@eng.it), ENG,
|
||||
Engineering Ingegneria Informatica S.p.A.
|
||||
|
||||
Ciro Formisano (Ciro.Formisano@eng.it), ENG,
|
||||
Engineering Ingegneria Informatica S.p.A.
|
|
@ -0,0 +1,38 @@
|
|||
The gCube System
|
||||
------------------------------------------------------------
|
||||
|
||||
This work is partially funded by the European Commission in the
|
||||
context of the D4Science project (www.d4science.eu), under the 1st
|
||||
call of FP7 IST priority.
|
||||
|
||||
|
||||
Authors
|
||||
-------
|
||||
|
||||
Kanchanna Ramasamy Balraj (Kanchanna.RamasamyBalraj@eng.it), ENG,
|
||||
Engineering Ingegneria Informatica S.p.A.
|
||||
|
||||
Giulio Galiero (Giulio.Galiero@eng.it), ENG,
|
||||
Engineering Ingegneria Informatica S.p.A.
|
||||
|
||||
Ciro Formisano (Ciro.Formisano@eng.it), ENG,
|
||||
Engineering Ingegneria Informatica S.p.A.
|
||||
|
||||
|
||||
Version and Release Date
|
||||
------------------------
|
||||
|
||||
03 September 2010
|
||||
* First release
|
||||
|
||||
Licensing
|
||||
---------
|
||||
|
||||
This software is licensed under the terms you may find in the file named "LICENSE" in this directory.
|
||||
|
||||
Documentation
|
||||
-------------
|
||||
|
||||
Documentation is available on - line from the Projects Documentation wiki:
|
||||
|
||||
https://gcube.wiki.gcube-system.org/gcube/index.php/UserManagement_Core
|
|
@ -0,0 +1,18 @@
|
|||
<ReleaseNotes>
|
||||
<Changeset component="org.gcube.vo-management.usermanagement-core.1-0-0"
|
||||
date="2010-09-03">
|
||||
<Change>UserManagement lib for Liferay</Change>
|
||||
</Changeset>
|
||||
<Changeset component="org.gcube.vo-management.usermanagement-core.1-1-0"
|
||||
date="2010-10-27">
|
||||
<Change>#82: UserManagement Portlet cannot assign role Production-Support</Change>
|
||||
</Changeset>
|
||||
<Changeset component="org.gcube.vo-management.usermanagement-core.1-1-1"
|
||||
date="2010-11-09">
|
||||
<Change>#120: Failed to Assign Production-Support role</Change>
|
||||
</Changeset>
|
||||
<Changeset component="org.gcube.vo-management.usermanagement-core.1-1-2"
|
||||
date="2010-11-25">
|
||||
<Change>#120: Failed to Assign Production-Support role</Change>
|
||||
</Changeset>
|
||||
</ReleaseNotes>
|
|
@ -0,0 +1,48 @@
|
|||
<assembly
|
||||
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
|
||||
<id>servicearchive</id>
|
||||
<formats>
|
||||
<format>tar.gz</format>
|
||||
</formats>
|
||||
<baseDirectory>/</baseDirectory>
|
||||
<fileSets>
|
||||
<fileSet>
|
||||
<directory>${distroDirectory}</directory>
|
||||
<outputDirectory>/</outputDirectory>
|
||||
<useDefaultExcludes>true</useDefaultExcludes>
|
||||
<includes>
|
||||
<include>README</include>
|
||||
<include>LICENSE</include>
|
||||
<include>INSTALL</include>
|
||||
<include>MAINTAINERS</include>
|
||||
<include>changelog.xml</include>
|
||||
</includes>
|
||||
<fileMode>755</fileMode>
|
||||
<filtered>true</filtered>
|
||||
</fileSet>
|
||||
<fileSet>
|
||||
<directory>target/apidocs</directory>
|
||||
<outputDirectory>/${artifactId}/doc/api</outputDirectory>
|
||||
<useDefaultExcludes>true</useDefaultExcludes>
|
||||
<fileMode>755</fileMode>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
<files>
|
||||
<file>
|
||||
<source>${distroDirectory}/profile.xml</source>
|
||||
<outputDirectory>./</outputDirectory>
|
||||
<filtered>true</filtered>
|
||||
</file>
|
||||
<file>
|
||||
<source>target/${build.finalName}.jar</source>
|
||||
<outputDirectory>/${artifactId}</outputDirectory>
|
||||
</file>
|
||||
<file>
|
||||
<source>${distroDirectory}/svnpath.txt</source>
|
||||
<outputDirectory>/${artifactId}</outputDirectory>
|
||||
<filtered>true</filtered>
|
||||
</file>
|
||||
</files>
|
||||
</assembly>
|
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Resource xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<ID></ID>
|
||||
<Type>Library</Type>
|
||||
<Profile>
|
||||
<Description>ASL Social Library</Description>
|
||||
<Class>ApplicationSupportLayer</Class>
|
||||
<Name>${artifactId}</Name>
|
||||
<Version>1.0.0</Version>
|
||||
<Packages>
|
||||
<Software>
|
||||
<Name>${artifactId}</Name>
|
||||
<Version>${version}</Version>
|
||||
<MavenCoordinates>
|
||||
<groupId>${groupId}</groupId>
|
||||
<artifactId>${artifactId}</artifactId>
|
||||
<version>${version}</version>
|
||||
</MavenCoordinates>
|
||||
<Files>
|
||||
<File>${build.finalName}.jar</File>
|
||||
</Files>
|
||||
</Software>
|
||||
</Packages>
|
||||
</Profile>
|
||||
</Resource>
|
|
@ -0,0 +1 @@
|
|||
${scm.url}
|
|
@ -0,0 +1,158 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<artifactId>maven-parent</artifactId>
|
||||
<groupId>org.gcube.tools</groupId>
|
||||
<version>1.0.0</version>
|
||||
<relativePath />
|
||||
</parent>
|
||||
|
||||
<groupId>org.gcube.dvos</groupId>
|
||||
<artifactId>usermanagement-core</artifactId>
|
||||
<version>1.2.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>User Management API</name>
|
||||
<description>
|
||||
User Management API
|
||||
</description>
|
||||
<scm>
|
||||
<connection>scm:svn:http://svn.d4science.research-infrastructures.eu/gcube/trunk/vo-mamangement/usermanagement-core</connection>
|
||||
<developerConnection>scm:https://svn.d4science.research-infrastructures.eu/gcube/trunk/trunk/vo-mamangement/usermanagement-core</developerConnection>
|
||||
<url>http://svn.d4science.research-infrastructures.eu/gcube/trunk/vo-mamangement/usermanagement-core</url>
|
||||
</scm>
|
||||
<properties>
|
||||
<distroDirectory>distro</distroDirectory>
|
||||
<maven.compiler.source>1.6</maven.compiler.source>
|
||||
<maven.compiler.target>1.6</maven.compiler.target>
|
||||
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
</properties>
|
||||
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.gcube.core</groupId>
|
||||
<artifactId>gcf</artifactId>
|
||||
<version>[1.4.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.liferay.portal</groupId>
|
||||
<artifactId>portal-service</artifactId>
|
||||
<version>6.0.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.portlet</groupId>
|
||||
<artifactId>portlet-api</artifactId>
|
||||
<version>2.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/java</directory>
|
||||
<includes>
|
||||
<include>**/*.*</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.0</version>
|
||||
<configuration>
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>test-jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.12</version>
|
||||
<configuration>
|
||||
<skipTests>true</skipTests>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>2.5</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-profile</id>
|
||||
<phase>install</phase>
|
||||
<goals>
|
||||
<goal>copy-resources</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>target</outputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>${distroDirectory}</directory>
|
||||
<filtering>true</filtering>
|
||||
<includes>
|
||||
<include>profile.xml</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<version>2.2</version>
|
||||
<configuration>
|
||||
<descriptors>
|
||||
<descriptor>${distroDirectory}/descriptor.xml</descriptor>
|
||||
</descriptors>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>fully.qualified.MainClass</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>servicearchive</id>
|
||||
<phase>install</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
package org.gcube.vomanagement.usermanagement;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault;
|
||||
import org.gcube.vomanagement.usermanagement.exception.UserManagementNameException;
|
||||
import org.gcube.vomanagement.usermanagement.exception.UserManagementPortalException;
|
||||
import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException;
|
||||
import org.gcube.vomanagement.usermanagement.exception.UserRetrievalFault;
|
||||
import org.gcube.vomanagement.usermanagement.model.GroupModel;
|
||||
import org.gcube.vomanagement.usermanagement.model.RoleModel;
|
||||
|
||||
|
||||
/**
|
||||
* This interface defines the class that manages the groups.
|
||||
*
|
||||
* @author Giulio Galiero
|
||||
*
|
||||
*/
|
||||
public interface GroupManager {
|
||||
|
||||
//public GroupModel createGroup(String groupName, String userId) throws UserManagementException;
|
||||
|
||||
public GroupModel createRootVO(String RootVOName, String userId, String description)throws UserManagementNameException, UserManagementSystemException, UserRetrievalFault ,GroupRetrievalFault, UserManagementPortalException;
|
||||
|
||||
public GroupModel createVO(String VOName, String rootVOGroupId, String userId, String description)throws UserManagementNameException, UserManagementSystemException, UserRetrievalFault, GroupRetrievalFault, UserManagementPortalException;
|
||||
|
||||
public GroupModel createVRE(String VREName, String VOGroupId, String userId, String description)throws UserManagementNameException, UserManagementSystemException, UserRetrievalFault, GroupRetrievalFault, UserManagementPortalException;
|
||||
|
||||
public void deleteGroup(String groupId) throws UserManagementSystemException, GroupRetrievalFault;
|
||||
|
||||
public void updateGroup(GroupModel group) throws UserManagementSystemException, GroupRetrievalFault;
|
||||
|
||||
public GroupModel getGroup(String groupId) throws UserManagementSystemException, GroupRetrievalFault;
|
||||
|
||||
public GroupModel getRootVO() throws UserManagementSystemException, GroupRetrievalFault;
|
||||
|
||||
public String getRootVOName() throws UserManagementSystemException, GroupRetrievalFault;
|
||||
|
||||
public List<GroupModel> listGroups() throws UserManagementSystemException;
|
||||
|
||||
public List<GroupModel> listGroupsByUser(String userId) throws UserManagementSystemException;
|
||||
|
||||
public List<GroupModel> listPendingGroupsByUser(String userId) throws UserManagementSystemException;
|
||||
|
||||
public List<GroupModel> listSubGroupsByGroup(String groupId) throws UserManagementSystemException, GroupRetrievalFault;
|
||||
|
||||
public HashMap<String, List<RoleModel>> listGroupsAndRolesByUser(String userId) throws UserManagementSystemException;
|
||||
|
||||
public void assignSubGrouptoParentGroup(String subGroupId, String parentGroupId) throws UserManagementSystemException, GroupRetrievalFault;
|
||||
|
||||
public void dismissSubGroupFromParentGroup(String subGroupId, String parentGroupId) throws UserManagementSystemException, GroupRetrievalFault;
|
||||
|
||||
public String getGroupId(String groupName) throws UserManagementSystemException, GroupRetrievalFault;
|
||||
|
||||
public long getGroupParentId(String groupId) throws UserManagementSystemException, GroupRetrievalFault;
|
||||
|
||||
public String getScope(String groupId) throws UserManagementSystemException, GroupRetrievalFault;
|
||||
|
||||
public Boolean isRootVO(String groupId) throws UserManagementSystemException, GroupRetrievalFault;
|
||||
|
||||
public Boolean isVO(String groupId) throws UserManagementSystemException, GroupRetrievalFault;
|
||||
|
||||
public Boolean isVRE(String groupId) throws UserManagementSystemException, GroupRetrievalFault;
|
||||
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
package org.gcube.vomanagement.usermanagement;
|
||||
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault;
|
||||
import org.gcube.vomanagement.usermanagement.exception.RoleRetrievalFault;
|
||||
import org.gcube.vomanagement.usermanagement.exception.UserManagementFileNotFoundException;
|
||||
import org.gcube.vomanagement.usermanagement.exception.UserManagementIOException;
|
||||
import org.gcube.vomanagement.usermanagement.exception.UserManagementPortalException;
|
||||
import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException;
|
||||
import org.gcube.vomanagement.usermanagement.exception.UserRetrievalFault;
|
||||
import org.gcube.vomanagement.usermanagement.model.RoleModel;
|
||||
|
||||
/**
|
||||
* This interface defines the manager class that manages the roles.
|
||||
*
|
||||
* @author Giulio Galiero
|
||||
*
|
||||
*/
|
||||
public interface RoleManager {
|
||||
|
||||
boolean isAdmin(String userId);
|
||||
|
||||
public void assignRoleToUser(String groupId, String roleId, String userId) throws UserManagementSystemException, UserRetrievalFault, GroupRetrievalFault,RoleRetrievalFault;
|
||||
|
||||
public void createRole(String groupName) throws UserManagementSystemException, GroupRetrievalFault, RoleRetrievalFault, UserManagementPortalException, UserManagementFileNotFoundException, UserManagementIOException;
|
||||
|
||||
public boolean createRole(String roleName,String roleDescription, String groupName) throws UserManagementSystemException, RoleRetrievalFault, GroupRetrievalFault, UserManagementPortalException;
|
||||
|
||||
public void deleteRole(String roleName, String groupName) throws UserManagementSystemException, RoleRetrievalFault ;
|
||||
|
||||
public void dismissRoleFromUser(String groupId, String roleId, String userId)throws UserManagementSystemException, UserRetrievalFault, GroupRetrievalFault,RoleRetrievalFault;
|
||||
|
||||
public RoleModel getRole(String roleId) throws UserManagementSystemException, RoleRetrievalFault;
|
||||
|
||||
public String getRoleId(String roleName, String groupName) throws UserManagementSystemException;
|
||||
|
||||
public HashMap<String, String> listAllowedRoles(String groupName) throws UserManagementSystemException, GroupRetrievalFault, UserManagementFileNotFoundException, UserManagementIOException;
|
||||
|
||||
@Deprecated
|
||||
public List<String> listRoles() throws UserManagementSystemException;
|
||||
|
||||
public List<RoleModel> listAllRoles() throws UserManagementSystemException;
|
||||
|
||||
public List<RoleModel> listRolesByGroup(String groupId) throws UserManagementSystemException, GroupRetrievalFault, UserManagementFileNotFoundException, UserManagementIOException;
|
||||
|
||||
public List<RoleModel> listRolesByUser(String userId) throws UserManagementSystemException;
|
||||
|
||||
public List<RoleModel> listRolesByUserAndGroup(String groupId, String userId) throws UserManagementSystemException, GroupRetrievalFault,UserRetrievalFault ;
|
||||
|
||||
public void updateRole(String initialRoleName, String newRoleName, String roleDescription, String groupName) throws UserManagementSystemException, RoleRetrievalFault, NumberFormatException, UserManagementFileNotFoundException, UserManagementIOException, GroupRetrievalFault,UserManagementPortalException;
|
||||
|
||||
public void updatePredefinedRoles(HashMap<String,String> rolesMap, String groupType) throws UserManagementIOException, UserManagementFileNotFoundException ;
|
||||
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
package org.gcube.vomanagement.usermanagement;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault;
|
||||
import org.gcube.vomanagement.usermanagement.exception.RoleRetrievalFault;
|
||||
import org.gcube.vomanagement.usermanagement.exception.UserManagementPortalException;
|
||||
import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException;
|
||||
import org.gcube.vomanagement.usermanagement.exception.UserRetrievalFault;
|
||||
import org.gcube.vomanagement.usermanagement.model.GroupModel;
|
||||
import org.gcube.vomanagement.usermanagement.model.RoleModel;
|
||||
import org.gcube.vomanagement.usermanagement.model.UserModel;
|
||||
|
||||
|
||||
/**
|
||||
* This interface defines the class that manages the users.
|
||||
*
|
||||
* @author Giulio Galiero
|
||||
*
|
||||
*/
|
||||
public interface UserManager {
|
||||
|
||||
public void createUser(UserModel usermodel) throws UserManagementSystemException, UserRetrievalFault;
|
||||
|
||||
public void deleteUser(String userId) throws UserManagementSystemException, UserRetrievalFault;
|
||||
|
||||
public void updateUser(UserModel user) throws UserRetrievalFault, UserManagementSystemException, UserManagementPortalException;
|
||||
|
||||
public UserModel getUser(String userId) throws UserManagementSystemException, UserRetrievalFault ;
|
||||
|
||||
public List<UserModel> listUsers() throws UserManagementSystemException, UserRetrievalFault;
|
||||
|
||||
public List<UserModel> listUsersByGroup(String groupId) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault;
|
||||
|
||||
public List<UserModel> listPendingUsersByGroup(String groupId) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault;
|
||||
|
||||
public String getMembershipRequestComment(String userId, String groupId) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault;
|
||||
|
||||
public HashMap<UserModel, List<RoleModel>> listUsersAndRolesByGroup(String groupId) throws GroupRetrievalFault, UserManagementSystemException, UserRetrievalFault ;
|
||||
|
||||
public HashMap<UserModel, List<GroupModel>> listUsersAndGroupsByRole(String roleId) throws UserManagementSystemException, RoleRetrievalFault, UserRetrievalFault ;
|
||||
|
||||
public List<UserModel> listUsersByGroupAndRole(String groupId, String roleId) throws UserManagementSystemException, RoleRetrievalFault, GroupRetrievalFault, UserRetrievalFault;
|
||||
|
||||
public void assignUserToGroup(String groupId, String userId) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault, UserManagementPortalException;
|
||||
|
||||
public void dismissUserFromGroup(String groupId, String userId) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault;
|
||||
|
||||
public void requestMembership(String userId, String groupId, String comment) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault;
|
||||
|
||||
public List<UserModel> listUnregisteredUsersByGroup(String groupId) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault;
|
||||
|
||||
public String getUserId(String screenName) throws UserManagementSystemException;
|
||||
|
||||
public List<UserModel> getMembershipRequests(String groupId) throws UserManagementSystemException,GroupRetrievalFault, UserRetrievalFault;
|
||||
|
||||
public UserModel getUserByScreenName(String screenName) throws UserManagementSystemException, UserRetrievalFault, UserManagementPortalException;
|
||||
|
||||
public HashMap<String, String> getUserCustomAttributes(String userId) throws UserManagementSystemException, UserRetrievalFault;
|
||||
|
||||
public void setUserCustomAttributes(String userId, HashMap<String,String> hMap) throws UserManagementSystemException, UserRetrievalFault, UserManagementPortalException;
|
||||
|
||||
public String getUserCustomAttributeByName(String userId, String attrName)throws UserManagementSystemException, UserRetrievalFault;
|
||||
|
||||
public void setUserCustomAttributeByName(String userId, String attrName, String attrValue) throws UserManagementSystemException, UserRetrievalFault, UserManagementPortalException;
|
||||
|
||||
public void denyMembershipRequest(String userId,String groupId)throws UserManagementSystemException, GroupRetrievalFault, UserManagementPortalException;
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package org.gcube.vomanagement.usermanagement.exception;
|
||||
|
||||
import com.liferay.portal.kernel.exception.PortalException;
|
||||
|
||||
|
||||
|
||||
public class GroupRetrievalFault extends Exception{
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -5809619725100397844L;
|
||||
|
||||
public GroupRetrievalFault(String errorMsg, String orgId ){
|
||||
System.out.println(errorMsg + orgId);
|
||||
}
|
||||
|
||||
public GroupRetrievalFault(String errorMsg, PortalException e){
|
||||
System.out.println(errorMsg);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
public GroupRetrievalFault(String errorMsg, String orgId , PortalException e){
|
||||
System.out.println(errorMsg + orgId);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package org.gcube.vomanagement.usermanagement.exception;
|
||||
|
||||
import com.liferay.portal.kernel.exception.PortalException;
|
||||
|
||||
|
||||
|
||||
public class RoleRetrievalFault extends Exception{
|
||||
|
||||
|
||||
private static final long serialVersionUID = 2824756378739545315L;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public RoleRetrievalFault(String errorMsg, String roleId){
|
||||
System.out.println(errorMsg + roleId);
|
||||
}
|
||||
|
||||
public RoleRetrievalFault(String errorMsg, PortalException e){
|
||||
System.out.println(errorMsg);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
public RoleRetrievalFault(String errorMsg, String roleId , PortalException e){
|
||||
System.out.println(errorMsg + roleId);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package org.gcube.vomanagement.usermanagement.exception;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
|
||||
|
||||
public class UserManagementFileNotFoundException extends Exception{
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 3573055203913190069L;
|
||||
|
||||
public UserManagementFileNotFoundException(String errorMsg, FileNotFoundException e){
|
||||
System.out.println(errorMsg);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package org.gcube.vomanagement.usermanagement.exception;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
public class UserManagementIOException extends Exception{
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -7351699091691019047L;
|
||||
|
||||
public UserManagementIOException(String errorMsg, IOException e){
|
||||
System.out.println(errorMsg);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package org.gcube.vomanagement.usermanagement.exception;
|
||||
|
||||
public class UserManagementNameException extends Exception{
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 9127162401036769140L;
|
||||
|
||||
public UserManagementNameException(String e){
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package org.gcube.vomanagement.usermanagement.exception;
|
||||
|
||||
import com.liferay.portal.kernel.exception.PortalException;
|
||||
|
||||
|
||||
|
||||
|
||||
public class UserManagementPortalException extends Exception{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -4958787007913556095L;
|
||||
|
||||
|
||||
public UserManagementPortalException(String errorMsg, PortalException e){
|
||||
System.out.println(errorMsg);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
public UserManagementPortalException(String errorMsg, String orgId , PortalException e){
|
||||
System.out.println(errorMsg + orgId);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package org.gcube.vomanagement.usermanagement.exception;
|
||||
|
||||
import com.liferay.portal.kernel.exception.SystemException;
|
||||
|
||||
|
||||
public class UserManagementSystemException extends Exception{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 7775831372490099004L;
|
||||
|
||||
|
||||
public UserManagementSystemException(String errorMsg, SystemException e){
|
||||
System.out.println(errorMsg);
|
||||
e.printStackTrace();
|
||||
}
|
||||
public UserManagementSystemException(String errorMsg,String orgId, Exception e){
|
||||
System.out.println(errorMsg + orgId);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package org.gcube.vomanagement.usermanagement.exception;
|
||||
|
||||
import com.liferay.portal.kernel.exception.PortalException;
|
||||
|
||||
|
||||
|
||||
public class UserRetrievalFault extends Exception{
|
||||
|
||||
private static final long serialVersionUID = 4384964298359631619L;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
public UserRetrievalFault(String errorMsg, PortalException e){
|
||||
System.out.println(errorMsg);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
public UserRetrievalFault(String errorMsg, String userId , PortalException e){
|
||||
System.out.println(errorMsg + userId);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,509 @@
|
|||
package org.gcube.vomanagement.usermanagement.impl.liferay;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.gcube.vomanagement.usermanagement.GroupManager;
|
||||
import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault;
|
||||
import org.gcube.vomanagement.usermanagement.exception.UserManagementNameException;
|
||||
import org.gcube.vomanagement.usermanagement.exception.UserManagementPortalException;
|
||||
import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException;
|
||||
import org.gcube.vomanagement.usermanagement.model.GroupModel;
|
||||
import org.gcube.vomanagement.usermanagement.model.RoleModel;
|
||||
|
||||
|
||||
|
||||
import com.liferay.portal.kernel.exception.PortalException;
|
||||
import com.liferay.portal.kernel.exception.SystemException;
|
||||
import com.liferay.portal.kernel.util.GetterUtil;
|
||||
import com.liferay.portal.kernel.util.PropsUtil;
|
||||
import com.liferay.portal.model.Company;
|
||||
import com.liferay.portal.model.MembershipRequest;
|
||||
import com.liferay.portal.model.Organization;
|
||||
import com.liferay.portal.model.Role;
|
||||
|
||||
import com.liferay.portal.service.CompanyLocalServiceUtil;
|
||||
import com.liferay.portal.service.MembershipRequestLocalServiceUtil;
|
||||
import com.liferay.portal.service.OrganizationLocalServiceUtil;
|
||||
import com.liferay.portal.service.RoleLocalServiceUtil;
|
||||
import com.liferay.portal.service.ServiceContext;
|
||||
|
||||
|
||||
/**
|
||||
* Liferay plugin for the GroupManager interface, this implementation interacts with Liferay through a LocalService.
|
||||
*
|
||||
* @author Giulio Galiero
|
||||
*
|
||||
*/
|
||||
public class LiferayGroupManager implements GroupManager {
|
||||
|
||||
private static final String DEFAULT_COMPANY_WEB_ID = "liferay.com";
|
||||
private final String REG_EX_MATCH = "^[A-Za-z0-9]+([-\\.\\_\\-ε]([A-Za-z0-9]+))*";
|
||||
|
||||
private long getLongId(String groupId) throws NumberFormatException{
|
||||
|
||||
long groupIdL = Long.parseLong(groupId);
|
||||
return groupIdL;
|
||||
}
|
||||
/**
|
||||
* return the companyId
|
||||
* @param webId .
|
||||
* @return the company bean
|
||||
* @throws PortalException .
|
||||
* @throws SystemException .
|
||||
*/
|
||||
public static Company getCompany() throws PortalException, SystemException {
|
||||
return CompanyLocalServiceUtil.getCompanyByWebId(getDefaultCompanyWebId());
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @return the default company web-id (e.g. iMarine.eu)
|
||||
*/
|
||||
public static String getDefaultCompanyWebId() {
|
||||
String defaultWebId = "";
|
||||
try {
|
||||
defaultWebId = GetterUtil.getString(PropsUtil.get("company.default.web.id"));
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
System.out.println("Cound not find property company.default.web.id in portal.ext file returning default web id: " + DEFAULT_COMPANY_WEB_ID);
|
||||
return DEFAULT_COMPANY_WEB_ID;
|
||||
}
|
||||
return defaultWebId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected long getCompanyId() throws UserManagementSystemException, UserManagementPortalException{
|
||||
Company company = null;
|
||||
try {
|
||||
company = getCompany();
|
||||
} catch (PortalException e) {
|
||||
throw new UserManagementPortalException("Error retrieving companyId ", e);
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error retrieving companyId ", e);
|
||||
}
|
||||
return company.getCompanyId();
|
||||
}
|
||||
|
||||
/* public GroupModel.GROUP_TYPE getGroupType(GroupModel gm){
|
||||
if(gm.getGroupName().startsWith("VO")){
|
||||
return GroupModel.GROUP_TYPE.VO;
|
||||
}else if(gm.getGroupName().contains("ROOT_VO")){
|
||||
return GroupModel.GROUP_TYPE.ROOT_VO;
|
||||
}else if(gm.getGroupName().contains("VRE")){
|
||||
return GroupModel.GROUP_TYPE.ROOT_VO;
|
||||
}
|
||||
return GroupModel.GROUP_TYPE.VO;
|
||||
}*/
|
||||
|
||||
public String getScope(String groupId) throws UserManagementSystemException, GroupRetrievalFault{
|
||||
StringBuilder scope = new StringBuilder("/");
|
||||
Organization org;
|
||||
|
||||
try{
|
||||
long groupIdL = this.getLongId(groupId);
|
||||
org = OrganizationLocalServiceUtil.getOrganization(groupIdL);
|
||||
}catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error retrieving scope for group ", groupId , e);
|
||||
} catch (PortalException e) {
|
||||
throw new GroupRetrievalFault("No group exists with group name ",groupId, e);
|
||||
}
|
||||
if (isRootVO(groupId))
|
||||
scope.append(org.getName());
|
||||
else if (isVO(groupId)){
|
||||
long rootVOId = getGroupParentId(groupId);
|
||||
Organization rootVO = null;
|
||||
try {
|
||||
rootVO = OrganizationLocalServiceUtil.getOrganization(rootVOId);
|
||||
} catch (PortalException e) {
|
||||
throw new GroupRetrievalFault("No group exists with group name ",String.valueOf(rootVOId), e);
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error retrieving scope for group ", groupId , e);
|
||||
}
|
||||
scope.append(rootVO.getName()).append("/").append(org.getName());
|
||||
}
|
||||
else if (isVRE(groupId)){
|
||||
long voId = getGroupParentId(groupId);
|
||||
Organization vo = null;
|
||||
try {
|
||||
vo = OrganizationLocalServiceUtil.getOrganization(voId);
|
||||
} catch (PortalException e) {
|
||||
throw new GroupRetrievalFault("No group exists with group name ",String.valueOf(voId), e);
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error retrieving scope for group ", groupId , e);
|
||||
}
|
||||
long rootVOId = getGroupParentId(String.valueOf(voId));
|
||||
Organization rootVO = null;
|
||||
try {
|
||||
rootVO = OrganizationLocalServiceUtil.getOrganization(rootVOId);
|
||||
} catch (PortalException e) {
|
||||
throw new GroupRetrievalFault("No group exists with group name ",String.valueOf(rootVOId), e);
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error retrieving scope for group ", groupId , e);
|
||||
}
|
||||
scope.append(rootVO.getName()).append("/").append(vo.getName()).append("/").append(org.getName());
|
||||
}
|
||||
|
||||
return scope.toString();
|
||||
|
||||
}
|
||||
|
||||
public Boolean isRootVO(String groupId) throws UserManagementSystemException, GroupRetrievalFault{
|
||||
if(this.getLongId(groupId)!=0){
|
||||
if (getGroupParentId(groupId) == 0)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public Boolean isVO(String groupId) throws UserManagementSystemException, GroupRetrievalFault{
|
||||
if(this.getLongId(groupId)!=0){
|
||||
long parentId = getGroupParentId(groupId);
|
||||
if (isRootVO(String.valueOf(parentId)))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public Boolean isVRE(String groupId) throws UserManagementSystemException, GroupRetrievalFault{
|
||||
long parentId = getGroupParentId(groupId);
|
||||
if (isVO(String.valueOf(parentId)))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
Already available in UserManager as listUsersByGroup!
|
||||
|
||||
public List<UserModel> getGroupUsers(long groupId){
|
||||
List<User> orgUsers = null;
|
||||
try {
|
||||
orgUsers = UserLocalServiceUtil.getOrganizationUsers(groupId);
|
||||
} catch (SystemException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
List<UserModel> userModels = new ArrayList<UserModel>();
|
||||
for(User user : orgUsers){
|
||||
UserModel um = new UserModel(user.getFirstName(),user.getLastName(),user.getFullName(),user.getEmailAddress(),user.getScreenName());
|
||||
userModels.add(um);
|
||||
}
|
||||
return userModels;
|
||||
}
|
||||
*/
|
||||
|
||||
public String getGroupId(String groupName) throws UserManagementSystemException, GroupRetrievalFault{
|
||||
List<Organization> organizations = null;
|
||||
long orgId = 0;
|
||||
try {
|
||||
organizations = OrganizationLocalServiceUtil.getOrganizations(0, OrganizationLocalServiceUtil.getOrganizationsCount());
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error retrieving Id for group ", groupName , e);
|
||||
}
|
||||
for(Organization organization: organizations){
|
||||
if(organization.getName().equalsIgnoreCase(groupName)){
|
||||
orgId = organization.getOrganizationId();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(orgId == 0){
|
||||
throw new GroupRetrievalFault("No group exists with group name ",groupName);
|
||||
}
|
||||
return String.valueOf(orgId);
|
||||
}
|
||||
|
||||
public GroupModel getGroup(String groupId) throws UserManagementSystemException, GroupRetrievalFault{
|
||||
Organization group = null;
|
||||
GroupModel gm = null;
|
||||
try {
|
||||
group = OrganizationLocalServiceUtil.getOrganization(this.getLongId(groupId));
|
||||
if(group!=null){
|
||||
gm = new GroupModel(String.valueOf(group.getOrganizationId()),String.valueOf(group.getParentOrganizationId()),group.getName(),group.getComments(),group.getLogoId());
|
||||
}else{
|
||||
// throw new UserManagementException("No Group Found with Id " + groupId);
|
||||
}
|
||||
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error retrieving group ", groupId , e);
|
||||
} catch (PortalException e) {
|
||||
throw new GroupRetrievalFault("No group exists with group name ",groupId, e);
|
||||
}
|
||||
return gm;
|
||||
}
|
||||
|
||||
public List<GroupModel> listGroups() throws UserManagementSystemException {
|
||||
List<Organization> groups = null;
|
||||
List<GroupModel> orgModels = new ArrayList<GroupModel>();
|
||||
try {
|
||||
groups = OrganizationLocalServiceUtil.getOrganizations(0, OrganizationLocalServiceUtil.getOrganizationsCount());
|
||||
if(groups!=null){
|
||||
for(Organization group:groups){
|
||||
GroupModel gm = new GroupModel(String.valueOf(group.getOrganizationId()),String.valueOf(group.getParentOrganizationId()),group.getName(),group.getComments(),group.getLogoId());
|
||||
orgModels.add(gm);
|
||||
}
|
||||
}else{
|
||||
// throw new UserManagementException("No Groups found ");
|
||||
}
|
||||
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error retrieving list of groups ", e);
|
||||
}
|
||||
return orgModels;
|
||||
}
|
||||
|
||||
public HashMap<String, List<RoleModel>> listGroupsAndRolesByUser(String userId) throws UserManagementSystemException {
|
||||
long userIdn = Long.parseLong(userId);
|
||||
HashMap<String, List<RoleModel>> hMap = new HashMap<String, List<RoleModel>>();
|
||||
List<Organization> groups = null;
|
||||
List<Role> roles = null;
|
||||
String roleName;
|
||||
String completeRoleName;
|
||||
LiferayRoleManager roleMan = new LiferayRoleManager();
|
||||
try {
|
||||
groups = OrganizationLocalServiceUtil.getUserOrganizations(userIdn);
|
||||
roles = RoleLocalServiceUtil.getUserRoles(userIdn);
|
||||
} catch (Exception e) {
|
||||
throw new UserManagementSystemException("Error listing groups and roles of user ", userId , e);
|
||||
}
|
||||
Iterator<Organization> groupIter = groups.iterator();
|
||||
while(groupIter.hasNext()){
|
||||
Organization group = (Organization)groupIter.next();
|
||||
List<RoleModel> userGroupRoles = new ArrayList<RoleModel>();
|
||||
for(Role role : roles){
|
||||
if(role.getName().contains(group.getName())){
|
||||
completeRoleName = role.getName();
|
||||
roleName = roleMan.getRoleName(completeRoleName);
|
||||
RoleModel rm = new RoleModel(roleName,String.valueOf(role.getRoleId()),role.getDescription());
|
||||
rm.setCompleteName(completeRoleName);
|
||||
userGroupRoles.add(rm);
|
||||
}
|
||||
}
|
||||
hMap.put(group.getName(), userGroupRoles);
|
||||
}
|
||||
return hMap;
|
||||
}
|
||||
|
||||
public List<GroupModel> listGroupsByUser(String userId) throws UserManagementSystemException {
|
||||
List<Organization> groups = null;
|
||||
List<GroupModel> orgModels = new ArrayList<GroupModel>();
|
||||
try {
|
||||
groups = OrganizationLocalServiceUtil.getUserOrganizations(getLongId(userId));
|
||||
for(Organization group:groups){
|
||||
GroupModel gm = new GroupModel(String.valueOf(group.getOrganizationId()),String.valueOf(group.getParentOrganizationId()),group.getName(),group.getComments(),group.getLogoId());
|
||||
orgModels.add(gm);
|
||||
}
|
||||
}catch (Exception e) {
|
||||
throw new UserManagementSystemException("Error retrieving groups of user ", userId , e);
|
||||
}
|
||||
return orgModels;
|
||||
}
|
||||
|
||||
public List<GroupModel> listSubGroupsByGroup(String groupIdn) throws UserManagementSystemException, GroupRetrievalFault{
|
||||
long groupId = getLongId(groupIdn);
|
||||
List<Organization> org = new ArrayList<Organization>();
|
||||
List<Organization> subOrgs = null;
|
||||
List<GroupModel> subOrgModels = new ArrayList<GroupModel>();
|
||||
try {
|
||||
org.add(OrganizationLocalServiceUtil.getOrganization(groupId));
|
||||
subOrgs = OrganizationLocalServiceUtil.getSuborganizations(org);
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error retrieving sub groups of group ", groupIdn , e);
|
||||
} catch (PortalException e) {
|
||||
throw new GroupRetrievalFault("No group exists with group name ",groupIdn, e);
|
||||
}
|
||||
|
||||
if(subOrgs!=null){
|
||||
for(Organization suborg : subOrgs){
|
||||
GroupModel gm = new GroupModel(String.valueOf(suborg.getOrganizationId()),String.valueOf(suborg.getParentOrganizationId()),suborg.getName(),suborg.getComments(),suborg.getLogoId());
|
||||
subOrgModels.add(gm);
|
||||
}
|
||||
}else{
|
||||
// throw new UserManagementException("No SubGroups present for the group " + groupIdn);
|
||||
}
|
||||
|
||||
return subOrgModels;
|
||||
}
|
||||
|
||||
public void assignSubGrouptoParentGroup(String subGroupId,
|
||||
String parentGroupId) throws UserManagementSystemException, GroupRetrievalFault{
|
||||
Organization subOrg = null;
|
||||
try {
|
||||
subOrg = OrganizationLocalServiceUtil.getOrganization(this.getLongId(subGroupId));
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error assigning subGroup to Parent group ", e);
|
||||
} catch (PortalException e) {
|
||||
throw new GroupRetrievalFault("No group exists with group Id ", subGroupId, e);
|
||||
}
|
||||
subOrg.setParentOrganizationId(this.getLongId(parentGroupId));
|
||||
this.updateOrganization(subOrg);
|
||||
|
||||
}
|
||||
|
||||
private GroupModel createGroup(String groupName, String parentGroupId , String userId, String description) throws UserManagementNameException, UserManagementSystemException, GroupRetrievalFault, UserManagementPortalException{
|
||||
/*Status Id is hard coded - ATTENTION*/
|
||||
ServiceContext serviceContext = new ServiceContext();
|
||||
Organization org = null;
|
||||
GroupModel gm = null;
|
||||
// Check for character, -, _, . which are valid characters for a group Name - requirement by Massi
|
||||
Pattern p = Pattern.compile(REG_EX_MATCH);
|
||||
Matcher m = p.matcher(groupName);
|
||||
if(m.matches()){
|
||||
try {
|
||||
org = OrganizationLocalServiceUtil.addOrganization(getLongId(userId), this.getLongId(parentGroupId), groupName, "regular-organization", true, 0L, 0L, 12017, description, serviceContext);
|
||||
org.setCompanyId(getCompanyId());
|
||||
gm = new GroupModel(String.valueOf(org.getOrganizationId()),String.valueOf(org.getParentOrganizationId()),org.getName(),org.getComments(),org.getLogoId());
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error creating group ", groupName , e);
|
||||
} catch (PortalException e) {
|
||||
throw new GroupRetrievalFault("Check the groupName and the parent groupId ", groupName, e);
|
||||
}
|
||||
}else{
|
||||
throw new UserManagementNameException("Not a valid group Name. The valid characters are only A-Z a-z - _ .");
|
||||
}
|
||||
return gm;
|
||||
}
|
||||
|
||||
public void deleteGroup(String groupName) throws UserManagementSystemException, GroupRetrievalFault{
|
||||
long organizationId = this.getLongId(groupName);
|
||||
Organization organization;
|
||||
try {
|
||||
organization = OrganizationLocalServiceUtil.getOrganization(organizationId);
|
||||
OrganizationLocalServiceUtil.deleteOrganization(organization);
|
||||
}catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error deleting group ", groupName , e);
|
||||
} catch (PortalException e) {
|
||||
throw new GroupRetrievalFault("No group exists with group name ",groupName, e);
|
||||
}
|
||||
|
||||
List<Role> roles;
|
||||
try {
|
||||
roles = RoleLocalServiceUtil.getRoles(0, RoleLocalServiceUtil.getRolesCount());
|
||||
for(Role role:roles){
|
||||
if(role.getName().contains(groupName)){
|
||||
RoleLocalServiceUtil.deleteRole(role);
|
||||
}
|
||||
}
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error deleting group ", groupName , e);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void dismissSubGroupFromParentGroup(String subGroupId,
|
||||
String parentGroupId) throws UserManagementSystemException, GroupRetrievalFault{
|
||||
long subOrgId = this.getLongId(subGroupId);
|
||||
Organization org = null;
|
||||
try {
|
||||
org = OrganizationLocalServiceUtil.getOrganization(subOrgId);
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error dismissing subGroup from Parent Group ", e);
|
||||
} catch (PortalException e) {
|
||||
throw new GroupRetrievalFault("No group exists with group Id ",subGroupId, e);
|
||||
}
|
||||
org.setParentOrganizationId(0);
|
||||
this.updateOrganization(org);
|
||||
}
|
||||
|
||||
public GroupModel createRootVO(String rootVOName, String userId, String description) throws UserManagementNameException, UserManagementSystemException, GroupRetrievalFault, UserManagementPortalException {
|
||||
return createGroup(rootVOName,"0",userId, description);
|
||||
}
|
||||
|
||||
public GroupModel createVO(String VOName, String rootVOGroupId , String userId, String description) throws UserManagementNameException, UserManagementSystemException, UserManagementPortalException, GroupRetrievalFault {
|
||||
return createGroup(VOName,rootVOGroupId,userId,description);
|
||||
}
|
||||
|
||||
public GroupModel createVRE(String VREName, String VOGroupId, String userId, String description) throws UserManagementNameException, UserManagementSystemException, GroupRetrievalFault, UserManagementPortalException {
|
||||
return createGroup(VREName,VOGroupId,userId,description);
|
||||
}
|
||||
|
||||
public GroupModel getRootVO() throws UserManagementSystemException, GroupRetrievalFault {
|
||||
|
||||
List<Organization> orgs = null;
|
||||
GroupModel gm = null;
|
||||
try {
|
||||
orgs = OrganizationLocalServiceUtil.getOrganizations(0, OrganizationLocalServiceUtil.getOrganizationsCount());
|
||||
} catch (SystemException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
for(Organization org : orgs){
|
||||
if(this.isRootVO(String.valueOf(org.getOrganizationId()))){
|
||||
gm = new GroupModel(String.valueOf(org.getOrganizationId()),String.valueOf(org.getParentOrganizationId()),org.getName(),org.getComments(),org.getLogoId());
|
||||
break;
|
||||
}
|
||||
}
|
||||
return gm;
|
||||
}
|
||||
|
||||
public String getRootVOName() throws UserManagementSystemException, GroupRetrievalFault {
|
||||
GroupModel gm = getRootVO();
|
||||
return gm.getGroupName();
|
||||
|
||||
}
|
||||
|
||||
public List<GroupModel> listPendingGroupsByUser(String userId) throws UserManagementSystemException {
|
||||
List<MembershipRequest> memberRequests = null;
|
||||
List<GroupModel> groupModels = new ArrayList<GroupModel>();
|
||||
long userIdL = this.getLongId(userId);
|
||||
try {
|
||||
memberRequests = MembershipRequestLocalServiceUtil.getMembershipRequests(0, MembershipRequestLocalServiceUtil.getMembershipRequestsCount());
|
||||
for(MembershipRequest memberRequest: memberRequests){
|
||||
if(memberRequest.getUserId() == userIdL){
|
||||
long groupId = memberRequest.getGroupId();
|
||||
List<Organization> orgs = OrganizationLocalServiceUtil.getOrganizations(0, OrganizationLocalServiceUtil.getOrganizationsCount());
|
||||
for(Organization org : orgs){
|
||||
if(org.getGroup().getGroupId()==groupId){
|
||||
GroupModel gm = new GroupModel(String.valueOf(org.getOrganizationId()),String.valueOf(org.getParentOrganizationId()),org.getName(),org.getComments(),org.getLogoId());
|
||||
groupModels.add(gm);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error retrieving pending groups for user ", userId , e);
|
||||
}
|
||||
return groupModels;
|
||||
}
|
||||
|
||||
public void updateGroup(GroupModel group) throws UserManagementSystemException, GroupRetrievalFault{
|
||||
Organization org = null;
|
||||
try {
|
||||
org = OrganizationLocalServiceUtil.getOrganization(Long.parseLong(group.getGroupId()));
|
||||
}catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error updating group ", group.getGroupName() , e);
|
||||
} catch (PortalException e) {
|
||||
throw new GroupRetrievalFault("No group exists with groupId ",group.getGroupId(), e);
|
||||
}
|
||||
this.updateOrganization(org);
|
||||
}
|
||||
|
||||
private void updateOrganization(Organization org) throws UserManagementSystemException{
|
||||
try {
|
||||
OrganizationLocalServiceUtil.updateOrganization(org);
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error updating group " , e);
|
||||
}
|
||||
}
|
||||
|
||||
public long getGroupParentId(String groupId) throws UserManagementSystemException, GroupRetrievalFault{
|
||||
long groupIdL = this.getLongId(groupId);
|
||||
Organization org = null;
|
||||
long parentOrgId = 0;
|
||||
try {
|
||||
org = OrganizationLocalServiceUtil.getOrganization(groupIdL);
|
||||
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error retrieving parent Group Id for group ", groupId , e);
|
||||
} catch (PortalException e) {
|
||||
throw new GroupRetrievalFault("No group exists with groupId ",groupId, e);
|
||||
}
|
||||
parentOrgId = org.getParentOrganizationId();
|
||||
return parentOrgId;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,788 @@
|
|||
package org.gcube.vomanagement.usermanagement.impl.liferay;
|
||||
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
import org.gcube.vomanagement.usermanagement.GroupManager;
|
||||
import org.gcube.vomanagement.usermanagement.RoleManager;
|
||||
import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault;
|
||||
import org.gcube.vomanagement.usermanagement.exception.RoleRetrievalFault;
|
||||
import org.gcube.vomanagement.usermanagement.exception.UserManagementFileNotFoundException;
|
||||
import org.gcube.vomanagement.usermanagement.exception.UserManagementIOException;
|
||||
import org.gcube.vomanagement.usermanagement.exception.UserManagementPortalException;
|
||||
import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException;
|
||||
import org.gcube.vomanagement.usermanagement.exception.UserRetrievalFault;
|
||||
import org.gcube.vomanagement.usermanagement.model.GroupModel;
|
||||
import org.gcube.vomanagement.usermanagement.model.RoleModel;
|
||||
|
||||
import com.liferay.portal.kernel.exception.PortalException;
|
||||
import com.liferay.portal.kernel.exception.SystemException;
|
||||
import com.liferay.portal.model.Organization;
|
||||
import com.liferay.portal.model.Role;
|
||||
import com.liferay.portal.model.UserModel;
|
||||
import com.liferay.portal.service.OrganizationLocalServiceUtil;
|
||||
import com.liferay.portal.service.RoleLocalServiceUtil;
|
||||
import com.liferay.portal.service.UserLocalServiceUtil;
|
||||
|
||||
|
||||
/**
|
||||
* Liferay plugin for the RoleManager interface, this implementation interacts with Liferay through a LocalService.
|
||||
*
|
||||
* @author Giulio Galiero
|
||||
*
|
||||
*/
|
||||
public class LiferayRoleManager implements RoleManager {
|
||||
|
||||
private static final String ADMIN_ROLE = "Administrator";
|
||||
protected static final String PRODUCTION_SUPPORT = "Production-Support";
|
||||
public static final String VRE = "vre";
|
||||
public static final String VO = "vo";
|
||||
public static final String ROOT_VO = "root-vo";
|
||||
|
||||
/**
|
||||
* @return true if the user is a portal administrator, false otherwise
|
||||
*/
|
||||
public boolean isAdmin(String userId) {
|
||||
LiferayGroupManager gm = new LiferayGroupManager();
|
||||
try {
|
||||
com.liferay.portal.model.User currUser = UserLocalServiceUtil.getUserByScreenName(gm.getCompanyId(), userId);
|
||||
for (Role role : currUser.getRoles())
|
||||
if (role.getName().compareTo(ADMIN_ROLE) == 0 )
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
long convertType(String stringId){
|
||||
return Long.parseLong(stringId);
|
||||
}
|
||||
|
||||
protected String getRoleName(String roleNameFull){
|
||||
List<Organization> orgs;
|
||||
String roleName = null;
|
||||
try {
|
||||
orgs = OrganizationLocalServiceUtil.getOrganizations(0, OrganizationLocalServiceUtil.getOrganizationsCount());
|
||||
for(Organization org : orgs){
|
||||
if(roleNameFull.contains(org.getName())){
|
||||
roleName = roleNameFull.substring(0, roleNameFull.indexOf(org.getName())-1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (SystemException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
return roleName;
|
||||
}
|
||||
|
||||
public HashMap <String, String> listAllowedRoles (String groupName) throws UserManagementSystemException, GroupRetrievalFault, UserManagementFileNotFoundException, UserManagementIOException
|
||||
{
|
||||
GroupManager gm = new LiferayGroupManager();
|
||||
String groupId = gm.getGroupId(groupName);
|
||||
HashMap<String,String> hMap = new HashMap<String,String>();
|
||||
// Code changed to remove hardcoded role names to external config file as requested by Leonordo and Manzi
|
||||
/* List<String> vreRoles = Arrays.asList("VRE-Manager", "VRE-User");
|
||||
List<String> voRoles = Arrays.asList("VO-Admin", "VRE-Designer", "VRE-Manager", "Data-Manager");
|
||||
List<String> rootVoRoles = Arrays.asList("Infrastructure-Manager", "Site-Manager");*/
|
||||
|
||||
if(gm.isRootVO(groupId)){
|
||||
hMap = ParseXML.getRoles(ROOT_VO);
|
||||
}else if (gm.isVO(groupId)){
|
||||
hMap = ParseXML.getRoles(VO);
|
||||
}else if (gm.isVRE(groupId)){
|
||||
hMap = ParseXML.getRoles(VRE);
|
||||
}
|
||||
return hMap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public String getRoleId(String roleName, String groupName) throws UserManagementSystemException{
|
||||
List<Role> roles = null;
|
||||
String rolenameLR = null;
|
||||
long roleId = 0;
|
||||
try {
|
||||
roles = RoleLocalServiceUtil.getRoles(0, RoleLocalServiceUtil.getRolesCount());
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error retrieving roles ", e);
|
||||
}
|
||||
if(!roleName.equalsIgnoreCase(PRODUCTION_SUPPORT)){
|
||||
roleName = roleName + "-" + groupName;
|
||||
}
|
||||
|
||||
for(Role role: roles){
|
||||
rolenameLR = role.getName();
|
||||
if(rolenameLR.equalsIgnoreCase(roleName)){
|
||||
roleId = role.getRoleId();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return String.valueOf(roleId);
|
||||
}
|
||||
|
||||
public void assignRoleToUser(String groupIdn, String roleIdn,
|
||||
String userIdn) throws UserManagementSystemException, GroupRetrievalFault, RoleRetrievalFault, UserRetrievalFault{
|
||||
long[] roleIds;
|
||||
long roleId = this.convertType(roleIdn);
|
||||
long userId = this.convertType(userIdn);
|
||||
long groupId = this.convertType(groupIdn);
|
||||
int i = 0;
|
||||
String orgName = null;
|
||||
Role role = null;
|
||||
Organization org;
|
||||
List<Role> roles;
|
||||
try {
|
||||
org = OrganizationLocalServiceUtil.getOrganization(groupId);
|
||||
roles = RoleLocalServiceUtil.getUserRoles(userId);
|
||||
}catch (PortalException e){
|
||||
throw new GroupRetrievalFault("No group exists with groupId ",groupIdn, e);
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error assigning role to user ", e);
|
||||
}
|
||||
|
||||
roleIds = new long[roles.size()+1];
|
||||
for(Role userRole : roles){
|
||||
roleIds[i++] = userRole.getRoleId();
|
||||
}
|
||||
roleIds[i]= this.convertType(roleIdn);
|
||||
orgName = org.getName();
|
||||
try {
|
||||
role = RoleLocalServiceUtil.getRole(roleId);
|
||||
} catch (PortalException e) {
|
||||
throw new RoleRetrievalFault("No Role exists with roleId",roleIdn,e);
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error assigning role to user ", e);
|
||||
}
|
||||
String roleName = role.getName();
|
||||
if(!roleName.equalsIgnoreCase(PRODUCTION_SUPPORT)){
|
||||
if(roleName.contains(orgName)){
|
||||
try {
|
||||
if(UserLocalServiceUtil.hasOrganizationUser(groupId, userId)){
|
||||
RoleLocalServiceUtil.setUserRoles(userId, roleIds);
|
||||
}
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error assigning role to user ", e);
|
||||
} catch (PortalException e) {
|
||||
throw new UserRetrievalFault("No User exists with userId ",userIdn,e);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
try {
|
||||
RoleLocalServiceUtil.setUserRoles(userId, roleIds);
|
||||
} catch (PortalException e) {
|
||||
throw new UserRetrievalFault("Error assigning role to user with userId ",userIdn,e);
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error assigning role to user ", e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private RoleModel createRoleUtil(String roleName,String roleDesc) throws UserManagementSystemException, RoleRetrievalFault, UserManagementPortalException {
|
||||
Role role = null;
|
||||
RoleModel rm = null;
|
||||
LiferayGroupManager gm = new LiferayGroupManager();
|
||||
//List<String> allowedRoles = getAllowedRoles(groupName);
|
||||
boolean roleExists = false;
|
||||
|
||||
long companyId = gm.getCompanyId();
|
||||
|
||||
//roleName = roleName + "-" + groupName;
|
||||
List<Role> roles;
|
||||
try {
|
||||
roles = RoleLocalServiceUtil.getRoles(0, RoleLocalServiceUtil.getRolesCount());
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error creating role ", e);
|
||||
}
|
||||
for(Role existingRole : roles){
|
||||
if(existingRole.getName().equals(roleName)){
|
||||
roleExists = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!roleExists){
|
||||
try {
|
||||
Locale english = new Locale("en");
|
||||
HashMap<Locale, String> roleNames = new HashMap<Locale, String>();
|
||||
roleNames.put(english, roleName);
|
||||
role = RoleLocalServiceUtil.addRole(0L, companyId, roleName, roleNames, roleDesc, 1);
|
||||
} catch (PortalException e) {
|
||||
throw new RoleRetrievalFault("Cannot create new role, check the roleName already exists",roleName,e);
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error creating role ", e);
|
||||
}
|
||||
if(!roleName.equalsIgnoreCase(PRODUCTION_SUPPORT)){
|
||||
roleName = roleName.substring(0, roleName.lastIndexOf("-"));
|
||||
}
|
||||
|
||||
rm = new RoleModel(roleName,String.valueOf(role.getRoleId()),role.getDescription());
|
||||
}else{
|
||||
throw new RoleRetrievalFault("Cannot create new role, check the roleName already exists",roleName);
|
||||
}
|
||||
return rm;
|
||||
}
|
||||
|
||||
public boolean createRole(String roleName,String roleDescription, String groupName) throws UserManagementSystemException, GroupRetrievalFault, RoleRetrievalFault, UserManagementPortalException {
|
||||
List<RoleModel> roleModels = new ArrayList<RoleModel>();
|
||||
//String roleDesc = validateRoleName(roleName, groupId);
|
||||
if(!roleName.equalsIgnoreCase(PRODUCTION_SUPPORT)){
|
||||
roleName = roleName +"-"+groupName;
|
||||
}
|
||||
|
||||
roleModels.add(this.createRoleUtil(roleName, roleDescription));
|
||||
return true;
|
||||
}
|
||||
|
||||
public void createRole(String groupName) throws UserManagementSystemException, GroupRetrievalFault, RoleRetrievalFault, UserManagementPortalException, UserManagementFileNotFoundException, UserManagementIOException{
|
||||
GroupManager gm = new LiferayGroupManager();
|
||||
Organization org;
|
||||
HashMap<String,String> allowedRolesConfig;
|
||||
try {
|
||||
String groupId = gm.getGroupId(groupName);
|
||||
allowedRolesConfig = listAllowedRoles(groupName);
|
||||
org = OrganizationLocalServiceUtil.getOrganization(this.convertType(groupId));
|
||||
}catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error creating roles for group ", groupName , e);
|
||||
} catch (PortalException e) {
|
||||
throw new GroupRetrievalFault("No group exists with group Name ", groupName, e);
|
||||
}
|
||||
String orgName = org.getName();
|
||||
Set<String> allowedRoles = allowedRolesConfig.keySet();
|
||||
Collection<String> allowedRolesDesc = allowedRolesConfig.values();
|
||||
Iterator<String> rolesDescIter = allowedRolesDesc.iterator();
|
||||
|
||||
for(String allowedRole : allowedRoles){
|
||||
if(!allowedRole.equalsIgnoreCase(PRODUCTION_SUPPORT)){
|
||||
allowedRole = allowedRole+ "-"+ orgName;
|
||||
}
|
||||
this.createRoleUtil(allowedRole, rolesDescIter.next());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void deleteRole(String roleName, String groupName)throws UserManagementSystemException, RoleRetrievalFault{
|
||||
try {
|
||||
String roleId = this.getRoleId(roleName, groupName);
|
||||
RoleLocalServiceUtil.deleteRole(this.convertType(roleId));
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error deleting role ", roleName , e);
|
||||
} catch (PortalException e) {
|
||||
throw new RoleRetrievalFault("No role exists with role name ", roleName, e);
|
||||
}
|
||||
}
|
||||
|
||||
public void dismissRoleFromUser(String groupIdn, String roleIdn,
|
||||
String userIdn) throws UserManagementSystemException, RoleRetrievalFault, GroupRetrievalFault, UserRetrievalFault{
|
||||
//boolean isMember = false;
|
||||
long roleId = this.convertType(roleIdn);
|
||||
long[] roleIds = {roleId};
|
||||
long userId = this.convertType(userIdn);
|
||||
long groupId = this.convertType(groupIdn);
|
||||
String orgName;
|
||||
Role role;
|
||||
try {
|
||||
role = RoleLocalServiceUtil.getRole(roleId);
|
||||
}catch (PortalException e) {
|
||||
throw new RoleRetrievalFault("No role exists with roleId ", roleIdn, e);
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error dismissing roles from userc", userIdn, e);
|
||||
}
|
||||
Organization org;
|
||||
try {
|
||||
org = OrganizationLocalServiceUtil.getOrganization(groupId);
|
||||
} catch (PortalException e) {
|
||||
throw new GroupRetrievalFault("No group exists with group Name ", groupIdn, e);
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error dismissing roles from userc", userIdn, e);
|
||||
}
|
||||
orgName = org.getName();
|
||||
if(!role.getName().equalsIgnoreCase(PRODUCTION_SUPPORT)){
|
||||
if(role.getName().contains(orgName)){
|
||||
try {
|
||||
if(UserLocalServiceUtil.hasRoleUser(roleId, userId)){
|
||||
RoleLocalServiceUtil.unsetUserRoles(userId, roleIds);
|
||||
}
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error dismissing roles from user ", userIdn, e);
|
||||
} catch (PortalException e) {
|
||||
throw new UserRetrievalFault("No User exists with userId ",userIdn,e);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
try {
|
||||
if(UserLocalServiceUtil.hasRoleUser(roleId, userId)){
|
||||
RoleLocalServiceUtil.unsetUserRoles(userId, roleIds);
|
||||
}
|
||||
}catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error dismissing roles from user ", userIdn, e);
|
||||
} catch (PortalException e) {
|
||||
throw new UserRetrievalFault("No User exists with userId ",userIdn,e);
|
||||
}
|
||||
}
|
||||
|
||||
//remove user from VO if no roles relevant to the VO are present
|
||||
// removed as requested by massi as this removes the Organization-member role for the user
|
||||
/* List<Role> userRoles = RoleLocalServiceUtil.getUserRoles(userId);
|
||||
for(Role userRole : userRoles){
|
||||
if(userRole.getName().contains(orgName)){
|
||||
isMember = true;
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
// if the user does nt have other roles in the group, remove the user from the group
|
||||
/* if(!isMember){
|
||||
long[] userIds = {userId};
|
||||
UserLocalServiceUtil.unsetOrganizationUsers(groupId, userIds);
|
||||
}*/
|
||||
|
||||
}
|
||||
|
||||
public RoleModel getRole(String roleId) throws UserManagementSystemException, RoleRetrievalFault{
|
||||
Role role = null;
|
||||
RoleModel rm = null;
|
||||
String roleName;
|
||||
String completeRoleName;
|
||||
try {
|
||||
role = RoleLocalServiceUtil.getRole(this.convertType(roleId));
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error retrieving role ", roleId , e);
|
||||
} catch (PortalException e) {
|
||||
throw new RoleRetrievalFault("No role exists with roleId ", roleId, e);
|
||||
}
|
||||
completeRoleName = role.getName();
|
||||
roleName = getRoleName(completeRoleName);
|
||||
rm = new RoleModel(roleName,String.valueOf(role.getRoleId()),role.getDescription());
|
||||
rm.setCompleteName(completeRoleName);
|
||||
|
||||
return rm;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public List<String> listRoles() throws UserManagementSystemException {
|
||||
List<Role> roles = null;
|
||||
String roleName;
|
||||
List<String> roleNames = new ArrayList<String>();
|
||||
try {
|
||||
roles = RoleLocalServiceUtil.getRoles(0, RoleLocalServiceUtil.getRolesCount());
|
||||
for(Role role:roles){
|
||||
roleName = role.getName();
|
||||
if(roleName.contains("-")){
|
||||
roleName = getRoleName(roleName);
|
||||
if(!roleNames.contains(roleName)){
|
||||
roleNames.add(roleName);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error listing roles ", e);
|
||||
}
|
||||
return roleNames;
|
||||
}
|
||||
|
||||
public List<RoleModel> listAllRoles() throws UserManagementSystemException {
|
||||
List<Role> roles = null;
|
||||
String roleName;
|
||||
String completeRoleName;
|
||||
List<RoleModel> roleModels = new ArrayList<RoleModel>();
|
||||
try {
|
||||
roles = RoleLocalServiceUtil.getRoles(0, RoleLocalServiceUtil.getRolesCount());
|
||||
for(Role role:roles){
|
||||
completeRoleName = role.getName();
|
||||
if(!completeRoleName.equalsIgnoreCase(PRODUCTION_SUPPORT)){
|
||||
roleName = getRoleName(completeRoleName);
|
||||
}
|
||||
else roleName = completeRoleName;
|
||||
|
||||
RoleModel rm = new RoleModel(roleName,String.valueOf(role.getRoleId()),role.getDescription());
|
||||
rm.setCompleteName(completeRoleName);
|
||||
roleModels.add(rm);
|
||||
}
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error listing roles ", e);
|
||||
}
|
||||
return roleModels;
|
||||
}
|
||||
|
||||
public List<RoleModel> listRolesByUser(String userId) throws UserManagementSystemException {
|
||||
List<Role> roles = null;
|
||||
List<RoleModel> roleModels = new ArrayList<RoleModel>();
|
||||
String roleName;
|
||||
String completeRoleName;
|
||||
try {
|
||||
roles = RoleLocalServiceUtil.getUserRoles(this.convertType(userId));
|
||||
for(Role role:roles){
|
||||
completeRoleName = role.getName();
|
||||
if(!completeRoleName.equalsIgnoreCase(PRODUCTION_SUPPORT)){
|
||||
roleName = getRoleName(completeRoleName);
|
||||
}
|
||||
else roleName = completeRoleName;
|
||||
|
||||
RoleModel rm = new RoleModel(roleName,String.valueOf(role.getRoleId()),role.getDescription());
|
||||
rm.setCompleteName(completeRoleName);
|
||||
roleModels.add(rm);
|
||||
|
||||
}
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error listing roles for user ",userId, e);
|
||||
}
|
||||
return roleModels;
|
||||
}
|
||||
|
||||
public List<RoleModel> listRolesByUserAndGroup(String groupId, String userId) throws UserManagementSystemException, GroupRetrievalFault{
|
||||
List<Role> userRoles = new ArrayList<Role>();
|
||||
List<RoleModel> userRoleModels = new ArrayList<RoleModel>();
|
||||
List<Role> roles = null;
|
||||
String roleName;
|
||||
String completeRoleName;
|
||||
String orgName;
|
||||
Organization org = null;
|
||||
try {
|
||||
roles = RoleLocalServiceUtil.getUserRoles(this.convertType(userId));
|
||||
}catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error listing roles by user and group ", e);
|
||||
}
|
||||
|
||||
try {
|
||||
org = OrganizationLocalServiceUtil.getOrganization(this.convertType(groupId));
|
||||
} catch (PortalException e) {
|
||||
throw new GroupRetrievalFault("No group exists with group Id ", groupId, e);
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error listing roles by user and group ", e);
|
||||
}
|
||||
orgName = org.getName();
|
||||
for(Role role : roles){
|
||||
if(role.getName().contains(orgName)){
|
||||
userRoles.add(role);
|
||||
completeRoleName = role.getName();
|
||||
roleName = getRoleName(completeRoleName);
|
||||
RoleModel rm = new RoleModel(roleName,String.valueOf(role.getRoleId()),role.getDescription());
|
||||
rm.setCompleteName(completeRoleName);
|
||||
userRoleModels.add(rm);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return userRoleModels;
|
||||
}
|
||||
|
||||
public List<RoleModel> listRolesByGroup(String groupId) throws UserManagementSystemException, GroupRetrievalFault, UserManagementFileNotFoundException, UserManagementIOException{
|
||||
|
||||
List<Role> groupRoles = new ArrayList<Role>();
|
||||
List<RoleModel> groupRoleModels = new ArrayList<RoleModel>();
|
||||
GroupManager gm = new LiferayGroupManager();
|
||||
List<Role> roles = null;
|
||||
String orgName;
|
||||
String roleName;
|
||||
String completeRoleName;
|
||||
String groupType = null;
|
||||
try {
|
||||
roles = RoleLocalServiceUtil.getRoles(0, RoleLocalServiceUtil.getRolesCount());
|
||||
|
||||
} catch (SystemException e) {
|
||||
|
||||
throw new UserManagementSystemException("Error listing roles for group ", groupId , e);
|
||||
}
|
||||
Organization org;
|
||||
try {
|
||||
org = OrganizationLocalServiceUtil.getOrganization(this.convertType(groupId));
|
||||
|
||||
} catch (PortalException e) {
|
||||
throw new GroupRetrievalFault("No group exists with group Id ", groupId, e);
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error listing roles for group ", groupId , e);
|
||||
}
|
||||
orgName = org.getName();
|
||||
if(gm.isRootVO(groupId)){
|
||||
groupType = ROOT_VO;
|
||||
}else if(gm.isVO(groupId)){
|
||||
groupType = VO;
|
||||
}else if(gm.isVRE(groupId)){
|
||||
groupType = VRE;
|
||||
}
|
||||
for(Role role : roles){
|
||||
if(role.getName().endsWith(orgName)){
|
||||
groupRoles.add(role);
|
||||
completeRoleName = role.getName();
|
||||
roleName = getRoleName(completeRoleName);
|
||||
if(ParseXML.getRoles(groupType).containsKey(roleName)){
|
||||
String roleDesc;
|
||||
if(role.getDescription()==""){
|
||||
roleDesc = ParseXML.getRoles(groupType).get(roleName);
|
||||
role.setDescription(roleDesc);
|
||||
try {
|
||||
RoleLocalServiceUtil.updateRole(role);
|
||||
}catch (SystemException e) {
|
||||
e.printStackTrace();
|
||||
throw new UserManagementSystemException("Error updating role ",role.getName(), e);
|
||||
}
|
||||
}else{
|
||||
roleDesc = role.getDescription();
|
||||
}
|
||||
RoleModel rm = new RoleModel(roleName,String.valueOf(role.getRoleId()),roleDesc);
|
||||
rm.setCompleteName(completeRoleName);
|
||||
groupRoleModels.add(rm);
|
||||
}else{
|
||||
|
||||
RoleModel rm = new RoleModel(roleName,String.valueOf(role.getRoleId()),role.getDescription());
|
||||
groupRoleModels.add(rm);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Role role = this.getCommonRole();
|
||||
if(role!=null){
|
||||
String roleDesc;
|
||||
try {
|
||||
if(role.getDescription()==""){
|
||||
roleDesc = ParseXML.getRoles(VO).get(role.getName());
|
||||
role.setDescription(roleDesc);
|
||||
RoleLocalServiceUtil.updateRole(role);
|
||||
}else{
|
||||
roleDesc = role.getDescription();
|
||||
}
|
||||
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error updating role Production-Support", e);
|
||||
}
|
||||
groupRoleModels.add(new RoleModel(role.getName(),String.valueOf(role.getRoleId()),roleDesc));
|
||||
}
|
||||
|
||||
return groupRoleModels;
|
||||
}
|
||||
|
||||
protected Role getCommonRole() throws UserManagementSystemException{
|
||||
List<Role> roles;
|
||||
try {
|
||||
roles = RoleLocalServiceUtil.getRoles(0, RoleLocalServiceUtil.getRolesCount());
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error listing roles ", e);
|
||||
}
|
||||
|
||||
for(Role role : roles){
|
||||
if(role.getName().equalsIgnoreCase(PRODUCTION_SUPPORT)){
|
||||
return role;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private List<GroupModel> getGroupsByType(String groupType) throws UserManagementSystemException, GroupRetrievalFault{
|
||||
LiferayGroupManager gm = new LiferayGroupManager();
|
||||
List<GroupModel> groups = gm.listGroups();
|
||||
List<GroupModel> groupsByType = new ArrayList<GroupModel>();
|
||||
|
||||
if(groupType.equals(VO)){
|
||||
for(GroupModel group:groups){
|
||||
if(gm.isVO(group.getGroupId())){
|
||||
groupsByType.add(group);
|
||||
}
|
||||
}
|
||||
}else if(groupType.equals(VRE)){
|
||||
for(GroupModel group:groups){
|
||||
if(gm.isVRE(group.getGroupId())){
|
||||
groupsByType.add(group);
|
||||
}
|
||||
}
|
||||
}else if(groupType.equals(ROOT_VO)){
|
||||
for(GroupModel group:groups){
|
||||
if(gm.isRootVO(group.getGroupId())){
|
||||
groupsByType.add(group);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return groupsByType;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void updateRole(String initialRoleName, String newRoleName, String roleDescription, String groupName) throws UserManagementSystemException, RoleRetrievalFault, NumberFormatException, UserManagementFileNotFoundException, UserManagementIOException, GroupRetrievalFault, UserManagementPortalException {
|
||||
|
||||
Role role = null;
|
||||
boolean isSystemRole = false;
|
||||
String roleId;
|
||||
String[] groupTypes = {VO,VRE,ROOT_VO};
|
||||
if(!initialRoleName.equalsIgnoreCase(PRODUCTION_SUPPORT)){
|
||||
roleId = this.getRoleId(initialRoleName, groupName);
|
||||
}else{
|
||||
roleId = String.valueOf(this.getCommonRole().getRoleId());
|
||||
for(String groupType : groupTypes){
|
||||
HashMap<String,String> hMap = ParseXML.getRoles(groupType);
|
||||
hMap.put(initialRoleName, roleDescription);
|
||||
ParseXML.updateRoles(hMap, groupType);
|
||||
}
|
||||
Role prod_supp_role;
|
||||
try {
|
||||
prod_supp_role = RoleLocalServiceUtil.getRole(Long.parseLong(roleId));
|
||||
prod_supp_role.setDescription(roleDescription);
|
||||
RoleLocalServiceUtil.updateRole(prod_supp_role);
|
||||
} catch (PortalException e1) {
|
||||
throw new UserManagementPortalException("Error retrieving role ", initialRoleName , e1);
|
||||
} catch (SystemException e1) {
|
||||
throw new UserManagementSystemException("Error updating role ", initialRoleName , e1);
|
||||
}
|
||||
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
role = RoleLocalServiceUtil.getRole(Long.parseLong(roleId));
|
||||
} catch (PortalException e2) {
|
||||
throw new UserManagementPortalException("Error retrieving role ", initialRoleName , e2);
|
||||
} catch (SystemException e2) {
|
||||
throw new UserManagementSystemException("Error updating role ", initialRoleName , e2);
|
||||
}
|
||||
|
||||
|
||||
if(ParseXML.getRoles(VO).containsKey(initialRoleName)){
|
||||
isSystemRole = true;
|
||||
// update the predefined config file
|
||||
HashMap<String,String> hMap = ParseXML.getRoles(VO);
|
||||
if(hMap.containsKey(initialRoleName)){
|
||||
hMap.put(initialRoleName, roleDescription);
|
||||
|
||||
ParseXML.updateRoles(hMap, VO);
|
||||
// update the actual roles
|
||||
List<GroupModel> voGroups = this.getGroupsByType(VO);
|
||||
|
||||
for(GroupModel group:voGroups){
|
||||
List<RoleModel> rm = this.listRolesByGroup(group.getGroupId());
|
||||
for(RoleModel roleModel : rm){
|
||||
if(roleModel.getRoleName().equals(initialRoleName)){
|
||||
String voroleId = this.getRoleId(initialRoleName, group.getGroupName());
|
||||
Role affectedRole;
|
||||
try {
|
||||
try {
|
||||
affectedRole = RoleLocalServiceUtil.getRole(Long.parseLong(voroleId));
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error updating role ", initialRoleName , e);
|
||||
}
|
||||
} catch (PortalException e) {
|
||||
throw new RoleRetrievalFault("Error retrieving role with name ", initialRoleName, e);
|
||||
}
|
||||
affectedRole.setDescription(roleDescription);
|
||||
try {
|
||||
RoleLocalServiceUtil.updateRole(affectedRole);
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error updating role ", initialRoleName , e);
|
||||
//break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} if(ParseXML.getRoles(VRE).containsKey(initialRoleName)){
|
||||
isSystemRole = true;
|
||||
HashMap<String,String> hMap = ParseXML.getRoles(VRE);
|
||||
if(hMap.containsKey(initialRoleName)){
|
||||
hMap.put(initialRoleName, roleDescription);
|
||||
ParseXML.updateRoles(hMap, VRE);
|
||||
|
||||
List<GroupModel> vreGroups = this.getGroupsByType(VRE);
|
||||
|
||||
for(GroupModel group:vreGroups){
|
||||
List<RoleModel> rm = this.listRolesByGroup(group.getGroupId());
|
||||
for(RoleModel roleModel : rm){
|
||||
if(roleModel.getRoleName().equals(initialRoleName)){
|
||||
if(this.listRolesByGroup(group.getGroupId()).contains(initialRoleName)){
|
||||
String vreroleId = this.getRoleId(initialRoleName, group.getGroupName());
|
||||
Role affectedRole;
|
||||
try {
|
||||
try {
|
||||
affectedRole = RoleLocalServiceUtil.getRole(Long.parseLong(vreroleId));
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error updating role ", initialRoleName , e);
|
||||
}
|
||||
} catch (PortalException e) {
|
||||
throw new RoleRetrievalFault("Error retrieving role with name ", initialRoleName, e);
|
||||
}
|
||||
affectedRole.setDescription(roleDescription);
|
||||
try {
|
||||
RoleLocalServiceUtil.updateRole(affectedRole);
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error updating role ", initialRoleName , e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} if(ParseXML.getRoles(ROOT_VO).containsKey(initialRoleName)){
|
||||
isSystemRole = true;
|
||||
HashMap<String,String> hMap = ParseXML.getRoles(ROOT_VO);
|
||||
if(hMap.containsKey(initialRoleName)){
|
||||
ParseXML.updateRoles(hMap, ROOT_VO);
|
||||
|
||||
List<GroupModel> rootvoGroups = this.getGroupsByType(ROOT_VO);
|
||||
for(GroupModel group:rootvoGroups){
|
||||
List<RoleModel> rm = this.listRolesByGroup(group.getGroupId());
|
||||
for(RoleModel roleModel : rm){
|
||||
if(roleModel.getRoleName().equals(initialRoleName)){
|
||||
String rootVoroleId = this.getRoleId(initialRoleName, group.getGroupName());
|
||||
Role affectedRole;
|
||||
try {
|
||||
try {
|
||||
affectedRole = RoleLocalServiceUtil.getRole(Long.parseLong(rootVoroleId));
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error updating role ", initialRoleName , e);
|
||||
}
|
||||
} catch (PortalException e) {
|
||||
throw new RoleRetrievalFault("Error retrieving role with name ", initialRoleName, e);
|
||||
}
|
||||
affectedRole.setDescription(roleDescription);
|
||||
try {
|
||||
RoleLocalServiceUtil.updateRole(affectedRole);
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error updating role ", initialRoleName , e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}if(!isSystemRole){
|
||||
role.setDescription(roleDescription);
|
||||
newRoleName = newRoleName + "-" + groupName;
|
||||
role.setName(newRoleName);
|
||||
try {
|
||||
RoleLocalServiceUtil.updateRole(role);
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error updating role ", initialRoleName , e);
|
||||
}
|
||||
}
|
||||
|
||||
/* role.setName(roleModel.getRoleName());
|
||||
role.setDescription(roleModel.getDescription());*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void updatePredefinedRoles(HashMap<String, String> rolesMap, String groupType)
|
||||
throws UserManagementIOException, UserManagementFileNotFoundException {
|
||||
if(groupType.equals(VRE)){
|
||||
ParseXML.updateRoles(rolesMap, VRE);
|
||||
}else if (groupType.equals(VO)){
|
||||
ParseXML.updateRoles(rolesMap, VO);
|
||||
}else if(groupType.equals(ROOT_VO)){
|
||||
ParseXML.updateRoles(rolesMap, ROOT_VO);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,969 @@
|
|||
package org.gcube.vomanagement.usermanagement.impl.liferay;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.gcube.vomanagement.usermanagement.GroupManager;
|
||||
import org.gcube.vomanagement.usermanagement.UserManager;
|
||||
import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault;
|
||||
import org.gcube.vomanagement.usermanagement.exception.RoleRetrievalFault;
|
||||
import org.gcube.vomanagement.usermanagement.exception.UserManagementPortalException;
|
||||
import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException;
|
||||
import org.gcube.vomanagement.usermanagement.exception.UserRetrievalFault;
|
||||
import org.gcube.vomanagement.usermanagement.impl.liferay.utils.ExpandoClassCodeManager;
|
||||
import org.gcube.vomanagement.usermanagement.impl.liferay.utils.ExpandoDefaultTableManager;
|
||||
import org.gcube.vomanagement.usermanagement.model.GroupModel;
|
||||
import org.gcube.vomanagement.usermanagement.model.RoleModel;
|
||||
import org.gcube.vomanagement.usermanagement.model.UserModel;
|
||||
|
||||
|
||||
import com.liferay.portal.kernel.exception.PortalException;
|
||||
import com.liferay.portal.kernel.exception.SystemException;
|
||||
import com.liferay.portal.model.MembershipRequest;
|
||||
import com.liferay.portal.model.Organization;
|
||||
import com.liferay.portal.model.Role;
|
||||
import com.liferay.portal.model.User;
|
||||
import com.liferay.portal.service.MembershipRequestLocalServiceUtil;
|
||||
import com.liferay.portal.service.OrganizationLocalServiceUtil;
|
||||
import com.liferay.portal.service.RoleLocalServiceUtil;
|
||||
import com.liferay.portal.service.ServiceContext;
|
||||
import com.liferay.portal.service.UserLocalServiceUtil;
|
||||
import com.liferay.portlet.expando.model.ExpandoColumn;
|
||||
import com.liferay.portlet.expando.model.ExpandoTable;
|
||||
import com.liferay.portlet.expando.model.ExpandoValue;
|
||||
import com.liferay.portlet.expando.service.ExpandoColumnLocalServiceUtil;
|
||||
import com.liferay.portlet.expando.service.ExpandoValueLocalServiceUtil;
|
||||
|
||||
/**
|
||||
* Liferay plugin for the UserManager interface, this implementation interacts with Liferay through a LocalService.
|
||||
*
|
||||
* @author Giulio Galiero
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
public class LiferayUserManager implements UserManager {
|
||||
|
||||
private final String DEFAULT_STRING = "_";
|
||||
|
||||
private long convertStringToLong(String id){
|
||||
return Long.parseLong(id);
|
||||
}
|
||||
|
||||
|
||||
public List<UserModel> getAllUsers () throws UserManagementSystemException, UserRetrievalFault
|
||||
{
|
||||
List<User> users = null;
|
||||
List<UserModel> response = new ArrayList<UserModel>();
|
||||
|
||||
try {
|
||||
users = UserLocalServiceUtil.getUsers(0, UserLocalServiceUtil.getUsersCount());
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error getting the user list",e);
|
||||
}
|
||||
for(User user: users)
|
||||
{
|
||||
|
||||
response.add(new UserModel(String.valueOf(user.getUserId()),user.getFirstName(),user.getLastName(),user.getFullName(),user.getEmailAddress(),user.getScreenName(), user.getCreateDate().getTime() ,this.getUserCustomAttributes(String.valueOf(user.getUserId()))));
|
||||
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
public String getUserId(String userName) throws UserManagementSystemException{
|
||||
List<User> users = null;
|
||||
long userId = 0;
|
||||
try {
|
||||
users = UserLocalServiceUtil.getUsers(0, UserLocalServiceUtil.getUsersCount());
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error getting the User Id of user ",userName, e);
|
||||
}
|
||||
for(User user: users){
|
||||
if(user.getScreenName().equalsIgnoreCase(userName)){
|
||||
userId = user.getUserId();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return String.valueOf(userId);
|
||||
}
|
||||
|
||||
public void assignUserToGroup(String groupIdn, String userIdn) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault, UserManagementPortalException {
|
||||
long userId = this.convertStringToLong(userIdn);
|
||||
List<MembershipRequest> memberRequests = null;
|
||||
long groupId = this.convertStringToLong(groupIdn);
|
||||
long[] userIds = {userId};
|
||||
GroupManager groupManager = new LiferayGroupManager();
|
||||
Organization org = null;
|
||||
|
||||
// Add the user to Parent Organization if they are not already added
|
||||
try {
|
||||
org = OrganizationLocalServiceUtil.getOrganization(groupId);
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error assigning user to Group ", groupIdn , e);
|
||||
} catch (PortalException e) {
|
||||
throw new GroupRetrievalFault("No group exists with groupId ",groupIdn, e);
|
||||
}
|
||||
User user = null;
|
||||
List<Organization> orgs = null;
|
||||
try {
|
||||
user = UserLocalServiceUtil.getUser(userId);
|
||||
orgs = user.getOrganizations();
|
||||
} catch (PortalException e) {
|
||||
throw new UserRetrievalFault("No user exists with userId ",userIdn, e);
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error assigning user to Group ", groupIdn , e);
|
||||
}
|
||||
|
||||
if(groupManager.isRootVO(groupIdn)){
|
||||
//RootVO
|
||||
try {
|
||||
UserLocalServiceUtil.addOrganizationUsers(groupId, userIds);
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error assigning user to Group ", groupIdn , e);
|
||||
} catch (PortalException e) {
|
||||
throw new UserManagementPortalException("Check if user already exists in group ", groupIdn , e);
|
||||
}
|
||||
|
||||
}else if (groupManager.isVO(groupIdn)){
|
||||
//VO
|
||||
try {
|
||||
UserLocalServiceUtil.addOrganizationUsers(groupId, userIds);
|
||||
} catch (PortalException e) {
|
||||
throw new UserManagementPortalException("Check if user already exists in group ", groupIdn , e);
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error assigning user to Group ", groupIdn , e);
|
||||
}
|
||||
long parentOrgId = org.getParentOrganizationId();
|
||||
Organization parentOrg = null;
|
||||
try {
|
||||
parentOrg = OrganizationLocalServiceUtil.getOrganization(parentOrgId);
|
||||
} catch (PortalException e) {
|
||||
throw new GroupRetrievalFault("No group exists with groupId ",String.valueOf(parentOrgId), e);
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error assigning user to Group ", groupIdn , e);
|
||||
}
|
||||
if(!orgs.contains(parentOrg)){
|
||||
try {
|
||||
UserLocalServiceUtil.addOrganizationUsers(parentOrgId, userIds);
|
||||
} catch (PortalException e) {
|
||||
throw new UserManagementPortalException("Check if user already exists in group ", String.valueOf(parentOrgId) , e);
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error assigning user to Group ", groupIdn , e);
|
||||
}
|
||||
}
|
||||
|
||||
}else if (groupManager.isVRE(groupIdn)){
|
||||
//VRE
|
||||
try {
|
||||
UserLocalServiceUtil.addOrganizationUsers(groupId, userIds);
|
||||
} catch (PortalException e) {
|
||||
throw new UserManagementPortalException("Check if user already exists in group ", String.valueOf(groupId) , e);
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error assigning user to Group ", groupIdn , e);
|
||||
}
|
||||
long parentOrgId = org.getParentOrganizationId();
|
||||
Organization parentOrg = null;
|
||||
try {
|
||||
parentOrg = OrganizationLocalServiceUtil.getOrganization(parentOrgId);
|
||||
} catch (PortalException e) {
|
||||
throw new GroupRetrievalFault("No group exists with groupId ",String.valueOf(parentOrgId), e);
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error assigning user to Group ", groupIdn , e);
|
||||
}
|
||||
if(!orgs.contains(parentOrg)){
|
||||
try {
|
||||
UserLocalServiceUtil.addOrganizationUsers(parentOrgId, userIds);
|
||||
} catch (PortalException e) {
|
||||
throw new GroupRetrievalFault("Check if user already exists in group ",String.valueOf(parentOrgId), e);
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error assigning user to Group ", groupIdn , e);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
parentOrgId = org.getParentOrganization().getParentOrganizationId();
|
||||
} catch (PortalException e) {
|
||||
throw new GroupRetrievalFault("No group exists with groupId ",String.valueOf(parentOrgId), e);
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error assigning user to Group ", groupIdn , e);
|
||||
}
|
||||
try {
|
||||
parentOrg = OrganizationLocalServiceUtil.getOrganization(parentOrgId);
|
||||
} catch (PortalException e) {
|
||||
throw new GroupRetrievalFault("No group exists with groupId ",String.valueOf(parentOrgId), e);
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error assigning user to Group ", groupIdn , e);
|
||||
}
|
||||
if(!orgs.contains(parentOrg)){
|
||||
try {
|
||||
UserLocalServiceUtil.addOrganizationUsers(parentOrgId, userIds);
|
||||
} catch (PortalException e) {
|
||||
throw new GroupRetrievalFault("Check if user already exists in group ",String.valueOf(parentOrgId), e);
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error assigning user to Group ", groupIdn , e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
//delete the corresponding member request from the MembershipRequest table
|
||||
try {
|
||||
memberRequests = MembershipRequestLocalServiceUtil.getMembershipRequests(0, MembershipRequestLocalServiceUtil.getMembershipRequestsCount());
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error getting membership request ", e);
|
||||
}
|
||||
for(MembershipRequest memberRequest: memberRequests){
|
||||
if(memberRequest.getUserId()==userId && memberRequest.getGroupId()==org.getGroup().getGroupId()){
|
||||
try {
|
||||
MembershipRequestLocalServiceUtil.deleteMembershipRequest(memberRequest);
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error deleting membership request ", String.valueOf(memberRequest.getMembershipRequestId()) , e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void requestMembership(String userIdn, String groupIdn,String comment) throws UserManagementSystemException, GroupRetrievalFault{
|
||||
long userId = this.convertStringToLong(userIdn);
|
||||
long organizationId = this.convertStringToLong(groupIdn);
|
||||
Organization org = null;
|
||||
try {
|
||||
org = OrganizationLocalServiceUtil.getOrganization(organizationId);
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error adding membership request to group ", groupIdn , e);
|
||||
} catch (PortalException e) {
|
||||
throw new GroupRetrievalFault("No group exists with groupId ",groupIdn, e);
|
||||
}
|
||||
try {
|
||||
if (!checkString(comment)) comment = DEFAULT_STRING;
|
||||
MembershipRequest mr = MembershipRequestLocalServiceUtil.addMembershipRequest(userId, org.getGroup().getGroupId(), comment);
|
||||
} catch (PortalException e) {
|
||||
throw new GroupRetrievalFault("error adding membership request for user id ",userIdn, e);
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error adding membership request to group ", groupIdn , e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* If the string is null, empty or a digit returns false
|
||||
*
|
||||
* @param string
|
||||
* @return false if the string is empty, null or a digit, true otherwise
|
||||
*/
|
||||
private boolean checkString (String string)
|
||||
{
|
||||
boolean response = true;
|
||||
|
||||
try
|
||||
{
|
||||
Double.parseDouble(string);
|
||||
response = false;
|
||||
|
||||
} catch (NullPointerException e)
|
||||
{
|
||||
response = false;
|
||||
} catch (NumberFormatException e)
|
||||
{
|
||||
if (string.trim().length() ==0) return false;
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
public List<UserModel> getMembershipRequests(String groupId) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault{
|
||||
List<MembershipRequest> memberRequests = null;
|
||||
List<UserModel> users = new ArrayList<UserModel>();
|
||||
Organization org = null;
|
||||
UserModel um = null;
|
||||
try {
|
||||
memberRequests = MembershipRequestLocalServiceUtil.getMembershipRequests(0, MembershipRequestLocalServiceUtil.getMembershipRequestsCount());
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error retrieving Membership requests of group ",groupId, e);
|
||||
}
|
||||
try {
|
||||
org = OrganizationLocalServiceUtil.getOrganization(convertStringToLong(groupId));
|
||||
} catch (PortalException e) {
|
||||
throw new GroupRetrievalFault("error retrieving group for group Id ",groupId, e);
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error retrieving Membership requests of group ",groupId, e);
|
||||
}
|
||||
for(MembershipRequest memberRequest: memberRequests){
|
||||
if(memberRequest.getGroupId() == org.getGroup().getGroupId()){
|
||||
long userId = memberRequest.getUserId();
|
||||
User user = null;
|
||||
try {
|
||||
user = UserLocalServiceUtil.getUser(userId);
|
||||
} catch (PortalException e) {
|
||||
throw new UserRetrievalFault("Error retrieving user for user Id ",String.valueOf(userId),e);
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error retrieving Membership requests of group ",groupId, e);
|
||||
}
|
||||
um = new UserModel(String.valueOf(user.getUserId()),user.getFirstName(),user.getLastName(),user.getFullName(),user.getEmailAddress(),user.getScreenName(),user.getCreateDate().getTime(),this.getUserCustomAttributes(String.valueOf(user.getUserId())));
|
||||
users.add(um);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return users;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void createUser(UserModel userModel) throws UserManagementSystemException, UserRetrievalFault {
|
||||
String password1 = null;
|
||||
Locale locale = new Locale("en_US");
|
||||
ServiceContext serviceContext = new ServiceContext();
|
||||
String password2 = null;
|
||||
try {
|
||||
UserLocalServiceUtil.addUser(0L, 1L, true, password1,password2, false, userModel.getScreenName(),userModel.getEmail(), 0L,"",
|
||||
locale, userModel.getFirstname(), "mn", userModel.getLastname(), 0, 0, true, 1, 1, 1940, "", null, null, null, null, true, serviceContext);
|
||||
}catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error creating user ",userModel.getScreenName(), e);
|
||||
} catch (PortalException e) {
|
||||
throw new UserRetrievalFault("Error adding user with screen name ",userModel.getScreenName(),e);
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteUser(String userId)throws UserManagementSystemException, UserRetrievalFault {
|
||||
try {
|
||||
UserLocalServiceUtil.deleteUser(this.convertStringToLong(userId));
|
||||
}catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error deleting user ",userId, e);
|
||||
} catch (PortalException e) {
|
||||
throw new UserRetrievalFault("Error deleting user with user Id ",userId,e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void dismissUserFromGroup(String groupId, String userId) throws UserManagementSystemException, NumberFormatException, GroupRetrievalFault, UserRetrievalFault {
|
||||
long[] userIds = {this.convertStringToLong(userId)};
|
||||
GroupManager groupManager = new LiferayGroupManager();
|
||||
long groupIdL = this.convertStringToLong(groupId);
|
||||
List<Organization> dismissedGroups = new ArrayList<Organization>();
|
||||
List<Organization> userOrgs = null;
|
||||
try{
|
||||
|
||||
userOrgs = OrganizationLocalServiceUtil.getUserOrganizations(this.convertStringToLong(userId));
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error dismissing user from group ",groupId, e);
|
||||
} catch (PortalException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
// Remove the user from sub organizations
|
||||
if(groupManager.isRootVO(groupId)){
|
||||
//RootVO
|
||||
// Remove the user from all groups
|
||||
for(Organization userOrg : userOrgs){
|
||||
try {
|
||||
UserLocalServiceUtil.unsetOrganizationUsers(userOrg.getOrganizationId(), userIds);
|
||||
} catch (PortalException e) {
|
||||
throw new UserRetrievalFault("Check the validity userId /Group Id ",e);
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error dismissing user from group ",groupId, e);
|
||||
}
|
||||
dismissedGroups.add(userOrg);
|
||||
}
|
||||
|
||||
}else if (groupManager.isVO(groupId)){
|
||||
//VO
|
||||
//Remove user from VREs under the VO
|
||||
//Remove user from VO
|
||||
try {
|
||||
UserLocalServiceUtil.unsetOrganizationUsers(groupIdL, userIds);
|
||||
} catch (PortalException e) {
|
||||
throw new UserRetrievalFault("Check the validity of userId /Group Id ",e);
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error dismissing user from group ",groupId, e);
|
||||
}
|
||||
try {
|
||||
dismissedGroups.add(OrganizationLocalServiceUtil.getOrganization(groupIdL));
|
||||
} catch (PortalException e) {
|
||||
throw new GroupRetrievalFault("Error retrieving group with group Id ",String.valueOf(groupIdL), e);
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error dismissing user from group ",groupId, e);
|
||||
}
|
||||
//Remove user from subgroups
|
||||
List<GroupModel> VREGroups = groupManager.listSubGroupsByGroup(groupId);
|
||||
for(GroupModel VREGroup : VREGroups){
|
||||
try {
|
||||
UserLocalServiceUtil.unsetOrganizationUsers(Long.parseLong(VREGroup.getGroupId()), userIds);
|
||||
} catch (PortalException e) {
|
||||
throw new UserRetrievalFault("Check the validity of userId /Group Id ",e);
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error dismissing user from group ",groupId, e);
|
||||
}
|
||||
try {
|
||||
dismissedGroups.add(OrganizationLocalServiceUtil.getOrganization(Long.parseLong(VREGroup.getGroupId())));
|
||||
} catch (PortalException e) {
|
||||
throw new GroupRetrievalFault("Error retrieving group with group Id ",VREGroup.getGroupId(), e);
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error dismissing user from group ",groupId, e);
|
||||
}
|
||||
}
|
||||
}else if(groupManager.isVRE(groupId)){
|
||||
//VRE
|
||||
//Remove user from the VRE
|
||||
try {
|
||||
UserLocalServiceUtil.unsetOrganizationUsers(groupIdL, userIds);
|
||||
} catch (PortalException e) {
|
||||
throw new UserRetrievalFault("Check the validity of userId /Group Id ",e);
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error dismissing user from group ",groupId, e);
|
||||
}
|
||||
try {
|
||||
dismissedGroups.add(OrganizationLocalServiceUtil.getOrganization(groupIdL));
|
||||
} catch (PortalException e) {
|
||||
throw new GroupRetrievalFault("Error retrieving group with group Id ",String.valueOf(groupIdL), e);
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error dismissing user from group ",groupId, e);
|
||||
}
|
||||
}
|
||||
|
||||
// Remove all roles from the user that is relevant to the group
|
||||
List<Role> userRoles = null;
|
||||
try {
|
||||
userRoles = RoleLocalServiceUtil.getUserRoles(this.convertStringToLong(userId));
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error dismissing user from group ",groupId, e);
|
||||
}
|
||||
for(Organization dismissedGroup : dismissedGroups){
|
||||
String dismissedGroupName = dismissedGroup.getName();
|
||||
for(Role userRole : userRoles){
|
||||
if(userRole.getName().contains(dismissedGroupName)){
|
||||
long[] roleIds ={userRole.getRoleId()};
|
||||
try {
|
||||
RoleLocalServiceUtil.unsetUserRoles(this.convertStringToLong(userId), roleIds);
|
||||
} catch (PortalException e) {
|
||||
throw new UserRetrievalFault("Error unsetting user roles for user ",userId, e);
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error dismissing user from group ",groupId, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public UserModel getUser(String userId) throws UserManagementSystemException, UserRetrievalFault {
|
||||
User user = null;
|
||||
UserModel um = new UserModel();
|
||||
try {
|
||||
user = UserLocalServiceUtil.getUser(this.convertStringToLong(userId));
|
||||
}catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error retrieving user ",userId, e);
|
||||
} catch (PortalException e) {
|
||||
throw new UserRetrievalFault("Error retrieving user for user Id ",userId, e);
|
||||
}
|
||||
um = new UserModel(String.valueOf(user.getUserId()),user.getFirstName(),user.getLastName(),user.getFullName(),user.getEmailAddress(),user.getScreenName(),user.getCreateDate().getTime(),this.getUserCustomAttributes(String.valueOf(user.getUserId())));
|
||||
return um;
|
||||
}
|
||||
|
||||
|
||||
public List<UserModel> listUsers() throws UserManagementSystemException, UserRetrievalFault {
|
||||
List<User> users = null;
|
||||
List<UserModel> userModels = new ArrayList<UserModel>();
|
||||
try {
|
||||
users = UserLocalServiceUtil.getUsers(0, UserLocalServiceUtil.getUsersCount());
|
||||
for(User user : users){
|
||||
UserModel um = new UserModel(String.valueOf(user.getUserId()),user.getFirstName(),user.getLastName(),user.getFullName(),user.getEmailAddress(),user.getScreenName(),user.getCreateDate().getTime(),this.getUserCustomAttributes(String.valueOf(user.getUserId())));
|
||||
userModels.add(um);
|
||||
}
|
||||
}catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error retrieving list of users ", e);
|
||||
}
|
||||
return userModels;
|
||||
}
|
||||
|
||||
|
||||
public HashMap<UserModel, List<GroupModel>> listUsersAndGroupsByRole(String roleIdn) throws UserManagementSystemException, RoleRetrievalFault, UserRetrievalFault {
|
||||
List<User> users;
|
||||
long userId;
|
||||
HashMap<User, List<Organization>> hMap = new HashMap<User, List<Organization>>();
|
||||
HashMap<UserModel, List<GroupModel>> hMapCustom = new HashMap<UserModel, List<GroupModel>>();
|
||||
UserModel um = null;
|
||||
long roleId = this.convertStringToLong(roleIdn);
|
||||
try {
|
||||
users = UserLocalServiceUtil.getRoleUsers(roleId);
|
||||
for(User user : users){
|
||||
userId = user.getUserId();
|
||||
um = new UserModel(String.valueOf(user.getUserId()),user.getFirstName(),user.getLastName(),user.getFullName(),user.getEmailAddress(),user.getScreenName(),user.getCreateDate().getTime(),this.getUserCustomAttributes(String.valueOf(user.getUserId())));
|
||||
Role role = null;
|
||||
List<Organization> group = new ArrayList<Organization>();
|
||||
List<GroupModel> groupModel = new ArrayList<GroupModel>();
|
||||
List<Organization> orgs = null;
|
||||
try {
|
||||
role = RoleLocalServiceUtil.getRole(roleId);
|
||||
orgs = OrganizationLocalServiceUtil.getUserOrganizations(userId);
|
||||
} catch (PortalException e) {
|
||||
throw new RoleRetrievalFault("Error retrieving role for role Id",String.valueOf(roleId),e);
|
||||
}
|
||||
String roleName = role.getName();
|
||||
for(Organization org : orgs){
|
||||
if(roleName.contains(org.getName())){
|
||||
group.add(org);
|
||||
GroupModel gm = new GroupModel(String.valueOf(org.getOrganizationId()),String.valueOf(org.getParentOrganizationId()),org.getName(),org.getComments(),org.getLogoId());
|
||||
groupModel.add(gm);
|
||||
hMap.put(user, group);
|
||||
|
||||
}
|
||||
}
|
||||
hMapCustom.put(um, groupModel);
|
||||
}
|
||||
}catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error retrieving list of users and groups for role ",roleIdn, e);
|
||||
}
|
||||
return hMapCustom;
|
||||
}
|
||||
|
||||
|
||||
public HashMap<UserModel, List<RoleModel>> listUsersAndRolesByGroup(String orgIdn) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault {
|
||||
List<User> users = null;
|
||||
List<Role> roles = null;
|
||||
UserModel um = null;
|
||||
String orgName = null;
|
||||
String roleName = null;
|
||||
String completeRoleName = null;
|
||||
HashMap<UserModel, List<RoleModel>> hMap = new HashMap<UserModel, List<RoleModel>>();
|
||||
long orgId = this.convertStringToLong(orgIdn);
|
||||
LiferayRoleManager roleMan = new LiferayRoleManager();
|
||||
try {
|
||||
users = UserLocalServiceUtil.getOrganizationUsers(orgId);
|
||||
Organization org = OrganizationLocalServiceUtil.getOrganization(orgId);
|
||||
orgName = org.getName();
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error retrieving list of users for group Id ",orgIdn, e);
|
||||
} catch (PortalException e) {
|
||||
throw new GroupRetrievalFault("Error retrieving group with group Id ",orgIdn, e);
|
||||
}
|
||||
for(User user : users){
|
||||
List<RoleModel> userRoles = new ArrayList<RoleModel>();
|
||||
um = new UserModel(String.valueOf(user.getUserId()),user.getFirstName(),user.getLastName(),user.getFullName(),user.getEmailAddress(),user.getScreenName(),user.getCreateDate().getTime(),this.getUserCustomAttributes(String.valueOf(user.getUserId())));
|
||||
try {
|
||||
roles = user.getRoles();
|
||||
} catch (SystemException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
Role Prod_Supp_role = roleMan.getCommonRole();
|
||||
if(Prod_Supp_role!=null){
|
||||
if(roles.contains(Prod_Supp_role)){
|
||||
RoleModel rm = new RoleModel(Prod_Supp_role.getName(),String.valueOf(Prod_Supp_role.getRoleId()),Prod_Supp_role.getDescription());
|
||||
userRoles.add(rm);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for(Role role : roles){
|
||||
if(role.getName().contains(orgName)){
|
||||
completeRoleName = role.getName();
|
||||
roleName = roleMan.getRoleName(completeRoleName);
|
||||
RoleModel rm = new RoleModel(roleName,String.valueOf(role.getRoleId()),role.getDescription());
|
||||
rm.setCompleteName(completeRoleName);
|
||||
userRoles.add(rm);
|
||||
}
|
||||
}
|
||||
hMap.put(um,userRoles);
|
||||
}
|
||||
return hMap;
|
||||
}
|
||||
|
||||
|
||||
public List<UserModel> listUsersByGroup(String groupId) throws UserManagementSystemException, UserRetrievalFault {
|
||||
List<User> users = null;
|
||||
List<UserModel> userModels = new ArrayList<UserModel>();
|
||||
try {
|
||||
users = UserLocalServiceUtil.getOrganizationUsers(this.convertStringToLong(groupId));
|
||||
for(User user : users){
|
||||
UserModel um = new UserModel(String.valueOf(user.getUserId()),user.getFirstName(),user.getLastName(),user.getFullName(),user.getEmailAddress(),user.getScreenName(),user.getCreateDate().getTime(),this.getUserCustomAttributes(String.valueOf(user.getUserId())));
|
||||
userModels.add(um);
|
||||
}
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error retrieving list of group users for group Id ",groupId, e);
|
||||
}
|
||||
return userModels;
|
||||
}
|
||||
|
||||
|
||||
public List<UserModel> listUsersByGroupAndRole(String groupIdn, String roleIdn) throws UserManagementSystemException, UserRetrievalFault {
|
||||
List<User> users = new ArrayList<User>();
|
||||
List<UserModel> userModels = new ArrayList<UserModel>();
|
||||
List<User> groupUsers = null;
|
||||
long userId;
|
||||
long roleId = this.convertStringToLong(roleIdn);
|
||||
long groupId = this.convertStringToLong(groupIdn);
|
||||
try {
|
||||
groupUsers = UserLocalServiceUtil.getOrganizationUsers(groupId);
|
||||
for(User user : groupUsers){
|
||||
userId = user.getUserId();
|
||||
if(RoleLocalServiceUtil.hasUserRole(userId, roleId)){
|
||||
if(OrganizationLocalServiceUtil.hasUserOrganization(userId, groupId)){
|
||||
users.add(user);
|
||||
UserModel um = new UserModel(String.valueOf(user.getUserId()),user.getFirstName(),user.getLastName(),user.getFullName(),user.getEmailAddress(),user.getScreenName(),user.getCreateDate().getTime(),this.getUserCustomAttributes(String.valueOf(user.getUserId())));
|
||||
userModels.add(um);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error retrieving list of users by group and role", e);
|
||||
}
|
||||
return userModels;
|
||||
}
|
||||
|
||||
|
||||
public List<UserModel> listPendingUsersByGroup(String groupIdn) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault {
|
||||
List<UserModel> userModels = new ArrayList<UserModel>();
|
||||
List<MembershipRequest> memberRequests = null;
|
||||
//List<UserModel> usermodels = new HashMap<UserModel, String> ();
|
||||
long groupId = this.convertStringToLong(groupIdn);
|
||||
Organization org;
|
||||
try {
|
||||
org = OrganizationLocalServiceUtil.getOrganization(groupId);
|
||||
memberRequests = MembershipRequestLocalServiceUtil.getMembershipRequests(0, MembershipRequestLocalServiceUtil.getMembershipRequestsCount());
|
||||
}catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error retrieving pending users for group ",groupIdn, e);
|
||||
} catch (PortalException e) {
|
||||
throw new GroupRetrievalFault("Error retrieving group with group Id ",groupIdn, e);
|
||||
}
|
||||
|
||||
for(MembershipRequest memberRequest: memberRequests){
|
||||
if(memberRequest.getGroupId()==org.getGroup().getGroupId()){
|
||||
long userId = memberRequest.getUserId();
|
||||
User user = null;
|
||||
try {
|
||||
user = UserLocalServiceUtil.getUser(userId);
|
||||
} catch (PortalException e) {
|
||||
throw new UserRetrievalFault("Error retrieving user for user Id ",String.valueOf(userId), e);
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error retrieving pending users for group ",groupIdn, e);
|
||||
}
|
||||
UserModel um = new UserModel(String.valueOf(user.getUserId()),user.getFirstName(),user.getLastName(),user.getFullName(),user.getEmailAddress(),user.getScreenName(),user.getCreateDate().getTime(),this.getUserCustomAttributes(String.valueOf(user.getUserId())));
|
||||
userModels.add(um);
|
||||
}
|
||||
}
|
||||
return userModels;
|
||||
}
|
||||
|
||||
|
||||
public void updateUser(UserModel usermodel) throws UserManagementSystemException, UserRetrievalFault, UserManagementPortalException {
|
||||
try {
|
||||
User user = null;
|
||||
LiferayGroupManager gm = new LiferayGroupManager();
|
||||
long companyId = gm.getCompanyId();
|
||||
try {
|
||||
user = UserLocalServiceUtil.getUserByScreenName(companyId, usermodel.getScreenName());
|
||||
user.setEmailAddress(usermodel.getEmail());
|
||||
user.setFirstName(usermodel.getFirstname());
|
||||
user.setLastName(usermodel.getLastname());
|
||||
}catch (PortalException e) {
|
||||
throw new UserRetrievalFault("Error retrieving user by screen name ",usermodel.getScreenName(), e);
|
||||
}
|
||||
UserLocalServiceUtil.updateUser(user);
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error updating user ",usermodel.getScreenName(), e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public List<UserModel> listUnregisteredUsersByGroup(String groupIdn) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault{
|
||||
List<User> users = new ArrayList<User>();
|
||||
List<User> unregisteredUsers = new ArrayList<User>();
|
||||
List<UserModel> unregisteredUserModels = new ArrayList<UserModel>();
|
||||
|
||||
long groupId = this.convertStringToLong(groupIdn);
|
||||
Organization org;
|
||||
try {
|
||||
org = OrganizationLocalServiceUtil.getOrganization(groupId);
|
||||
users = UserLocalServiceUtil.getUsers(0, UserLocalServiceUtil.getUsersCount());
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error retrieving unregistered users for group ",groupIdn, e);
|
||||
} catch (PortalException e) {
|
||||
throw new GroupRetrievalFault("Error retrieving group with group Id ",groupIdn, e);
|
||||
}
|
||||
|
||||
for(User user : users){
|
||||
boolean isRegistered = false;
|
||||
//System.out.println(user.getFirstName());
|
||||
List<Organization> userOrgs = null;
|
||||
try {
|
||||
userOrgs = user.getOrganizations();
|
||||
} catch (PortalException e) {
|
||||
e.printStackTrace();
|
||||
} catch (SystemException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
for(Organization userOrg : userOrgs){
|
||||
if(userOrg.getOrganizationId()==org.getOrganizationId()){
|
||||
isRegistered = true;
|
||||
}
|
||||
}
|
||||
if(!isRegistered){
|
||||
unregisteredUsers.add(user);
|
||||
UserModel um = new UserModel(String.valueOf(user.getUserId()),user.getFirstName(),user.getLastName(),user.getFullName(),user.getEmailAddress(),user.getScreenName(),user.getCreateDate().getTime(),this.getUserCustomAttributes(String.valueOf(user.getUserId())));
|
||||
unregisteredUserModels.add(um);
|
||||
}
|
||||
}
|
||||
return unregisteredUserModels;
|
||||
}
|
||||
|
||||
public String getMembershipRequestComment(String userId, String groupId) throws UserManagementSystemException, GroupRetrievalFault {
|
||||
long userIdL = convertStringToLong(userId);
|
||||
long groupIdL = convertStringToLong(groupId);
|
||||
String comment = null;
|
||||
List<MembershipRequest> memberRequests = null;
|
||||
try {
|
||||
Organization org = OrganizationLocalServiceUtil.getOrganization(groupIdL);
|
||||
memberRequests = MembershipRequestLocalServiceUtil.getMembershipRequests(0, MembershipRequestLocalServiceUtil.getMembershipRequestsCount());
|
||||
for(MembershipRequest memberRequest: memberRequests){
|
||||
if(memberRequest.getGroupId()==org.getGroup().getGroupId() && memberRequest.getUserId() == userIdL){
|
||||
comment = memberRequest.getComments();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error retrieving membership request comment ", e);
|
||||
} catch (PortalException e) {
|
||||
throw new GroupRetrievalFault("Error retrieving group with group Id ",groupId, e);
|
||||
}
|
||||
return comment;
|
||||
}
|
||||
|
||||
public UserModel getUserByScreenName(String screenName) throws UserManagementSystemException, UserManagementPortalException, UserRetrievalFault {
|
||||
User user = null;
|
||||
UserModel um = null;
|
||||
LiferayGroupManager gm = new LiferayGroupManager();
|
||||
long companyId = gm.getCompanyId();
|
||||
try {
|
||||
user = UserLocalServiceUtil.getUserByScreenName(companyId, screenName);
|
||||
um = new UserModel(String.valueOf(user.getUserId()),user.getFirstName(),user.getLastName(),user.getFullName(),user.getEmailAddress(),user.getScreenName(),user.getCreateDate().getTime(),this.getUserCustomAttributes(String.valueOf(user.getUserId())));
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error retrieving user by screename ",screenName, e);
|
||||
} catch (PortalException e) {
|
||||
throw new UserManagementPortalException("Error retrieving user by screename ",screenName, e);
|
||||
}
|
||||
return um;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public HashMap<String,String> getUserCustomAttributes(String userId) throws UserManagementSystemException, UserRetrievalFault{
|
||||
|
||||
User user = null;
|
||||
HashMap<String,String> hMap = new HashMap<String,String>();
|
||||
try {
|
||||
user = UserLocalServiceUtil.getUser(Long.parseLong(userId));
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error retrieving custom attributes of user ",userId, e);
|
||||
} catch (PortalException e) {
|
||||
throw new UserRetrievalFault("Error retrieving user for user Id ",userId, e);
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
long id = ExpandoClassCodeManager.getInstance().getClassCode(User.class);
|
||||
ExpandoTable table = ExpandoDefaultTableManager.getInstance().getExpandoDefaultTable(id);
|
||||
|
||||
if (table != null)
|
||||
{
|
||||
long tableID = table.getTableId();
|
||||
List<ExpandoColumn> columns = ExpandoColumnLocalServiceUtil.getColumns(tableID);
|
||||
|
||||
for (ExpandoColumn column : columns)
|
||||
{
|
||||
ExpandoValue value = ExpandoValueLocalServiceUtil.getValue(tableID, column.getColumnId(), user.getUserId());
|
||||
String valueString = "";
|
||||
|
||||
if (value != null && value.getString() != null) valueString = value.getString();
|
||||
|
||||
//System.out.println(valueString);
|
||||
|
||||
hMap.put(column.getName(), valueString);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
return hMap;
|
||||
}
|
||||
|
||||
|
||||
public String getUserCustomAttributeByName(String userId, String attrName) throws UserManagementSystemException, UserRetrievalFault{
|
||||
User user = null;
|
||||
try {
|
||||
user = UserLocalServiceUtil.getUser(this.convertStringToLong(userId));
|
||||
}catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error retrieving custom attributes of user ",userId, e);
|
||||
} catch (PortalException e) {
|
||||
throw new UserRetrievalFault("Error retrieving user for user Id ",userId, e);
|
||||
}
|
||||
|
||||
String response = null;
|
||||
|
||||
long id = ExpandoClassCodeManager.getInstance().getClassCode(User.class);
|
||||
ExpandoTable table = ExpandoDefaultTableManager.getInstance().getExpandoDefaultTable(id);
|
||||
|
||||
|
||||
if (table != null)
|
||||
{
|
||||
long tableID = table.getTableId();
|
||||
try {
|
||||
|
||||
ExpandoColumn column = ExpandoColumnLocalServiceUtil.getColumn(tableID, attrName);
|
||||
|
||||
if (column != null)
|
||||
{
|
||||
ExpandoValue value = ExpandoValueLocalServiceUtil.getValue(tableID, column.getColumnId(), user.getUserId());
|
||||
|
||||
if (value != null) response = value.getString();
|
||||
|
||||
}
|
||||
} catch (SystemException e)
|
||||
{
|
||||
throw new UserManagementSystemException("Error retriving custom attributes",userId, e);
|
||||
} catch (PortalException e)
|
||||
{
|
||||
throw new UserRetrievalFault("Error retriving custom attributes ",userId, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
public void setUserCustomAttributeByName(String userId, String attrName, String attrValue) throws UserManagementSystemException, UserRetrievalFault, UserManagementPortalException{
|
||||
User user = null;
|
||||
boolean attrPresent = false;
|
||||
try {
|
||||
user = UserLocalServiceUtil.getUser(this.convertStringToLong(userId));
|
||||
}catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error setting custom attributes of user ",userId, e);
|
||||
} catch (PortalException e) {
|
||||
throw new UserRetrievalFault("Error retrieving user for user Id ",userId, e);
|
||||
}
|
||||
Enumeration<String> attrNamesExist = user.getExpandoBridge().getAttributeNames();
|
||||
while(attrNamesExist.hasMoreElements()){
|
||||
if(attrNamesExist.nextElement().equals(attrName)){
|
||||
attrPresent = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(attrPresent){
|
||||
user.getExpandoBridge().setAttribute(attrName, attrValue);
|
||||
}else{
|
||||
try {
|
||||
user.getExpandoBridge().addAttribute(attrName);
|
||||
user.getExpandoBridge().setAttribute(attrName, attrValue);
|
||||
} catch (PortalException e) {
|
||||
throw new UserManagementPortalException("Error setting custom attributes of user ",userId, e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setUserCustomAttributes(String userId, HashMap<String, String> hMap) throws UserManagementSystemException, UserRetrievalFault, UserManagementPortalException{
|
||||
User user = null;
|
||||
String attrName = null ;
|
||||
boolean attrPresent = false;
|
||||
try {
|
||||
user = UserLocalServiceUtil.getUser(this.convertStringToLong(userId));
|
||||
}catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error setting custom attributes of user ",userId, e);
|
||||
} catch (PortalException e) {
|
||||
throw new UserRetrievalFault("Error retrieving user for user Id ",userId, e);
|
||||
}
|
||||
|
||||
Iterator<String> customAttributesIterNew = hMap.keySet().iterator();
|
||||
Enumeration<String> attrNamesExist = user.getExpandoBridge().getAttributeNames();
|
||||
while(customAttributesIterNew.hasNext()){
|
||||
attrPresent = false;
|
||||
String customAttribute = customAttributesIterNew.next();
|
||||
while(attrNamesExist.hasMoreElements()){
|
||||
attrName = attrNamesExist.nextElement();
|
||||
if(attrName.equals(customAttribute)){
|
||||
attrPresent = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(attrPresent){
|
||||
user.getExpandoBridge().setAttribute(attrName ,hMap.get(attrName) );
|
||||
}else{
|
||||
try {
|
||||
user.getExpandoBridge().addAttribute(customAttribute);
|
||||
user.getExpandoBridge().setAttribute(customAttribute, hMap.get(customAttribute));
|
||||
} catch (PortalException e) {
|
||||
throw new UserManagementPortalException("Error setting custom attributes of user ",userId, e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void denyMembershipRequest(String userId, String groupId) throws UserManagementSystemException, GroupRetrievalFault, UserManagementPortalException {
|
||||
List<MembershipRequest> memberRequests;
|
||||
Organization org;
|
||||
try {
|
||||
memberRequests = MembershipRequestLocalServiceUtil.getMembershipRequests(0, MembershipRequestLocalServiceUtil.getMembershipRequestsCount());
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error retrieving Membership requests ", e);
|
||||
}
|
||||
try {
|
||||
org = OrganizationLocalServiceUtil.getOrganization(this.convertStringToLong(groupId));
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error deleting membership request of user ", userId , e);
|
||||
} catch (PortalException e) {
|
||||
throw new GroupRetrievalFault("No group exists with groupId ",groupId, e);
|
||||
}
|
||||
for(MembershipRequest memberRequest:memberRequests){
|
||||
if(memberRequest.getGroupId()==org.getGroup().getGroupId() && memberRequest.getUserId() == this.convertStringToLong(userId)){
|
||||
try {
|
||||
MembershipRequestLocalServiceUtil.deleteMembershipRequest(memberRequest.getMembershipRequestId());
|
||||
} catch (PortalException e) {
|
||||
throw new UserManagementPortalException("Error deleting membership request of user ", userId , e);
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException("Error deleting membership request of user ", userId , e);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
//MembershipRequestLocalServiceUtil.updateStatus(replierUserId, membershipRequestId, replyComments, statusId)
|
||||
}
|
||||
|
||||
// public List<CustomFieldModel> getUserCustomAttributes(String userId)
|
||||
// throws UserManagementSystemException, UserRetrievalFault
|
||||
// {
|
||||
// HashMap<String, String> map = internalGetUserCustomAttributes(userId);
|
||||
// List<CustomFieldModel> response = new ArrayList<CustomFieldModel>();
|
||||
//
|
||||
// if (map != null)
|
||||
// {
|
||||
// Iterator<String> keys = map.keySet().iterator();
|
||||
//
|
||||
// while (keys.hasNext())
|
||||
// {
|
||||
// String key = keys.next();
|
||||
// response.add(new CustomFieldModel(key, map.get(key)));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return response;
|
||||
// }
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,144 @@
|
|||
package org.gcube.vomanagement.usermanagement.impl.liferay;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.transform.Transformer;
|
||||
import javax.xml.transform.TransformerFactory;
|
||||
import javax.xml.transform.dom.DOMSource;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
|
||||
import org.gcube.vomanagement.usermanagement.exception.UserManagementFileNotFoundException;
|
||||
import org.gcube.vomanagement.usermanagement.exception.UserManagementIOException;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NamedNodeMap;
|
||||
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.xml.sax.InputSource;
|
||||
|
||||
public class ParseXML {
|
||||
|
||||
|
||||
private static Document convertStringToDocument (FileInputStream inputFile) throws IOException {
|
||||
|
||||
InputSource in = null;
|
||||
try {
|
||||
in = new InputSource (inputFile);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
|
||||
Document doc = null;
|
||||
try {
|
||||
doc = dfactory.newDocumentBuilder().parse(in);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
inputFile.close();
|
||||
return doc;
|
||||
}
|
||||
|
||||
private static String document2String(Document document) throws Exception {
|
||||
ByteArrayOutputStream baos;
|
||||
Transformer t;
|
||||
|
||||
baos = new ByteArrayOutputStream();
|
||||
t = TransformerFactory.newInstance().newTransformer();
|
||||
t.transform(new DOMSource(document), new StreamResult(baos));
|
||||
return baos.toString();
|
||||
|
||||
}
|
||||
|
||||
protected static HashMap<String,String> getRoles(String groupType) throws UserManagementFileNotFoundException, UserManagementIOException {
|
||||
HashMap<String,String> hMap = new HashMap<String,String>();
|
||||
File file = new File (Settings.getInstance().getProperty("sharedDir")+ File.separator + "roles-config.xml");
|
||||
|
||||
Document dom = null;
|
||||
try {
|
||||
FileInputStream in = new FileInputStream(file);
|
||||
dom = convertStringToDocument(in);
|
||||
in.close();
|
||||
} catch (FileNotFoundException e) {
|
||||
throw new UserManagementFileNotFoundException("Roles config file not found. Check if the config file exists", e);
|
||||
} catch (IOException e) {
|
||||
throw new UserManagementIOException("Error writing to the roles config file", e);
|
||||
}
|
||||
Element elem = dom.getDocumentElement();
|
||||
|
||||
NodeList nl = elem.getElementsByTagName(groupType);
|
||||
for(int i=0;i<nl.getLength();i++){
|
||||
|
||||
Element el = (Element)nl.item(i);
|
||||
|
||||
NodeList nl2 = el.getElementsByTagName("role");
|
||||
for(int j=0;j<nl2.getLength();j++){
|
||||
Element el2 = (Element)nl2.item(j);
|
||||
NamedNodeMap map = el2.getAttributes();
|
||||
hMap.put(map.getNamedItem("name").getNodeValue().toString(), map.getNamedItem("description").getNodeValue().toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return hMap;
|
||||
}
|
||||
|
||||
protected static void updateRoles(HashMap<String, String> rolesMap, String groupType) throws UserManagementIOException, UserManagementFileNotFoundException{
|
||||
File file = new File (Settings.getInstance().getProperty("sharedDir")+ File.separator + "roles-config.xml");
|
||||
Document dom;
|
||||
Iterator<String> keyIter = rolesMap.keySet().iterator();
|
||||
try {
|
||||
dom = convertStringToDocument(new FileInputStream(file));
|
||||
} catch (FileNotFoundException e) {
|
||||
throw new UserManagementFileNotFoundException("Roles config file not found. Check if the config file exists", e);
|
||||
} catch (IOException e) {
|
||||
throw new UserManagementIOException("Error writing to the roles config file", e);
|
||||
}
|
||||
Element elem = dom.getDocumentElement();
|
||||
NodeList nl = elem.getElementsByTagName(groupType);
|
||||
for(int i=0;i<nl.getLength();i++){
|
||||
|
||||
Element el = (Element)nl.item(i);
|
||||
NodeList nl2 = el.getElementsByTagName("role");
|
||||
while(nl2.getLength()>0){
|
||||
Element el2 = (Element)nl2.item(nl2.getLength()-1);
|
||||
el.removeChild(el2);
|
||||
}
|
||||
|
||||
while(keyIter.hasNext()){
|
||||
Element role = dom.createElement("role");
|
||||
|
||||
Element roleNode = (Element)el.appendChild(role);
|
||||
String roleName = keyIter.next();
|
||||
roleNode.setAttribute("name", roleName);
|
||||
|
||||
roleNode.setAttribute("description", rolesMap.get(roleName));
|
||||
}
|
||||
}
|
||||
FileWriter out = null;
|
||||
try {
|
||||
out = new FileWriter(file);
|
||||
} catch (IOException e) {
|
||||
throw new UserManagementIOException("Error writing to the roles config file", e);
|
||||
}
|
||||
try {
|
||||
out.write(document2String(dom));
|
||||
out.flush();
|
||||
out.close();
|
||||
} catch (IOException e) {
|
||||
throw new UserManagementIOException("Error writing to the roles config file", e);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
package org.gcube.vomanagement.usermanagement.impl.liferay;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class Settings {
|
||||
|
||||
static Properties props = new Properties();
|
||||
static Settings settings = null;
|
||||
|
||||
Settings()
|
||||
{
|
||||
try
|
||||
{
|
||||
props.load(Settings.class.getResourceAsStream("/etc/settings.properties"));
|
||||
|
||||
}
|
||||
catch (FileNotFoundException e)
|
||||
{
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static Settings getInstance()
|
||||
{
|
||||
if (settings == null)
|
||||
settings = new Settings();
|
||||
return settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the props
|
||||
*/
|
||||
public String getProperty(String key) {
|
||||
String value = props.getProperty(key);
|
||||
if(value.contains("${"))
|
||||
{
|
||||
int start = 0;
|
||||
int i;
|
||||
while((i= value.indexOf("${", start)) != -1)
|
||||
{
|
||||
start = value.indexOf("}", i) +1;
|
||||
String reg = value.substring(i, start);
|
||||
//System.out.println(reg);
|
||||
//System.out.println(reg.substring(2, reg.length() -1));
|
||||
value = value.replace(reg, (System.getProperty(reg.substring(2, reg.length() -1)) != null)?System.getProperty(reg.substring(2, reg.length() -1)):"");
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package org.gcube.vomanagement.usermanagement.impl.liferay.utils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.liferay.portal.service.ClassNameLocalServiceUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
* Utility class to load the classes of custom field
|
||||
*
|
||||
* @author Ciro Formisano
|
||||
*
|
||||
*/
|
||||
public class ExpandoClassCodeManager
|
||||
{
|
||||
private Map<String, Long> map;
|
||||
|
||||
private static ExpandoClassCodeManager instance;
|
||||
|
||||
public static ExpandoClassCodeManager getInstance ()
|
||||
{
|
||||
if (instance == null) instance = new ExpandoClassCodeManager();
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
public ExpandoClassCodeManager()
|
||||
{
|
||||
this.map = new HashMap<String, Long> ();
|
||||
}
|
||||
|
||||
public long getClassCode (Class<?> type)
|
||||
{
|
||||
String className = type.getName();
|
||||
Long code = this.map.get(className);
|
||||
|
||||
if (code == null)
|
||||
{
|
||||
code = ClassNameLocalServiceUtil.getClassNameId(type);
|
||||
this.map.put(className, code);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
package org.gcube.vomanagement.usermanagement.impl.liferay.utils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.liferay.portlet.expando.model.ExpandoTable;
|
||||
import com.liferay.portlet.expando.service.ExpandoTableLocalServiceUtil;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Utility class to load the table of custom fields
|
||||
*
|
||||
* @author Ciro Formisano
|
||||
*
|
||||
*/
|
||||
public class ExpandoDefaultTableManager
|
||||
{
|
||||
|
||||
private Map<Long, ExpandoTable> tableMap;
|
||||
private final String DEFAULT_TABLE_NAME = "DEFAULT_TABLE";
|
||||
|
||||
private static ExpandoDefaultTableManager instance;
|
||||
|
||||
public static ExpandoDefaultTableManager getInstance ()
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
instance = new ExpandoDefaultTableManager();
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
public ExpandoDefaultTableManager()
|
||||
{
|
||||
this.tableMap = new HashMap<Long, ExpandoTable> ();
|
||||
}
|
||||
|
||||
public ExpandoTable getExpandoDefaultTable (long classId)
|
||||
{
|
||||
ExpandoTable response = this.tableMap.get(classId);
|
||||
|
||||
if (response == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
response = getExpandoDefaultTableFromDatabase(classId);
|
||||
|
||||
if (response != null) this.tableMap.put(classId, response);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
private ExpandoTable getExpandoDefaultTableFromDatabase (long classId) throws Exception
|
||||
{
|
||||
int numberOfTables = ExpandoTableLocalServiceUtil.getExpandoTablesCount();
|
||||
List<ExpandoTable> tables = ExpandoTableLocalServiceUtil .getExpandoTables(0, numberOfTables);
|
||||
ExpandoTable response = null;
|
||||
|
||||
if (tables != null)
|
||||
{
|
||||
Iterator<ExpandoTable> tableIterator = tables.iterator();
|
||||
|
||||
|
||||
while (tableIterator.hasNext() && response == null)
|
||||
{
|
||||
ExpandoTable currentTable = tableIterator.next();
|
||||
|
||||
if (currentTable.getName().equals(DEFAULT_TABLE_NAME) && currentTable.getClassNameId() == classId) response = currentTable;
|
||||
}
|
||||
}
|
||||
|
||||
return response;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,129 @@
|
|||
package org.gcube.vomanagement.usermanagement.impl.voms;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.vomanagement.usermanagement.GroupManager;
|
||||
import org.gcube.vomanagement.usermanagement.model.GroupModel;
|
||||
import org.gcube.vomanagement.usermanagement.model.RoleModel;
|
||||
|
||||
/**
|
||||
* VOMS plugin for the GroupManager interface.
|
||||
*
|
||||
* @author Giulio Galiero
|
||||
*
|
||||
*/
|
||||
public class VOMSGroupManager implements GroupManager {
|
||||
|
||||
public void assignSubGrouptoParentGroup(String subGroupId,
|
||||
String parentGroupId) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public GroupModel createRootVO(String RootVOName, String userId, String description) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public GroupModel createVO(String VOName, String rootVOGroupId,
|
||||
String userId, String description) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public GroupModel createVRE(String VREName, String VOGroupId, String userId, String description) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public void deleteGroup(String groupId) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public void dismissSubGroupFromParentGroup(String subGroupId,
|
||||
String parentGroupId) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public GroupModel getGroup(String groupId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getGroupId(String groupName) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public long getGroupParentId(String groupId) {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
public GroupModel getRootVO() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getRootVOName() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getScope(String groupId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public Boolean isRootVO(String groupId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public Boolean isVO(String groupId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public Boolean isVRE(String groupId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<GroupModel> listGroups() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public HashMap<String, List<RoleModel>> listGroupsAndRolesByUser(
|
||||
String userId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<GroupModel> listGroupsByUser(String userId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<GroupModel> listPendingGroupsByUser(String userId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<GroupModel> listSubGroupsByGroup(String groupId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public void updateGroup(GroupModel group) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,135 @@
|
|||
package org.gcube.vomanagement.usermanagement.impl.voms;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault;
|
||||
import org.gcube.vomanagement.usermanagement.exception.RoleRetrievalFault;
|
||||
import org.gcube.vomanagement.usermanagement.exception.UserManagementFileNotFoundException;
|
||||
import org.gcube.vomanagement.usermanagement.exception.UserManagementIOException;
|
||||
import org.gcube.vomanagement.usermanagement.exception.UserManagementPortalException;
|
||||
import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException;
|
||||
import org.gcube.vomanagement.usermanagement.exception.UserRetrievalFault;
|
||||
import org.gcube.vomanagement.usermanagement.model.RoleModel;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* VOMS plugin for the RoleManager interface.
|
||||
*
|
||||
* @author Giulio Galiero
|
||||
*
|
||||
*/
|
||||
public class VOMSRoleManager implements
|
||||
org.gcube.vomanagement.usermanagement.RoleManager {
|
||||
|
||||
public void assignRoleToUser(String groupId, String roleId, String userId)
|
||||
throws UserManagementSystemException, UserRetrievalFault,
|
||||
GroupRetrievalFault, RoleRetrievalFault {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public void createRole(String groupName)
|
||||
throws UserManagementSystemException, GroupRetrievalFault,
|
||||
RoleRetrievalFault, UserManagementPortalException,
|
||||
UserManagementFileNotFoundException, UserManagementIOException {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public boolean createRole(String roleName, String roleDescription,
|
||||
String groupName) throws UserManagementSystemException,
|
||||
RoleRetrievalFault, GroupRetrievalFault,
|
||||
UserManagementPortalException {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
public void deleteRole(String roleName, String groupName)
|
||||
throws UserManagementSystemException, RoleRetrievalFault {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public void dismissRoleFromUser(String groupId, String roleId, String userId)
|
||||
throws UserManagementSystemException, UserRetrievalFault,
|
||||
GroupRetrievalFault, RoleRetrievalFault {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public RoleModel getRole(String roleId)
|
||||
throws UserManagementSystemException, RoleRetrievalFault {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getRoleId(String roleName, String groupName)
|
||||
throws UserManagementSystemException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public HashMap<String, String> listAllowedRoles(String groupName)
|
||||
throws UserManagementSystemException, GroupRetrievalFault,
|
||||
UserManagementFileNotFoundException, UserManagementIOException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public List<String> listRoles() throws UserManagementSystemException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<RoleModel> listRolesByGroup(String groupId)
|
||||
throws UserManagementSystemException, GroupRetrievalFault {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<RoleModel> listRolesByUser(String userId)
|
||||
throws UserManagementSystemException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<RoleModel> listRolesByUserAndGroup(String groupId, String userId)
|
||||
throws UserManagementSystemException, GroupRetrievalFault,
|
||||
UserRetrievalFault {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public void updatePredefinedRoles(HashMap<String, String> rolesMap,
|
||||
String groupType) throws UserManagementIOException,
|
||||
UserManagementFileNotFoundException {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public void updateRole(String initialRoleName, String newRoleName,
|
||||
String roleDescription, String groupName)
|
||||
throws UserManagementSystemException, RoleRetrievalFault,
|
||||
NumberFormatException, UserManagementFileNotFoundException,
|
||||
UserManagementIOException, GroupRetrievalFault,
|
||||
UserManagementPortalException {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public List<RoleModel> listAllRoles() throws UserManagementSystemException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isAdmin(String userId) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,155 @@
|
|||
package org.gcube.vomanagement.usermanagement.impl.voms;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.vomanagement.usermanagement.UserManager;
|
||||
import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault;
|
||||
import org.gcube.vomanagement.usermanagement.exception.UserManagementPortalException;
|
||||
import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException;
|
||||
import org.gcube.vomanagement.usermanagement.model.GroupModel;
|
||||
import org.gcube.vomanagement.usermanagement.model.RoleModel;
|
||||
import org.gcube.vomanagement.usermanagement.model.UserModel;
|
||||
|
||||
/**
|
||||
* VOMS plugin for the UserManager interface.
|
||||
*
|
||||
* @author Giulio Galiero
|
||||
*
|
||||
*/
|
||||
public class VOMSUserManager implements UserManager {
|
||||
|
||||
public void assignUserToGroup(String groupName, String userId) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public void createUser(UserModel usermodel) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public void deleteUser(String userId) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public void dismissUserFromGroup(String groupName, String userId) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public UserModel getUser(String userId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<UserModel> listPendingUsersByGroup(String groupId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<UserModel> listUsers() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public HashMap<UserModel, List<GroupModel>> listUsersAndGroupsByRole(
|
||||
String roleName) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public HashMap<UserModel, List<RoleModel>> listUsersAndRolesByGroup(
|
||||
String groupName) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<UserModel> listUsersByGroup(String groupId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<UserModel> listUsersByGroupAndRole(String groupName,
|
||||
String roleName) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public void updateUser(UserModel user) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public List<UserModel> listUnregisteredUsersByGroup(String groupId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public void requestMembership(String userId, String groupId, String comment) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public String getUserId(String userName) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<UserModel> getMembershipRequests(String groupId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getMembershipRequestComment(String userId, String groupId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public UserModel getUserByScreenName(String screenName) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public HashMap<String, String> getCustomAttributes(String userId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getUserCustomAttributeByName(String userId, String attrName)
|
||||
throws UserManagementSystemException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public HashMap<String, String> getUserCustomAttributes(String userId)
|
||||
throws UserManagementSystemException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setUserCustomAttributeByName(String userId, String attrName,
|
||||
String attrValue) throws UserManagementSystemException,
|
||||
UserManagementPortalException {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public void setUserCustomAttributes(String userId,
|
||||
HashMap<String, String> hMap) throws UserManagementSystemException,
|
||||
UserManagementPortalException {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public void denyMembershipRequest(String userId, String groupId)
|
||||
throws UserManagementSystemException, GroupRetrievalFault,
|
||||
UserManagementPortalException {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
package org.gcube.vomanagement.usermanagement.model;
|
||||
|
||||
|
||||
public class GroupModel {
|
||||
|
||||
String groupId;
|
||||
String parentGroupId;
|
||||
String groupName;
|
||||
String description;
|
||||
long logoId;
|
||||
|
||||
public GroupModel() {
|
||||
this("","","","",0L);
|
||||
}
|
||||
|
||||
public GroupModel(String groupId,String parentGroupId, String groupName, String description, long logoId){
|
||||
this.groupId = groupId;
|
||||
this.parentGroupId = parentGroupId;
|
||||
this.groupName = groupName;
|
||||
this.description = description;
|
||||
this.logoId = logoId;
|
||||
}
|
||||
|
||||
public String getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
|
||||
public void setGroupId(String groupId) {
|
||||
this.groupId = groupId;
|
||||
}
|
||||
|
||||
public String getParentGroupId() {
|
||||
return parentGroupId;
|
||||
}
|
||||
|
||||
public void setParentGroupId(String parentGroupId) {
|
||||
this.parentGroupId = parentGroupId;
|
||||
}
|
||||
|
||||
public String getGroupName() {
|
||||
return groupName;
|
||||
}
|
||||
|
||||
public void setGroupName(String groupName) {
|
||||
this.groupName = groupName;
|
||||
}
|
||||
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public long getLogoId() {
|
||||
return logoId;
|
||||
}
|
||||
|
||||
public void setLogoId(long logoId) {
|
||||
this.logoId = logoId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
package org.gcube.vomanagement.usermanagement.model;
|
||||
|
||||
public class RoleModel {
|
||||
|
||||
String roleName;
|
||||
String roleId;
|
||||
String description;
|
||||
String completeName;
|
||||
|
||||
|
||||
public RoleModel(){
|
||||
|
||||
}
|
||||
public RoleModel(String roleName,String roleId, String description){
|
||||
this.roleName = roleName;
|
||||
this.roleId = roleId;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getRoleName() {
|
||||
return roleName;
|
||||
}
|
||||
public void setRoleName(String roleName) {
|
||||
this.roleName = roleName;
|
||||
}
|
||||
public String getRoleId() {
|
||||
return roleId;
|
||||
}
|
||||
public void setRoleId(String roleId) {
|
||||
this.roleId = roleId;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
public String getCompleteName() {
|
||||
return completeName;
|
||||
}
|
||||
public void setCompleteName(String completeName) {
|
||||
this.completeName = completeName;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
package org.gcube.vomanagement.usermanagement.model;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
|
||||
/**
|
||||
* Liferay User Object Model
|
||||
*
|
||||
*/
|
||||
public class UserModel{
|
||||
|
||||
private String fullname;
|
||||
|
||||
private String email;
|
||||
|
||||
private String screenName;
|
||||
|
||||
private String firstname;
|
||||
|
||||
private String lastname;
|
||||
|
||||
private String userId;
|
||||
|
||||
private long registrationDate;
|
||||
|
||||
private HashMap<String,String> customAttrsMap;
|
||||
|
||||
public HashMap<String, String> getCustomAttrsMap() {
|
||||
return customAttrsMap;
|
||||
}
|
||||
public void setCustomAttrsMap(HashMap<String, String> customAttrsMap) {
|
||||
this.customAttrsMap = customAttrsMap;
|
||||
}
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
public void setUserId(String userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
public String getFirstname() {
|
||||
return firstname;
|
||||
}
|
||||
public void setFirstname(String firstname) {
|
||||
this.firstname = firstname;
|
||||
}
|
||||
public String getLastname() {
|
||||
return lastname;
|
||||
}
|
||||
public void setLastname(String lastname) {
|
||||
this.lastname = lastname;
|
||||
}
|
||||
|
||||
|
||||
public String getFullname() {
|
||||
return fullname;
|
||||
}
|
||||
public void setFullname(String fullname) {
|
||||
this.fullname = fullname;
|
||||
}
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
public String getScreenName() {
|
||||
return screenName;
|
||||
}
|
||||
public void setScreenName(String screenName) {
|
||||
this.screenName = screenName;
|
||||
}
|
||||
public UserModel() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public long getRegistrationDate() {
|
||||
return registrationDate;
|
||||
}
|
||||
public void setRegistrationDate(long registrationDate) {
|
||||
this.registrationDate = registrationDate;
|
||||
}
|
||||
public UserModel(String userId, String firstname, String lastname, String fullname,String email,String screenname,long registrationDate,HashMap<String,String> customAttrsMap) {
|
||||
this.userId = userId;
|
||||
this.firstname=firstname;
|
||||
this.lastname=lastname;
|
||||
this.fullname= fullname;
|
||||
this.email = email;
|
||||
this.screenName = screenname;
|
||||
this.customAttrsMap = customAttrsMap;
|
||||
this.registrationDate = registrationDate;
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
sharedDir=${catalina.home}/shared/d4s
|
Loading…
Reference in New Issue