Update the list of shared classes with the tree widget

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/workspace-sharing-widget@181285 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2019-07-22 12:52:38 +00:00
parent b34e54635f
commit 7995569be9
13 changed files with 212 additions and 173 deletions

View File

@ -180,7 +180,7 @@ public class SimpleMultiDragWorkspaceContact {
* Load all contacts
*/
private void loadAllContacts(boolean readGroupsFromHL, boolean readGroupsFromPortal) {
userStore.getListContact(addSourceContacts, false, readGroupsFromHL, readGroupsFromPortal);
userStore.getListContact(addSourceContacts, false);
}
private AsyncCallback<List<InfoContactModel>> addSourceContacts = new AsyncCallback<List<InfoContactModel>>() {

View File

@ -6,6 +6,7 @@ import org.gcube.portlets.widgets.workspacesharingwidget.shared.AllowAccess;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.CredentialModel;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.ExtendedWorkspaceACL;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.FileModel;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.GGroup;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.ReportAssignmentACL;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.WorkspaceACL;
@ -61,4 +62,8 @@ public interface WorkspaceSharingService extends RemoteService {
boolean addAdministratorsByFolderId(String itemId, List<String> listContactLogins) throws Exception;
List<GGroup> getVREList() throws Exception;
List<InfoContactModel> getUsersByKeyword(String keyword) throws Exception;
}

View File

@ -6,6 +6,7 @@ import org.gcube.portlets.widgets.workspacesharingwidget.shared.AllowAccess;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.CredentialModel;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.ExtendedWorkspaceACL;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.FileModel;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.GGroup;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.ReportAssignmentACL;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.WorkspaceACL;
@ -61,4 +62,8 @@ public interface WorkspaceSharingServiceAsync {
void addAdministratorsByFolderId(String itemId, List<String> listContactLogins, AsyncCallback<Boolean> callback);
void getVREList(AsyncCallback<List<GGroup>> callback);
void getUsersByKeyword(String keyword, AsyncCallback<List<InfoContactModel>> callback);
}

View File

@ -9,7 +9,7 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
public interface ContactFetcher {
public void getListContact(AsyncCallback<List<InfoContactModel>> callback, boolean reloadList, boolean readGroupsFromHL, boolean readGroupsFromPortal);
public void getListContact(AsyncCallback<List<InfoContactModel>> callback, boolean reloadList);
public void getListSharedUserByFolderId(String sharedFolderId, AsyncCallback<List<InfoContactModel>> callback);
public List<InfoContactModel> getExclusiveContactsFromAllContact(List<InfoContactModel> listSharedUser);
public void getOwner(String sharedFolderId, AsyncCallback<InfoContactModel> callback);

View File

@ -5,6 +5,7 @@ import java.util.List;
import org.gcube.portlets.widgets.workspacesharingwidget.client.ConstantsSharing;
import org.gcube.portlets.widgets.workspacesharingwidget.client.WorkspaceSharingController;
import org.gcube.portlets.widgets.workspacesharingwidget.client.permissions.PanelTogglePermission;
import org.gcube.portlets.widgets.workspacesharingwidget.client.view.sharing.multisuggest.DialogMultiDragContact;
import org.gcube.portlets.widgets.workspacesharingwidget.client.view.sharing.multisuggest.MultiDragContact;
import org.gcube.portlets.widgets.workspacesharingwidget.client.view.sharing.multisuggest.MultiValuePanel;
@ -65,7 +66,7 @@ public class DialogShareWItem extends Dialog {
public DialogShareWItem(boolean readGroupsFromHL, boolean readGroupsFromPortal) {
this.readGroupsFromHL = readGroupsFromHL;
this.readGroupsFromPortal = readGroupsFromPortal;
suggestPanel = new MultiValuePanel(userStore, readGroupsFromHL, readGroupsFromPortal);
suggestPanel = new MultiValuePanel(userStore);
initLayout();
}
@ -162,7 +163,7 @@ public class DialogShareWItem extends Dialog {
@Override
public void onSuccess(List<WorkspaceACL> result) {
permission = new PanelTogglePermission(result, defaultACL);
permission = new PanelTogglePermission(result);
hpPermission.add(permission);
hpPermission.layout();
layout();

View File

@ -1,149 +0,0 @@
package org.gcube.portlets.widgets.workspacesharingwidget.client.view.sharing;
import java.util.List;
import org.gcube.portlets.widgets.workspacesharingwidget.client.resources.GetPermissionIconByACL;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.ACL_TYPE;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.WorkspaceACL;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.WorkspaceACL.USER_TYPE;
import com.extjs.gxt.ui.client.Style.ButtonScale;
import com.extjs.gxt.ui.client.Style.IconAlign;
import com.extjs.gxt.ui.client.Style.VerticalAlignment;
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.widget.HorizontalPanel;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.button.ToggleButton;
import com.extjs.gxt.ui.client.widget.tips.ToolTipConfig;
import com.google.gwt.core.shared.GWT;
import com.google.gwt.user.client.ui.AbstractImagePrototype;
public class PanelTogglePermission extends LayoutContainer {
protected static final String WORKSPACEACLGROUP = "WORKSPACEACLGROUPSHARING";
private HorizontalPanel hp = new HorizontalPanel();
private WorkspaceACL selectedAcl = null;
private ACL_TYPE defaultACLType;
public PanelTogglePermission(List<WorkspaceACL> acls, ACL_TYPE defaultACL) {
this.defaultACLType = defaultACL;
// setStyleAttribute("margin-top", "10px");
setStyleAttribute("margin-bottom", "15px");
setSize(350, 40);
hp.mask("Loading ACLs");
hp.setVerticalAlign(VerticalAlignment.MIDDLE);
hp.setStyleAttribute("padding-left", "35px");
for (WorkspaceACL acl : acls) {
if(acl.getUserType().equals(USER_TYPE.OTHER)){
ToggleButton toggle = createToggle(acl);
toggle.setToggleGroup(WORKSPACEACLGROUP);
toggle.setStyleAttribute("margin-right", "10px");
// buttonGroup.add(toggle);
// listToogle.add(toggle);
// add(toggle);
hp.add(toggle);
}
}
hp.unmask();
add(hp);
layout();
}
private ToggleButton createToggle(final WorkspaceACL acl) {
final ToggleButton bToggle = new ToggleButton(acl.getLabel());
bToggle.setScale(ButtonScale.MEDIUM);
bToggle.setId(acl.getId());
bToggle.setAllowDepress(false);
if(defaultACLType!=null){
GWT.log("comparing.. "+defaultACLType + " and "+acl.getAclType());
GWT.log(defaultACLType.equals(acl.getAclType())+"");
// defaultACLType.equals(acl.getAclType());
bToggle.toggle(defaultACLType.equals(acl.getAclType()));
}else{
bToggle.toggle(acl.getDefaultValue());
}
if(acl.getDefaultValue())
selectedAcl = acl;
bToggle.setIconAlign(IconAlign.TOP);
bToggle.addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
if(bToggle.isPressed()){
selectedAcl = acl;
}
}
});
bToggle.setToolTip(new ToolTipConfig(acl.getDescription()));
AbstractImagePrototype img = GetPermissionIconByACL.getImage(acl);
if(img!=null)
bToggle.setIcon(img);
// setIcon(bToggle, acl.getId());
return bToggle;
}
// private void setIcon(ToggleButton bToggle, String id){
//
// if(id.compareTo("ADMINISTRATOR")==0){
//
// }else if(id.compareTo("READ_ONLY")==0){
// bToggle.setIcon(Resources.getIconReadOnly());
// }else if(id.compareTo("WRITE_OWNER")==0){
// bToggle.setIcon(Resources.getIconWriteOwn());
// }else if(id.compareTo("WRITE_ALL")==0){
// bToggle.setIcon(Resources.getIconWriteAll());
// }
//
// }
public WorkspaceACL getSelectedACL() {
GWT.log("Selected ACL is: "+selectedAcl);
return selectedAcl;
}
/*
public List<WorkspaceACL> getCheckedGroupList() {
List<WorkspaceACL> listDS = new ArrayList<WorkspaceACL>();
List<Radio> values = new ArrayList<Radio>();
if (radioGroup.getValue()!=null){
Radio radio = radioGroup.getValue();
values.add((Radio) radio);
}
else {
List<Field<?>> listChecks = radioGroup.getAll();
for (Field<?> field : listChecks) {
values.add((Radio) field);
}
}
for (Radio radio : values) {
if (radio.isEnabled()){
WorkspaceACL acl = (WorkspaceACL) radio.getData(WORKSPACEACL);
listDS.add(acl);
}
}
if (listDS.size() == 0)
return null;
return listDS;
}
*/
}

View File

@ -66,7 +66,7 @@ public class SmartShare extends Dialog implements SmartDialogInterface{
public SmartShare(boolean readGroupsFromHL, boolean readGroupsFromPortal) {
this.readGroupsFromHL = readGroupsFromHL;
this.readGroupsFromPortal = readGroupsFromPortal;
suggestPanel = new MultiValuePanel(userStore, readGroupsFromHL, readGroupsFromPortal);
suggestPanel = new MultiValuePanel(userStore);
initLayout();
}

View File

@ -30,7 +30,7 @@ public class UserStore implements ContactFetcher{
loadSharedUserBySharedFolderId(sharedFolderId, callback);
}
private void loadAllUsersFromServer(final AsyncCallback<List<InfoContactModel>> callback, boolean readGroupsFromHL, boolean readGroupsFromPortal){
private void loadAllUsersFromServer(final AsyncCallback<List<InfoContactModel>> callback){
listAllContact = new ArrayList<InfoContactModel>();
@ -126,10 +126,10 @@ public class UserStore implements ContactFetcher{
* @see org.gcube.portlets.widgets.workspacesharingwidget.client.view.sharing.ContactFetcher#getListContact(com.google.gwt.user.client.rpc.AsyncCallback, boolean, boolean, boolean)
*/
@Override
public void getListContact(AsyncCallback<List<InfoContactModel>> callback,boolean reloadList, boolean readGroupsFromHL, boolean readGroupsFromPortal) {
public void getListContact(AsyncCallback<List<InfoContactModel>> callback,boolean reloadList) {
if(reloadList || listAllContact==null)
loadAllUsersFromServer(callback,readGroupsFromHL,readGroupsFromPortal);
loadAllUsersFromServer(callback);
else
callback.onSuccess(listAllContact);

View File

@ -41,9 +41,7 @@ public class MultiValuePanel extends Composite {
private SuggestBox box;
private ContactFetcher userFetch;
private MultiWordSuggestOracle oracle = new MultiWordSuggestOracle(); //ORACLE OF FULL NAMES
private boolean readGroupsFromHL;
private boolean readGroupsFromPortal;
/**
* Instantiates a new multi value panel.
*
@ -51,10 +49,8 @@ public class MultiValuePanel extends Composite {
* @param readGroupsFromHL the read groups from hl
* @param readGroupsFromPortal the read groups from portal
*/
public MultiValuePanel(ContactFetcher userFetch, boolean readGroupsFromHL, boolean readGroupsFromPortal) {
public MultiValuePanel(ContactFetcher userFetch) {
this.userFetch = userFetch;
this.readGroupsFromHL = readGroupsFromHL;
this.readGroupsFromPortal = readGroupsFromPortal;
initWidget(panel);
panel.setWidth("100%");
listBullet.setStyleName("multivalue-panel-suggest");
@ -128,7 +124,7 @@ public class MultiValuePanel extends Composite {
* @param list the list
*/
private void chosenContactItem(final TextBox itemBox, final BulletList list) {
if (itemBox.getValue() != null && !"".equals(itemBox.getValue().trim())) {
if (itemBox.getValue() != null && !itemBox.getValue().trim().isEmpty()) {
final ListItem displayItem = new ListItem();
displayItem.setStyleName("multivalue-panel-token-ws");
Paragraph p = new Paragraph(itemBox.getValue());
@ -193,7 +189,7 @@ public class MultiValuePanel extends Composite {
* @return names of possible contacts
*/
private MultiWordSuggestOracle getSuggestions() {
userFetch.getListContact(contacts, false,readGroupsFromHL,readGroupsFromPortal);
userFetch.getListContact(contacts, false);
return oracle;
}

View File

@ -30,13 +30,16 @@ import org.gcube.portlets.widgets.workspacesharingwidget.server.util.WsUtil;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.ACL_TYPE;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.FileModel;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.FolderModel;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.GGroup;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.GXTFolderItemTypeEnum;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.WorkspaceACL;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.WorkspaceACL.USER_TYPE;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.system.VO;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.system.VRE;
import org.gcube.vomanagement.usermanagement.GroupManager;
import org.gcube.vomanagement.usermanagement.UserManager;
import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager;
import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager;
import org.gcube.vomanagement.usermanagement.model.GCubeGroup;
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
@ -255,9 +258,9 @@ public class GWTWorkspaceSharingBuilder {
* Error
*/
public List<InfoContactModel> buildGXTListContactsModelFromUserModel(PortalContextInfo info) throws Exception {
List<GCubeUser> listUsers = new LiferayUserManager().listUsersByGroup(info.getCurrGroupId());
List<GCubeUser> listUsers = new LiferayUserManager().listUsersByGroup(info.getCurrGroupId());
if (listUsers == null) {
logger.error("No users found in: " + info.getCurrentScope());
throw new Exception("An error occurred on recovering users from Portal, try again later");
@ -283,9 +286,40 @@ public class GWTWorkspaceSharingBuilder {
return listContactsModel;
}
public List<InfoContactModel> searchUsersFromKeyword(PortalContextInfo info, String keyword) throws Exception {
public ArrayList<GGroup> getVREList(PortalContextInfo info) throws Exception {
try {
logger.debug("Search Keyword: " + keyword);
logger.info("Current context is " + info.getCurrGroupId());
ArrayList<GGroup> contexts = new ArrayList<>();
GroupManager gm = new LiferayGroupManager();
GCubeGroup currentGroup = gm.getGroup(info.getCurrGroupId());
// is root
List<GCubeGroup> children = currentGroup.getChildren();
for (GCubeGroup gCubeGroup : children) {
// get the vo children
List<GCubeGroup> childrenVO = gCubeGroup.getChildren();
for (GCubeGroup voChildren : childrenVO) {
GGroup gGroup = new GGroup(voChildren.getGroupId(), voChildren.getParentGroupId(),
voChildren.getGroupName(), voChildren.getDescription());
contexts.add(gGroup);
}
}
return contexts;
} catch (Exception e) {
logger.error("Error retrieving the list of VRE!", e);
throw new Exception("Error retrieving the list of VRE!", e);
}
}
public List<InfoContactModel> searchUsersByKeyword(PortalContextInfo info, String keyword) throws Exception {
try {
logger.debug("Search use keyword: " + keyword);
List<InfoContactModel> listInfoContactModel = new ArrayList<>();
UserManager userManager = new LiferayUserManager();
List<GCubeUser> users = userManager.searchUsersByGroup(keyword, info.getCurrGroupId());
@ -294,10 +328,9 @@ public class GWTWorkspaceSharingBuilder {
user.getFullname(), false);
listInfoContactModel.add(icm);
}
return listInfoContactModel;
} catch (Exception e) {
logger.error("Error searching user by kewords: " + e.getLocalizedMessage(), e);
logger.error("Error retrieving the users by keyword: "+e.getLocalizedMessage(), e);
throw e;
}
}

View File

@ -45,6 +45,7 @@ import org.gcube.portlets.widgets.workspacesharingwidget.shared.AllowAccess;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.CredentialModel;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.ExtendedWorkspaceACL;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.FileModel;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.GGroup;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.ReportAssignmentACL;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.SessionExpiredException;
@ -169,10 +170,50 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
} catch (Exception e) {
logger.error("Error in getAllContacts(): " + e.getLocalizedMessage(), e);
throw new Exception("Error retrieving all contacts: " + e.getLocalizedMessage(), e);
throw new Exception("Error retrieving the contacts!", e);
}
}
@Override
public List<InfoContactModel> getUsersByKeyword(String keyword) throws Exception {
try {
logger.info("Call getUsersByKeyword(): keyword="+keyword);
PortalContextInfo info = WsUtil.getPortalContext(this.getThreadLocalRequest());
GWTWorkspaceSharingBuilder builder = new GWTWorkspaceSharingBuilder();
List<InfoContactModel> listContactsModel = builder.searchUsersByKeyword(info, keyword);
logger.debug("Get Users by keyword returning a list having size: " + listContactsModel.size());
return listContactsModel;
} catch (Exception e) {
logger.error("Error in getUsersByKeyword(): " + e.getLocalizedMessage(), e);
throw new Exception("Error retrieving list of contacts!", e);
}
}
@Override
public List<GGroup> getVREList() throws Exception {
try {
PortalContextInfo info = WsUtil.getPortalContext(this.getThreadLocalRequest());
GWTWorkspaceSharingBuilder builder = new GWTWorkspaceSharingBuilder();
List<GGroup> listContactsModel = builder.getVREList(info);
return listContactsModel;
} catch (Exception e) {
logger.error("Error in getVREList(): " + e.getLocalizedMessage(), e);
throw new Exception("Error retrieving VRE List!", e);
}
}
/*
* (non-Javadoc)
*

View File

@ -0,0 +1,64 @@
package org.gcube.portlets.widgets.workspacesharingwidget.shared;
import java.io.Serializable;
public class GGroup implements Serializable {
private static final long serialVersionUID = 1L;
private long groupId;
private long parentGroupId;
private String groupName;
private String description;
public GGroup() {
super();
}
public GGroup(long groupId, long parentGroupId, String groupName, String description) {
super();
this.groupId = groupId;
this.parentGroupId = parentGroupId;
this.groupName = groupName;
this.description = description;
}
public long getGroupId() {
return groupId;
}
public void setGroupId(long groupId) {
this.groupId = groupId;
}
public long getParentGroupId() {
return parentGroupId;
}
public void setParentGroupId(long parentGroupId) {
this.parentGroupId = parentGroupId;
}
public String getGroupName() {
return groupName;
}
public void setGroupName(String groupName) {
this.groupName = groupName;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
@Override
public String toString() {
return "GGroup [groupId=" + groupId + ", parentGroupId=" + parentGroupId + ", groupName=" + groupName
+ ", description=" + description + "]";
}
}

View File

@ -0,0 +1,43 @@
/**
*
*/
package org.gcube.portlets.widgets.workspacesharingwidget.shared;
import java.io.Serializable;
import java.util.ArrayList;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
/**
*
* @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
* Nov 4, 2015
*/
public class ListContact<T extends InfoContactModel> extends ArrayList<T> implements Serializable{
private static final long serialVersionUID = 544202687567940083L;
public ListContact() {
}
public boolean contains(InfoContactModel infoContactModel) {
if(infoContactModel==null)
return false;
if(infoContactModel.getLogin()==null)
return false;
for (int i = 0; i < this.size(); i++){
InfoContactModel log = get(i);
if (log.getLogin()!=null && log.getLogin().compareTo(infoContactModel.getLogin())==0)
return true;
}
return false;
}
}