diff --git a/src/main/java/org/gcube/vomanagement/usermanagement/UserManager.java b/src/main/java/org/gcube/vomanagement/usermanagement/UserManager.java index a9a9114..9533f19 100644 --- a/src/main/java/org/gcube/vomanagement/usermanagement/UserManager.java +++ b/src/main/java/org/gcube/vomanagement/usermanagement/UserManager.java @@ -1,5 +1,6 @@ package org.gcube.vomanagement.usermanagement; +import java.io.Serializable; import java.util.List; import java.util.Map; @@ -334,29 +335,29 @@ public interface UserManager { * @param email * @return true on success, false otherwise */ - public boolean userExistsByEmail(String email); + boolean userExistsByEmail(String email); /** * Returns the user's full name given his email * @param email * @return null on failure */ - public String getFullNameFromEmail(String email); + String getFullNameFromEmail(String email); /** * Delete a user given his mail * @param email */ - public void deleteUserByEMail(String email) throws UserManagementSystemException, UserManagementPortalException, PortalException, SystemException; + void deleteUserByEMail(String email) throws UserManagementSystemException, UserManagementPortalException, PortalException, SystemException; /** * Retrieve user's avatar as bytes */ - public byte[] getUserAvatarBytes(String screenName); + byte[] getUserAvatarBytes(String screenName); /** * Retrieve user's openId field */ - public String getUserOpenId(String screenName); + String getUserOpenId(String screenName); /** * Update screenName user's contact information @@ -369,7 +370,23 @@ public interface UserManager { * @param aimsn * @return true on success, false otherwise */ - public boolean updateContactInformation(String screenName, String mySpacesn, + boolean updateContactInformation(String screenName, String mySpacesn, String twittersn, String facebooksn, String skypesn, String jabbersn, String aimsn); + /** + * + * @param attributeKey the name of the attribute you want to read its value + * @return the attributeKey value if existing, null otherwise + * @return + * @throws UserRetrievalFault + */ + Serializable readCustomAttr(long userId, String attributeKey) throws UserRetrievalFault; + /** + * + * @param userId + * @param attributeKey the name of the attribute you want to save + * @param value the value + * @throws UserRetrievalFault + */ + void saveCustomAttr(long userId, String attributeKey, Serializable value) throws UserRetrievalFault; } diff --git a/src/main/java/org/gcube/vomanagement/usermanagement/impl/LiferayUserManager.java b/src/main/java/org/gcube/vomanagement/usermanagement/impl/LiferayUserManager.java index 207e74e..7ffe201 100644 --- a/src/main/java/org/gcube/vomanagement/usermanagement/impl/LiferayUserManager.java +++ b/src/main/java/org/gcube/vomanagement/usermanagement/impl/LiferayUserManager.java @@ -1,5 +1,6 @@ package org.gcube.vomanagement.usermanagement.impl; +import java.io.Serializable; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -959,4 +960,39 @@ public class LiferayUserManager implements UserManager { } } + /** + * {@inheritDoc} + */ + @Override + public Serializable readCustomAttr(long userId, String attributeKey) throws UserRetrievalFault { + try { + doAsAdmin(); + User u = UserLocalServiceUtil.getUser(userId); + if (u.getExpandoBridge().hasAttribute(attributeKey)) { + _log.info("User Attribute found: " + attributeKey + " trying read value"); + return u.getExpandoBridge().getAttribute(attributeKey); + } else + return null; + } catch (PortalException e1) { + throw new UserRetrievalFault("User not existing (I think you better check)", e1); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + /** + * {@inheritDoc} + */ + @Override + public void saveCustomAttr(long userId, String attributeKey, Serializable value) throws UserRetrievalFault { + try { + doAsAdmin(); + User u = UserLocalServiceUtil.getUser(userId); + u.getExpandoBridge().setAttribute(attributeKey, value); + } catch (PortalException e1) { + throw new UserRetrievalFault("User not existing (I think you better check)", e1); + } catch (Exception e) { + e.printStackTrace(); + } + } } diff --git a/src/main/java/org/gcube/vomanagement/usermanagement/model/CustomAttributeKeys.java b/src/main/java/org/gcube/vomanagement/usermanagement/model/CustomAttributeKeys.java index ed08624..106f63e 100644 --- a/src/main/java/org/gcube/vomanagement/usermanagement/model/CustomAttributeKeys.java +++ b/src/main/java/org/gcube/vomanagement/usermanagement/model/CustomAttributeKeys.java @@ -4,17 +4,20 @@ package org.gcube.vomanagement.usermanagement.model; * @author Massimiliano Assante, CNR-ISTI * For gCube Portal Bundle (Site) Custom Attributes keys * - * use LiferayGroupManager#readCustomAttr method to read them + * use LiferayGroupManager#readCustomAttr method to read them or LiferayUserManager#readCustomAttr * */ public enum CustomAttributeKeys { + //Group MANDATORY("Mandatory"), IS_EXTERNAL("Isexternal"), URL("Url"), POST_NOTIFICATION("Postnotificationviaemail"), VIRTUAL_GROUP("Virtualgroup"), GATEWAY_SITE_NAME("Gatewayname"), - GATEWAY_SITE_EMAIL_SENDER("Emailsender"); + GATEWAY_SITE_EMAIL_SENDER("Emailsender"), + //User + USER_COMPANY_OR_INSTITUTION("company"); private String name; diff --git a/src/main/java/org/gcube/vomanagement/usermanagement/util/ManagementUtils.java b/src/main/java/org/gcube/vomanagement/usermanagement/util/ManagementUtils.java index a7a150b..35299c2 100644 --- a/src/main/java/org/gcube/vomanagement/usermanagement/util/ManagementUtils.java +++ b/src/main/java/org/gcube/vomanagement/usermanagement/util/ManagementUtils.java @@ -15,7 +15,8 @@ public class ManagementUtils { * logger */ private static final Logger _log = LoggerFactory.getLogger(ManagementUtils.class); - /** + + /** * */