This commit is contained in:
Francesco Mangiacrapa 2013-03-11 15:37:10 +00:00
parent 56ceea5bf5
commit 1db23d384b
4 changed files with 67 additions and 26 deletions

View File

@ -14,6 +14,7 @@ import com.extjs.gxt.ui.client.data.BaseModelData;
public class InfoContactModel extends BaseModelData implements Serializable {
protected static final String FULLNAME = "fullname";
/**
*
*/
@ -21,20 +22,19 @@ public class InfoContactModel extends BaseModelData implements Serializable {
public InfoContactModel() {}
public InfoContactModel(String id, String login, String name) {
public InfoContactModel(String id, String login, String fullName) {
setId(id);
setLogin(login);
setName(name);
setCheck(false);
setName(fullName);
}
public void setName(String name) {
set("fullname",name);
set(FULLNAME,name);
}
public String getName(){
return get("fullname");
return get(FULLNAME);
}
public String getId() {
@ -53,13 +53,6 @@ public class InfoContactModel extends BaseModelData implements Serializable {
set(ConstantsExplorer.LOGIN, login);
}
public void setCheck(Boolean bool){
set("check", bool);
}
public Boolean isCheck(){
return (Boolean) get("check");
}
public static Comparator<InfoContactModel> COMPARATOR = new Comparator<InfoContactModel>() {
// This is where the sorting happens.
@ -68,7 +61,6 @@ public class InfoContactModel extends BaseModelData implements Serializable {
}
};
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
@ -78,8 +70,6 @@ public class InfoContactModel extends BaseModelData implements Serializable {
builder.append(getId());
builder.append(", getLogin()=");
builder.append(getLogin());
builder.append(", isCheck()=");
builder.append(isCheck());
builder.append("]");
return builder.toString();
}

View File

@ -78,6 +78,7 @@ import org.gcube.portlets.user.workspace.client.workspace.folder.item.gcube.GWTM
import org.gcube.portlets.user.workspace.client.workspace.folder.item.gcube.GWTPDFDocument;
import org.gcube.portlets.user.workspace.client.workspace.folder.item.gcube.GWTUrlDocument;
import org.gcube.portlets.user.workspace.server.util.AllScope;
import org.gcube.portlets.user.workspace.server.util.UserUtil;
/**
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
@ -837,13 +838,11 @@ public class GWTWorkspaceBuilder {
}
//TODO
//TEMP??
protected List<InfoContactModel> buildGxtInfoContactFromPortalLogin(List<String> listPortalLogin){
protected List<InfoContactModel> buildGxtInfoContactFromPortalLogin(List<String> listUserLogin){
List<InfoContactModel> listContact = new ArrayList<InfoContactModel>();
for (String portalLogin : listPortalLogin)
listContact.add(new InfoContactModel(portalLogin, portalLogin, "name"));
for (String portalLogin : listUserLogin)
listContact.add(new InfoContactModel(portalLogin, portalLogin, UserUtil.getUserFullName(portalLogin)));
return listContact;
}
@ -1422,7 +1421,7 @@ public class GWTWorkspaceBuilder {
List<InfoContactModel> listContactsModel = new ArrayList<InfoContactModel>();
for(User user: listUsers){
listContactsModel.add(new InfoContactModel(user.getId(), user.getPortalLogin(), user.getPortalLogin()));
listContactsModel.add(new InfoContactModel(user.getId(), user.getPortalLogin(), UserUtil.getUserFullName(user.getPortalLogin())));
}
return listContactsModel;
@ -1501,7 +1500,7 @@ public class GWTWorkspaceBuilder {
public InfoContactModel buildGXTInfoContactModel(User user) throws InternalErrorException{
if(user!=null)
return new InfoContactModel(user.getId(), user.getPortalLogin(), "name");
return new InfoContactModel(user.getId(), user.getPortalLogin(), UserUtil.getUserFullName(user.getPortalLogin()));
return new InfoContactModel();
}

View File

@ -1584,11 +1584,11 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
List<String> listUser = wsFolder.getUsers();
List<String> listPortalLogin = wsFolder.getUsers();
workspaceLogger.trace("getListUserSharedByFolderSharedId return "+ listUser.size() + " user");
workspaceLogger.trace("getListUserSharedByFolderSharedId return "+ listPortalLogin.size() + " user");
return builder.buildGxtInfoContactFromPortalLogin(listUser);
return builder.buildGxtInfoContactFromPortalLogin(listPortalLogin);
}
else{

View File

@ -0,0 +1,52 @@
package org.gcube.portlets.user.workspace.server.util;
import org.apache.log4j.Logger;
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) {
}
if (curr != null)
return curr.getFullname();
}
return "";
}
}