fixed method for getting portrait URL
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/vo-management/usermanagement-core@126286 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
42f4a1f22e
commit
6dfa6941b3
|
@ -24,6 +24,8 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import com.liferay.portal.kernel.exception.PortalException;
|
||||
import com.liferay.portal.kernel.exception.SystemException;
|
||||
import com.liferay.portal.kernel.util.DigesterUtil;
|
||||
import com.liferay.portal.kernel.util.HttpUtil;
|
||||
import com.liferay.portal.model.EmailAddress;
|
||||
import com.liferay.portal.model.Group;
|
||||
import com.liferay.portal.model.MembershipRequest;
|
||||
|
@ -41,6 +43,7 @@ import com.liferay.portal.service.RoleServiceUtil;
|
|||
import com.liferay.portal.service.ServiceContext;
|
||||
import com.liferay.portal.service.UserLocalServiceUtil;
|
||||
import com.liferay.portal.util.PortalUtil;
|
||||
import com.liferay.portal.webserver.WebServerServletTokenUtil;
|
||||
|
||||
public class LiferayUserManager implements UserManager {
|
||||
/**
|
||||
|
@ -91,6 +94,8 @@ public class LiferayUserManager implements UserManager {
|
|||
for (EmailAddress e : u.getEmailAddresses()) {
|
||||
emails.add(new Email(e.getAddress(), e.getType().toString(), e.isPrimary()));
|
||||
}
|
||||
|
||||
|
||||
return new GCubeUser(
|
||||
u.getUserId(),
|
||||
u.getScreenName(),
|
||||
|
@ -100,7 +105,7 @@ public class LiferayUserManager implements UserManager {
|
|||
u.getLastName(),
|
||||
u.getFullName(),
|
||||
u.getCreateDate().getTime(),
|
||||
u.getPortraitId()+"",
|
||||
getUserAvatarAbsoluteURL(u),
|
||||
u.isMale(),
|
||||
u.getJobTitle(),
|
||||
emails);
|
||||
|
@ -108,7 +113,19 @@ public class LiferayUserManager implements UserManager {
|
|||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param u
|
||||
* @return the absolute path of the avatar URL comprising security token e.g. /image/user_male_portrait?img_id=22910&img_id_token=0RJ5WkeDV9F9bETGlqzb7LahygM%3D&t=1458899199747
|
||||
* @throws PortalException
|
||||
* @throws SystemException
|
||||
*/
|
||||
private static String getUserAvatarAbsoluteURL(User u) throws PortalException, SystemException {
|
||||
String pictureBaseURL = u.isMale() ? "/image/user_male_portrait?img_id=" : "/image/user_female_portrait?img_id=";
|
||||
String img_id_token = HttpUtil.encodeURL(DigesterUtil.digest(u.getUuid()));
|
||||
String token = WebServerServletTokenUtil.getToken(u.getPortraitId());
|
||||
return pictureBaseURL+u.getPortraitId()+"&img_id_token="+img_id_token+"&t="+token;
|
||||
}
|
||||
private static GCubeMembershipRequest mapLRMembershipRequest(MembershipRequest req) throws PortalException, SystemException {
|
||||
MembershipRequestStatus requestStatus = MembershipRequestStatus.REQUEST;
|
||||
if (req.getStatusId() == 1)
|
||||
|
|
|
@ -20,7 +20,7 @@ public class GCubeUser implements Serializable {
|
|||
private String lastName;
|
||||
private String fullname;
|
||||
private long registrationDate;
|
||||
private String userAvatarId;
|
||||
private String userAvatarURL;
|
||||
private boolean male;
|
||||
private String jobTitle;
|
||||
private Map<String,String> customAttrsMap;
|
||||
|
@ -43,7 +43,7 @@ public class GCubeUser implements Serializable {
|
|||
*/
|
||||
public GCubeUser(long userId, String username, String email,
|
||||
String firstName, String middleName, String lastName,
|
||||
String fullname, long registrationDate, String userAvatarId,
|
||||
String fullname, long registrationDate, String userAvatarURL,
|
||||
boolean male, String jobTitle, Map<String, String> customAttrsMap,
|
||||
List<Email> emailAddresses) {
|
||||
super();
|
||||
|
@ -55,7 +55,7 @@ public class GCubeUser implements Serializable {
|
|||
this.lastName = lastName;
|
||||
this.fullname = fullname;
|
||||
this.registrationDate = registrationDate;
|
||||
this.userAvatarId = userAvatarId;
|
||||
this.userAvatarURL = userAvatarURL;
|
||||
this.male = male;
|
||||
this.jobTitle = jobTitle;
|
||||
this.customAttrsMap = customAttrsMap;
|
||||
|
@ -90,7 +90,7 @@ public class GCubeUser implements Serializable {
|
|||
this.lastName = lastName;
|
||||
this.fullname = fullname;
|
||||
this.registrationDate = registrationDate;
|
||||
this.userAvatarId = userAvatarId;
|
||||
this.userAvatarURL = userAvatarId;
|
||||
this.male = male;
|
||||
this.jobTitle = jobTitle;
|
||||
this.emailAddresses = emailAddresses;
|
||||
|
@ -168,13 +168,23 @@ public class GCubeUser implements Serializable {
|
|||
public void setRegistrationDate(long registrationDate) {
|
||||
this.registrationDate = registrationDate;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String getUserAvatarId() {
|
||||
return userAvatarId;
|
||||
return userAvatarURL;
|
||||
}
|
||||
@Deprecated
|
||||
public void setUserAvatarId(String userAvatarId) {
|
||||
this.userAvatarURL = userAvatarId;
|
||||
}
|
||||
/**
|
||||
* @return the absolute path of the avatar URL comprising security token e.g. /image/user_male_portrait?img_id=12345&img_id_token=0GJ5WkeDV9F9bDZGkqzb7LahygM%3D&t=1457799199747
|
||||
*/
|
||||
public String getUserAvatarURL() {
|
||||
return userAvatarURL;
|
||||
}
|
||||
|
||||
public void setUserAvatarId(String userAvatarId) {
|
||||
this.userAvatarId = userAvatarId;
|
||||
public void setUserAvatarURL(String userAvatarURL) {
|
||||
this.userAvatarURL = userAvatarURL;
|
||||
}
|
||||
|
||||
public boolean isMale() {
|
||||
|
@ -213,7 +223,7 @@ public class GCubeUser implements Serializable {
|
|||
+ ", email=" + email + ", firstName=" + firstName
|
||||
+ ", middleName=" + middleName + ", lastName=" + lastName
|
||||
+ ", fullname=" + fullname + ", registrationDate="
|
||||
+ new Date(registrationDate) + ", userAvatarId=" + userAvatarId
|
||||
+ new Date(registrationDate) + ", userAvatarId=" + userAvatarURL
|
||||
+ ", male=" + male + ", jobTitle=" + jobTitle
|
||||
+ ", customAttrsMap=" + customAttrsMap + ", emailAddresses="
|
||||
+ emailAddresses + "]";
|
||||
|
|
Loading…
Reference in New Issue