Added getUserAvatarBytes and getUserOpenId functions. CreateUser now accepts the former parameters
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/vo-management/usermanagement-core@126806 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
0b0022d86d
commit
ae5ce990da
10
.classpath
10
.classpath
|
@ -18,11 +18,6 @@
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/LIFERAY_LIBS"/>
|
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/LIFERAY_LIBS"/>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
|
|
||||||
<attributes>
|
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
|
||||||
</attributes>
|
|
||||||
</classpathentry>
|
|
||||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
@ -34,5 +29,10 @@
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
<classpathentry kind="output" path="target/classes"/>
|
<classpathentry kind="output" path="target/classes"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|
4
.project
4
.project
|
@ -21,12 +21,12 @@
|
||||||
</arguments>
|
</arguments>
|
||||||
</buildCommand>
|
</buildCommand>
|
||||||
<buildCommand>
|
<buildCommand>
|
||||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
<name>org.eclipse.wst.validation.validationbuilder</name>
|
||||||
<arguments>
|
<arguments>
|
||||||
</arguments>
|
</arguments>
|
||||||
</buildCommand>
|
</buildCommand>
|
||||||
<buildCommand>
|
<buildCommand>
|
||||||
<name>org.eclipse.wst.validation.validationbuilder</name>
|
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||||
<arguments>
|
<arguments>
|
||||||
</arguments>
|
</arguments>
|
||||||
</buildCommand>
|
</buildCommand>
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
#Fri Jul 26 17:34:06 CEST 2013
|
|
||||||
eclipse.preferences.version=1
|
eclipse.preferences.version=1
|
||||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
disabled=06target
|
||||||
|
eclipse.preferences.version=1
|
|
@ -55,6 +55,24 @@ public interface UserManager {
|
||||||
* @throws UserManagementSystemException
|
* @throws UserManagementSystemException
|
||||||
*/
|
*/
|
||||||
GCubeUser createUser(boolean autoScreenName, String username, String email, String firstName, String middleName, String lastName, String jobTitle, String location_industry, String backgroundSummary, boolean male, String reminderQuestion, String reminderAnswer, boolean sendEmail, boolean forcePasswordReset) throws UserManagementSystemException;
|
GCubeUser createUser(boolean autoScreenName, String username, String email, String firstName, String middleName, String lastName, String jobTitle, String location_industry, String backgroundSummary, boolean male, String reminderQuestion, String reminderAnswer, boolean sendEmail, boolean forcePasswordReset) throws UserManagementSystemException;
|
||||||
|
/**
|
||||||
|
* Create the user and let you choose if you want to send him/her a mail notification and force or not the user to change his/her password.
|
||||||
|
* You can also pass the avatar to set as bytes.
|
||||||
|
* @param autoScreenName set true if you want liferay to auto generate a screename for this user, false otherwise
|
||||||
|
* @param username the username of the user you want
|
||||||
|
* @param email a valid email address
|
||||||
|
* @param firstName
|
||||||
|
* @param middleName
|
||||||
|
* @param lastName
|
||||||
|
* @param jobTitle
|
||||||
|
* @param backgroundSummary
|
||||||
|
* @param male
|
||||||
|
* @param portraitBytes the bytes of the avatar to use for the user
|
||||||
|
* @param openId user's openId
|
||||||
|
* @return an instance of the yet created user
|
||||||
|
* @throws UserManagementSystemException
|
||||||
|
*/
|
||||||
|
GCubeUser createUser(boolean autoScreenName, String username, String email, String firstName, String middleName, String lastName, String jobTitle, String location_industry, String backgroundSummary, boolean male, String reminderQuestion, String reminderAnswer, boolean sendEmail, boolean forcePasswordReset, byte[] portraitBytes) throws UserManagementSystemException;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param username the username of the user you want to get
|
* @param username the username of the user you want to get
|
||||||
|
@ -259,4 +277,13 @@ public interface UserManager {
|
||||||
* @param email
|
* @param email
|
||||||
*/
|
*/
|
||||||
public void deleteUserByEMail(String email) throws UserManagementSystemException, UserManagementPortalException, PortalException, SystemException;
|
public void deleteUserByEMail(String email) throws UserManagementSystemException, UserManagementPortalException, PortalException, SystemException;
|
||||||
|
/**
|
||||||
|
* Retrieve user's avatar as bytes
|
||||||
|
*/
|
||||||
|
public byte[] getUserAvatarBytes(String screenName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve user's openId field
|
||||||
|
*/
|
||||||
|
public String getUserOpenId(String screenName);
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@ import com.liferay.portal.security.permission.PermissionChecker;
|
||||||
import com.liferay.portal.security.permission.PermissionCheckerFactoryUtil;
|
import com.liferay.portal.security.permission.PermissionCheckerFactoryUtil;
|
||||||
import com.liferay.portal.security.permission.PermissionThreadLocal;
|
import com.liferay.portal.security.permission.PermissionThreadLocal;
|
||||||
import com.liferay.portal.service.GroupLocalServiceUtil;
|
import com.liferay.portal.service.GroupLocalServiceUtil;
|
||||||
|
import com.liferay.portal.service.ImageLocalServiceUtil;
|
||||||
import com.liferay.portal.service.MembershipRequestLocalServiceUtil;
|
import com.liferay.portal.service.MembershipRequestLocalServiceUtil;
|
||||||
import com.liferay.portal.service.RoleLocalServiceUtil;
|
import com.liferay.portal.service.RoleLocalServiceUtil;
|
||||||
import com.liferay.portal.service.RoleServiceUtil;
|
import com.liferay.portal.service.RoleServiceUtil;
|
||||||
|
@ -177,7 +178,8 @@ public class LiferayUserManager implements UserManager {
|
||||||
reminderQuestion,
|
reminderQuestion,
|
||||||
reminderAnswer,
|
reminderAnswer,
|
||||||
false,
|
false,
|
||||||
false);
|
false,
|
||||||
|
null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -201,13 +203,40 @@ public class LiferayUserManager implements UserManager {
|
||||||
reminderQuestion,
|
reminderQuestion,
|
||||||
reminderAnswer,
|
reminderAnswer,
|
||||||
sendEmail,
|
sendEmail,
|
||||||
forcePasswordReset);
|
forcePasswordReset,
|
||||||
|
null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public GCubeUser createUser(boolean autoScreenName, String username, String email, String firstName, String middleName, String lastName,
|
||||||
|
String jobTitle, String location_industry, String backgroundSummary, boolean male, String reminderQuestion, String reminderAnswer, boolean sendEmail, boolean forcePasswordReset,
|
||||||
|
byte[] portraitBytes)
|
||||||
|
throws UserManagementSystemException {
|
||||||
|
return createUserBody(
|
||||||
|
autoScreenName,
|
||||||
|
username,
|
||||||
|
email,
|
||||||
|
firstName,
|
||||||
|
middleName,
|
||||||
|
lastName,
|
||||||
|
jobTitle,
|
||||||
|
backgroundSummary,
|
||||||
|
location_industry,
|
||||||
|
male,
|
||||||
|
reminderQuestion,
|
||||||
|
reminderAnswer,
|
||||||
|
sendEmail,
|
||||||
|
forcePasswordReset,
|
||||||
|
portraitBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
private GCubeUser createUserBody(boolean autoScreenName, String username,
|
private GCubeUser createUserBody(boolean autoScreenName, String username,
|
||||||
String email, String firstName, String middleName, String lastName,
|
String email, String firstName, String middleName, String lastName,
|
||||||
String jobTitle, String location_industry, String backgroundSummary, boolean male,
|
String jobTitle, String location_industry, String backgroundSummary, boolean male,
|
||||||
String reminderQuestion, String reminderAnswer, boolean sendEmail, boolean forcePasswordReset){
|
String reminderQuestion, String reminderAnswer, boolean sendEmail, boolean forcePasswordReset, byte[] portraitBytes){
|
||||||
|
|
||||||
GCubeUser toReturn = null;
|
GCubeUser toReturn = null;
|
||||||
try {
|
try {
|
||||||
|
@ -264,6 +293,23 @@ public class LiferayUserManager implements UserManager {
|
||||||
UserLocalServiceUtil.updateReminderQuery(added.getUserId(), reminderQuestion, reminderAnswer);
|
UserLocalServiceUtil.updateReminderQuery(added.getUserId(), reminderQuestion, reminderAnswer);
|
||||||
_log.debug("User " + lastName + " has agreed to ToU");
|
_log.debug("User " + lastName + " has agreed to ToU");
|
||||||
_log.debug("User " + lastName + " updatePasswordReset & updateReminderQuery");
|
_log.debug("User " + lastName + " updatePasswordReset & updateReminderQuery");
|
||||||
|
|
||||||
|
// try to change user's avatar
|
||||||
|
if(portraitBytes != null){
|
||||||
|
|
||||||
|
try{
|
||||||
|
_log.debug("Updating user's avatar");
|
||||||
|
UserLocalServiceUtil.updatePortrait(added.getUserId(), portraitBytes);
|
||||||
|
_log.debug("User's avatar set OK");
|
||||||
|
}catch(PortalException e1){
|
||||||
|
_log.debug("Unable to set user's avatar", e1);
|
||||||
|
}
|
||||||
|
catch(SystemException e1){
|
||||||
|
_log.debug("Unable to set user's avatar", e1);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return mapLRUser(added);
|
return mapLRUser(added);
|
||||||
} catch (SystemException e) {
|
} catch (SystemException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -734,5 +780,29 @@ public class LiferayUserManager implements UserManager {
|
||||||
_log.debug("Delete user with email " + email);
|
_log.debug("Delete user with email " + email);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public byte[] getUserAvatarBytes(String screenName) {
|
||||||
|
try {
|
||||||
|
User user = UserLocalServiceUtil.getUserByScreenName(ManagementUtils.getCompany().getCompanyId(), screenName);
|
||||||
|
return ImageLocalServiceUtil.getImage(user.getPortraitId()).getTextObj();
|
||||||
|
} catch (PortalException e) {
|
||||||
|
_log.debug("Unable to retrieve user's avatar", e);
|
||||||
|
} catch (SystemException e) {
|
||||||
|
_log.debug("Unable to retrieve user's avatar", e);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String getUserOpenId(String screenName) {
|
||||||
|
try {
|
||||||
|
User user = UserLocalServiceUtil.getUserByScreenName(ManagementUtils.getCompany().getCompanyId(), screenName);
|
||||||
|
return user.getOpenId();
|
||||||
|
} catch (PortalException e) {
|
||||||
|
_log.debug("Unable to retrieve user's openId", e);
|
||||||
|
} catch (SystemException e) {
|
||||||
|
_log.debug("Unable to retrieve user's openId", e);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue