started implementing
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/vo-management/usermanagement-core@122874 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
72b7fd947e
commit
b0b7c1c5ac
|
@ -24,6 +24,12 @@
|
|||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
|
|
13
.project
13
.project
|
@ -5,6 +5,11 @@
|
|||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.wst.common.project.facet.core.builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
|
@ -20,10 +25,18 @@
|
|||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.wst.validation.validationbuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
|
||||
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.maven.ide.eclipse.maven2Nature</nature>
|
||||
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
|
||||
<wb-module deploy-name="usermanagement-core">
|
||||
<wb-resource deploy-path="/" source-path="/src/main/java"/>
|
||||
<wb-resource deploy-path="/" source-path="/src/main/resources"/>
|
||||
</wb-module>
|
||||
</project-modules>
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<faceted-project>
|
||||
<installed facet="java" version="1.6"/>
|
||||
<installed facet="jst.utility" version="1.0"/>
|
||||
</faceted-project>
|
33
pom.xml
33
pom.xml
|
@ -10,7 +10,7 @@
|
|||
|
||||
<groupId>org.gcube.dvos</groupId>
|
||||
<artifactId>usermanagement-core</artifactId>
|
||||
<version>1.4.1-SNAPSHOT</version>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>User Management API</name>
|
||||
|
@ -24,18 +24,16 @@
|
|||
</scm>
|
||||
<properties>
|
||||
<distroDirectory>distro</distroDirectory>
|
||||
<maven.compiler.source>1.6</maven.compiler.source>
|
||||
<maven.compiler.target>1.6</maven.compiler.target>
|
||||
|
||||
<maven.compiler.source>1.7</maven.compiler.source>
|
||||
<maven.compiler.target>1.7</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.liferay.portal</groupId>
|
||||
<artifactId>portal-service</artifactId>
|
||||
<version>6.0.6</version>
|
||||
<version>6.2.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.portlet</groupId>
|
||||
|
@ -43,13 +41,34 @@
|
|||
<version>2.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
<version>2.4</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet.jsp</groupId>
|
||||
<artifactId>jsp-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>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
<version>1.6.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>1.6.4</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<resources>
|
||||
|
|
|
@ -14,56 +14,82 @@ import org.gcube.vomanagement.usermanagement.model.UserModel;
|
|||
|
||||
|
||||
/**
|
||||
* This interface defines the class that manages the users.
|
||||
*
|
||||
* @author Giulio Galiero
|
||||
*
|
||||
* @author Massimiliano Assante, CNR-ISTI
|
||||
*
|
||||
*/
|
||||
public interface UserManager {
|
||||
public interface UserManager {
|
||||
/**
|
||||
*
|
||||
* @param username the username of the user you want to get
|
||||
* @return the instance of the user
|
||||
* @throws UserManagementSystemException
|
||||
* @throws UserRetrievalFault
|
||||
*/
|
||||
UserModel getUserByUsername(String username) throws UserManagementSystemException, UserRetrievalFault ;
|
||||
/**
|
||||
*
|
||||
* @param username the email of the user you want to get
|
||||
* @return the instance of the user
|
||||
* @throws UserManagementSystemException
|
||||
* @throws UserRetrievalFault
|
||||
*/
|
||||
UserModel getUserByEmail(String email) throws UserManagementSystemException, UserRetrievalFault;
|
||||
/**
|
||||
*
|
||||
* @return a list of all portal active users no matter if the belong or not to a VRE, if a user is deactived is not returned
|
||||
* @throws UserManagementSystemException
|
||||
*/
|
||||
List<UserModel> listUsers() throws UserManagementSystemException;
|
||||
/**
|
||||
*
|
||||
* @param groupId the LR groupId
|
||||
* @return
|
||||
* @throws UserManagementSystemException
|
||||
* @throws GroupRetrievalFault
|
||||
* @throws UserRetrievalFault
|
||||
*/
|
||||
List<UserModel> listUsersByGroup(long groupId) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault;
|
||||
/**
|
||||
*
|
||||
* @param the name of the VO or VRE (e.g. devVRE, or gcube etc.)
|
||||
* @return
|
||||
* @throws UserManagementSystemException
|
||||
* @throws GroupRetrievalFault
|
||||
* @throws UserRetrievalFault
|
||||
*/
|
||||
List<UserModel> listUsersByGroupName(String name) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault;
|
||||
|
||||
public void createUser(UserModel usermodel) throws UserManagementSystemException, UserRetrievalFault;
|
||||
List<UserModel> listPendingUsersByGroup(String groupId) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault;
|
||||
|
||||
public void deleteUser(String userId) throws UserManagementSystemException, UserRetrievalFault;
|
||||
String getMembershipRequestComment(String userId, String groupId) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault;
|
||||
|
||||
public void updateUser(UserModel user) throws UserRetrievalFault, UserManagementSystemException, UserManagementPortalException;
|
||||
HashMap<UserModel, List<RoleModel>> listUsersAndRolesByGroup(String groupId) throws GroupRetrievalFault, UserManagementSystemException, UserRetrievalFault ;
|
||||
|
||||
public UserModel getUser(String userId) throws UserManagementSystemException, UserRetrievalFault ;
|
||||
HashMap<UserModel, List<GroupModel>> listUsersAndGroupsByRole(String roleId) throws UserManagementSystemException, RoleRetrievalFault, UserRetrievalFault ;
|
||||
|
||||
public List<UserModel> listUsers() throws UserManagementSystemException, UserRetrievalFault;
|
||||
List<UserModel> listUsersByGroupAndRole(String groupId, String roleId) throws UserManagementSystemException, RoleRetrievalFault, GroupRetrievalFault, UserRetrievalFault;
|
||||
|
||||
public List<UserModel> listUsersByGroup(String groupId) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault;
|
||||
void assignUserToGroup(String groupId, String userId) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault, UserManagementPortalException;
|
||||
|
||||
public List<UserModel> listPendingUsersByGroup(String groupId) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault;
|
||||
void dismissUserFromGroup(String groupId, String userId) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault;
|
||||
|
||||
public String getMembershipRequestComment(String userId, String groupId) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault;
|
||||
void requestMembership(String userId, String groupId, String comment) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault;
|
||||
|
||||
public HashMap<UserModel, List<RoleModel>> listUsersAndRolesByGroup(String groupId) throws GroupRetrievalFault, UserManagementSystemException, UserRetrievalFault ;
|
||||
List<UserModel> listUnregisteredUsersByGroup(String groupId) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault;
|
||||
|
||||
public HashMap<UserModel, List<GroupModel>> listUsersAndGroupsByRole(String roleId) throws UserManagementSystemException, RoleRetrievalFault, UserRetrievalFault ;
|
||||
Long getUserId(String screenName) throws UserManagementSystemException;
|
||||
|
||||
public List<UserModel> listUsersByGroupAndRole(String groupId, String roleId) throws UserManagementSystemException, RoleRetrievalFault, GroupRetrievalFault, UserRetrievalFault;
|
||||
List<UserModel> getMembershipRequests(String groupId) throws UserManagementSystemException,GroupRetrievalFault, UserRetrievalFault;
|
||||
|
||||
public void assignUserToGroup(String groupId, String userId) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault, UserManagementPortalException;
|
||||
HashMap<String, String> getUserCustomAttributes(String userId) throws UserManagementSystemException, UserRetrievalFault;
|
||||
|
||||
public void dismissUserFromGroup(String groupId, String userId) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault;
|
||||
void setUserCustomAttributes(String userId, HashMap<String,String> hMap) throws UserManagementSystemException, UserRetrievalFault, UserManagementPortalException;
|
||||
|
||||
public void requestMembership(String userId, String groupId, String comment) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault;
|
||||
String getUserCustomAttributeByName(String userId, String attrName)throws UserManagementSystemException, UserRetrievalFault;
|
||||
|
||||
public List<UserModel> listUnregisteredUsersByGroup(String groupId) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault;
|
||||
void setUserCustomAttributeByName(String userId, String attrName, String attrValue) throws UserManagementSystemException, UserRetrievalFault, UserManagementPortalException;
|
||||
|
||||
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;
|
||||
void denyMembershipRequest(String userId,String groupId)throws UserManagementSystemException, GroupRetrievalFault, UserManagementPortalException;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,301 @@
|
|||
package org.gcube.vomanagement.usermanagement.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
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.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.Email;
|
||||
import org.gcube.vomanagement.usermanagement.model.GroupModel;
|
||||
import org.gcube.vomanagement.usermanagement.model.RoleModel;
|
||||
import org.gcube.vomanagement.usermanagement.model.UserModel;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
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.EmailAddress;
|
||||
import com.liferay.portal.model.Group;
|
||||
import com.liferay.portal.model.User;
|
||||
import com.liferay.portal.service.CompanyLocalServiceUtil;
|
||||
import com.liferay.portal.service.GroupLocalServiceUtil;
|
||||
import com.liferay.portal.service.UserLocalServiceUtil;
|
||||
import com.liferay.portlet.sites.util.SitesUtil;
|
||||
|
||||
public class LiferayUserManager implements UserManager {
|
||||
/**
|
||||
* logger
|
||||
*/
|
||||
private static final Logger _log = LoggerFactory.getLogger(LiferayUserManager.class);
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static final String DEFAULT_COMPANY_WEB_ID = "liferay.com";
|
||||
|
||||
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) {
|
||||
_log.info("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;
|
||||
}
|
||||
|
||||
private static UserModel mapLRUser(User u) throws PortalException, SystemException {
|
||||
if (u != null) {
|
||||
List<Email> emails = new ArrayList<Email>();
|
||||
for (EmailAddress e : u.getEmailAddresses()) {
|
||||
emails.add(new Email(e.getAddress(), e.getType().toString(), e.isPrimary()));
|
||||
}
|
||||
return new UserModel(
|
||||
u.getUserId(),
|
||||
u.getScreenName(),
|
||||
u.getEmailAddress(),
|
||||
u.getFirstName(),
|
||||
u.getMiddleName(),
|
||||
u.getLastName(),
|
||||
u.getFullName(),
|
||||
u.getCreateDate().getTime(),
|
||||
u.getPortraitId()+"",
|
||||
u.isMale(),
|
||||
u.getJobTitle(),
|
||||
emails);
|
||||
}
|
||||
else
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public UserModel getUserByUsername(String username) throws UserManagementSystemException, UserRetrievalFault {
|
||||
User toGet = null;
|
||||
UserModel toReturn = null;
|
||||
try {
|
||||
toGet = UserLocalServiceUtil.getUserByScreenName(getCompany().getCompanyId(), username);
|
||||
toReturn = mapLRUser(toGet);
|
||||
} catch (PortalException e) {
|
||||
throw new UserRetrievalFault("User not existing", e);
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException(e.getMessage(), e);
|
||||
}
|
||||
return toReturn;
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public UserModel getUserByEmail(String emailAddress) throws UserManagementSystemException, UserRetrievalFault {
|
||||
User toGet = null;
|
||||
UserModel toReturn = null;
|
||||
try {
|
||||
toGet = UserLocalServiceUtil.getUserByEmailAddress(getCompany().getCompanyId(), emailAddress);
|
||||
toReturn = mapLRUser(toGet);
|
||||
} catch (PortalException e) {
|
||||
throw new UserRetrievalFault("User not existing", e);
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException(e.getMessage(), e);
|
||||
}
|
||||
return toReturn;
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<UserModel> listUsers() throws UserManagementSystemException {
|
||||
List<UserModel> toReturn = new ArrayList<UserModel>();
|
||||
try {
|
||||
List<User> lrUsers = UserLocalServiceUtil.getUsers(0, UserLocalServiceUtil.getUsersCount());
|
||||
for (User user : lrUsers) {
|
||||
if (user.isActive())
|
||||
toReturn.add(mapLRUser(user));
|
||||
}
|
||||
} catch (SystemException e) {
|
||||
throw new UserManagementSystemException(e.getMessage(), e);
|
||||
} catch (PortalException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return toReturn;
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<UserModel> listUsersByGroup(long groupId) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault {
|
||||
List<UserModel> toReturn = new ArrayList<UserModel>();
|
||||
try {
|
||||
for (User user : UserLocalServiceUtil.getGroupUsers(groupId)) {
|
||||
if (user.isActive())
|
||||
toReturn.add(mapLRUser(user));
|
||||
}
|
||||
} catch (PortalException e) {
|
||||
e.printStackTrace();
|
||||
} catch (SystemException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return toReturn;
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<UserModel> listUsersByGroupName(String name) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault {
|
||||
List<UserModel> toReturn = new ArrayList<UserModel>();
|
||||
try {
|
||||
Group g = (GroupLocalServiceUtil.getGroup(getCompany().getCompanyId(), name));
|
||||
for (User user : UserLocalServiceUtil.getGroupUsers(g.getGroupId())) {
|
||||
if (user.isActive())
|
||||
toReturn.add(mapLRUser(user));
|
||||
}
|
||||
} catch (PortalException e) {
|
||||
e.printStackTrace();
|
||||
} catch (SystemException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserModel> listPendingUsersByGroup(String groupId)
|
||||
throws UserManagementSystemException, GroupRetrievalFault,
|
||||
UserRetrievalFault {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMembershipRequestComment(String userId, String groupId)
|
||||
throws UserManagementSystemException, GroupRetrievalFault,
|
||||
UserRetrievalFault {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<UserModel, List<RoleModel>> listUsersAndRolesByGroup(
|
||||
String groupId) throws GroupRetrievalFault,
|
||||
UserManagementSystemException, UserRetrievalFault {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<UserModel, List<GroupModel>> listUsersAndGroupsByRole(
|
||||
String roleId) throws UserManagementSystemException,
|
||||
RoleRetrievalFault, UserRetrievalFault {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserModel> listUsersByGroupAndRole(String groupId, String roleId)
|
||||
throws UserManagementSystemException, RoleRetrievalFault,
|
||||
GroupRetrievalFault, UserRetrievalFault {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void assignUserToGroup(String groupId, String userId)
|
||||
throws UserManagementSystemException, GroupRetrievalFault,
|
||||
UserRetrievalFault, UserManagementPortalException {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dismissUserFromGroup(String groupId, String userId)
|
||||
throws UserManagementSystemException, GroupRetrievalFault,
|
||||
UserRetrievalFault {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestMembership(String userId, String groupId, String comment)
|
||||
throws UserManagementSystemException, GroupRetrievalFault,
|
||||
UserRetrievalFault {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserModel> listUnregisteredUsersByGroup(String groupId)
|
||||
throws UserManagementSystemException, GroupRetrievalFault,
|
||||
UserRetrievalFault {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getUserId(String screenName)
|
||||
throws UserManagementSystemException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserModel> getMembershipRequests(String groupId)
|
||||
throws UserManagementSystemException, GroupRetrievalFault,
|
||||
UserRetrievalFault {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<String, String> getUserCustomAttributes(String userId)
|
||||
throws UserManagementSystemException, UserRetrievalFault {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUserCustomAttributes(String userId,
|
||||
HashMap<String, String> hMap) throws UserManagementSystemException,
|
||||
UserRetrievalFault, UserManagementPortalException {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUserCustomAttributeByName(String userId, String attrName)
|
||||
throws UserManagementSystemException, UserRetrievalFault {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUserCustomAttributeByName(String userId, String attrName,
|
||||
String attrValue) throws UserManagementSystemException,
|
||||
UserRetrievalFault, UserManagementPortalException {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void denyMembershipRequest(String userId, String groupId)
|
||||
throws UserManagementSystemException, GroupRetrievalFault,
|
||||
UserManagementPortalException {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,509 +0,0 @@
|
|||
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;
|
||||
}
|
||||
}
|
|
@ -1,788 +0,0 @@
|
|||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,969 +0,0 @@
|
|||
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;
|
||||
// }
|
||||
|
||||
|
||||
}
|
|
@ -1,144 +0,0 @@
|
|||
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();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
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;
|
||||
}
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
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;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,86 +0,0 @@
|
|||
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;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,129 +0,0 @@
|
|||
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
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,135 +0,0 @@
|
|||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,155 +0,0 @@
|
|||
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,45 @@
|
|||
package org.gcube.vomanagement.usermanagement.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class Email implements Serializable {
|
||||
private String email;
|
||||
private String type;
|
||||
boolean primary;
|
||||
|
||||
public Email() {
|
||||
super();
|
||||
}
|
||||
public Email(String email, String type, boolean primary) {
|
||||
super();
|
||||
this.email = email;
|
||||
this.type = type;
|
||||
this.primary = primary;
|
||||
}
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
public boolean isPrimary() {
|
||||
return primary;
|
||||
}
|
||||
public void setPrimary(boolean primary) {
|
||||
this.primary = primary;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Email [email=" + email + ", type=" + type + ", primary="
|
||||
+ primary + "]";
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,94 +1,214 @@
|
|||
package org.gcube.vomanagement.usermanagement.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* Liferay User Object Model
|
||||
* @author Massimiliano Assante, CNR-ISTI
|
||||
*
|
||||
*/
|
||||
public class UserModel{
|
||||
|
||||
private String fullname;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class UserModel implements Serializable {
|
||||
private long userId;
|
||||
private String username;
|
||||
private String email;
|
||||
|
||||
private String screenName;
|
||||
|
||||
private String firstname;
|
||||
|
||||
private String lastname;
|
||||
|
||||
private String userId;
|
||||
|
||||
private String firstName;
|
||||
private String middleName;
|
||||
private String lastName;
|
||||
private String fullname;
|
||||
private long registrationDate;
|
||||
|
||||
private HashMap<String,String> customAttrsMap;
|
||||
|
||||
public HashMap<String, String> getCustomAttrsMap() {
|
||||
return customAttrsMap;
|
||||
}
|
||||
public void setCustomAttrsMap(HashMap<String, String> customAttrsMap) {
|
||||
private String userAvatarId;
|
||||
private boolean male;
|
||||
private String jobTitle;
|
||||
private Map<String,String> customAttrsMap;
|
||||
private List<Email> emailAddresses;
|
||||
/**
|
||||
* constructor without custom attrs
|
||||
* @param userId
|
||||
* @param username
|
||||
* @param email
|
||||
* @param firstName
|
||||
* @param middleName
|
||||
* @param lastName
|
||||
* @param fullname
|
||||
* @param registrationDate
|
||||
* @param userAvatarId
|
||||
* @param male
|
||||
* @param jobTitle
|
||||
* @param customAttrsMap
|
||||
* @param emailAddresses
|
||||
*/
|
||||
public UserModel(long userId, String username, String email,
|
||||
String firstName, String middleName, String lastName,
|
||||
String fullname, long registrationDate, String userAvatarId,
|
||||
boolean male, String jobTitle, Map<String, String> customAttrsMap,
|
||||
List<Email> emailAddresses) {
|
||||
super();
|
||||
this.userId = userId;
|
||||
this.username = username;
|
||||
this.email = email;
|
||||
this.firstName = firstName;
|
||||
this.middleName = middleName;
|
||||
this.lastName = lastName;
|
||||
this.fullname = fullname;
|
||||
this.registrationDate = registrationDate;
|
||||
this.userAvatarId = userAvatarId;
|
||||
this.male = male;
|
||||
this.jobTitle = jobTitle;
|
||||
this.customAttrsMap = customAttrsMap;
|
||||
this.emailAddresses = emailAddresses;
|
||||
}
|
||||
public String getUserId() {
|
||||
/**
|
||||
* constructor without custom attrs
|
||||
* @param userId
|
||||
* @param username
|
||||
* @param email
|
||||
* @param firstName
|
||||
* @param middleName
|
||||
* @param lastName
|
||||
* @param fullname
|
||||
* @param registrationDate
|
||||
* @param userAvatarId
|
||||
* @param male
|
||||
* @param jobTitle
|
||||
* @param emailAddresses
|
||||
*/
|
||||
public UserModel(long userId, String username, String email,
|
||||
String firstName, String middleName, String lastName,
|
||||
String fullname, long registrationDate, String userAvatarId,
|
||||
boolean male, String jobTitle,
|
||||
List<Email> emailAddresses) {
|
||||
super();
|
||||
this.userId = userId;
|
||||
this.username = username;
|
||||
this.email = email;
|
||||
this.firstName = firstName;
|
||||
this.middleName = middleName;
|
||||
this.lastName = lastName;
|
||||
this.fullname = fullname;
|
||||
this.registrationDate = registrationDate;
|
||||
this.userAvatarId = userAvatarId;
|
||||
this.male = male;
|
||||
this.jobTitle = jobTitle;
|
||||
this.emailAddresses = emailAddresses;
|
||||
}
|
||||
|
||||
public long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
public void setUserId(String userId) {
|
||||
|
||||
public void setUserId(long 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 getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
public void setFirstName(String firstName) {
|
||||
this.firstName = firstName;
|
||||
}
|
||||
|
||||
public String getMiddleName() {
|
||||
return middleName;
|
||||
}
|
||||
|
||||
public void setMiddleName(String middleName) {
|
||||
this.middleName = middleName;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
public String getUserAvatarId() {
|
||||
return userAvatarId;
|
||||
}
|
||||
|
||||
public void setUserAvatarId(String userAvatarId) {
|
||||
this.userAvatarId = userAvatarId;
|
||||
}
|
||||
|
||||
public boolean isMale() {
|
||||
return male;
|
||||
}
|
||||
|
||||
public void setMale(boolean male) {
|
||||
this.male = male;
|
||||
}
|
||||
|
||||
public String getJobTitle() {
|
||||
return jobTitle;
|
||||
}
|
||||
|
||||
public void setJobTitle(String jobTitle) {
|
||||
this.jobTitle = jobTitle;
|
||||
}
|
||||
|
||||
public Map<String, String> getCustomAttrsMap() {
|
||||
return customAttrsMap;
|
||||
}
|
||||
public void setCustomAttrsMap(Map<String, String> customAttrsMap) {
|
||||
this.customAttrsMap = customAttrsMap;
|
||||
}
|
||||
public List<Email> getEmailAddresses() {
|
||||
return emailAddresses;
|
||||
}
|
||||
|
||||
public void setEmailAddresses(List<Email> emailAddresses) {
|
||||
this.emailAddresses = emailAddresses;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "UserModel [userId=" + userId + ", username=" + username
|
||||
+ ", email=" + email + ", firstName=" + firstName
|
||||
+ ", middleName=" + middleName + ", lastName=" + lastName
|
||||
+ ", fullname=" + fullname + ", registrationDate="
|
||||
+ new Date(registrationDate) + ", userAvatarId=" + userAvatarId
|
||||
+ ", male=" + male + ", jobTitle=" + jobTitle
|
||||
+ ", customAttrsMap=" + customAttrsMap + ", emailAddresses="
|
||||
+ emailAddresses + "]";
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue