70 lines
1.9 KiB
Java
70 lines
1.9 KiB
Java
package org.gcube.portlets.user.workspace.server.util;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
import org.apache.log4j.Logger;
|
|
import org.gcube.portlets.user.workspace.client.model.InfoContactModel;
|
|
import org.gcube.vomanagement.usermanagement.UserManager;
|
|
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.impl.liferay.LiferayUserManager;
|
|
import org.gcube.vomanagement.usermanagement.model.UserModel;
|
|
|
|
|
|
|
|
public class UserUtil {
|
|
|
|
static UserManager um = new LiferayUserManager();
|
|
protected static Logger logger = Logger.getLogger(UserUtil.class);
|
|
|
|
|
|
/**
|
|
*
|
|
* @param user
|
|
* @return
|
|
*/
|
|
public static String getUserFullName(String portalLogin){
|
|
// return user.getPortalLogin(); //for testing in eclipse
|
|
|
|
if (portalLogin.compareTo(Util.TEST_USER) != 0) { //skip test.user
|
|
|
|
UserModel curr = null;
|
|
|
|
try {
|
|
try {
|
|
curr = um.getUserByScreenName(portalLogin);
|
|
|
|
} catch (UserManagementSystemException e) {
|
|
|
|
logger.error("An error occurred in getUserFullName "+e,e);
|
|
} catch (UserRetrievalFault e) {
|
|
|
|
logger.error("An error occurred in getUserFullName "+e,e);
|
|
}
|
|
} catch (UserManagementPortalException ume) {
|
|
logger.error("An error occurred in getUserFullName "+ume,ume);
|
|
}
|
|
if (curr != null)
|
|
return curr.getFullname();
|
|
}else{
|
|
|
|
return Util.TEST_USER_FULL_NAME;
|
|
}
|
|
|
|
return "";
|
|
}
|
|
|
|
public static List<String> getListLoginByInfoContactModel(List<InfoContactModel> listContacts){
|
|
|
|
List<String> listUsers = new ArrayList<String>();
|
|
|
|
for (InfoContactModel infoContactModel : listContacts) {
|
|
listUsers.add(infoContactModel.getLogin());
|
|
}
|
|
|
|
return listUsers;
|
|
}
|
|
}
|