added read / write custom attrobute for User
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/vo-management/usermanagement-core@129524 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
f90da4f15d
commit
3232afcb6e
|
@ -1,5 +1,6 @@
|
||||||
package org.gcube.vomanagement.usermanagement;
|
package org.gcube.vomanagement.usermanagement;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -334,29 +335,29 @@ public interface UserManager {
|
||||||
* @param email
|
* @param email
|
||||||
* @return true on success, false otherwise
|
* @return true on success, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean userExistsByEmail(String email);
|
boolean userExistsByEmail(String email);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the user's full name given his email
|
* Returns the user's full name given his email
|
||||||
* @param email
|
* @param email
|
||||||
* @return null on failure
|
* @return null on failure
|
||||||
*/
|
*/
|
||||||
public String getFullNameFromEmail(String email);
|
String getFullNameFromEmail(String email);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a user given his mail
|
* Delete a user given his mail
|
||||||
* @param email
|
* @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
|
* Retrieve user's avatar as bytes
|
||||||
*/
|
*/
|
||||||
public byte[] getUserAvatarBytes(String screenName);
|
byte[] getUserAvatarBytes(String screenName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve user's openId field
|
* Retrieve user's openId field
|
||||||
*/
|
*/
|
||||||
public String getUserOpenId(String screenName);
|
String getUserOpenId(String screenName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update screenName user's contact information
|
* Update screenName user's contact information
|
||||||
|
@ -369,7 +370,23 @@ public interface UserManager {
|
||||||
* @param aimsn
|
* @param aimsn
|
||||||
* @return true on success, false otherwise
|
* @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 twittersn, String facebooksn, String skypesn,
|
||||||
String jabbersn, String aimsn);
|
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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package org.gcube.vomanagement.usermanagement.impl;
|
package org.gcube.vomanagement.usermanagement.impl;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,17 +4,20 @@ package org.gcube.vomanagement.usermanagement.model;
|
||||||
* @author Massimiliano Assante, CNR-ISTI
|
* @author Massimiliano Assante, CNR-ISTI
|
||||||
* For gCube Portal Bundle (Site) Custom Attributes keys
|
* 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 {
|
public enum CustomAttributeKeys {
|
||||||
|
//Group
|
||||||
MANDATORY("Mandatory"),
|
MANDATORY("Mandatory"),
|
||||||
IS_EXTERNAL("Isexternal"),
|
IS_EXTERNAL("Isexternal"),
|
||||||
URL("Url"),
|
URL("Url"),
|
||||||
POST_NOTIFICATION("Postnotificationviaemail"),
|
POST_NOTIFICATION("Postnotificationviaemail"),
|
||||||
VIRTUAL_GROUP("Virtualgroup"),
|
VIRTUAL_GROUP("Virtualgroup"),
|
||||||
GATEWAY_SITE_NAME("Gatewayname"),
|
GATEWAY_SITE_NAME("Gatewayname"),
|
||||||
GATEWAY_SITE_EMAIL_SENDER("Emailsender");
|
GATEWAY_SITE_EMAIL_SENDER("Emailsender"),
|
||||||
|
//User
|
||||||
|
USER_COMPANY_OR_INSTITUTION("company");
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,8 @@ public class ManagementUtils {
|
||||||
* logger
|
* logger
|
||||||
*/
|
*/
|
||||||
private static final Logger _log = LoggerFactory.getLogger(ManagementUtils.class);
|
private static final Logger _log = LoggerFactory.getLogger(ManagementUtils.class);
|
||||||
/**
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue