added methods for reading custom attributes for USER class
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/vo-management/usermanagement-core@129554 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
3232afcb6e
commit
2a4704cb3d
|
@ -373,6 +373,14 @@ public interface UserManager {
|
|||
boolean updateContactInformation(String screenName, String mySpacesn,
|
||||
String twittersn, String facebooksn, String skypesn,
|
||||
String jabbersn, String aimsn);
|
||||
/**
|
||||
*
|
||||
* @param userId
|
||||
* @param theJob the job headline
|
||||
* @return true if ok
|
||||
*/
|
||||
boolean updateJobTitle(long userId, String theJob);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param attributeKey the name of the attribute you want to read its value
|
||||
|
|
|
@ -28,9 +28,6 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import com.liferay.portal.kernel.exception.PortalException;
|
||||
import com.liferay.portal.kernel.exception.SystemException;
|
||||
import com.liferay.portal.kernel.util.PropsKeys;
|
||||
import com.liferay.portal.kernel.util.PropsUtil;
|
||||
import com.liferay.portal.model.Company;
|
||||
import com.liferay.portal.model.Group;
|
||||
import com.liferay.portal.model.GroupConstants;
|
||||
import com.liferay.portal.model.Role;
|
||||
|
@ -39,7 +36,6 @@ import com.liferay.portal.security.auth.PrincipalThreadLocal;
|
|||
import com.liferay.portal.security.permission.PermissionChecker;
|
||||
import com.liferay.portal.security.permission.PermissionCheckerFactoryUtil;
|
||||
import com.liferay.portal.security.permission.PermissionThreadLocal;
|
||||
import com.liferay.portal.service.CompanyLocalServiceUtil;
|
||||
import com.liferay.portal.service.GroupLocalServiceUtil;
|
||||
import com.liferay.portal.service.LayoutSetLocalServiceUtil;
|
||||
import com.liferay.portal.service.RoleServiceUtil;
|
||||
|
|
|
@ -15,6 +15,7 @@ import org.gcube.vomanagement.usermanagement.exception.TeamRetrievalFault;
|
|||
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.CustomAttributeKeys;
|
||||
import org.gcube.vomanagement.usermanagement.model.Email;
|
||||
import org.gcube.vomanagement.usermanagement.model.GCubeMembershipRequest;
|
||||
import org.gcube.vomanagement.usermanagement.model.GCubeRole;
|
||||
|
@ -95,13 +96,18 @@ public class LiferayUserManager implements UserManager {
|
|||
return null;
|
||||
}
|
||||
//simple user mapping
|
||||
private static GCubeUser mapLRUser(User u) throws PortalException, SystemException {
|
||||
private GCubeUser 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()));
|
||||
}
|
||||
|
||||
String locationIndustry = "";
|
||||
try {
|
||||
locationIndustry = (String) readCustomAttr(u.getUserId(), CustomAttributeKeys.USER_LOCATION_INDUSTRY.getKeyName());
|
||||
} catch (UserRetrievalFault e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
return new GCubeUser(
|
||||
u.getUserId(),
|
||||
u.getScreenName(),
|
||||
|
@ -114,7 +120,7 @@ public class LiferayUserManager implements UserManager {
|
|||
getUserAvatarAbsoluteURL(u),
|
||||
u.isMale(),
|
||||
u.getJobTitle(),
|
||||
u.getOpenId(),
|
||||
locationIndustry,
|
||||
emails);
|
||||
}
|
||||
else
|
||||
|
@ -133,7 +139,7 @@ public class LiferayUserManager implements UserManager {
|
|||
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 {
|
||||
private GCubeMembershipRequest mapLRMembershipRequest(MembershipRequest req) throws PortalException, SystemException {
|
||||
MembershipRequestStatus requestStatus = MembershipRequestStatus.REQUEST;
|
||||
if (req.getStatusId() == 1)
|
||||
requestStatus = MembershipRequestStatus.APPROVED;
|
||||
|
@ -333,7 +339,7 @@ public class LiferayUserManager implements UserManager {
|
|||
username,
|
||||
email,
|
||||
0L,
|
||||
location_industry,
|
||||
"",
|
||||
locale,
|
||||
firstName,
|
||||
middleName,
|
||||
|
@ -364,6 +370,9 @@ public class LiferayUserManager implements UserManager {
|
|||
_log.debug("User " + lastName + " has agreed to ToU");
|
||||
_log.debug("User " + lastName + " updatePasswordReset & updateReminderQuery");
|
||||
|
||||
//try save the location/industry
|
||||
saveCustomAttr(added.getUserId(), CustomAttributeKeys.USER_LOCATION_INDUSTRY.getKeyName(), location_industry);
|
||||
|
||||
// try to change user's avatar
|
||||
if(portraitBytes != null){
|
||||
try{
|
||||
|
@ -399,11 +408,9 @@ public class LiferayUserManager implements UserManager {
|
|||
ContactLocalServiceUtil.updateContact(contact);
|
||||
|
||||
return mapLRUser(added);
|
||||
} catch (SystemException e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} catch (PortalException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return toReturn;
|
||||
|
||||
}
|
||||
|
@ -995,4 +1002,14 @@ public class LiferayUserManager implements UserManager {
|
|||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public boolean updateJobTitle(long userId, String theJob) {
|
||||
try {
|
||||
UserLocalServiceUtil.updateJobTitle(userId, theJob);
|
||||
} catch (PortalException | SystemException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ public enum CustomAttributeKeys {
|
|||
GATEWAY_SITE_NAME("Gatewayname"),
|
||||
GATEWAY_SITE_EMAIL_SENDER("Emailsender"),
|
||||
//User
|
||||
USER_COMPANY_OR_INSTITUTION("company");
|
||||
USER_LOCATION_INDUSTRY("industry");
|
||||
|
||||
private String name;
|
||||
|
||||
|
|
Loading…
Reference in New Issue