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 { 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() {}
public InfoContactModel(String id, String login, String name) { public InfoContactModel(String id, String login, String fullName) {
setId(id); setId(id);
setLogin(login); setLogin(login);
setName(name); setName(fullName);
setCheck(false);
} }
public void setName(String name) { public void setName(String name) {
set("fullname",name); set(FULLNAME,name);
} }
public String getName(){ public String getName(){
return get("fullname"); return get(FULLNAME);
} }
public String getId() { public String getId() {
@ -52,14 +52,7 @@ public class InfoContactModel extends BaseModelData implements Serializable {
public void setLogin(String login) { public void setLogin(String login) {
set(ConstantsExplorer.LOGIN, login); 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>() { public static Comparator<InfoContactModel> COMPARATOR = new Comparator<InfoContactModel>() {
// This is where the sorting happens. // This is where the sorting happens.
@ -67,7 +60,6 @@ public class InfoContactModel extends BaseModelData implements Serializable {
return o1.getLogin().compareToIgnoreCase(o2.getLogin()); return o1.getLogin().compareToIgnoreCase(o2.getLogin());
} }
}; };
@Override @Override
public String toString() { public String toString() {
@ -78,8 +70,6 @@ public class InfoContactModel extends BaseModelData implements Serializable {
builder.append(getId()); builder.append(getId());
builder.append(", getLogin()="); builder.append(", getLogin()=");
builder.append(getLogin()); builder.append(getLogin());
builder.append(", isCheck()=");
builder.append(isCheck());
builder.append("]"); builder.append("]");
return builder.toString(); 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.GWTPDFDocument;
import org.gcube.portlets.user.workspace.client.workspace.folder.item.gcube.GWTUrlDocument; 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.AllScope;
import org.gcube.portlets.user.workspace.server.util.UserUtil;
/** /**
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
@ -837,13 +838,11 @@ public class GWTWorkspaceBuilder {
} }
//TODO protected List<InfoContactModel> buildGxtInfoContactFromPortalLogin(List<String> listUserLogin){
//TEMP??
protected List<InfoContactModel> buildGxtInfoContactFromPortalLogin(List<String> listPortalLogin){
List<InfoContactModel> listContact = new ArrayList<InfoContactModel>(); List<InfoContactModel> listContact = new ArrayList<InfoContactModel>();
for (String portalLogin : listPortalLogin) for (String portalLogin : listUserLogin)
listContact.add(new InfoContactModel(portalLogin, portalLogin, "name")); listContact.add(new InfoContactModel(portalLogin, portalLogin, UserUtil.getUserFullName(portalLogin)));
return listContact; return listContact;
} }
@ -1422,7 +1421,7 @@ public class GWTWorkspaceBuilder {
List<InfoContactModel> listContactsModel = new ArrayList<InfoContactModel>(); List<InfoContactModel> listContactsModel = new ArrayList<InfoContactModel>();
for(User user: listUsers){ 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; return listContactsModel;
@ -1501,7 +1500,7 @@ public class GWTWorkspaceBuilder {
public InfoContactModel buildGXTInfoContactModel(User user) throws InternalErrorException{ public InfoContactModel buildGXTInfoContactModel(User user) throws InternalErrorException{
if(user!=null) 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(); return new InfoContactModel();
} }

View File

@ -1584,11 +1584,11 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder(); 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{ 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 "";
}
}