From d1f0dc7dbb0ab3a711d11339fe81a3c34b719e7e Mon Sep 17 00:00:00 2001 From: Francesco Mangiacrapa Date: Mon, 2 Sep 2013 16:16:37 +0000 Subject: [PATCH] history of share, unshare is completed git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@81006 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../workspace/server/GWTWorkspaceBuilder.java | 30 +++++++++++++------ .../user/workspace/server/util/UserUtil.java | 30 +++++++++++++++++++ .../user/workspace/server/util/WsUtil.java | 4 +-- 3 files changed, 53 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceBuilder.java b/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceBuilder.java index 69cb24b..4890657 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceBuilder.java +++ b/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceBuilder.java @@ -93,6 +93,8 @@ import org.gcube.portlets.user.workspace.server.util.WsUtil; import org.gcube.portlets.user.workspace.shared.accounting.GxtAccountingEntryType; import org.gcube.portlets.user.workspace.shared.accounting.GxtAccountingField; +import com.liferay.portal.model.Contact; + /** * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @@ -1894,17 +1896,30 @@ public class GWTWorkspaceBuilder { af.setOperation(GxtAccountingEntryType.SHARE); AccountingEntryShare acc = (AccountingEntryShare) accountingEntry; + + List listContacts = new ArrayList(); + + if(acc.getMembers()!=null && acc.getMembers().size()>0){ + + listContacts = acc.getMembers(); + } + String msg = ""; if(acc.getItemName()==null || acc.getItemName().isEmpty()) - msg = GxtAccountingEntryType.SHARE.getName()+" by "+user.getName(); + msg = user.getName() + " "+GxtAccountingEntryType.SHARE.getName()+ " workspace folder"; +// msg = GxtAccountingEntryType.SHARE.getName()+" by "+user.getName(); else - msg = acc.getItemName() +" "+GxtAccountingEntryType.SHARE.getName()+" by "+user.getName(); + msg = user.getName() + " "+GxtAccountingEntryType.SHARE.getName()+ " workspace folder "+acc.getItemName(); +// msg = acc.getItemName() +" "+GxtAccountingEntryType.SHARE.getName()+" by "+user.getName(); + + + if(listContacts.size()>0){ + + msg+=" with "+UserUtil.separateFullNameToCommaForPortalLogin(acc.getMembers()); + } af.setDescription(msg); - -// af.setDescription(GxtAccountingEntryType.UPDATE.getName()+ " "+acc.getItemName() +" by "+user.getName()); -// af.setDescription(acc.getItemName() +" "+GxtAccountingEntryType.UPDATE.getName()+" by "+user.getName()); } break; @@ -1924,14 +1939,11 @@ public class GWTWorkspaceBuilder { af.setDescription(msg); -// af.setDescription(GxtAccountingEntryType.UPDATE.getName()+ " "+acc.getItemName() +" by "+user.getName()); -// af.setDescription(acc.getItemName() +" "+GxtAccountingEntryType.UPDATE.getName()+" by "+user.getName()); } break; } - - + listAccFields.add(af); } diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/util/UserUtil.java b/src/main/java/org/gcube/portlets/user/workspace/server/util/UserUtil.java index fb48867..938b359 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/server/util/UserUtil.java +++ b/src/main/java/org/gcube/portlets/user/workspace/server/util/UserUtil.java @@ -66,4 +66,34 @@ public class UserUtil { return listUsers; } + + public static String separateUsersNamesToComma(List listContacts){ + + String users = ""; + + for (int i = 0; i < listContacts.size()-1; i++) { + users+= listContacts.get(i).getName() + ", "; + } + + if(listContacts.size()>1) + users += listContacts.get(listContacts.size()-1).getName(); + + return users; + } + + + public static String separateFullNameToCommaForPortalLogin(List listLogin){ + + String users = ""; + + for (int i = 0; i < listLogin.size()-1; i++) { + users+= getUserFullName(listLogin.get(i)) + ", "; + } + + if(listLogin.size()>1) + users += getUserFullName(listLogin.get(listLogin.size()-1)); + + return users; + } + } diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/util/WsUtil.java b/src/main/java/org/gcube/portlets/user/workspace/server/util/WsUtil.java index 411ca7c..b3cb90b 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/server/util/WsUtil.java +++ b/src/main/java/org/gcube/portlets/user/workspace/server/util/WsUtil.java @@ -71,8 +71,8 @@ public class WsUtil { if (user == null) { - user=TEST_USER; -// user = "francesco.mangiacrapa"; +// user=TEST_USER; + user = "francesco.mangiacrapa"; defaultLogger.warn("WORKSPACE PORTLET STARTING IN TEST MODE - NO USER FOUND - PORTLETS STARTING WITH FOLLOWING SETTINGS:"); defaultLogger.warn("session id: "+sessionID);